Axis 05 · Absence: Can this bad sequence ever happen?
Something that must never happen, whatever else happens first. A cancelled order is never shipped. This is not about one value; it is about the order of events over time.
A service scheduled a shipment when an order was confirmed, and cancelling the order did not cancel the shipment. Confirm, then cancel, then the shipment still went out.
Temporal<FulfilmentEvent>.Never<FulfilmentEvent.Cancelled, FulfilmentEvent.Shipped>((_, _) => true)
Also Always for a rule about every event, and Transitions for the legal order of events.
It drives your real service with random calls (confirm, cancel, in any order) on a virtual clock, records the events the service emits with their times, and checks the rule against that log. Nothing waits in real time.
Absence failed.
Rule broken cancelled-orders-are-never-shipped Noticed at +30s What happened Cancelled, then Shipped Events recorded +0s Confirmed +14s Cancelled +30s Shipped Calls made wait 47s, Confirm -> wait 14s, Cancel
Law A sequence the domain forbids never happens, whatever the calls and their timing. Consequence A forbidden state is reachable in production by a sequence nobody wrote a test for.
Smallest case found, after 4 shrinks. To run this case again: .Seed("bJG2B9wvdYq4")
How to read this:
- Events recorded is what the service did, with times relative to the first event.
- Calls made is what the test did to cause it: wait 11 seconds, confirm, wait 6 seconds, cancel.
- What happened names the forbidden sequence:
Cancelled, then Shipped.
A scenario test picks one order of calls. The forbidden sequence happens under the order, or the timing, the author did not pick.
In docs-builder, the live build behind docs-builder serve is tested this way: its events must always arrive as start, then findings, then an end, whatever the saves and timing.
Previous: 04 Conservation · Next: 06 Temporal · All nine axes