/** * Pure run-metrics aggregator. Takes parsed events from the event log and * produces a structured RunMetrics summary: per-stage timings, commits, * retries, verdicts, and final lifecycle status. * * No token/cost fields yet — those require grounding Pi's real JSONL usage * shape first (see run-output-ux/04). The schema reserves a `usage?` field * so it can be added later without a breaking change. * * Pure (no I/O) so it is unit-tested directly with event fixtures. */ import type { LoggedEvent } from "./event-log.ts"; /** Per-stage metrics derived from event sequences. */ export interface StageMetrics { stage: string; title: string; /** Human-readable role inferred from event kinds. */ role: "planner" | "designer" | "worker" | "verifier"; startedAt: string; endedAt?: string; wallMs?: number; verdict?: "pass" | "fail"; commits: string[]; retries: number; haltReason?: string; } /** Aggregate totals across all stages. */ export interface RunTotals { commits: number; retries: number; pass: number; fail: number; } /** Final lifecycle status of the run. */ export type RunLifecycle = "done" | "halted" | "partial"; /** The complete metrics summary for a run. */ export interface RunMetrics { issue: string; lifecycle: RunLifecycle; haltReason?: string; totalWallMs?: number; stages: StageMetrics[]; totals: RunTotals; malformedCount: number; workflowTier?: string; } /** * Aggregate parsed events into a structured RunMetrics. Expects events * sorted chronologically (as they come from the JSONL file). */ export declare function aggregateMetrics(events: LoggedEvent[]): RunMetrics;