Repository navigation
[2.0] Fixes #38638: Gate memory edit and delete on the memory's own permission - #38773
Conversation
…ion (#38676) Every user inherits OrganizationPolicy-Owner-Rule (All when isOwner()), which the server reports as conditional at resource level, so the Context Center hid Edit and Delete from a non-admin owner of a memory. The new useMemoryActionPermissions hook answers each memory from its own permission through useBulkEntityPermissions: a non-admin's owned memories are looked up by FQN, an admin keeps the resource-level answer with no lookup, and a loading or failed lookup offers no action. The owner-or-admin rule is kept. MemoriesView takes a getMemoryActions resolver instead of page-wide canEdit/canDelete flags, and the detail modal gets the open memory's own answer. Create stays resource level. Three ContextCenterPermission.spec.ts assertions that expected an owner without a role grant to have no Edit or Delete now expect them, per ADR:2026-10-09-data-consumers-create-context-memories. (cherry picked from commit 590ea15) Backport notes for 2.0: useBulkEntityPermissions, PermissionDerivation and the Vitest browser-test harness are not on 2.0, so useMemoryActionPermissions queries per-memory permissions with useQueries directly, and the ContextCenterMemoriesPage browser/Jest tests and personas fixture are dropped.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
…mission lookups The spec auto-merged but on 2.0 never imported createMemoryViaApi, so it failed to compile. Memory permission queries now use main's 5 minute staleTime instead of the 2.0 client default of 0.
Code Review ✅ Approved 🔴 High riskPer-memory permission checks now expose Context Memory edit/delete actions to owners, so a misapplied permission result could enable unauthorized changes or deletion. Gates memory Edit and Delete actions on each owned memory's own permission by FQN instead of the resource-level VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Cherry-pick of #38676 (
590ea15b78e) onto2.0. Fixes #38638.Context Center gated memory Edit/Delete on the resource-level
contextMemorypermission. For a non-admin,OrganizationPolicy-Owner-Rule(isOwner()) shows up as conditional at resource level, so owners couldn't see Edit or Delete.useMemoryActionPermissionsnow checks each owned memory's own permission by FQN. Admins keep the resource-level answer, and the owner-or-admin rule stays.Backport adaptations
2.0 is missing some of the infrastructure #38676 builds on, so the backport differs from main:
useMemoryActionPermissionscallsuseQueriesandgetEntityPermissionByFqndirectly, because 2.0 doesn't haveuseBulkEntityPermissionsorPermissionDerivation. The behaviour is the same, and a memory gets no actions while its lookup is loading or after it fails.MemoriesView,ContextCenterMemoriesPageand theMemoriesViewtest were ported by hand onto 2.0's versions, which have diverged from main.ContextCenterMemoriesPage.browser.test.tsxand thepersonas.tsfixture, because 2.0 has no Vitest browser-test harness. Also dropped theContextCenterMemoriesPage.test.tsxchanges, because that file was removed on 2.0.ContextCenterPermission.spec.ts(Playwright): the changes merged cleanly, butcreateMemoryViaApialso had to be imported because 2.0 didn't import it. The helper is already in 2.0'sContextCenterUtil.ts.staleTime.Tests
MemoriesView.test.tsxanduseMemoryActionPermissions.test.tsxpass (16/16).tsc: none of the changed files have errors. 2.0 already has unrelated errors in other files.🤖 Generated with Claude Code