Scenario compiler
The scenario compiler (@molar/scenario-spec) validates .molar.md files, resolves clone legs, and emits deterministic Playwright .spec.ts artifacts.
Commands
molar scenarios validate # lint frontmatter + step grammar
molar scenarios compile # write .molar/scenarios/*.spec.ts (gitignored)
Validation runs in CI and locally. Compilation is content-hash keyed — the same scenario always produces the same Playwright output for a given compiler version.
File format
Each scenario is a Markdown file with YAML frontmatter:
---
spec_version: '1.0'
id: '019301c0-cafe-7000-bea7-000000000001'
slug: checkout-happy-path
description: User completes checkout
priority: medium
tags: [smoke]
clones:
- { kind: stripe, seed: stripe-base }
---
# Checkout
## Steps
1. Navigate to /checkout
2. Click "Pay now"
3. Wait for webhook stripe.checkout.session.completed {timeout: 30s}
4. Assert text "Thank you" is visible
Project-level config lives in repo-root .molar.md.
P1 verbs (shipped)
These verbs compile to Playwright today:
| Verb | Purpose |
|---|---|
navigate | Go to a path or URL |
fill | Fill an input |
click | Click an element |
assert | Text/visibility/state assertion |
wait | Fixed delay or condition |
snapshot | DOM snapshot checkpoint |
screenshot | Capture screenshot |
inject_error | Inject fault (chaos testing) |
advance_clock | Advance clone virtual clock |
request | HTTP request (API-only scenarios) |
debug | Debugger breakpoint |
P2 verbs (hover, select, drag, upload, etc.) fail validation with MOLAR_S001 until the compiler ships them.
Frontmatter schema
Required keys: spec_version (must be '1.0'), id (UUIDv7), slug, description.
Optional: priority, tags, clones, schedule (Guard production), shadow_prod, mender.mode.
Unknown frontmatter keys are rejected (MOLAR_S004).
Clone integration
Clone declarations in frontmatter tell Guard and the runtime which vendor simulators to start. Setup steps can reset clone state before assertions.
See Clones scenario integration.
MCP equivalents
| CLI | MCP |
|---|---|
molar scenarios validate | molar_validate_scenario |
molar scenarios compile | molar_compile_scenario |
Related
- .molar.md config
- Your first scenario
- Unified CLI
- Error codes — MOLAR_S0xx compiler diagnostics