RUNVS ← All guides
AI security · 5 min read

An Exit Code Is Not a Verdict

By RUNVS Staff · November 16, 2026

A scheduled job of ours failed on every run for nine days. The scheduler marked every run a success. Nothing was hidden: the failure was written down each morning in a log that nobody read.

What actually happened

It was a small automation that ran each morning and wrote a report. Its scheduler recorded an exit code of zero every time, so the dashboard stayed green. But the real work happened inside a wrapper script, and the wrapper caught the error, wrote it to a log file, and then exited normally. From the outside, a run that did nothing looked exactly like a run that did everything.

We only found it because a person went looking for the report and it was not there. Nine days of silence, and every signal we had built said things were fine.

This is not a rare bug. It is the default shape of most automation. A process tells you one number when it ends. That number answers one narrow question: did the process decide to call itself a failure? It does not answer the question you care about, which is whether the work got done.

Why exit status lies so easily

There are a few ordinary ways a broken run comes back as zero.

Habit one: judge the output, not the exit

Decide what a successful run leaves behind, and check for that. For a report job, that means a file with today's date and a plausible size. A sync job should leave the destination matching the source. Backups should be restorable, which means someone restores it on a schedule. The question is never "did it exit zero." The question is "is the thing it was supposed to make actually there, and does it look right."

This costs a little more to write, because you have to say in advance what "right" means. That is the point. If you cannot describe the output of a good run, you do not yet know what your check is protecting.

Habit two: a check only counts if something reads it

Our failing job had a log, and the log was accurate. It did not matter, because nothing read it. A check that writes to a file nobody opens is a diary, not a control.

So every check needs a reader, and the reader should be something that already gets looked at. For us that meant routing check results into the briefing we read at the start of each work session, with failures printed first and successes collapsed to a single word. If a check cannot reach a place a human will see, either connect it or delete it. A check you think is running, but nobody watches, is worse than no check, because it gives you confidence you have not earned.

Habit three: break the thing on purpose

The only way to know a check catches a failure is to cause the failure and watch the check fire. Delete the file it looks for. Point it at an empty input. Corrupt one record. Kill the service it monitors. If the check stays green, it was never checking what you thought.

This is the same idea as mutation testing in software: deliberately introduce a defect and confirm the test suite fails. It feels like extra work. It is the cheapest insurance you will ever buy, because a check that has never gone red is a check you have only assumed works.

Habit four: make the failure loud at the source

Where you control the code, make failure the default outcome rather than something the code has to remember to report.

Why this matters more with AI agents

An AI agent that runs a task and reports "done" is giving you an exit code in sentence form. It is a claim about the work, not proof of it. Agents are good at producing confident summaries, and a confident summary of a task that silently failed is the same trap with better grammar.

The habits carry over directly. Ask what a finished task leaves behind and check for that artifact yourself. Make sure some person or process actually reads the agent's results. Test your review process by handing it a task you know was done wrong. We cover the same theme from the security side in why a guard prompt is not a control: a sentence that says something is safe is not the same as a mechanism that makes it safe.

A short checklist

  1. For each automated job, write one sentence: "a good run leaves behind ____."
  2. Check for that thing, not for the exit code.
  3. Route the result somewhere a human already looks, failures first.
  4. Break what the check guards at least once and confirm it goes red.
  5. Turn on strict error handling and pipefail in shell scripts.

Sources