0064. The per-stop work clock
Status
Accepted (2026-11-14; first Proposed 2026-11-08, built since: see the Addendum). Pick-batching wave 3; companion to ADR 0063.
Context
TaskCompleted.duration_seconds is completion minus claim time, and
labor-performance recovers each claim instant from it. If a batched
picker's first stop is claimed at 10:00 and the last stop completes at
10:20, a claim-based clock books all twenty minutes against every stop:
batched pickers look slow, exactly the failure mode the plan flagged
("labor timing must stay per stop"). Each stop's clock must start when the
previous stop completes — the NextStopClock policy — and nothing outside a
batch may change by a byte, because labor-performance parses today's
payloads as-is.
Decision
Taskgainswork_started_at(migration 0026, nullable). NULL means the claim time, so every existing row and every task outside a batch keeps exactly today's duration.StartWork(at)stamps it. The batch lifecycle hooks call it: the first member's clock starts at its claim (identical to today), each later member when the previous stop completes. A NULL-safeDurationBase()returnswork_started_atwhen set, else the claim time.publisher_encode.gousesDurationBase()in place ofClaimedAt()forduration_seconds. The golden test for a non-batched task (work_started_at NULL) stays byte-identical, which is the proof the change is invisible outside a batch.
Consequences
- Per-stop durations sum to the walk with zero idle gap between stops and the true idle gap only after the batch's last stop, which is what labor-performance's idleness recovery needs.
- No consumer change: the field is the same
duration_secondsv1 payload, only its meaning sharpens for batched picks, andbatch_id(ADR 0063) is how the consumer tells the two apart. - Standards (ADR 0004) stay frozen; whether batched picks beating a single-pick standard warrants a revision is a human decision after wave 4 data.
Addendum (2026-11-13): current state
Built and on develop (PR #280): tasks.work_started_at is migration 0026_task_work_started_at; Task.StartWork and Task.DurationBase are in internal/domain/task/task.go:319 and :338; CompleteTask starts the next member's clock (internal/application/usecases/complete_task.go:119); and duration_seconds is measured from DurationBase() (internal/adapters/outbound/kafka/publisher_encode.go:32). The Status line above was flipped to Accepted on 2026-11-14.