Skip to content

feat(eventmodeling): enforce Event Modeling connection invariants via Langium validator#7588

Merged
pbrolin47 merged 1 commit intomermaid-js:developfrom
yordis:yordis/fix-eventmodeling-external-events
Apr 16, 2026
Merged

feat(eventmodeling): enforce Event Modeling connection invariants via Langium validator#7588
pbrolin47 merged 1 commit intomermaid-js:developfrom
yordis:yordis/fix-eventmodeling-external-events

Conversation

@yordis
Copy link
Copy Markdown
Contributor

@yordis yordis commented Apr 7, 2026

📑 Summary

Adds a Langium semantic validator to the Event Modeling diagram that enforces the directional connection invariants defined by the Event Modeling methodology.

📏 Design Decisions

Event Modeling defines a strict information flow between entity types:

screen/ui → command → event → read model → processor/screen

Without enforcement, the grammar silently accepted connections that violate these invariants. Most notably, an event flowing directly into a processor (bypassing a read model), which is not a valid pattern in Event Modeling.

The validator enforces the following rules via Langium's ValidationRegistry, reporting errors on invalid ->> source references:

Target type Allowed sources
event command only
read model event only
processor read model only
screen read model only
anything else cannot source from event or read model

The check also covers the complementary direction, e.g. a command, frame cannot consume an event as its source. Ensuring events flow exclusively into read models, and read models flow exclusively into processors or screens.

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
  • 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • 🦋 If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 7, 2026

🦋 Changeset detected

Latest commit: d50c423

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@mermaid-js/parser Major
mermaid Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 7, 2026

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit d50c423
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/69d55dcbfe5fab00089787e4
😎 Deploy Preview https://deploy-preview-7588--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@adymitruk
Copy link
Copy Markdown

Screen is a loose term for human interface which can be an email, voice command or voice feedback.

@yordis
Copy link
Copy Markdown
Contributor Author

yordis commented Apr 7, 2026

@pbrolin47 These changes are based on @adymitruk (the author of eventmodeling 😃) to make sure the diagram is proper.

As @adymitruk mentioned above, screen isn't the language we use, normally it would be ui since the ui could be a non-graphical interface as well.

@yordis yordis force-pushed the yordis/fix-eventmodeling-external-events branch 3 times, most recently from e0b28f0 to 72f1ece Compare April 7, 2026 19:19
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 7, 2026

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/@mermaid-js/examples@7588

mermaid

npm i https://pkg.pr.new/mermaid@7588

@mermaid-js/layout-elk

npm i https://pkg.pr.new/@mermaid-js/layout-elk@7588

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/@mermaid-js/layout-tidy-tree@7588

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/@mermaid-js/mermaid-zenuml@7588

@mermaid-js/parser

npm i https://pkg.pr.new/@mermaid-js/parser@7588

@mermaid-js/tiny

npm i https://pkg.pr.new/@mermaid-js/tiny@7588

commit: d50c423

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 1.72414% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.33%. Comparing base (abecf56) to head (d50c423).
⚠️ Report is 75 commits behind head on develop.

Files with missing lines Patch % Lines
...language/eventmodeling/event-modeling-validator.ts 1.85% 53 Missing ⚠️
...ckages/parser/src/language/eventmodeling/module.ts 0.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #7588      +/-   ##
==========================================
- Coverage     3.33%   3.33%   -0.01%     
==========================================
  Files          536     537       +1     
  Lines        56240   56298      +58     
  Branches       820     821       +1     
==========================================
+ Hits          1877    1878       +1     
- Misses       54363   54420      +57     
Flag Coverage Δ
unit 3.33% <1.72%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ckages/parser/src/language/eventmodeling/module.ts 3.84% <0.00%> (-0.70%) ⬇️
...language/eventmodeling/event-modeling-validator.ts 1.85% <1.85%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 👍 Changes approved 1 changed Apr 7, 2026, 7:52 PM

@yordis yordis force-pushed the yordis/fix-eventmodeling-external-events branch 2 times, most recently from 659411e to 58e481c Compare April 7, 2026 19:37
… Langium validator

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis yordis force-pushed the yordis/fix-eventmodeling-external-events branch from 58e481c to d50c423 Compare April 7, 2026 19:40
@pbrolin47
Copy link
Copy Markdown
Collaborator

@yordis Thanks for this PR.

@yordis
Copy link
Copy Markdown
Contributor Author

yordis commented Apr 15, 2026

@pbrolin47 any opportunity to take this one before the official release cause the situation to be a breaking change? I have another PR I would like to make around the word "screen"

@pbrolin47 pbrolin47 added this pull request to the merge queue Apr 16, 2026
Merged via the queue into mermaid-js:develop with commit 8b69f3c Apr 16, 2026
23 checks passed
@mermaid-bot
Copy link
Copy Markdown

mermaid-bot Bot commented Apr 16, 2026

@yordis, Thank you for the contribution!
You are now eligible for a year of Premium account on MermaidChart.
Sign up with your GitHub account to activate.

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.

3 participants