Repository navigation
test(shell): pin that an approval-required command never runs unapproved - #4043
Conversation
The shell tool's approval path is being reworked by in-flight branches, and nothing currently pins the invariant those changes have to preserve: when no console is present, there is nothing that can approve a command, so a command needing approval must not run. Every assertion checks the side effect rather than the returned status. A tool that reports an error after already deleting the file is the case this is meant to catch, and a status-only assertion cannot tell the two apart. A read-only command is included as a control, so the suite cannot pass by refusing everything.
|
Verdict: Request changes — the suite is worth having, but its name and docstrings promise an invariant it doesn't actually exercise. This adds a tests-only file that checks a shell command needing approval leaves no trace on disk. The side-effect assertions (did the file really survive?) are a genuine improvement over the existing status-string checks. The problem is the framing: every command the suite tries is refused by the shell tool's read-only allowlist, long before anything asks for approval. The shell tool never consults a console at all, so the "no console, therefore no" reasoning in the docstring describes a decision made in a different layer than the one under test. Two things follow, and both matter given the stated purpose of guarding in-flight approval-path work:
The cheapest fix is to rename the file and rewrite the docstrings to claim what it really pins — the allowlist refusal holds, and holds regardless of console or auto-approve — which is a useful guard and true. If you want the confirm tier itself pinned, that needs one test driving the agent's gate with a granted binary and no console. Worth knowing: the "nothing can approve, so deny" invariant is already covered at the layer that owns it, in the existing console-confirmation tests. Real-world evidenceN/A — tests-only change, no runnable surface. No 🔍 Technical details🟡 The file pins the refusal tier, not the confirm tier (
|
The file claimed to pin the approval gate, but nothing in its call path can prompt: every command it tries is refused earlier, by the shell tool's read-only allowlist. Renamed and re-docstringed to say so, and the blanket-approval case now flips the opt-in through the startup-environment reader it is actually read from, so it can fail.
|
The review is right: this test never went near the confirmation gate. Every command it tries is refused earlier, by the shell tool's own read-only allowlist — I confirmed that by running each one and reading the refusal text back ("Command 'rm' is not in the allowed list"). The file has been renamed and re-docstringed to claim what it actually pins, and it now points at the existing suite that covers the approval tier. The blanket-approval case was also vacuous, for a second reason: the environment variable it set could never take effect, because the opt-in is read from a snapshot of the environment taken at startup. It now flips the reader that opt-in is really read from, and asserts the flip took before asserting anything else — so the test can fail. The temp-dir case now asserts the refusal as well as the absent file, and targets a process-unique name so nothing has to be deleted up front. On the overlap with the existing guardrail suite: agreed, leaving it. These assert the side effect, which the other suite does not. 🔍 Technical detailsFinding 1 — confirmed. Renamed Finding 2 — confirmed, and it had two independent reasons to be unfailable. The test now does Finding 3 — applied. Added Finding 4 — no action, as you suggested.
|
A command that needs the user's approval must not run when there is nothing present to approve it. That invariant is currently unpinned, and the shell tool's approval path is being reworked by several in-flight branches — so this adds the guard before those land, rather than after.
The assertions deliberately check what happened on disk, not what the tool reported. A tool that returns an error after deleting the file would satisfy a status-only assertion, and that is precisely the case worth catching. A read-only command is included as a control so the suite cannot pass by simply refusing everything.
These pass on
mainas written.Test plan
pytest tests/unit/test_shell_confirm_tier_never_fails_open.py— 9 passed onmain🔍 Technical details
tests/unit/test_shell_confirm_tier_never_fails_open.py, new file, no source changes.The host is a bare
ShellToolsMixinsubclass with noconsoleattribute — the shape a unit test, a script, or an embedding application produces. Approval is the console's job, so with no console the answer is no.Covered: a destructive command leaves its target in place; a writing command creates nothing; commands outside the no-prompt list (
curl,git commit,pip install,npm install) do not execute;GAIA_AUTO_APPROVE_TOOLSpre-approves prompts without widening what may run; nothing is written into the system temp directory when no path validator is configured. Plus the read-only control.