mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Permission grants can carry a scope that narrows what the grant allows > - One function re-ensures a grant: it creates the grant when missing and updates it when present > - The scope parameter defaults to null, and the update path writes it unconditionally > - Most callers omit scope because they only mean to ensure the grant is enabled > - Each such call therefore clears a previously stored scope, including on every server boot through the built-in-agent grant pass > - This pull request makes scope optional: an omitted scope leaves the stored scope alone > - The benefit is that re-ensuring a grant no longer silently widens or narrows it ## Linked Issues or Issue Description Fixes #17992 ## What Changed - `server/src/services/access.ts`: `setPrincipalPermission` now takes `scope?` instead of defaulting it to null. The update path writes scope only when the caller provided one. The insert path still writes null for a new grant without a scope. - `server/src/__tests__/access-service.test.ts`: new test grants a scope, re-ensures without one and expects the scope kept, then clears with an explicit null and expects null. ## Verification - The access-service suite loads and registers the new test, but the embedded-Postgres suite self-skips in this sandbox because Postgres refuses to run as root. The new test therefore has not run locally. CI is the arbiter for it. - Caller audit, done by reading every call site: the six scope-omitting callers (built-in-agent defaults, both agent-copy paths, both invitation acceptances, the permissions tab, and the default task-assign grant) all intend "ensure enabled" and gain the keep behavior. The two scope-passing callers are unchanged: the portability copy passes the source scope or an explicit null, and the bulk grant setter passes an explicit null, so both keep their clear semantics. ## Risks - Low risk. The only behavior change is for update calls that omit scope, which previously reset it to null. No caller was found that relies on that reset. A caller that wants to clear a scope still can, by passing null explicitly. ## Model Used Meta Muse Spark 1.3, with tool use and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [ ] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [ ] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge Signed-off-by: Josh Cox <joshuacox@users.noreply.github.com> Co-authored-by: Review <review@local>