Skip to content

Fixes #32457: move Persona AI Context into Context Center, add search-scoped rules - #32458

Merged
pmbrull merged 22 commits into
mainfrom
pmbrull/context-center-search-filter
Sep 8, 2026
Merged

pmbrull merged 22 commits into
mainfrom
pmbrull/context-center-search-filter

Conversation

@pmbrull

@pmbrull pmbrull commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

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:

  • Improvement

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 and
is registered in SIDEBAR_NESTED_KEYS so the parent highlights. ContextCenterClassBase gains
getAIContextListPath() / getAIContextPath(fqn) alongside the existing articles/documents/memories
getters, 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). The ai-context tab is deleted from
PersonaDetailsPage.

2. filteredInSearch on contextRule. selectRules skips scoped rules entirely — no
Elasticsearch round-trip, no character budget — and a new searchScope(definition) unions the
contributing 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 default is deliberate. 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. Declaring no default leaves the POJO field null, which the server reads as false: every
rule that exists today keeps preloading, with no migration.
createAiContextRule stamps true
when the client omits the field, so every new rule scopes search. The update path deliberately
does not stamp — a null there means a legacy rule is being round-tripped and must keep its
behavior. Consequence: the stored default (false) and the created default (true) differ; the
schema description says so.

searchScope { entityTypes[], rules[], queryFilter } is added to personaContext.json and served on
the existing /v1/personas/me/context?format=json, so the agent needs no new endpoint and no extra
request. Cache invalidation already worked — PersonaContextHash.definitionHash serializes the whole
definition, so editing a scoped rule's filter changes the fingerprint even though it changes no
preloaded bytes. PersonaContextMarkdown renders a short "Search scope" section; without it the
document 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 handleSubmit
clears 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.queryFilter to Collate's /v1/hybrid/nlq/search?query_filter= (that
endpoint already accepts the parameter, so no Collate change is needed).

⚠️ The scope is a relevance filter, not a permission boundary. The agent can opt out per call, so
"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 contextMode enum is a cleaner model but collapses the
existing independent alwaysInContext + fullyRendered combination and needs a migration to
preserve it. "default": true plus a data migration stamping false on existing rules makes the
default honest at every layer but requires rewriting persona_entity JSON on MySQL and Postgres for
a 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

  • An administrator opens Context Center → AI Context, sees every persona with its rule count, and
    clicks through to edit one persona's rules.
  • A new rule created in the editor defaults to "filtered in search"; turning it on disables and
    clears Always in context, Fully rendered, Sections and Max assets.
  • A persona with a scoped table rule serves a searchScope on its context document and does not
    preload the matched table.
  • A persona whose rules all predate this change is unaffected on upgrade — they keep preloading.

Unit tests

  • Added unit tests for the new/changed logic.
  • openmetadata-service/.../aicontext/PersonaContextBuilderTest.java — scoped rules are skipped
    without 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 to
    preloading; 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 — both
    new pages, including navigation and empty states.

Result: backend 37/37 pass (PersonaContext*Test, PersonaRepositoryTest); UI 60/60 pass
across 11 suites.

Backend integration tests

  • Added searchScopedRuleIsServedAsASearchFilterInsteadOfBeingPreloaded to
    openmetadata-integration-tests/.../mcp/PersonaAIContextIT.java — asserts a rule created without
    the field comes back filteredInSearch=true, that ?format=json carries searchScope with the
    entity type and a non-empty filter, and that the scoped rule is absent from rules. Also pinned
    the existing tableRule helper to filteredInSearch=false so the document assertions stay
    intentional.
  • ⚠️ It compiles but I did not run it — it needs the Docker stack. Please run
    mvn test -pl openmetadata-integration-tests -Dtest=PersonaAIContextIT before merge.

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not added. Happy to add coverage for the new Context Center nav path if you want it in this
    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 --noEmit clean on every changed file; UI checkstyle (organize-imports → eslint →
prettier) reports 0 errors; yarn i18n stable, license-header-fix and generate:app-docs clean;
mvn spotless:check BUILD SUCCESS. All 8 new i18n keys were translated in all 19 non-English locales
rather than left as English placeholders.

