14 November 2026 · Lean 4 proof
Agent harness — trace-ledger hash chain
Every entry in our agent harness's trace ledger is hash-linked to the entry before it: each entry's stored hash is computed over its own content and the hash it points back to. Proved in Lean 4: if any entry's content no longer matches its stored hash, or any link in the chain is broken, verification fails at exactly the first failing entry — and a pass means every check holds along the whole chain. The boundary is stated on the report: this proves detection of alteration in a ledger as presented, not protection against a wholesale rewrite.
Proven Lean 4 proof
What was proven
- Content tampering is detected at the entry. If an entry's stored hash does not recompute from its content as presented, verification fails at exactly that entry's position, named as a recomputation failure — provided the entries before it pass and its own sequence, identity, and link are in order.
- A broken link is detected at the entry. If an entry does not point back at the previous entry's stored hash — or, for the first entry, at the chain's starting value — verification fails at exactly its position, named as a link failure.
- A pass means the whole chain holds. Verification passes over a ledger exactly when every entry, at its position, passes every check: sequence, identity, link, hash recomputation, and the ordering counters all hold along the entire walk. The equivalence is proved in both directions.
- The first failure is the reported failure. If any entry's check fails, verification fails at or before that entry's position; and any failure verification reports is the first failing position, with every entry before it passing. No failing entry is silently passed over.
- The harness's own worked example is a theorem. In the harness's test suite, the second entry of a test ledger is rewritten in a copy of the file, its stored hash untouched, and verification is observed to break at position 2. That exact case — first entry intact, second entry's presented content differing from what its hash was computed over — is proved to fail at exactly position 2 with the recomputation reason.
What was not proven
- A wholesale rewrite would pass. Every result here concerns a ledger as presented, checked against its own internal chain. A ledger rewritten in full — every entry replaced, every hash and link recomputed consistently — passes this verification completely, and no result here says otherwise, because none can: the chain is unkeyed, so anyone can recompute it, and verification has no reference outside the presented entries. The remedy is a reference held outside the ledger; that is the anchored chain report in this register, a separate mechanism with its own boundary.
- Verification cannot prove an entry was true when it was written. It proves a ledger was not altered after its entries were committed. A false entry, honestly committed, chains perfectly.
- SHA-256 itself is not proved. The hash function is modelled as an abstract function. The detection results rest on determinism alone — the same function, over the same input, at commit and at verification — except for one step: from 'the content was altered' to 'the recomputation differs'. That step assumes, for the pair of inputs involved, that their hashes do not collide. Collision resistance is a standard, believed property of SHA-256; in this proof it enters only as a named assumption, discharged by nothing here, and the content reading of the first result carries it.
- The proof is about a model of the code, not the running code itself. The model mirrors the verification walk and the hash construction step for step, and the correspondence is documented and reviewed — but it is not itself machine-checked. A proof of the model is not a proof of the running program.
- How an entry becomes the string the hash covers is not proved. The model takes each entry's canonical form as given. In the running code, one fixed serialization produces that form, identically at commit and at verification — a fact read from the code, and the reason the determinism results are about the real system at all. That two different entries could never serialize to the same string is not proved; a serialization collision would defeat the content check before the hash is consulted.
- Entries with missing or mistyped fields are outside the model. The model's entries have every field present and correctly typed, so such entries cannot be represented. In the running code a missing field makes verification fail — the detection reading is not weakened — but no theorem here is about them. The ordering counters are likewise modelled as plain whole numbers: the code's handling of negative or non-numeric counter values, which fails verification, cannot be represented in the model, and one counter check in the code reads a JSON true as the number 1, a case the model does not have.
- Loading the ledger is outside the proof. The theorems concern a list of entries already loaded. Reading the file and parsing it are not covered — including the path where a malformed line stops the load and the ledger is set aside on the parse error, without this verification ever running. A ledger changing while it is read is likewise outside.
- What is done with the verdict is not covered. How the harness's index uses the verdict — marking a broken ledger quarantined, deciding which entries count as verified, answering trusted-only queries — is separate code, not modelled here. The index also keeps its own separate hash chain over its rows; that chain is not proved by this report. That property has its own published reports in this register: the index quarantine proof, and the fixed-code index quarantine proof.
- Concurrency sits outside the proof. Verification runs over a loaded snapshot; entries appended while a verification runs, or two writers racing to append, are not covered by these theorems.
How it was verified
Lean 4 formal proof (toolchain v4.22.0), checked by the Lean kernel. The proof compiles with no placeholder steps (no sorry, no admit) and depends on no axioms beyond Lean's core three; two of its results depend on no axioms at all. The subject of the proof is the chain-verification walk, modelled step for step from the code as built: the six checks each entry faces, their order, and the state threaded from entry to entry. The hash function is modelled abstractly — the proof is about the walk, not about SHA-256.
How this report came to be
The gatekeeper report in this register names the hash chain as a separate law, not claimed there; this is that law's own report. The claim under examination described the ledger as a 'signed hash chain'. Checked against the code, the chain half is real — hash-linked, with unkeyed SHA-256 — and is proved here exactly as built. The signed half is not true of the code: nothing in the append or verification paths signs anything, and there is no key and no signature field. Signing was ruled a separate, later strengthening; this report does not claim it.