ADR 0017: return-pickup inductions (Induction.Kind, COLLECTED, PackagePickupOut)
Status
Accepted (2026-11-14).
Context
The network's return authorization (the customer-returns context) can offer a
shopper a doorstep pickup as the return method instead of a drop-off: the
reverse label's package is collected at the same stop the outbound package was
delivered to, by the same last-mile operation that delivers. Until now every
package this context inducts is a delivery: outcomes are DELIVERED or
FAILED only, and Route.Start announces every package as
PackageOutForDelivery.
The reverse label carries the same ship-to, so its stopKey equals the outbound stopKey by construction: a pickup stop groups with the delivery stop at the same address for free. What is missing is the reason a package takes a stop (deliver to it, or collect from it), an outcome for a successful collection, and an event that tells downstream contexts a package is out for pickup, not out for delivery.
The alternatives weighed:
- A separate pickup aggregate or context. Rejected: a pickup stop IS a stop — it shares the wave's capacity, the route's van and the attempt history; a second model would duplicate all of it.
- Reusing
PackageOutForDeliverywith a payload flag. Rejected: the outbound scan flow of shipping-and-tracking keys on the event type; a pickup announced as out-for-delivery would poison that read model. A new type keeps consumers dispatching on the full type string, and the old one untouched. - A
PICKED_UP-style attempt outcome only, no induction kind. Rejected:COLLECTEDmust be legal exactly for packages inducted as pickups, and only the induction can carry that fact.
Decision
InductiongainsKind,DELIVERY(the default) orPICKUP. The command isInduct(trackingNumber, stopKey, kind, at, now); an unknown kind is a value-object error. APICKUPinduction occupies stop capacity, follows the uniqueness rules and raisesDeliveryWaveCapacityChangedexactly like any other induction. The persisted form addskind(migration 0008,wave_inductions.kind TEXT NOT NULL DEFAULT 'DELIVERY'with a CHECK of the two values); an omitted kind decodes asDELIVERY.- Activation-gated, dormant by default: no writer of this context passes
PICKUPuntil the return authorization flow requests it. Every existing writer — the arrival, retry, sweep and re-induct paths — passesDELIVERY, so the default is what every wave holds until then. This context has NO REST induction route to extend (induction is driven by theLoadArrivedconsumer; ADR 0003): the kind rides the domain seam above, and the wave's check (not a route) is its only gate. DeliveryAttempted.outcomegainsCOLLECTED. It is valid only when the package's induction isPICKUP;FAILEDstays valid for both kinds;DELIVEREDstays valid as before.checkAttemptis extended: aCOLLECTEDattempt carries nofailureReasonand nooutcomeDetail(none of the detail categories fits a collection). On the PackageAttemptHistory aCOLLECTEDattempt is a terminal success — it takes the sameRecordDeliveredtransition and the four statuses are unchanged.Route.StartraisesPackageOutForDeliveryforDELIVERYpackages and a newPackagePickupOut{routeId, trackingNumber, stopKey, stationNodeId, at}forPICKUPpackages — typecom.retailnetwork.logistics.last-mile-delivery.route.PackagePickupOut, same topic, subject and Kafka key asPackageOutForDelivery(the routeId), so both streams stay ordered per route. The analytics projector skips it committed-past (no report needs it; ADR 0012).- A third
FAILEDattempt of a pickup package raises the existingPackageReturnInitiated(G16) unchanged; the return context consumes it as its pickup-failed fact. Nothing in this context changes for that path.
Consequences
- The catalogue (ADR 0004) and
apis/asyncapi.yamlgain thePackagePickupOuttype and payload; the REST attempt outcome enum (apis/openapi.yaml) gainsCOLLECTED. Both stay additive and optional: consumers that decode tolerantly see nothing new until a pickup is inducted, and no pickup is until the return flow asks for one. - The derived per-stop outcome (G17) is unchanged:
COLLECTEDis notFAILED, so a stop of collected packages derivesDELIVERED; the stop view keeps its two values. - Rollback is the down migration
0008; no event or row written before activation mentions a pickup.