Skip to content

fix(metamodel,export): derive a flow's sourceOutputFeature and targetInputFeature from its ends - #2516

Merged
HuiJun merged 6 commits into
developfrom
fix/flow-source-output-target-input-feature
Nov 23, 2026
Merged

HuiJun merged 6 commits into
developfrom
fix/flow-source-output-target-input-feature

Conversation

@devin-ai-integration

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

Copy link
Copy Markdown
Contributor

Fixes #2199.

What and why

For flow f from t.fuelOut to e.fuelIn;, a flow's sourceOutputFeature and targetInputFeature were derived as the features its two ends attach to (Tank::fuelOut, Engine::fuelIn). They are now the features the two ends own, which redefine those:

P::f property before after
sourceOutputFeature P::Tank::fuelOut P::f::source::fuelOut
targetInputFeature P::Engine::fuelIn P::f::target::fuelIn

Model (from the issue), read with GetElementProperties through the Python client:

package P {
    part def Tank { out fuelOut; }
    part def Engine { in fuelIn; }
    part t : Tank;
    part e : Engine;
    flow f from t.fuelOut to e.fuelIn;
}

The change is in the shared derivation, internal/semantic/metamodel/structure_rules.go: structureFlowEndFeature takes the flow's connectorEnd at index 0 or 1 and answers its first ownedFeature; the superseded structureFlowAttachment is removed. An end inherited from a library flow (a message, or a flow declaring no ends) is read through the semantic model and still answers no feature, so the message behaviour of #2042 is unchanged.

Surfaces:

  • Symbol API and GetElementProperties read the shared derivation and now answer the end-owned features for a flow, a succession flow, a flow whose ends are feature chains (tank.inner.o), and the KerML flow / succession flow forms.
  • API-JSON (sysml -convert api-json) wrote neither property. apiJSONCompletedProperties gains the two Flow rows, so the export writes the same elements.
  • Document queries refuse every derived Flow property ("does not derive yet") before and after this change, so they give no wrong answer. That limitation is left as it is.

Specification basis

KerML 8.3.4.9.2 (Flow):

deriveFlowSourceOutputFeature — The sourceOutputFeature of a Flow is the first ownedFeature of the first connectorEnd of the Flow.
sourceOutputFeature = if connectorEnd->isEmpty() or connectorEnd.ownedFeature->isEmpty() then null else connectorEnd.ownedFeature->first() endif

deriveFlowTargetInputFeature — The targetInputFeature of a Flow is the first ownedFeature of the second connectorEnd of the Flow.
targetInputFeature = if connectorEnd->size() < 2 or connectorEnd->at(2).ownedFeature->isEmpty() then null else connectorEnd->at(2).ownedFeature->first() endif

The pilot implementation answers the same elements. No row of docs/project/spec-compliance/ moves.

Generated baselines

