Skip to content

fix(roadmap): run a negative search verify in the step - #3269

Merged
dan-petty merged 3 commits into
mainfrom
fix/3263-negative-search-verify
Nov 2, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/3263-negative-search-verify

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The stage gate admitted ! git grep ... as a verify command, and the implement step refused it, because ! is on no allowlist. The step now runs the form as a fixed shape and never as a shell: ! git grep [options] <literal> [--] <path>.... The options are -n -I -F -i -w -l -c -q. The literal is plain text and the paths are relative. The step runs git grep <options> <literal> -- <paths> and the search passes only when git exits 1. The gate asks the same function (verification_problem), so it gives the reason of the step for a command the step refuses. A pipe, ;, &&, a redirect, --no-index, -O, -f, -e and every other option are refused, and the step starts no process for them.

Closes #3263

Change: openspec/changes/archive/2026-11-02-3263-negative-search-verify


Generated by Claude Code

The stage gate admitted `! git grep ...` as a verify command, and the
implement step refused it because `!` is on no allowlist. The step now
runs the form as a fixed shape, with no shell: the options -n -I -F -i
-w -l -c -q, one plain literal and relative paths after `--`. The search
passes only when git exits 1. The gate asks the same function, so it
gives the reason of the step for a command the step refuses.

Closes #3263

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PeiMDoPafqUWqpk1WxhaYW
@dan-petty
dan-petty marked this pull request as ready for review November 2, 2026 19:17
@dan-petty
dan-petty merged commit 42bc835 into main Nov 2, 2026
20 checks passed
@dan-petty
dan-petty deleted the fix/3263-negative-search-verify branch November 2, 2026 19:17
dan-petty pushed a commit that referenced this pull request Nov 2, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.48.1](v0.48.0...v0.48.1)
(2026-11-02)


### Bug Fixes

