Skip to content

fix(roadmap): tell the agent the step runs a bang command - #3275

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

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

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The shell of the agent refuses !, and the refusal gave only the list of allowed programs. Step 5 of the prompt told the agent to run every verification command, so the agent could spend refusals on a negative search that it cannot run. The refusal and the prompt now give git grep -n <literal> -- <paths>, say that no output is a pass, and say that the step runs a command that starts with ! itself.

The words of a negative search hold at most 2000 characters in all (a word of 300000 characters crashed the step with E2BIG). A word in a refusal reason is escaped and cut. A test pins that a fullwidth or accented literal and path are refused. The step calls the one reader that the stage gate calls, and its three refusal messages are one.

A path that matches no file still passes: a group that deletes a directory needs it, and the stage job checks the paths of verify at plan time. Several names in one search (-e, repeated) are not part of this change.

Refs #3263

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


Generated by Claude Code

The agent shell refused `!` with the list of allowed programs only, and
the prompt told the agent to run every verification command, so the
agent spent refusals on a check it cannot run. The refusal now names the
git grep form and says the step runs the command itself.

Also cap the words of a negative search (E2BIG crashed the step), show
words in a reason escaped and cut, pin the ASCII-only patterns with
tests, and make the step call the one reader that the gate calls.

Refs #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 20:05
@dan-petty
dan-petty merged commit a88f9c8 into main Nov 2, 2026
20 checks passed
@dan-petty
dan-petty deleted the fix/3263-negative-search-followup branch November 2, 2026 20:06
dan-petty pushed a commit that referenced this pull request Nov 2, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.48.2](v0.48.1...v0.48.2)
(2026-11-02)


### Bug Fixes

