Audit retention and verification
Retention must support reconstruction: what was declared, what was observed, which trust checks ran, what decision was returned and whether the retained record was altered.
Two bounded primitives
| Primitive | Purpose | Boundary |
|---|---|---|
EvidenceLedger | In-memory append-only sequence with duplicate-id rejection and JSONL export. | Useful for controlled replay; it is not durable enterprise storage. |
AuditChain | File-backed hash-linked event records with schema and sequence verification. | Detects alteration; availability, backup and access control remain external. |
Evidence ledger
Each entry records a monotonic sequence, evidence identity, append time and immutable evidence object. Duplicate ids and missing integrity hashes are rejected.
ledger = EvidenceLedger() ledger.append(evidence, appended_at=now) ledger.export_jsonl("evidence.jsonl")
Hash-linked audit chain
Each event record contains sequence, previous hash, event and record hash. Verification recomputes the chain from the genesis hash and checks schema, sequence, previous link and record digest.
chain = AuditChain("audit/events.jsonl") chain.append({ "event": "assurance_decision", "service_id": decision.service_id, "state": decision.state.value, "evidence_ids": decision.evidence_ids, }) verification = chain.verify()
Signed checkpoints
A checkpoint binds genesis hash, current head hash and record count to a signer. Verification first checks the live chain against the checkpoint head and count, then verifies the checkpoint signature.
checkpoint = chain.create_checkpoint(signer, "audit-key") result = chain.verify_checkpoint(checkpoint, verifier)
Minimum retained decision record
- Contract identity or immutable contract snapshot.
- Evidence identities and source provenance.
- Evaluation time and time authority.
- Enabled engine strictness requirements.
- Top-level and component states with reasons.
- Standard context and applicability decisions.
- Response action, owner and later disposition.
Operational controls
| Control | Why |
|---|---|
| Separate write and review roles | Reduce unilateral alteration risk. |
| Independent checkpoint custody | Make whole-chain replacement detectable. |
| Retention and deletion policy | Meet legal, privacy and evidence needs. |
| Backup and recovery test | Ensure audit evidence remains available. |
| Periodic verification | Detect damage before the record is needed. |
Operational basis
NIST SP 800-92 provides foundational guidance on log-source configuration, storage, protection, analysis, response and long-term management. The library primitives address only a small technical subset of that operational program.