A gate should refuse with a reason you can act on
What should a review or merge gate do when it cannot say yes? It should fail closed, and it should say why in a way that names one cause and points at one next step. A refusal that is correct but vague costs almost as much as a wrong one, because the reader cannot tell a real problem from a broken gate.
I am writing this down because between November 13 and 21, 2026, my agents and I worked on eight gates and guards in my own tooling. Most of them refused for the wrong reason, or with a reason nobody could act on. Two did the opposite and went quiet. The fixes kept the same shape, so here is the pattern.
Refusals that hid their cause
The review gate in my agent harness normalizes a reviewer model's output before it trusts the verdict. It returned NO_RESULT / INVALID_OUTPUT whenever stdout, stderr and the last message added up to more than 1,000,000 bytes. Codex in JSON mode repeats the full output of every probe on stdout, so the reviews that actually probed the code ran long: they measured 1.08 to 2.68 MB. Their clean VERDICT: BLOCK was discarded, and the generic reason hid why. A thorough review read as a missing review.
The fix counts only verdict-bearing bytes against the 1 MB bound, adds a separate raw ceiling of 16 MiB (the change describes it as "about 6x above the largest real review"), and gives size failures their own reason, OUTPUT_TOO_LARGE. It still fails closed. It just says so.
A day later the PR review tool failed with ISOLATION_FAILED on one repo, with the message "worktree metadata scan refused a special or unstable entry". That blocked every merge receipt for the repo. There was a tracked symlink in the repo, and it was not the cause. The metadata scan had a fixed 5 second deadline, and "exceeded limits" was reported with the same text as a special file. The budget is now 5 s plus 0.5 ms per tracked index entry, with the 250k-entry cap kept, so the worst case is 130 s. More useful than the budget: the two cases now have separate codes, WORKTREE_SCAN_LIMIT and WORKTREE_SPECIAL_ENTRY. That turned a confusing symlink hunt into a one-line diagnosis.
Refusals nothing could satisfy
The kill guard's script rule refused an SSH command that ran a database test lane. The command signalled no process. The rule scanned every interpreter argument, and the test file's name contained -kill-, which matched the kill pattern. The fix makes the guard ignore kill words in interpreter path operands. A guard that blocks wrongly teaches people, and agents, to route around it.
The second one was worse because it looked like a working escape hatch. The review tool called its commit-range check with the literal name HEAD and looked up the tickets waiver under that string. The waive command only accepts a full commit SHA. So no waiver could ever satisfy the gate. The fix resolves the head to a full SHA once, before reading the range, which also means a ref that moves during the check cannot borrow another commit's waiver.
Normal read as error, and error read as normal
My disk cleaner fails closed on what it cannot establish about a repo, which is right for a tool that deletes things. But with git's extensions.worktreeConfig on and no config.worktree file, which is normal because git creates that file on the first --worktree write, the scanner's git config --worktree --list exited 128, and every fact of that repo or linked worktree became unknown. On the first real run that was 71 repos and worktrees, among them the three largest. The fix finds the file by lstat before running any git command. A missing file adds no keys if no worktree scope exists, and a symlink is refused.
The mirror image: a landing command read a runner's lease through a dead host and treated the unreadable lease as absent, so the runner protection was silently off. It now refuses with exit 3 when the lease is unreadable or unparseable, and credential failures carry a redacted reason. "Cannot read" is unknown, never "none".
A lineage check on served files had a related flaw. It went stale on November 6, and eight merged pull requests changed served files without leaving a lineage record. The check also stopped at the first mismatch, so one stale pin hid every later break. It now checks every unit and names each changed one.
What a named refusal looks like
This is an illustration, not output from my tools:
# illustration only
vague: REFUSED: validation failed
named: REFUSED SCAN_TIME_LIMIT: scan stopped at its time budget
(not a file problem; see the budget setting)
The named line rules out the wrong hunt and points at the next step. A clear refusal also makes the right fix possible when the refusal is correct. When a command guard blocked a helper that one session needed, we did not bypass the guard. A separate session built a route that allows exactly one pinned command: a file by SHA-256, no arguments, with an expiry. After it merged, the installed hook refused the same command with an extra argument, piped variants were blocked, and there was no route at the expiry time. The helper itself had not been run at that point. A related essay: guards that say which way they lean.
Test the refusal paths
These bugs lived on paths that run when a gate is deciding whether to say no. Several of the fixes came with tests that fail on the old code. Against the old scan helper, the new tests gave failures=14, errors=10. Both new waiver tests fail on the pre-fix code. The old lease handling, under its new tests, gave failures=5, errors=2. The pinned-command route had 208 focused tests passing at the reviewed head. See also a merge gate must prove the tests ran.
Checklist
- Fail closed, and give each refusal its own code. Never share message text between two causes.
- Bound what can influence the verdict, and give raw size its own, much higher ceiling with its own refusal code.
- Scale time budgets with input size, and keep a hard cap.
- Match guards on what a command does, not on substrings of file names.
- Resolve a mutable ref to an immutable ID once, then use that ID for every lookup.
- Treat "cannot read" as unknown, never as absent. Treat a normal state of the underlying tool as normal.
- Report every failure, not just the first.
- For each escape hatch, prove with a test that it can actually satisfy the gate.
- Write tests for the refusal paths, and confirm they fail on the old code.