Skip to content

fix(semantic): classify action nodes, succession flows and subjects by their statement - #2053

Merged
HuiJun merged 14 commits into
developfrom
fix/action-node-and-subject-classification
Nov 9, 2026
Merged

HuiJun merged 14 commits into
developfrom
fix/action-node-and-subject-classification

Conversation

@devin-ai-integration

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

Copy link
Copy Markdown
Contributor

What and why

Fixes #2008
Fixes #2009

Action nodes and succession flows (#2008). An action declared as a node — action a accept …, action a assign …, perform action a, action a if …, action a while …/until, action a for …, action a terminate — was a plain SymbolActionUsage, and a succession flow a plain SymbolFlowUsage, because internal/semantic/symbols has one kind per usage keyword and the builder mapped ast.Usage.Kind without reading the statement the action was written as. Symbol kind, query @type, the reflective metaclass and the symbol facts all read that kind, so every one of them said ActionUsage/FlowUsage; the exporter also had no named-node branch for if/while/for and mapped UsageFlow to FlowUsage regardless of succession.

What changed:

  • Symbols. New kinds SymbolAcceptActionUsage, SymbolAssignmentActionUsage, SymbolPerformActionUsage, SymbolIfActionUsage, SymbolWhileLoopActionUsage, SymbolForLoopActionUsage, SymbolTerminateActionUsage and SymbolSuccessionFlowUsage (acceptActionUsage, …, successionFlowUsage). classifyUsage classifies every action node in one place, classifyActionNode, from the statement the node is written as (symbols.ActionNodeStatementOf, symbols.AcceptPayloadOf, Usage.IsPerformedAction, Usage.IsTerminate) and a flow from Usage.IsSuccessionFlow(). SymbolKind.IsActionUsage() / IsFlowUsage() replace the kind tests that meant "any action usage" / "any flow usage" (runtime, lowering, views, REPL, LSP, checks, codegen, highlighting), so a specialized kind behaves as its plain kind did everywhere else.
  • Query, reflection, facts. MetamodelTypeNameOf (@type) and sysmlMetaclassName (reflective metaclass, x meta SysML::IfActionUsage) map the new kinds; Symbol.kind over gRPC follows.
  • Graph side. semantics.ImpliedBaseFQNsForMetaclass and the nested-usage rules know the node metaclasses (base Actions::actions) and SuccessionFlowUsage (base Flows::successionFlows, SysML v2 §8.3.15.7), so a graph read without its notation inherits what the symbol table gives the declaration (this is what keeps the structure differential's Connector::connectorEnd rows equal for succession flows).
  • Exporter. usageMetaclassOf/nodeStatement write a named if/while/for node as the one IfActionUsage/WhileLoopActionUsage/ForLoopActionUsage carrying the name, and a succession flow as SuccessionFlowUsage; the decoder writes the action <name> head back in front of the loop or conditional (loopText, conditionalText), so the round trip holds. messageParameterEnd accepts a SuccessionFlowUsage owner as it does a FlowUsage.
  • Exporter, succession flows. The succession prefix is carried by the SuccessionFlowUsage metaclass (prefixCarriedByGraph) rather than recorded as sysx:declaredPrefix, and the decoder restores it from the metaclass, so a graph without layout reads back succession flow a.x to b.y. A KerML succession flow stays FlowUsage, as a KerML flow already is.
  • Persistence. The symbol-kind numbering the library index records and the stdlib snapshot persist moved: formatVersion 33 → 34 and snapshotFormatVersion 27 → 28, with the pinned digests.

Subjects and inherited return parameters (#2009). A subject is parsed two ways (ast.SubjectMember in a requirement body, ast.Usage{Kind: UsageSubject} in a case body); symbolfacts.typeInfoOf knew only *ast.Usage/*ast.Definition, so a requirement's subject had no type facts, and a case body's subject reported no direction. The subject's kind itself — SymbolReferenceUsage for both shapes, in from its SubjectMembership, the view placement through semantics.IsSubjectUsage — landed on develop in #2059 while this PR was open; this PR is merged on top of it and keeps only what #2059 does not cover:

  • symbolfacts reads a SubjectMember's type and multiplicity (subjectTypeInfo, metadata.type), and writes the reflective direction (semantics.ReflectiveDirection) into metadata.direction when none was written, so Symbol kind/metadata, query @type, the reflective metaclass and the API JSON agree for constraint, requirement, use case, analysis and verification definitions, their specializations and their usages.
  • Inherited result/verdict. symbolfacts.membersOf no longer withholds a library-inherited member owned through a ParameterMembership (or SubjectMembership, ActorMembership, StakeholderMembership, ReturnParameterMembership — semantics.Model.MembershipMetaclassOf): Cases::Case::result, VerificationCases::VerificationCase::verdict and Requirements::RequirementConstraintCheck::result are listed as a declared return r is, with their library provenance; a declared return r still masks the result it redefines. Documented in docs/project/spec-compliance/08-grpc-service-layer.md (GetSymbol) and 06-verification-case.md.

Relation to #1992

#1992 (fix/send-action-usage-classification) introduces SymbolSendActionUsage with the same mechanism — a kind, symbols.SendStatementOf, a classifyUsage check and SymbolKind.IsActionUsage() — and is still open. This PR deliberately does not touch the send case. It should land after #1992; the overlap resolves as: keep #1992's IsActionUsage and add this PR's kinds to it, move #1992's SendStatementOf(u) != nil check into classifyActionNode as case *ast.SendStatement: return SymbolSendActionUsage (it can then be written over ActionNodeStatementOf), and add "SendActionUsage": ast.UsageAction to impliedUsageKinds. Both PRs bump kindMappingDigest/formatVersion/snapshotKindDigest; whichever lands second re-pins them.

Specification basis

SysML v2.1 Beta 2 §8.2.2.17 ActionNode : ActionUsage = ControlNode | SendNode | AcceptNode | AssignmentNode | TerminateNode | IfNode | WhileLoopNode | ForLoopNode; §8.2.2.14 SuccessionFlowUsage; §8.3.15.7 (succession flows subset Flows::successionFlows); §8.2.2.19 SubjectUsage : ReferenceUsage; §8.3.21.11 SubjectMembership is a ParameterMembership; KerML v1.1 Beta 2 §8.3.4.6 parameterDirection() defaults to in. Compliance rows added to docs/project/spec-compliance/02-detailed-semantic-compliance-map/13-action.md, 12-requirement.md and 06-verification-case.md.

Baselines

Structure differential (internal/translate/export/testdata/structure_differential_expected.txt, re-recorded with -update-structure-differential): 85 rows moved, roots examples (unmatched 17504 → 17502) and examples/spec-examples (4037 → 4027). 80 rows improve — subjects now agree on Usage::nestedReference/ownedReference/isReference/ownedPart/nestedPart, succession flows on Connector::connectorEnd/endFeature/Usage::nestedFlow, and the node metaclasses on their ownedFeature/inheritedFeature rows. 5 rows regress by one element each and are expected: in examples/spec-examples/sysml/7.17.11/1.sysml the named action test if … is now written as the IfActionUsage itself, whose graph side carries the condition and branch parameters while the symbol side does not derive them yet (Step::parameter, Type::directedFeature, Type::input, Usage::directedUsage) — deriving the node arguments is the follow-up the issue leaves out of scope; examples Usage::nestedConnection 5098/150 → 5097/151 is the same node reclassification seen through the connector filter. The KerML TakePicture.kerml rows for succession flow exposure are unchanged against develop (checked by running the differential on both trees).

API JSON differential (docs/project/api-json-differential-baseline.json, go run -C tools ./cmd/pilot-apijson-diff -update; figures re-counted with make docs-counts): elements ours-only 16216 → 16210 (a named if/for node is written as the node carrying the name, not an anonymous node under a plain ActionUsage: StructuredControlTest, Sysml 7.17.12 example 4::dynamicScenario); type mismatches 1821 → 1820 — three fewer in pilot-examples/examples where the pilot names the node too, two more in spec-examples, where Sysml 7.17.11 example 1::test (action test if speed < lowerLimit … with lowerLimit/IncreaseSpeed/MaintainSpeed undeclared) is now the IfActionUsage the grammar states while the pilot's export of that incomplete example gives a plain ActionUsage without condition or branches; the same element is the one new pilot-missing on ActionUsage.input/directedFeature/directedUsage; properties present-equal −1, present-different +747, ours-missing −746, pilot-missing +4. The scorecard rows that moved are the node metaclasses' inheritedFeature/inheritedMembership/feature/featureMembership/member/membership/usage (Accept/Assignment/ForLoop/If/Terminate/WhileLoop…ActionUsage): every one goes from ours-missing to present-different, because the writer now gives those elements the library-inherited members the pilot also lists, with our element ids for them; IfActionUsage.usage 0/4 → 3/1 equal/different; ActionUsage.usage 136 → 132 equal as four named nodes left the generic row; WhileLoopActionUsage.nestedConnection pilot-missing 2 → 3 is a succession flow inside a loop the pilot does not report as a nested connection.

Golden conversions (tests/export/testdata/convert, -update): end_prefix_metadata, kind_keyword_synonyms, qualified_usages, requirements, condition_references, constraints, metadata_prefixes, result_expressions, shadowed_references change only a sysml:PartUsage → a sysml:ReferenceUsage on their subjects (one 5-byte move per subject in the digested files); accept, state_machine, shadowing_parameters grow by the Actions::Action::subactions library closure an AcceptActionUsage now reaches through acceptSubactions.

Corpus round-trip (tests/corpus, -update-corpus-roundtrip with the corpora present): no movement. training_examples_expected.txt untouched.

Persistence pins: formatVersion 33 → 34, snapshotFormatVersion 27 → 28, kindMappingDigest/snapshotKindDigest re-pinned; stdlib snapshot regenerated with make stdlib-snapshot.

After merging develop at 4456378 (#2037, #2045) and again at bfebfa9 (#2050, which re-recorded the API JSON baseline's writer digest): the four generated files GitHub reported conflicting were taken from develop and re-recorded, never hand-merged. API JSON (-update, then -check): every figure above is unchanged — -lost-against the pre-merge run reports 0 matches lost, 0 gained; only the provenance digest and date moved, so the adjudication above stands. Structure differential: the same 85-row movement as before the merge, re-based on develop's new Step::parameter row (equal 576 → 575, the Sysml 7.17.11 example 1::test case already explained under API JSON). Golden conversions: only the shadowing_parameters and state_machine digests were re-recorded (both carry develop's FeatureMembership change over this branch's subjects); the other goldens merged cleanly. Corpus round-trip re-run: no movement. The second merge conflicted only on the API JSON baseline; re-recorded the same way, again 0 matches lost / 0 gained and no figure moved, and the structure differential, golden conversions and corpus round-trip pass unchanged.

After merging develop at 4464eed (#2054, #2055, #2039, #2040): GitHub reported the API JSON baseline, the structure differential and docs/project/spec-compliance/08-grpc-service-layer.md conflicting. The two generated files were taken from develop and re-recorded by tool (pilot-apijson-diff -update then -check; -update-structure-differential then the plain run, all corpora present), never hand-merged; the compliance row for GetSymbol was merged by hand: develop's rewrite (derived type_info.types, references specializations) plus this PR's one sentence on library-owned result/verdict return parameters. API JSON: every figure above is unchanged against the pre-merge baseline (develop moved only the writer digest), so the adjudication stands. Structure differential: the same 25 properties move against develop as before (87 expectation lines now, 87 before the merge), each re-based on #2054's first-marker membership counts (matched 28930 → 28924 on develop itself); no property moves that did not move before. Golden conversions and the corpus round-trip pass unchanged.
Merged fix/conjugated-port-typing (#1980, at f07308c, which carries develop 528a425 — #2054, #2055, #2039, #2040, #2057, #2059, #2056, #2049, #2061, #2060, #2041, #2046, #2064) and then develop at ddc5b7a (#1980 merged, #2065): merge commits only, never rebased. #2059 landed the subject's kind (SymbolReferenceUsage for both parser shapes, in from its SubjectMembership, IsSubjectUsage on recorded symbols, the view placement) while this PR was open, so this PR's duplicate of that change was dropped in the merge in favour of develop's — ReflectiveDirection, the isComposite derivation, IsSubjectUsage, the builder's subject cases and mixedStructural are develop's; the subject-reference-usage changelog fragment is one entry, develop's sentence plus this PR's on the requirement-body subject's type facts and the inherited result/verdict parameters. formatVersion is 35 (develop's #2059 took 34 for the subject kind; this PR's action-node kinds need their own invalidation), kindMappingDigest 97f47fda5699409a, snapshotFormatVersion 28 / snapshotKindDigest unchanged. Generated files were taken from the base and re-recorded by tool after make stdlib-snapshot: structure differential — 15 properties / 55 lines move against the base, a subset of the 25 adjudicated above (the eight Definition::owned{Item,Occurrence,Part,Reference} / Usage::nested{…} rows were the subject→ReferenceUsage movement, now on develop, and #2064's Comment elements re-based the rest); API JSON — against the base the movement is exactly the one adjudicated above (ours-only 16216 → 16210, type mismatches 1821 → 1820, present-equal −1, present-different +747, ours-missing −746, pilot-missing +4, unkeyed references 157266 → 157815, extension properties 269337 → 269339), -check reproduces it; golden conversions — accept, shadowing_parameters and state_machine re-recorded with -update: only additions, the library closure an accept node now reaches as an AcceptActionUsage (Actions::Action::subactions::this, Performances::Performance::subperformances::thisPerformance, Occurrences::Occurrence::suboccurrences::… and their documentation), no element changes metaclass (the subject goldens moved on develop in #2059); the corpus round-trip passes unchanged; derived-property census — re-recorded with derived-census -update, -check reproduces it; the silent list is unchanged (18 rules). Movements: AcceptActionUsage::payloadArgument/payloadParameter/receiverArgument carriers 143 → 192 — every accept node is now an AcceptActionUsage carrier, so payloadParameter is derived on all 192 (value 143 → 192), payloadArgument on 63 (49 → 63; the rest are accept with no payload value) and receiverArgument stays underived on them (empty 119 → 168, the pre-existing gap the issue leaves out of scope); Type::inheritedFeature/inheritedMembership value +46 / empty −46 and Type::endFeature empty −46 / notDerived +46 — a succession flow now inherits Flows::successionFlows' features; Namespace::member/membership, Type::feature/featureMembership and Usage::usage each move value −3 / empty +3 (pilot-examples 1, pilot-validation 2) with the action-node kinds — the element set is unchanged (the API JSON of both corpora compared element by element against the base), no rule joins or leaves silent. Browser REPL size budget — on the merged tree the gzipped RE sysml.wasm the gate links measures 15,901,230 bytes, 1,230 over the 15,900,000 budget (develop alone is about 7.5 KB under it; the action-node kinds and their metaclass tables are the difference), so the budget is raised to 16,000,000 in its own commit, as the previous raises were.

How it was verified

  • go build ./..., go vet ./..., gofmt -l . (no output), go test -count=1 -timeout 45m ./...: green on this head (every package ok, exit 0).
  • go test -C tools -count=1 ./...: green (29 packages), including referee/apijson provenance and figures gates; make docs-counts current.
  • OPENSYSML_REQUIRE_TRAINING_CORPUS=1 OPENSYSML_REQUIRE_PILOT_CORPORA=1 OPENSYSML_REQUIRE_SPEC_EXAMPLES=1 go test ./tests/corpus -run TestCorpusRoundTrip -update-corpus-roundtrip: ok, no movement.
  • New tests: internal/semantic/symbols/action_node_kind_test.go (every node kind, succession flow, both subject shapes), internal/semantic/semantics/reflective_action_nodes_test.go and the implicit_metaclass_test.go additions (reflective metaclass and implied bases, document and index record), internal/frontend/symbolfacts/subject_test.go (five definition kinds, their specializations and usages: kind, direction, type, resolved type, query @type, reflective metaclass and direction, SubjectMembership), internal/frontend/symbolfacts/inherited_parameter_test.go (inherited result/verdict listed with provenance, declared return r/verdict masks without duplicates), tests/export named-node and succession-flow API JSON/Turtle round trips, and gRPC conformance fixtures symbol_action_node_kinds, symbol_succession_flow_kind, symbol_subject_parameter, symbol_verdict_member.
  • The issues' reproductions over sysml-grpc (Symbol kind, query @type, reflective metaclass, metadata, members with provenance) report the metaclasses of the issues' tables; send stays actionUsage until fix(semantics): a send action is a SendActionUsage with its payload, sender and receiver on every surface #1992 lands.

Checklist

  • make test and make lint pass locally (go build, go vet, gofmt -l, go test -count=1 -timeout 45m ./..., tools module)
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (spec-compliance sources 13-action, 12-requirement, 06-verification-case, 08-grpc-service-layer; api-json differential record; inherited-member listing)
  • Changelog entry added as changes/unreleased/action-node-kinds.fixed.md and changes/unreleased/subject-reference-usage.fixed.md
  • baselines regenerated and make docs-counts run (structure differential, api-json differential, golden conversions, corpus round-trip unchanged)
  • No internal work-item labels in the body, docs, or changelog

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

Devin Review

…y their statement

An action written as a node (accept, assign, perform, if, while/until, for, terminate) is the ActionUsage kind of that node and a `succession flow` a SuccessionFlowUsage, on the symbol kind, the query `@type`, the reflective metaclass, the symbol facts and the exporter, which also writes a named if/while/for node as the node carrying the name and carries `succession` by metaclass. A subject is one ReferenceUsage parameter of direction `in`, typed as written, from both parser shapes; library-inherited members owned through a ParameterMembership (`result`, `verdict`) are listed like a declared return. Structure, API JSON and golden baselines re-recorded; library index and snapshot format versions bumped for the new kinds.

Fixes #2008
Fixes #2009

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

…d-subject-classification

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

# Conflicts:
#	docs/project/api-json-differential-baseline.json
#	internal/translate/export/testdata/structure_differential_expected.txt
#	tests/export/testdata/convert/shadowing_parameters.golden.ttl.sha256
#	tests/export/testdata/convert/state_machine.golden.ttl.sha256
…d-subject-classification

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

# Conflicts:
#	docs/project/api-json-differential-baseline.json
@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review November 8, 2026 04:47
devin-ai-integration Bot and others added 6 commits November 8, 2026 04:53
SymbolKind.Family() spelled a named if, loop, accept or assignment node
"if action", "while loop action" and so on, so an external analysis
engine advertising the "action" subject refused those nodes, and the
behaviour-order and document-plan diagnostics named them by metaclass
rather than by their keyword. A node is declared with `action`, and a
succession flow with `flow`, so their families are their keywords'.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
rootsByOwner selected roots of exactly SymbolActionUsage, so a named if
or loop node exposed as a root of its own lost the succession arrows its
owner declares to and from it, and the related-successions collector
looked for an owner of the two plain kinds only. Both now select by the
action-usage family, as behaviorKind already did for the roots drawn.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
staticcheck S1011 flagged the loop that re-appended the split steps one
by one; the helper was strings.Split, so the test calls it as such.

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

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…d-subject-classification

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

# Conflicts:
#	docs/project/api-json-differential-baseline.json
#	docs/project/spec-compliance/08-grpc-service-layer.md
#	internal/translate/export/testdata/structure_differential_expected.txt
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 2 findings. Devin automatically fixed all 2 findings.

Fixed by Devin (2)
  • External engines reject named action nodes — SymbolKind.Family() now returns "action" for every action-usage kind (if/while/for/accept/assignment/perform/terminate nodes) and "flow" for a succession flow, so engines advertising the action subject accept named nodes; unit test TestActionNodeKindsShareTheActionFamily locks it.
  • Succession arrows vanish between action nodes — rootsByOwner and the related-successions collector now select roots/owners by the action-usage family (IsActionUsage / actionOwnerKind) instead of exactly SymbolActionUsage; TestActionNodeRootsAreJoinedByTheirOwnersSuccessions exposes named if and while nodes and asserts both succession arrows (fails without the fix).

View findings in Devin Review · Follow Devin's work

Devin Review

devin-ai-integration Bot and others added 2 commits November 8, 2026 19:06
… fix/action-node-and-subject-classification

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

# Conflicts:
#	changes/unreleased/subject-reference-usage.fixed.md
#	docs/project/api-json-differential-baseline.json
#	docs/project/api-json-differential.md
#	internal/frontend/repl/self_check_test.go
#	internal/frontend/symbolfacts/facts.go
#	internal/semantic/semantics/annotations.go
#	internal/semantic/semantics/reflective_feature_test.go
#	internal/semantic/symbols/builder.go
#	internal/semantic/symbols/kind_mapping_test.go
#	internal/translate/export/testdata/structure_differential_expected.txt
The headline figures follow the re-recorded baseline, and the re-record
paragraph names the action-node change alone, the subject's kind having
landed on develop on its own.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration
devin-ai-integration Bot changed the base branch from develop to fix/conjugated-port-typing November 8, 2026 19:32
Base automatically changed from fix/conjugated-port-typing to develop November 8, 2026 23:34
devin-ai-integration Bot and others added 3 commits November 8, 2026 23:36
… fix/action-node-and-subject-classification

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

# Conflicts:
#	docs/project/api-json-differential-baseline.json
#	docs/project/api-json-differential.md
#	internal/semantic/metamodel/derived_census_baseline.json
#	internal/translate/export/testdata/structure_differential_expected.txt
#	tests/export/testdata/convert/accept.golden.ttl
#	tests/export/testdata/convert/shadowing_parameters.golden.ttl.sha256
#	tests/export/testdata/convert/state_machine.golden.ttl.sha256
Co-Authored-By: jason.han <hanhuijun@gmail.com>
@HuiJun
HuiJun merged commit 15b0ea7 into develop Nov 9, 2026
37 of 62 checks passed
@HuiJun
HuiJun deleted the fix/action-node-and-subject-classification branch November 9, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant