ADR 0028: out-of-order capacity and scorecard facts never overwrite a newer one
Status
Accepted (2026-11-14). Amends A25 and hotspot H2 of ADR 0002 (a capacity event that arrives before its schedule event) and follows the precedent of ADR 0022 (the changedAt guard of NodeTierEligibilityChanged).
Context
OnDepartureCapacityChanged, OnWaveCapacityChanged and OnScorecardUpdated overwrote the stored row with whatever arrived last. The context documentation (warehouse-docs, domain-events) says the opposite: DepartureCapacityChanged and DeliveryWaveCapacityChanged apply "newer time wins", NodeScorecardUpdated "only if computedAt is newer". A retried or replayed older figure therefore brought back room that a newer fact had taken away: the documentation-derived BDD pass reproduced a stale remainingPackages reopening a full pickup, so the search quoted a tier whose witness path MakePromise then had to refuse as promise-capacity-exhausted.
Decision
search.Departureandsearch.WavecarryCapacityAt, the CloudEventstimeof the newest fact that setRemaining. The two capacity handlers drop an event whosetimeis older thanCapacityAt; an equal instant is the later delivery of the same fact and applies (the ADR 0022 rule).CapacityAtis stored in the row'sdatajsonb: no migration.DepartureScheduledandDeliveryWaveScheduledstampCapacityAtonly when they create the row; a row that a capacity event created earlier keeps its remaining packages and itsCapacityAt(the A25 behaviour is unchanged).NodeScorecardUpdatedis applied only whencomputedAtis not older than the stored scorecard's.- A zero instant on either side (an older producer, a row written before
CapacityAtexisted) carries no ordering: the fact applies, as before.
Consequences
- A late older figure is dropped silently; there is no new metric or error, and the inbox row is still written, so the event is not redelivered.
- Rows written before this change accept the first capacity event unconditionally and are stamped from then on.
- Not covered here: the
timeordering ofNodeActivated/NodeSuspendedand of listing availability, which the documentation also words as "newer time wins". They are a separate change.