feat(core): implement context-aware persistent policy approvals#23257
feat(core): implement context-aware persistent policy approvals#23257
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the security and predictability of tool execution within the Gemini CLI by introducing context-aware persistent policy approvals. The core purpose is to safeguard the integrity of Plan Mode as a read-only research environment, preventing tools approved for active implementation from inadvertently executing during the planning phase. This change ensures that user trust in tools is applied precisely where intended, providing a more secure and controlled user experience without requiring manual mode restrictions for common workflows. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces context-aware persistent policy approvals to enhance the security of Plan Mode by restricting tool approvals based on the mode in which they were granted. It adds a modes field to the UpdatePolicy message protocol, updates the policy persistence logic, and includes unit tests to verify the new behavior. The documentation has also been updated to reflect these changes. The review identified a potential issue with the test case for YOLO mode, where the expected modes were not being checked correctly, and a suggestion was made to correct this, aligning with the principle of avoiding overly restrictive policies without proper approval flows.
|
Size Change: +1.72 kB (0%) Total Size: 34.6 MB
ℹ️ View Unchanged
|
|
@galz10 is working on an alternative fix |
0687a87 to
316663d
Compare
55b7535 to
81b2af7
Compare
- Update UpdatePolicy message protocol to include optional modes field. - Implement context-aware mode selection in updatePolicy to restrict approvals granted in implementation modes (default, autoEdit, yolo) to those modes. - Approvals granted while in Plan Mode remain global (unrestricted). - Ensure policy updater serializes the 'modes' field correctly in TOML rules. - Add table-driven unit tests to verify behavior across all approval modes. - Update documentation in Plan Mode and Policy Engine sections to reflect new behavior.
Update test descriptions to explicitly state that Plan Mode is excluded when approvals are granted in implementation modes (including YOLO), and that global trust is granted when in Plan Mode. This addresses high-priority feedback regarding YOLO mode behavior.
78ce76a to
527c249
Compare
|
/patch preview |
|
🚀 [Step 1/4] Patch workflow(s) waiting for approval! 📋 Details:
⏳ Status: The patch creation workflow has been triggered and is waiting for deployment approval. Please visit the specific workflow links below and approve the runs. 🔗 Track Progress: |
|
🚀 [Step 2/4] Patch PR Created! 📋 Patch Details:
📝 Next Steps:
🔗 Track Progress: |
|
🚀 [Step 3/4] Patch Release Waiting for Approval! 📋 Release Details:
⏳ Status: The patch release has been triggered and is waiting for deployment approval. Please visit the specific workflow run link below and approve the deployment. You'll receive another update when it completes. 🔗 Track Progress: |
|
✅ [Step 4/4] Patch Release Complete! 📦 Release Details:
🎉 Status: Your patch has been successfully released and published to npm! 📝 What's Available:
🔗 Links: |
Summary
This PR implements permissive context-aware persistent policy approvals. When a tool is allowed for all future sessions, the generated policy rule now explicitly includes the current approval mode and all more permissive modes in the hierarchy:
plan<default<autoEdit<yolo.Details
Previously, persistent approvals were either global or restricted to implementation modes. This change introduces a refined, explicit flow for tool trust:
plan(least permissive) <default<autoEdit<yolo(most permissive).yolo).planmode: Explicitly includesplan,default,autoEdit, andyolo. This represents a global trust choice.defaultmode: Includesdefault,autoEdit, andyolo. This ensures tools trusted for standard work are available in automated modes but not in the restricted research environment ofplanmode.autoEditmode: Includes onlyautoEditandyolo.yolomode: Includes onlyyolo.modesand permissions in-place.This ensures that trust flows correctly to more permissive environments while maintaining the safety of
planmode as a read-only space.Related Issues
Fixes #23245
How to Validate
Prerequisites
Enable the persistent approval UI in your
settings.json:{ "security": { "enablePermanentToolApproval": true } }Approval in
defaultModedefaultmode.ls) and select "Allow for all future sessions"..gemini/policies/auto-saved.tomlcontainsmodes = [ "default", "autoEdit", "yolo" ].planmode and verify the tool still requires confirmation.Approval in
planModeplanmode.modes = [ "plan", "default", "autoEdit", "yolo" ].Approval in
autoEditModeautoEditmode.modes = [ "autoEdit", "yolo" ].Pre-Merge Checklist