Lifecycle and ordering
Reconstruct queued, in-transit, and delivered states from ordered events without assuming arrival order.
Read as MarkdownThree events, three states
A queued event creates a batch at its source station. A dispatched event moves the state to in_transit and still references the source. A delivered event changes the state to delivered and references the destination.
The fixture snapshot contains eight three-event delivered lifecycles, three two-event in-transit lifecycles, and one single-event queued lifecycle: 31 events in total. Missing later stages in this snapshot are deliberate, not malformed records.
queued → state: queued · source station
dispatched → state: in_transit · source station
delivered → state: delivered · destination stationOrder within a batch
Group by batch_id, deduplicate by id, and sort by sequence within each group. sequence is local to one batch, so it must never be used as a global cursor. Check timestamps as a consistency constraint, not as an identity key.
If two events reuse a sequence with different IDs or content, report a conflict. If an event is absent in the middle of a sequence, report a gap rather than inventing it.
Replay a known example
Batch batch-001 queues at 08:00 UTC, dispatches at 08:02, and delivers at 08:10 on October 1, 2026. It carries 42 units from wp-001 to wp-003. The authored end-to-end duration is 10 minutes.
const response = await fetch('/resources/datasets/relay-events.json');
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const fixture = await response.json();
const events = fixture.records
.filter(row => row.batch_id === 'batch-001')
.sort((a, b) => a.sequence - b.sequence);
// queued, dispatched, delivered
const elapsedMs = Date.parse(events.at(-1).timestamp)
- Date.parse(events[0].timestamp);
console.log(elapsedMs / 60_000);
// 10Treat the snapshot as a fixture
All timestamps and IDs are stable within a catalog version. There is no scheduler advancing these batches, no webhook endpoint, and no polling stream. Re-fetching does not turn a queued sample into a delivered one.
Use the fixture to test deterministic reconstruction and error handling. It does not model network delays, delivery guarantees, or the complete behavior of a production event system.
KEEP EXPLORING
Open the waypoint directory