Skip to content

fix(plan): route diff inspection through safe git tools - #91

Merged
tt-a1i merged 2 commits into
openpi-dev:mainfrom
CuSO41108:codex/issue-70-plan-git-safety
Aug 24, 2026
Merged

tt-a1i merged 2 commits into
openpi-dev:mainfrom
CuSO41108:codex/issue-70-plan-git-safety

Conversation

@CuSO41108

Copy link
Copy Markdown
Contributor

Summary

  • load the search capability whenever Plan Mode enters or restores a planning state, making git_log, git_diff, and git_show available
  • reject raw git diff, git show, git whatchanged, and diff-generating git log options while preserving non-diff history and status inspection
  • update Plan Mode guidance, documentation, and threat-model wording to direct diff inspection through the structured Git tools

Security boundary

Structured git_diff and git_show always pass:

  • --no-ext-diff
  • --no-textconv
  • --no-color

This closes the repository-configured diff.external and 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:

  • focused Plan Mode, git-read, and real Pi tool-surface suites: 52 tests
  • hostile diff.external and textconv controls on Windows
  • worktree, staged, revision, and path diff coverage
  • changed-file Biome format check
  • bun run lint
  • bun run typecheck
  • git diff --check
  • explicit current-checkout Plan extension smoke with the local Pi CLI

Windows validation notes:

  • bun run check was 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 test was 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

Copilot AI lite review requested due to automatic review settings August 23, 2026 15:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 search capability on Plan Mode entry/restore so git_log/git_diff/git_show are available in-session.
  • Refuse raw Bash git diff/git show/git whatchanged and diff-generating git log options 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 tt-a1i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 tt-a1i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tt-a1i
tt-a1i merged commit 5398c2e into openpi-dev:main Aug 24, 2026
2 checks passed
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.

Plan Mode:原始 git diff/show 可通过仓库配置执行外部程序

3 participants