14 November 2026 · Lean 4 proof
Agent harness — anchored trace-ledger chain
The chain report in this register states its own boundary: a ledger rewritten in full, honestly re-chained, passes chain verification, because the chain has no reference outside itself. The harness's answer is anchoring: from time to time, the chain head — the entry count and the head hash at that moment — is recorded in custody outside the ledger. Proved in Lean 4: a rewritten anchored prefix is detected, a new anchor cannot be taken over a changed prefix, a ledger with no anchor never passes, and the entries beyond the latest anchor are counted and stated exactly.
Proven Lean 4 proof
What was proven
- Verified means the whole statement. A result of 'anchored-verified', with its stated tail count, holds exactly when: a latest anchor exists; the anchored prefix — the ledger's first entries up to the anchor's count — verifies; the head at that count equals the recorded head; the full chain verifies; and the tail count is the presented length minus the anchored count. The equivalence is proved, not just the safe direction.
- A rewritten anchored prefix is detected. If the head at the latest anchor's count differs from the recorded head — or the prefix no longer verifies, or the ledger is now shorter than its anchor — verification reports a mismatch. It never reports verified.
- Anchors cannot launder a rewrite. Taking a new anchor when the previously anchored prefix has changed is refused, and nothing is written: the anchor record is left exactly as it was. In the other direction, the record grows only over an intact prefix — a successful new anchor certifies that the previously anchored prefix still stood at the moment of anchoring.
- No anchor, no pass. A ledger with no anchor record returns 'unanchored' — a failure result, never a pass.
- The un-anchored tail is counted and stated exactly. A verified result carries the number of entries beyond the latest anchor, no more and no less. When that number is positive, the result names those entries as stale; a freshly taken anchor verifies with a tail of zero. 'Stale' is a stated count on a verified result — not a separate verdict, and staleness alone is not a failure.
- A break in the tail is named, not passed. If the anchored prefix matches but the chain breaks beyond it, the result is 'chain broken' — never a pass — carrying the same exact tail count; and the break is proved to lie beyond the anchored count, in the tail, since the prefix was just verified.
What was not proven
- Detection is proved given an authentic anchor record. Every result here assumes the anchor record the verifier reads — its entry count and head hash — is the record that was actually taken, over the history that was actually committed. That the custody copies sit outside the ledger writer's reach — one an append-only record held apart from the ledger, one a copy delivered to the operator's own mailbox — is an assumption about the world, not a theorem. A writer who could also rewrite the custody copies could rewrite the anchor to match a rewritten ledger, and no theorem here says otherwise, because none can: the anchor is data, not a signature. What is proved is the comparison itself: if the anchor record is out of reach, the anchored prefix cannot be rewritten without detection.
- One component hypothesis remains named and unproved. Detection is proved at the comparison the code performs — a presented head that differs from the recorded head is caught. The further step, that altering an entry deep inside the prefix and honestly re-chaining the rest must change the head, rests on two properties of the real hash construction: its outputs are fixed-length, so a changed link value inside a hash input cannot be compensated by the entry content that follows it; and no recomputation along the way collides. The model treats hashes as arbitrary strings, where neither property is available, so the step is stated here as the hypothesis it is. The harness's own planted test observes the concrete behaviour; the theorem covers the comparison that behaviour feeds.
- Entries after the latest anchor are protected by the chain law alone until the next anchor. A wholesale rewrite of that tail alone, honestly re-chained, passes chain verification and the anchor comparison alike; it is caught when the next anchor is attempted over it — the rewritten tail has become part of the prefix-to-be, and the anchor is refused — or if it breaks the chain. How large the tail can grow is bounded only conditionally: it depends on the anchor step actually running after appends and succeeding. What holds unconditionally is that the tail's size is always counted and stated exactly.
- No signing is claimed. The anchor record is plain data in custody: nothing here establishes who took an anchor, and there is no key and no signature anywhere in the anchoring. Signing the anchors is a deferred strengthening with a named trigger, not part of this proof.
- The proof is about a model of the code, not the running code itself. The model mirrors the anchoring decisions branch for branch, 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.
- Custody itself is outside the proof. Writing and reading the custody records, their storage and placement, and the delivery of the second custody copy are operations, not theorems. A damaged or truncated custody record is a load error in the code and never reaches the decisions proved here; the same holds for an unreadable ledger. The second copy's failure handling — the anchor stands on the first custody, with the failed leg named — is code behaviour read and reported, not a theorem.
- Which records count as a ledger's anchors is outside the proof. The model takes a ledger's anchor sequence as given and proves facts about its latest record. The code's matching of records to ledgers — including its path handling — is not modelled; a fault there would be a selection failure, not a comparison failure, and is not covered.
- The verdicts are proved; their wording is not. The proof is about the states the verifier reports. The explanation text attached to each state — including the two different explanations under the one mismatch state — is presentation, checked by reading, not proved.
- Concurrency sits outside the proof. Two anchor-takings racing on one custody record, or an append racing an anchor, are runtime matters; the model decides over a snapshot.
- The chain proof's boundaries are inherited. This proof builds on the chain model unchanged, so its limits apply here too: the hash function itself is not proved, each entry's canonical form is taken as given, entries with missing or mistyped fields are outside the model, and loading a ledger is outside both proofs.
How it was verified
Lean 4 formal proof (toolchain v4.22.0), checked by the Lean kernel. The proof composes the chain proof in this register: its model is imported unmodified, not restated, and the chain walk is not re-proved. It compiles with no placeholder steps (no sorry, no admit) and depends on no axioms beyond Lean's core three; seven of its thirteen stated results depend on no axioms at all. The subject is the anchoring decision logic — taking an anchor, and verifying a ledger against its latest anchor — modelled branch for branch from the code as built.
How this report came to be
The remedy chosen for the chain's boundary was anchoring, not signing. A signing key kept beside the ledger would be readable by whatever could rewrite the ledger, so signing each entry would buy little inside one trust boundary while adding key custody. Anchor records are therefore plain records — an entry count and a head hash — each written to two custodies outside the ledger itself. Signing is deferred, with a named trigger: if these records are ever used as evidence for third parties, or kept between parties who do not trust each other, the anchors — not the entries — are what would be signed. That would be a code change first and a new proof second; nothing here claims it.