Skip to content

feat(edit): author state transitions, sub-states and behavior parameters - #616

Merged
HuiJun merged 8 commits into
developfrom
feature/editor-remaining-issues
Sep 26, 2026
Merged

HuiJun merged 8 commits into
developfrom
feature/editor-remaining-issues

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Covers the authoring gaps still open after #609 and #611.

  • Transitions with triggers, guards and effects (Editor API: add support for StateUsage / TransitionUsage authoring #602). A new AddTransitionEdit add_transition = 9 operation, gated by the new transition_authoring capability (appended to the capability list), writes
    transition [name] first <source> [accept <trigger>] [if <guard>] [do <effect>] then <target>;
    or, with initial, the entry transition entry; then <target>;. It is a separate operation rather than new fields on AddConnectionEdit because an older service would silently drop the extra fields. Trigger, guard and effect are free text, so the written transition is parsed on its own first. It must be exactly one TransitionMember whose name, source, target, trigger, guard and effect source text match the request exactly. Anything else (e.g. X; part p, X then idle, a stray }) is refused with InvalidValue. The edit is refused for owners that are not state bodies, for KerML sources, and for a second entry action.
  • Transition clause rules in the parser. The pinned TransitionUsage/TargetTransitionUsage productions admit at most one accept, if and do clause, in that order. parseTransitionTail reports a repeated clause (a transition has at most one 'if' clause) and an out-of-order one at its keyword. Before this, a second if silently replaced the first guard.
  • Sub-states (Editor API: add support for StateUsage / TransitionUsage authoring #602). A bodiless state x; inside a state body parses as SubstateMember, and it could not be used as an add or move owner (OwnerNotNamespaceError). It is now accepted as an owner with the state-usage body context, and the edit opens its body when needed.
  • Clients. Python adds add_transition(owner, source, target, name=None, trigger=None, guard=None, effect=None) and add_entry_transition(owner, target). Go adds AddTransition and AddEntryTransition, and Java adds Edit.AddTransition. All three check for transition_authoring before sending.
  • Calculation and action helpers (Editor API: add_calc_def should support inputs and return expression #604, Editor API: add_action / add_action_def should support parameters, sequencing, nested actions #605). Python add_calc_def and add_calc accept inputs=[(name, type)], return_type and return_expression (an expression requires a return type). add_action_def and add_action accept inputs and outputs. Each expands into the existing add_member / add_parameter / add_return operations in the same batch. The result is in ref x : T; and return : T = expr;; they never write return <expr>;.
  • RDF conversion drops top-level redefinition values (attribute :>> x = v), while nested anonymous redefinitions keep them #88. Not reproducible on develop: a top-level attribute :>> tempo = Tempo::operative; already exports sysml:redefines and sysml:value in Turtle. This PR adds a regression test for it.

Closes #602. Closes #604. Closes #605. Closes #88.

Specification basis

Pinned pilot grammar (SysML.xtext):

  • TransitionUsage: TransitionUsageKeyword (UsageDeclaration? 'first')? TransitionSourceMember … (TriggerActionMember)? (GuardExpressionMember)? (EffectBehaviorMember)? 'then' TransitionSuccessionMember, with TriggerFeatureKind: 'accept'.
  • EntryActionMember with an empty action, followed by EntryTransitionMember, gives entry; then <target>;.
  • StateBodyPart admits nested state usages and transitions.
  • ReturnParameterMember is 'return' UsageElement. There is no return <expression> form.

Always writing first <source> avoids the unnamed form, in which a leading identifier would be read as the source. No spec-compliance row moves.

How it was verified

  • Go edit-layer tests: each clause alone and all together, entry transitions, injection refusals, entry refusals (name, source or trigger given, or a second entry), non-state owner, KerML, unknown target, name taken, adding and moving into a bodiless sub-state. Parser tests for the sub-state body context. gRPC capability tests.
  • Python: live round trips against a real sysml-grpc for the toaster state machine (nested sub-state, entry transition, two accept transitions), the Editor API: add_calc_def should support inputs and return expression #604 DeliveredEnergy calculation and the Editor API: add_action / add_action_def should support parameters, sequencing, nested actions #605 BreadHandling action. Each reloads with no diagnostics (127 passed, 0 skipped).
  • Java Maven tests. Go/Node/Java conformance runs include a new add_transition scenario.
  • make build-grpc, make lint docs-check proto-lint proto-breaking, python3 scripts/changelog.py check, and the OMG training and pilot corpus gates.

Checklist

  • make test and make lint pass locally (lint and targeted suites run locally; full suite in CI)
  • 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)

Link to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/ee3f85506c5d4cb88bc8da2e0de696c0
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/ee3f85506c5d4cb88bc8da2e0de696c0?variant=devin
Requested by: @HuiJun

devin-ai-integration Bot and others added 2 commits September 26, 2026 12:52
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…sition

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

Copy link
Copy Markdown
Contributor Author

End-to-end test of 5d0dfd3: the worktree Python client against a freshly built sysml-grpc. All cases passed, and every edited model reloaded with no diagnostics.

  • Toaster state machine: one batch adds the nested sub-state, the entry transition and two triggered transitions (one with a guard and an effect). A separate follow-up edit adds a state inside a now-bodied sub-state.
  • Calculation: typed calculation inputs, and the result is written as a bound return : T = expr; parameter, never return <expr>;.
  • Action: a parameterized action def, parameterized nested actions and a succession.
  • Refusals (8 cases): trigger/guard injection (InvalidValue), a second entry transition and a non-state owner (IllegalKind), an unknown target (analysis refusal), and malformed inputs (client TypeError). In each case the original model's hash, text and query results were unchanged.
  • Regression: anonymous :>> redefinition, require constraint, asserted satisfy and default = all still work.
entry; then idle;
transition idle_to_toasting first idle accept CycleStart then toasting;
transition toasting_to_idle first toasting accept CycleEnd if true do action cool then idle;

in ref power : ISQ::PowerValue;
in ref duration : ISQ::TimeValue;
in ref efficiency : ScalarValues::Real;
return : ISQ::EnergyValue = power * duration * efficiency;

succession first load_bread then eject_toast;

devin-ai-integration Bot and others added 2 commits September 26, 2026 13:44
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
devin-ai-integration Bot added a commit that referenced this pull request Sep 26, 2026
Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration devin-ai-integration Bot mentioned this pull request Sep 26, 2026
6 tasks
@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review September 26, 2026 15:08
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration Bot and others added 3 commits September 26, 2026 15:20
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@HuiJun
HuiJun merged commit 8f4d225 into develop Sep 26, 2026
18 checks passed
@HuiJun
HuiJun deleted the feature/editor-remaining-issues branch September 26, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment