fix(migrate): write an empty transition effect the parser accepts and gate the PSSM suite - #485
Merged
Merged
Conversation
… gate the PSSM suite
A transition whose effect writes no statements was written 'do action
effect;' before its 'then <target>', which the parser rejects; the effect
is now 'do action effect { }', a referenced effect 'do action : Def'
without ';', and the report says when an action is empty or runs
nothing. A transition's effect referring to a behavior owned elsewhere
was dropped silently and is now run.
TestPSSMSuiteMigration asserts the migrated OMG PSSM suite parses and
ratchets its report totals and validation errors; CI downloads the suite
and requires the gate.
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)".
|
…is not run A referenced entry, do, exit or effect that has no v2 declaration, or is written as something no state runs, left the state or transition mapped while only a comment was written for it; the owner is now approximated with the reason, as it already was when the behavior's context could not be bound. Co-Authored-By: jason.han <hanhuijun@gmail.com>
6 tasks
…effect-body Co-Authored-By: jason.han <hanhuijun@gmail.com> # Conflicts: # internal/translate/migrate/carriers.go # internal/translate/migrate/states.go
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
bin/sysml model.xmi -convert sysmlwrote a transition whoseeffectis an Activity with no nodes asThe parser rejects the
;(expected the target of the transition after 'then'), and one such transition made the whole migrated file unwritable — the OMG PSSM test suite (47k elements) failed at output line 12343 on a single empty effect.Root cause
writer.block(header, body)writesheader;when the body writes nothing. That is right for every standalone declaration, but a transition'sdo <action-usage>is a clause: the grammar continues withthen <target>on the next line, and;ends the transition instead. Only that one site was affected; the fix is a second helper that keeps an empty brace pair and a context flag in the behavior writer:inlineBehaviorpicksbracedwhen the owner is a Transition and the keyword isdo action, andblockfor a state'sentry/do/exitaction, which stands alone. A referenced effect likewise drops the;:do action : Defthenthen t;.Notation per shape (state action / transition effect)
entry/do/exitdoentry action x;do action x { }entry action x { /* … */ }do action x { /* … */ }(flow lines and one comment per refused node)entry action x { /* body … */ }do action x { /* body … */ }entry x : Def;(unchanged)do action : DefthenThe same shapes apply to a guard-less completion transition, which shares
writeTransitionEffect.do action x { }was chosen over dropping thedoclause: an Activity with no nodes is an empty behavior, so writing an empty action is the faithful mapping and the report can stayMappedwith a note, whereas omitting the clause would have to be reported approximated for a construct that lost nothing.A second defect surfaced by the referenced-effect fixture: a transition whose
effectis a Behavior owned elsewhere (effect="_id"rather than an owned<effect>child) was silently dropped —firstOwned(t, "effect")found nothing.behaviorIn(t, "effect"), the lookup already used for a state's entry/do/exit, now resolves both forms, instates.goand in the carrier check that decides whether a transition's effect is written inline.Audit of head + optional body
Every
w.blocksite was checked for a body that may be empty and a continuation that follows on the next line (w.blockhas 39 call sites acrossactivity.go,behavior.go,interaction.go,migrate.go,simconfig.go,states.go). The transitiondoclause was the only one: every otherblockwrites a definition, usage, package, state, region, oractioninside a body, and each of those is complete atheader;. The transition writer's ownbraced("do action", …)(theacceptkeep-alive when there is no effect) always writes a line, so it was never empty, but it usesbracedtoo so the site cannot regress if the body ever becomes optional.PSSM corpus gate
tests/corpus/pssm_migration_test.go(TestPSSMSuiteMigration) migratesbuild/pssm/PSSM_TestSuite.xmithrough the sameconvert.Migratethe CLI uses, and*convert.SyntaxErrorfails the test;tests/corpus/testdata/pssm_migration_expected.txt, regenerated with-update-pssm-migration(any movement must be adjudicated in the PR, as for the pilot corpora);OPENSYSML_REQUIRE_PSSM_SUITE=1, through the sharedcorpusGateincorpus_gate_test.go.The validation-error count (21) is recorded because it was identical across repeated runs and across cache states (a fresh
XDG_CACHE_HOMEis used). It is a ratchet, not an assertion: the 21 are unresolved-member and junction errors from unrelated refusals, described indocs/project/pssm-migration.md.CI downloads the suite with
./scripts/download-pssm-suite.sh(the pin intools/referee/pssm/pin.go, unchanged) and runs the gate withOPENSYSML_REQUIRE_PSSM_SUITE=1in both.circleci/config.ymland.github/workflows/pr.yml, mirroring the pilot corpora steps.tools/referee/pssm/is not touched.Docs
docs/reference/sysml-v1-migration.md: five new mapping rows (the three empty/refused/unsupported shapes, the referenced transition effect, and a referenced behavior that cannot be run).docs/project/pssm-migration.md(new, linked fromdocs/project/README.mdandmkdocs.yml),docs/reference/environment.md,CONTRIBUTING.md,AGENTS.md: the gate, its variable and its update flag, beside the pilot-corpora entries.changes/unreleased/migrate-empty-effect-body.fixed.md.states.gochanges are confined toinlineBehavior,writeTransitionEffectand thebehaviorIndoc comment, so they merge cleanly with the composite-state entry/exit work.Specification basis
OMG SysML v2 textual notation,
TransitionUsage:transition [first source] [accept …] [if …] [do <ActionUsage>] then <target>;— the effect action usage has no terminator of its own; the transition's;follows the target.internal/syntax/parser(the transition rule) and the golden ASTs undertests/parser/testdata/parse/fix the accepted forms:do action x { }anddo action : Defcontinue intothen,do action x;ends the transition. No row indocs/project/spec-compliance.mdmoves; this is the v1→v2 mapping, tracked indocs/reference/sysml-v1-migration.md.How it was verified
New tests:
internal/translate/migrate/writer_test.goTestWriterBracedKeepsEmptyBody:bracedkeeps{ }for an empty body and braces a non-empty one;blockstill writes;.tests/migrate/testdata/xmi/empty_behaviors.xmi(hand-written, non-TMT) with.golden.sysmland.golden.report.txt: a state machine whose states carry empty, all-refused (CreateObjectAction/DestroyObjectAction) and unsupported-language (FortranOpaqueBehavior) entry/do/exit behaviors, the same three shapes as effects of triggered and of guard-less completion transitions, a class-owned Activity referenced as the effect of one triggered and one completion transition, and a class-owned StateMachine that a state names as its entry and a transition as its effect, which no state can run: both owners are reported approximated with the reason, where the state was previously left mapped over a comment.TestGoldenConstructFixturesalready opens every migrated golden in a workspace and fails on any diagnostic error, so the golden is asserted to parse and validate clean (checked: it does for every fixture undertests/migrate/testdata/xmi/). Report: 60 elements, 37 mapped, 17 approximated, 6 unmapped (the six refused action nodes).tests/corpus/pssm_migration_test.goas above.Gates (all green on this branch):
No pilot-corpus, training-corpus or round-trip ratchet moved.
End-to-end, PSSM (
./scripts/download-pssm-suite.sh && bin/sysml build/pssm/PSSM_TestSuite.xmi -convert sysml -migration-report /tmp/pssm-report.txt -o /tmp/pssm.sysml, thenbin/sysml /tmp/pssm.sysml -validate; the binary has no-check,-validateis the validation surface):the migrated notation could not be written: …:12343:41: expected the target of the transition after 'then': 1 syntax error(s)SemanticTestlayout)migrate.Migrateondevelop)Report totals do not move: the one empty effect was already
Mapped; its note now says the action is empty. The suite has no transition with a referenced effect, no effect whose every node is refused, and no unsupported-language effect, so the approximated count is unchanged too.TMT (
bin/sysml <TMT>.mdzip -convert sysml -migration-report … -o …, then-validate), this branch againstdevelop:The three elements that move from mapped to approximated are exactly the all-refused state actions, which the report now describes as they are written: Activity
ActuatorServoStates::CALIBRATE::update(a do action, "none of its 1 action is migrated, so it runs nothing"),Indexer::indexerStates::PWR_DOWN::startTimer(an entry action, the same), andPEAS::…::'Rigid Body and Segment Figure correction'(a do action, none of its 2 actions migrated). What is written for them does not change — the notation was already the action holding the flow and a comment per refused node — only the verdict, which previously called an action that runs nothing mapped. The model has no transition with a referenced effect and no unsupported-language opaque body, so nothing else moves.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 changelog