Examples
Method facts
A guest opens a booking, then confirms it or cancels it. A payment from an outside system becomes a deposit.
The model states facts that earlier versions kept in descriptions, comments, or hotspots. Spec v0.8.0 added these facts. The model uses every new construct of v0.8.0.
state_change state_view automationThe rendered canvas
Generated with emhcl diagram examples/method-facts.em.hcl. Use the view switcher for the Model, Compact, and Storming views. Context Map covers the whole model. Click a slice to view its scenarios.
What the model shows
- Aggregate identity.
identity = field_type.booking_idon thebookingaggregate names the field type of one stream. Each event of the aggregate has abooking_idfield. Without it, the event isEM018. - Key flags. The outside event
payment_receivedmarksbooking_referencewithcorrelation_key = trueandpayment_referencewithdeduplication_key = true. - Lifecycle. The
bookinglifecycle has the statesopen,confirmed, andcanceled. Three transitions move a stream between them.before = []onopen_bookingstates that this transition starts the stream. The invalid transitionconfirm_canceled_bookingstates that a canceled booking cannot be confirmed. - Field sources. Each
field_sourcestates where one field gets its value, for examplecommand.open_booking.field.guest_namefromscreen.booking_form.field.name. The input and the target connect along one canonical edge of the workflow. - Scenario cases.
casenames the business rule of each scenario:happy_path,state_violation, andbusiness_duplicatefor command scenarios, andappearanddisappearfor read model scenarios. - Empty history. The scenario
no_booking_yethasempty_history = true. It states the open bookings list before any event. - Dispatch assertions. In
record_deposit, the scenariopayment_becomes_depositstates that the processor issuesrecord_deposit. The scenariorepeated_payment_is_ignoredstates withexpect_no_dispatch = truethat a repeated payment issues no command. - Evidence. The evidence source
booking_policyis a document. Oneevidencerecord withcertainty = "stated"supports the invalid transition. Another record withcertainty = "assumed"states that no source says that a payment reference is unique. - Decision.
one_open_bookings_listaccepts theEM403signal on the open bookings read model and gives the reason. The signal stays. The decision does not change a diagnostic. - Hotspot kinds.
refund_ruleis an assumption about a rule, with two answer options.late_cancellation_scenariois a request that concerns a scenario.
emhcl export drops these facts with a warning, because Event Modeling JSON cannot hold them.
The source
Source file: examples/method-facts.em.hcl.