/** * PerfMonitor, collects metrics from the runtime store and evaluates * them against registered performance budgets. * * The monitor maintains a violation streak counter per budget so that * transient spikes do not trip CI; only sustained regressions fail. */ import type { SurfacePerfDomainState } from '../store/domains/surface-perf.js'; import type { PerfBudget, PerfReport } from './types.js'; /** * Snapshot of runtime state provided to the monitor for metric extraction. * Callers supply this from the store or from test fixtures. */ export interface PerfSnapshot { /** Current surface performance domain state. */ surfacePerf: SurfacePerfDomainState; /** * Optional additional metric overrides keyed by metric name. * Useful for injecting tool executor or compaction metrics from * other subsystems that are not yet reflected in the store domain. */ extraMetrics?: Record | undefined; } /** * PerfMonitor collects metrics from a runtime snapshot, evaluates them * against a set of performance budgets, and tracks consecutive violation * streaks per budget. * * @example * ```ts * const monitor = new PerfMonitor(); * const report = monitor.evaluate(snapshot); * if (!report.passed) process.exit(1); * ``` */ export declare class PerfMonitor { private readonly budgets; /** Maps budget metric name to number of consecutive violations. */ private readonly streaks; /** Heap snapshot from the previous evaluation, used to compute growth delta. */ private _previousHeapUsedBytes; constructor(budgets?: PerfBudget[]); /** * Extracts PerfMetrics from a PerfSnapshot. * * Metrics derived from SurfacePerfDomainState: * - frame.render.p95, p95 of recentCycles.durationMs * - memory.growth.bytes_per_hour, heap growth rate since previous evaluate() * * Metrics from extraMetrics (pass-through): * - event.queue.depth * - tool.executor.overhead.p95 * - compaction.latency.p95 */ private extractMetrics; /** * Evaluates the given snapshot against all registered budgets. * Updates internal violation streak counters. * * @param snapshot - Runtime state snapshot to evaluate. * @returns A PerfReport summarising metrics and active violations. */ evaluate(snapshot: PerfSnapshot): PerfReport; /** Resets all violation streak counters. */ reset(): void; /** Returns the current violation streak for a given metric, or 0. */ streak(metric: string): number; } //# sourceMappingURL=monitor.d.ts.map