Expand description
Append-only JSONL event log: JsonlLog.
Per BUILD_SPEC §7, the JSONL mirror is a peer to the SQLite store: it provides inspectability (one event per line, grep-able) and disaster recovery (the full ledger can be rebuilt from this file alone). Append-only, fsync-per-write, and hash-chained.
§Append protocol
- The caller hands
JsonlLog::appendanEvent. - The log sets
prev_event_hashto its current head (orNonefor the first event). - The log re-seals the event via
crate::hash::seal, which recomputes bothpayload_hashandevent_hashunder the canonical framing. - The log writes one JSON line +
\n, then fsyncs the file. - The new
event_hashbecomes the head.
Re-sealing on append means callers don’t need to pre-populate the hashes (they’re an artifact of the chain, not the event’s identity).
§Why fsync per write
The JSONL log is the disaster-recovery source of truth. An event that is “appended” but lost on power loss leaves the SQL store ahead of the mirror — defeating the mirror’s purpose. We pay the latency cost (~1ms-10ms per write on commodity SSDs) in exchange for crash safety. Higher-throughput modes (group commit, periodic fsync) are a future optimization gated on a config flag and an ADR.
§What this module does NOT do
- Replicate the chain to remote storage (out of scope; future ADR).
- Compact or rotate the log (out of scope for v0; planned for Phase 4).
- Index the log (the SQL store is the queryable surface).
Structs§
- Jsonl
Iter - Owning iterator over a
JsonlLog. - Jsonl
Log - Append-only JSONL log handle.
- Signed
Jsonl Iter - Owning iterator over a
JsonlLogyielding fullSignedRowenvelopes (event + optional signature). Used by the Ed25519-aware audit verifier incrate::audit::verify_signed_chain.
Enums§
- Jsonl
Error - Errors raised by
JsonlLog.
Constants§
- APPEND_
ATTESTATION_ REQUIRED_ RULE_ ID - Required contributor rule id documenting that attestation requirements
(ADR 0010 §1, ADR 0014 §3, ADR 0026 §4) composed into the policy
decision for an unsigned JSONL append. The contributor MUST vote
AllowforEventSource::User; the ledger refuses authority-bearing rows that lack attestation. - APPEND_
EVENT_ SOURCE_ TIER_ GATE_ RULE_ ID - Required contributor rule id documenting that the event source tier gate
composed into the policy decision for an unsigned JSONL append
(ADR 0019 §3, ADR 0026 §2). The ledger refuses
EventSource::Userrows when the final outcome isPolicyOutcome::RejectorPolicyOutcome::Quarantine. - APPEND_
RUNTIME_ MODE_ RULE_ ID - Required contributor rule id documenting that the runtime mode gate
(ADR 0037 §2) composed into the policy decision for an unsigned JSONL
append. Local-development unsigned ledgers register a
Warn; trusted modes registerRejectto prevent unsigned rows from being passed off as authority grade. - APPEND_
SIGNED_ KEY_ STATE_ CURRENT_ USE_ RULE_ ID - Required contributor rule id documenting that the signing key state at
event time satisfies ADR 0023 current-use revalidation for a signed
JSONL append. Historical-only or revoked keys vote
Rejecthere. - APPEND_
SIGNED_ TRUST_ TIER_ MINIMUM_ RULE_ ID - Required contributor rule id documenting that the signing principal’s
trust tier satisfies the ADR 0019 minimum for a signed JSONL append.
Principals below
VerifiedvoteRejecthere. - SCHEMA_
MIGRATION_ ATTESTATION_ REQUIRED_ RULE_ ID - Required contributor rule id documenting that a fresh operator attestation
(ADR 0010 §1-§2) was supplied over the proposed v1 -> v2 boundary payload.
Absent or invalid attestation votes
Reject. ADR 0026 §4 forbidsBreakGlasssubstituting for this contributor at the migration authority root. - SCHEMA_
MIGRATION_ AUTHORITY_ CLASS_ RULE_ ID - Required contributor rule id documenting that the proposing principal sits
in the
Operatorauthority class (ADR 0019 §3) for a v1 -> v2 schema migration boundary append. Non-operator principals voteRejecthere; the rule is documented as authority-class so a future ADR 0019 §7 scopedtier_admincapability can satisfy the same contributor. - SCHEMA_
MIGRATION_ CURRENT_ USE_ TEMPORAL_ AUTHORITY_ RULE_ ID - Required contributor rule id documenting that the signing key supplied for
the operator attestation is in current use (ADR 0023 §2 / §5): the key
state at attestation time is
Active, notRetiredorRevoked. A historical-only signing key votesRejecthere; ADR 0026 §4 forbidsBreakGlasssubstituting for this contributor.
Functions§
- append_
policy_ decision_ test_ allow - Build a
PolicyDecisionthat satisfiesJsonlLog::appendinputs for the happy path. Intended for tests and fixtures only. - append_
signed_ policy_ decision_ test_ allow - Build a
PolicyDecisionthat satisfiesJsonlLog::append_signedinputs for the happy path. Intended for tests and fixtures only; seeappend_policy_decision_test_allowfor the production-caller contract. - schema_
migration_ v1_ to_ v2_ policy_ decision_ test_ allow - Build a
PolicyDecisionthat satisfiesJsonlLog::append_schema_migration_v1_to_v2inputs for the happy path. Intended for tests and fixtures only.