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:
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.
|
||||
|
||||
Reference in new issue
Block a user