Skip to main content

Task Interleaving

Supporting Subdomain

Task Interleaving is one of the fleet's sixteen domain bounded contexts. It sits in the wes tier of the CloudEvents subdomain taxonomy and is the youngest context of the fleet. When a station completes a task, it looks at the open tasks of the site, ranks them by the detour from the place where the operator now stands to the place each task starts (a pure function over an event-fed copy of the open-task pool and of the location geometry), and issues an interleaving hint: a short, ranked, expiring list of candidate tasks. Operators chain nearby work instead of walking empty.

The hint is advisory. fulfillment-execution stays pull-based (claimNext remains its only claim path) and would use a hint only as a tie-break inside one priority band, failing open when the hint is absent, expired or unknown. This context never assigns work and never writes task state (its ADR 0001).

What is built, what is deployed, and what is planned

Per this context's own Context Map and integration page, checked against develop (and, for deployment, warehouse-infra develop):

Built on develop (df901f1): the REST API (ten path × method pairs in apis/openapi.yaml, including the two analytics report routes, /healthz and /readyz), Postgres repositories with embedded migrations, the transactional outbox and relay, a hint-expiry worker (default sweep 5 s), and two Kafka consumers (open tasks, claims and completions from fulfillment-execution; zones, locations and geometry from facility-layout) with retry, a dead-letter topic and processed-event de-duplication. Postgres and Kafka are the only runtime (its ADR 0006): DATABASE_URL is required, each consumer's mode must be kafka (permissive is a boot error) and its group variable must be set. It ships four binaries: cmd/api, a read-only MCP server (cmd/mcp, ADR 0007) and the analytics read side cmd/ti-projector + cmd/ti-reports (ADR 0008), plus a Dockerfile, a Helm chart and the console remote task_interleaving_mfe.

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 and the analytics projector, so the consumed edges K41, K45 and K46 are live. warehouse-ops-agent has an MCP client for it (internal/adapters/outbound/mcpclient/task_interleaving.go). The kind cluster was not checked.

Its one output edge is live too: fulfillment-execution consumes InterleavingHintIssued (its ADR 0051) and uses it only as a tie-break inside one claimNext priority band; warehouse-infra sets TASK_INTERLEAVING_MODE=kafka with its own consumer group for it (edge K47).

Only some tasks reach the pool. fulfillment-execution announces TaskAvailable for RELOCATE and REPLENISH tasks only, because only those carry bins. A PICK, PACK, SLAM or REBIN task has no location in that service. The candidate list is therefore made of those two task types, and a station's position is recorded only when it completes an announced task.

Planned, not built: wider pool coverage (tasks without bins are never announced).

It owns two aggregates, a pure recommender and a travel model:

  • InterleavingPolicy (package internal/domain/policy): one per site. How far (MaxDetourM), how many candidates (MaxCandidates, 1 to 5), how long (HintTTL), which task types are eligible, and how much vertical travel weighs. A site with no policy is inert: it issues no hint. Declared with PUT /sites/{siteId}/policy under If-Match optimistic concurrency.
  • StationTrip (package internal/domain/stationtrip): one per station. Where the operator stands (the end of the last completed task) and the most recent hint, in the states Active, Consumed, Expired or Superseded. At most one hint is Active.
  • The recommender (package internal/domain/recommend): the pure function that ranks candidates by detour, then task id.
  • The travel model (package internal/domain/travel): the port behind the distance, rectilinear-v1 in v1 (|dx| + |dy| + verticalWeight * |dz|, in metres). Unknown geometry is unknown, never zero.

This context's pages​

Elsewhere​