Repository navigation
Fixes #32457: move Persona AI Context into Context Center, add search-scoped rules - #32458
Conversation
…-scoped rules Persona AI Context was a tab three levels down under Settings → Personas, away from every other AI-context surface, and every enabled rule was preloaded into the cached document regardless of whether the user ever asked about those assets. Move the editor into Context Center as an "AI Context" submenu (persona list → rule editor) and delete the tab from the persona detail page. The component folder moves to components/ContextCenter/PersonaAIContext/ with it. Add `filteredInSearch` to a context rule. A scoped rule is not materialized at all; instead it contributes its entity type and query filter to a `searchScope` on the PersonaContext document, which AI search tools apply as a default filter. No scoped rules means no filter and search is unchanged; one or more compose a strict allowlist, so a persona whose only scoped rule selects tables searches those tables and nothing else. The schema deliberately declares no default for the field. jsonschema2pojo compiles a schema default into the field initializer, which would make a rule stored before this field indistinguishable from one explicitly set to true and force a data migration over persona_entity JSON. With no default the POJO field is null, read as false, so existing rules keep preloading; the rule creation API stamps true when the client omits it, making search scoping the default for new rules without touching stored data. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
There was a problem hiding this comment.
🟡 Changes recommended
Knowledge-entity rules can currently be stamped/treated as filteredInSearch, which can incorrectly drop knowledge rules from materialization and allow them to influence search scoping.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR addresses #32457 by relocating the Persona AI Context editor from Settings → Personas into Context Center (as an “AI Context” submenu) and introducing a new context-rule delivery mode (filteredInSearch) that contributes to a persona “search scope” instead of preloading entities into the cached context document.
Changes:
- Added Context Center routes + sidebar entry for AI Context (persona list + detail/rule editor) and removed the AI Context tab from PersonaDetailsPage.
- Introduced
filteredInSearchon persona context rules and asearchScopepayload on persona context, updating schemas, generated TS types, backend builder/markdown rendering, and integration/unit tests. - Updated UI rule editor behaviors (mutual exclusivity, defaults, badges/counts) and added i18n strings and Jest coverage for the new pages and utilities.
File summaries
| File | Description |
|---|---|
| openmetadata-ui/src/main/resources/ui/src/utils/PersonaAIContextUtils.ts | Normalize filteredInSearch and add scoped-rule counting helper for UI. |
| openmetadata-ui/src/main/resources/ui/src/utils/PersonaAIContextUtils.test.ts | Unit tests for filteredInSearch normalization and scoped-rule counting. |
| openmetadata-ui/src/main/resources/ui/src/utils/ContextCenterClassBase.ts | Add Context Center route helpers for AI Context list/detail paths. |
| openmetadata-ui/src/main/resources/ui/src/pages/Persona/PersonaDetailsPage/PersonaDetailsPage.tsx | Remove Persona “AI Context” tab entry (moved to Context Center). |
| openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterAIContextPage/ContextCenterAIContextPage.tsx | New Context Center page listing personas with rule + scoped-rule counts. |
| openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterAIContextPage/ContextCenterAIContextPage.test.tsx | Tests for AI Context persona list page (rendering + navigation + empty state). |
| openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterAIContextPage/ContextCenterAIContextDetailPage.tsx | New Context Center detail page hosting the Persona AI Context editor. |
| openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterAIContextPage/ContextCenterAIContextDetailPage.test.tsx | Tests for AI Context detail page (loads persona + empty state). |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/ar-sa.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/de-de.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/gl-es.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/he-he.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/ko-kr.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/mr-in.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/nl-nl.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/pr-pr.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-pt.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/ru-ru.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/sv-se.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/th-th.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/tr-tr.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-tw.json | Add i18n strings for AI Context + “filtered in search” UI. |
| openmetadata-ui/src/main/resources/ui/src/generated/type/personaContextDefinition.ts | Generated type update: add filteredInSearch to context rules. |
| openmetadata-ui/src/main/resources/ui/src/generated/type/personaContext.ts | Generated type update: add searchScope structures to persona context. |
| openmetadata-ui/src/main/resources/ui/src/generated/entity/teams/persona.ts | Generated entity type update: add filteredInSearch to rule model. |
| openmetadata-ui/src/main/resources/ui/src/generated/api/teams/createPersona.ts | Generated API type update: add filteredInSearch to rule model. |
| openmetadata-ui/src/main/resources/ui/src/enums/sidebar.enum.ts | Add sidebar enum key for the AI Context entry. |
| openmetadata-ui/src/main/resources/ui/src/enums/entity.enum.ts | Add TabSpecificField.CONTEXT_DEFINITION for persona fetches. |
| openmetadata-ui/src/main/resources/ui/src/constants/LeftSidebar.constants.ts | Register AI Context under Context Center sidebar + nested key mapping. |
| openmetadata-ui/src/main/resources/ui/src/constants/constants.ts | Add route constants for Context Center AI Context list/detail. |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/VersionHistoryDrawer/VersionHistoryDrawer.test.tsx | Update imports/paths after moving Persona AI Context under Context Center. |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/VersionHistoryDrawer/VersionHistoryDrawer.component.tsx | Update imports/paths after move + keep functionality intact. |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/PersonaAIContext.test.tsx | Update imports/mocks after move under Context Center. |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/PersonaAIContext.component.tsx | Update imports/paths after move under Context Center. |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextRuleEditor/RuleQueryBuilderField.test.tsx | Update imports/mocks after move under Context Center. |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextRuleEditor/RuleQueryBuilderField.component.tsx | Update imports/paths after move under Context Center. |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextRuleEditor/ContextRuleEditor.test.tsx | Add tests for filteredInSearch defaults + mutual exclusivity behaviors. |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextRuleEditor/ContextRuleEditor.component.tsx | UI behavior for filteredInSearch mode (disable/mute preload settings, defaulting). |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextRuleCard/ContextRuleCard.test.tsx | Update imports after move + maintain card behavior coverage. |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextRuleCard/ContextRuleCard.component.tsx | Display “Filtered in search” badge + summary text for scoped rules. |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextPreviewModal/ContextPreviewModal.test.tsx | Update imports/mocks after move under Context Center. |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextPreviewModal/ContextPreviewModal.component.tsx | Update imports/paths after move under Context Center. |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextPreviewModal/context-preview-modal.less | Add styling support for the moved context preview modal. |
| openmetadata-ui/src/main/resources/ui/src/components/AppRouter/ContextCenterRouter/ContextCenterRouter.tsx | Register new Context Center routes for AI Context list/detail. |
| openmetadata-spec/src/main/resources/json/schema/type/personaContextDefinition.json | Schema update: add filteredInSearch to contextRule (no schema default). |
| openmetadata-spec/src/main/resources/json/schema/type/personaContext.json | Schema update: add searchScope + supporting definitions to persona context. |
| openmetadata-service/src/test/java/org/openmetadata/service/aicontext/PersonaContextBuilderTest.java | Add/extend tests for skipping scoped rules and composing searchScope. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/teams/PersonaResource.java | Create-path stamping behavior for filteredInSearch on new rules. |
| openmetadata-service/src/main/java/org/openmetadata/service/aicontext/PersonaContextMarkdown.java | Render “Search scope” section into markdown when scoped rules exist. |
| openmetadata-service/src/main/java/org/openmetadata/service/aicontext/PersonaContextBuilder.java | Skip scoped rules in materialization and generate searchScope.queryFilter. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/mcp/PersonaAIContextIT.java | Integration coverage for create defaulting + searchScope presence + rule exclusion from preloads. |
Review details
Suppressed comments (2)
openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextRuleEditor/ContextRuleEditor.component.tsx:127
getDefaultRulecan preservefilteredInSearch=truefor knowledge rules when editing existing data, even though knowledge rules are not allowed to be search-scoped. Since the toggle is disabled for knowledge rules, this can leave a stuck invalid state that will submit back to the server.
This issue also appears on line 268 of the same file.
openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextRuleEditor/ContextRuleEditor.component.tsx:283
handleSubmittreats any truthyfilteredInSearchas scoped, but knowledge rules should never be scoped. If a knowledge rule is ever stored withfilteredInSearch=true(e.g. via API/default stamping), this submit path would keep it true and could also clear preload options based onscopedlogic.
- Files reviewed: 52/57 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…Articles The nav and routes I added only reached the legacy ContextCenterRouter. The running app resolves Context Center through the ai-shell AppModule, which owns its own route table and sub-nav, so AI Context never appeared and its URLs did not resolve there. Register both pages in contextCenter.module.tsx and add the sub-nav entry directly after Overview. The classic sidebar entry moves to the same position so the two agree. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
There are correctness/API-shape issues that can silently change rule behavior in the UI and can produce ambiguous “empty scope” payloads for consumers.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (3)
Previously missed (2) — in code that hasn't changed since the last review.
openmetadata-service/src/main/java/org/openmetadata/service/aicontext/PersonaContextBuilder.java:323
- When no enabled rules opt into filteredInSearch, searchScope() returns empty entityTypes/rules. Given the schema text (“An entity type absent from this list is outside the scope entirely”), an empty list is ambiguous and can be interpreted as “no entity types allowed”. Clearing entityTypes/rules to null in this empty case makes “unscoped” unambiguous for consumers.
openmetadata-service/src/main/java/org/openmetadata/service/aicontext/PersonaContextBuilder.java:302 - searchScope() currently returns a SearchScope with empty entityTypes/rules when the definition is disabled. Because OpenMetadata commonly serializes empty collections, this can be misread downstream as “scope to nothing” rather than “unscoped”. Prefer returning a SearchScope with null fields in the empty/unscoped cases so consumers can treat missing fields as “no scope”.
openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextRuleEditor/ContextRuleEditor.component.tsx:417
- Changing the entity type currently forces the delivery-mode toggles (alwaysInContext/fullyRendered/filteredInSearch) to the new type’s defaults. This will silently change existing asset rules (e.g., table→dashboard) from preloading to search-scoped just because the entity type was edited. Delivery mode should only be forced when switching to/from knowledge entity types; otherwise keep the user’s current selection.
- Files reviewed: 53/58 changed files
- Comments generated: 1
- Review effort level: Lite
New asset rules default to search-scoped, disabling Max assets.
New asset rules default to search-scoped, which disables preload-only controls. Switch them to preloaded mode through the accessible keyboard interaction to avoid sticky-footer pointer interception.
…r-search-filter # Conflicts: # openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextRuleCard/ContextRuleCard.component.tsx # openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/ContextRuleEditor/ContextRuleEditor.component.tsx # openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/PersonaAIContext/PersonaAIContext.component.tsx
…lter' into pmbrull/context-center-search-filter
Code Review 👍 Approved with suggestions 2 resolved / 3 findingsMoves Persona AI Context into Context Center with a new search-scoped delivery mode that filters rules in search rather than preloading them, reducing character budget. Adds comprehensive unit and integration tests covering scoped rules, UI behavior, and backward compatibility with pre-existing rules. Consider addressing the test cleanup issue in 💡 Quality: Union test leaks the second table it creates📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/mcp/PersonaAIContextIT.java:207 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/mcp/PersonaAIContextIT.java:227-229 twoScopedRulesSelectTheUnionOfBothWhenTheFilterIsActuallySearched creates the extra ✅ 2 resolved✅ Bug: Scoped-rule badge counts disabled rules, diverging from applied scope
✅ Edge Case: AI Context persona list capped at 50 with no pagination
🤖 Prompt for agentsOptionsDisplay: compact → Showing less information. 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:
Screen.Recording.2026-09-02.at.17.08.55.mov
Fixes #32457
I moved the Persona AI Context editor out of Settings → Personas and into Context Center as an AI
Context submenu, and added a third delivery mode to a context rule — filtered in search —
because every enabled rule was previously materialized into the cached document whether or not the
user ever asked about those assets. A scoped rule preloads nothing; it hands its selection to the AI
search tools as a default filter instead, so the persona still only sees the assets its
administrator selected but the character budget no longer grows with the catalog.
Type of change:
High-level design:
1. Context Center submenu. Two new routes on the existing Context Center router —
/context-center/ai-context(persona list, rule counts + scoped-rule badge) and/context-center/ai-context/<fqn>(the rule editor). Nav item sits between Memories and Archive andis registered in
SIDEBAR_NESTED_KEYSso the parent highlights.ContextCenterClassBasegainsgetAIContextListPath()/getAIContextPath(fqn)alongside the existing articles/documents/memoriesgetters, so Collate's embedded-mode override keeps working. The editor folder moves
components/Settings/Persona/PersonaAIContext/→components/ContextCenter/PersonaAIContext/(
git mv, all four subfolders, relative imports rewritten). Theai-contexttab is deleted fromPersonaDetailsPage.2.
filteredInSearchoncontextRule.selectRulesskips scoped rules entirely — noElasticsearch round-trip, no character budget — and a new
searchScope(definition)unions thecontributing rules into one ready-to-use filter, each rule contributing
entityType AND its own filter:{"query":{"bool":{"filter":[ {"term":{"deleted":false}}, {"bool":{"minimum_should_match":1,"should":[ {"bool":{"filter":[{"term":{"entityType":"table"}}, <rule queryFilter>]}} ]}} ]}}No scoped rules → no filter at all, and search behaves exactly as before. One or more → a strict
allowlist, which is what makes "this persona only searches tables" expressible.
Backward compatibility — the missing schema
defaultis deliberate. jsonschema2pojo compiles aschema
defaultinto the field initializer, which would make a rule stored before this fieldindistinguishable from one explicitly set to
trueand force a data migration overpersona_entityJSON. Declaring no default leaves the POJO field
null, which the server reads asfalse: everyrule that exists today keeps preloading, with no migration.
createAiContextRulestampstruewhen the client omits the field, so every new rule scopes search. The update path deliberately
does not stamp — a
nullthere means a legacy rule is being round-tripped and must keep itsbehavior. Consequence: the stored default (
false) and the created default (true) differ; theschema description says so.
searchScope { entityTypes[], rules[], queryFilter }is added topersonaContext.jsonand served onthe existing
/v1/personas/me/context?format=json, so the agent needs no new endpoint and no extrarequest. Cache invalidation already worked —
PersonaContextHash.definitionHashserializes the wholedefinition, so editing a scoped rule's filter changes the fingerprint even though it changes no
preloaded bytes.
PersonaContextMarkdownrenders a short "Search scope" section; without it thedocument gives no hint that searches are narrowed and the model cannot explain a thin result set.
Editor UI. Three behaviour cards — Filtered in search / Always in context / Fully rendered.
Turning the first on disables and mutes the other two plus Sections and Max assets, and
handleSubmitclears them, so the UI reads as an exclusive three-way choice while the schema stays additive.
Consumer side is ai-platform #1252,
which forwards
searchScope.queryFilterto Collate's/v1/hybrid/nlq/search?query_filter=(thatendpoint already accepts the parameter, so no Collate change is needed).
"this persona may only search tables" is advisory. OpenMetadata RBAC remains the only enforcement of
what a user may read. This is stated in the tool description, the prompt, and the schema.
Alternatives rejected. A single exclusive
contextModeenum is a cleaner model but collapses theexisting independent
alwaysInContext+fullyRenderedcombination and needs a migration topreserve it.
"default": trueplus a data migration stampingfalseon existing rules makes thedefault honest at every layer but requires rewriting
persona_entityJSON on MySQL and Postgres fora behavior the create-path stamp already delivers. Per-entity-type pass-through (types with no scoped
rule stay unrestricted) is a safer default but cannot express "only tables".
Design doc:
docs/superpowers/specs/2026-09-02-persona-context-search-scope-design.md.Tests:
Use cases covered
clicks through to edit one persona's rules.
clears Always in context, Fully rendered, Sections and Max assets.
tablerule serves asearchScopeon its context document and does notpreload the matched table.
Unit tests
openmetadata-service/.../aicontext/PersonaContextBuilderTest.java— scoped rules are skippedwithout an ES call; the union is composed per entity type; disabled rules and disabled definitions
contribute nothing.
.../ui/src/utils/PersonaAIContextUtils.test.ts— a rule stored without the field normalizes topreloading;
getScopedRuleCount..../ContextRuleEditor/ContextRuleEditor.test.tsx— new-rule default, existing-rule default,mutual exclusivity, and that switching to scoped clears the preload options on submit.
.../ContextCenterAIContextPage.test.tsx,.../ContextCenterAIContextDetailPage.test.tsx— bothnew pages, including navigation and empty states.
Result: backend 37/37 pass (
PersonaContext*Test,PersonaRepositoryTest); UI 60/60 passacross 11 suites.
Backend integration tests
searchScopedRuleIsServedAsASearchFilterInsteadOfBeingPreloadedtoopenmetadata-integration-tests/.../mcp/PersonaAIContextIT.java— asserts a rule created withoutthe field comes back
filteredInSearch=true, that?format=jsoncarriessearchScopewith theentity type and a non-empty filter, and that the scoped rule is absent from
rules. Also pinnedthe existing
tableRulehelper tofilteredInSearch=falseso the document assertions stayintentional.
mvn test -pl openmetadata-integration-tests -Dtest=PersonaAIContextITbefore merge.Ingestion integration tests
Playwright (UI) tests
PR rather than a follow-up.
Manual testing performed
Not run against a live stack — verification here is the unit/jest suites plus the checks below. The
integration test above is the gap and is called out as such.
Also verified:
tsc --noEmitclean on every changed file; UI checkstyle (organize-imports → eslint →prettier) reports 0 errors;
yarn i18nstable,license-header-fixandgenerate:app-docsclean;mvn spotless:checkBUILD SUCCESS. All 8 new i18n keys were translated in all 19 non-English localesrather than left as English placeholders.
UI screen recording / screenshots:
Context Center → AI Context; a recording should be added before merge.
Checklist:
I have read the CONTRIBUTING document.
My PR title is
Fixes <issue-number>: <short explanation>My PR is linked to a GitHub issue via
Fixes #<issue-number>above.I have commented on my code, particularly in hard-to-understand areas.
For JSON Schema changes: I updated the migration scripts or explained why it is not needed —
no migration is needed, and the reasoning is under High-level design.
For UI changes: I attached a screen recording and/or screenshots above.
I have added tests (unit / integration / Playwright as applicable) and listed them above.
I have added tests around the new logic.
🤖 Generated with Claude Code