* **roadmap:** never cut the plan title, count its summary once
([#3272](#3272))
([0e0e017](0e0e017))
* **roadmap:** tell the agent the step runs a bang command
([#3275](#3275))
([a88f9c8](a88f9c8))

---
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 #3275 (round 2).

Verdict: BLOCK (1 blocker, 1 major, 5 minor). Head 54c14a1. CI is green (22 checks). Locally: 348 tests of the 6 touched modules pass, ruff and mypy are clean, openspec validate --all --strict passes 209 of 209, and the requirement bodies are 241 to 362 characters.

Round 1 (#3269) check: finding 1 is fixed (finding 6 here covers the unpinned parts). Finding 2 is accepted, but its stated reason is false (finding 3). Finding 3 is deferred to #3276, which is safe but incomplete (finding 5). Finding 4 is fixed for ! only (finding 4). Finding 5 is fixed. Finding 6 is fixed (the archive commit is last). Finding 7 is partly fixed: with the constant added to base, 55 of 67 tests in that module fail for the right reason.

  1. blocker: the stop reason echoes the raw command, so the escape of the word is bypassed.

    • The spec delta says "the reason holds no raw line break and no NUL byte". _shown escapes the word inside the reason, but commands_failure then writes {command} into the same sentence. _command_shown only cuts it and does not escape it.
    • Repro, with commands_failure(repo, [cmd]):
      • curl \x1b[31mRED gives a reason that holds a raw ESC.
      • ! git grep -n 'a\nb' src/ holds a raw newline.
      • ! rm \x00 x holds a raw NUL.
      • curl <U+202E>evil @octocat holds a raw bidi override and a live mention.
      • ! git grep -n a<U+0085>b src/ holds a raw NEL.
    • It reaches a person. run_step on a tasks.md whose Verification line is curl \x1b[31mRED evil @octocat returns outcome.reason == 'The verification command curl \x1b[31mRED� evil @octocat is refused: ...'. implement_run.stop then posts mask_secrets(reason).strip() to the item with textwrap.indent. The sibling last_message goes through safe_text; the reason does not.
    • parse_task_groups already turns NUL into U+FFFD, so NUL and newline are not reachable through a tasks.md line. ESC, VT, NEL, U+2028 and bidi overrides are. NUL and newline are reachable through commands_failure directly (the eval property verify_passes).
    • The gate path (stage_form._verify_problem) echoes the command uncut and unescaped too. A ! git grep command of 300000 characters gives a 300190-character problem.
    • The test for the scenario asserts verification_problem, not the stop reason, so it passes anyway.
    • Fix: make _command_shown call _shown(command, CONST_ROADMAP_IMPLEMENT_SEARCH_CHARS), and use the same in stage_form. Then assert that no character of outcome.reason is a control or format character (category Cc, Cf, Zl, Zp).
  2. major: failure.py still reads the old text, and the new text changes the class of a stop.

    • failure.py:147 has command \S+ is not allowed. That matches the old "The verification command curl is not allowed. ..." for a one-word command. The PR says "No test or document keeps the old texts"; this regex does, and no test pins it.

    • Repro, with classify_failure(FailureEvidence(text=commands_failure(repo,[c]))):

      Command Base Head
      curl, nc, sh, python, docker, rg refused_tool / action wait types / action repair

      The new text lists mypy and ruff in "is not one of: ...", which matches the types rule.

    • The stop comment now names the wrong class and the wrong next action for a one-word program that is refused. Multi-word commands were already types on base, so this is the same bug, now wider.

    • Fix: classify on a stable marker, for example Verification command .* is refused -> refused_tool, ahead of the types rule. Add a test that both a one-word and a multi-word refusal classify as refused_tool. Remove the dead alternative.

  3. minor: the stated reason for "a path that matches no file passes" is false for the main form.

    • The design says "The stage job already checks the paths of verify ... so a typo is caught there". StagedTree.as_path returns None for any word without a / after normpath, so src/ and tests/ are never checked.
    • Repro: StagedTree([...]).paths_in('! git grep -n name src/ tests/') returns [], and the same for scr/ testz/. commands_failure(repo, ['! git grep -n hello scr/ testz/']) returns None, a pass that searched nothing.
    • Only paths with two or more segments are plan-checked. The form that docs/TESTING.md names (src/ tests/) has no typo check on either side.
    • Fix: let paths_in count a one-segment word that ends in / or is a known top-level name. Or have the step require each path to match a tracked file at start, and not at exit, so a deleted directory still passes. Change the design text either way.
  4. minor: the length cap fixes ! only; the same crash stays for every other verification command.

    • Repro: verification_problem("grep -n zz " + "a"*300000 + " src/") returns None (the gate admits it), and commands_failure(...) raises OSError: [Errno 7] Argument list too long: 'grep'. uv run devops ci test <300000> crashes the same way.
    • The design rejects OSError handling and says the wider crash "is not part of fix(roadmap): the stage form admits a negative search verify that the implement step refuses #3263". The brief rule 11 asks for the cause at its source, and no issue is cited.
    • Fix: file an issue, or bound the whole command in read_verification. A 2000-character limit on every Verification command costs nothing: the longest command in all committed tasks.md is 414 characters, and the longest negative search has 92 characters in its words.
  5. minor: feat(roadmap): let a negative search verify check more than one name #3276 is safe to defer, but its premise is incomplete, and the PR text does not cite it.

  6. minor: mutation survivors. Each mutation was run against the 4 test modules (+ test_roadmap_implement_step.py where it touches the step).

    • Survived: _shown: len(text) <= limit -> < (no test with a word of exactly 60 escaped characters).
    • Survived: word=_shown(rest[0]) -> word=rest[0] (an option word is not tested hostile).
    • Survived: program=_shown(words[0]) -> program=words[0] (the first word is not tested hostile).
    • Survived: _command_shown: <= -> < (no refused command of exactly 2000 characters).
    • Survived: CONST_ROADMAP_IMPLEMENT_SEARCH_CHARS 2000 -> 2001 or 1999. The tests read the constant, so the "2000" of the spec is not pinned.
    • Survived: remove the sentence "the step runs it itself after your run, and the shell refuses !" from step 5. Also survived: remove "To see its result now, run the git grep form ...". The prompt test checks only the prefix and the | ! | row.
    • Killed: the limit (>, sum, missing, first-3-skip), negative flag (3 ways), allowlist skip (step and gate), re.ASCII (4 tests, as claimed), _shown cut, escape and 60, _command_shown cut, docs row, hint sentences, and the bang row. Also killed: the message without a reason, and a moved start check.
    • Fix: add one test for each survivor.
  7. minor: ! is now a known program of the log, so the words after it are logged.

    • _KNOWN_PROGRAMS is built from IMPLEMENT_SHELL_REPLACEMENTS, and the new row adds !. logged_command({'command': '! Authorization: Bearer abcdef0123456789abcdef'}) returns that whole text on head and other on base. A word that has no secret form is shown. Only the first 6 words and 200 characters (existing limits) are logged.
    • Fix: build _KNOWN_PROGRAMS from IMPLEMENT_ALLOWED_PROGRAMS alone, or keep ! out. The log can then say other, and the counter line is the only place it shows.

Attacks tried that did not break it:

  • The shell still refuses ! in every position. 41 commands ran through the real harness Shell with the step hooks, and no process started for any ! form:
    • Plain and spaced: ! git, !git, !!, !$, !-1, !?x, !!:p, ^a^b, \!, '!', "!", ! !.
    • After other text: tab, leading space, FOO=1 !, env !, time !, and the full-width ! and ❗.
    • Inside compounds: &&, ;, |, ||, newline, $(! ..), `! ..`, (! ..), { ! ..; }, and !/bin/true, !;ls, !&&ls.
    • git ! grep x and git grep ! start git as on base; they are not ! commands.
  • The hint text and the table row change only the text. The allowlist of the Shell is IMPLEMENT_SHELL_PROGRAMS, which does not read the refusal table. Finding 7 is the only other reader.
  • Limit edges with a real git repo: totals of 1999, 2000 and 2001 (literal, 1988 or 1989 one-character paths, repeated -n); whitespace of 1 million characters and 500000 pairs of '' (the words stay small, run in under 1 s); 2000 emoji and 5000 emoji (refused before the regex; _shown is not reached; the reason holds 2075 characters).
  • Unicode is characters, not bytes, but the regexes are ASCII, so the accepted argv is at most 2000 bytes plus git grep --. E2BIG cannot come from a negative search.
  • Gate and step on 54 hostile and ordinary commands (uv run devops ..., ;, $(..), >, tabs, ~, .git, src//x, quotes, comments, newlines): 0 mismatches between verification_problem, _verify_problem and commands_failure. Mutating the step side or the gate side is killed (finding 6).
  • Old messages: no source, doc, prompt, fixture or test reads implement_stop_command_denied, _unparsed, _search_refused, or the old sentences, other than failure.py:147 (finding 2).
  • Spec delta: strict validate passes, bodies under 500 characters, MODIFIED text equals the main spec. The archive commit is last. The title is a Conventional Commit.
  • No exec, read, write or network path through the accepted form. .git and src//x pass as paths, but git prints lines only on exit 0.

Not verified:

  • The full CI suite beyond the 6 touched modules (CI itself is green).
  • Whether an item comment with a bidi override or mention is rendered or notified by GitHub (finding 1 stops at the text posted).
  • That repair for types starts a repair round in the Job (finding 2 shows the class and action the comment names).
  • devops ci fail-to-pass itself: I ran the new tests against base by hand instead.

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.

2 participants