Repository navigation
Isolate unsandboxable providers from the repo cwd in scry plan - #21
Merged
Merged
Conversation
`scry plan` gives the panel read-only access to the repo cwd, but the guarantee was enforced per-provider and agy/Gemini has no read-only mechanism: in headless `-p` mode it auto-approves file writes, so a planning run could (and did) silently modify the working tree. Add `_provider_repo_safe()`: a provider may run in the user's repo only if it has a proven read-only mechanism (claude `--disallowedTools`, codex `--sandbox read-only`, kimi read-only agent file). Anything else — agy and unknown/future providers — runs in a throwaway temp cwd (fail-closed), gated in both `call_cli` and `stream_call`. Those providers trade repo grounding for safety; the rest keep grounding. Temporary measure (see TODO in `call_cli`): the proper fix restricts such providers to read-only tools once agy exposes it for headless runs (google-antigravity/antigravity-cli#45), and should also scrub `$PWD`/`$OLDPWD` from the child env. Test: tests/test_call_cli.py::TestCwdIsolation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…cept) The `except (BrokenPipeError, ...): pass` is pre-existing logic that the read-only re-indent moved into this PR's diff, so CodeQL surfaced its long-standing `py/empty-except` note. Document why the pass is correct (the child may have already closed stdin / exited) to resolve it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.
Problem
scry plangives the panel read-only access to the repo cwd so drafts are grounded in the code. But the read-only guarantee was enforced per-provider, and agy/Gemini has no read-only mechanism — in headless-pmode it auto-approves file writes. A planning run could (and in testing did, twice) silently modify the working tree.Verified upstream limitations:
agy --sandboxonly restricts shell/terminal tools —write_filestill executes.-pruns google-antigravity/antigravity-cli#45).Fix
Add
_provider_repo_safe(p): a provider may run in the user's repo cwd only if it has a proven read-only mechanism:--disallowedTools(caps.mutator_disallow)--sandbox read-onlyAnything else — agy, and unknown/future providers — runs in a throwaway temp cwd (fail-closed). Gated in both
call_cliandstream_call(the only two subprocess spawn points), so it covers interview, panel, judge, and synthesis. Those providers trade repo grounding for safety; the rest keep grounding. Derived in code (not a config flag) so existing user configs are protected automatically.Temporary measure
This is cwd-isolation, not tool-restriction — agy loses repo grounding. The proper fix (tracked in a
TODO(read-only-hardening)incall_cli) is to restrict such providers to read-only tools once agy exposes it for-p, and to scrub$PWD/$OLDPWDfrom the child env.Tests
tests/test_call_cli.py::TestCwdIsolation— asserts an unsandboxable provider (agy) never runs in the given repo cwd, while a read-only one (kimi) does. Full suite green (531 tests).🤖 Generated with Claude Code