An in-browser learning lab for CALM: a terminal, an editor and a live diagram, with calm validate,
calm generate and calm diff running the real CALM engine (@finos/calm-shared/browser) — the
same validation the CLI performs, with nothing to install and nothing sent to a server. The terminal
accepts the CLI's own syntax (calm validate -p <pattern> -a <file>, calm generate -p <pattern> -o <file>, calm diff -a <file> -b <file>), so every command works unchanged after installing the CLI.
Hosted at https://lab.calm.finos.org. It has its own origin because many CALM users work behind proxies that block sites accepting free-text input; the documentation at https://calm.finos.org stays reachable, and the lab can be allow-listed on its own.
Learners work through guided lessons in an IDE-style workspace: a lesson rail with steps and hints, an editor, a terminal, a Problems tab and a live diagram. Every step is checked against real state — the saved workspace and the engine's validation result — so any valid solution passes.
A lesson is a folder under src/lessons/. Open one with ?lesson=<id>
(e.g. https://lab.calm.finos.org/?lesson=beginner-02). The docs and each lesson's completion link to it;
the lab has no lesson picker.
| Lesson | Tutorial | Status |
|---|---|---|
beginner-02 |
02-first-node | Released |
beginner-03 |
03-relationships | Released |
beginner-05 |
05-interfaces | Released |
beginner-06 |
06-metadata | Released |
beginner-07 |
07-complete-architecture | Released |
intermediate-08 |
08-controls | Released |
intermediate-09 |
09-business-flows | Released |
intermediate-10 |
10-adr-linking | Released |
intermediate-17 |
17-patterns | Released |
intermediate-18 |
18-standards | Released |
intermediate-19 |
19-enforcing-standards | Released |
intermediate-20 |
20-multi-pattern-validation | Released |
-
Create
src/lessons/<id>/lesson.tsthat exports aLesson(seesrc/lessons/types.ts):Field What it is idLowercase, hyphenated. It is the ?lesson=value and the storage key. Do not change it after release.titleThe lesson's name, used in notices. tutorialThe tutorial page this lesson follows: { title, url }, with the page's own title. The top of the lesson guide links to it in a new tab.editorFileThe lesson's main architecture. The editor opens it first, and state.docand the status badge describe it.editableFilesThe files the learner can open in the editor, for example an ADR next to the architecture. It must include editorFile. Each file must be inseedFilesor be written by a hint (for example the output ofcalm generate -o); the selector lists a file only when it exists. Default:[editorFile]. With more than one file, a "File" selector shows in the editor tab bar. The diagram shows the open file when it is an architecture (it has anodesarray), elseeditorFile.seedFilesThe workspace at the start: absolute path under /workspace→ contents.chainsFromThe lesson whose end state this one starts from. Build the seed with endFiles(previous), imported fromsrc/lessons/chain.ts(notindex.ts, to avoid a circular import).stepsOrdered steps, below. completionHeading, message and links shown when every step is done. -
Write each step:
id,title,body(inline code in backticks) and ahint:{ kind: 'file', content, path? }— the complete file after the step, so paste-and-save always works.pathis the file to write; it must be ineditableFiles. Default:editorFile;{ kind: 'commands', commands }— the commands to run, from/workspace. A command must not print an error or fail validation. To show a failure, write{ run: 'calm validate …', expect: 'failure' }: the command must run and every error must be in the architecture. A missing file, a$refthat does not load or an error in the pattern does not count. The learner sees only the command text.
Write a CALM release URL as
${CALM_META_SCHEMA_BASE_URL}/calm.jsonand the release number asCALM_SCHEMA_RELEASE, both fromsrc/schemas.ts, not as a literal release. Then a schema bump moves the lesson too. -
Write each
check(state)with the helpers insrc/lessons/checks.ts. A check reads state, not history:state.doc(the saved editor file),state.validation.ok, andstate.commands(the commands whose files have not changed since they ran). Check what the step asked for, not the names in the hint, so any valid answer passes. For a "see it fail" step, checkrejected(state, files): the same rule asexpect: 'failure'.ranFailedaccepts any failure, so use it only forgenerateordiff. File paths given toranOk,ranFailedandrejectedare absolute: usestate.editorFileor a/workspace/...path.To read another saved file, use
fileText(state, path)(the text, ornull) orfileJson(state, path)(a JSON object, ornull).markdownSection(text, heading)gives the trimmed text under## heading(case-insensitive), or''. -
Register the lesson in
src/lessons/index.ts, add it to the table above, and addsrc/lessons/<id>/lesson.spec.ts. For each step, it must have:- a passing answer that uses different names from the hint, which the check accepts;
- at least one wrong answer, which the check rejects.
src/lessons/invariants.spec.ts runs every registered lesson through the real shell and engine:
files live under /workspace, editable files are seeded or written by a hint and include the
editor file, file hints write only to editable files, no step is complete before its hint, each hint
completes its step and each command does what the hint expects, the end state validates, each CALM
release in the files, hints and copy is the pinned CALM release, every
calm command in the copy runs in the lab's shell after all the hints, lesson links name registered lessons, and a chained lesson starts from its predecessor's end
state.
Run everything from the repository root.
npm run calm-lab:run # Dev server
npm run build:calm-lab # models → widgets → shared → lab, into calm-lab/dist
npm test --workspace calm-lab # Unit tests
npm run lint --workspace calm-lab # ESLint
npm run typecheck --workspace calm-lab # tsc --noEmitshared must be built first — the app imports the compiled browser entry, which
build:calm-lab takes care of.
Commands the browser cannot honour report why: the shell reads the BROWSER_COMMAND_SUPPORT
manifest in shared rather than guessing, so calm docify explains that it needs a local
filesystem and a headless browser and points at the CLI docs.
See AGENTS.md for the browser-engine contract and the conventions this package follows.