/** * fold(event log) → RunState-shaped phase snapshot (RFC §6.4, S1). * * Pure reduce over {@link Event} / legacy TraceEvent-compatible records. * Does **not** spawn processes or touch disk. Used by: * - S1 differential: assert fold(log) matches phase statuses the imperative * runtime would have left in RunState * - S3 replay: re-fold under alternate knobs (thresholds/budget) without * re-entering the driver * * Never throws. */ import type { Event, EventDecision } from "./events.ts"; import type { UsageStats } from "../usage.ts"; /** Per-phase folded snapshot (subset of PhaseState the runtime persists). */ export interface FoldedPhase { phaseId: string; status: "pending" | "running" | "done" | "failed" | "blocked" | "skipped" | "timedOut"; /** Last recorded text output (subagent or decision summary). */ output?: string; error?: string; /** Accumulated usage from subagent-call events. */ usage: UsageStats; /** Last decision event for this phase (gate / when / cache / …). */ decision?: EventDecision; /** Number of subagent-call events seen. */ subagentCalls: number; startedAt?: number; endedAt?: number; } /** Whole-run fold result. */ export interface FoldedRun { runId: string; phases: Record; /** Events that could not be associated with a phaseId (malformed). */ orphans: number; /** Total events folded. */ eventCount: number; } /** * Reduce an ordered event list into a per-phase snapshot. * Accepts {@link Event} (with `v`) or plain TraceEvent-shaped records. */ export declare function foldEvents(events: readonly Event[]): FoldedRun; //# sourceMappingURL=fold.d.ts.map