/** * Legacy v1 → v2 envelope compatibility for replay reads. * * Pre-T8 envelopes hashed `(version, kind, payload, createdAt, actor, taint)`. * v2 hashes `(version, kind, payload, nonce, actor, taint)`. Replay * harnesses reading historical rows need to reconstruct envelopes that * still produce the SAME intentHash the original kernel computed — * otherwise replay reports false-positive drift on every pre-T8 record. * * `legacyV1ToV2(row)` synthesizes a v2 envelope from a v1 row by: * - reading the stored envelope_jsonb (which carries the original * `createdAt` and lacks `nonce`). * - using the original `createdAt` AS the nonce (the same string that * the v1 hash used as its idempotency key, even if implicitly). * * The resulting v2 envelope has: * - `version: 2` * - `nonce` = original `createdAt` * - same `kind`, `payload`, `actor`, `taint`, `createdAt` * - a v2 hash recomputed over the v2 recipe. * * **Important:** the v1 row's `intent_hash` and the synthesized v2 * envelope's `intentHash` will NOT match — they were computed from * different recipes. The replay harness must compare against the v1 * `intent_hash` separately when reading pre-T8 rows; the v2 envelope is * only useful for re-running `adjudicate()` to detect Decision drift. */ import { type IntentEnvelope, type RecordedAuthoritySnapshot } from "@adjudicate/core"; import type { IntentAuditRow } from "./postgres-sink.js"; /** * Promote a stored v1 row to a v2 envelope. The synthesized nonce is the * v1 row's original createdAt — the closest stand-in available. * * For a row that already has `nonce !== null` (a v2 row), this function * returns a faithful v2 envelope with the original nonce; for v1 rows * (record_version === 1 OR null OR `nonce === null`), it synthesizes. */ export declare function legacyV1ToV2(row: IntentAuditRow): IntentEnvelope; /** * 033 — degrade-safe read of the RECORDED authority snapshot from a stored audit * row, for the legacy/replay reader. * * The recorded authority snapshot (`{ graph, snapshotHash }`) is a record-level * field 033 added to `AuditRecord` (recorded so the decision replays bit- * identically — §D-5, invariant #5). OLDER audit rows predate it: they carry no * snapshot at all. This helper makes that degradation EXPLICIT and SAFE — exactly * the drop-safe posture `legacyV1ToV2` takes for `resourceRefs`: * * - A row whose stored `envelope_jsonb` (or a future dedicated column) carries * a structurally-valid recorded snapshot returns it verbatim. * - A legacy row that lacks one returns `undefined` — the reconstructed * `AuditRecord` simply omits `authoritySnapshot` (no key), so it stays * byte-identical to its pre-033 shape and `verifyAuditRecord` re-derives the * same auditHash (no false-positive tampering). * * NEVER throws on a malformed/absent snapshot: a tolerant reader degrades to * "no recorded snapshot" rather than failing a historical-row read (the snapshot * INTEGRITY check belongs to `authorityGraphStoreFromRecorded` at replay time, * not to a legacy read). Pure: no clock/RNG/IO. */ export declare function recordedAuthoritySnapshotFromRow(row: IntentAuditRow): RecordedAuthoritySnapshot | undefined; //# sourceMappingURL=legacy-v1-compat.d.ts.map