Skip to content

fix(guard): cross-repo scope + companion-rescue Bash for tri-review - #96

Merged
5uck1ess merged 2 commits into
mainfrom
fix/bugfixes
Apr 17, 2026
Merged

fix(guard): cross-repo scope + companion-rescue Bash for tri-review#96
5uck1ess merged 2 commits into
mainfrom
fix/bugfixes

Conversation

@5uck1ess

Copy link
Copy Markdown
Owner

Summary

Fixes the two tri-review blockers from #95 that are in devkit's scope.

Closes #95.

Changes

  • src/cmd/guard.go — cross-repo scope check in runPreToolGuard, companion-rescue carve-out in the prompt+hard branch, readToolNameFromStdinreadToolInvocationFromStdin (also parses tool_input.command), isCompanionRescueCommand helper with .mjs-suffix match.
  • src/cmd/guard_test.go — 4 new rows in TestGuardPreToolUse (companion allow × 2, unrelated Bash block, command-step rescue-looking Bash still blocks); new TestGuardPreToolUseRepoScope (5 subtests covering cross-repo allow, matching-repo block, empty RepoRoot fail-closed, unresolvable current repo fail-closed, command-step session cross-repo).

Test plan

  • go test ./... — 371 tests pass across 6 packages
  • go vet ./... clean
  • gofmt -l . clean
  • TestGuardPreToolUseRepoScope (5 subtests) green
  • TestGuardPreToolUse rescue-Bash rows green
  • Post-merge: rerun /devkit:tri-review on a multi-model PR and confirm both Codex and Gemini rescue paths produce output

Two fixes for tri-review blockers reported in #95:

- PreToolUse guard now honours state.RepoRoot the same way the
  stop-guard does since #91. A wedged workflow in repo A no longer
  blocks unrelated tool calls in repo B for the full TTL window.
- Prompt+hard allows Bash when the command invokes codex-companion
  or gemini-companion — the rescue subagents require that nested
  Bash to reach external models, and tri-review's model-diversity
  invariant fails silently without it.

readToolNameFromStdin is renamed readToolInvocationFromStdin and now
also extracts tool_input.command so the Bash carve-out can inspect
the payload without a second parse pass.
Prevents a trivial bypass where a Bash comment token like
`# codex-companion` would satisfy the substring match. Both
real companions ship as .mjs so the tightening doesn't break
any intended invocation style. A future .js/.cjs adapter must
update this allowlist deliberately rather than relying on the
loose match.
@5uck1ess
5uck1ess merged commit b4c4a89 into main Apr 17, 2026
6 checks passed
@5uck1ess
5uck1ess deleted the fix/bugfixes branch April 17, 2026 20:40
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.

tri-review: multiple blockers prevent actual model-diversity review

1 participant