Skip to content

fix(semantics): state-body then after a state is a TransitionUsage owning its succession - #2133

Merged
HuiJun merged 15 commits into
developfrom
fix/state-then-transition-usage
Nov 13, 2026
Merged

HuiJun merged 15 commits into
developfrom
fix/state-then-transition-usage

Conversation

@devin-ai-integration

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

Copy link
Copy Markdown
Contributor

What and why

Merge order

Merge after #2121 (fix/then-succession-member). This branch was cut from develop with #2121 merged in and builds on it; once #2121 lands, develop is 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: tag 2026-09, artifact 0.63.0). Each finding was re-verified against the spec text, the pinned SysML.xtext and the pilot's export-json before changing anything.

1. State-body then x; after a state is a TransitionUsage (fixed)

SysML §8.2.2.18.1 StateBodyItem (BehaviorUsageMember (TargetTransitionUsageMember)*), §8.2.2.18.3 TargetTransitionUsage : TransitionUsage, §7.18.3. state idle; then running; is a TransitionUsage the state owns through a FeatureMembership, which owns the SuccessionAsUsage to its target through an OwningMembership (TransitionSuccessionMember). #2121 reflected and wrote it as a SuccessionAsUsage of the state.

  • ast.IsStateTargetTransition names the form (after a state; not after entry/do/exit, not member-attached); SuccessionAdmitsBody uses it.
  • Symbols: buildDecl builds such an edge as an anonymous action-usage symbol whose DeclaresTransition() is true; records carry NodeTransition (Symbol.NodeKind).
  • Semantic model: metaclass is TransitionUsage, the implicit base Actions::transitionActions; every transition (this form and transition …/accept …) owns its succession as a synthesized part (ExpressionTransitionSuccession) reflected as OwningMembership → SuccessionAsUsage, answered as succession, with relatedFeature = source state, target state. The query leg reads these through OwnedRelationships.
  • Writers: the RDF/API JSON writer emits a TransitionUsage (sysx:transitionSyntax "target") owning its succession with two ends, sysml:source the preceding state and sysml:target; the notation reader writes then x; / then x { … } back (the body is the transition's ActionBody).
  • entry; then idle; (EntryTransitionMember) and then state off; / then part p2; (SourceSuccessionMember) stay SuccessionAsUsage (§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 named transition 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.go TestIsStateTargetTransition, tests/export/behavior_test.go TestStateMembersRoundTrip (then idle;, then idle { … }, entry; then idle;, then state busy;), reflective_transition_kinds_test.go now also expects the transition's succession membership.

2. Connector ends and relatedFeature (approximate; known limitation)

Since #2173 a then x; whose source is the member before it owns its two ends (TargetSuccession's SourceEndMember/ConnectorEndMember, §8.2.2.17.8) as ReferenceUsages under EndFeatureMemberships, the way the pilot exports them (semantics/succession_ends.go SuccessionEndMembers). This branch keeps the boundary that model implies: a state body's then x; after a state is a TransitionUsage, not a connector, so SuccessionEndMembers returns none for a symbol whose DeclaresTransition() holds (and the export ID mirror, recordSuccessionEnds, skips the same edges); the SuccessionAsUsage the 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). relatedFeature stays derived from the members the then is written between (KerML §8.3.4.5.3 derives it from the ends): since #2143 entry; then idle; answers (the anonymous entry action, idle), while then assign …; remains unanswered because the statement has no element on the symbol side (pre-existing, outside #2121). Recorded as ⚠️ in both compliance areas.

3. SuccessionAdmitsBody and then done { … } (fixed)

then done { … } derives from TargetSuccession 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 to ActionTargetSuccession now says it is the ActionBody of TargetTransitionUsage.

4. Compliance map (fixed)

Rows added in 13-action.md (owned body-less SuccessionAsUsage, ⚠️ for the ends) and 15-state-machine.md (state-body then metaclass ✅; successions' owned ends ⚠️), 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 changes/unreleased/state-then-transition-usage.fixed.md.

Known limitations

Baselines moved

  • internal/translate/export/testdata/structure_differential_expected.txt (pilot-corpora root): six state-body then successions become TransitionUsages; their synthesized successions are now mapped by the differential (TransitionUsage::succession), and since the symbol side mints no ends for them (above) their ownedRelationship/ownedMember/ownedEndFeature/nestedReference rows agree with the graph (+6 equal, −6 different each).
  • docs/project/api-json-differential/index.json and 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 a TransitionUsage.
  • 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.3 TargetTransitionUsage : TransitionUsage, §7.18.3; §8.2.2.17.1 ActionBodyItem, §8.2.2.17.8 ActionTargetSuccession / TargetSuccession UsageBody; §8.2.2.9.3 SourceSuccessionMember; §8.3.13.6 SuccessionAsUsage. KerML 1.1 Beta 2: §8.3.4.5.3 Connector (relatedFeature from connectorEnd), §8.3.4.5.4 Succession. Rows added in docs/project/spec-compliance/02-detailed-semantic-compliance-map/13-action.md and 15-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 45m after hitting the 10m default under load); go test -count=1 ./tests/hygiene green.
  • TestSymbolStructureMatchesGraphStructure re-recorded with -update-structure-differential after adjudication (above).
  • go run -C tools ./cmd/pilot-apijson-diff -check moved three pilot files (AssignmentTest, 6-Individual and Snapshots, 10c-Fuel Economy Analysis): the StateDefinition.ownedConnection / ExhibitStateUsage.nestedConnection rows leave present-different for indeterminate, as the state no longer owns the then succession as a connection and the transition's synthesized elements are unkeyable; re-recorded with -update; go test -C tools ./referee/apijson green.
  • python3 scripts/spec_compliance.py check, python3 scripts/changelog.py check, python3 scripts/check-doc-ids.py clean.

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/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

Devin Review

devin-ai-integration Bot and others added 2 commits November 11, 2026 06:49
…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>
@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

@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review November 11, 2026 09:11
devin-ai-integration Bot and others added 2 commits November 11, 2026 09:21
…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>

@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

…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
@HuiJun
HuiJun enabled auto-merge November 12, 2026 00:27
@HuiJun
HuiJun disabled auto-merge November 12, 2026 00:56
devin-ai-integration Bot and others added 8 commits November 12, 2026 03:44
…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-ai-integration

Copy link
Copy Markdown
Contributor Author

Devin Review on 1dbc04b reports two findings; both are on code this PR does not change (the files only entered this branch through the --no-ff merges of develop), so neither is fixed here:

  1. [security] internal/frontend/guard/oidc/introspect.go:87-89 — revoked tokens keep their cached principal until expiry. git diff --merge-base origin/develop -- internal/frontend/guard/oidc/introspect.go is empty. The introspection cache is the MCP-OIDC work on develop; a semantics PR is the wrong place to change its revocation policy.

  2. [bug] internal/semantic/symbols/builder.go:690-694 — a bare entry; action receives no Actions::actions base. buildStateSubaction and the anonymous entry;/do;/exit; action come from fix(symbols,semantics,export): a bare entry;, do; or exit; 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 (9b8e736) on develop; this PR's only hunk in builder.go is in buildBehaviorDecl (the state-body then x; transition), and its only hunk in implicit.go adds the TransitionUsage base (kindBaseFQN, *ast.SuccessionEdge whose DeclaresTransition() holds) without touching the subaction path. The missing base is a real gap, but a fix(symbols,semantics,export): a bare entry;, do; or exit; 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 follow-up: adding it moves the derived census and the api-json baselines again and belongs in its own PR.

@HuiJun
HuiJun added this pull request to the merge queue Nov 13, 2026
Merged via the queue into develop with commit a1f54e7 Nov 13, 2026
30 checks passed
@HuiJun
HuiJun deleted the fix/state-then-transition-usage branch November 13, 2026 08:40
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