Repository navigation
skill contract: Bash writes to repo files count as edits for check_after_last_edit (GST-1633) - #4078
Merged
Merged
Conversation
…ter_last_edit (GST-1633) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
perl and sed option clusters stop at the first option that takes an attached value, so perl -Ilib t/basic.t, perl -MList::Util and sed -fscript.sed are no longer in-place writes (GST-1633). Review-Finding: p1/red-team#1 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[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.
What changed
A fix written through a Bash heredoc after the last test now reads missing instead of met.
Before/after as text: A fix written through a Bash heredoc after the last test now reads missing instead of met
/investigate's
check_after_last_editcontract item now treats a Bash command that writes a file inside the session directory as an edit. Before, only Edit, Write, MultiEdit and NotebookEdit counted, so a run that tested, then fixed the code through the shell and never tested again readmet. The new parser,lib/shell-writes.ts, reports the files written by>/>>/&>redirects,tee,sed -i/perl -i,patch,git apply, and inline or heredoc python, node, ruby, bun or deno code that opens a literal path for writing. A target counts only when it resolves inside the session directory (the transcript's firstcwd). A check later in the same Bash command counts, and so does the command whose output a redirect orteecaptures (bun test > out.log). The miss detail names the write:no test or repro command after the last Bash write (src/auth.ts)./ship's review found one blocker, fixed in f6e6b50: perl and sed option clusters were scanned for
ithrough attached values, soperl -Ilib t/basic.t(a standard Perl test run) counted as an in-place write of the whole repo and could never satisfy the item. Clusters now stop at the first option that takes an attached value (perl-I -M -m -C -d -D -F -x, sed-e -f).Why
In GEVA-2's L1 run, 5 of 7 probe-I fixes were heredoc writes, and every one of them read
metwith no test after the fix. A contract that says "run the test after your last edit" has to see every edit, or it rewards the shell route it was meant to police.Tests
Failing-first: the two new
check_after_last_edittests in test/skill-contract.test.ts failed on main (the heredoc python write readmet;sed -iwithout a transcript cwd readmet) and pass now. They cover 12 write forms (heredoc python with a variable path,sed -i,tee,>>,cat > file <<EOF,git applyheredoc,patch -p1 <,cd && perl -pi,python -cwithPath.write_text,node -e writeFileSyncto an absolute repo path, a script written to /tmp then run,xargs sed -i), each as missing alone, met with a later test call, met with a test later in the same call, and missing with the test earlier in the same call; plus 25 negative controls and a unit test oflastBashWrite.Blast radius
Only the skill contract checker (the Stop hook and
gstack-skill-contract) callslastBashWrite, andcheck_after_last_editis its one consumer (lib/skill-contract.ts:389, read).parseTranscript's newcwdfields are optional, so existing callers and hand-built transcripts parse unchanged; the full free suite passed at this tree (run 42242441792).Approvals
No approvals recorded for branch capy/gst-1633-bash-writes.
Summary
The Stop hook let a fix written through the shell pass as tested. It now counts in-repo Bash writes as edits, with a conservative parser that ignores reads, stdout, /tmp, home and variable targets. Review hardened the perl and sed option parsing so ordinary Perl test runs are not mistaken for writes.
Test Coverage
Coverage: deterministic (each of 2 changed runtime files has a changed test naming it; no audit reader).
Regression proof: the perl/sed case in test/skill-contract.test.ts (
lastBashWritetest) failed on ce10db3 (perl -Ilib t/basic.treturned{files:['.']}) and passes after f6e6b50.Tests ran: targeted 52
Tests ran: free 1610 (files, carried from CI run 42242441792)
Pre-Landing Review
Pass 1 (full depth, policy risk declared):
Pre-Landing Review: 3 issues — 1 auto-fixed, 2 asked (0 fixed, 2 skipped), 0 deferred, 0 noted. The two skips were taken unattended on the run's recommendation under the crew blocking floor; both are listed under Open notes below.Pass 2 (range ce10db3..f6e6b50):
Pre-Landing Review: 1 issue — 0 auto-fixed, 0 asked (0 fixed, 0 skipped), 0 deferred, 1 notedREVIEW_LOOP: passes=2 blocking_found=1 deferred=0 noted=1 fixed=1 scope=frozen ledgers_read=3 dispatches=4 est_input_tokens=21881
Gate edits: none detected (2 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Outside review: Codex CLI is not installed on this machine, so the outside voice ran as a separate Claude subagent (same model family); it completed with 5 findings, none blocking. Cross-family outside coverage is unavailable.
Review notes
Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.
lib/shell-writes.ts:284perl's -e detection still reads letters.endsWith('e'), so an attached -I/-M value ending in e (-I../include, -Mopen=locale) is taken as -e and swallows the next argument;perl -I../include -pi -e 's/a/b/' src/x.tsis a missed in-place write (a false met, no weaker than main, which saw no Bash writes)lib/shell-writes.ts:282perl -E and -V: are not option-cluster stops and -E is not treated like -e, soperl -nE'print if /x/' src/a.pm,perl -E'print 1'andperl -V:libpthread as writes of '.' (pre-existing, also on ce10db3); a false missing after the last checklib/shell-writes.ts:282C and d in the perl stop set hideperl -dpi -e ... src/a.pm(and-CSDpi, which perl itself rejects per outside-voice#5) as writes; a rare missed in-place edit, no weaker than mainlib/shell-writes.ts:286an attached sed -e/-f script (sed -i -es/a/b/ src/a.py src/b.py) is not marked as the script, so rest.slice(1) drops the first target or widens it to '.' (pre-existing over-approximation)lib/shell-writes.ts:284letters.endsWith('e') treats an attached -M/-I value ending in e as -e, soperl -MTime::Piece -pi -e ... src/a.pmandperl -Ilib/site -pi -e ...now return null (found by ce10db3 by accident); a missed write and false met, no weaker than main. Same as p2/red-team#1Open notes from pass 1 (skipped, below the blocking floor):
lib/shell-writes.ts:306An inline interpreter repro that also writes an output file inside the repo (open('out.json','w')) is the last edit and cannot count as its own check, so the item reads missing where main read met; the agent recovers by running any other check.lib/shell-writes.ts:338A redirect is always the writer's own output, sopython3 -c ... > src/app.pyis credited as its own check; main read met for the same transcript, so the gate is no weaker than before, but this form of shell-written fix is not closed.Exploratory QA
Target:
bin/gstack-skill-contract check(the Stop hook's checker), functional CLI surface, synthetic transcripts under /home/user/.capy/work/gstack-1633/qa/t (root /repo). Smoke: 5 probes on ce10db3, then 5 revalidation captures after the perl/sed option fix.Results
perl -Ilib t/basic.tafter an Edit read missing on ce10db3 (003); after the fix it reads met (008: pass)python3 -c ... > src/app.pyreads met (004, 009): documented behavior, noted design limitVerdict: pass (gstack-qa-evidence materialize). Checkpoints: checkpoint 002 checkpoint 003 checkpoint 004 checkpoint 005 checkpoint 006 checkpoint 007 checkpoint 008 checkpoint 009 checkpoint 010
Limits
Captures 001-005 are superseded. The debug-report item fails in every fixture because the fixture's DEBUG REPORT predates the installed labels; only check-after-last-edit is under test.
Design Review
No frontend files changed — design review skipped.
Eval Results
No prompt-related files changed. The eval selector's PR profile names 120+ behavioral probes through derived references to lib/shell-writes.ts and lib/skill-contract.ts; the narrow PR screen (evals.yml run 42237202397) planned 0 of them and leaves them to the train gate's full census. No paid eval ran; $0 spent.
Review bot comments
No review bot comments.
Plan Completion
Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). Fix: add "Plan: " to the PR body, or run /autoplan.
Issues
Refs p1/red-team#1
Verification Results
No Step 8.1 obligations (no plan bound). Exploratory QA: 10 captures, verdict pass.
TODOS
No TODO items completed in this PR.
Documentation
Scope: main...HEAD (5 files: lib/shell-writes.ts, lib/skill-contract.ts, test/skill-contract.test.ts, docs/skill-routing-and-contracts.md, changelog.d fragment); working tree clean.
Result: Current. The
check_after_last_editrow in docs/skill-routing-and-contracts.md already says that Bash writes inside the session directory count as edits, and it matches the parser's behavior. The changelog.d fragment is accurate.Debt: None found.
Test plan
🤖 Generated with Claude Code