Skip to content

[2.0] Fixes #38638: Gate memory edit and delete on the memory's own permission - #38773

Merged
Rohit0301 merged 2 commits into
2.0from
cherry-pick-38676-2.0
Nov 26, 2026
Merged

Rohit0301 merged 2 commits into
2.0from
cherry-pick-38676-2.0

Conversation

@Rohit0301

@Rohit0301 Rohit0301 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Cherry-pick of #38676 (590ea15b78e) onto 2.0. Fixes #38638.

Context Center gated memory Edit/Delete on the resource-level contextMemory permission. For a non-admin, OrganizationPolicy-Owner-Rule (isOwner()) shows up as conditional at resource level, so owners couldn't see Edit or Delete. useMemoryActionPermissions now 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:

  • useMemoryActionPermissions calls useQueries and getEntityPermissionByFqn directly, because 2.0 doesn't have useBulkEntityPermissions or PermissionDerivation. The behaviour is the same, and a memory gets no actions while its lookup is loading or after it fails.
  • MemoriesView, ContextCenterMemoriesPage and the MemoriesView test were ported by hand onto 2.0's versions, which have diverged from main.
  • Dropped ContextCenterMemoriesPage.browser.test.tsx and the personas.ts fixture, because 2.0 has no Vitest browser-test harness. Also dropped the ContextCenterMemoriesPage.test.tsx changes, because that file was removed on 2.0.
  • ContextCenterPermission.spec.ts (Playwright): the changes merged cleanly, but createMemoryViaApi also had to be imported because 2.0 didn't import it. The helper is already in 2.0's ContextCenterUtil.ts.
  • The permission lookups keep main's 5-minute staleTime.

Tests

  • Jest: MemoriesView.test.tsx and useMemoryActionPermissions.test.tsx pass (16/16).
  • tsc: none of the changed files have errors. 2.0 already has unrelated errors in other files.
  • I haven't run the Playwright spec locally.

🤖 Generated with Claude Code

…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.
@Rohit0301
Rohit0301 requested a review from a team as a code owner November 26, 2026 06:11
@Rohit0301
Rohit0301 requested review from shah-harshit and removed request for a team November 26, 2026 06:11
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

…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.
@gitar-bot

gitar-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk

Per-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 contextMemory permission, so owners can see these actions again. Admins keep the resource-level answer and the owner-or-admin rule is unchanged. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@Rohit0301
Rohit0301 merged commit 6ccf14d into 2.0 Nov 26, 2026
58 of 61 checks passed
@Rohit0301
Rohit0301 deleted the cherry-pick-38676-2.0 branch November 26, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants