ADR-0010 — Gift wrap is a WorkReleased characteristic, not a product attribute
Status
Accepted.
Context
A request came in to "implement gift wrap." Before building anything, the
ambiguity in that request had to be resolved: is gift wrap a per-SKU
product attribute — the same shape as inventory-storage's
ProductClassification (Hazmat, Fragile, TemperatureSensitive,
Oversized, HighValue, see
ADR-0009)
— or is it something a caller states at the moment work is enqueued,
independent of what SKU (if any) is involved?
The human clarification settled this explicitly: gift wrap is not a
property of the product. The same SKU might ship gift-wrapped for one order
and bare for another — it is a fact about this particular unit of work,
supplied by whoever is asking the warehouse to produce it, not a fact
inventory-storage could ever answer via
GET /products/{sku}/classification. That rules out extending
ProductClassificationView/classificationHints (ADR-0009's mechanism) —
that pipeline exists specifically to propagate SKU-level master data
inventory-storage owns, and gift wrap has no such owner.
What gift wrap does resemble is CPT, reference, and SKU on
EnqueueWorkUnitRequest: caller-supplied facts about a WorkUnit, threaded
onto the aggregate at enqueue time, and later stamped onto the outbound
WorkReleased event so a downstream consumer
(fulfillment-execution, in a sibling change) has what it needs without a
callback. This service already has that mechanism built and proven; gift
wrap only needed to ride the same rail.
Decision
We will add an optional GiftWrap bool to EnqueueWorkUnitRequest,
thread it onto WorkUnit via a plain setter (mirroring SKU), and stamp it
onto WorkReleased's data payload as gift_wrap — read directly off the
WorkUnit, never derived through classificationHints or any
inventory-storage lookup.
WorkUnitcarries an optionalgiftWrap bool.GiftWrap()/SetGiftWrap(bool)mirrorSKU()/SetSKU()exactly: a separate setter rather than aNewWorkUnitparameter, so every existing caller and test fixture keeps compiling. Defaultfalse— most work is not gift-wrapped.EnqueueWorkUnitRequestgainsGiftWrap bool, defaultfalse.Executecallsunit.SetGiftWrap(req.GiftWrap)right next to the existingunit.SetSKU(req.SKU)call.- The outbound Kafka adapter reads
GiftWrap()straight off theWorkUnit, in the samep.workUnits.FindByIdblock that already loadscpt/ref/sku— not insideclassificationHints, which stays a pureinventory-storageclassification concern. Whentrue,data["gift_wrap"] = true; omitted entirely whenfalse, the same disciplinefragilealready uses, so an event with no gift-wrap request looks identical to a pre-this-feature event. - No
inventory-storageinvolvement whatsoever. No newProductClassificationtag, no change toports.ProductClassificationLookuporproductclassificationview. Gift wrap and product classification are two independent mechanisms that happen to both enrichWorkReleased. - DTO and OpenAPI/AsyncAPI mirror the
skufield's documentation style, explicitly cross-referencing this ADR so a future reader does not conflate the two mechanisms.
Consequences
Easier
- No cross-service coupling. Unlike ADR-0009's SKU classification read,
gift wrap never leaves this service's own
EnqueueWorkUnit→WorkUnit→WorkReleasedpipeline. There is no synchronous HTTP call, no fail-open concern, no availability dependency oninventory-storage. - Reuses a proven pattern exactly. A developer who understands how
SKUorreferenceflows from request to published event already understands howgift_wrapflows — no new mental model. - Per-work-unit, not per-SKU, matches reality. The same SKU can be
gift-wrapped on one order and not another; modeling this as a
WorkReleasedcharacteristic instead of aProductClassificationtag is the only shape that is actually correct.
Harder
- The caller must know and state gift wrap at enqueue time. There is no
mechanism (and none is planned) for gift wrap to be decided or corrected
after a
WorkUnitis enqueued — it is captured once, likeSKU, and carried forward. A request to gift-wrap an already-enqueued or already-released unit is out of scope for this decision. - Two similarly-shaped but differently-sourced
WorkReleasedfields.gift_wrapandfragileare both optional booleans on the same payload, omitted when false — but one is caller-supplied and one is derived from a cross-service lookup. A reader must not assume they share a data source; this ADR and the inline code comments exist specifically so that question keeps getting the same answer.