Repository navigation
Backport 2.0: AI context trust signals (#32261) + prerequisite MCP context-memory visibility (#32465) - #32973
Conversation
…ad-time staleness stamping (#32261) * Fixes #32260: trust signals for AI context — gate pills on Active, read-time staleness stamping * Fixes #32260: address review — exact cue budget sizing, upstream DQ authorization gate, log placeholder * Fixes #32260: charge stale cue to the shared budget pool; count ellipsis inside the excerpt limit * Fixes #32260: guard excerpt against non-positive limits (zero-allowance structural preview) * Fixes #32260: gate upstream DQ behind VIEW_TESTS, bound structural preview to the excerpt limit * Fixes #32260: suppress caller-relative upstream DQ signal when no caller context exists (persona materialization) (cherry picked from commit c3d6c03)
❌ PR checklist incompleteThis 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 |
| "default": false | ||
| }, | ||
| "staleReasons": { | ||
| "description": "Machine-readable reasons for the stale flag (e.g. assetUpdated, dataQualityFailing).", |
There was a problem hiding this comment.
💡 Quality: staleReasons schema example doesn't match emitted value
The staleReasons description in aiContext.json lists the example reason assetUpdated, but stampStaleness actually emits assetUpdatedAfterKnowledge (alongside dataQualityFailing and upstreamDataQualityFailing). This schema field is consumer-facing for agents, so the mismatched example is misleading. Update the example to the real reason strings.
Align the schema example with the reason strings the builder emits.:
"description": "Machine-readable reasons for the stale flag (e.g. assetUpdatedAfterKnowledge, dataQualityFailing, upstreamDataQualityFailing).",
Was this helpful? React with 👍 / 👎
🔴 Playwright Results — workflow failedValidated commit ✅ 0 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky ⚙️ No test failures. This run failed in CI infrastructure or reporting (see Pipeline and setup failures), not because of your changes — no test action needed from you. Pipeline and setup failures (26)
Performance⚪ Performance metrics unavailable; see the CI and reporting failures above.
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
* fix(mcp): apply per-entity visibility rules on direct entity reads * test(mcp): cover the shared-pill lookup and state the rule in comments * review: exercise the sharedWith path, cover the admin branch, correct the scope note (cherry picked from commit d3ab545)
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsBackports AI context trust signals (#32261) and prerequisite MCP context-memory visibility (#32465) to 💡 Quality: staleReasons schema example doesn't match emitted value📄 openmetadata-spec/src/main/resources/json/schema/type/aiContext.json:47 📄 openmetadata-service/src/main/java/org/openmetadata/service/aicontext/AIContextBuilder.java:601-607 The Align the schema example with the reason strings the builder emits.🤖 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:
Two backports to
2.0, cherry-picked in dependency order:c3d6c03d3ab5452.0did not compile without it — see belowWhy #32465 is in this PR
2.0was broken at HEAD before this branch.1f7813f0b0(the2.0backport of #32858, fix(context): hydrate owners for memory reads) added two call sites ofContextMemoryVisibility.guardFields(entityType, fieldsParam)inContextMemoryResource.java(lines 400 and 438), but #32465 — the PR that definesguardFieldsonContextMemoryVisibility— was never backported:Nothing on push-to-
2.0compiles Java (only CodeQL runs), which is why this went unnoticed. Picking #32465 here both restores the branch and lets this PR's CI actually validate the #32261 backport instead of failing on a pre-existing break.What #32261 does
Knowledge pills (ContextMemory items) attached to an asset flowed into AI context bundles (
get_asset_context, persona documents) regardless of lifecycle state, and the bundle never told an agent whether the knowledge it received was still current.Active-only pill gating —
toPillKnowledgeItemmirrors the glossary path's approval gating: pills inDraftorArchivedstate with a liveAPPLIED_TOedge are no longer served to agents as current context. Pre-lifecycle memories (no status) remain visible, matching howisApprovedtreats a missing glossary review status.Read-time staleness stamping —
KnowledgeItemgains additivestale+staleReasonsfields, stamped byAIContextBuilderfrom two deterministic, pure-function signals:assetUpdatedAfterKnowledge— the attached asset'supdatedAtis newer than the knowledge item's last update;dataQualityFailing/upstreamDataQualityFailing— the asset's (or a direct upstream's, capped at 3 edges, gated behindVIEW_TESTSand memoized per bundle) data-quality tests are failing.Stamping is informational only — items are never removed, so agents can weigh the signal instead of silently losing context.
Compact Markdown trust cue — stale items render a one-line cue naming the reasons, only when stale; the cue's exact rendered length is charged to the existing knowledge budget (
fitItem) so it can never push a bundle past the caller's budget.No new status vocabulary, no new provenance model, no relational migration (additive fields on the
KnowledgeItemJSON type;ContextMemoryschema untouched).What #32465 does
Applies the per-entity ContextMemory visibility rules on MCP entity reads:
CommonUtils.readEntityForCaller/enforceEntityVisibility, wired intoGetEntityTool,PatchEntityToolandCompanyContextTool, plus theguardFields/hasVisibilityRuleshelpers onContextMemoryVisibilitythat mergeownersinto the caller's field selection (a read that omitsownershands the guard an ownerless memory and denies the owner their own private memory).Type of change:
Backport fidelity:
Both picks were diffed line-by-line against their upstream commits, comparing only added/removed content lines (ignoring blob hashes and hunk offsets):
496changed lines, identical to upstream. Applied with zero conflicts.747changed lines, identical to upstream. One conflict, inPatchEntityToolTest.java, confined to the import block (2.0's copy of that file has drifted frommain); resolved by taking the incoming imports, thenspotless:applydropped the three that are unused on the 2.0 base (java.util.Set,ResourceContextInterface,EntityUtil.Fields). No logic was touched.Also checked:
ContextMemoryStatus(Draft/Active/Archived) exists on2.0with the same vocabulary, so the pill gate keeps its meaning.Tests:
Use cases covered
get_asset_contextoutputassetUpdatedAfterKnowledgeget_entity/patch_entity/ company-context reads honour ContextMemory visibility;guardFieldsmergesownersinto the caller's field selectionUnit tests
Both upstream test suites come across with the picks. Green on this branch:
Backend integration tests
McpContextMemoryVisibilityITcomes across with Apply context memory visibility rules on MCP entity reads #32465 and compiles on this branch.AIContextMcpITharness.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
UI screen recording / screenshots:
Not applicable.
Checklist: