Skip to content

Align Context Center principal handling - #36663

Merged
pmbrull merged 1 commit into
mainfrom
pmbrull/context-principal-identity
Oct 31, 2026
Merged

pmbrull merged 1 commit into
mainfrom
pmbrull/context-principal-identity

Conversation

@pmbrull

@pmbrull pmbrull commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Describe your changes

Align Context Center principal handling with the existing search behavior, and keep owner reference checks consistent for memories and files. Add coverage for the related REST and MCP operations.

Type of change

  • Bug fix

High-level design

Reuse the existing principal ID resolver for Context Center sharing. Owner checks use the reference type already stored with each owner. This uses the existing data model and requires no migration for valid stored references.

Tests

Use cases covered

Direct sharing, team/domain membership, principal renames, owner references, REST memory and file operations, and MCP memory reads.

Unit tests

Updated ContextMemoryVisibilityTest, ContextFileVisibilityTest, and CompanyContextToolTest.

Additional unit selections passed 513 distinct cases; full class results are recorded in a comment. Changed-class line coverage: ContextMemoryVisibility 93.1%, ContextFileVisibility 100%.

Backend integration tests

Added McpContextMemoryPrincipalIdentityIT. Focused HTTP/MCP selection: 286 passed, 27 skipped.

The affected Java run completed with no failing executed cases. The local runner reports an incomplete entry for the McpServiceResourceIT source placeholder; the planner adjustment is tracked in #36553.

Local Java verification

Local Java test run: FAILED

  • Commit: 767c1b0a8dfb (base origin/main)
  • Finished: 2026-10-30 08:46 UTC · 22.4 min
Step Scope Classes Tests Failed Skipped Min Result
unit openmetadata-mcp (1 class), openmetadata-service (3 classes) 4 100 0 0 1.3 passed
integration mysql-elasticsearch · parallel 55 3438 0 297 6.0 FAILED
integration mysql-elasticsearch · isolated 3 12 0 0 5.7 passed
integration mysql-elasticsearch · rdf 2 43 0 0 9.4 passed

Selected but produced no report: McpServiceResourceIT (mysql-elasticsearch · parallel)

Java class results · Additional checks

Other checks

Spotless, Java impact ownership, and decision-record validation passed. Ingestion tests and a UI recording are not applicable to this backend change. Playwright planning selected 34 specs; they were not run because this checkout has no UI test server. No separate manual UI session was run; the HTTP integration suites exercise the backend behavior.

Self-review

Reviewed 767c1b0a8df against REVIEW.md; no outstanding findings. The change follows the existing identity contract and requires no new decision record.

Checklist

  • Added unit and HTTP integration coverage.
  • Reviewed the final committed change.
  • Checked formatting and impact ownership.
  • Evaluated schema, migration, UI, and decision-record requirements.

Users, teams and domains have independent name namespaces. Match shared
principals by their stored IDs and require a user reference for caller
ownership checks, so namesakes cannot read memories or files.

Reuse search's principal IDs and deny sharing when the caller lookup fails.
@pmbrull pmbrull added the skip-pr-checks Bypass PR metadata validation check label Oct 30, 2026
@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Oct 30, 2026
@pmbrull

pmbrull commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

Additional local verification

Unit selections completed with 513 distinct cases passing. The table uses the latest result for each class from the context selection and memory/file follow-up.

Class Run Failed Skipped
mcp.tools.CommonUtilsAuthorizeOverwriteTest 4 0 0
mcp.tools.CompanyContextToolTest 17 0 0
mcp.tools.GetEntityToolTest 36 0 0
mcp.tools.PatchEntityToolTest 38 0 0
service.aicontext.AIContextBuilderTest 51 0 0
service.aicontext.AIContextFinderAccessTest 2 0 0
service.aicontext.AIContextFinderTest 9 0 0
service.aicontext.AIContextMarkdownTest 31 0 0
service.aicontext.ConceptContextCatalogTest 7 0 0
service.context.center.ContextFileProcessingServiceTest 14 0 0
service.context.center.ContextFileTextExtractorTest 5 0 0
service.context.center.ContextMemoryExtractionJobHandlerTest 4 0 0
service.context.center.ContextMemoryExtractorTest 10 0 0
service.context.center.ContextMemoryReconcilerTest 21 0 0
service.jdbi3.ContextMemoryConditionalWriteSqlTest 2 0 0
service.jdbi3.ContextMemoryLifecycleTest 38 0 0
service.jdbi3.ContextMemoryOutcomeWriteSqlTest 2 0 0
service.jdbi3.ContextMemoryRepositoryTest 23 0 0
service.resources.context.ContextMemoryAnchorAccessTest 2 0 0
service.resources.context.ContextMemoryEvidenceAccessTest 5 0 0
service.resources.context.ContextMemoryResourceTest 5 0 0
service.resources.context.ContextMemorySchemaTest 7 0 0
service.resources.context.ContextMemoryStatusTransitionTest 14 0 0
service.resources.context.ContextMemoryVisibilityTest 36 0 0
service.resources.context.ContextMemoryWriteAccessTest 24 0 0
service.resources.drive.ContextFileResourceTest 21 0 0
service.resources.drive.ContextFileUploadSupportTest 6 0 0
service.resources.drive.ContextFileVisibilityTest 18 0 0
service.search.ContextMemoryIndexMappingTest 3 0 0
service.search.indexes.ContextFileIndexTest 3 0 0
service.search.indexes.ContextMemoryIndexTest 15 0 0
service.search.security.ContextMemoryAnchorPinsTest 5 0 0
service.search.security.ContextMemorySearchVisibilityTest 29 0 0
service.search.vector.ContextMemoryBodyTextContributorTest 6 0 0