* **roadmap:** make the plan summary fit its title
([#3267](#3267))
([758b7a8](758b7a8))
* **roadmap:** run a negative search verify in the step
([#3269](#3269))
([42bc835](42bc835))
* **roadmap:** write the Verification line under a staged task
([#3268](#3268))
([acaf455](acaf455))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>

Copy link
Copy Markdown
Owner Author

Adversarial review of #3269 (round 1).

Head reviewed: 24ffb3fb. Verdict: FIX (no blocker). I found no way to make git read a file, run a program, write a file or reach the network through an accepted form. Counts: 0 blocker, 1 major, 5 minor, 2 nit.

CI at the end: 22 check runs, all success or skipped (including Tests & Coverage and Fail-to-Pass). Local: the 4 touched test modules pass (224 tests), ruff check and ruff format --check are clean, openspec validate --all --strict gives 207 passed, 0 failed (openspec 1.14.3).

Findings

  1. major - The agent is told to run the verification command of each task, but its shell refuses !, and the refusal gives no way out.

    • src/devops_cli/ai/tasks/roadmap_implement_step.md step 5: "Run the verification command of each task." The same prompt says each shell refusal counts against a limit, and that when the limit is used up "the step stops and all your work is lost".
    • Reproduced: refusal_hint('!') returns only "These programs are allowed: git, uv, ... Run the commands of the project with uv run ...". The prompt has no word about a negative search ('negative' in prompt, 'git grep' in prompt are both False). The PR's own test test_the_shell_of_the_agent_refuses_a_command_that_starts_with_a_bang pins this generic answer.
    • So the gate now admits the form and the step runs it at the end, but a model that follows step 5 spends refusals on a command that it cannot run. AC 3 of fix(roadmap): the stage form admits a negative search verify that the implement step refuses #3263 asks for the refusal, so keep it.
    • Fix: give ! a hint (for example in refusal_hint, or a sentence in the prompt): "To check a negative search, run git grep <options> <literal> -- <paths>. No output and exit 1 is a pass." Add a test that the hint is in the answer to ! git grep ....
  2. minor - A path that matches nothing is a pass. Reproduced with the real commands_failure in a scratch git repo: ! git grep -n absent_zz missing/ returns None, and ! git grep -n root src/etcdir/passwd (a path beyond a symlink) returns None. The PR test test_a_path_is_never_read_as_a_revision pins this on purpose. The stage job checks paths of verify at plan time, but at step time a typo or a rename gives a green check. Suggest: say in the design that this is accepted, or print a note when no tracked file matches a path that was not deleted by the group.

  3. minor - Test hole: re.ASCII can be removed from _LITERAL and from _PATH and all four touched test modules still pass (mutation run; both mutants SURVIVED). Real behavior is right today (! git grep -n foo src/ and ... src/ are refused), but nothing holds it. Fix: add a fullwidth or accented literal and path to the refused table.

  4. minor - The fixed shape refuses -e and -E, and the form is common. In openspec/changes/2610-*/tasks.md the Verification line ! git grep -n -E "ImagetoolsFake|inspect_command|imagetools_recording|imagetools_runs" -- src tests is now refused (parse_task_groups + verification_problem: "the option -E is not allowed"). A group has one verify, so a group that removes several names cannot express the check. Also openspec/config.yaml (which the design says names this form) and the other places that teach the form do not give the shape; only docs/TESTING.md and the stage prompt do. Suggest: allow -e <literal> repeated (the value is checked as a literal) or state the limit in openspec/config.yaml.

  5. minor - No length bound. commands_failure(repo, ["! git grep -n " + "a"*300000 + " src/"]) raises OSError: [Errno 7] Argument list too long: 'git' (uncaught, so the step crashes instead of stopping with a reason). 100000 characters runs. The regexes are linear (500000-character option word: 3.9 s, all in shlex), so no ReDoS. Pre-existing for other programs, but the new reader is the place to cap the literal.

  6. minor - The refusal reason echoes the raw word. verification_problem("! git grep -n 'a\x00b' src/") returns a reason that holds the NUL byte, and a newline literal puts a line break in the stop reason. Fix: repr the word, or cut it.

  7. nit - commands_failure repeats the allowlist and unparsed branches of verification_problem instead of calling it (two texts, two places). I found no case where they differ today: mutating verification_problem (program, unparsed, ! reader) is killed by 2 to 8 tests each. A test that runs a refused list through both would keep it so.

  8. nit - Rule 1: the archive commit (63b8809c) is followed by a merge commit, so it is not the last commit. The proposal cites base e0de9ba1; the PR base is 3f3103ab. On the base, test_roadmap_implement_negative_search.py and test_roadmap_implement_shell_policy.py fail only with ImportError at collection (7 stage-form tests fail for the right reason).

Attacks tried that did not break it:

  • Real git 2.43.0 in a scratch repo with core.fsmonitor, core.pager, pager.grep, alias.grep, diff.*.textconv, filter.*.smudge, grep.patternType=perl, grep.fallbackToNoIndex, core.hooksPath and .gitattributes drivers: only core.fsmonitor ran (it runs for any git command; the agent shell already has git with write access, and nothing in this PR adds it). GIT_CONFIG_COUNT/KEY/VALUE, GIT_DIR and GIT_PAGER in the environment: nothing ran (env is scrubbed).
  • Option clusters (-nI, -nnn, -i-w, -nP, -n--), zero-width characters in an option, long options, -e, -f, -O, --no-index, --ext-grep, -- as literal, as option and twice, a literal that starts with a space and holds -O.
  • Paths: /etc, .. in every position, :(top), :!, .git, .git/config (rc 1), *, a tracked symlink to /etc/passwd and to /etc (git does not follow it), HEAD, @, ~, ./src, ; and | glued to a path.
  • Literals: shell characters, $(), backtick, empty, NUL, tab, newline, fullwidth letters, a 100000-character literal.
  • Exit status with real git: -q, -c, -l on a match all give 0 and stop the step; 128 stops; mutants "pass on 0", "pass on nonzero", "pass on < 2", "pass on 0 or 1" are each killed.
  • Same function for both sides: the step runs read_negative_search, the gate runs verification_problem; mutating either side fails tests. _valid_verify and _NEGATIVE_SEARCH_PREFIX are gone from the whole repo outside the archived change. The shell of the agent still refuses ! and !git (test present, no code change).
  • Mutation of the refused table: 31 of 33 mutants of the reader, the gate and the step were killed by at least 1 test (the 2 survivors are finding 3). -- removal from argv, -- not dropped, no-path, no-text, empty literal, loose start words, leading /, leading - and .. were each killed.
  • openspec validate --all --strict, requirement texts under 500 characters, scenarios kept for the modified requirement, change folder complete, Closes #3263 form, title form.

Not verified:

  • mypy on the changed files (timed out in my sandbox; CI Static Analysis is green).
  • The full uv run devops ci.
  • Other git versions than 2.43.0, or another platform.
  • How a real model behaves with finding 1 and with the one-retry stage gate.

Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(roadmap): the stage form admits a negative search verify that the implement step refuses

2 participants