BPMN 2.0: bpmn-beta - PR series tracker
A BPMN 2.0 process diagram for mermaid: bpmn-beta. This issue tracks the PR series that adds it.
Companions: #2623 (demand and scoping) and #7699 (design proposal, Status: Approved).
Start here
What it is. A new diagram type that renders BPMN 2.0.2 from text - pools and lanes, events with
their triggers, gateways, activities, artifacts and the flows between them - plus the swimlane-engine
work it needs. It is built on swimlane-beta's layout engine, which @knsv called the precursor for
BPMN on #2623.
Where it stands. Nine PRs, all ready for review and mergeable, each rebuilt on current develop
as atomic commits. Six are green on every check including argos; three move snapshots deliberately
and are waiting on a baseline decision. No unresolved review threads. No maintainer has reviewed any
of it yet.
What I am asking for. Three decisions, in Open questions below. Nothing else blocks this. If the answer to any of them is no, that is a useful answer and the work follows it.
Fastest way in. #8161 is one commit and three files: a real DOM-id collision between two diagrams on one page, with a test that fails before and passes after. It has nothing to do with BPMN.
Scope of the first release. What the beta covers, and how bpmn-beta becomes bpmn, is on the
syntax page;
the element reference
gives every BPMN 2.0 element's status. Both are in #8167.
What this looks like
This source:
bpmn-beta LR
pool "Order handling"
lane "Sales"
start message s1 "Order received"
user task t1 "Approve order"
boundary timer b1 "2 days"
xor gw "Approved?"
lane "Warehouse"
service task t2 "Pick items"
end e1 "Shipped"
s1 --> t1 --> gw
gw -- yes --> t2 --> e1
b1 --> t2renders this:

The two images that carry the most notation detail are the event tables. BPMN 2.0.2 Table 10.93 draws a trigger unfilled when the event catches and filled when it throws, which is why the same keyword produces a different marker on an intermediate than on an end:


A collaboration: two pools joined by a message flow, drawn dashed with an open arrowhead and a hollow ring at its source.

The five gateways and the activity types:

The artifacts - data object, data store, text annotation - and a group:

A group on its own:

