/** * log10x_datadog_change_report: what changed in a Datadog install since a * point in time, read from the per-pattern series the engine's Datadog * output publishes, plus the monitor definitions that watch the same series. * * view=markdown|summary: statements new in a service since `since`, each * with lines a day, estimated Standard indexing cost a month, whether a rule * held it and which (container row and action from the engine files), and * proposed per-service rows in the plan's sentence form. * * view=monitors: the route monitor and the weekly-baseline monitor as JSON * (lib/datadog-monitors.ts). Reads nothing. * * Stateless by design: "since the last run" is the `since` argument, and * every report returns `next_since` for the next call. Reads only: Datadog's * query API (GET) and the engine's caps.csv / actions.csv from the gitops * repo or the policy ConfigMap. */ import { z } from 'zod'; import type { EnvConfig } from '../lib/environments.js'; import { type DatadogMetricsCreds, type DdSeries } from '../lib/datadog-metrics-read.js'; import { type SpikeMonitors } from '../lib/datadog-monitors.js'; import { type PerEventTierPricing } from '../lib/cost.js'; import { type ChassisEnvelope } from '../lib/chassis-envelope.js'; export declare const datadogChangeReportSchema: { view: z.ZodDefault>; since: z.ZodDefault; lookback: z.ZodDefault; tenx_env: z.ZodOptional; team_tag: z.ZodOptional; action: z.ZodDefault>; headroom: z.ZodDefault; limit: z.ZodDefault; site: z.ZodOptional; notify: z.ZodOptional>; environment: z.ZodOptional; }; export interface DatadogChangeReportArgs { view?: 'markdown' | 'summary' | 'monitors'; since?: string; lookback?: string; tenx_env?: string; team_tag?: string; action?: 'tier_down' | 'offload'; headroom?: number; limit?: number; site?: string; notify?: string[]; environment?: string; } export interface PolicyFiles { /** Where the files came from, or null when neither source answered. */ source: string | null; capsCsv?: string; actionsCsv?: string; } export interface ChangeReportDeps { /** Datadog keys. Undefined reads DD_API_KEY / DD_APP_KEY / DD_SITE; null means none. */ creds?: DatadogMetricsCreds | null; readPolicy?: (env: EnvConfig | undefined) => Promise; nowMs?: () => number; } export declare function readPolicyFilesDefault(env: EnvConfig | undefined): Promise; /** actions.csv: `,[:][:]`, header `container,action`. */ export declare function parseActionsCsv(csv: string | undefined): Map; export type RuleKind = 'statement_row' | 'service_row' | 'fleet_default' | 'not_read'; export interface HoldingRule { kind: RuleKind; container: string; /** Action from actions.csv, or the observed route when the file has no row. */ action: string; text: string; } export interface NewStatement { pattern: string; pattern_hash: string; container: string; service: string; team: string | null; routes: string[]; first_seen_iso: string | null; lines_a_day: number; held_lines_a_day: number; standard_usd_month: number; held: boolean; rule: HoldingRule | null; } export interface ProposedRow { container: string; lines_a_day_limit: number; basis: 'service' | 'fleet'; action: 'tier_down' | 'offload'; statements: Array<{ pattern: string; pattern_hash: string; lines_a_day: number; standard_usd_month: number; }>; standard_usd_month: number; sentence: string; } export interface ChangeReport { since_iso: string; until_iso: string; next_since: string; window_days: number; team_tag: string | null; statements: NewStatement[]; statement_count_total: number; held_count: number; standard_usd_month_total: number; proposed_rows: ProposedRow[]; services_without_proposal: string[]; policy_source: string | null; pricing: { standard_usd_per_million_events: number; text: string; }; caveats: string[]; } export interface BuildChangeReportInput { current: DdSeries[]; prior: DdSeries[]; sinceSec: number; nowSec: number; teamTag: string | null; policy: PolicyFiles; action: 'tier_down' | 'offload'; headroom: number; limit: number; pricing?: PerEventTierPricing; } export declare function fmtLinesADay(n: number): string; export declare function fmtUsdMonth(v: number): string; export declare function standardUsdMonth(linesADay: number, pricing?: PerEventTierPricing): number; export declare function buildChangeReport(input: BuildChangeReportInput): ChangeReport; export declare function reportHeadline(r: ChangeReport): string; export declare function renderChangeReportMarkdown(r: ChangeReport, opts?: { tenxEnv?: string; }): string; export declare function renderMonitorsMarkdown(m: SpikeMonitors): string; export declare function parseSince(since: string, nowSec: number): number | null; export declare function executeDatadogChangeReport(args: DatadogChangeReportArgs, env?: EnvConfig, deps?: ChangeReportDeps): Promise;