Skip to content

fix(semantics): reflect a #M prefix through the OwningMembership its element owns - #2486

Closed
devin-ai-integration[bot] wants to merge 4 commits into
developfrom
fix/reflect-prefix-metadata-owning-membership
Closed

devin-ai-integration[bot] wants to merge 4 commits into
developfrom
fix/reflect-prefix-metadata-owning-membership

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What and why

A reflective query over #M part def n; returned an Annotation with no elementId. The RDF conversion never writes that element: it writes the OwningMembership through which n owns the prefix's MetadataUsage, and that membership has an id (<owner>___400_om). The reflective layer disagreed with the grammar, docs/reference/rdf-mapping.md and the conversion by reporting an Annotation for every #M prefix.

This PR changes the reflective layer only (internal/semantic/semantics); internal/translate/export is untouched.

  • An ordinary prefix (on a definition, usage, parameter or package) is now an owned membership, first among the element's ownedMembership, and its metadata usage is an owned member whose owningMembership is that membership. It annotates its owner through no Annotation, like the body spelling @M;.
  • It is owned through an OwningMembership, so it is not an ownedFeature, and its owningType and owningFeatureMembership are empty, as in the graph.
  • A relationship such as dependency keeps its Annotation (PrefixMetadataAnnotation), with the id <owner>___400_an.
  • A recorded symbol answers the same way as a parsed one.

Follow-up to #2414, which left this case out because it is not an export defect.

Specification basis

SysML.xtext / KerML.xtext: PrefixMetadataMember returns OwningMembership for DefinitionExtensionKeyword and UsageExtensionKeyword; PrefixMetadataAnnotation returns Annotation appears only in Dependency. The compliance row for prefix metadata in docs/project/spec-compliance/02-detailed-semantic-compliance-map/35-parser-recovery.md moves from Approximate to Faithful.

How it was verified

  • New internal/doc/queryexec/prefix_metadata_ids_test.go (TestPrefixMetadataIsOwnedThroughAnIdentifiedMembership): fails on develop with three blank-id Annotations; asserts the ids of the membership and metadata usage for a definition, a usage and a package, and of the Annotation for a dependency.
  • internal/semantic/semantics/reflective_memberships_test.go: five tests asserted the old contract (prefix owned through an Annotation, absent from ownedMembership); they now assert the membership, its position, and the dependency/relationship-body cases unchanged.
  • go build ./..., go vet ./..., gofmt -l ., make lint and go test ./... with the corpus require variables set, on the commit before develop was merged in. After the merge both baselines were re-recorded on the merged tree with the same movement, and the semantic, document, export, gRPC, corpus and hygiene suites were rerun.
  • go run -C tools ./cmd/pilot-apijson-diff -check passes with no movement: the API-JSON output is unchanged.

Baseline movements

Structure differential (internal/translate/export/testdata/structure_differential_expected.txt, symbol side against graph side). More elements match in every root, and unmatched falls by the same amount: examples +259, tests/testdata +6, training +6, pilot corpora +168, specification examples +10. These are the prefix memberships, which the symbol side did not state before.

  • Disagreement falls on the rows the defect caused, e.g. in examples: Element::ownedAnnotation and AnnotatingElement::annotation 261 → 2, Element::owningMembership 280 → 21, Namespace::ownedMembership 950 → 692; the Definition::ownedItem/ownedMetadata and Usage::nestedItem/nestedMetadata rows that differed by the prefix count now agree.
  • The only rows whose disagreement rises are Membership::memberElementId and OwningMembership::ownedMemberElementId, symbol-missing up by exactly the newly matched count in each root. The symbol side states no memberElementId for any membership; the newly matched memberships join that existing class.