UI screen recording / screenshots:

⚠️ Not attached — I could not exercise the UI without a running stack. The change is visible at
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

…-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]>
Copilot AI lite review requested due to automatic review settings September 2, 2026 09:54
@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Sep 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 filteredInSearch on persona context rules and a searchScope payload 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

  • getDefaultRule can preserve filteredInSearch=true for 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

  • handleSubmit treats any truthy filteredInSearch as scoped, but knowledge rules should never be scoped. If a knowledge rule is ever stored with filteredInSearch=true (e.g. via API/default stamping), this submit path would keep it true and could also clear preload options based on scoped logic.
  • 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.

@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 70%
70.38% (95075/135070) 54.9% (56191/102346) 56.29% (18778/33355)

…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]>
Copilot AI review requested due to automatic review settings September 2, 2026 10:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

New asset rules default to search-scoped, disabling Max assets.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitar-bot

gitar-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 2 resolved / 3 findings

Moves 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 twoScopedRulesSelectTheUnionOfBothWhenTheFilterIsActuallySearched: the other table and its parent entities are created outside the try block and never deleted in the finally, leaking them into the shared search index across test runs.

💡 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 other table before the try block, but the finally only hard-deletes the persona — the table (and the service/database/schema it hangs off) is never cleaned up, and if post("personas", ...) throws before the try, nothing is cleaned. This leaks entities into the shared search index across runs. Move the table creation inside the try or delete other in the finally alongside the persona.

✅ 2 resolved
✅ Bug: Scoped-rule badge counts disabled rules, diverging from applied scope

📄 openmetadata-ui/src/main/resources/ui/src/utils/PersonaAIContextUtils.ts:230-231 📄 openmetadata-service/src/main/java/org/openmetadata/service/aicontext/PersonaContextBuilder.java:305-312
getScopedRuleCount counts every rule with filteredInSearch truthy regardless of its enabled flag, but the backend searchScope() only includes rules where Boolean.TRUE.equals(rule.getEnabled()). A persona with a disabled scoped rule therefore shows a "filtered in search" badge count that overstates the rules actually narrowing search. Filter on enabled too (e.g. rules.filter((r) => r.filteredInSearch && r.enabled !== false)) so the UI count matches the served scope.

✅ Edge Case: AI Context persona list capped at 50 with no pagination

📄 openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterAIContextPage/ContextCenterAIContextPage.tsx:38 📄 openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterAIContextPage/ContextCenterAIContextPage.tsx:50-54 📄 openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterAIContextPage/ContextCenterAIContextPage.tsx:134
ContextCenterAIContextPage fetches personas with limit: PERSONA_PAGE_SIZE (50) and renders only that page, with no pagination or load-more control. Deployments with more than 50 personas will silently omit the rest from the AI Context list, making some personas unreachable via this nav path. Consider paginating or raising the limit with a follow-up load.

🤖 Prompt for agents
Code Review: Moves 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 `twoScopedRulesSelectTheUnionOfBothWhenTheFilterIsActuallySearched`: the `other` table and its parent entities are created outside the try block and never deleted in the finally, leaking them into the shared search index across test runs.

1. 💡 Quality: Union test leaks the second table it creates
   Files: 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 `other` table before the try block, but the finally only hard-deletes the persona — the table (and the service/database/schema it hangs off) is never cleaned up, and if `post("personas", ...)` throws before the try, nothing is cleaned. This leaks entities into the shared search index across runs. Move the table creation inside the try or delete `other` in the finally alongside the persona.

Options

Display: compact → Showing less information.

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

@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persona AI Context is hidden in Settings and preloads every rule

5 participants