Skip to content

fix(intent): lay out generated BPMN/EDM diagrams so they read cleanly#6299

Merged
iliyan-velichkov merged 1 commit into
masterfrom
fix/intent-diagram-layout
Jul 15, 2026
Merged

fix(intent): lay out generated BPMN/EDM diagrams so they read cleanly#6299
iliyan-velichkov merged 1 commit into
masterfrom
fix/intent-diagram-layout

Conversation

@iliyan-velichkov

Copy link
Copy Markdown
Contributor

Problem

The intent generators emit diagram interchangebpmndi:BPMNDiagram for .bpmn, mxGraphModel for .edm — because the Flowable/Oryx and EDM modelers render the canvas only from that block. Placement was naive, so generated files opened badly formatted and had to be reordered by hand:

  • BPMN laid every node on a single line at X = declaration-index × spacing, with only two fixed Y lanes (main 140, else-branch 300). Parallel branches didn't align, multiple/nested decisions piled onto the same lanes and overlapped, and edges were straight diagonals cutting across other shapes.
  • EDM used a blind index % 3 grid that ignored card heights (columns became wildly unequal) and the relation graph (FK-linked entities landed far apart, so connectors crisscrossed).

Change

BPMN — BpmnIntentGenerator: replace the single-line placement with a deterministic layered (Sugiyama-style) layout:

  • Column (X) = longest-path distance from the start event (rankByLongestPath, cycle-guarded, end pinned rightmost), so a gateway's then/else branches share a column and the flow reads left-to-right.
  • Lane (Y) = per-column assignment by the barycentre of each node's predecessors, spread symmetrically around a centre lane — branches fan out above/below instead of piling onto two fixed lanes.
  • Edges routed orthogonally (right-angle L/Z) across lanes, straight when aligned.
  • The obsolete secondaryBranchTargets single-drop heuristic is removed.

EDM — EdmIntentGenerator.appendMxGraphModel: place entities in a relationship-aware order (BFS over the FK graph so connected entities cluster) and pack each into the currently shortest column instead of index % 3, keeping columns balanced and related entities adjacent. Cells are still emitted in declaration order, so regeneration diffs stay stable.

Determinism & tests

Both layouts are pure functions of the model → output stays byte-stable; the modeler re-routes on first manual edit. Existing engine-intent unit tests and the IntentEngineIT / IntentEmissionCoverageIT assertions key on element/flow presence, not coordinates, so they are unaffected. All engine-intent unit tests pass locally; verified visually in a running instance against branching processes and multi-entity models.

🤖 Generated with Claude Code

The intent generators emitted diagram interchange (bpmndi for .bpmn,
mxGraphModel for .edm) with naive placement, so branching processes and
larger entity models opened badly formatted and had to be reordered by hand.

BPMN (BpmnIntentGenerator): replace the single-line, declaration-order
placement with a deterministic layered (Sugiyama-style) layout. A node's
column (X) is its longest-path distance from the start event, so a gateway's
then/else branches share a column and the flow reads strictly left-to-right;
its lane (Y) is assigned per column by the barycentre of its predecessors'
lanes and spread symmetrically around a centre lane, so branches fan out
above and below instead of piling onto the two fixed lanes (140/300) the old
code used. Edges are routed orthogonally (right-angle L/Z) when their
endpoints are on different lanes, straight when aligned. The obsolete
secondaryBranchTargets single-drop heuristic is removed.

EDM (EdmIntentGenerator.appendMxGraphModel): place entities in a
relationship-aware order (breadth-first over the FK graph so connected
entities cluster) and pack each into the currently shortest column instead of
a blind index % 3, so columns stay balanced regardless of card height and
FK-linked entities land near each other. Cells are still emitted in
declaration order, keeping regeneration diffs stable.

Both layouts are pure functions of the model, so output stays byte-stable;
the modeler re-routes on first manual edit. Existing engine-intent unit tests
and IntentEngineIT/IntentEmissionCoverageIT assertions key on element/flow
presence, not coordinates, so they are unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@iliyan-velichkov iliyan-velichkov self-assigned this Jul 15, 2026
@iliyan-velichkov
iliyan-velichkov merged commit 2c928bc into master Jul 15, 2026
10 checks passed
@iliyan-velichkov
iliyan-velichkov deleted the fix/intent-diagram-layout branch July 15, 2026 14:22
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