Skip to main content

Stations

The Station aggregate: a work position with a capability set, occupied by at most one worker/robot at a time. Covers registration (which also serves as idempotent re-certification), check-in/ check-out of the occupant (see ADR-0014), and is the entry point for PULL dispatch (task-claims is a Station action).

๐Ÿ“„๏ธRegister or re-register a station

Creates a station with the given capability set, or โ€” if `stationId` already exists โ€” replaces its capability set (e.g. recertifying a station for a new capability). This is deliberately idempotent by client-supplied id: re-registering the same `stationId` upserts rather than erroring or duplicating, which is what closes the pull-dispatch gap for HTTP-only smoke testing (without this endpoint there is no way to create a station over HTTP, so `task-claims` against a freshly started server always 404s).

๐Ÿ“„๏ธPULL-dispatch the best-fit pending task to this station

Implements this service's core dispatch rule: **pull, not push**. The station calls claimNext; the system โ€” never the caller โ€” selects which task to hand it. Among Pending tasks of `taskType` that this station's registered capabilities satisfy, the **earliest-CPT** task is selected and leased to `stationId` for a fixed duration (5 minutes by default). Assignment is **at-most-once**: a task with an active, unexpired lease cannot be claimed by anyone else, and this endpoint will simply skip it and try the next-best candidate. If the lease is not renewed or the task completed before it expires, the task automatically returns to the pool (see `POST /task-lease-expirations`) rather than being lost. This call is not idempotent in the way a PUT would be โ€” every successful call claims a *different* task (or the same task again only after its prior lease was released); that's intended PULL semantics, not a bug.

๐Ÿ“„๏ธForm this station's pick walk (ADR 0063)

Pick batching behind the `PICK_BATCH_MODE` rollout gate. The anchor is exactly the task `POST /stations/{stationId}/task-claims` with `taskType: PICK` would return (the same claimer selects it), so batching never changes who goes first; companions are the station's interleaving-hint candidates inside the anchor's CPT band, in hint rank order, kept only when the station can do them and the cart segregation matrix allows sharing, up to the configured maximum (default 4). A batch of one is valid; nothing waits for a batch to fill. With the mode not `on` (the fleet default is `off`) the surface answers 503 batch-mode-off and `task-claims` is the only dispatch path, exactly as before.

๐Ÿ“„๏ธCheck a worker or robot into a station

Assigns an occupant to a station โ€” the Station aggregate's `CheckIn` invariant enforced through the application layer: one occupant at a time. This is operational state, not a labor-performance domain event in its own right (see [ADR-0014](/docs/adr/0014-labor-performance-integration-hooks)): no domain event is published by this endpoint. The checked-in occupant is instead surfaced, best-effort, as `associateId` on the `TaskCompleted` Kafka event when a task claimed by this station is later completed.

๐Ÿ“„๏ธRead how many registered stations hold a given capability (read model)

A projection over the Station registry, not a staffing count: returns how many currently-registered stations hold `capability`, regardless of occupancy. This is the raw installed ceiling a process path can ever be staffed up to โ€” workforce-management's CommitShiftPlan calls this endpoint to enforce `plannedHeads` against reality, live, instead of trusting a caller-supplied installed-station count alone (see this repo's ADR-0018). Read-only โ€” never mutates state. An unrecognized `capability` is not an error; it simply has an installed count of `0`, the same 'count over existing rows, not a lookup against a fixed enum' contract `getQueueDepth` already uses.