Skip to content

feat(permissions): ask before the file tools read or write outside the project - #316

Merged
stippi merged 3 commits into
mainfrom
feat/read-outside-project-permission
Nov 17, 2026
Merged

stippi merged 3 commits into
mainfrom
feat/read-outside-project-permission

Conversation

@daniel-kurzynski

Copy link
Copy Markdown
Collaborator

Summary

The file tools refused every path that leaves the project (absolute, .., or through a symlink), whatever the permission tier. Now they ask the user instead.

  • Reading (read_files, list_files, search_files, glob_files, view_images, view_documents) and writing (write_file, edit, replace_in_file, delete_files) ask before they reach such a path. Each call asks once, covering all of its outside paths: allow once, always (session) or deny.
  • The prompt comes in every tier, bypass-all included. Reads and writes are asked and granted separately: the reason is PermissionRequestReason::OutsideProject with a FileAccess of Read or Write, and a session grant for reads does not allow writes.
  • A session grant covers every tool of that kind and is stored in the session's ToolPermissions. Tools reach it through ToolContext::request_escalation.
  • Files written outside the project get no format-on-save (the format command runs in the project) and no resource events.
  • Where no frontend can ask, the access is still rejected.
  • Writes outside the project go through the same "changed since you last read it" check as writes inside it. read_files records what it saw for outside files too.

Shared helper: tools::impls::outside_project. Docs: docs/permission-tiers.md.

Test plan

  • Unit tests for each tool: allow once, session grant, deny, no mediator, read grant does not cover writes
  • cargo test, cargo clippy --all-targets --all-features -- -D warnings, cargo fmt --check

daniel-kurzynski and others added 3 commits November 13, 2026 12:09
read_files, list_files, search_files, glob_files, view_images and
view_documents refused any path leaving the project (absolute, `..`, or a
symlink), whatever the permission tier. They now ask the user instead,
once per call for all such paths: allow once, always for the session, or
deny. A session grant covers all of these tools. Where no frontend can
ask, the access is still rejected.

Tools reach the session's ToolPermissions through ToolContext, and
ToolContext::request_escalation asks for and remembers such grants.
write_file, edit, replace_in_file and delete_files refused any path
leaving the project. Like the reading tools, they now ask the user
instead. Reads and writes are asked and granted separately: the
permission reason is now OutsideProject with a FileAccess of Read or
Write, and a session grant for reads does not allow writes.

Files written outside the project get no format-on-save (its command
runs in the project) and no resource events.
Address review findings on the outside-project permission:

- Tools use the path resolved before the question, so a symlink changed
  while it is open cannot redirect the access (resolve_and_approve)
- search_files asks before it says whether an outside path exists
- Absolute glob patterns inside the project match; the literal base is
  split by path components, so Windows separators work
- Absolute paths inside the project are made relative for format-on-save
  and resource events
- Outside explorers come from explorer_for everywhere; read_files no
  longer resolves paths again for its resource events
- Parallel calls ask one after another, so an "always" answer covers the
  calls waiting behind it
@stippi
stippi merged commit 62647c3 into main Nov 17, 2026
9 checks passed
@stippi
stippi deleted the feat/read-outside-project-permission branch November 17, 2026 10:17
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