Derived census (internal/semantic/metamodel/derived_census_records.tsv, our column only; the pilot column is unchanged). Of the rows that move, 125 move toward the pilot's count, 56 keep the same distance and 20 move away.

  • Toward: the Annotation::*, AnnotatingElement::annotation, Element::ownedAnnotation, owningMembership, owningNamespace, Membership::*, Namespace::ownedMember(ship) rows, and Definition::ownedMetadata / Usage::nestedMetadata (e.g. examples ownedMetadata 1 → 130 against the pilot's 132).
  • Away, 19 rows: Definition::ownedItem, ownedOccurrence, ownedUsage and Usage::nestedItem, nestedOccurrence. The prefix is now an owned member, and these collections are derived by filtering owned members by metaclass, so they list it; the pilot's counts suggest it does not. The graph side already listed it there before this PR (the structure differential rows above), so this is the symbol side reaching the conversion's existing answer, not a new one. I tried deriving these from owned features instead and excluding metadata usages from them; each made other rows worse, so the derivation is left alone here and is a candidate follow-up for both sides.
  • Away, 1 row: Annotation::annotatedElement in the specification examples, 28 → 18 carriers against the pilot's 32. The symbol side now has the annotations the graph has (structure differential Element::ownedAnnotation there 19 → 11 different). I did not identify which annotations the pilot has that neither side states.

training_examples_expected.txt is untouched, and TestExamplesSweep verdicts do not move.

Checklist

  • make test and make lint pass locally
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (see CONTRIBUTING.md)
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md
  • baselines regenerated and make docs-counts run if a gate count moved (compliance rows need nothing: the census is counted at docs build)
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

🟢 Devin fixed all 2 findings · Follow Devin's work

Devin Review

…element owns

A definition, usage or package owns the metadata usage of a `#M` prefix through an
OwningMembership (KerML.xtext PrefixMetadataMember); only a relationship such as a
dependency owns it through an Annotation (PrefixMetadataAnnotation). The reflective
layer reported an Annotation for every prefix, an element the RDF conversion never
writes, so a query read it with no elementId.

Co-Authored-By: Nicolas Rouquette <nicolas.f.rouquette@jpl.nasa.gov>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

devin-ai-integration Bot and others added 3 commits November 20, 2026 19:35
…-metadata-owning-membership

Co-Authored-By: Nicolas Rouquette <nicolas.f.rouquette@jpl.nasa.gov>

# Conflicts:
#	internal/semantic/metamodel/derived_census_records.tsv
#	internal/semantic/semantics/annotations.go
#	internal/translate/export/testdata/structure_differential_expected.txt
…herits

Co-Authored-By: Nicolas Rouquette <nicolas.f.rouquette@jpl.nasa.gov>
Co-Authored-By: Nicolas Rouquette <nicolas.f.rouquette@jpl.nasa.gov>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Devin Review found 2 findings. Devin automatically fixed all 2 findings.

Fixed by Devin (2)
  • Prefix metadata leaks into inherited features — Confirmed: B's feature listed A's #M prefix. The feature filter now excludes a prefix metadata usage; TestPrefixMetadataIsNoInheritedFeature fails without the fix.
  • API comment exceeds repository length limit — The OwnedAnnotations comment is now two lines.

View findings in Devin Review · Follow Devin's work

Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Closing as superseded: this fix already landed on develop in #2280, and the queued #2048 carries the same implementation. Merged onto #2048's head, this branch adds no production code.

It would have added two tests, which both pass against the landed implementation and can go in a follow-up if wanted:

  • TestPrefixMetadataIsOwnedThroughAnIdentifiedMembership (internal/doc/queryexec/prefix_metadata_ids_test.go): element ids of a #M prefix on a definition, usage, package (OwningMembership) and dependency (Annotation).
  • TestPrefixMetadataIsNoInheritedFeature (internal/semantic/semantics/reflective_memberships_test.go): a specialization does not inherit the prefix as a feature.

@devin-ai-integration
devin-ai-integration Bot deleted the fix/reflect-prefix-metadata-owning-membership branch November 23, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant