Skip to content

chore(agents): the tool guard repairs a call whose fix is known, refuses a push to main and adds the rule sections agents open - #1923

Merged
V3RON merged 8 commits into
mainfrom
chore/guard-repairs
Nov 27, 2026
Merged

V3RON merged 8 commits into
mainfrom
chore/guard-repairs

Conversation

@V3RON

@V3RON V3RON commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Why

Workflow review 2026-11-27 (instructions-and-tokens 5, 8, 9, 10, 20; autonomy 13):

  • Two refusals cost a turn each though the fix is known: a test run without timeout: 600000 (174 in 21 days), tsc --noEmit (88).
  • On 2026-11-20 a triage agent's git push -u origin bug/1790-repro put d7bd191 on main: the branch tracked origin/main and push.default is upstream.
  • Three roles open the same rule sections almost every run.

What

  • A sub-agent's test run gets timeout: 600000, and its tsc --noEmit becomes pnpm typecheck. additionalContext says so.
  • Every session's push that lands on origin's main is refused, the upstream case included. Nine deny rules cover the forms a pattern names.
  • A reviewer whose prompt names inputs: (a replay) gets the pinned review-protocol.md.
  • Added to the prompt from the rule files: "Tests agents run" for the code lens; "Slow lane" for the hardware verifier; "Tests agents run", testing rule 10 and delivery rules 8 and 17 for the bug triager.
  • A new branch tracks no base: --no-track in worktree.sh and the triager's git switch -c.
  • disableClaudeAiConnectors: true.

Proof

Replay of the refusals in it/rows2.jsonl through the new guard, full tool input from the transcripts
  test without timeout   174 cases: 0 refused for the timeout, 170 repaired (timeout 600000, command kept),
                         4 refused by a rule the old refusal hid (3 background job, 1 slow-lane file)
  tsc --noEmit            88 cases: 77 run `pnpm typecheck`; 11 still refused: 7 name the e2e project,
                         3 also run oxlint or fallow, 1 follows a `cd $W` the guard cannot read

Every `git push` of 2026-11-13..27 through the old and the new guard: 886 commands (725 sub-agent, 161 main)
  the branch as recorded, no upstream set      0 new refusals, 0 refusals lifted, 0 deny-rule matches
  the same with the branch tracking main     316 refused: every `git push [-u] origin <branch>` and bare push
    their recorded output names the target     2 `main` (d7bd191cf; a later one git rejected), 67 their own branch,
                                             247 none (piped away); `main` got no other commit outside a PR or a release

Live, two Haiku sub-agents in this checkout: a 125 s command with no timeout came back in the foreground;
`pnpm exec tsc --noEmit -p .` ran `pnpm typecheck`; both results carried the guard's note.

Characters added to a prompt (tokens at 3.22 chars; the report estimated about 1k tokens a role)
  code lens            1,886   about   590
  hardware verifier    6,573   about 2,040
  bug triager          7,288   about 2,260

Unit: src/tool-guard.test.ts, 242 tests, with the 2026-11-20 command, each push form, each accepted
`tsc` form and 29 neighbours that are never rewritten;
src/worktree-script.test.ts: a branch cut from origin/main has no upstream (fails without --no-track).

Not verified: the pinned protocol on a real replay; the deny rules in Claude Code itself; connectors gone from a new session.

Review

Spec review: skipped. Code review: 1 blocking, 1 fixed, 3 notes. Claims review: 0 blocking, 1 fixed, 0 notes.
Rounds: 3. Tokens: 6.2M.
Assessment: complete

Written by an agent.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: 23c7e0cb-7111-442f-8181-a1a31be87c78
Commits

Reviewing files that changed from the base of the PR and between e206ead and 9ed0554.

Files selected for processing: 14

  • .agents/briefs/implement-audit.md
  • .agents/briefs/implement-build.md
  • .agents/briefs/implement-fix.md
  • .agents/briefs/implement-refactor.md
  • .agents/briefs/review-code.md
  • .agents/scripts/tool-guard.mjs
  • .agents/scripts/worktree.sh
  • .claude/agents/bug-triager.md
  • .claude/agents/hardware-verifier.md
  • .claude/agents/implementer.md
  • .claude/settings.json
  • docs/internal/agent-rules/toolchain.md
  • src/tool-guard.test.ts
  • src/worktree-script.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@V3RON
V3RON marked this pull request as ready for review November 27, 2026 11:47
@V3RON

V3RON commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Review notes

  • code: .agents/scripts/tool-guard.mjs, asTypecheck. Removing the re-parse comparison leaves every test green: it is defensive code no test exercises. The mismatches it guards against are refused by forbiddenCheck anyway.
  • code: the narrowing is intentional. pnpm -s exec tsc --noEmit, pnpm exec -- tsc --noEmit and /usr/local/bin/tsc --noEmit are refused now, and the refusal names pnpm typecheck.

Written by an agent.

@V3RON
V3RON merged commit 3505a0c into main Nov 27, 2026
45 checks passed
@V3RON
V3RON deleted the chore/guard-repairs branch November 27, 2026 18:24
V3RON added a commit that referenced this pull request Nov 29, 2026
… lens is sent back, and script tests are linted for Windows traps (#1950)

## Not verified

```
These checks stop the forms agents use, and mistakes; a call built to evade them (through a
script file or another interpreter, say) is stopped only at the merge gate: pr-body-check.mjs,
and the author check of PR #1944.

Last fix run (lens check at e411922):
- R4  gh-argv.mjs reads gh's arguments as gh does (-R/--repo/--hostname first, --flag=value,
      glued and combined short flags); the shim's body and label checks and the guard's write
      check all use it. A sub-agent's `gh alias` or alias is refused; extensions pass.
- R2, R20  the guard reads the mark and the shim bypasses from the parsed words (quotes removed,
      pieces joined, strings kept whole, `bash -c` scripts included); a sub-agent's eval or a
      sourced file the same call wrote is refused beside a gh write; a `gh` function always.
- R21 delivery.md says which of the two refuses what.

Replay at a8cbec0 (CI green), 28 days: 17,144 Bash calls (11,175 sub-agent). Guard, new
rules: 0 refused (eval and a sourced file it wrote refuse only beside a gh write). Shim,
sub-agent mode, 4,650 gh commands: 1 refusal, a reviewer's deliberate probe. Bodies on GitHub's text: 1,001 found, false refusals 0.

#1944's guard test now belongs to the shim's tests (the guard no longer reads labels).
A sandbox delivery with the shim at e411922 merged two deliveries; bodies and labels passed.
```

## Why

Workflow review 2026-11-27 (instructions-and-tokens 6, review-and-gates
8). Replayed deliveries lost 3.2 turns each to refusals: unreadable
bodies, wrong `ledger:` lines, review rounds with no lens.

## What

- A `gh` shim first on PATH (`session-env.sh`) checks a body when gh
runs. The guard stops parsing bodies, and refuses gh by a path or after
a PATH change.
- A wrong `ledger:` line is rewritten, or refused with the exact line.
- `report-guard` sends back a round 1 or 2 with no lens, reads its lines
loosely, and lets a clean later check skip the findings file.
- The test lint flags three Windows traps in agent-script tests.
- The shim lets a sub-agent write labels only by `gh issue|pr edit` or
`create` label flags (all 28 days of real use), never removing
`fast-track` or `fast-track-review`.
- Findings need `path:line`; a later check's inputs carry the previous
`findings.json`.

## Proof

```
Replay at this head, transcripts of 28 days: 9,844 Bash calls that run gh (3,881 sub-agent).
  guard, new rules: 0 refused (one main-session `export PATH=...; gh api -X POST .../cancel`
                    was, until the rule counted only calls the shim checks)
  shim, sub-agent mode, 4,650 gh commands: 1 label refusal, a reviewer's deliberate probe
                    (`gh api --hostname 127.0.0.1:9 -X=DELETE .../labels/fast-track`); 0 false
  bodies on GitHub's text: 1,001 found, 1,000 pass, 1 real defect: false refusals 0 of 1,001

Shim: every gh issue|pr|api call with a body, transcripts 2026-11-08..28: 1,408 (470 sub-agent).
The guard's verdict as recorded; the shim run on the body rebuilt from the transcript.
  guard passed           1,110   replayed on the text GitHub received (a comment by the URL gh
                                 printed, else by time; an edit or create by its edit history):
                                 1,001 found: shim passes 1,000, refuses 1, a real defect (PR #1766
                                 body at 14:11 had no footer; added at 14:18). False refusals: 0 of
                                 1,001. Not found 109: 67 releases or reviews, 40 creates whose
                                 output the transcript dropped, 2 with no version in 10 minutes
  guard: body shape         57   shim refuses the same defect 43, unknown 9, passes 5 (the guard
                                 read the file before `printf <footer> >> f` earlier in the call)
  guard could not read     235   (122 `$(...)`/variable, 113 file not there yet) shim verdict on 111:
                                 102 pass, 9 refused (7 footer or handoff, 2 triage over 300 words)
  gh run by a path            0   in 28 days

Ledger tag: 44 spawns refused in 28 days (25 sessions, 19 a second time in a row):
  36 repaired (32 `[ledger #N implement]`-style builds), 8 refused with the exact line.

Report guard, 720 reviewer runs, 28 days:
  round 1 or 2 with no lens: 57 (25 r1: 8 said complete, 17 incomplete; 32 r2: 27 complete)
    all 57 sent back; 0 of 473 runs that started a lens; 0 of 170 fix-checks with none.
  sends-back then: 424 in 310 runs; 311 pass now (36 once their file exists), 98 still sent back
  named cases as tests: before-2 #77, after-1 #103 (incomplete), PR #1862 round 1 (complete)

path:line: 834 of 854 findings in 316 ledgers (PRs merged 10-29..11-27) have no line.

Windows lint: flags PR #1919's first head (fake pmset -g), PR #1924 at 1c9611f (CRLF quote)
  and 031fc6a (2 merges with no git identity); 0 on both merged heads; 0 on main's 778 test
  files. Misses 1caed1e (fakeCommandEnv where the fake is written only off Windows).

Sandbox passes, 77 refusals in 24 deliveries: #1923 repairs 17, this PR removes 45 (18 ledger
  spawns, 27 bodies), 15 left: 3.21 -> 0.63 per delivery (after-1, with #1923: 3.25 -> 0.75);
  Agent spawns refused 19 -> 1. About 2 of the 27 bodies hold a real defect the shim refuses.
```

## Review

Spec review: skipped. Code review: 9 blocking, 9 fixed, 0 notes. Claims
review: 3 blocking, 3 fixed, 0 notes.
Rounds: 5. Tokens: 10.6M.
Assessment: complete

*Written by an agent.*
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.

1 participant