You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: Expose saved permissions (or rule provenance) to server plugins #61767
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Expose saved permissions to server plugins (and/or say where an evaluate allow came from)
Problem. A server plugin that enforces a stricter floor for some agents needs to tell a saved "Always allow" apart from a config-level allow. For example, it may want a config-wide external_directory: allow not to apply to restricted agents, while still honouring an approval the user saved. As of v2.2.5 the plugin can't do that:
ctx.permission is Pick<PermissionApi, "list" | "get" | "reply"> + hook + assert. That covers pending requests only. permission.saved.list/update/remove exist only as HTTP endpoints (/api/permission/saved). TUI plugins can read them (data.project.permission.list), but server plugins and headless runs can't.
PermissionSaved.add/update/remove publish no bus event, so a plugin can't keep a copy in sync either. Once a user removes a saved approval, a copy goes stale.
evaluateInput appends savedRules() after the configured rules and passes only the combined effect to hooks.trigger("permission", "evaluate", …). The event doesn't say which rule matched.
Today the workaround is to create a throwaway child session whose own permissions ask for the action, assert in it, read the effect in your own evaluate hook, force deny so it never prompts, then remove the session. It works, but it costs a session per check, and other plugins' evaluate hooks can affect it.
Proposal (any one of these would do):
Add saved: Pick<PermissionApi["saved"], "list"> to the server plugin PermissionDomain, scoped to ctx.location.project.id.
Publish permission.saved.updated (and/or permission.saved.removed) bus events, so ctx.event.subscribe can track changes.
Add rule provenance to the evaluate event, for example readonly rule?: { source: "agent" | "session" | "saved"; action; resource; effect } for the rule that decided each resource.
Option 3 would also help with #48456 ("Always allow" silently overriding a configured ask), because plugins could then enforce or flag that themselves.
Thanks for the detailed write-up, @yandy-r! To restate the request: server plugins should be able to tell a saved "Always allow" approval apart from a config-level allow. That could be done by exposing permission.saved.list on the plugin PermissionDomain, by publishing bus events when saved approvals change, or by including the deciding rule's source (agent, session or saved) in the evaluate hook event.
I checked this against the current code and it matches what you describe. PermissionDomain only includes list, get and reply plus hook and assert. evaluateInput adds the saved rules after the configured ones and passes only the combined effect to the evaluate hook. So beyond your child-session workaround, a plugin can't do this cleanly today. The maintainers will consider which of the three options fits best.
Activity
opencodejr commentedon Nov 4, 2026
Thanks for the detailed write-up, @yandy-r! To restate the request: server plugins should be able to tell a saved "Always allow" approval apart from a config-level allow. That could be done by exposing
permission.saved.liston the pluginPermissionDomain, by publishing bus events when saved approvals change, or by including the deciding rule's source (agent, session or saved) in theevaluatehook event.I checked this against the current code and it matches what you describe.
PermissionDomainonly includeslist,getandreplyplushookandassert.evaluateInputadds the saved rules after the configured ones and passes only the combined effect to theevaluatehook. So beyond your child-session workaround, a plugin can't do this cleanly today. The maintainers will consider which of the three options fits best.Related issues:
ask. Rule provenance would let plugins detect or enforce this.