AxiomCode Verify an artefact

15 November 2026 · Lean 4 proof

Agent harness — run supervisor fence

Our agent harness runs long work under a supervisor. The supervisor judges each run only from the artifacts the run leaves behind — its completion and failure markers, its heartbeat, its checkpoint — and when a run stalls it may resume it from that checkpoint, up to a declared maximum number of attempts: the fence. Past the fence the run is preserved and reported, never resumed again. Proved in Lean 4: a run is completed exactly when its own marker says so, a resume is launched only on a checkpoint that verifies exactly, and the fence is never crossed.

Proven Lean 4 proof

What was proven

  • Completion is sound, in both directions. Over a supervisor pass on an active run, the run is classified completed exactly when its completion marker is present, parses as an object, and its status says 'complete'. The completion check comes first: when the marker says complete, no other artifact is consulted for the verdict, and nothing else — no failure marker, no heartbeat state — can complete a run whose marker does not say so.
  • A present-but-invalid completion marker fails the run — never completes it. If the marker file cannot be parsed, or parses to something that is not an object, the run is classified failed at that pass, with exactly the one failure record the code writes for it and no classification record before it. A marker that parses but says anything else — or says nothing — completes nothing and fails nothing by itself; judgment moves on to the failure marker and to stillness.
  • The two markers are deliberately treated differently, and the proof keeps the difference. An unreadable completion marker fails the run, as the item above states; an unreadable failure marker is simply ignored — it neither fails nor completes the run, and judgment falls through to stillness, exactly as if the marker were absent. A readable failure marker that says 'failed' does fail the run.
  • A resume is exact. A resume is launched only when the run's checkpoint verifies in the same pass: the checkpoint state file present and parseable, its step recorded as a whole number, and every required component present in the code's sense — a missing key, an empty string, or an empty object counts as missing, while a value of 0, false, or an empty list counts as present. The launched resume carries the checkpoint's own step and the SHA-256 of the state file's bytes, computed at verification time in that same pass.
  • An incomplete checkpoint is declined, and the run is preserved. When verification declines, the decline names what is missing, the run is marked preserved, and no resume is launched — not at that pass, and not at any later one, even if the checkpoint is afterwards repaired: preserved is a final state, and the code has no path back from it.
  • The fence holds as a bound, exactly. Across any sequence of supervisor passes, the number of resumes launched for a run equals the growth of its attempt counter — no more, no fewer: the counter is moved in exactly one place, in the branch that launches the resume, by exactly one, and only from below the fence on an active run. The total therefore never exceeds the run's declared maximum, and every launched resume carries an attempt number at or below that maximum.
  • At a final state, the supervisor is a fixed point. Once a run's status is completed, failed, or preserved, it is no longer acted on: every further pass leaves its registry record exactly as it stands, records no events for it, and appends nothing. The silence the fence promises holds in full — at the final state, which is where the code places it.
  • The harness's own test cases are theorems. A run with a fresh heartbeat is judged running and its record unchanged; when its completion marker appears, the next pass completes it. A stalled run with a complete checkpoint is resumed exactly once, carrying the checkpoint's own step and hash. A checkpoint missing one named component is declined with that component named, the run preserved, and no resume launched. At a fence of two, repeated passes relaunch exactly twice and end with the run preserved, and a further pass adds nothing at all. A stalled run with no resume mechanism is escalated and preserved, never completed. And a readable failure marker fails its run.

