Scenarios: make the slice testable
A scenario sits beside its workflow. It describes one business rule with typed steps.
| Workflow | Given | When | Then | Cardinality |
|---|---|---|---|---|
| State Change | Event | Command | Event or Error | zero or more given, one when, one or more then |
| State View | Event | none | Read Model or Error | one or more given, zero when, one or more then |
| Automation / Translation | Event or Read Model | Processor or Command | Event or Error | one when, one or more then |
Each step has one typed target. An error target contains a literal string.
The v0.4.0 specification defines these HCL rules. Canvas examples in the methodology are conceptual, not alternative grammar.
State Change scenario
An error path uses a different then target. An optional comment records the business rule:
State View scenario
For example: given Student Registered, then Students to Welcome.
A State View has one or more Event given steps, no when, and one or more Read Model or Error then steps.
If you work from an older draft, read the migration guide for the removed Query form.
Automation / Translation scenarios
The given step targets an Event or Read Model. The when step targets a Processor or Command. The then step targets an Event or Error.
Cover behavior, not just syntax
For each Command, review success, invalid input, invalid state, duplicate actions, alternative outcomes, external failure, and compensation. Write each applicable case.
Use the actual business thresholds and concrete field values. Explain why a case cannot occur instead of inventing a rule.
Review Read Models separately, including todo lists. Cover population, updates, and removal from their source Events.
The methodology also uses storylines for lifecycles. HCL has no storyline block. Use several legal scenarios and comment blocks to explain related transitions.
A canvas automation can describe an empty When and a dispatched Command in Then. Native HCL requires one Processor or Command when, then an Event or Error.
Do not invent query or expect_empty_list attributes. A rejected Command uses an Error target, not an empty-list assertion. Record a tracked business failure as an Event.
See methodology scenario coverage for discovery questions. Keep forms that HCL cannot express in explanatory prose, not invented syntax.
Faded exercise: complete a State View
Fill in each ???, then open the answer.