What these images are and are not. They are the fixtures committed in #8166, rendered at its current head in Chromium with the default theme, and they exist so this discussion has something concrete to argue about. They are not test baselines - the visual baselines are the Argos snapshots, which need maintainer approval - and they are not evidence that the layout is stable across themes or directions. They are hosted on a branch of my fork rather than committed, so they add nothing to any diff.
Merge order
The first five stand alone and can be reviewed in any order. The last four each sit on something,
for the reason given. Every branch is on current develop.
| # | PR | What it changes | Sits on | Size | argos |
|---|---|---|---|---|---|
| 1 | #8161 | fix(clusters): a swimlane cluster wrote the author's node id into id, so two diagrams on one page collided. Every other cluster already uses domId |
- | 1 commit, 3 files | green |
| 2 | #8163 | feat(swimlanes): pin a node to another node's border, which is how a boundary event straddles its host. Gated on node metadata, so a diagram that pins nothing is unchanged |
- | 1 commit | green |
| 3 | #8164 | feat(rendering-util): the open-arrow and hollow-circle edge markers. Additive; nothing existing names them |
- | 1 commit | green |
| 4 | #8165 | feat(shapes): the BPMN element shapes, one per file over a shared core, in the use-case actor pattern |
- | 1 commit | green |
| 5 | #8270 | fix(rendering): clip an edge for the engine that drew it, not for the configured layout. A no-op for every renderer on develop |
- | 1 commit | green |
| 6 | #8162 | refactor(swimlanes): one shared lane model, replacing call sites that had each decided what a lane is and drifted apart |
#8161, #8163 | 1 own commit | green |
| 7 | #8171 | fix(swimlanes): dock an edge on the shape it points at, instead of on the box a caption reserves |
#8270 | 1 own commit | 4 sheets to approve |
| 8 | #8166 | feat(bpmn): the diagram - grammar, db, renderer, styles, config and theme, fixtures and browser suites |
all of the above | 5 own commits | 4 changed, 3 added |
| 9 | #8167 | docs(bpmn): the syntax page and the element reference, with tables generated from the grammar |
#8166 | 1 own commit | as #8166 |
Two commits have no PR of their own and are reviewed inside the ones that carry them:
feat(clusters): draw a pool as a swimlane cluster with its own classes (in #8162 and #8166 - the
lane model assigns that shape, and the shape type is keyof typeof shapes, so it must be registered
first) and fix(rendering): shorten an edge for its arrowhead along the way it arrives (in #8166).
Either can be split out if you would rather review it on its own.
Nothing outside the swimlane engine changes. 242 ELK, flowchart, state, class and ER fixtures
were rendered on develop and on the branch and compared as SVG: 240 byte-identical, two differing
only in the element ids state diagrams generate at random.
What it draws today
| Area | Supported |
|---|---|
| Containers | Pools, lanes, black-box participants, groups |
| Events | All 13 triggers of BPMN 2.0.2 at the 5 positions the notation draws each at, unfilled when catching and filled when throwing; boundary events pinned to their host's border |
| Gateways | Exclusive, parallel, inclusive, event-based, complex |
| Activities | The 7 task types, sub-processes, call activities |
| Flows | Sequence, labelled sequence, message, association (directed and not) |
| Artifacts | Data object, data input/output, data collection, data store, text annotation |
A position and trigger pair the notation does not draw is refused while the line is read, naming the line and where that trigger does belong. The parser, the docs table and the tests read that matrix from one source, so they cannot drift apart.
Measured against the OMG's own example corpus (25 files, dtc-10-06-03): 1002 of 1151 drawable
elements are expressible, and all 25 render - the measurement, with the converter and every
generated .mmd.
Limitations today
- Event sub-processes and transactions have no syntax. The two rules that depend on one are
therefore wider here than in the notation:
error,escalationandcompensationare accepted on anystart, andcancelon anyboundaryorend. Every other pair is checked. - Activity markers (loop, multi-instance, ad-hoc, compensation) have no syntax; the glyphs exist but nothing can ask for one.
- A group is held by one lane, so it cannot stretch across pools as Figure 8.14 shows.
- No choreography or conversation diagrams, and no BPMN XML import or export.
- Each of these is stated on the docs page too, rather than left to be discovered.
Assumptions I made
These are choices, not conclusions - say the word and any of them changes.
bpmn-betaas the keyword, becomingbpmnwhen the syntax is declared stable, followingswimlane-beta,agentflow-betaandusecase-beta.- A Chevrotain parser co-located with the diagram, per the new-diagram guide, with the use-case diagram as the model.
- Indentation expresses containment, as in mindmap, kanban and treeView.
- The diagram names its own layout engine (
swimlane) rather than reading it from config, because a pooled process is drawn in lanes whichever engine the document prefers. - Per-element attributes will use
@{ }, matching flowchart, kanban and usecase, when the syntax grows beyond what is here - see the staged proposal.
Open questions
- Which syntax? Four candidates exist: @andreas-emrich's two tiers on #7699, @OKHP3's published
plugin
@okhp3/mermaid-diagram-bpmn, @derari's editor, and this one. @OKHP3's and mine converged independently on the same keyword, the same keyword-position element type and the same quoted-label form. I have no stake in which wins - porting mine to another is a parser change and nothing else. None of the four has had a maintainer reply. - Core or external plugin? @sidharthv96 (#6305), @ashishjain0512 (#6305, #6317) and @pbrolin47 (#7624) have all said this is an architectural decision maintainers make per diagram. "External plugin" is a reasonable answer, and @OKHP3 already has one published.
- How much scope? @knsv named Level 1 Descriptive as the realistic target on #2623. What is here goes beyond that, which I would rather say than have discovered in review. If Level 1 is what is wanted, the extra elements move to a follow-up.
A fourth, only if the first three land well: where BPMN XML import/export should live - this repo or a separate package - asked on #2623.
What comes next, if this is wanted
Staged, each gated on the one before it being wanted, and none of it written yet: A - the rest of @knsv's Level 2 (activity markers, non-interrupting events, event sub-processes, transactions, default and conditional flows, data state, nested lanes, groups across pools, semantic validation, styling). B - choreography and conversation diagrams. C - BPMN XML with DI, so a diagram opens in bpmn.io or Camunda Modeler. Detail in the staged proposal.
Detail, moved out of this description
- How the branches are built, the three browser suites, and how to read a red check
- Latest status, and what the Argos counts turned out to be
- Measured against the OMG example corpus
- An earlier measurement I had to correct, and why
On prior art. @OKHP3, @derari and @andreas-emrich each proposed or published BPMN support before this series, and none of them has had a maintainer reply. I am not claiming the keyword or the design, and I would rather the syntax question were decided between the candidates than settled by whoever opened a PR first.
Source: mermaid-js/mermaid