Repository navigation
fix(semantic): classify action nodes, succession flows and subjects by their statement - #2053
Merged
Merged
Conversation
…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>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
This was referenced Nov 7, 2026
…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
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>
Contributor
Author
There was a problem hiding this comment.
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).
… 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
Bot
changed the base branch from
develop
to
fix/conjugated-port-typing
November 8, 2026 19:32
… 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
…d-subject-classification
Co-Authored-By: jason.han <hanhuijun@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 plainSymbolActionUsage, and asuccession flowa plainSymbolFlowUsage, becauseinternal/semantic/symbolshas one kind per usage keyword and the builder mappedast.Usage.Kindwithout reading the statement the action was written as. Symbolkind, query@type, the reflective metaclass and the symbol facts all read that kind, so every one of them saidActionUsage/FlowUsage; the exporter also had no named-node branch for if/while/for and mappedUsageFlowtoFlowUsageregardless ofsuccession.What changed:
SymbolAcceptActionUsage,SymbolAssignmentActionUsage,SymbolPerformActionUsage,SymbolIfActionUsage,SymbolWhileLoopActionUsage,SymbolForLoopActionUsage,SymbolTerminateActionUsageandSymbolSuccessionFlowUsage(acceptActionUsage, …,successionFlowUsage).classifyUsageclassifies 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 fromUsage.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.MetamodelTypeNameOf(@type) andsysmlMetaclassName(reflective metaclass,x meta SysML::IfActionUsage) map the new kinds;Symbol.kindover gRPC follows.semantics.ImpliedBaseFQNsForMetaclassand the nested-usage rules know the node metaclasses (baseActions::actions) andSuccessionFlowUsage(baseFlows::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'sConnector::connectorEndrows equal for succession flows).usageMetaclassOf/nodeStatementwrite a namedif/while/fornode as the oneIfActionUsage/WhileLoopActionUsage/ForLoopActionUsagecarrying the name, and asuccession flowasSuccessionFlowUsage; the decoder writes theaction <name>head back in front of the loop or conditional (loopText,conditionalText), so the round trip holds.messageParameterEndaccepts aSuccessionFlowUsageowner as it does aFlowUsage.successionprefix is carried by theSuccessionFlowUsagemetaclass (prefixCarriedByGraph) rather than recorded assysx:declaredPrefix, and the decoder restores it from the metaclass, so a graph without layout reads backsuccession flow a.x to b.y. A KerMLsuccession flowstaysFlowUsage, as a KerMLflowalready is.formatVersion33 → 34 andsnapshotFormatVersion27 → 28, with the pinned digests.Subjects and inherited return parameters (#2009). A subject is parsed two ways (
ast.SubjectMemberin a requirement body,ast.Usage{Kind: UsageSubject}in a case body);symbolfacts.typeInfoOfknew 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 —SymbolReferenceUsagefor both shapes,infrom its SubjectMembership, the view placement throughsemantics.IsSubjectUsage— landed ondevelopin #2059 while this PR was open; this PR is merged on top of it and keeps only what #2059 does not cover:symbolfactsreads aSubjectMember's type and multiplicity (subjectTypeInfo,metadata.type), and writes the reflective direction (semantics.ReflectiveDirection) intometadata.directionwhen 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.result/verdict.symbolfacts.membersOfno longer withholds a library-inherited member owned through a ParameterMembership (or SubjectMembership, ActorMembership, StakeholderMembership, ReturnParameterMembership —semantics.Model.MembershipMetaclassOf):Cases::Case::result,VerificationCases::VerificationCase::verdictandRequirements::RequirementConstraintCheck::resultare listed as a declaredreturn ris, with their library provenance; a declaredreturn rstill masks theresultit redefines. Documented indocs/project/spec-compliance/08-grpc-service-layer.md(GetSymbol) and06-verification-case.md.Relation to #1992
#1992 (
fix/send-action-usage-classification) introducesSymbolSendActionUsagewith the same mechanism — a kind,symbols.SendStatementOf, aclassifyUsagecheck andSymbolKind.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'sIsActionUsageand add this PR's kinds to it, move #1992'sSendStatementOf(u) != nilcheck intoclassifyActionNodeascase *ast.SendStatement: return SymbolSendActionUsage(it can then be written overActionNodeStatementOf), and add"SendActionUsage": ast.UsageActiontoimpliedUsageKinds. Both PRs bumpkindMappingDigest/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.14SuccessionFlowUsage; §8.3.15.7 (succession flows subsetFlows::successionFlows); §8.2.2.19SubjectUsage : ReferenceUsage; §8.3.21.11SubjectMembershipis aParameterMembership; KerML v1.1 Beta 2 §8.3.4.6parameterDirection()defaults toin. Compliance rows added todocs/project/spec-compliance/02-detailed-semantic-compliance-map/13-action.md,12-requirement.mdand06-verification-case.md.Baselines
Structure differential (
internal/translate/export/testdata/structure_differential_expected.txt, re-recorded with-update-structure-differential): 85 rows moved, rootsexamples(unmatched 17504 → 17502) andexamples/spec-examples(4037 → 4027). 80 rows improve — subjects now agree onUsage::nestedReference/ownedReference/isReference/ownedPart/nestedPart, succession flows onConnector::connectorEnd/endFeature/Usage::nestedFlow, and the node metaclasses on theirownedFeature/inheritedFeaturerows. 5 rows regress by one element each and are expected: inexamples/spec-examples/sysml/7.17.11/1.sysmlthe namedaction test if …is now written as theIfActionUsageitself, 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;examplesUsage::nestedConnection5098/150 → 5097/151 is the same node reclassification seen through the connector filter. The KerMLTakePicture.kermlrows forsuccession flow exposureare unchanged againstdevelop(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 withmake docs-counts): elements ours-only 16216 → 16210 (a namedif/fornode is written as the node carrying the name, not an anonymous node under a plainActionUsage:StructuredControlTest,Sysml 7.17.12 example 4::dynamicScenario); type mismatches 1821 → 1820 — three fewer inpilot-examples/exampleswhere the pilot names the node too, two more inspec-examples, whereSysml 7.17.11 example 1::test(action test if speed < lowerLimit …withlowerLimit/IncreaseSpeed/MaintainSpeedundeclared) is now theIfActionUsagethe grammar states while the pilot's export of that incomplete example gives a plainActionUsagewithout condition or branches; the same element is the one new pilot-missing onActionUsage.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.usage0/4 → 3/1 equal/different;ActionUsage.usage136 → 132 equal as four named nodes left the generic row;WhileLoopActionUsage.nestedConnectionpilot-missing 2 → 3 is asuccession flowinside 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_referenceschange onlya sysml:PartUsage→a sysml:ReferenceUsageon their subjects (one 5-byte move per subject in the digested files);accept,state_machine,shadowing_parametersgrow by theActions::Action::subactionslibrary closure anAcceptActionUsagenow reaches throughacceptSubactions.Corpus round-trip (
tests/corpus,-update-corpus-roundtripwith the corpora present): no movement.training_examples_expected.txtuntouched.Persistence pins:
formatVersion33 → 34,snapshotFormatVersion27 → 28,kindMappingDigest/snapshotKindDigestre-pinned; stdlib snapshot regenerated withmake stdlib-snapshot.After merging
developat 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 fromdevelopand re-recorded, never hand-merged. API JSON (-update, then-check): every figure above is unchanged —-lost-againstthe 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 ondevelop's newStep::parameterrow (equal 576 → 575, theSysml 7.17.11 example 1::testcase already explained under API JSON). Golden conversions: only theshadowing_parametersandstate_machinedigests were re-recorded (both carrydevelop'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
developat 4464eed (#2054, #2055, #2039, #2040): GitHub reported the API JSON baseline, the structure differential anddocs/project/spec-compliance/08-grpc-service-layer.mdconflicting. The two generated files were taken fromdevelopand re-recorded by tool (pilot-apijson-diff -updatethen-check;-update-structure-differentialthen the plain run, all corpora present), never hand-merged; the compliance row forGetSymbolwas merged by hand:develop's rewrite (derivedtype_info.types,referencesspecializations) plus this PR's one sentence on library-ownedresult/verdictreturn parameters. API JSON: every figure above is unchanged against the pre-merge baseline (developmoved only the writer digest), so the adjudication stands. Structure differential: the same 25 properties move againstdevelopas before (87 expectation lines now, 87 before the merge), each re-based on #2054's first-marker membership counts (matched 28930 → 28924 ondevelopitself); 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 carriesdevelop528a425 — #2054, #2055, #2039, #2040, #2057, #2059, #2056, #2049, #2061, #2060, #2041, #2046, #2064) and thendevelopat ddc5b7a (#1980 merged, #2065): merge commits only, never rebased. #2059 landed the subject's kind (SymbolReferenceUsagefor both parser shapes,infrom its SubjectMembership,IsSubjectUsageon 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 ofdevelop's —ReflectiveDirection, theisCompositederivation,IsSubjectUsage, the builder's subject cases andmixedStructuralaredevelop's; thesubject-reference-usagechangelog fragment is one entry,develop's sentence plus this PR's on the requirement-body subject's type facts and the inheritedresult/verdictparameters.formatVersionis 35 (develop's #2059 took 34 for the subject kind; this PR's action-node kinds need their own invalidation),kindMappingDigest97f47fda5699409a,snapshotFormatVersion28 /snapshotKindDigestunchanged. Generated files were taken from the base and re-recorded by tool aftermake stdlib-snapshot: structure differential — 15 properties / 55 lines move against the base, a subset of the 25 adjudicated above (the eightDefinition::owned{Item,Occurrence,Part,Reference}/Usage::nested{…}rows were the subject→ReferenceUsage movement, now ondevelop, 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),-checkreproduces it; golden conversions —accept,shadowing_parametersandstate_machinere-recorded with-update: only additions, the library closure anacceptnode 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 ondevelopin #2059); the corpus round-trip passes unchanged; derived-property census — re-recorded withderived-census -update,-checkreproduces it; the silent list is unchanged (18 rules). Movements:AcceptActionUsage::payloadArgument/payloadParameter/receiverArgumentcarriers 143 → 192 — everyacceptnode is now an AcceptActionUsage carrier, sopayloadParameteris derived on all 192 (value 143 → 192),payloadArgumenton 63 (49 → 63; the rest areacceptwith no payload value) andreceiverArgumentstays underived on them (empty 119 → 168, the pre-existing gap the issue leaves out of scope);Type::inheritedFeature/inheritedMembershipvalue +46 / empty −46 andType::endFeatureempty −46 / notDerived +46 — a succession flow now inheritsFlows::successionFlows' features;Namespace::member/membership,Type::feature/featureMembershipandUsage::usageeach 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 leavessilent. Browser REPL size budget — on the merged tree the gzipped REsysml.wasmthe gate links measures 15,901,230 bytes, 1,230 over the 15,900,000 budget (developalone 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 packageok, exit 0).go test -C tools -count=1 ./...: green (29 packages), includingreferee/apijsonprovenance and figures gates;make docs-countscurrent.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.internal/semantic/symbols/action_node_kind_test.go(every node kind, succession flow, both subject shapes),internal/semantic/semantics/reflective_action_nodes_test.goand theimplicit_metaclass_test.goadditions (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(inheritedresult/verdictlisted with provenance, declaredreturn r/verdictmasks without duplicates),tests/exportnamed-node and succession-flow API JSON/Turtle round trips, and gRPC conformance fixturessymbol_action_node_kinds,symbol_succession_flow_kind,symbol_subject_parameter,symbol_verdict_member.sysml-grpc(Symbolkind, query@type, reflective metaclass,metadata, members with provenance) report the metaclasses of the issues' tables;sendstaysactionUsageuntil fix(semantics): a send action is a SendActionUsage with its payload, sender and receiver on every surface #1992 lands.Checklist
make testandmake lintpass locally (go build,go vet,gofmt -l,go test -count=1 -timeout 45m ./..., tools module)changes/unreleased/action-node-kinds.fixed.mdandchanges/unreleased/subject-reference-usage.fixed.mdmake docs-countsrun (structure differential, api-json differential, golden conversions, corpus round-trip unchanged)🟢 Devin Review found nothing to fix · View findings · Follow Devin's work