Skip to main content

Sequence diagrams

UML sequence diagrams of the key scenarios, with error branches. Every participant is code on develop; where a message names a Go function it is a function that exists, and the order of steps follows the use cases in internal/application/usecases.

Complete a task, issue a hint​

Source: internal/application/usecases/apply_task_completed.go, intake.go, ranker.go, StationTrip.RecordCompletion, StationTrip.IssueHint, recommend.Recommend, internal/adapters/inbound/kafka/consumer.go, internal/adapters/outbound/events/sink.go. A transient failure rolls the unit of work back (which un-claims the event id), the consumer retries the same message with backoff and, after 5 attempts, publishes it to warehouse.fulfillment.events.dlq. A save that loses a version race is such a transient failure. The relay publishes only when DATABASE_URL and KAFKA_BROKERS are set.

The flow is the same for every task type, PICK included (ADR 0012): nothing in the use case, the pool or recommend.Recommend branches on the type, so a TaskCompleted of an announced PICK task moves the station to the pick face (its to_location, equal to its from_location), and the ranking interleaves PICK, RELOCATE and REPLENISH candidates by detour, then task id. The only type-dependent input is the site policy's eligibleTaskTypes.

The hinted station claims a candidate​

Source: internal/application/usecases/apply_task_claimed.go, StationTrip.RecordClaim, apis/asyncapi.yaml (TaskClaimed) and fulfillment-execution's apis/asyncapi.yaml (the producer, with claimed_at).

A hint expires​

Source: internal/adapters/inbound/expiry/worker.go, internal/application/usecases/expire_hints.go, StationTrip.Expire. The worker runs in both storage modes.

Declare a policy​

Source: internal/application/usecases/declare_policy.go, internal/adapters/inbound/http/policy_handlers.go, errors.go, policy.New, Policy.WithChanges, apis/openapi.yaml (declareInterleavingPolicy). The PUT is not wrapped by the Idempotency-Key middleware; the version check is its concurrency control.

Simulate a recommendation​

Source: internal/application/usecases/recommend.go, internal/adapters/inbound/http/recommend_handler.go, idempotency.go, recommend.Recommend, apis/openapi.yaml (recommendTasks). A FINAL refusal is rolled back and stored on its own so the same key replays the same rejection; a RETRYABLE refusal (the three 422s) and a 5xx are never stored: the key is released and a retry executes again (ADR 0013).