/** * log10x_metric_overlay — deterministic primitive: return two timeseries * pre-aligned to the same timestamp grid, plus a small set of deterministic * facts the agent can read directly (peak_at, peak_value, peak_offset). * * Design rationale (from the design-dilemma consult + the chaos retest): * the agent's hardest call in cross-pillar correlation is "does this * candidate's curve actually lead/lag/co-move with the anchor's curve." * Pearson collapses that into one number; correlation tier compresses * further. The agent then has to trust the tool's verdict OR ask for * the raw curves anyway. This primitive gives the curves directly with * NO interpretation layer — no Pearson, no tier, no causal claim. The * agent eyeballs lead/lag the same way an SRE opens two Grafana panels * side by side. * * Inputs: anchor expression (a Log10x pattern OR a customer PromQL), * candidate expression (a customer PromQL), window + step. * * Output: aligned arrays of `(ts, anchor_value, candidate_value)` tuples * plus deterministic facts: * - peak_anchor_at, peak_anchor_value * - peak_candidate_at, peak_candidate_value * - peak_offset_seconds (candidate_peak_ts - anchor_peak_ts; negative * = candidate leads anchor) * - n_buckets_aligned (how many buckets where both series have data) * * No Pearson. No tier. No verdict. Composes with rank_by_shape_similarity * (when the agent has many candidates) and metrics_that_moved (when the * agent is narrowing the candidate pool first). */ import { z } from 'zod'; import type { EnvConfig } from '../lib/environments.js'; import { type StructuredOutput } from '../lib/output-types.js'; export declare const metricOverlaySchema: { anchor_type: z.ZodEnum<["log10x_pattern", "customer_metric"]>; anchor: z.ZodString; candidate: z.ZodOptional; candidates: z.ZodOptional>; window: z.ZodDefault; timeRange: z.ZodOptional; step: z.ZodDefault; max_buckets: 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 `series` and `facts`. * - `anchor_no_phase_separation`: anchor MAD/median < 0.15. Refused. * - `no_signal`: anchor or candidate returned no overlapping data. * - `error`: structural failure; read `data.error`. */ export type MetricOverlayStatus = 'success' | 'anchor_no_phase_separation' | 'no_signal' | 'error'; export declare function executeMetricOverlay(argsInput: { anchor_type: 'log10x_pattern' | 'customer_metric'; anchor: string; candidate?: string; candidates?: string[]; window?: string; timeRange?: string; step?: string; max_buckets?: number; environment?: string; customer_metrics_url?: string; customer_metrics_type?: string; customer_metrics_auth?: string; /** Ignored. Retained for backward-compat with in-process callers. */ view?: 'summary' | 'markdown'; }, env: EnvConfig): Promise; export declare function peakOf(points: Array<{ ts: number; v: number | null; }>): { ts: number; v: number; } | null;