/** * Postgres-backed OutcomeSink + OutcomeLookup. Plugs into core's * `recordRetrospectiveOutcome` flow and the admin-sdk's * `governance.decisionAccuracy` query. * * Writes are append-only into `audit_outcomes` (one row per observation). * The lookup interface returns the most recent observation for a given * `intentHash` — multiple-observation history is queryable via the table * directly but isn't part of the in-memory shape the SDK consumes. */ import type { OutcomeSink, RetrospectiveOutcome } from "@adjudicate/core"; import type { PostgresReader } from "./pg-reader.js"; export interface OutcomesWriter { insertOutcome(args: { readonly intentHash: string; readonly observed: RetrospectiveOutcome["observed"]; readonly at: string; readonly note: string | null; }): Promise; } export declare const INSERT_OUTCOME_SQL = "\nINSERT INTO audit_outcomes (intent_hash, observed, observed_at, note)\nVALUES ($1, $2, $3, $4)\nON CONFLICT (intent_hash, observed_at) DO NOTHING\n"; export interface CreatePostgresOutcomeSinkDeps { readonly writer: OutcomesWriter; } export declare function createPostgresOutcomeSink(deps: CreatePostgresOutcomeSinkDeps): OutcomeSink; /** * Read-side lookup for `governance.decisionAccuracy`. Returns the most * recent observation per `intentHash`. Queried per-record by the * decision-accuracy handler. */ export declare function createPostgresOutcomeLookup(deps: { readonly reader: PostgresReader; }): { get(intentHash: string): RetrospectiveOutcome | undefined; }; /** * Bulk preload for the accuracy handler: fetch all outcomes whose * `observed_at` falls in the inclusive window [sinceIso, untilIso] and return * them indexed by intentHash (latest observation wins). The admin-sdk handler * can build the in-memory lookup from this. * * Inclusive bounds on both ends (APIReviewer-003 boundary convention): an * observation whose `observed_at` equals `untilIso` IS included, so the * `decisionAccuracy` window join stays consistent with the audit query window. */ export declare function loadOutcomesWindow(reader: PostgresReader, args: { readonly sinceIso: string; readonly untilIso?: string; }): Promise>; //# sourceMappingURL=outcomes-store.d.ts.map