Repository navigation
Fixes AI Platform #1262: Apply persona scope to MCP search - #32919
Conversation
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
| Optional<PersonaSearchScope> personaScope = personaSearchScope(securityContext, params); | ||
| VectorSearchParameters searchParameters = | ||
| new VectorSearchParameters( | ||
| query, | ||
| filters, | ||
| size, | ||
| from, | ||
| k, | ||
| threshold, | ||
| null, | ||
| null, | ||
| personaScope.map(PersonaSearchScope::queryFilter).orElse(null)); | ||
|
|
||
| try { | ||
| VectorSearchResponse response = |
There was a problem hiding this comment.
💡 Edge Case: Persona filter forwarded verbatim to embedding index may match nothing
SemanticSearchTool now forwards the persona's compiled searchScope queryFilter (raw DSL authored against the regular entity/dataAsset indexes) to the vector search, which queries the separate data_asset_embeddings_chunks (dataAssetEmbeddings) index. That chunk index carries denormalized fields (entityType, tags, owners, tier, service, fullyQualifiedName) but its mapping can differ from the entity index — e.g. analyzed .keyword subfields or nested owner structures a persona rule references may be unmapped there — so a term/terms clause silently matches zero documents. A persona whose scope works correctly for search_metadata could then make every semantic_search return empty, and since scope now applies by default (falling back to the user's default persona even when no X-OpenMetadata-Persona header is sent), affected users lose semantic results until they retry with ignorePersonaScope=true. Consider validating/translating persona filter fields against the embedding index mapping, or documenting the field constraints persona rules must satisfy to remain semantic-search compatible. The empty-result annotation that suggests the bypass partially mitigates this, but the degradation is silent.
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsApplies persona search scope to MCP keyword and semantic searches, with Consider validating or translating persona filter fields against the embedding index mapping before forwarding to semantic search, since the chunk index may lack subfields (e.g., 💡 Edge Case: Persona filter forwarded verbatim to embedding index may match nothing📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/SemanticSearchTool.java:118-132 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorSearchQueryBuilder.java:394-404 SemanticSearchTool now forwards the persona's compiled searchScope queryFilter (raw DSL authored against the regular entity/dataAsset indexes) to the vector search, which queries the separate 🤖 Prompt for agentsOptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
Describe your changes:
Fixes open-metadata/ai-platform#1262
Resolves #32457, the parent feature that introduced persona search scopes for AI search tools.
MCP keyword and semantic searches now apply the active user's persona search scope by default. The tools expose
ignorePersonaScopefor an explicit retry beyond that scope after a scoped miss or user request.The change also preserves
X-OpenMetadata-Personathrough the MCP transport, composes persona and caller filters with AND semantics, and adds compiled-query-filter support to both Elasticsearch and OpenSearch vector searches.Type of change:
High-level design:
PersonaContextAccesspath and compile its rules withPersonaContextBuilder, keeping persona scope a relevance preference rather than an authorization boundary.search_metadata; forward the same raw DSL filter to both vector backends forsemantic_search.SubjectContextmembership validation selects only an assigned persona.Tests:
Use cases covered
ignorePersonaScope=truepreserves the existing unscoped keyword and semantic search paths.Unit tests
openmetadata-service: 130 focused tests passed; changed-line coverage is 95.45%, with every touched production file at or above 90%.openmetadata-mcp: 630 tests passed; changed-line coverage is 96.70%, with every touched production file at or above 90%.Commands:
Backend integration tests
PersonaAIContextITcovering default scoping and explicit bypass with a real MySQL, Elasticsearch, application, and MCP server stack.PersonaAIContextITtests passed.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
Tested against a locally running OpenMetadata and MCP server with real OpenSearch embeddings:
search_metadatawithout the bypass flag and verified only the selected table was returned;ignorePersonaScope=truereturned both tables allowed by the caller filter.ignorePersonaScope=true.semantic_searchwithout the bypass flag and verified only the selected table was returned; the explicit bypass returned all five relevant embedded tables.UI screen recording / screenshots:
Not applicable; there are no UI changes.
Checklist:
Fixes <issue-number>: <short explanation>.Fixesreference above.