Skip to content

SWF(bug): fix OwningMembership for a trigger's named payload - #2425

Merged
HuiJun merged 7 commits into
developfrom
fix/accept-payload-owning-membership
Nov 20, 2026
Merged

HuiJun merged 7 commits into
developfrom
fix/accept-payload-owning-membership

Conversation

@HuiJun

@HuiJun HuiJun commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

OwningMembership(x) for the payload a transition's trigger names (accept x : Sig) now returns a membership that owns x, not a second, synthesized payload.

Reported by Devin Review on internal/semantic/semantics/reflective_memberships.go (landed with #2411). The model held two symbols for one element:

declared x synthesized payload
kind itemUsage, named x referenceUsage, unnamed
owner the transition the trigger's accept
Expr none ExpressionPayload

OwningMembership(x) special-cased x by recursing into OwningMembership(parts.payload), so it answered the synthesized payload's ParameterMembership: non-nil, the right elementId, but its member was not x. The existing test only asserted non-nil.

That special case was a symptom patch over the duplication, so the fix removes the duplication instead:

  • transitionPartsOf uses the symbol the transition's scope declares as the accept's payload; it synthesizes one only for an unnamed payload (accept Sig).
  • The named payload reflects as what the grammar makes it: a ReferenceUsage owned by the accept through a ParameterMembership, and no longer a member the transition owns.
  • OwningMembership loses its special case; isTriggerPayload compares symbols, not declarations.
  • The payload keeps its default [1..1] Multiplicity, which it used to get from reading as an ItemUsage.
  • The payload takes no usage kind's base: it is declared as an item usage, and would otherwise read Items::Item as a second type beside the one it declares (accept x : ScalarValues::Integer). TestNamedTriggerPayloadTakesNoUsageBase covers it.
  • ResolveElement still resolves the @id the tree writes for the payload (<transition>__@trigger__x) to the declared symbol, which is filed under the accept while its name sits in the transition.

Specification basis

SysML.xtext TriggerAction / PayloadParameterMember / PayloadParameter: the payload parameter is one ReferenceUsage owned by the trigger's AcceptActionUsage through a ParameterMembership, named or not. No compliance row moves.

How it was verified

Failing test first. TestTransitionTriggerPayloadTypingReadsOnce now asserts the membership's member is x, that x is the accept's payloadParameter, that the transition does not own it, and that it is a ReferenceUsage.

On the base, with only the test change:

--- FAIL: TestTransitionTriggerPayloadTypingReadsOnce (0.75s)
    transition_trigger_typing_ids_test.go:70: named trigger payload's owning membership owns referenceUsage "", not the payload

On this branch:

--- PASS: TestTransitionTriggerPayloadTypingReadsOnce (0.11s)

Try it: go test -count=1 ./internal/doc/queryexec -run TestTransitionTriggerPayloadTypingReadsOnce -v

No regression in what the conversion writes: TestGoldenConversions passes unchanged, so the Turtle for every fixture, the payload's Multiplicity included, is byte-identical. TestElementIdentityIsTheTreesIDAndRoundTrips covers the @id round trip.

Gate on this head, with the training, pilot and specification-example corpora present and required: gofmt -l . empty, go build ./... and go vet ./... clean, go test -timeout 45m ./... 140 packages ok and 0 failed, go test -C tools ./... 35 packages ok and 0 failed, make lint passed, and derived-census -check -recorded-pilot and doc-counts -check reproduce.

Not run locally: the -race suite (make test), and the Java-backed checks (Xpect oracle, cross-MDK suite, derived-property differential). CI ran those three on the first head of this PR and they passed; the commits since only narrow the payload's types back to what the base wrote.

Baselines moved: structure differential and derived census

derived_census_records.tsv, re-recorded with go run -C tools ./cmd/derived-census -update -recorded-pilot (our columns only; the pilot's stay as recorded). 20 records move, all the same way: five rules (Element::name, Membership::memberElementId, Membership::memberName, OwningMembership::ownedMemberElementId, OwningMembership::ownedMemberName) on four roots each gain values with carriers unchanged, for example Element::name on pilot-examples 5355 → 5368 with a value. None loses one.

structure_differential_expected.txt, re-recorded with -update-structure-differential on this tree. 15 cells move, matched/unmatched is unchanged on every root. 14 improve, because the symbol side now answers the payload's name and memberships as the graph does (for example pilot-corpora Element::name different 18 → 5).

One cell worsens: pilot-corpora OwningMembership::ownedMemberElementId, different 31 → 32 (equal 7236 → 7248, symbol-missing 14171 → 14158). 13 memberships that had no symbol-side answer now have one; 12 agree and 1 differs.

The one that differs is in sysml-examples/Simple Tests/StateTest.sysml, where two unnamed transitions each declare accept s : Sig. SymbolStructure.ElementIdentity gives members of two unnamed sibling transitions the same id, so the first payload's membership reads the second payload's id. This collision predates this change: the same file already reports it on the base for the two do action D members (StateTest__S___404__D_om: graph #StateTest__S___404__D, symbol #StateTest__S___407__D). The payload joins it only because it is now a declared symbol. The query leg (ElementIDOf) gives the two payloads distinct, correct ids. Fixing the collision is a separate change and is not in this PR.

Base

This branch contains #2002's head 9d19bbe589 (which contains #2414), merged once, because the baseline is re-recorded on top of theirs. The diff of this PR alone is git diff 9d19bbe589...HEAD.

Checklist

  • make lint, go test ./... and go test -C tools ./... pass locally; make test (-race) was not run locally
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (none covers it)
  • Changelog entry added as changes/unreleased/accept-named-payload-one-element.fixed.md
  • baselines regenerated with their recorders; doc-counts -check is current
  • No internal work-item labels in the body, docs, or changelog

Software Factory opened this PR for Jason
Implemented in session Fix OwningMembership for an accept payload
Review with Devin · Open in Devin Desktop


devin-ai-integration Bot and others added 4 commits November 20, 2026 05:50
The payload a trigger names (`accept x : Sig`) was two symbols: the one the
transition's scope declares and a ReferenceUsage synthesized for the accept.
OwningMembership(x) answered the synthesized one's membership, whose member
is not x, and x read as an ItemUsage the transition owned.

The accept's payload parameter is now the declared symbol: a ReferenceUsage
the accept owns through its ParameterMembership.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
The payload reads as a ReferenceUsage, which takes no implicit [1..1] by
metaclass, so the conversion stopped writing the Multiplicity it owns.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ger payload

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

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 Bot and others added 2 commits November 20, 2026 07:20
The payload is declared as an item usage, so it took Items::Item as a type
beside the one it declares (`accept x : ScalarValues::Integer`).

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ayload

Co-Authored-By: jason.han <hanhuijun@gmail.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 findings. Devin automatically fixed all 3 findings.

Fixed by Devin (3)
  • Spurious item type on data payloads — Reproduced: accept x : ScalarValues::Integer read Items::Item as a second type. withUsageBases now skips a named trigger payload; TestNamedTriggerPayloadTakesNoUsageBase covers it.
  • Three-line identity helper comment — Comment cut to two lines.
  • Three-line payload predicate comment — Comment cut to two lines.

View findings in Devin Review · Follow Devin's work

Devin Review

devin-ai-integration Bot added a commit that referenced this pull request Nov 20, 2026
sysmlMetaclassName keeps #2425's trigger-payload ReferenceUsage rule ahead
of the declaration switch, which this branch reads through
UsageFormMetaclassName.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
devin-ai-integration Bot added a commit that referenced this pull request Nov 20, 2026
One pilot-corpora cell moves on the combined tree (OwningMembership::
ownedMemberElementId, one more differing pair) where #2425's trigger
payload ownership meets this branch's synthesized memberships.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@HuiJun
HuiJun added this pull request to the merge queue Nov 20, 2026
Merged via the queue into develop with commit 8a7f51e Nov 20, 2026
32 checks passed
@HuiJun
HuiJun deleted the fix/accept-payload-owning-membership branch November 20, 2026 11:54
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