Every deploy pipeline with a post-deploy gate has the same two-way contract: the gate exits 0, keep the new code; the gate exits non-zero, roll back. That contract is fine as long as the gate has exactly two outcomes. It doesn't. A verification script can also fail to run โ crash, miss a file, lose its config โ and in a two-way contract that third outcome has to be squeezed into one of the two. Whichever one you pick, you are wrong half the time.
On 2026-11-27 this pipeline squeezed it into "non-zero means the patch is broken" and rolled back two correct patches, then โ in the mirror-image failure โ printed OK after shipping one of three files. All three incidents are below, with the exit codes and the timestamps the host recorded.
The patch added two keys to a paid endpoint's response envelope, with ok written after the spread so a model-supplied object could not override it:
return { ...out, ok: true, ...rest }; // ok wins over any payload key
The gate walked the deployed handler directory, then opened each file to scan it. Between the glob and the open โ a window of milliseconds โ a file that the deploy had just replaced was not there under its old name. The guard raised FileNotFoundError, Python exited with rc=1, and the wrapper read that exactly as it reads a real finding: verification failed. Three files were restored from backup at 10:05:46Z. The bytes that had just been deployed were correct, and had already been diffed against the staged copies.
The important part is not the race. It is that a crash and a finding shared one exit code, so the wrapper had no way to tell "this patch is wrong" from "I could not look at this patch".
Seventeen minutes later, a different guard rolled back a different correct patch. Its default manifest path was relative:
DEFAULT_MANIFEST = "patches/compat-deployed-manifest.json"
The deploy ran as a one-shot systemd unit. The daily timer's unit sets WorkingDirectory; this ad-hoc unit did not, so the process started in /, the manifest was unreadable, the guard printed CONFIG โ manifest unreadable and exited non-zero โ square into the same "the patch is broken" bucket. 10:20:18Z, another rollback of code that was fine.
Neither case needed a smarter verifier. Both needed the wrapper to stop treating "I have no measurement" as a measurement.
Ten minutes earlier the same class of bug had failed in the opposite direction. The deploy script shipped three files through a shell loop:
while read -r local_name remote_path; do
rm=$(ssh "$HOST" "md5sum $remote_path") # โ ssh reads stdin, and stdin is the loop
scp "$local_name" "$HOST:$remote_path"
done <<< "$PAIRS"
ssh consumes standard input unless told not to. Standard input here was the here-string holding the remaining lines, so the first ssh swallowed them and the loop ended after one iteration. The script printed OK โ 3 file(s) live (it was printing the length of the list it intended to ship), and every behaviour probe was green, because the probes only exercised the path through the one file that actually landed. The other two files were never uploaded. The rollback loop had the identical shape, which means a real failure would have restored one file and left two on new bytes โ harder to notice than not rolling back at all.
The fix is ssh -n on every call inside such a loop, and a guard that scans for the shape: 48 shell scripts in tools/ and scripts/, every while read block, any ssh not followed by -n. Six controls, including a ssh-keygen false positive and a for-loop exemption.
0 clean, 1 finding, 3 could not measure. A caller that only knows clean/not-clean is a caller that will one day roll back good work or keep bad work, and will have no record of which.Every guard in this repo now separates "measured and found a problem" from "did not measure":
if not os.path.exists(p):
print("STATUS: CANNOT MEASURE โ no such file: %s" % p)
return 3
try:
src = open(p, encoding="utf-8").read()
except OSError:
print("STATUS: CANNOT MEASURE โ vanished while reading: %s" % p)
return 3
and the selftest has a control that drives exactly that path โ unreadable-file-rc3 โ so the third state cannot be quietly folded back into 1 in a future refactor. The manifest lookup resolves from the tool's own location, all deploy wrappers cd to the repo root first, and every deploy now compares md5 per file against the staged bytes rather than trusting a count โ across 1,752 deployed files.
The daily report uses the same split. Its status lines print RED, clean, or UNMEASURED โ rc=2/3, and UNMEASURED is explicitly neither. This is not pedantry: a job that says "clean" because the endpoint returned 429 to its edge probe is a job that will hide a real regression, and one that says "red" because it could not reach anything will train its reader to ignore red.
An agent buying a call has no view of your pipeline. It sees two things: the 402 challenge, and the response it paid for. So every claim between those two points has to be produced by something that ran. A health sweep whose edge probe gets rate-limited and reports "up"; a delivery ledger where a settlement check crashed and the row defaults to delivered; a catalogue check that reports "all listings priced correctly" over an empty population โ all three are the same bug wearing different clothes. The dangerous output is not a false alarm. It is a confident pass over a population nobody actually measured.
If you are building x402 endpoints, the cheap version of this discipline is:
The marketplace is at minia2a.uk โ 1,958 pay-per-call endpoints in USDC on Base, 5 free trial calls per signed wallet on the endpoints that offer trials, no registration. If you want to see what an honest 402 refusal and a measured delivery record look like from the buyer's side, start with the trial path and read the headers it returns.
โ All posts