Chronicle
Overview
Section titled “Overview”Chronicle — the audit trail for every Nexus action. SQLite-backed, queryable, exportable for compliance.
Red-team round 2 (R2-4): the kernel only ever appends, but the ledger is a file owned by
the user, so any process running as them could edit it. Each row now carries chain,
a SHA-256 over the previous row’s chain and this row’s fields, and verify() walks it.
Editing, deleting or reordering a chained row breaks the chain at that row. Rows written
before chaining existed are reported as legacy, not as tampering. Truncating the newest
rows, or rewriting the whole chain from the start, can only be caught against a head
recorded somewhere else: head() returns it for that.
- Version:
0.1.0 - Class:
Chronicle
init_db(self) -> None
Section titled “init_db(self) -> None”log(self, source: str, action: str, payload: dict[str, Any] | None = None) -> str
Section titled “log(self, source: str, action: str, payload: dict[str, Any] | None = None) -> str”head(self) -> dict[str, Any]
Section titled “head(self) -> dict[str, Any]”The newest chain value and how many rows lead to it. Record it somewhere this process can’t write to (a commit, a printout, another machine) to catch truncation.
verify(self) -> dict[str, Any]
Section titled “verify(self) -> dict[str, Any]”Walk the chain in insertion order. ok is False at the first row whose chain
doesn’t follow from the row before it, with that row’s event_id.