Skip to content

Stage D: ask before reading outside the workspace (session read grants)#6

Closed
Anmolnoor wants to merge 1 commit into
stage-c/user-questionsfrom
stage-d/out-of-scope-escalation
Closed

Stage D: ask before reading outside the workspace (session read grants)#6
Anmolnoor wants to merge 1 commit into
stage-c/user-questionsfrom
stage-d/out-of-scope-escalation

Conversation

@Anmolnoor
Copy link
Copy Markdown
Owner

Context

The final stage of the "make fcli ask me" feature, and the security-sensitive one. Out-of-scope file reads previously hard-blocked silently (the same boundary that blocked reading the beekeeper repo). Now an out-of-scope read asks the user, and on approval grants read-only access to that directory for the rest of the session.

Note: based on stage-c/user-questions; merge order #3#4#5 → this. Reuses Stage C's question/prompt plumbing.

Design (scoped to stay safe)

Out-of-scope reads are blocked at two layers — the guardrail policy and the FileService's own path confinement — so a grant has to be honored by both. A shared ScopeGrantStore (in-memory, read-only) does that.

  • Guardrails: an out-of-scope path on builtin.file.read / builtin.file.read_chunk with read-only side effects now yields a REQUIRE_APPROVAL verdict tagged PolicyReasonCode.SCOPE_ESCALATION instead of BLOCK. A granted root counts as in-scope, so repeat reads under it don't re-prompt. Writes, shell, and discovery stay hard-blocked — escalation is deliberately limited to typed file reads where a grant can actually be honored.
  • PolicyDecision gained reason_codes so the executor distinguishes a scope escalation from a normal approval.
  • Executor: on a scope-escalation decision it prompts Allow for this session / Deny (via Stage C's question callback), grants the path's directory on approval, then proceeds; denial — or no interactive prompt — blocks. Never silent-allows, regardless of approval mode.
  • FileService: reads consult the grant store via _resolve_read_path; writes stay workspace-confined.

Tests

4 new (397 total, ruff clean): granted session read + a sibling read under the same root without re-prompting; denial blocks; an out-of-scope write is never escalated and stays blocked; and a FileService-level boundary test (granted read ok, non-granted blocked, write-to-granted-root still blocked).

Sequencing

Final stage of A→B→C→D. With all four merged, fcli no longer crashes on large writes and pauses to ask you — both for genuine ambiguity and before stepping outside the workspace.

🤖 Generated with Claude Code

Out-of-scope file reads previously hard-blocked silently. Now an out-of-scope
read of a typed file capability asks the user for permission and, on approval,
grants read access to that directory for the rest of the session.

- New ScopeGrantStore (in-memory, read-only) shared between the guardrail
  policy engine and the file service so one grant unblocks both layers.
- Guardrails: an out-of-scope path on builtin.file.read / read_chunk with
  read-only side effects yields a REQUIRE_APPROVAL verdict tagged
  PolicyReasonCode.SCOPE_ESCALATION instead of a BLOCK; a granted root counts
  as in-scope so repeat reads don't re-prompt. Writes, shell, and discovery
  stay hard-blocked.
- PolicyDecision carries reason_codes so the executor can distinguish a scope
  escalation from a normal approval.
- Executor: on a scope-escalation decision it prompts (Allow for this session /
  Deny) via the Stage C question callback, grants the path's directory on
  approval, then proceeds; denial (or no interactive prompt) blocks. Never
  silent-allows, regardless of approval mode.
- FileService: reads consult the grant store via _resolve_read_path; writes
  remain workspace-confined.

Tests: granted session read + sibling read without re-prompt; denial blocks;
out-of-scope write is never escalated and stays blocked; FileService read-grant
boundary (granted read ok, non-granted blocked, write still blocked).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Anmolnoor
Copy link
Copy Markdown
Owner Author

Merged into main via commit 27c97b0 (stages A–G landed as one merge). See the summary on #9.

@Anmolnoor Anmolnoor closed this May 27, 2026
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.

1 participant