A focused MySQL/Elasticsearch HTTP run also completed with 286 passed and 27 skipped: ContextMemoryIT, ContextMemoryWriteAccessIT, ContextMemorySearchMatrixIT, McpContextMemoryVisibilityIT, McpContextMemoryPrincipalIdentityIT, ContextFileIT, and FolderIT.

JaCoCo line coverage: ContextMemoryVisibility 121/130 (93.1%); ContextFileVisibility 63/63 (100%).

@gitar-bot

gitar-bot Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved

🔴 High risk · Changes memory and file sharing authorization to match principal IDs, so resolver or reference mismatches could expose private Context Center content or deny access.

Aligns Context Center sharing with the existing principal ID resolver used by search, and makes owner reference checks for memories and files use the reference type stored with each owner. Adds REST and MCP coverage for these paths. 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

@pmbrull

pmbrull commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

Local Java test run: FAILED — details

  • Commit: 767c1b0a8dfb (base origin/main)
  • The summary is in the PR description.

Selected but produced no report: McpServiceResourceIT (mysql-elasticsearch · parallel)

Tests run locally

  • unit · openmetadata-mcp (1 class), openmetadata-service (3 classes): CompanyContextToolTest (17 passed), ContextFileVisibilityTest (18 passed), ContextMemorySearchVisibilityTest (29 passed), ContextMemoryVisibilityTest (36 passed)
  • integration · mysql-elasticsearch · parallel: 55 classes, 3141 tests executed (listed below)
  • integration · mysql-elasticsearch · isolated: ContextMemoryDerivationIT (5 passed), ContextMemoryExtractionIT (5 passed), ConversationSchemaMigrationIT (2 passed)
  • integration · mysql-elasticsearch · rdf: AgentSparqlResourceIT (22 passed), RdfMcpKnowledgeGraphIT (21 passed)

Per-class counts come from the test reports, which can credit a test to the wrong class when classes run concurrently, and keep only the last run of a nested class that several test classes inherit. The summary's step totals are Maven's own counts.

integration · mysql-elasticsearch · parallel: 56 classes

AIApplicationResourceIT (26 passed), AIContextKnowledgeAuthorizationIT (5 passed, 1 skipped), AIContextMcpIT (39 passed, 6 skipped), AIContextRestIT (58 passed, 6 skipped), AIFrameworkControlResourceIT (10 passed), AIGovernancePolicyResourceIT (11 passed, 1 skipped), AgentExecutionResourceIT (1 passed, 2 skipped), AttachmentListIT (13 passed), BaseEntityIT$ListEntityHistoryByTimestampPaginationTest (39 passed, 4 skipped), ConceptContextIT (2 passed), ConfigResourceIT (13 passed), ContextFileIT (79 passed, 7 skipped), ContextMemoryAnchorIT (32 passed, 3 skipped), ContextMemoryConflictReviewIT (37 passed, 3 skipped), ContextMemoryCreateGrantIT (4 passed), ContextMemoryIT (27 passed, 3 skipped), ContextMemoryLifecycleIT (58 passed, 3 skipped), ContextMemoryQueryEvidenceIT (263 passed, 32 skipped), ContextMemoryRelatedEntitiesReconcileIT (95 passed, 7 skipped), ContextMemorySearchMatrixIT (11 passed, 1 skipped), ContextMemorySourceEntityTiebreakIT (36 passed, 4 skipped), ContextMemoryStatusMigrationIT (1 passed), ContextMemoryWriteAccessIT (8 passed), ConversationResourceIT (155 passed, 19 skipped), CredentialMcpRevocationIT (8 passed), DatabaseSmokeIT (18 passed, 4 skipped), DirectoryResourceIT (24 passed, 2 skipped), DriveFileUploadIT (20 passed, 4 skipped), DriveServiceResourceIT (11 passed, 2 skipped), FileResourceIT (123 passed, 18 skipped), FolderIT (29 passed, 2 skipped), FolderResourceIT (49 passed, 6 skipped), GlossaryTermResourceIT (152 passed, 8 skipped), IngestionPipelineAgentTypeIT (1 passed), LLMModelResourceIT (59 passed, 5 skipped), LLMServiceResourceIT (59 passed, 10 skipped), McpContextMemoryPrincipalIdentityIT (1 passed), McpContextMemoryVisibilityIT (16 passed, 3 skipped), McpExecutionResourceIT (79 passed), McpIntegrationIT (62 passed, 3 skipped), McpOAuthIT (29 passed, 3 skipped), McpPermissionIT (84 passed, 13 skipped), McpRdfNotEnabledIT (0 passed), McpSearchIT (136 passed, 16 skipped), McpServerResourceIT (54 passed, 4 skipped), McpToolsValidationIT (68 passed, 3 skipped), McpUserContextIT (5 passed, 2 skipped), MetricAssetsIT (8 passed, 2 skipped), OntologyAiResourceIT (5 passed, 6 skipped), PersonaAIContextIT (145 passed, 20 skipped), PromptTemplateResourceIT (16 passed, 2 skipped), SeedDataPresenceIT (13 passed, 1 skipped), SpreadsheetResourceIT (43 passed, 4 skipped), TableResourceIT (145 passed), UserResourceIT (113 passed, 10 skipped), WorksheetResourceIT (306 passed, 26 skipped)

