DEV Community

correctover
correctover

Posted on Edited on

A Boolean Almost Cost Us a Double-Fire: Replacing already_executed with Six Explicit States

A public standards list did to us what every maintainer fears: it broke our reference verifier in front of everyone. The fix took 24 hours. This post is about what the bug actually was, because the shape of it — a boolean standing in for a process — is one of the most common silent defects in agent-runtime code.

The bug

Our recovery-admission reference verifier (ECR — recovery actions admission control) modeled the executor's retained disposition as a single boolean: already_executed. True = refuse the replay attempt. False = proceed with the rest of the authorization binding.

On the agent2agent IETF list, Justin Kintzele (J Diesel NY) publicly identified the hole: an in-process exception test cannot see the live-worker case, because the claiming owner is still running when the boolean is read. After a process crash or reboot between "invoking an external side effect" and "persisting the receipt", fresh authorization alone cannot tell a retry apart from a second effect. A boolean cannot represent the states between "nothing happened" and "it happened" — and the dangerous middle is exactly where blind retries double-fire.

Six states

The fix replaces the boolean with six explicit dispositions, fail-closed:

State Meaning Fresh attempt?
absent no retained record allow
claimed O_CREAT|O_EXCL won, handler unfinished refuse (owner alive)
in_progress handler running refuse (blind retry double-fires)
outcome_unknown owner dead / lease expired refuse — reconciliation required
completed result persisted refuse (replay, or NONCE_CONFLICT if same nonce with different digest)
reconciled outcome_unknown resolved by external evidence allow

Two rules do most of the work: a crash window with no explicit record is outcome_unknown, never absent; and only absent/reconciled admit a fresh attempt. The legacy boolean maps True → completed for compatibility.

The test that had to turn red

We've been burned before by tests that verify their own construction. So the suite ships with a mutation self-test: --mutation-no-disposition disables the six-state check entirely and requires the disposition suite to go red. Delete the load-bearing branch → 1 failed with the real failure signature; restore → 9/9 green. A suite that stays green when the code under test is removed proves nothing.

(That lesson came from another public review, on a different repo, where a maintainer correctly called out that our first test "only verified its own construction". Public refutations are how we learn. We record them, with attribution, in our VERIFIED_BY.md — a refutation that stands after review is credited more prominently than a pass.)

Why this matters beyond one repo

Autonomous agents are starting to carry money and side effects. The numbers on the runtime side are rough — one independent sandbox study of 13,756 stdio MCP packages found only 46.5% even start and pass before any security check. When a recovery action retries after a crash, "did it already happen?" is a money question, and a boolean is not an answer.

Fixed vectors, idempotent replay, and signed receipts are how we think it should be answered. Our verifier-divergence corpus (DOI 10.5281/zenodo.24618874) publishes 11 fixed vectors against 5 Ed25519 verifier implementations, and independent teams now pin their runs against it with content hashes. The six-state suite lives in DSHCorrectover/correctover-recovery-admission — clone it, run python3 ecr/verify-binding.py --mutation-no-disposition, and watch it go red on purpose.

The meta-point

AI (and AI-built systems) cannot be trusted to self-certify — not ours, not anyone's. The gate has to live outside the thing being verified: a maintainer's hostile read, a mutation that must turn red, a third party who can re-derive your numbers from public anchors. If your test suite can't fail when the guarantee is deleted, you don't have a test suite; you have a mirror.

Cross-posted from our engineering notes. Attribution policy: hostile readers welcome, paid in credit, not in silence.

Continuing the conversation

This piece lands in the middle of a live discussion. @rengond's recent article on authorization, idempotency and audit trails at the server boundary makes the complementary client-side point: durable operation identifiers and unique constraints are exactly the executor-side fence that our six dispositions model from the verifier side. If you are building agent tools that carry side effects and want an independent read of your idempotency contract - or want to trade notes on crash-window semantics - our inbox is open (wangguigui@correctover.com), and the runnable suite is at DSHCorrectover/correctover-recovery-admission.

Top comments (0)