feat(statestore): enforce the execution transition table and map ErrIllegalTransition over the wire

Every caller-supplied status write (Transition, ParkTask, Requeue,
RetryTask, BeginRemediation) now checks the shared taskstate transition
table inside the write's transaction, after the from guard decides
staleness. An off-table pair returns the new storecontract.ErrIllegalTransition,
carried over gRPC through mapError/unmapError on (FailedPrecondition,
"illegal transition"). Claim, BeginRemediation and RecoverStale pin
their pairs in SQL; a test pins those pairs to the table so a query
edit cannot move a write off it. Requeue/RetryTask share one guarded
requeue body. (archie-core-qdbo.5)
This commit is contained in:
sam committed 2026-09-26 13:13:20 +10:00
1 parent e7e3ea9d49
commit 71d98fe9b4
8 files changed
+274 -33

No files matched your search

@@ -73,6 +73,12 @@ UPDATE tasks SET workflow = $2, stage = $3, branch = $4, plan = $5, notes = $6,
updated_at = now()
WHERE id = $1;
-- name: LockTaskStatus :one
-- Locks the task's row and returns its current status, so the staleness and
-- transition-table checks that decide a guarded write hold against a
-- concurrent claim or transition until the update in the same transaction.
SELECT status FROM tasks WHERE id = $1 FOR UPDATE;
-- name: TransitionTask :execrows
-- Arriving at 'parked' also records why. The class is normalized by the
-- caller, so an unknown value persists as needs_human rather than as itself.