Repository navigation
fix(bash): narrow the shell-search opt-in to file lists and counts; close the bash -c and loop dodges - #40
Merged
Merged
Conversation
…h; check bash -c and loop bodies Co-Authored-By: lemoncrow <302591943+lemoncrow-agent[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Four days after #38, agents were mostly getting around the block instead of switching to
code_search:LEMONCROW_SHELL_SEARCH=1prefix appeared on 713 shell calls, against 115 calls that were actually blocked. 46% of blocks were followed by the same search rerun with the prefix; only 19% by a code search.code_searchanswers. Very little is the exhaustive enumeration the opt-in was for.bash -c '...'and one inside afor ... do ... doneloop body were never checked. Andexport LEMONCROW_SHELL_SEARCH=1;early in a chain unlocked everything after it.Net: Opus 5.5 build agents moved from 15% to 21% of repo searches through
code_search, while still running ~17 shell repo searches per 100 tool calls.What
grep -rl/-L/-c,rg -l/-c/--count-matches,git grep -l/--name-only/-c. That is what a rename needs (the file list, then edit). A prefixed search that prints matching lines is blocked like any other.LEMONCROW_SHELL_SEARCH=1 grep -rl ...,env LEMONCROW_SHELL_SEARCH=1 ..., or on an inline shell running it (LEMONCROW_SHELL_SEARCH=1 bash -c '... grep -rl ...'). Anexport, or an assignment on another command in the chain, no longer counts.bash -c '...'/sh -cpayloads are followed (with the currentcd), and a segment's leadingdo/then/else/if/while/!is skipped to reach the real command.LEMONCROW_SHELL_SEARCH=1 grep -rl PATTERN DIR.Unchanged: everything the index can't answer still runs without any prefix (single files, outside the repo, dependency/build/gitignored dirs, other revisions, stdin, output feeding a command).
Replay against real sessions
All 12,059
lc bashcommands since Sep 22 whose working directory still exists, classified by the installed (#38) check and this one:Of the 476 prefixed commands that still run, 259 are single-file or non-recursive greps (never blocked; the prefix is superstition), 31 feed their output into a command, 20 list files (the intended use), and 153 search worktrees deleted since then, which the replay can't judge (at the time they were live and would now be blocked).
Verification
test_bash_exec_repo_search_block.py: 57 cases (16 new): prefixed line-printing searches blocked;-l/-c/--count-matches/--name-only/--files-with-matchesallowed with the prefix;exportand other-segment prefixes ignored;bash -c/sh -c,for ... do,if ... thenbodies blocked; prefixedbash -crunning a list-only search allowed; end-to-end MCPbashrun of a prefixedgrep -rl.