Skip to content

fix(semantics,query): serve the relationship ends and expression operators a query used to refuse - #2140

Merged
HuiJun merged 16 commits into
developfrom
fix/reflective-relationship-ends
Nov 13, 2026
Merged

HuiJun merged 16 commits into
developfrom
fix/reflective-relationship-ends

Conversation

@devin-ai-integration

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

Copy link
Copy Markdown
Contributor

What and why

A query that read one of these metamodel properties stopped with the path error expected <Class>::<property> derived by OpenSysML, although the semantic layer already held the answer. They are now derived in the reflective layer (internal/semantic/semantics), which the query evaluator, -run-query and the symbol-backed element structure all read:

  • Relationship::source, target and relatedElement on a connector — KerML binding n of f = g;, succession n first f then g;, connector n from f to g;, SysML binding n bind a1 = a2;, succession n first a1 then a2; — as its sourceFeature, targetFeature and relatedFeature, and on dependency n from A to C; as its clients and suppliers. A connector whose first end references nothing (connector n from Missing to g;) answers none of the three, so the end that did resolve is not read as the source; one whose later end references nothing (connector n from g to Missing;) keeps its source.
  • Disjoining::typeDisjoined / disjoiningType, FeatureInverting::featureInverted / invertingFeature, TypeFeaturing::featureOfType / featuringType on the keyword-first members disjoining n disjoint A from B;, inverting n inverse f of g;, featuring n of f by A;, with the source, target and relatedElement they redefine. Their owningType, owningFeature and owningFeatureOfType are empty, as a namespace owns them.
  • Expression::operator: . on a feature chain expression (a.b), collect on a.{in q; q}, select on a.?{in q; true}.
  • FeatureTyping::target of the typing a transition's accept trigger writes (transition t first s1 accept Sig then s2;). The trigger's parts carry no scope of their own, so the first read resolved the type against nothing and the resolver remembered the miss for every later read; they now resolve in the scope the trigger is written in. The typing of an ordinary feature f : A; or part p : A; already answered its target.

One correction rides along: a keyword-first relationship whose source is a feature chain (inverting n inverse g.f of h;) answered the chain's last feature as its source. It now leaves that end underived, as it already did for a chain target, since the end is the chain feature the relationship owns.

Overlap with #2135, #2172 and #2175

#2135 landed first with a connector arm for relatedElement, source and target in ReflectiveElements. This branch merges it and keeps one arm: it reads through declaredRelationshipEnds, which reuses #2135's connectorEndRedefinition and adds what that arm did not have, the dependency ends and the unresolved-end guard. The keyword-first relationship ends, the three operators and the trigger typing do not touch #2135's code.

#2172 lets a connector's source and target answer past the valueless ends it inherits from the library, and its test has a connector whose second end is unresolved and still expects a source. The unresolved-end guard here refused all three properties when any end was unresolved; it now refuses only when the first end is, which is the case that shifts the ends after it.

#2175 derives an association's relatedElement, source and target in the same ReflectiveElements case. The merge keeps that branch first and unchanged; every other relationship goes on through declaredRelationshipEnds.

Specification basis

KerML 1.1 Beta 2: 8.3.4.5.3 Connector (sourceFeature redefines source, targetFeature redefines target, relatedFeature redefines relatedElement); 8.3.2.2.2 Dependency (client redefines source, supplier redefines target); 8.3.3.1.4 Disjoining, 8.3.3.3.6 FeatureInverting, 8.3.3.3.11 TypeFeaturing (each end redefines source or target; the textual grammar writes inverse featureInverted of invertingFeature); 8.3.4.8.2 CollectExpression (operator = 'collect'), 8.3.4.8.18 SelectExpression (operator = 'select'), 8.3.4.8.4 FeatureChainExpression (operator = '.'). No compliance row moves.

