Skip to content

Fixes #36959: Only Approved glossary terms and metrics reach AI context as governed knowledge - #36990

Merged
pmbrull merged 7 commits into
mainfrom
pmbrull/memory-unapproved-definitions
Nov 6, 2026
Merged

pmbrull merged 7 commits into
mainfrom
pmbrull/memory-unapproved-definitions

Conversation

@pmbrull

@pmbrull pmbrull commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #36959

A glossary term or metric now reaches AI context as governed knowledge only when its entityStatus is Approved or unset (no review workflow applies). AI context had already dropped unapproved glossary terms, but it let metrics of any stage through and built concept context for any term or metric. Chat then presented an In Review term as "the governed glossary definition". Entity details still return an unapproved definition with its stage, and the ai-platform companion names that stage in the answer.

Type of change:

  • Bug fix

High-level design:

  • One rule: AIContextBuilder.isGovernedDefinition.
  • Paths it gates:
    • Attached persona knowledge (PersonaContextBuilder.fullKnowledgeItem, and attachFullKnowledge, which skips a null item instead of throwing).
    • Search-found context (AIContextFinder).
    • The metrics applied or related to an anchor (AIContextBuilder.metricKnowledgeItem).
    • Concept context and the metric definition built from it (AIContextBuilder.hasConceptContext).
    • Column glossary terms.
  • Chunk hits: a vector chunk hit carries no entityStatus, so the finder reads the stage of a term or metric hit from the entity. That read is cached per entity per request and fails closed if the entity can't be read. Chunk docs aren't stamped instead, because bumping CHUNK_DOC_VERSION would restamp, and possibly re-embed, every chunk set.
  • Record: docs/decisions/2026-11-03-only-approved-definitions-reach-ai-context-as-governed-knowledge.md.
  • Counterpart: open-metadata/ai-platform#2036 names an unapproved definition's stage in entity details and forbids calling it governed.

Tests:

Use cases covered

  • A persona whose selected asset has a Draft metric applied builds its context. The metric is left out, and the build doesn't fail.
  • Chat anchored on a table with an In Review metric gets no definition for that metric.
  • Concept context isn't built for an unapproved term or metric.
  • A search hit for an In Review term, including its chunk-index copies, is dropped. An Approved metric's chunk hit is kept.

Unit tests

  • GovernedDefinitionTest (8), AIContextFinderTest (9), PersonaContextBuilderTest (25), AIContextBuilderTest (51), ConceptContextCatalogTest (7), AIContextFinderAccessTest (2).
  • 102/102 pass at cfc0d1f5baa. The 3 chunk guard tests fail with the old rule.

Backend integration tests

Not run locally: make java_affected selects 76 integration tests. The IT module does not compile against the local snapshot jars. The tests run in the merge queue. No regression IT with an In Review metric was added (AIContextRestIT / PersonaAIContextIT); the unit tests pin each path.

UI screen recording:

Not applicable: backend-only change.

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 added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: four REVIEW.md rounds.
    • Fixed:
      • Metrics leaked through attached knowledge and concept context.
      • A persona build failed with an NPE on a Draft metric.
      • Anchored metrics weren't gated.
      • Chunk hits carried no stage.
    • The final round at cfc0d1f5baa found one more 🔴: a concept read of an unapproved term returns its description, which the platform rendered as governed. It is fixed in the ai-platform companion, which reads the stage itself, and this record says so (0841407f68b).
    • Nits left:
      • The builder wiring is pinned only through helpers.
      • Metric index docs written before the 2.1.0 stage backfill read Unprocessed until the reindex.
      • The persona cache's TTL window.
  • Decision check: the record above.

