Skip to main content

Module sanctuary_audit_dag

Module sanctuary_audit_dag 

Source
Expand description

Sanctuary audit DAG (vault v2, slice A) — the append-only, per-session-branch log a coercer’s actions get recorded into.

This module sits on top of the crypto primitives in super::sanctuary_audit — it does not re-implement any of them. Each record carries an opaque sealed blob (produced by super::sanctuary_audit::seal_to in the real design) that only the real lane can super::sanctuary_audit::open_sealed; the DAG stores it verbatim and never inspects it.

§What the DAG guarantees

Records are content-addressed and hash-chained with chain_hash: a record’s id is chain_hash(&parent, &canonical_bytes(record)), and each record’s parent is the previous record’s id. Because canonical_bytes is a deterministic, unambiguous (length-prefixed) encoding of the content fields, any of the following becomes detectable by verify_chain:

  • Rewrite — changing any content field changes the recomputed idTampered.
  • Reorder / broken link — a record whose parent no longer matches its predecessor’s idBrokenLink.
  • Drop — removing a middle record breaks the successor’s parent link ⇒ BrokenLink.

§What the DAG does not guarantee — a deliberate honesty note

derive_sessions groups records by branch_ref (one branch per duress-unlock entry point). The number of sessions is the number of distinct entry-point unlocks. This is a proxy, not a verified head-count of attackers: shared credentials (many people, one branch) and one persistent actor opening many sessions (one person, many branches) both fool it. Treat the count as a loose lower/upper-bound signal, never as evidence of “how many people”.

Structs§

AuditRecord
One append-only node in the audit DAG.
Routing
The outcome of retention routing: records destined for the archive vs. the human-triage inbox.
Session
A derived view of one branch as a session. records are ordered by chain linkage where the branch is well-formed, falling back to unix order otherwise.

Enums§

AuditAction
The kind of action a session recorded. Other carries a free-form label for anything not in the fixed set. Serialized in snake_case (e.g. open_session, add_note, {"other":"..."}).
ChainStatus
Result of verifying one branch’s chain integrity.
RetentionMode
How records are routed once they arrive from a duress session. Serialized in snake_case.

Functions§

canonical_bytes
The deterministic content encoding hashed into a record’s id. Encodes, in a fixed order and with unambiguous framing, every content field except id: branch_ref, actor_did, role, stated_purpose, action, unix, sealed.
derive_sessions
Group records into sessions, one per distinct branch_ref.
route
Route records according to the retention policy.
verify_chain
Verify the integrity of a single branch’s records, assumed in chain order.