How it was verified

  • internal/semantic/semantics/reflective_relationship_ends_test.go: each property on the tree and on its recorded form, the unresolved and chain ends, non-relationships, the three operators, the trigger typing with no document walk before it, a connector with an unresolved first end and one with an unresolved later end. internal/doc/queryexec/relationship_ends_test.go: one Project test per property group. Every new test fails on develop.
  • sysml <fixture> -run-query over a model with each construct returns the elements where develop returned the path error. The qvts recipe audit (scripts/check-synthetic.sh against this build) reports 0 unverifiable probe instances on the merge with develop, where develop alone reports 30. Both report the same 2 mismatches, PerformActionUsage::isComposite (expected true, reflected false), which this change does not touch.
  • The generated baselines were re-recorded on the merge with develop by the rebaseline workflow's recorder sequence under Java 21, and scripts/rebaseline-movement.py accepts the movement. Two files move against develop:
    • internal/translate/export/testdata/structure_differential_expected.txt, five lines: Relationship::source, target and relatedElement gain agreements in the examples and pilot roots (a disjoint … from …, a featuring … of … by … and relationships with a chain source); nothing else moves.
    • internal/semantic/metamodel/derived_census_records.tsv, four records. Relationship::source and target move in examples and kerml-examples for the same constructs. The fourth is not this change's behaviour: the pilot column of Feature::featuringType in pilot-examples goes from 14551 to 14548. The committed value reproduces only under Java 25; under Java 21, which the workflow runs, the pilot states no featuringType for three FeatureChainExpressions of ServerSequenceModelOutside.sysml.
  • On that merge: go build ./..., go vet ./..., gofmt -l . and make lint clean; go test -timeout 120m ./... passes; go test -C tools ./referee/apijson passes; the corpus gates pass with the require variables set (training, pilot corpora, specification examples, PSSM, pilot library XMI). pilot-apijson-diff -update moved nothing.

Known limitations

These are outside this change and unchanged by it:

  • A flow usage projects source and target empty beside its relatedElement on the query surface (flow f of M from p.o to q.i; gives source = (none), relatedElement = [p::o, q::i]), on develop as here.
  • The RDF and API JSON writers state the first-written end of inverse a of b as invertingFeature, the reverse of the grammar; the structure differential keeps those rows as differences. They also write no operator on feature chain, collect and select expressions.
  • A transition's accept trigger reflects its payload's typing on the accept, on the payload and, when the payload is named, on the named parameter, all under one element id.
  • Connector::sourceFeature and targetFeature still read the resolved end of a connector whose first end references nothing as its source; only the three Relationship properties are left underived there.
  • A dependency read from a recorded document derives no ends, as its client and supplier do not.

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

Link to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/6716186d318146d7a574f263bb87fb92
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/6716186d318146d7a574f263bb87fb92?variant=devin
Requested by: @HuiJun


🟢 Devin Review found nothing to fix · View findings · Follow Devin's work

Devin Review

…ators a query used to refuse

Relationship: :source, target and relatedElement answer on a connector as the features its ends reference and on a dependency as its clients and suppliers; a keyword-first disjoining, inverting or featuring answers the ends its metaclass declares; Expression::operator reads '.', 'collect' and 'select' on a feature chain, collect and select expression; the typing a transition's accept trigger writes resolves in the scope the trigger is written in. A keyword-first relationship's chain source stays unresolved, as its chain target does.
Co-Authored-By: jason.han <hanhuijun@gmail.com>
@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

…rs no source, target or relatedElement

The resolved end was read as the source, since the related features drop the missing position before the first is taken.

Co-Authored-By: jason.han <hanhuijun@gmail.com>

@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 1 finding. Devin automatically fixed it.

Fixed by Devin (1)
  • Unresolved connector end shifts source — A connector with an end that references nothing (connector cn from Missing to g;) read the resolved end as its source. It now leaves source, target and relatedElement underived; TestConnectorRelationshipEndsUnresolved covers it.

View findings in Devin Review · Follow Devin's work

Devin Review

devin-ai-integration Bot and others added 2 commits November 11, 2026 19:49
Keeps one arm for a connector's relatedElement, source and target: it reads through declaredRelationshipEnds, which reuses connectorEndRedefinition and keeps the dependency ends and the unresolved-end guard.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ationship-ends

Co-Authored-By: jason.han <hanhuijun@gmail.com>

# Conflicts:
#	internal/translate/export/testdata/structure_differential_expected.txt
@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review November 12, 2026 00:47
@devin-ai-integration devin-ai-integration Bot added the ci:rebaseline Merge develop into this pull request and re-record its generated baselines label Nov 12, 2026
@github-actions github-actions Bot removed the ci:rebaseline Merge develop into this pull request and re-record its generated baselines label Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

ci:rebaseline stopped without pushing (run, failure). Movement seen so far:

  • internal/semantic/metamodel/derived_census_records.tsv: 4 record(s) moved; 2 moved by develop
    • ours.empty: 3022033 → 3022030 (-3)
    • ours.value: 1838001 → 1838004 (+3)
    • pilot.empty: 2751340 → 2751343 (+3)
    • pilot.value: 2989326 → 2989323 (-3)
    • 4 movement(s) the merge does not explain (neither side moved the record, or the fresh value is neither side's):
      • examples Relationship::target
      • kerml-examples Relationship::source
      • kerml-examples Relationship::target
      • pilot-examples Feature::featuringType
  • internal/translate/export/testdata/structure_differential_expected.txt: 5 record(s) moved; 5 moved by both sides (the merge's verdict, adjudicate)

devin-ai-integration Bot and others added 12 commits November 12, 2026 17:54
…elationship::source

Only an unresolved first end shifts the ends after it, so only that one refuses source, target and relatedElement. A resolved first end answers as the source whatever the later ends resolve to.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Relationship::source and target move in the examples and kerml-examples roots: declared disjoinings, type featurings and feature invertings now state their ends, and a relationship whose source is a feature chain states none instead of the chain's last feature.

Recorded under Java 21, the version the rebaseline workflow runs. The pilot states featuringType for three FeatureChainExpressions of ServerSequenceModelOutside.sysml under Java 25 and not under Java 21, which moves the pilot column of Feature::featuringType in pilot-examples.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ationship-ends

annotations.go: an association answers relatedElement, source and target with its ends' types, as develop derives them; every other relationship goes through declaredRelationshipEnds. The conflicting generated baselines took develop's side and are re-recorded in the next commit.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
… on the merged tree

Recorded with the rebaseline workflow's recorders under Java 21 after merging develop, whose side the conflicting generated files took.

The census moves in the four records this branch already moved: Relationship::source and target in examples and kerml-examples, and the pilot column of Feature::featuringType in pilot-examples. The structure differential moves in five Relationship::relatedElement, source and target lines, each toward agreement with the graph: develop re-recorded those lines without the declared relationship ends this branch derives.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ationship-ends

The conflicting structure-differential baseline took develop's side and is re-recorded in the next commit.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…tree

Recorded with -update-structure-differential after merging develop, whose side the conflicting baseline took.

Five Relationship::relatedElement, source and target lines move, each by the sum of what the two sides recorded: develop's association ends on the RDF leg and this branch's declared relationship ends. In examples, relatedElement and source agree on 2 more elements than develop and target on 1 more; in examples/pilot-corpora, relatedElement on 5 more and source on 4 more. scripts/rebaseline-movement.py attributes all five to both sides and none to neither.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ationship-ends

Co-Authored-By: jason.han <hanhuijun@gmail.com>

# Conflicts:
#	internal/semantic/metamodel/derived_census_records.tsv
#	internal/translate/export/testdata/structure_differential_expected.txt
…fferential on current develop

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@HuiJun
HuiJun added this pull request to the merge queue Nov 13, 2026
Merged via the queue into develop with commit cafd49e Nov 13, 2026
30 checks passed
@HuiJun
HuiJun deleted the fix/reflective-relationship-ends branch November 13, 2026 16:34
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