import { b as Cmd, c as Sub, M as Machine } from '../core-sEWVgnpI.js'; import { B as BootingRuntime } from '../runtime-types-f231H8Gq.js'; import { T as Trace, R as RecorderOptions } from '../index-DvlQz14y.js'; import '@standard-schema/spec'; /** * the record → replay → normalized-diff go/no-go gate. * * The parity spike proved the mechanism already composes from in-tree * primitives: `recorder` captures the starting State and Msg sequence, * `replayTrace` re-folds it purely, and `trace-replay`'s order-insensitive deep-equal diffs * the result. Non-determinism is a RECORD-TIME property — ids/timestamps freeze * into the recording, `replayTrace` never re-mints them — so the same recording * replays byte-identical every time. * * This module is the thin packaging over that substrate plus the one genuinely * new helper, `normalizeForParity`: the finding-normalizer that strips * record-time non-determinism (generated ids/timestamps) and stable-key-sorts * collections, so an OLD-engine golden run and a NEW-engine run diff as equal * exactly when they are behaviourally equivalent. Every domain (audit, auth, * ingest, …) gets its old-vs-new parity check without reinventing the capture, * the normalization, and the diff. * * ```text * recordRun(runtime) → Recording // wraps the recorder * goldenReplay(machine, rec) → State // wraps replayTrace * normalizeForParity(schema) → (finding) => norm // strip + stable-sort * parityEqual(a, b) → boolean // normalized deep-equal * ``` * * @packageDocumentation */ /** * A live parity recording attached to a Runtime — the go/no-go gate's golden * artifact. Wraps a {@link recorder}: drive the runtime, then snapshot with * {@link Recording.trace} (or hand the live `Recording` straight to * {@link goldenReplay}, which snapshots for you). * * @typeParam S - the machine's State type. * @typeParam M - the machine's Msg union. */ interface Recording { /** * Snapshot the recording so far as a replayable {@link Trace} — `loaded` * (boot state), the ordered non-null `msgs`, and `finalState`. Sufficient to * reproduce the run via {@link goldenReplay}. Fresh object each call. */ trace(): Trace; /** Serialize the recording as JSONL (see {@link recorder}'s `toJSONL`). */ toJSONL(): string; /** Detach the underlying observer. Idempotent. */ stop(): void; } /** * Attach a parity recording to a Runtime, reusing the `recorder`/`historyTracker` * capture (the boot observe for `loaded` + every non-null msg in order) rather * than a fresh observer path. * * Attach on the synchronous `run()` handle so the boot transition is captured * as `loaded`; drive the runtime; then `trace()` (or pass the handle to * {@link goldenReplay}). See {@link RecorderOptions} for `captureSteps` (needed * only for the per-step / resume-cache-prefix inspection, not for replay). */ declare function recordRun(runtime: BootingRuntime, opts?: RecorderOptions): Recording; /** * Reproduce a recording's final State by folding from its captured post-init * State. Calls no init, handlers, Store operations or Sub runners. Accepts a * live {@link Recording} or a bare {@link Trace}. * * `ctx` is an optional legacy argument; recorded replay needs no init context. */ declare function goldenReplay(machine: Machine, recording: Recording | Trace, ctx?: Ctx): S; /** Configuration for {@link normalizeForParity}. */ interface ParitySchema { /** * Object keys stripped wherever they appear — the record-time * non-determinism `replay` never re-mints. Default: `id`, `runId`, * `timestamp`. */ readonly stripKeys?: readonly string[]; /** * Candidate keys used to stable-sort arrays of objects. For each array the * first candidate present (as a primitive) on the items decides the order; * arrays with no candidate fall back to canonical-JSON order. Default: * `ruleId`, `selector`, `url`. */ readonly sortKeys?: readonly string[]; } /** * Build a finding-normalizer: a pure `(value) => normalized` that strips the * schema's `stripKeys`, recursively sorts object keys, and stable-key-sorts * arrays by the schema's `sortKeys`. Two runs that differ only in generated * ids/timestamps or intra-effect ordering normalize to a byte-identical value, * so {@link parityEqual} on the normalized pair reflects behavioural (not incidental) * difference. */ declare function normalizeForParity(schema?: ParitySchema): (value: unknown) => unknown; /** * The parity verdict: `true` iff `a` and `b` are structurally equal. Reuses * `trace-replay`'s order-insensitive deep-equal (the comparator the * record/replay lane owns) rather than adding another boolean deep-compare — * feed it the pair produced by {@link normalizeForParity} for the * normalized-JSON equality the gate rests on. */ declare function parityEqual(a: unknown, b: unknown): boolean; export { type ParitySchema, RecorderOptions, type Recording, Trace, goldenReplay, normalizeForParity, parityEqual, recordRun };