PR #161 · SPEC-C2 · Dispatch State Machine
feat(harness): SPEC-C2 dispatch state machine
What
Implements turn lifecycle (QUEUED → DISPATCHING → RUNNING → DONE/FAILED/CANCELLED) plus a sweeper that reconciles stuck rows and caps concurrency.
Why now
Without durable dispatch, async turns can leak: tasks run forever, heartbeats stall, or duplicate kicks spawn multiple workers.
What changed
think2earn_turn_dispatch table with byStatus index; dispatchNext sweeper logic; per-user concurrency (3) and global cap; orphan-task guard via DescribeTasks; heartbeat staleness detection.
Risk / trade-off
State machines have edge cases. Tests cover idempotency, redelivery, cancellation, and crash paths. Production soak recommended.
Money & ops
Prevents runaway Fargate tasks. Caps concurrent spend. Gives users queue position visibility.
CEO decision
Approve. Merge after SPEC-000 foundation and before C4 worker wiring.