Skip to main content

Business Context

Written here from the context's own introduction, its integration page and its ADRs under docs/adr/ in IQVO/task-interleaving (0001 to 0005, all Accepted 2026-10-17), checked against the code on develop. Where the code has moved past an ADR's wording, the code is authoritative.

The gap​

fulfillment-execution hands out work through the pull-based claimNext(stationId, capabilities): the system selects the task, and a lease protects a claim. Nothing in the fleet asked which open task is close to where this operator now stands. An operator who finishes in aisle A01 can be sent to aisle A19 while a task two bins away waits, so travel, the largest share of picking labour, is spent without a policy. Task interleaving (task chaining, dual command cycling) is the usual warehouse-execution answer: weigh the travel from the end of one task to the start of the next.

It could be a rule inside claimNext. It is a separate context, by decision, only while three properties hold (ADR 0001): the output is advisory, the context never issues an assign, and it owns no task state. If any of them is dropped, the logic belongs back in fulfillment-execution.

What it owns​

FactValue
Subdomain classSupporting (ADR 0001)
TierWES (CloudEvents subdomain segment wes)
AggregatesInterleavingPolicy (package internal/domain/policy, one per site) and StationTrip (package internal/domain/stationtrip, one per station), ADR 0002
Recommenderthe pure function recommend.Recommend, with the travel.Model port (v1: rectilinear-v1)
Binariesfour: cmd/api (REST on HTTP_ADDR, default :8080, plus two Kafka consumers, the hint-expiry worker and the outbox relay as goroutines), cmd/mcp (read-only MCP server, ADR 0007), cmd/ti-projector and cmd/ti-reports (the analytics read side, ADR 0008)
Data storeone Postgres database (embedded migrations) plus a separate analytics database written only by the projector. DATABASE_URL is required: Postgres and Kafka are the only runtime (ADR 0006)
Kafkapublishes warehouse.task-interleaving.events and warehouse.task-interleaving.analytics; consumes warehouse.fulfillment.events and warehouse.facility.events (ADR 0003, ADR 0004)
Authnone (fleet-wide decision)
  • The policy. Per site: MaxDetourM (greater than 0), MaxCandidates (1 to 5), HintTTL, EligibleTaskTypes (a non-empty subset of PICK, PACK, REBIN, SLAM, RELOCATE, REPLENISH), VerticalWeight (at least 0) and a version. Declared with PUT /sites/{siteId}/policy under If-Match optimistic concurrency. A site with no policy is inert: no hint, by design. Declaring publishes the analytics-only fact InterleavingPolicyDeclared.
  • The station trip. Where the operator stands (the end location of the last completed task) and the most recent hint: Active, then Consumed, Expired or Superseded. At most one hint is Active per station. A hint is Consumed when the station claims one of its candidates before it expires.
  • The recommender. From the station's origin, the open-task pool and the policy it returns the candidates of the same site, of an eligible type, not the task just completed, with known geometry and a detour at most MaxDetourM, ranked by detour then task id, cut to MaxCandidates. The result does not depend on the order of the pool. An empty result issues no hint.

The v1 policy​

Deterministic and explainable (ADR 0002; see the Ubiquitous Language):

  1. Detour = the distance from the origin to the candidate's from_location, |dx| + |dy| + verticalWeight * |dz| in metres, rounded to 0.1 m (rectilinear-v1). A location with no geometry has an unknown distance: it is never a candidate, and as an origin it yields no hint.
  2. Ranking is by detour ascending, then task id ascending, so a hint is reproducible from the same pool and position.
  3. Expiry: expires_at = issued_at + HintTTL; the expiry worker sweeps Active hints past it (default every 5 s, HINT_EXPIRY_INTERVAL).
  4. A completion that leaves no candidate issues no hint and does not retract an older Active hint; that one expires at its TTL (ADR 0002).

Aisle geometry, cross-aisle routes and fixed structures are planned refinements behind the same travel.Model port. They do not exist today.

Main capabilities​

CapabilityInterfaceUse case
Declare and read a site policyPUT/GET /sites/{siteId}/policyDeclarePolicy, GetPolicy; see Use Cases
Read hints and a station's tripGET /hints, GET /hints/{hintId}, GET /stations/{stationId}ListHints, GetHint, GetStation
Simulate the recommender, read-onlyPOST /recommendationsRecommend
Keep the open-task pool currentKafka consumer (FULFILLMENT_MODE=kafka)ApplyTaskAvailable, ApplyTaskClaimed
Record a completion and issue a hintthe same consumer, on TaskCompletedApplyTaskCompleted
Keep the location geometry currentKafka consumer (LAYOUT_MODE=kafka)ApplyZone, ApplyLocationRegistered, ApplyLocationDecommissioned, ApplyGeometryUpdated
Expire hintsthe expiry workerExpireHints
Publish hints and their outcometransactional outbox + relay (needs DATABASE_URL and KAFKA_BROKERS)every write use case

The write endpoint takes an Idempotency-Key that is enforced with Postgres. The full catalogue is on Use Cases.

What it deliberately does not do​

  • Own tasks, claims or locations. It keeps event-fed local copies (task_pool, zones, locations) and never calls a sibling at request time. It makes no outbound HTTP or MCP call at all, and nothing calls it on the hot claim path.
  • Assign work. There is no assign; claimNext stays the only claim path. A hint that is ignored costs nothing.
  • Interpret priority. priority_band is carried and never read.
  • Know the associate. Hints are per station.
  • Retract a hint. An outdated hint expires on its TTL.

It has no edge to wes-work-planning, process-path-management, order-management, inventory-storage, labor-performance or pick-face-replenishment (ADR 0001). A REPLENISH task reaches it only as an ordinary TaskAvailable.

Honest scope today​

  • The service is built on IQVO/task-interleaving develop: REST API, Postgres repositories, outbox and relay, the expiry worker, the two consumers, the read-only MCP server, the analytics projector and reports, the console remote and the BDD and architecture fitness suites. This site holds its apis/task-interleaving/ specs, the generated references and the synced artifact pack and operations pages.
  • It is wired in warehouse-infra develop: terraform/apps.yaml registers it (database, analytics database, web remote) and helm-values/task-interleaving.yaml sets both consumer groups. Its Kong path is /api/task-interleaving. The kind cluster was not checked for this page.
  • The inputs are built and wired on both sides. fulfillment-execution publishes TaskAvailable and TaskClaimed (its ADR 0049) and TaskCompleted, and facility-layout publishes the zone, location and geometry events. TaskAvailable is announced only for tasks that carry bins (today RELOCATE and REPLENISH, its ADR 0049 and ADR 0050), so the pool, and with it every hint, contains those task types.
  • The output has a consumer. fulfillment-execution reads InterleavingHintIssued (its ADR 0051) and uses it only as a tie-break inside one claimNext priority band; warehouse-infra develop sets TASK_INTERLEAVING_MODE=kafka for it.
  • Live-data findings owed (ADR 0003): whether the pool's site_id values equal facility-layout's siteCode values, what share of pool task locations has a geometry point, and whether the geometry frame is the same for every location of a site. None can be answered before the service runs against real rows.
  • The analytics topic is read only by this context's own projector.