EventStorming
Following the ddd-crew EventStorming glossary: domain events in orange, commands in blue, policies in lilac, read models in green, external systems in pink and hotspots marked. The board is reconstructed from the code, not from a workshop.
Timeline
Source: internal/adapters/inbound/kafka/handlers.go (the facts), internal/application/usecases/intake.go
(deduplication and recording), cmd/api/workers.go (runRecompute),
internal/domain/scorecard/scorecard.go and grade.go (grading and alert policies),
internal/domain/scorecard/eligibility.go (FastTierEligibility, tierEvents),
internal/adapters/outbound/kafka/encoder.go (the three events). The FastTierEligibility policy
runs inside Recompute only for the 7d scorecard and only on a GRADED result, and raises
NodeTierEligibilityChanged only when the flag flips (eligibility.go assess); delivery-promise's
reaction is in its own apis/asyncapi.yaml.
Hotspots
| Hotspot | What the code does about it |
|---|---|
| Facts arrive in no global order across topics | A handover or acknowledgement that beats its purchase order is retried (200 ms doubling to 5 s, 5 attempts) and then dead-lettered; there is no automatic redrive from the DLQ. |
PromiseBroken for causes that are not the node's fault | Only LATE, LATE_HANDOVER, VENDOR_REJECT, ACK_EXPIRED count; other causes are acknowledged and ignored. |
| A quiet new node must not look good | Under 50 observations a scorecard is PROVISIONAL and publishes nothing. |
| Observations leave the window with no new fact | ExpiresAt makes a scorecard due when its oldest observation expires, so a grade can fall back to PROVISIONAL. |
| Declared profile next to measured capability | Not modelled: NodeOperationalProfileDeclared is consumed with no effect and no read model holds it. |
| Inbound accuracy mixes node and seller causes | Informational only, never graded. |
| Kafka down while recomputing | The event waits in the outbox; delivery is at-least-once, consumers deduplicate on the id. |
| A suspended node that stops reporting | It is only recomputed when observations leave its window, so it stays suspended until fresh facts say otherwise (ADR 0013 consequences). |
Aggregate and read model
One aggregate, NodeScorecard (canvas). The two reads
(GET /scorecards/{nodeId}, GET /scorecards?grade=) read its table directly; there is no separate
read model.
Policies
| Policy | When | Then | Owner |
|---|---|---|---|
| Deduplicate | an event arrives | claim its CloudEvents id in processed_events, or stop | Node Performance |
| Late acknowledgement | an acknowledgement is recorded | late if in the last tenth of the ack window | Node Performance |
| Grading | a recompute has 50 or more observations | grade A to D | Node Performance |
| Threshold alert | a recompute moves a metric across its bound | raise NodeThresholdBreached | Node Performance |
| Fast-tier eligibility | a GRADED 7d recompute is below 0.90 on-time handover (suspend), or at or above 0.95 on three consecutive distinct UTC days (reinstate) | raise NodeTierEligibilityChanged, one per tier | Node Performance |
| Scorecard handicap | NodeScorecardUpdated | delay the node's ship-by | delivery-promise |
| Assignment cost | NodeScorecardUpdated | weigh the grade in the cost | order-sourcing |
| Fast-tier gate | NodeTierEligibilityChanged | drop an ineligible node from the SAME_DAY / NEXT_DAY candidates of future quotes and estimates; existing promises are never touched | delivery-promise |