Regression follow-up (2026-11-04)

  • New ConceptContextIT#pendingDefinitionsKeepTheirStageButHaveNoGovernedConceptContext creates a glossary term and metric through the normal approval workflow, verifies their actual In Review stage, excludes governed concept context, and checks approved positive controls.
  • The new REST case passed on isolated MySQL/Elasticsearch. Combined memory/governance unit run: 240 passed, including GovernedDefinitionTest.
  • Self-review: 96c3ab93f8478390355f50357790132ef681faa8, fresh REVIEW.md pass, no unanswered Important findings. Coverage findings were fixed before this pass.
  • Runtime evidence: all 12 pinned PR heads are present in the combined stack; source heads: OpenMetadata 7d7ac24b6e4e274b935954a067dbae7fa61007a3, AI eacb39819e854615b6eebf27b6fa486b4b9beba3, Collate f10b2d235cd4ec4f461a2db409f43a9289d4e3ae. Targeted combined runs are reported here; this does not claim that every planner-selected integration or browser suite ran.

Merge readiness (2026-11-06)

Merge order (12 memory PRs). OpenMetadata #36988 first, then #36990 and #36992 in any order, then #36989 (it needs #36988). Right after #36989: Collate #8241, then #8239. Until #8241 lands, Collate main starts a memory created without a stage Approved. Collate #8240 and #8242 can merge any time. OpenMetadata #36991 goes last of the OpenMetadata PRs, after one update once #36989 and #36992 land; its conflicts are already resolved. ai-platform #2035 and #2036 can merge any time. #2034 goes after Collate #8239 and #8241, with one update after #2035, also already resolved.

🤖 Generated with Claude Code

pmbrull and others added 4 commits November 3, 2026 14:03
…ntext as governed knowledge

Release testing saw Chat answer from an In Review glossary term and call it
"the governed glossary definition". Attached knowledge and search-found
context already dropped unapproved terms but let metrics of any stage through,
and concept context was built for any term or metric. All three now share
AIContextBuilder.isGovernedDefinition: Approved or no stage.

ADR:2026-11-03-only-approved-definitions-reach-ai-context-as-governed-knowledge

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…persona builds without failing

- A persona whose selected asset has a Draft metric applied threw: the metrics
  loop attached the reference of a knowledge item that is now null. Both the
  article and metric loops go through attachFullKnowledge, which skips it.
- Metrics applied or related to an anchor reached AIContext.metrics and the
  concept's metrics whatever their stage; metricKnowledgeItem now admits only
  Approved (or stage-less) ones, as the record says.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Vector chunk docs carry no entityStatus, and the finder read a missing
stage as "no review workflow applies", so a Draft or In Review term or
metric reached find and MCP find_context as governed knowledge through its
chunks. A term or metric hit without a stage is now judged on its entity,
read once per entity per request, and dropped when that cannot be read.

Stamping the stage on chunk docs instead would bump CHUNK_DOC_VERSION,
restamping every chunk set on the next reindex, and would still need this
read until that backfill ran.

ADR:2026-11-03-only-approved-definitions-reach-ai-context-as-governed-knowledge

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 3, 2026 19:50
@pmbrull
pmbrull requested a review from a team as a code owner November 3, 2026 19:50
@pmbrull
pmbrull requested a review from manerow November 3, 2026 19:50

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 insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Nov 3, 2026
@pmbrull pmbrull added the 2.1 label Nov 4, 2026
Copilot AI balanced review requested due to automatic review settings November 4, 2026 16:22

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 insufficient remaining quota. Try requesting a review at a lower effort level.

pmbrull and others added 2 commits November 5, 2026 17:13
…oved-definitions

# Conflicts:
#	openmetadata-service/src/main/java/org/openmetadata/service/aicontext/AIContextFinder.java
Merging main brought a find_context test whose glossary-term hit carries no stage;
this PR drops such a hit unless its entity reads Approved.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 16:29

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 insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Filtering unapproved glossary terms and metrics from AI context could leave answers without useful definitions across search, persona, and anchored requests.

Restricts AI context to glossary terms and metrics that are Approved or have no review workflow, so unapproved definitions no longer reach chat as governed knowledge. 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 merged commit e940eb8 into main Nov 6, 2026
66 of 70 checks passed
@pmbrull
pmbrull deleted the pmbrull/memory-unapproved-definitions branch November 6, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.1 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.

AI context presents unapproved glossary terms and metrics as governed definitions

3 participants