Repository navigation
fix(plan): route diff inspection through safe git tools - #91
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The changes consistently enforce diff inspection via structured Git tools, align documentation with the threat model, and add targeted tests validating the security boundary against diff.external and textconv execution.
Pull request overview
This PR tightens Plan Mode’s read-only investigation boundary by routing all diff/patch inspection through the structured git-read tools (git_diff/git_show) and proactively loading the search capability when Plan Mode is entered or restored, preventing repository-configured diff drivers (diff.external, textconv) from executing during planning.
Changes:
- Auto-load the
searchcapability on Plan Mode entry/restore sogit_log/git_diff/git_showare available in-session. - Refuse raw Bash
git diff/git show/git whatchangedand diff-generatinggit logoptions while still allowing non-diff Git/GitHub inspection. - Expand tests and documentation to reflect the new boundary and validate that structured tools don’t execute hostile diff/textconv helpers.
File summaries
| File | Description |
|---|---|
| SETUP.md | Documents the Plan Mode exception that loads search and clarifies blocked raw diff commands and the structured Git boundary. |
| README.md | Updates user-facing Plan Mode guidance and threat-model wording to prefer structured Git tools for diffs. |
| extensions/plan-mode/index.ts | Loads search capability when planning is active; allows git_log/git_diff/git_show as Plan Mode-safe tools; updates in-UI Plan Mode guidance. |
| extensions/plan-mode/index.test.ts | Adds/updates tests asserting Plan Mode loads search and preserves gating behavior across restore flows. |
| extensions/plan-mode/bash-policy.ts | Blocks raw diff-rendering Git subcommands and diff-generating git log flags; improves threat-model commentary accordingly. |
| extensions/plan-mode/bash-policy.test.ts | Updates allow/refuse expectations to match the new Git diff policy and adds coverage for the newly refused forms. |
| extensions/git-read/index.test.ts | Adds explicit hostile diff.external/textconv execution controls and asserts structured git_diff/git_show don’t trigger them; strengthens diff form coverage. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
tt-a1i
left a comment
There was a problem hiding this comment.
Thanks for the focused implementation. The diff-driver-specific part is solid: raw diff-producing commands are refused, the structured tools force --no-ext-diff --no-textconv --no-color, and the new hostile diff.external/textconv controls plus common diff-form tests pass. I also ran the repository gates locally at this exact head: bun run check, 848 Node tests, 30 Vitest tests, and git diff --check all pass.
One blocking gap remains against Issue #70 as currently written. Plan Mode still permits raw git status; repository-local core.fsmonitor can execute an external helper during that command. On this head, planBashDecision("git status --short") returns allowed, and a temporary-repository control with core.fsmonitor=/usr/bin/touch <marker> created the marker. The README now narrows the guarantee to diff drivers, but #70 asks that the Plan Mode read-only guarantee not depend on hostile repository Git configuration.
Please either harden the remaining config-sensitive Git inspection path (for example, route it through a structured/config-isolated execution seam) or first align and explicitly narrow #70's contract with the maintainer. With the issue's current scope, this is partial rather than complete.
GitHub CI has not run yet (action_required, no jobs), so that remains a separate gate after this finding is addressed.
| ); | ||
| } | ||
| } | ||
| return scanArguments(args, GIT_FLAGS, "git"); |
There was a problem hiding this comment.
Blocking: this generic path still admits git status --short. Git status can execute a repository-local core.fsmonitor helper; I reproduced that on this head with a marker-writing helper while the policy returned allowed: true. That leaves Issue #70's top-level guarantee dependent on hostile Git config. Please route remaining config-sensitive Git reads through a hardened structured/config-isolated seam, or explicitly narrow the issue contract before treating the implementation as complete.
tt-a1i
left a comment
There was a problem hiding this comment.
Approved against the clarified Issue #70 contract. The earlier core.fsmonitor finding assumed a broader hostile-Git-config sandbox; #70 now explicitly scopes this fix to the Plan Mode diff-driver seam (diff.external and textconv), so that finding is no longer a blocker. The implementation keeps the mechanism narrow: raw diff-rendering Git commands are blocked in Plan Mode, structured git_diff/git_show run with fixed --no-ext-diff --no-textconv --no-color flags, and docs/tests state the trust boundary. Revalidated after updating the branch to current main: bun run check, bun run test (867 Node tests + 30 Vitest tests), diff check, isolated Pi package/Plan Mode wiring smoke, and GitHub CI on Node 22.19 and Node 24 all pass.
Summary
searchcapability whenever Plan Mode enters or restores a planning state, makinggit_log,git_diff, andgit_showavailablegit diff,git show,git whatchanged, and diff-generatinggit logoptions while preserving non-diff history and status inspectionSecurity boundary
Structured
git_diffandgit_showalways pass:--no-ext-diff--no-textconv--no-colorThis closes the repository-configured
diff.externaland textconv execution seam without claiming that every possible hostile Git configuration is inert. Remaining allowlisted Git investigation commands continue to run within Pi's existing project Trust boundary.Tests
Passed:
diff.externaland textconv controls on Windowsbun run lintbun run typecheckgit diff --checkWindows validation notes:
bun run checkwas attempted, but the repository-wide Biome format step reports the existing CRLF checkout of JSON/config files; the changed TypeScript files pass formatting, lint, and typecheck.bun run testwas attempted; unrelated tests in untouched Background Terminal process-management and Windows path-separator assertions failed, after which the suite did not terminate. All suites in scope for this change pass.Closes #70