Why these tests
  • area ai-mcp-context ← openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/CompanyContextToolTest.java, openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryVisibility.java
  • area drives-attachments ← openmetadata-service/src/main/java/org/openmetadata/service/resources/drive/ContextFileVisibility.java
  • called from entity ContextFile ← openmetadata-service/src/main/java/org/openmetadata/service/resources/drive/ContextFileVisibility.java
  • called from entity ContextMemory ← openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryVisibility.java, openmetadata-service/src/main/java/org/openmetadata/service/resources/drive/ContextFileVisibility.java
  • called from entity Folder ← openmetadata-service/src/main/java/org/openmetadata/service/resources/drive/ContextFileVisibility.java
  • changed test ← openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/mcp/McpContextMemoryPrincipalIdentityIT.java, openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/CompanyContextToolTest.java, openmetadata-service/src/test/java/org/openmetadata/service/resources/context/ContextMemoryVisibilityTest.java, openmetadata-service/src/test/java/org/openmetadata/service/resources/drive/ContextFileVisibilityTest.java
  • smoke ← code other than a test class changed
Commands
mvn -B package -pl openmetadata-mcp,openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=CompanyContextToolTest,ContextFileVisibilityTest,ContextMemorySearchVisibilityTest,ContextMemoryVisibilityTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<56 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state -Dit.test=ContextMemoryDerivationIT,ContextMemoryExtractionIT,ConversationSchemaMigrationIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=rdf -Dit.test=AgentSparqlResourceIT,RdfMcpKnowledgeGraphIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false

@pmbrull
pmbrull marked this pull request as ready for review October 30, 2026 08:50
@pmbrull
pmbrull requested a review from a team as a code owner October 30, 2026 08:50
@pmbrull
pmbrull requested a review from IceS2 October 30, 2026 08:50
@pmbrull pmbrull added the To release Will cherry-pick this PR into the release branch label Oct 30, 2026
@pmbrull
pmbrull added this pull request to the merge queue Oct 30, 2026
@sonarqubecloud

Copy link
Copy Markdown

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-31T04:46:18Z)

Blocked the queue: playwright-summary

Failed Playwright tests:

  • Features/OntologyFirstRun.spec.ts › creates an ontology from scratch and lands in Edit with the New class panel
  • Features/OntologyNativeAuthoring.spec.ts › a competing lease leaves no partial class and the form stays usable
  • Features/OntologyNativeAuthoring.spec.ts › creates every class field atomically, preserves free space, and cancels provisional relations
  • Features/OntologyNativeExport.spec.ts › downloads every format of the current ontology release, then gates on SHACL
  • Features/OntologyNativeStudio.spec.ts › authors a native model through the shared View, Edit, and Query shell

@pmbrull
pmbrull added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 9b32eb8 Oct 31, 2026
208 checks passed
@pmbrull
pmbrull deleted the pmbrull/context-principal-identity branch October 31, 2026 20:33
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.1 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.0 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.1 opened as #36759 (clean cherry-pick). It merges itself once the checks pass.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.0 failed. The conflict could not be resolved, so this change is not on that branch. Resolver run.

pmbrull added a commit that referenced this pull request Nov 1, 2026
* fix(context): match shares by principal ID

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)

* test(context): adapt backport list and read checks

* test(context): cover unresolved sharing enforcement

* test(context): scope backport to guarded read routes

* test(context): use 2.0 JWT test helper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants