/** * log10x_metrics_that_moved — deterministic primitive: list customer * metrics whose value during an anchor's incident window meaningfully * differs from their value during the anchor's quiet baseline phase. * * Design rationale (from the design-dilemma consult): movement is the * first filter a sharp SRE applies. "What was different DURING the * incident than otherwise?" answers that. Without this filter, the * candidate pool stays at hundreds-to-thousands of metrics at customer * scale, and Pearson on a flat-but-correlated-by-shape gauge co-occurs * with real movement and gets ranked alongside it. * * The deterministic rule: partition the anchor's bucket grid into * "anchor high-phase" (anchor > anchor median) and "anchor low-phase". * For each candidate, compute its mean during each phase. Keep the * candidate when |mean_high - mean_low| / max(|mean_high|, |mean_low|) * ≥ threshold (default 15%). Surfaced as a standalone filter, returnable * as a deterministic candidate list before any Pearson pass runs. * * NOT a correlation tool. Returns the list of metrics that moved with * the anchor's phase + the magnitude of the move. Pearson lives in * rank_by_shape_similarity; visual overlay lives in metric_overlay. */ import { z } from 'zod'; import type { EnvConfig } from '../lib/environments.js'; import { type StructuredOutput } from '../lib/output-types.js'; /** Default phase-gap floor. Hand-picked, uncalibrated — see README "Threshold provenance". */ export declare const DEFAULT_PHASE_GAP_FLOOR = 0.15; /** * Extract the leading metric name from a PromQL candidate string. Strips * a single layer of common rate-style wrappers (`rate(...)`, `sum(...)`, * `avg(...)`, `irate(...)`, `increase(...)`) so wrapped meta-metrics * like `rate(scrape_duration_seconds[5m])` still get caught. Returns * null when no recognizable metric name leads the expression. */ export declare function extractLeadingMetricName(expr: string): string | null; /** * Return `true` when the candidate's leading metric name is on the * Prometheus meta-metric blacklist (see `META_METRIC_NAME_REGEX`). */ export declare function isMetaMetricCandidate(expr: string): boolean; export declare const metricsThatMovedSchema: { anchor_type: z.ZodEnum<["log10x_pattern", "customer_metric"]>; anchor: z.ZodString; candidates: z.ZodArray; window: z.ZodDefault; timeRange: z.ZodOptional; step: z.ZodDefault; phase_gap_floor: z.ZodDefault; environment: z.ZodOptional; customer_metrics_url: z.ZodOptional; customer_metrics_type: z.ZodOptional>; customer_metrics_auth: z.ZodOptional; }; /** * Top-level call status. Agent branches on this before reading anything else. * - `success`: math ran cleanly; read `moved[]` / `not_moved[]`. * - `anchor_no_phase_separation`: anchor MAD/median < 0.15. Refused. * Agent should re-anchor with a clearer log pattern. * - `no_signal`: search completed, but every candidate either failed or * fell below the threshold. Agent should stop, not retry. * - `error`: a structural failure (backend down, schema invalid, etc.). * Read `data.error` for the structured envelope. */ export type MetricsThatMovedStatus = 'success' | 'anchor_no_phase_separation' | 'no_signal' | 'error'; export declare function executeMetricsThatMoved(args: { anchor_type: 'log10x_pattern' | 'customer_metric'; anchor: string; candidates: string[]; window?: string; timeRange?: string; step?: string; phase_gap_floor?: number; environment?: string; customer_metrics_url?: string; customer_metrics_type?: string; customer_metrics_auth?: string; /** Ignored. Retained in the signature for backward-compat with * existing in-process callers; the markdown view was removed from * the public schema in favor of the structured `human_summary` * field that lives inside the success envelope. */ view?: 'summary' | 'markdown'; }, env: EnvConfig): Promise; export interface AnchorPartition { median: number; highTs: Set; lowTs: Set; } export declare function partitionAnchorByMedian(anchorSeries: Array<[number, number]>): AnchorPartition; export type MovedSignal = { kind: 'failed'; } | { kind: 'evaluated'; meanHigh: number; meanLow: number; phaseGap: number; direction: 'co' | 'anti'; nHigh: number; nLow: number; }; export declare function computeMovedSignal(anchor: AnchorPartition, candSeries: Array<[number, number]>, stepSeconds: number): MovedSignal; export declare function inSetWithin(s: Set, ts: number, tolerance: number): boolean;