Expand description
Per-row audit verification of a JSONL ledger file.
verify_chain walks the file and returns a Report listing every
row that fails one of the canonical chain invariants, with a typed
reason (FailureReason). Unlike crate::JsonlLog::verify_chain
which short-circuits on the first failure, this audit collects all
failures so an operator can see the full damage in one pass.
Failure modes covered:
FailureReason::Orphan—prev_event_hashdoes not match theevent_hashof the row immediately preceding it.- [
FailureReason::HashBreak { kind: PayloadHashMismatch }] — the storedpayload_hashdoes not matchblake3(canonical_payload). - [
FailureReason::HashBreak { kind: EventHashMismatch }] — the storedevent_hashdoes not match the framing recompute overprev_event_hash+payload_hash. FailureReason::OrdinalGap— when ordinals are present (we don’t store them inline in the JSONL today, but external trace-event tables may carry them), a gap or duplicate is reported. For the JSONL-only audit we treat the file order as the canonical sequence and report nothing here unless callers pass an external ordinal stream (future expansion). For now, this variant exists in the public API so audit consumers don’t break when we wire SQL ordinals in.FailureReason::Decode— the row failed to parse as ancortex_core::Event.
§Acceptance test (T-1.B.4)
corruption_fixture_produces_expected_failure_report builds a
deliberately-broken file (good row, then a row with a mutated payload,
then an orphan whose prev_event_hash is wrong) and asserts the
report names exactly those failures.
Structs§
- Report
- Verification report.
- RowFailure
- One row’s failure record.
- Schema
Migration Boundary Failure - Stable failure record for the v1 -> v2 boundary invariant.
- Schema
Migration Boundary Report - Report for
verify_schema_migration_v1_to_v2_boundary. - Schema
Migration Boundary Row - One observed
schema_migration.v1_to_v2boundary row. - Signed
Chain Outcome - Outcome of
verify_signed_chainover a JSONL file.
Enums§
- Failure
Reason - What broke at a given row.
- Hash
Kind - Which hash field broke.
- Schema
Migration Boundary Failure Detail - Why the v1 -> v2 boundary invariant failed.
Constants§
- POST_
CUTOVER_ V2_ AUDIT_ DISPATCH_ UNSUPPORTED_ INVARIANT - Stable invariant name for schema v2 non-boundary rows that are recognized as post-cutover audit-dispatch work but not yet verifiable by this build.
- SCHEMA_
MIGRATION_ V1_ TO_ V2_ BOUNDARY_ DUPLICATE_ INVARIANT - Stable invariant name for duplicate v1 -> v2 boundary rows.
- SCHEMA_
MIGRATION_ V1_ TO_ V2_ BOUNDARY_ MISSING_ INVARIANT - Stable invariant name for a required v1 -> v2 boundary row that is absent.
- UNSUPPORTED_
EVENT_ SCHEMA_ VERSION_ INVARIANT - Stable invariant name for unsupported event schema versions.
Functions§
- verify_
chain - Walk
path, checking every row, and produce aReportof failures. - verify_
schema_ migration_ v1_ to_ v2_ boundary - Scan a JSONL ledger for the
schema_migration.v1_to_v2boundary row. - verify_
signed_ chain - Verify the Ed25519 signature chain end-to-end (Lane 3.D.6 / ADR 0010 §1-§2).