zarvis: auto-approve batched widget-dir edits; teach reviewer the widget dir#347
Merged
Conversation
…get dir The daemon already adds the session widget directory to the auto-approve policy, and effective_risk downgrades widget-dir `edit_file` writes to Safe — but `auto_approve_covers` only inspected the top-level `path`, so the batched `edits[]` form (which the model is encouraged to use) still hit the approval gate. Cover both forms: an `edit_file` call is auto-approved only when every target path — the single top-level `path`, or each `edits[].path` falling back to the top-level one — is inside an allowed directory. A single out-of-policy target keeps the whole call gated. This makes creating/updating widget files auto-approved in every mode, single-hunk or batched. Also tell the auto-review reviewer where the session widget directory is and that maintaining its files is routine, so the residual cases that still reach the reviewer (e.g. shell reads or removals of widget files) are approved rather than bounced to the user.
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.
Goal
Make sure file operations on a session's own widget directory (the agent's session-UI scratch space) are auto-approved, so they don't bounce to the user under auto-review.
What I found
The daemon already adds the session widget dir to the auto-approve policy (
AGENTD_AUTO_APPROVE_PATHS,session.rs), andeffective_riskalready downgrades widget-diredit_filewrites toSafe. Butauto_approve_coversonly inspected the top-levelpath— so the batchededits[]form (which the model is encouraged to use) wasn't covered and still hit the approval gate.Fix
Part A — deterministic (
tools/mod.rs):auto_approve_coversnow covers bothedit_fileforms. A call is auto-approved (Safe) only when every target path — the single top-levelpath, or eachedits[].pathfalling back to the top-level one — is inside an allowed directory. A single out-of-policy target keeps the whole call gated. So creating/updating widget files is now auto-approved in every mode, single-hunk or batched. Extended the existingeffective_risk_downgrades_widget_dir_writestest with multi-edit cases (all-inside → Safe, one-outside → Risky).Part B — reviewer hint (
agent.rs): The auto-review reviewer now sees the session widget directory and is told that maintaining its files is routine, so residual cases that still reach the reviewer (chiefly shell-based reads/removals of widget files) are approved rather than bounced.Coverage
Safe; non-read-only reads get the reviewer hint.rmcan't be deterministically scoped without parsing shell commands (which this codebase deliberately avoids — theread_onlyopt-in design), so it's handled by the reviewer hint, not a hard guarantee.Test
agentd-adapter-zarvis: 149 passed, 0 failed; workspace builds clean.Relevant binary:
agentd-adapter-zarvis(only crate touched).🤖 Generated with Claude Code