Repository navigation
[2.0] Align Context Center principal handling (#36663) - #36774
Conversation
Users, teams and domains have independent name namespaces. Match shared principals by stored IDs and require user references for caller ownership. Adapt the REST and MCP regression tests to the 2.0 memory APIs; file sharing and approved-memory status are not available on this branch. (cherry picked from commit 9b32eb8)
Code Review ✅ Approved🔴 High risk · Changing Context Memory sharing and ownership authorization to principal IDs could deny legitimate readers when identity resolution fails or IDs are missing. Backports the principal-ID matching fix for memory shares so a user named like a team or domain no longer gains that principal's access, and requires a user-type owner reference for caller ownership checks. No issues found. 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 |
|



Describe your changes
Backport of #36663 to
2.0(source merge commit9b32eb82ad95d45ac7e942f55eaf49833aac5324).A user named like a shared team or domain must not gain that principal's access. Match memory shares by stored principal IDs using the existing search resolver, deny unresolved callers, and require a user-type owner reference when checking caller ownership.
Type of change
High-level design and backport compatibility
Keep the principal-ID and owner-reference fixes from the source PR while preserving the
2.0visibility implementation and private helper scope.2.0has no ContextFile sharing/visibility implementation, so the source PR's ContextFile changes are omitted.2.0memory schema and JWT helper; the newerApprovedentity-status field is not introduced.mainare not present on2.0, so those assertions are not carried over. MCPget_entityandcompany_contextpositive/negative checks remain.Tests
Use cases covered
2.0production code, five adapted regression unit tests fail; with the fix, all 145 selected unit tests pass.Unit tests and coverage
145 tests passed across 10 classes (129 service, 16 MCP), with zero failures, errors, or skips. The final production source is unchanged from that instrumented run.
ContextMemoryVisibility: 91.7% line coverage (66/72), measured with JaCoCo 0.8.13 on Java 21. The JaCoCo version override was local only; no POM changes.Backend integration tests
Added
McpContextMemoryPrincipalIdentityIT, adapted for2.0. All three new regression cases passed.Manual affected selection:
ContextMemoryIT,McpContextMemoryVisibilityIT,McpContextMemoryPrincipalIdentityIT,AIContextRestIT,AIContextMcpIT,McpIntegrationIT,McpToolsValidationIT,McpUserContextIT,PersonaAIContextIT,McpServiceResourceIT. The2.0branch has no Java affected-test planner or impact map.Local Java verification: FAILED
8956f3c8365c6f7fc09b51996e9d3d80be1d2948(baseorigin/2.0).McpServiceResourceIT#mcpServiceApiKey_encryptedAtRest_maskedForAdmin_readableForBot(encrypted-at-rest assertion).McpUserContextIT#ownedSummaryFindsOwnedTableViaNestedOwnersQuery.origin/2.0baselineaa70b3d1a49b460bc0e0bbd0ec448b837b920ca2reproduced both the same credential assertion and the same owned-summary timeout: 459 tests, 1 failure, 1 error, 50 skipped. The three additional cases in this backport all pass. The PR remains draft because the full selected run is red.Clean 2.0 baseline comparison
A separate, unmodified worktree at
aa70b3d1a49b460bc0e0bbd0ec448b837b920ca2ran the same integration selection excludingMcpContextMemoryPrincipalIdentityIT, which is introduced by this backport.git status --porcelain=v1was empty before and after the run.Both runs fail the same tests:
McpServiceResourceIT#mcpServiceApiKey_encryptedAtRest_maskedForAdmin_readableForBot: encrypted-at-rest assertion.McpUserContextIT#ownedSummaryFindsOwnedTableViaNestedOwnersQuery: one-minute owned-table summary timeout.Baseline command:
Commands and per-class JUnit results
Instrumented units and coverage:
Integration command:
The table groups raw JUnit XML testcase entries by their reported class, including inherited nested test classes. The XMLs contain five repeated class/method entries for inherited cases; aggregate counts above come from
failsafe-summary.xml.Ingestion integration tests
Not applicable — no Python or connector changes.
Playwright and UI recording
Not applicable — backend-only release backport; no UI changes.
Manual testing performed
No separate manual UI session. Real HTTP/MCP integration tests create team/domain principals, member and namesake users, and shared/private memories, then assert allowed reads and denied reads without disclosing the memory answer.
Other checks
spotless:apply,spotless:check, commit hooks, andgit diff --checkpassed.Self-review
A fresh reviewer checked final commit
8956f3c8365c6f7fc09b51996e9d3d80be1d2948against the sharedREVIEW.mdbar: no Important findings remain. Target-branch test API, JWT, guarded-route, and list-pagination incompatibilities identified during review were resolved.Checklist
skip-pr-checkslabel.