symfonic.services.switching.audit¶
audit ¶
SCP-AUD — the tamper-evident, append-only switch audit chain.
Each record's hash covers the previous record's hash, so an altered or removed record breaks every hash after it. The point is not that tampering becomes impossible; it is that tampering stops being silent, which is the only property a retirement gate can actually rely on.
AuditRecord
dataclass
¶
AuditRecord(seq: int, prev_hash: str, actor: str, role: str, bundle_id: str, prior_epoch: int, proposed_vector_hash: str, outcome: str, reason: str, timestamp: float)
One mutation attempt — accepted or denied, both recorded identically.
HashChainAuditLog ¶
An in-process append-only hash chain (the reference implementation).
Source code in src/symfonic/services/switching/audit.py
assert_no_credentials
staticmethod
¶
SCP-AUD-3 — refuse credential-shaped free text before it is chained.
Source code in src/symfonic/services/switching/audit.py
commit ¶
Chain a prepared record, refusing one that no longer fits the chain.
Source code in src/symfonic/services/switching/audit.py
prepare ¶
prepare(*, actor: str, role: str, bundle_id: str, prior_epoch: int, proposed_vector_hash: str, outcome: str, reason: str = '') -> AuditRecord
Build the next record without chaining it.
Preparing and committing are separate because the bundle record must store the audit head that attests it (SCP-AUD-1), and the record it attests is only durable once the CAS lands. Preparing lets the caller compute that head, commit the bundle, and only then chain the entry — so a lost CAS race never leaves an "accepted" record for a mutation that never happened.
Source code in src/symfonic/services/switching/audit.py
tamper_for_test ¶
Rewrite one record in place — the only way to exercise SCP-AUD-2.
It lives on the log rather than in a test helper so that "the chain detects this" is asserted against the same object production uses, and so any future storage backend inherits the same characterisation.
Source code in src/symfonic/services/switching/audit.py
verify ¶
SCP-AUD-2 — recompute the chain from genesis.