Skip to content

Draw a StateRefinement without from as an entry transition - #15

Merged
CatarinaGamboa merged 1 commit into
mainfrom
feat/14-entry-transitions
Oct 27, 2026
Merged

CatarinaGamboa merged 1 commit into
mainfrom
feat/14-entry-transitions

Conversation

@CatarinaGamboa

Copy link
Copy Markdown
Contributor

Closes #14

What changes

The verifier tries a method's @StateRefinements in declaration order and uses the first one whose from matches (AuxStateHandler.changeState). A @StateRefinement without from has from = true, so:

  • Edges — it now only goes from the states that the earlier from= alternatives of the same method do not cover. A state counts as covered when an earlier from names it without a condition.
  • Entry transitions — when it sits beside from= alternatives, it also becomes a StateMachineEntryTransition(to, label, toCondition) in the new StateMachine.entryTransitions list: how an object whose state is unknown (a field, a parameter, a getter result) enters the protocol. Clients can draw it as [*] --> to: label.
  • A from-less @StateRefinement with no alternatives keeps its edges from every state and gets no entry transition (it really applies in every known state, see ToOnlyTransition).

For the UndoManager canUndo() in the issue, the four canUndo [return] → endDone edges are gone; instead there is one entry transition [*] → endDone: canUndo [return], plus the self-loops from the from= alternatives.

Compatibility

StateMachine gets a new component entryTransitions. The existing 4- and 5-argument constructors are kept and default it to an empty list. The MCP's get_state_machine and the VS Code extension will need a follow-up to render the new list.

Tests

  • EntryTransition.java fixture: the canUndo spec from the issue, plus a reset() whose from-less alternative still goes from the uncovered states.
  • testToOnlyTransitionHasNoEntryTransition: a from-less refinement alone adds no entry transition.
  • mvn test: 27 tests, 0 failures.

🤖 Generated with Claude Code

The verifier uses the first StateRefinement of a method whose from
matches, so one without from only goes from the states that the earlier
ones do not cover. Beside StateRefinements with from it is also how an
object in an unknown state enters the protocol, now in entryTransitions.

Closes #14

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CatarinaGamboa
CatarinaGamboa merged commit 9047856 into main Oct 27, 2026
2 checks passed
CatarinaGamboa added a commit to liquid-java/vscode-liquidjava that referenced this pull request Oct 27, 2026
Brings
[liquidjava-fsm#15](liquid-java/liquidjava-fsm#15)
to the extension, released as liquidjava-fsm 0.2.2.

The verifier uses the first `@StateRefinement` of a method whose `from`
matches. A `@StateRefinement` without `from` beside ones with `from` is
how an object whose state is unknown (a field, a parameter or a getter's
result) enters the protocol. The parser now reports these as
`entryTransitions`, and the diagram draws them as arrows from the
initial node, labelled with the method and, when conditions are shown,
its postcondition.

- `server/pom.xml`: liquidjava-fsm 0.2.1 → 0.2.2
- `StateMachineDTO`: passes `entryTransitions` to the client
- `diagram.ts`: draws `[*] --> to : method` for each entry transition,
dimmed in focus mode like the constructor arrows
- `fsm.ts`: an entry transition postcondition enables Expand Conditions

The fsm PR's `EntryTransition` spec, with `new Edit().undo()` as the
state error. `canUndo` (`return`) → `endDone` and `reset` → `start` now
come out of the initial node:

| Show all | Focus on error | Conditions collapsed |
|---|---|---|
| <img
src="https://raw.githubusercontent.com/liquid-java/vscode-liquidjava/pr-screenshots/169/entry-all.png"
width="300"> | <img
src="https://raw.githubusercontent.com/liquid-java/vscode-liquidjava/pr-screenshots/169/entry-focus.png"
width="300"> | <img
src="https://raw.githubusercontent.com/liquid-java/vscode-liquidjava/pr-screenshots/169/entry-collapsed.png"
width="300"> |

## Tests
- client: `vitest run` 110 passed, typecheck clean
- server: `mvn test` 35 passed, against liquidjava-fsm 0.2.2 from Maven
Central
- checked in headless VS Code with the fixture above

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

Draw a @StateRefinement without from as an entry arrow, not an edge from every state

1 participant