#8288·mermaid

eventmodeling: explicit `->>` sources on an `rf` frame are silently dropped

Author: TomasEkeliCreated Sep 22, 2026Updated Sep 28, 2026
LabelsStatus: Approvedv12.0.1Graph: EventModeling

Description

A reset frame (rf) is documented as breaking the inferred relation to the previous frame. It also discards any explicit ->> sources on the same line. rf 06 rmo X ->> 03 draws X with no relations at all, without warning.

Steps to reproduce

eventmodeling

tf 01 ui AppointmentUI
tf 02 cmd AddAppointment
tf 03 evt Appointments.AppointmentAdded
tf 04 rmo Calendar
tf 05 ui CalendarUI
rf 06 rmo AppointmentsWithoutForecast ->> 03
tf 07 pcr WeatherProcessor

Expected: a relation from AppointmentAdded (03) into AppointmentsWithoutForecast (06), and no inferred relation from CalendarUI (05).

Actual: AppointmentsWithoutForecast has no incoming relation. Changing rf 06 to tf 06 draws the 03 -> 06 relation, and the explicit source correctly replaces the inferred one.

Screenshots

Both cases are live below. They will look the same once the bug is fixed. The issue is that with a rf the connection from 03 to 06 is impossible.

With rf on frame 06, no arrow reaches AppointmentsWithoutForecast:

mermaid
eventmodeling

tf 01 ui AppointmentUI
tf 02 cmd AddAppointment
tf 03 evt Appointments.AppointmentAdded
tf 04 rmo Calendar
tf 05 ui CalendarUI
rf 06 rmo AppointmentsWithoutForecast ->> 03
tf 07 pcr WeatherProcessor

With tf on frame 06 and nothing else changed, the 03 -> 06 arrow is drawn and the inferred one from CalendarUI is not:

mermaid
eventmodeling

tf 01 ui AppointmentUI
tf 02 cmd AddAppointment
tf 03 evt Appointments.AppointmentAdded
tf 04 rmo Calendar
tf 05 ui CalendarUI
tf 06 rmo AppointmentsWithoutForecast ->> 03
tf 07 pcr WeatherProcessor

Code Sample

packages/mermaid/src/diagrams/eventmodeling/db.ts, decidePositionRelation:

typescript
if (isEmResetFrame(command.frame) || isFirstFrame(command.index, command.frame)) {
  return [];
}

const targetBox = findBoxByFrame(state.boxes, command.frame);
...
let sourceBox;
if (command.sourceFrame) {
  sourceBox = findBoxByFrame(state.boxes, command.sourceFrame);
} else {
  sourceBox = findBoxByLineIndex(state.boxes, targetBox.swimlane.index, command.index - 1);
}

Explicit sources are dispatched as one PositionRelation command per source frame, each with command.sourceFrame set. The reset check runs before the branch that looks at sourceFrame, so every one of them returns [].

Setup

  • mermaid 11.17.2 via @mermaid-js/mermaid-cli
  • also read against develop, db.ts as of 2026-09-22

Suggested Solutions

Apply the reset check only to the inferred relation:

typescript
if (command.sourceFrame) {
  sourceBox = findBoxByFrame(state.boxes, command.sourceFrame);
} else {
  if (isEmResetFrame(command.frame) || isFirstFrame(command.index, command.frame)) {
    return [];
  }
  sourceBox = findBoxByLineIndex(state.boxes, targetBox.swimlane.index, command.index - 1);
}

If the intended semantics are that rf never has relations, the validator should reject ->> on a reset frame. Today the grammar for EmResetFrame allows sourceFrames and the renderer ignores them, so the two disagree.

Additional Context

The "Multiple relations" example in the docs puts rf on the events and tf with ->> on the read model, which avoids the case. A user who reads rf as "start a new slice" and then wants that slice's read model fed by earlier events will hit it.