fix(intent): lay out generated BPMN/EDM diagrams so they read cleanly#6299
Merged
Conversation
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>
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.
Problem
The intent generators emit diagram interchange —
bpmndi:BPMNDiagramfor.bpmn,mxGraphModelfor.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:X = declaration-index × spacing, with only two fixed Y lanes (main140, else-branch300). Parallel branches didn't align, multiple/nested decisions piled onto the same lanes and overlapped, and edges were straight diagonals cutting across other shapes.index % 3grid 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:rankByLongestPath, cycle-guarded, end pinned rightmost), so a gateway'sthen/elsebranches share a column and the flow reads left-to-right.secondaryBranchTargetssingle-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 ofindex % 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-intentunit tests and theIntentEngineIT/IntentEmissionCoverageITassertions 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