/** * Outcome reconciliation — record what actually happened after the kernel's * Decision. * * Per SA2 Rec 6, this is the substrate for "decision accuracy" analytics: * the kernel said EXECUTE, then upstream observation says the action * succeeded (or failed, or was withdrawn). Sinks accept retrospective * outcomes keyed by `intentHash` so audit rows can be joined with reality. * * v0 is a strict push API — no expiry, no compaction, no consensus across * sinks. Production adopters wire `PostgresOutcomeSink` from * `@adjudicate/audit-postgres` (Phase 1.5C) for durable storage. */ import { z } from "zod"; export type ObservedOutcome = "succeeded" | "failed" | "withdrawn"; export interface RetrospectiveOutcome { /** * intentHash of the AuditRecord this outcome reconciles. The Postgres * sink joins on this column. */ readonly intentHash: string; readonly observed: ObservedOutcome; /** ISO-8601 wall-clock when the outcome was observed. */ readonly at: string; /** Free-form note carrying operator context. Bounded by adopters. */ readonly note?: string; } /** * Wire schema for `RetrospectiveOutcome`. Enforces a 2000-character cap on * `note` so unbounded operator text cannot inflate audit storage or bypass * downstream column limits. Call `RetrospectiveOutcomeWireSchema.parse(raw)` * at API boundaries (tRPC mutation handler, REST adapter) before forwarding * to `recordRetrospectiveOutcome`. * * APIReviewer-011: `note` has no length cap at the interface level; the Zod * schema is the authoritative wire-boundary enforcement point. */ export declare const RetrospectiveOutcomeWireSchema: z.ZodObject<{ intentHash: z.ZodString; observed: z.ZodEnum<{ succeeded: "succeeded"; failed: "failed"; withdrawn: "withdrawn"; }>; at: z.ZodString; note: z.ZodOptional; }, z.core.$strip>; export interface OutcomeSink { recordOutcome(outcome: RetrospectiveOutcome): void | Promise; } export declare function setOutcomeSink(sink: OutcomeSink): void; /** Has an OutcomeSink been explicitly installed via setOutcomeSink? */ export declare function hasOutcomeSink(): boolean; /** @internal — for tests. */ export declare function _resetOutcomeSink(): void; /** * Module-level helper — adopters compose `setOutcomeSink(yourSink)` once at * boot, then forward retrospective observations through this function. * * ConcurrencyReviewer-008: outcome-sink failures are swallowed and routed to * `recordSinkFailure` telemetry (sink: "outcome") rather than propagated to * the caller. This mirrors the learning-sink and guard-stats best-effort * pattern — telemetry must never crash the path that records it, and a * transient sink outage (e.g. a Postgres blip) must not surface as a thrown * error at every operator-driven call site. Operators observe the failure on * the metrics dashboard; the helper always resolves. */ export declare function recordRetrospectiveOutcome(outcome: RetrospectiveOutcome): Promise; /** * Default cap on the number of distinct `intentHash` entries an * {@link InMemoryOutcomeSink} retains. Sized so dev/test workloads never * notice it, while a long-lived process cannot accumulate retrospective * outcomes without bound. Override via the constructor's `maxEntries`. */ export declare const DEFAULT_MAX_OUTCOME_ENTRIES = 50000; export interface InMemoryOutcomeSinkOptions { /** * MemoryReviewer-004: hard cap on retained entries. When a *new* * `intentHash` would push the map past this size, the oldest-inserted * entry is evicted (FIFO). Defaults to {@link DEFAULT_MAX_OUTCOME_ENTRIES}. */ readonly maxEntries?: number; } /** * In-memory accumulator. Useful for tests, dev, and adopters who don't * need durable storage yet. * * The map is keyed by `intentHash`; later observations overwrite earlier * ones (last-write-wins). Adopters who need full history install a * Postgres sink and append rather than overwrite. * * MemoryReviewer-004: the map is bounded by `maxEntries` with FIFO eviction * of the oldest-inserted entry. Re-recording an existing `intentHash` keeps * its original insertion position (Map semantics), so refreshing a known * outcome never evicts a neighbour. */ export declare class InMemoryOutcomeSink implements OutcomeSink { private readonly memo; private readonly maxEntries; constructor(options?: InMemoryOutcomeSinkOptions); recordOutcome(outcome: RetrospectiveOutcome): void; get(intentHash: string): RetrospectiveOutcome | undefined; all(): readonly RetrospectiveOutcome[]; } //# sourceMappingURL=outcomes.d.ts.map