Architecture Decision Records
An Architecture Decision Record (ADR) captures a single architecturally significant decision: the forces at play, the choice made, and what that choice commits the team to. One decision, one file, numbered in the order they were taken.
Why these exist
Code shows what was built. Tests show that it works. Neither shows why the obvious alternative was rejected — and that is the expensive knowledge to lose.
Concretely, in this repository: nothing in internal/domain/task/task.go
explains why there is a lease rather than a database row lock, or why
ExpireLeaseIfDue is called before the already-claimed check inside Claim.
Both are load-bearing decisions with real alternatives, and both look like
arbitrary style choices to anyone reading the code cold. An ADR is the
cheapest possible place to put that reasoning: next to the code, in version
control, dated, and immutable once accepted.
The ADRs here are reconstructed from decisions actually made in this
repository — visible in CLAUDE.md, TASKS.md, INTEGRATION.md, the CI
workflow and the git history. They are not generic best-practice essays.
The template
These records use Michael Nygard's template, the de facto standard, with five sections:
# NNNN. Title in the imperative
## Status
Proposed | Accepted | Deprecated | Superseded by ADR-NNNN
## Context
The forces at play: technical, business, operational. Written in
value-neutral language — what is true, not what we want to do about it.
## Decision
The response to those forces, stated in the active voice:
"We will …"
## Consequences
What becomes easier and what becomes harder as a result. Both.
An ADR with only positive consequences is not describing a real decision.
Two properties make the format work, and are worth preserving:
- The Context section is neutral. If it argues for the decision, it has stopped describing the problem and started selling the solution — and a future reader can no longer tell whether the reasoning still holds.
- The Consequences section is honest about costs. Every decision here has a "what becomes harder" paragraph. Pull dispatch gave up global optimisation; leases gave up immediate detection of an abandoned claim. Recording that is the point.
Lifecycle
ADRs are immutable once accepted. A decision that changes is not edited —
a new ADR supersedes it, and the old one's status becomes
Superseded by ADR-NNNN. The record of what was believed, and when, is as
valuable as the current answer.
Proposing a new one
- Copy the template above into
docs/docs/adr/NNNN-short-kebab-title.md, taking the next free number. - Set the status to
Proposedand open a PR. - Discuss in review. If the decision changes shape, edit the PR — the immutability rule starts at acceptance, not at drafting.
- On merge, set the status to
Accepted. - Add the file to the ADR list in
docs/sidebars.ts.
If a decision supersedes an existing one, say so in both files: the new one
gets a "Supersedes ADR-NNNN" line in its Context, the old one gets
Superseded by ADR-NNNN in its Status.
The records
| # | Title | Status |
|---|---|---|
| 0001 | Hexagonal (ports and adapters) architecture | Accepted |
| 0002 | Pull-based claimNext dispatch over push assignment | Accepted |
| 0003 | Lease-based at-most-once claiming over a hard lock | Accepted |
| 0004 | Kafka for integration events, with a CloudEvents-typed catalogue | Superseded (envelope) by ADR-0032 |
| 0005 | RFC 7807 application/problem+json for every error response | Accepted |
| 0006 | arch-go fitness tests to enforce the dependency rule | Accepted |
| 0007 | godog (Gherkin) acceptance tests for the invariants | Accepted |
| 0008 | Model Context Protocol as an inbound adapter, not a new service | Accepted (auth section superseded by ADR-0022) |
| 0009 | Fragile and hazmat handling flags carried on Task and Package | Accepted |
| 0010 | Live per-item DOT hazard classification, same-package segregation, and SortLane | Accepted (live lookup superseded by ADR-0039) |
| 0011 | Gift wrap handling flag carried on Task and Package | Accepted |
| 0012 | Per-service analytical data product (report) via a separate analytics topic | Accepted |
| 0013 | Adopt the fleet's micro-frontend console architecture — fulfillment-mfe, GET /tasks?orderRef=, and CORS | Accepted |
| 0014 | Labor-performance integration hooks — check-in/check-out wiring and TaskCompleted enrichment | Accepted |
| 0015 | Structural anti-corruption-layer seam for the (unbuilt) WCS tier | Accepted |
| 0016 | REBIN task type and OrderConsolidation, kept inside fulfillment-execution | Accepted |
| 0017 | Process-path catalogue as configuration, replacing the path_id-prefix guess | Accepted (Kafka-source boot order amended by ADR-0044) |
| 0018 | Installed-capacity read endpoint for workforce-management's capacity ceiling | Accepted |
| 0019 | Standard metrics convention across the fleet (Tier 1 baseline, Tier 2 naming) | Accepted |
| 0020 | Transactional outbox feeding both the integration and analytics topics from one table, with an in-process relay | Accepted (relay retry amended by ADR-0042) |
| 0021 | Adopt the fleet REST identity — static bearer keys with read/read-write scopes, AUTH_MODE rollout gate | Superseded by ADR-0022 |
| 0022 | Remove the REST + MCP static-bearer auth layer (fleet-wide auth removal) | Accepted |
| 0023 | Put the completed task's own type on TaskCompleted's wire payload, closing labor-performance's documented per-task-type gap | Accepted |
| 0024 | Optional Station.locationCode, validated against facility-layout's WorkCenter role | Accepted |
| 0025 | TaskCPTMissed sweep and PackageManifested on the outbox (companion to order-management ADR 0014 §5) | Accepted |
| 0026 | On-time-to-CPT KPI on the throughput analytics data product (companion to order-management ADR 0014 §6) | Accepted |
| 0027 | Migrate warehouse.fulfillment.events to a CloudEvents 1.0 structured envelope via a dual-read/dual-write bake period; companion to wes-work-planning's own envelope-migration ADR-0021 | Superseded by ADR-0032 |
| 0028 | Transactional Idempotency-Key middleware for POST /tasks, direct port of order-management ADR-0023 | Accepted |
| 0029 | Circuit breakers, jittered retry, dead-letter-queue hardening, and graceful shutdown for outbound dependencies, direct port of order-management ADR-0025 | Accepted (readiness also covers the Kafka catalogue warm-up, ADR-0044) |
| 0030 | Per-workload HorizontalPodAutoscaler and pgxpool MaxConns/statement_timeout tuning, direct port of order-management ADR-0026 | Accepted |
| 0031 | Run golang-migrate against a direct Postgres connection, not PgBouncer — direct port of order-management ADR-0029 | Accepted |
| 0032 | CloudEvents 1.0 as the mandatory event envelope — every Kafka message (integration + analytics), SDK-built, no flat/dual modes | Accepted |
| 0033 | Package read model — GET /packages/{id} and GET /packages?orderRef=; SLAM stays 204 | Accepted |
| 0034 | Optimistic/pessimistic concurrency for consolidation and claim CAS | Accepted |
| 0035 | Kafka hash partition key — every message keyed by its aggregate id; shared synchronous-writer settings | Accepted |
| 0036 | Transfer task types (DISPATCH/ARRIVAL), atomic WorkReleased consumption, and per-work_kind transfer completion facts | Accepted |
| 0037 | The two sweeps are scheduled by Helm CronJobs, on by default (expire-leases every minute, sweep-cpt-misses every 5 minutes) | Accepted |
| 0038 | SealPackage with a missing or expired lease returns task-not-claimed (like Complete/RenewLease); another station's active lease stays task-not-owner | Accepted |
| 0039 | Product classification from a local copy of product-master's ProductClassified events; PRODUCT_CLASSIFICATION_MODE=kafka|permissive, http rejected at boot | Accepted |
| 0040 | TaskCompleted v1 (both topics) carries an optional order_ref so inventory-storage confirms picks per order; short picks not modelled | Accepted |
| 0041 | WorkReleased.line_no is stamped on the Task (source_line_no, order work only) and TaskCompleted v1 (both topics) carries an optional line_no, so inventory-storage confirms the picked line (per-line confirm-pick) | Accepted |
| 0042 | Outbox relay attempt cap: a row that failed OUTBOX_MAX_ATTEMPTS sends (default 20, 0 = unlimited) is excluded from claims, logged at ERROR and kept for inspection; later same-key rows overtake it | Accepted |
| 0043 | The cmd/fulfillment-reports routes are specified in apis/openapi-reports.yaml, linted, rendered as a generated Reports API reference and contract-tested against the real router | Accepted |
| 0044 | With PATH_CATALOGUE_SOURCE=kafka the HTTP listener starts before the catalogue replay; /healthz answers at once, /readyz is 503 until the replay catches up, the WorkReleased consumer starts afterwards; a missed WaitReadyTimeout is still fatal | Accepted |
| 0045 | Migration 0018 drops the legacy domain_events table (created by 0001, never read or written); approved by the owner 2026-10-12 | Accepted |
| 0046 | The WorkReleased consumer fetches and commits only after a message is settled; a shutdown mid-handle neither dead-letters nor commits it, so it is redelivered and deduplicated (amends 0029) | Accepted |
| 0047 | RELOCATE tasks execute approved slot-plan moves: WorkReleased.data.relocation carries the move, completion takes the confirmed quantity and the scanned fromBin/toBin, and TaskCompleted gains the additive sku, from_bin, to_bin, quantity, relocation_ref (slotting-optimization ADR 0010) | Accepted |
| 0048 | The sweep CronJobs run /app/sweep: per-attempt timeout, bounded backed-off retry, non-zero exit on give-up, Istio sidecar quit on every exit path; the render fails when the retry budget does not fit activeDeadlineSeconds (amends 0037) | Accepted |
| 0049 | TaskAvailable and TaskClaimed on warehouse.fulfillment.events: raised from the same transaction as the pool change through the outbox; priority_band derives from the real claimNext ordering key (task type, CPT instant); only tasks with a determinable location are announced (RELOCATE at the time; REPLENISH since 0050, a sited PICK since 0062); consumer-first for task-interleaving | Accepted |
| 0050 | REPLENISH tasks execute pick-face replenishment moves, mirroring RELOCATE (0047): WorkReleased.data.replenishment carries the move, the pairing rule and the confirmed quantity apply, TaskCompleted gains the additive request_ref (inventory-storage ADR 0041 applies it as a REPLENISHMENT relocation), TaskAvailable announces both bins; claimNext still orders by CPT only, so URGENT is recorded but not sorted first | Accepted |
| 0051 | InterleavingHintIssued is consumed into a one-active-hint-per-station copy (interleaving_hints); claimNext uses the active, unexpired hint only as a tie-break among same-priority-band peers, never across a CPT boundary; fail-open everywhere; CloudEvents-id dedupe in the same transaction as the hint upsert | Accepted (consumer modes amended by ADR-0052) |
| 0052 | Postgres and Kafka are the only runtime of every cmd/ binary: boot errors naming the variable, no in-memory storage, log publisher or permissive/off mode, /readyz checks Postgres and a Kafka broker (never a topic), Idempotency-Key required, NUL is a client error, contract CI on real Postgres and Kafka, fitness test keeps the memory adapters out of cmd/ | Accepted |
| 0053 | PackageDiverted and WeightDiscrepancyDetected are published on warehouse.fulfillment.events as well as warehouse.fulfillment.analytics — same type, subject/key and byte-identical data — so exception-management can consume the SLAM divert facts; LeaseExpired is not promoted (amends 0032's publish list) | Accepted |
| 0054 | A PICK task confirms by EACH or CASE GTIN scan against a local PackView with a SKU guard; a BREAK_CASE task asks inventory-storage to break a sealed case with a stable Idempotency-Key; quantities stay in eaches | Proposed |
| 0055 | Amends 0054: pick scans require an Idempotency-Key and replay the stored answer on a retry (never double-count); BREAK_CASE is claimable through claim-next | Proposed |
| 0056 | Ship in own container: an order line that is exactly one full active CASE is sealed in the case itself (its GTIN, dims and weight), opt-in on seal-package, additive on the package and PackageSealed | Proposed |
| 0057 | A Kafka consumer or the outbox relay that returns while the service is meant to run ends the process (exit non-zero, pod restarted); a requested shutdown is clean; records the rule serveUntilSignal already implements and pins it with tests | Accepted |
| 0058 | Delegating work requests to Work Planning over A2A: outbound a2a-go/v2 client (real Agent Card discovery) behind a WorkPlanning port, driven by RequestNextWork over POST /paths/{pathId}/work-requests; the authoritative fact still returns as the WorkReleased CloudEvent | Accepted |
| 0059 | A2A inbound adapter (third driving adapter): cmd/a2a on :8093, two curated skills over the REST/MCP use cases, backlog_status (read) and complete_task (write, the one write MCP offers), message-only with in-band RFC 7807 problems; TaskCompleted still leaves through the transactional outbox; independent of the ADR-0058 outbound client | Accepted |
| 0060 | Adopt the fleet REST API guideline as a hard cutover: ten verb routes become nouns (task-claims, check-ins, completions, slam-runs, task-lease-expirations, ...), every POST behind one global Idempotency-Key middleware (409 idempotency-key-reused, Idempotency-Replayed, a 5xx is never stored), GET /tasks and GET /packages keyset-paged as {items,nextCursor} | Accepted |
| 0061 | PackageManifested carries the ship correlation outbound-shipping needs: additive optional site_id, source_order_id, cpt, weight_g (dataschema stays :v1, old bytes unchanged); ArriveAtRebin stamps the rebin PACK task's sourceOrderId so both package paths agree; site_id declared but omitted until a later wave sources it (sourced by ADR 0065) | Proposed |
| 0062 | A PICK whose plan carries both WorkReleased.data.pick.site_id and from_bin (the producer's additive omit-when-unknown contract) gets a Placement and is announced with TaskAvailable, the pick face as both ends of the trip; a pick missing either is not announced and can only be an anchor, never a companion; TaskAvailable stays :v1, and every consumer of the topic must tolerate task_type: "PICK" | Accepted |
| 0063 | A WorkBatch (one station's pick walk) forms at assignment time behind PICK_BATCH_MODE off|shadow|on (fleet default off): the anchor is exactly what ClaimNext would return — same shared claimer — companions are hinted same-CPT-band candidates in rank order filtered by capability and cart segregation, claimed per task compare-and-set; lease renewal covers every open member, an expired member detaches through the existing sweep; TaskCompleted gains optional batch_id/batch_size and WorkBatchFormed/Completed/Abandoned go to both topics; three REST routes and the get_work_batch MCP tool | Accepted |
| 0064 | The work clock runs per stop behind the batch: work_started_at (migration 0026, NULL = claim time so every pre-batching row keeps today's duration), a batched pick's clock starts when the previous stop completes, and duration_seconds uses DurationBase() so a non-batched TaskCompleted stays byte-identical | Accepted |
| 0065 | The order's fulfillment site travels from WorkReleased.site_id to PackageManifested.site_id: order work keeps it as tasks.order_site_id (migration 0028; invalid or absent = no site, never a DLQ; transfer work unchanged), the rebin PACK task inherits it from the order's PICK tasks through TaskRepo.FindBySourceOrderId (nothing added to POST /rebin/arrivals), and PackageManifested publishes site_id and falls back to the PACK task's CPT for cpt when the order has no SLAM task (a SLAM task's CPT still wins) | Proposed |