Repository navigation
AI context: a metric concept carries its filters, granularity and unit - #37419
Conversation
7b61191 to
9ac9555
Compare
|
@claude review |
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
…d record the concept context contract
✅ Generated Sources Auto-UpdatedThe generated TypeScript types ( |
Code Review ✅ Approved 2 closed / 2 findings🟡 Medium risk · Adding metric filters, granularity, and units to AI context changes how agents compute and report values; misapplied conditions could produce incorrect answers. Adds ✅ 2 closed✅ Quality: No decision record for the new conceptContext metric fields
✅ Edge Case: Multiple filters are newline-joined, so how they combine is unclear
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|



Fixes #37476
Related: open-metadata/openmetadata-collate#8310
Replaces #37193 (closed when its branch was renamed to
ai-sql-qa-fixes; its reviews are there).Describe your changes:
A metric's concept context (
GET /metrics/name/{fqn}/context) carried only its expression and bindings, so the agent computing it never saw the rest of what defines the number:filters: the SQL conditions the metric is defined under (status = 'paid'). Without them the agent computes the metric unfiltered, and the number is wrong.granularity: the time grain it is reported at.unit: the unit it is measured in; the custom unit whenunitOfMeasurementisOTHER. QA found a DOLLARS metric whose$in the answer was only the model's guess.conceptContextgains the three optional fields;ConceptContextBuilderfills them for a metric (each omitted when the metric does not declare it), andConceptContextMarkdownrenders them under the definition. The filters all apply, so they render as one conjunction,(a)\nAND (b), and never as a list a model could read as alternatives. Blank conditions are dropped. Type, dimensions, measures and the variant hierarchy stay out: they do not change the number.Decision record:
ADR:2026-11-10-a-metric-concept-context-carries-what-changes-its-number(theconceptContextmetric fields are a contract ai-platform reads).Companion: open-metadata/ai-platform renders the same fields in the SQL and worker concept text (open-metadata/ai-platform#2155, which also carries the former ai-platform#2061); it builds against this one, so this merges first.
Type of change:
Verification
ConceptContextBuilderTest.metricCarriesWhatDefinesItsNumber,metricNamesItsCustomUnitAndOmitsWhatItDoesNotDeclare;ConceptContextMarkdownTest.rendersWhatDefinesAMetricsNumber(now also asserts two filters render as(a)\nAND (b)).fe76f007efc(isolated Maven repo):mvn -pl openmetadata-service test -Dtest='ConceptContextMarkdownTest,ConceptContextBuilderTest': 28 run, 0 failed. The first run caught a whitespace-only filter passing through; fixed in the same commit.mvn spotless:apply: clean.Checklist: