Repository navigation
Fixes 33455: Include bounded metric semantics in JSON AI context #37992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iamkiayun
wants to merge
7
commits into
open-metadata:main
Choose a base branch
from
iamkiayun:fix/33455-metric-json-context
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,658
−43
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
19dd7c9
Fixes 33455: Include bounded metric semantics in JSON AI context
iamkiayun c071872
Address metric context Java style feedback
iamkiayun 8a78522
Address metric context review feedback
iamkiayun 469335c
Report only visible omitted metric relations and cover legacy date ma…
iamkiayun c2667e9
fix: flag omitted visible metric relations
pmbrull 56e0454
Merge remote-tracking branch 'upstream/main' into local/37992-maintai…
iamkiayun 56adb78
Merge remote-tracking branch 'upstream/main' into local/37992-maintai…
iamkiayun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
docs/decisions/2026-11-16-metric-structural-context-carries-semantic-fields.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Metric semantic fields extend bounded generic JSON without changing concept context | ||
|
|
||
| - **Status:** Proposed | ||
| - **Revisions:** v1 2026-11-16 (initial) | ||
| - **Guard:** `AIContextBuilderTest`, `AIContextMarkdownTest`, `MetricContextBudgetTest`, `ConceptContextIT`, `McpMetricRelationVisibilityIT`, `MetricExpressionMappingIT` | ||
| - **Related:** #33455, ADR:2026-11-10-a-metric-concept-context-carries-what-changes-its-number | ||
|
|
||
| ## Context | ||
|
|
||
| The generic metric block carries expression code and source assets but omits semantic dimensions, | ||
| measure aggregations, conditions and related FQNs. Structured-context callers need these to inspect | ||
| the metric. Concept context has a separate accepted contract that deliberately excludes dimensions, | ||
| measures and the variant hierarchy from its computation prompt. | ||
|
|
||
| ## Decision | ||
|
|
||
| Add optional `dimensions`, `measures`, `filters` and related metric FQNs to | ||
| `assetContext.generic` in structured JSON. Reuse the metric schemas and the concept builder's | ||
| non-blank filter conditions. Related FQNs are distinct references already admitted to the existing | ||
| visible, Approved-or-unset, bounded concept metric knowledge list. After checking the first 50 | ||
| knowledge candidates, structured metric JSON checks omitted related references in batches of 50. | ||
| It stops at the first visible, Approved-or-unset omission and sets the truncation marker. | ||
| A relation the caller cannot view does not set the marker. | ||
|
|
||
| Keep `conceptContext` JSON and default concept Markdown unchanged, including its granularity, | ||
| units and parenthesized AND conjunction of all filters. The earlier accepted decision remains | ||
| in force. The existing JSON format explicitly opts into the new generic fields; legacy builder | ||
| callers and Markdown requests retain their full previous knowledge budget. The new generic JSON | ||
| fields do not opt dimensions or measures into that prompt. | ||
|
|
||
| Charge the serialized new semantic fields, including their JSON envelope and truncation marker, | ||
| to the existing knowledge-character budget before attached knowledge. Reuse the existing | ||
| 50-item knowledge limit for each projected array. The stable knowledge-item TypeScript `Type` export is pinned by a schema title, so adding the | ||
| dimension enum does not rename an existing export. Spend space on complete filters first, then | ||
| related FQNs, dimensions and measures. Retain complete entries in source order; never clip SQL, | ||
| names or FQNs. A filter group is kept entirely or omitted entirely, because a partial conjunction | ||
| would change the definition. Set `semanticFieldsTruncated=true` when the projection drops entries | ||
| or a filter group. Clients must fetch the metric entity for the complete declarations in that case. | ||
| The original expression and source assets retain their existing shape and budget behavior. | ||
|
|
||
| The localized index templates add the emitted `metricExpression` field while retaining | ||
| `expression` with its old mapping. The new explicit text fields preserve the previous dynamic | ||
| `keyword` subfields (including `ignore_above: 256`), so exact-match searches remain available | ||
| on fresh indexes and existing indexes where the dynamic field is already text. | ||
|
|
||
| If the first expression looked like a date, the search engine may have mapped | ||
| `metricExpression.code` as `date`. An in-place mapping update then returns HTTP 400 because | ||
| the field type cannot change. After upgrading, run the Search Indexing application for the | ||
| `metric` entity with **Recreate Index** enabled. The equivalent admin request is | ||
| `POST /api/v1/apps/trigger/SearchIndexingApplication` with | ||
| `{"entities":["metric"],"recreateIndex":true}`. This rebuilds the metric documents from the | ||
| catalog into a fresh backing index with the explicit text mapping, then promotes that index. | ||
| Verify that the job succeeds and that an exact search on `metricExpression.code.keyword` | ||
| finds the original expression. | ||
|
|
||
| ## Consequences | ||
|
|
||
| Structured clients can inspect semantic declarations while consumers of concept JSON and default | ||
| Markdown retain their accepted prompt contract. Consumers reading only concept context do not | ||
| automatically gain dimensions or measures. Large declarations consume the shared budget and | ||
| produce explicit partial-projection metadata; attached knowledge may become shorter or reference | ||
| only. Existing concept conditions remain complete even when their generic duplicate cannot fit. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this commit,
hasVisibleOmittedRelationreplaced the previous single 50-reference lookahead with a loop over every omitted related reference, 50 at a time. It only stops early when it finds a visible, Approved-or-unset metric. Each batch callscontainsEligibleRelatedMetric, which does a bulkrepository.get(...)(find +setFieldsInBulk) and then aViewPermissionFilterpolicy evaluation. Take a metric with N related metrics where the ones past the first 50 are hidden, unapproved or deleted: every structuredget_asset_contextcall then makes about (N-50)/50 extra repository and authorization round trips. Nothing caps this. It also contradicts the PR's stated constraint of "no additional related-entity reads", and the ADR edit drops the former "up to 50 additional" bound without recording a new limit. Fix: put a hard cap on the lookahead batches (for example one or two), and once the cap is hit setsemanticFieldsTruncatedconservatively or leave it unasserted, as the earlier ADR wording did. Record that cap in the ADR.Bound the number of lookahead batches:
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating #33455, @pmbrull. I checked the scan cost. In your regression, 50 visible metrics are followed by 50 hidden ones and then one more visible metric. A one-batch lookahead misses that last metric. Setting
semanticFieldsTruncatedwhenever we hit a cap would also signal an omission when every remaining metric is hidden.I kept the visibility rule you requested. Structured JSON checks 50 references at a time and stops at the first visible, approved-or-unset omission. If none qualifies, it can read every remaining batch. Markdown skips this lookup. I updated the PR description to make that cost explicit.
Could you rerun Validate PR Metadata? Its last run predates your update, and I don’t have permission to rerun it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gitar can change code and merge on your behalf, so it only acts on requests from people who can push. This needs Write access to this repository.