Every file below was rewritten by its recorder; training_examples_expected.txt is untouched and no size allowlist entry is added.

  • Structure differential (structure_differential_expected.txt): the ten Flow::sourceOutputFeature / Flow::targetInputFeature rows are gone (five roots, e.g. equal 2 … symbol-extra 66, equal 16 … symbol-extra 100). They recorded the Symbol API answering an element the graph did not; the two now agree on every flow, and the file lists only the properties they disagree on.
  • Element-properties agreement ratchet (answered-not-exported.txt): FlowUsage::sourceOutputFeature 70, FlowUsage::targetInputFeature 71, SuccessionFlowUsage::sourceOutputFeature 2 and SuccessionFlowUsage::targetInputFeature 2 are gone: the export now writes what the reader answers.
  • clauses.txt, edited by hand: the symbol-76 line is removed. It is a hand-written adjudication, not recorder output; it stated the old rule ("the features the flow's two ends attach to … the export writes none for them"), which contradicts 8.3.4.9.2, and no ratchet row cites it any more.
  • Derived census (derived_census_records.tsv, recorded date in derived_census_baseline.json), agreement with the pilot for both properties: pilot-examples 67 → 68 of 94 equal (27 → 26 different); spec-examples 7 → 14 of 26 equal (11 → 7 different, 8 → 5 unanswered). No row gets worse.
  • API-JSON differential: eleven fragments, each moving only the two Flow/FlowUsage/SuccessionFlowUsage rows and the file's summary. In ten (TakePicture.kerml, AHFSequences, Flashlight Example, ServerSequenceOutsideRealization-3, ServerSequenceRealization-3, RoomModel, Annex_A_VehicleViews, Annex A SimpleVehicleModel, kerml/7.4.10.3/1.kerml, Interaction Realization-2) the rows move from ours-missing to present-equal, e.g. RoomModel [0,0,6,0,0,0,0] → [6,0,0,0,0,0,0]. In spec-examples/kerml/7.4.10.3/3.kerml they move from ours-missing to present-different ([0,0,1,…] → [0,1,0,…]): the example leaves Vehicle, fuelTank and engine unresolved, and both tools name the first feature owned by fuelFlow::source, but this export classifies that end-owned feature as a ReferenceUsage where the pilot has a Feature, so the two references do not match by metaclass. That classification predates this change and is not altered by it. index.json totals: present-equal 2,332,784 → 2,332,874, ours-missing 186,616 → 186,524, present-different 168,586 → 168,588.
  • Model-reading test suite (docs/project/hideo-suite-baseline.tsv, hideo-suite.md): group B20 goes from 51 pass / 24 fail to 75 / 0 in both transports (48 case results), all cases 1729 / 51 / 33 → 1753 / 27 / 33.

How it was verified

New tests, each failing before the fix:

  • TestSymbolStructureDerivesAFlowsEndFeaturesFromItsEnds (internal/semantic/metamodel) — flow, succession flow, feature-chain ends, a message, KerML flow and succession flow.
  • TestElementPropertiesReadAFlowsEndFeatures (internal/frontend/grpc) — the same over GetElementProperties, also checking that each answer is the feature its FlowEnd owns and that its ownedRedefinition reaches the attached feature.
  • TestAPIJSONWritesAFlowsEndFeatures (internal/translate/export).

Gates on this head: go test ./... with the training, pilot, specification-example, library-XMI and PSSM corpora required, go build ./..., go vet ./... (root and tools), gofmt -l empty, make lint, staticcheck (root and tools), go test -C tools ./referee/apijson, TestSymbolStructureMatchesGraphStructure, derived-census -check -recorded-pilot, pilot-apijson-diff -check, doc-counts -check, scripts/changelog.py check. pilot-diff -check and hideo-suite -check were run before the last merge of develop, which touched neither surface.

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 Review found nothing to fix · View findings

Devin Review

devin-ai-integration Bot and others added 6 commits November 21, 2026 17:40
…InputFeature from its ends

KerML 8.3.4.9.2 deriveFlowSourceOutputFeature and deriveFlowTargetInputFeature
state the two properties as the first ownedFeature of the flow's first and
second connectorEnd. The shared derivation answered the features those owned
features redefine instead. It now reads the ends, so GetElementProperties, the
Symbol API and the graph structure answer the end-owned features, and the
API-JSON element form writes the two properties.

Fixes #2199.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
The structure differential, agreement ratchet, derived census, api-json
differential and hideo-suite baseline move with Flow::sourceOutputFeature
and Flow::targetInputFeature now read from the flow's ends.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…tput-target-input-feature

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

# Conflicts:
#	docs/project/api-json-differential/index.json
#	docs/project/api-json-differential/kerml-examples/Behavior Examples/TakePicture.kerml.json
#	docs/project/api-json-differential/spec-examples/kerml/7.4.10.3/1.kerml.json
…tput-target-input-feature

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

# Conflicts:
#	docs/project/api-json-differential/index.json
Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

devin-ai-integration Bot commented Nov 22, 2026 •

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 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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@HuiJun
HuiJun added this pull request to the merge queue Nov 22, 2026
Merged via the queue into develop with commit 013190a Nov 23, 2026
33 checks passed
@HuiJun
HuiJun deleted the fix/flow-source-output-target-input-feature branch November 23, 2026 00:33
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.

GetElementProperties: a flow's sourceOutputFeature and targetInputFeature are empty, and a message has no connectorEnd

1 participant