<!-- example:order-events -->
# Event-driven order notifications specification example

When an order changes, the customer hears about it: placed, shipped and delivered.

- [HTML version](https://specifica.org/examples/order-events/)
- [Specifica format](https://specifica.org/format.md)
- [Editable Playground](https://playground.specifica.org/): choose Order events and Simple

## spec.md

### Requirements

- [ ] The shop records an event when an order is placed, shipped or delivered.
- [ ] Each event sends the customer an email that names the order and what happened.
- [ ] The shipped email includes the tracking link.
- [ ] Staff see the list of events for an order, newest first.
- [ ] A failed email is retried three times before it is marked failed.

### Edge Cases

- The same event is recorded twice → only one email is sent.
- Delivered arrives before shipped → both emails are sent, in the order the events happened.
- The customer's email address bounces → the event is marked "not delivered" for staff.

## tasks.md

### Build order

- [ ] Data model: orders, order events, messages
- [ ] Record events in the same transaction as the order change
- [ ] Worker that sends one email per event, with retries
- [ ] Email templates: placed, shipped (with tracking), delivered
- [ ] Staff view of an order's events

Optional workflow reference: delivery, retry and deduplication rules can be evaluated before merge; runtime operations remain with the team. [Cognium Autonomous Loop](https://cognium.net/how-it-works/).
