Repository navigation
fix(semantics): state-body then after a state is a TransitionUsage owning its succession - #2133
Conversation
… fix/state-then-transition-usage
…ning its succession
A state body's `then x;` after a state is a TargetTransitionUsage (SysML v2.1
§8.2.2.18.1, §8.2.2.18.3): a TransitionUsage the state owns, which owns the
SuccessionAsUsage to its target through an OwningMembership. Symbols, the
semantic model, the RDF/API JSON writers and the notation reader now agree;
every transition owns its succession the same way and answers `succession`.
`then done { … }` is admitted a body (§8.2.2.17.8). Compliance rows added
with the pinned edition's clauses; baselines re-recorded after adjudication.
Co-Authored-By: jason.han <hanhuijun@gmail.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
…icity back targetTransitionText now prefixes the target with the bounds the owned succession's target end states, so `then [2] busy;` survives the round trip. Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…nsition-usage Co-Authored-By: jason.han <hanhuijun@gmail.com> # Conflicts: # docs/project/api-json-differential.md # internal/syntax/ast/succession.go
…nsition-usage Co-Authored-By: jason.han <hanhuijun@gmail.com> # Conflicts: # docs/project/api-json-differential/index.json # tests/export/testdata/convert/then_after_members.golden.ttl.sha256
…nsition-usage Co-Authored-By: jason.han <hanhuijun@gmail.com> # Conflicts: # docs/project/api-json-differential/index.json # docs/project/api-json-differential/pilot-validation/06-Individual and Snapshots/6-Individual and Snapshots.sysml.json # docs/project/api-json-differential/pilot-validation/10-Analysis and Trades/10c-Fuel Economy Analysis.sysml.json # internal/semantic/metamodel/derived_census_baseline.json # internal/semantic/metamodel/derived_census_records.tsv # internal/translate/export/testdata/structure_differential_expected.txt # tests/export/testdata/convert/then_after_members.golden.ttl.sha256
…nsition-usage Co-Authored-By: jason.han <hanhuijun@gmail.com> # Conflicts: # internal/semantic/metamodel/derived_census_records.tsv # internal/translate/export/testdata/structure_differential_expected.txt
…nsition-usage Co-Authored-By: jason.han <hanhuijun@gmail.com>
…nsition-usage Co-Authored-By: jason.han <hanhuijun@gmail.com>
…nsition-usage Co-Authored-By: jason.han <hanhuijun@gmail.com> # Conflicts: # docs/project/api-json-differential/index.json # docs/project/api-json-differential/pilot-examples/Simple Tests/AssignmentTest.sysml.json # docs/project/api-json-differential/pilot-validation/06-Individual and Snapshots/6-Individual and Snapshots.sysml.json # docs/project/api-json-differential/pilot-validation/10-Analysis and Trades/10c-Fuel Economy Analysis.sysml.json # internal/semantic/metamodel/derived_census_baseline.json # internal/semantic/metamodel/derived_census_records.tsv # internal/translate/export/testdata/structure_differential_expected.txt
A state body's `then x;` after a state is a TransitionUsage owning its SuccessionAsUsage, not a connector, so SuccessionEndMembers returns no ends for a symbol that declares a transition; the export ID mirror skips the same edges. Re-recorded the derived census and structure differential by tooling; the compliance rows describe which successions own ends. Co-Authored-By: jason.han <hanhuijun@gmail.com>
…nsition-usage Co-Authored-By: jason.han <hanhuijun@gmail.com> # Conflicts: # docs/project/api-json-differential/index.json # internal/translate/export/testdata/structure_differential_expected.txt
|
Devin Review on 1dbc04b reports two findings; both are on code this PR does not change (the files only entered this branch through the
|
What and why
Merge order
Merge after #2121 (
fix/then-succession-member). This branch was cut fromdevelopwith #2121 merged in and builds on it; once #2121 lands,developis merged back here so the diff shows only this change.What this fixes
Follow-up to the audit of #2121 against the pinned specification (SysML v2.1 Beta 2, KerML 1.1 Beta 2) and the pinned pilot (
scripts/pilot-pin.sh: tag2026-09, artifact 0.63.0). Each finding was re-verified against the spec text, the pinnedSysML.xtextand the pilot'sexport-jsonbefore changing anything.1. State-body
then x;after a state is aTransitionUsage(fixed)SysML §8.2.2.18.1
StateBodyItem(BehaviorUsageMember (TargetTransitionUsageMember)*), §8.2.2.18.3TargetTransitionUsage : TransitionUsage, §7.18.3.state idle; then running;is aTransitionUsagethe state owns through aFeatureMembership, which owns theSuccessionAsUsageto its target through anOwningMembership(TransitionSuccessionMember). #2121 reflected and wrote it as aSuccessionAsUsageof the state.ast.IsStateTargetTransitionnames the form (after a state; not afterentry/do/exit, not member-attached);SuccessionAdmitsBodyuses it.buildDeclbuilds such an edge as an anonymous action-usage symbol whoseDeclaresTransition()is true; records carryNodeTransition(Symbol.NodeKind).metaclassisTransitionUsage, the implicit baseActions::transitionActions; every transition (this form andtransition …/accept …) owns its succession as a synthesized part (ExpressionTransitionSuccession) reflected asOwningMembership → SuccessionAsUsage, answered assuccession, withrelatedFeature= source state, target state. The query leg reads these throughOwnedRelationships.TransitionUsage(sysx:transitionSyntax "target") owning its succession with two ends,sysml:sourcethe preceding state andsysml:target; the notation reader writesthen x;/then x { … }back (the body is the transition'sActionBody).entry; then idle;(EntryTransitionMember) andthen state off;/then part p2;(SourceSuccessionMember) staySuccessionAsUsage(§8.2.2.9.3, §8.3.13.6; KerML §8.3.4.5.4).Pilot evidence (
export-json,state def Mach { entry; then idle; state idle; then running; … then state off; }):FeatureMembership → SuccessionAsUsage(entry),FeatureMembership → StateUsage(idle),FeatureMembership → TransitionUsage { Membership ⇒ idle, OwningMembership → SuccessionAsUsage(relatedFeature idle, running), FeatureMembership → transitionLink },FeatureMembership → SuccessionAsUsage(then state off); a namedtransition t first off accept Sig then idle;owns its succession the same way.Tests:
semantics/state_then_transition_test.go(metaclass, memberships,relatedFeature,succession, nested state body),parser/succession_body_admitted_test.goTestIsStateTargetTransition,tests/export/behavior_test.goTestStateMembersRoundTrip(then idle;,then idle { … },entry; then idle;,then state busy;),reflective_transition_kinds_test.gonow also expects the transition's succession membership.2. Connector ends and
relatedFeature(approximate; known limitation)Since #2173 a⚠️ in both compliance areas.
then x;whose source is the member before it owns its two ends (TargetSuccession'sSourceEndMember/ConnectorEndMember, §8.2.2.17.8) asReferenceUsages underEndFeatureMemberships, the way the pilot exports them (semantics/succession_ends.goSuccessionEndMembers). This branch keeps the boundary that model implies: a state body'sthen x;after a state is aTransitionUsage, not a connector, soSuccessionEndMembersreturns none for a symbol whoseDeclaresTransition()holds (and the export ID mirror,recordSuccessionEnds, skips the same edges); theSuccessionAsUsagethe transition owns is written with both ends by the RDF writer (transitionSuccession) but owns none on the symbol side, like every transition's succession (#2068 stays open).relatedFeaturestays derived from the members thethenis written between (KerML §8.3.4.5.3 derives it from the ends): since #2143entry; then idle;answers (the anonymous entry action,idle), whilethen assign …;remains unanswered because the statement has no element on the symbol side (pre-existing, outside #2121). Recorded as3.
SuccessionAdmitsBodyandthen done { … }(fixed)then done { … }derives fromTargetSuccession UsageBody(§8.2.2.17.8) and now admits its body; the comment/test that attributed a body after a state in a state body toActionTargetSuccessionnow says it is theActionBodyofTargetTransitionUsage.4. Compliance map (fixed)
Rows added in⚠️ for the ends) and ⚠️ ), with the pinned edition's clauses: SysML §8.2.2.17.1/.8, §8.2.2.9.3, §8.2.2.18.1/.3, §8.3.13.6; KerML §8.3.4.5.3/.4. Changelog fragment
13-action.md(owned body-lessSuccessionAsUsage,15-state-machine.md(state-bodythenmetaclass ✅; successions' owned endschanges/unreleased/state-then-transition-usage.fixed.md.Known limitations
SuccessionAsUsagea transition owns (a state body'sthen x;after a state,transition …,accept …) owns no end features on the symbol side, and athensuccession that reaches its source by position owns none;relatedFeatureis unanswered where an end is a statement (then assign …;) — Successions lose their related features unless named; transition successions, action-node ends and body-declared connection ends have none #2068.first x then y;in an action body has noSuccessionAsUsagesymbol;if x then a;/else b;after adecidehave no membership on the symbol side (pre-existing, noted by the audit; the bareentry;case is closed by fix(symbols,semantics,export): a bareentry;,do;orexit;performs the anonymous empty ActionUsage its StateSubactionMembership owns — the symbol structure, the semantic model, the query leg and the RDF writer state it, both readers take it back, as the pilot exports it #2143).then done;although its production admits a body: it has no insertion point for one (thedoneis declared between the keyword and the;), stated as such ininlineAnnotationAdmitted.then x;after a non-behavior member in a state body (entry; attribute a; then idle;), which the pinned grammar does not admit and the pilot fails to parse, is classified as aTargetTransitionUsage, following the parser's existing leniency.Baselines moved
internal/translate/export/testdata/structure_differential_expected.txt(pilot-corpora root): six state-bodythensuccessions becomeTransitionUsages; their synthesized successions are now mapped by the differential (TransitionUsage::succession), and since the symbol side mints no ends for them (above) theirownedRelationship/ownedMember/ownedEndFeature/nestedReferencerows agree with the graph (+6 equal, −6 different each).docs/project/api-json-differential/index.jsonand three pilot fragments (AssignmentTest,6-Individual and Snapshots,10c-Fuel Economy Analysis): see below.tests/export/testdata/convert/then_after_members.golden.ttl.sha256:state def Switch { entry; attribute pressed; then idle; … }is written as aTransitionUsage.internal/semantic/metamodel/derived_census_baseline.json/derived_census_records.tsv(derived-census -update): element and implied counts rise in every root because each transition now owns its succession and that succession's implied base; no rule verdict moves.Specification basis
SysML v2.1 Beta 2: §8.2.2.18.1
StateBodyItem/TargetTransitionUsageMember, §8.2.2.18.3TargetTransitionUsage : TransitionUsage, §7.18.3; §8.2.2.17.1ActionBodyItem, §8.2.2.17.8ActionTargetSuccession/TargetSuccession UsageBody; §8.2.2.9.3SourceSuccessionMember; §8.3.13.6SuccessionAsUsage. KerML 1.1 Beta 2: §8.3.4.5.3Connector(relatedFeaturefromconnectorEnd), §8.3.4.5.4Succession. Rows added indocs/project/spec-compliance/02-detailed-semantic-compliance-map/13-action.mdand15-state-machine.md(sources; the combined page is not committed).How it was verified
gofmt -l .(empty),go build ./...,go vet ./...,make lint(staticcheck + gosec) clean.go test ./...green (the runtime, smt, codegen, cmd/sysml and tests/export packages re-run with-timeout 45mafter hitting the 10m default under load);go test -count=1 ./tests/hygienegreen.TestSymbolStructureMatchesGraphStructurere-recorded with-update-structure-differentialafter adjudication (above).go run -C tools ./cmd/pilot-apijson-diff -checkmoved three pilot files (AssignmentTest,6-Individual and Snapshots,10c-Fuel Economy Analysis): theStateDefinition.ownedConnection/ExhibitStateUsage.nestedConnectionrows leave present-different for indeterminate, as the state no longer owns thethensuccession as a connection and the transition's synthesized elements are unkeyable; re-recorded with-update;go test -C tools ./referee/apijsongreen.python3 scripts/spec_compliance.py check,python3 scripts/changelog.py check,python3 scripts/check-doc-ids.pyclean.Checklist
make testandmake lintpass locallychanges/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (compliance rows need nothing: the census is counted at docs build)F4,K5) in the body, docs, or changelogLink to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/646cfbd400b24080a168f29eb053ccd9
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/646cfbd400b24080a168f29eb053ccd9?variant=devin
Requested by: @HuiJun
🟢 Devin Review found nothing to fix · View findings · Follow Devin's work