Skip to content

fix(core): revert auto-save of policies to user space#20531

Merged
Abhijit-2592 merged 1 commit into
mainfrom
abhijit-2592/revert-auto-save-to-user-space
Feb 27, 2026
Merged

fix(core): revert auto-save of policies to user space#20531
Abhijit-2592 merged 1 commit into
mainfrom
abhijit-2592/revert-auto-save-to-user-space

Conversation

@Abhijit-2592

Copy link
Copy Markdown
Contributor

Summary

Reverts the auto-save of tool approval policies from the workspace directory back to the global user space (~/.gemini/policies). This is necessary because workspace policies are being temporarily disabled to simplify policy management.

Details

  • Updated Storage.getAutoSavedPolicyPath in packages/core/src/config/storage.ts to use getUserPoliciesDir().
  • Modified createPolicyUpdater in packages/core/src/policy/config.ts to ensure the parent directory of the policy file is created before writing. This handles cases where ~/.gemini/policies might not exist.
  • Updated persistence tests to reflect the change in storage location and removed redundant mocks for workspacePoliciesDir.

Related Issues

Fixes #20530
Related to #20522

How to Validate

  1. Run the CLI in a workspace.
  2. Perform an action that triggers a policy auto-save (e.g., "always allow" a tool).
  3. Verify that auto-saved.toml is created in ~/.gemini/policies/ and NOT in the workspace's .gemini/policies/.
  4. Run persistence tests: npm test -w @google/gemini-cli-core -- src/policy/persistence.test.ts

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt

@Abhijit-2592 Abhijit-2592 requested a review from a team as a code owner February 27, 2026 04:10
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 addresses an issue where auto-saved tool approval policies were incorrectly stored in the workspace directory. The changes revert this behavior, ensuring policies are now saved to the user's global configuration directory. This simplifies policy management by centralizing auto-saved policies and prepares for the temporary disabling of workspace-specific policies.

Highlights

  • Policy Storage Location: Reverted the auto-save location for tool approval policies from the workspace directory to the global user space (~/.gemini/policies).
  • Directory Creation Logic: Modified the policy updater to ensure the parent directory of the policy file is created before writing, handling cases where the global user policy directory might not exist.
  • Test Updates: Updated persistence tests to reflect the change in policy storage location and removed redundant mocks related to workspace policies.
Changelog
  • packages/core/src/config/storage.ts
    • Updated getAutoSavedPolicyPath to store policies in the user's global directory.
  • packages/core/src/policy/config.ts
    • Modified createPolicyUpdater to ensure the parent directory for the policy file is created, accommodating the new global storage location.
  • packages/core/src/policy/persistence.test.ts
    • Adjusted test setup to mock userPoliciesDir instead of workspacePoliciesDir.
    • Removed redundant mocks for getWorkspacePoliciesDir.
    • Updated fs.mkdir assertions to reflect the change to user policy directory.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request reverts the auto-save location for tool approval policies from the workspace directory to the global user directory. The changes in storage.ts and config.ts correctly implement this reversion by updating the path generation and ensuring the global directory is created. The corresponding tests in persistence.test.ts have been updated to reflect the new behavior. The implementation appears correct and aligns with the stated goal of the pull request.

@github-actions

github-actions Bot commented Feb 27, 2026

Copy link
Copy Markdown

Size Change: -104 B (0%)

Total Size: 25.7 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 25.2 MB -104 B (0%)
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B

compressed-size-action

@gemini-cli gemini-cli Bot added the area/enterprise Issues related to Telemetry, Policy, Quota / Licensing label Feb 27, 2026
Reverts the auto-save of tool approval policies from the workspace directory
back to the global user space (~/.gemini/policies). This change is necessary
as workspace policies are being temporarily disabled to simplify policy
management.

- Updated Storage.getAutoSavedPolicyPath to use getUserPoliciesDir.
- Modified createPolicyUpdater to ensure the parent directory of the policy file
  is created before writing.
- Updated persistence tests to reflect the change in storage location.

Fixes: #20530
Refs: #20522
@Abhijit-2592 Abhijit-2592 force-pushed the abhijit-2592/revert-auto-save-to-user-space branch from 0777f06 to 678e663 Compare February 27, 2026 04:25
@Abhijit-2592 Abhijit-2592 added this pull request to the merge queue Feb 27, 2026
Merged via the queue into main with commit 32e777f Feb 27, 2026
27 checks passed
@Abhijit-2592 Abhijit-2592 deleted the abhijit-2592/revert-auto-save-to-user-space branch February 27, 2026 16:17
@galdawave

Copy link
Copy Markdown
Contributor

/patch preview

@github-actions

Copy link
Copy Markdown

Patch workflow(s) dispatched successfully!

📋 Details:

  • Channels: preview
  • Commit: 32e777f8387f6bcb6f6b2eafa353e861a2e1e47c
  • Workflows Created: 1

🔗 Track Progress:

@github-actions

Copy link
Copy Markdown

🚀 Patch PR Created!

📋 Patch Details:

📝 Next Steps:

  1. Review and approve the hotfix PR: #20607
  2. Once merged, the patch release will automatically trigger
  3. You'll receive updates here when the release completes

🔗 Track Progress:

@github-actions

Copy link
Copy Markdown

🚀 Patch Release Started!

📋 Release Details:

  • Environment: prod
  • Channel: preview → publishing to npm tag preview
  • Version: v0.31.0-preview.2
  • Hotfix PR: Merged ✅
  • Release Branch: release/v0.31.0-preview.2-pr-20531

⏳ Status: The patch release is now running. You'll receive another update when it completes.

🔗 Track Progress:

@github-actions

Copy link
Copy Markdown

Patch Release Complete!

📦 Release Details:

🎉 Status: Your patch has been successfully released and published to npm!

📝 What's Available:

🔗 Links:

BryanBradfo pushed a commit to BryanBradfo/gemini-cli that referenced this pull request Mar 5, 2026
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
warrenzhu25 pushed a commit to warrenzhu25/gemini-cli that referenced this pull request Apr 9, 2026
@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/enterprise Issues related to Telemetry, Policy, Quota / Licensing size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Revert auto-save of policies to workspace

3 participants