Skip to content

feat: an automaton in the stock look for a product's own server - #284

Merged
endrix merged 2 commits into
mainfrom
feat/stock-automaton
Dec 4, 2026
Merged

endrix merged 2 commits into
mainfrom
feat/stock-automaton

Conversation

@endrix

@endrix endrix commented Dec 4, 2026

Copy link
Copy Markdown
Owner

A product whose server builds its own model (mlir-viewer) can now draw an automaton inside one of its frames, as every producer's automaton is drawn: each state its name in a pill, the initial one double-outlined, and each transition a curve or a loop labelled with what takes it.

Changes

  • stockAutomaton(states, transitions) (model/stock-automaton.ts). It returns the graph source's states and transitions under the product's ids, as stockNode does for one node.
  • placeAutomatonStates(elk, states, transitions) (server/automaton-layout.ts). This is the engine's own placement (spread until clear enough), moved out of WorkflowElkLayoutEngine so that a product's engine can place a nested automaton. The engine calls it as before, and its log line is unchanged.
  • Client. A transition is worked out from what holds it (the root, or a product's frame), in that holder's coordinates. Before, it was always worked out from the root, so an automaton inside a frame drew no transition at all. An automaton at the root draws exactly as before.
  • Label box. A transition's label box takes the pointer itself, so the label still selects it in a product whose edges take no pointer events.
  • Exports. The client exports StateNode, StateNodeView, TransitionEdge, TransitionEdgeView and WorkflowDiagramMetadata.

Why

mlir-viewer draws an open ats.fsm as boxes in layers. Its edges keep one edge between two states and none from a state to itself, so the @Cpu_cpu machine of picorv32 shows 18 of its 33 transitions. The mlir-viewer PR that follows draws it with these pieces.

Tests

  • stock-automaton.test.ts. Ids, sizes, the initial mark, every transition including loops and parallel ones, and the exported placement (states apart, inside the drawing).
  • automaton-in-frame.test.ts. A transition in a frame draws in the frame's coordinates, the same as at the root. Both tests fail on main.
  • Suites. Server: 1,196 passed, 2 skipped. Client: 1,286 passed. One client run hit timing flakes in unrelated panels (chat, surface host, panel drag), and the next run passed in full.
  • Checks. typecheck.sh and check-neutrality.sh pass.
  • Visual. Rendered headless in mlir-viewer (the picorv32 @Cpu_cpu and @MemIf machines, dark and light), and checked live: selecting a state or a transition, and the panel.

https://claude.ai/code/session_011UYzzShRuBLgefHUrAbqya

A product whose server builds its own model can now draw an automaton
inside one of its frames, as every producer's automaton is drawn:

- `stockAutomaton(states, transitions)`: the graph source's states and
  transitions, under the product's ids.
- `placeAutomatonStates(elk, states, transitions)`: the engine's own
  placement, moved out of WorkflowElkLayoutEngine so a product's engine
  can place a nested automaton; the engine calls it as before.
- The client works a transition out from what holds it (the root, or a
  frame) in that holder's coordinates; an automaton at the root is drawn
  as before.
- A transition's label box takes the pointer itself, so it selects in a
  product whose edges take none.
- The client exports StateNode, StateNodeView, TransitionEdge,
  TransitionEdgeView and WorkflowDiagramMetadata.

For mlir-viewer's open `ats.fsm`, which today draws as boxes and loses
its loops and parallel transitions.

Claude-Session: https://claude.ai/code/session_011UYzzShRuBLgefHUrAbqya
- stockAutomaton folds no run: a folded run is a node the product does
  not have (its ways in and out ended on it, the states inside were
  lost), and its toggle an operation the product's server does not
  answer. The graph source takes `openRuns`, which stockAutomaton sets to
  every run, and the open run's toggle marks are dropped. The ways into a
  hub stay stubs, as in every producer's automaton.
- A transition's link anchor is in the diagram's coordinates: the label
  is drawn in those of what holds it, so a frame's place is added.
- The bounds comment says they are in the holder's coordinates, which
  every reader takes up through the parents (`boundsInViewport`).

Claude-Session: https://claude.ai/code/session_011UYzzShRuBLgefHUrAbqya
@endrix
endrix merged commit 5c666b0 into main Dec 4, 2026
1 check passed
@endrix
endrix deleted the feat/stock-automaton branch December 4, 2026 11:03
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