DEV Community

Debashish Ghosal
Debashish Ghosal

Posted on

Exit Code 0 Is the Weakest Evidence You Have

Exit Code 0 Is the Weakest Evidence You Have

From the agentkeys v0.1.0 release: a local credential broker for AI agents. Agents hold references, never secrets; the broker injects scoped, bound, expiring tokens at egress, and revoke kills access in under a second. This story is from the v0.1.0 field test report: 74 cases, 71 PASS, 0 FAIL, 3 WARN.

AI disclosure: this article was drafted and edited with AI assistance. The field test, the defects, the fixes, and every number are real and linked below.

The most expensive lesson of my last field test hid behind the most comfortable sentence in engineering: "the runner exited 0."

Seventy-four cases, sixteen packs, a final tally of 71 PASS, 0 FAIL, 3 WARN. Every PASS was re-derived from committed artifacts before I wrote it down, and that re-derivation kept catching real problems on the way: a wrong belief encoded as an assertion, a stored secret in my own evidence files, a verifier bug that manufactured false findings. None of them were product defects.

That is what sent me back to first principles on the exit code itself. It proves the runner finished the way I, its author, defined as success. That is a statement about my program's internals, not about my claims.

A green test can be wrong in four ways

An exit code can bless all of these without flinching:

  • An assertion that encodes the wrong belief, honestly evaluated.
  • An evidence file that was never written.
  • An output that says "passed" while the artifact contradicts it.
  • A summary nobody can check without re-running everything.

I hit the first one for real. One of my revocation cases asserted that after revoke, the live-issuance list is empty. Sounds right. Revoke means dead, right? Except agentkeys revoke is an epoch compare-and-set: it does not flip a row's status, it advances the epoch, and the next use() fails the epoch check. The row stays live until consumed. The assertion encoded a belief about the product that was simply false, and a green run would have blessed it.

The grounding pass on the killtime results caught it. The fix was to assert the externally visible truth instead: the revoked event was recorded, and the next hop was refused. The assertion got stronger and correct at the same time.

Separate the runner from the verifier

The pattern that fixed this for the whole suite: the thing that runs the test and the thing that proves the test are different programs with different jobs.

The runner is allowed to be wrong. The verifier exists to catch that. Mine re-derives every assertion from the committed result files: it recomputes passed from the assertion kind, the expected value, and the actual value. It checks that evidence files exist and hash-match, so a stale or edited artifact cannot vouch for a fresh claim.

It enforces a minimum evidence depth, at least two grounded assertions per case, three for the five release-blocking scenarios, so a PASS can never rest on one thin check. And it validates structure, not just content: every case needs its status and limitation fields well-formed, and every case that was not run needs an explicit reason.

A PASS with no grounded assertions is itself a finding.

Traceability is the connective tissue. Every claim maps to a case, every case to committed results, every result to a run with its environment fingerprint, image digests, git SHA, platform, recorded alongside. When a verifier re-derives a claim, it walks that chain in reverse: from the number in the report back to the artifact that produced it. If any link is missing, the re-derivation fails loudly instead of shrugging.

By the end of the sweep, all 71 PASS verdicts had been re-derived from committed artifacts, and the verifier reported zero findings. That sentence is qualitatively different from "the tests passed."

Test the verifier too

If you stop there, you have just moved blind trust one layer over. So the verifier gets a self-test: seeded defects that must be caught, on temp copies of the results tree. Mine rejects five ways to be confidently wrong: an ungrounded PASS, an assertion whose re-derived value disagrees with the stored one, a WARN with no limitation, a planted secret, and any attempt to write a protected report file. If the self-test does not reject every one of those, the verifier is decoration.

One subtle rule from experience: the self-test only ever runs against copies. The first version of my self-test ran the leak scanner against the real results directory. A destructive gate exercised on the real artifacts is an outage waiting for a calendar slot.

And the verifier is not above suspicion either. During the sweep the deep-validation gate manufactured false findings by counting assertion minimums against cases that never ran. The rule got scoped to skip not-run cases, their recorded reasons still required, and the gate got honest.

When is this overkill?

For a CRUD endpoint, it is. Fast feedback loops and exit codes are a good trade for low-stakes checks. This protocol earns its cost when the claim is release-blocking: security properties, compliance, migration safety, performance numbers you intend to publish, anything where being quietly wrong is expensive. If a claim would appear in your release notes and you cannot say who re-derived it, that is exactly the claim that needs a verifier.

Steal this checklist:

  • Recompute every pass from artifacts, not from logs.
  • Hash the evidence files, do not just expect them to exist.
  • Enforce minimum assertion depth; a shallow PASS fails.
  • Treat an ungrounded PASS as a finding, not a success.
  • Seed known-bad controls and prove the verifier fires.
  • Self-test the verifier, on copies, never on the real tree.

A green process is only a suggestion. A re-derived claim is evidence.


What is the most confident green you have ever had to walk back, and what finally gave it away: a re-check, a customer, or a 3 a.m. page? I would love your version in the comments.

Top comments (0)