Skip to main content

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​

  1. Copy the template above into docs/docs/adr/NNNN-short-kebab-title.md, taking the next free number.
  2. Set the status to Proposed and open a PR.
  3. Discuss in review. If the decision changes shape, edit the PR — the immutability rule starts at acceptance, not at drafting.
  4. On merge, set the status to Accepted.
  5. 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​

#TitleStatus
0001Hexagonal (ports and adapters) architectureAccepted
0002Pull-based claimNext dispatch over push assignmentAccepted
0003Lease-based at-most-once claiming over a hard lockAccepted
0004Kafka for integration events, with a CloudEvents-typed catalogueSuperseded (envelope) by ADR-0032
0005RFC 7807 application/problem+json for every error responseAccepted
0006arch-go fitness tests to enforce the dependency ruleAccepted
0007godog (Gherkin) acceptance tests for the invariantsAccepted
0008Model Context Protocol as an inbound adapter, not a new serviceAccepted (auth section superseded by ADR-0022)
0009Fragile and hazmat handling flags carried on Task and PackageAccepted
0010Live per-item DOT hazard classification, same-package segregation, and SortLaneAccepted (live lookup superseded by ADR-0039)
0011Gift wrap handling flag carried on Task and PackageAccepted
0012Per-service analytical data product (report) via a separate analytics topicAccepted
0013Adopt the fleet's micro-frontend console architecture — fulfillment-mfe, GET /tasks?orderRef=, and CORSAccepted
0014Labor-performance integration hooks — check-in/check-out wiring and TaskCompleted enrichmentAccepted
0015Structural anti-corruption-layer seam for the (unbuilt) WCS tierAccepted
0016REBIN task type and OrderConsolidation, kept inside fulfillment-executionAccepted
0017Process-path catalogue as configuration, replacing the path_id-prefix guessAccepted (Kafka-source boot order amended by ADR-0044)
0018Installed-capacity read endpoint for workforce-management's capacity ceilingAccepted
0019Standard metrics convention across the fleet (Tier 1 baseline, Tier 2 naming)Accepted
0020Transactional outbox feeding both the integration and analytics topics from one table, with an in-process relayAccepted (relay retry amended by ADR-0042)
0021Adopt the fleet REST identity — static bearer keys with read/read-write scopes, AUTH_MODE rollout gateSuperseded by ADR-0022
0022Remove the REST + MCP static-bearer auth layer (fleet-wide auth removal)Accepted
0023Put the completed task's own type on TaskCompleted's wire payload, closing labor-performance's documented per-task-type gapAccepted
0024Optional Station.locationCode, validated against facility-layout's WorkCenter roleAccepted
0025TaskCPTMissed sweep and PackageManifested on the outbox (companion to order-management ADR 0014 §5)Accepted
0026On-time-to-CPT KPI on the throughput analytics data product (companion to order-management ADR 0014 §6)Accepted
0027Migrate 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-0021Superseded by ADR-0032
0028Transactional Idempotency-Key middleware for POST /tasks, direct port of order-management ADR-0023Accepted
0029Circuit breakers, jittered retry, dead-letter-queue hardening, and graceful shutdown for outbound dependencies, direct port of order-management ADR-0025Accepted (readiness also covers the Kafka catalogue warm-up, ADR-0044)
0030Per-workload HorizontalPodAutoscaler and pgxpool MaxConns/statement_timeout tuning, direct port of order-management ADR-0026Accepted
0031Run golang-migrate against a direct Postgres connection, not PgBouncer — direct port of order-management ADR-0029Accepted
0032CloudEvents 1.0 as the mandatory event envelope — every Kafka message (integration + analytics), SDK-built, no flat/dual modesAccepted
0033Package read model — GET /packages/{id} and GET /packages?orderRef=; SLAM stays 204Accepted
0034Optimistic/pessimistic concurrency for consolidation and claim CASAccepted
0035Kafka hash partition key — every message keyed by its aggregate id; shared synchronous-writer settingsAccepted
0036Transfer task types (DISPATCH/ARRIVAL), atomic WorkReleased consumption, and per-work_kind transfer completion factsAccepted
0037The two sweeps are scheduled by Helm CronJobs, on by default (expire-leases every minute, sweep-cpt-misses every 5 minutes)Accepted
0038SealPackage with a missing or expired lease returns task-not-claimed (like Complete/RenewLease); another station's active lease stays task-not-ownerAccepted
0039Product classification from a local copy of product-master's ProductClassified events; PRODUCT_CLASSIFICATION_MODE=kafka|permissive, http rejected at bootAccepted
0040TaskCompleted v1 (both topics) carries an optional order_ref so inventory-storage confirms picks per order; short picks not modelledAccepted
0041WorkReleased.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
0042Outbox 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 itAccepted
0043The 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 routerAccepted
0044With 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 fatalAccepted
0045Migration 0018 drops the legacy domain_events table (created by 0001, never read or written); approved by the owner 2026-10-12Accepted
0046The 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
0047RELOCATE 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
0048The 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
0049TaskAvailable 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-interleavingAccepted
0050REPLENISH 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 firstAccepted
0051InterleavingHintIssued 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 upsertAccepted (consumer modes amended by ADR-0052)
0052Postgres 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
0053PackageDiverted 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
0054A 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 eachesProposed
0055Amends 0054: pick scans require an Idempotency-Key and replay the stored answer on a retry (never double-count); BREAK_CASE is claimable through claim-nextProposed
0056Ship 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 PackageSealedProposed
0057A 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 testsAccepted
0058Delegating 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 CloudEventAccepted
0059A2A 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 clientAccepted
0060Adopt 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
0061PackageManifested 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
0062A 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
0063A 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 toolAccepted
0064The 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-identicalAccepted
0065The 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