Repository navigation
Description
Problem
Strict admission (ConcurrencyReservation, queue caps) is scoped to a claimed node attempt, not to a run. There is no declaration that means "hold this slot from the run's first executable operation until its final one", so a keyed run cannot own exclusion across its own graph.
For any workload where a graph is a sequence of phases over one shared resource — not a fan-out of independent work — this is the difference between serialization and interleaving. Two runs of the same key are each individually compliant with a one-slot reservation on every node, and still legally interleave their bodies:
A.first → B.first → A.second → B.second # all four legal under per-node one-slot reservations
max_concurrent does not fix it (explicitly a per-round damper), max_in_flight does not (per-run materialization, not run exclusion), and run keys do not (they dedupe identities; different keys for the same logical source are legal and coexist).
Evidence
docs/guides/workflows.md:981-994— the capacity surface:reservationsis the strict instrument per row,max_concurrentthe damper.src/taskq/worker/run.py:1099-1106— the flow attempt's acquired slot is released in the door's ownfinally, per attempt: "the flow attempt is over — succeeded, laddered, held …, the queue's capacity is back before this worker claims again." Every node therefore re-acquires independently.docs/api-reference/workflows.md:160-174—capacity_owner/max_pendingare per-cohort (actor), not per-run;max_pendingis deliberately absent from the workflow create surface.src/taskq/workflows/chain.py:202-232— aChainhas one actor/queue for every row of every record; no run-scoped capacity term exists to attach.
Holding an outer vanilla actor's reservation while waiting for the flow does work, but then the actor remains the lifecycle owner and the flow has not replaced it — which defeats the purpose of expressing the pipeline as a flow.
Minimal conceptual repro
Two flows, A and B, both first → second, every node declared reservations=[ConcurrencyReservation(name="the-resource", slots=1)]. Run A, then B one second later, with a two-worker fleet and distinct run keys. Both first bodies are claimable in that order; A's second waits behind B's first. A test asserting "no other run's body entered between A.first and A.second" fails, and there is no declaration available that would make it pass.
What the engine would need
A run-scoped (keyed) lease with an explicit acquire point (first executable node) and release point (run terminal, including failure/cancel/crash-reclaim), inherited by every node of the run and re-acquired across attempts and workers. It must be strict in the same sense as ConcurrencyReservation (leased rows, not a read-then-claim count), and it must survive the fleet-reclaim path, not just the happy path.
Two acceptable shapes:
run_reservations=[...]oncreate_flow/the app: the lease is acquired when the root becomes executable and released when the run terminalizes.- A first-class "lease holder" node kind whose body owns the slot and whose exit is safe to defer — but this must not require the caller to keep an actor outside the graph, or the benefit is gone.
The failure modes to pin: crash during the run, cancel while running, deploy/SIGTERM mid-run, retry ladder re-pend, and two workers racing the release. A per-node finally is the wrong seam for all five.
Not in scope of this issue
Per-node capacity terms on the chain-source surface (#716), emit backpressure (#718), cancellation visibility inside bodies (#720). This issue is only run-scoped exclusion.
Activity