Skip to content

Isolate unsandboxable providers from the repo cwd in scry plan - #21

Merged
dandragona merged 2 commits into
mainfrom
dandragona/plan-readonly-cwd-isolation
Jun 21, 2026
Merged

dandragona merged 2 commits into
mainfrom
dandragona/plan-readonly-cwd-isolation

Conversation

@dandragona

Copy link
Copy Markdown
Owner

Problem

scry plan gives 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 -p mode it auto-approves file writes. A planning run could (and in testing did, twice) silently modify the working tree.

Verified upstream limitations:

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:

  • claude — --disallowedTools (caps.mutator_disallow)
  • 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 (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) in call_cli) is to restrict such providers to read-only tools once agy exposes it for -p, and to scrub $PWD/$OLDPWD from 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

`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>
Comment thread scry Fixed
…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>
@dandragona
dandragona merged commit 3b673f4 into main Jun 21, 2026
7 checks passed
@dandragona
dandragona deleted the dandragona/plan-readonly-cwd-isolation branch June 21, 2026 17:56
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.

2 participants