feat(policy): repurpose "Always Allow" persistence to workspace level#19707
Conversation
Summary of ChangesHello @Abhijit-2592, 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 refines how tool and MCP server permissions are managed by shifting the 'Always Allow' persistence mechanism from a global user setting to a project-specific workspace setting. This change enhances security and project isolation by ensuring that granted permissions are relevant only to the active workspace, preventing unintended global effects. The implementation involves updating policy configuration, introducing new priority constants, and adjusting the policy updater to leverage workspace-level storage. Highlights
Changelog
Activity
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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Size Change: +909 B (0%) Total Size: 25.2 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request effectively repurposes the "Always Allow" policy persistence from the user level to the workspace level, significantly enhancing security and project-specific configuration. No high or critical security vulnerabilities were found. The implementation is robust, correctly modifying createPolicyUpdater to use a Storage instance for workspace-scoped persistence and appropriately moving dynamic rule priority to the workspace tier. The refactoring of hardcoded priority values into named constants improves readability and maintainability. The changes also ensure proper TOML serialization, maintain a clear priority hierarchy, and include thorough test updates, making this a solid contribution to the policy engine's design.
5e8f295 to
738478b
Compare
Repurposes the "Allow for all future sessions" (policy persistence) functionality from the user level to the workspace level. This ensures that tool and MCP server permissions granted by the user are scoped to the specific project/workspace rather than being applied globally. Key changes: - Updated `createPolicyUpdater` to accept a `Storage` instance and use the workspace policies directory for TOML persistence. - Moved dynamic "Always Allow" rules from the User Tier (3.95) to the Workspace Tier (2.95) using a new `ALWAYS_ALLOW_PRIORITY` constant. - Introduced static constants for all policy priority levels in `packages/core/src/policy/config.ts` to eliminate hardcoded numbers. - Consistently used constant names in documentation and introduced `AUTO_SAVED_POLICY_FILENAME` for the policy filename. - Updated CLI orchestration to pass the `Storage` instance to the policy updater. - Updated core unit tests to verify workspace-level persistence and priority logic. Fixes #19704
…documentation - Moved `AUTO_SAVED_POLICY_FILENAME` and added `getAutoSavedPolicyPath()` to the `Storage` class. - Relocated priority calculation logic explanation to the constant definition in `config.ts`. - Removed obsolete priority comments from tool confirmation logic.
738478b to
fd1cadc
Compare

Summary
Repurposes the "Allow for all future sessions" (policy persistence) functionality from the user level to the workspace level. This ensures that tool and MCP server permissions granted by the user are scoped to the specific project/workspace rather than being applied globally.
Details
createPolicyUpdaterinpackages/core/src/policy/config.tsto accept aStorageinstance and usestorage.getWorkspacePoliciesDir()for persisting rules to.gemini/policies/auto-saved.toml.ALWAYS_ALLOW_PRIORITYconstant.gemini.tsxand the policy wrapper inpackages/cli/src/config/policy.tsto pass theStorageinstance correctly.Related Issues
Fixes #19704
How to Validate
.gemini/policies/auto-saved.tomlis created in the current directory.npm test -w @google/gemini-cli-core -- src/policy/policy-updater.test.ts src/policy/persistence.test.tsPre-Merge Checklist