What was not proven

  • The fence law as first sketched is not what is proved — because as sketched, it is false of the code. The sketch said that once the fence is reached, every further pass leaves the run's registry state and event count unchanged. The registry half holds — a pass that judges a run still running saves nothing — but a run whose attempts are spent is still active, and a later pass with a fresh heartbeat still records a classification event for it: the event record grows while no resume is possible. What is proved instead is the law in its true forms: the bound above, preservation at the first stalled pass that finds the fence spent, and total silence — events and registry alike — only once the run reaches a final state. This report does not claim the sketched form.
  • Judging by artifacts alone has two halves, and only one of them is a theorem. What is proved: the modelled supervisor's every decision is a function of the declared inputs — the run's registered configuration, the two markers, the heartbeat's stillness, the checkpoint — and checkpoint verification reads the state file only through its step, its hash, and its required components. The other half — that the running code never consults process state: it records the launched process's identity at start and never reads it again, and no process inspection appears anywhere in it — is a fact read from the code and checked by search, not a theorem, and this report does not present it as one.
  • The resume pin is derived, never compared. There is no stored pin anywhere for a resume to match against: the supervisor computes the pin from the checkpoint file inside the pass, and the resume reads that same computed value. The proof is of the derivation's exactness — that the launched step and hash are the file's own step and the hash of its bytes at that moment — not of agreement with any expectation recorded earlier.
  • One planted case is named, not claimed. The harness's seventh supervisor case exercises the supervisor driving the mirrored trace ledger — the local event record and its mirror landing together. That composition is the subject of the gatekeeper and chain reports in this register, not of this one; this proof's counts are over the local record, and nothing in it turns on the mirror.
  • A checkpoint file of the wrong shape can end the pass early, and that path is outside the proof. If the state file parses to something that is not an object, verification raises an error instead of declining, and the supervisor pass stops part-way. The model has no such case — in the model a parsed state file is always object-shaped — so the crash path is named here, not modelled, as with the crash paths named in the earlier reports.
  • A truth value can pass as a step count. In the language the supervisor is written in, the JSON literal true satisfies the whole-number test, so a state file whose step is true would have that value carried as its pinned step. The model's step is a whole number or nothing and cannot represent the case. It is a margin at the data boundary; no clause of the law turns on it.
  • Stillness is taken as a single number. The supervisor judges a run stalled by how long its heartbeat has been still, and the proof takes that stillness as given. How it is computed — from the heartbeat file's modification time, or from the run's start when no heartbeat exists, each measured against the pass's clock — is not modelled, and neither is the clock itself. The law governs what the supervisor does with the stillness it computes, not the computation.
  • The artifacts' authorship is not covered. The supervisor classifies the bytes it finds: a completion marker written by something other than the run, a checkpoint file swapped between passes, a heartbeat touched by another process. The proof covers the classification of what is found, not who wrote it; that the artifacts are the run's own is an assumption about the world the supervisor runs in.
  • The relaunch itself is outside the proof. The law governs the supervisor's bookkeeping — the resume event, the counter, the pin it carries. Whether the launched command actually restarts the run, and whether the restarted run resumes from the pinned step, is the resumed program's contract; it is exercised by the harness's own tests against the real supervisor, not by this model. That a supervisor pass itself always finishes is likewise not claimed: the model's pass is a total function, while the running pass can block on reading its files.
  • The proof is about a model of the code, not the running code itself. The model mirrors the supervisor's classification and stall-response logic 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. Two supervisors running at once over the same registry and event records — concurrency — sit outside the proof, as in the earlier reports.

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; ten of its stated results — including every planted test case below — depend on no axioms at all. The subject of the proof is the supervisor's classification and stall-response decision logic, modelled step for step from the code as built. One honesty note this register keeps: this proof needed no named assumptions at all. Elsewhere in this register a collision assumption is named wherever a hash is compared; here the checkpoint's hash is derived and carried, never compared against anything, so there is nothing for such an assumption to attach to.

How this report came to be

The claim this report examines ran: the run supervisor never resumes beyond its declared fence. Checked against the code, the sentence is true — and narrower than the discipline the code actually keeps. The fence is one leg of a four-leg response to a stall — fence spent, no resume mechanism, checkpoint declined, exact resume — and it means anything only alongside the classification soundness and the artifact-only judgment that decide when a stall is real. One clause of the claim's original sketch, that once the fence is reached later passes change nothing at all, turned out false of the code; the law is stated and proved in the code's true forms instead, and the first item of the boundary list below carries that correction in full. This is the fourth law of the harness proof round. The supervisor's events are also mirrored into the trace ledger whose gatekeeper, chain, and quarantine laws are the earlier reports in this register; this proof's counts are over the supervisor's own event record, which is written first and unconditionally, and nothing in it turns on the mirror.

← All verification reports · How the practice runs