Relationships
#4998 v3: a swamp child process started from inside a method can't join its parent's writer lease, so it waits 60 s and fails
Opened by skunk-ape · 11/22/2026
What happens
On a local v3 datastore with no serve, a method that runs swamp as a child process (for example to run another behavior or workflow) deadlocks against its own parent. The parent CLI command holds the datastore's writer lease for its whole life (#4993). The child is a new process, asks for the lease, waits the full lock timeout (60 s by default) and exits 75 with datastore_v3_writer_busy.
Per-behavior locks already handle this case. A parent passes the locks it holds to its children through SWAMP_LOCK_HOLDER_TOKENS, so a child joins them and doesn't wait. The v3 writer lease isn't part of that hand-off.
On v2, and on v3 through swamp serve, the same child process works.
We found this while making stagecraft publish to a tracker from inside a write: its child-process publish route can't work on local v3 without serve. Stagecraft now uses an in-process route where context.runModel() allows it.
Steps to reproduce
swamp repo initandswamp datastore setup filesystem --path ~/ds3 --format 3. Don't start serve.- Write an extension method that runs
swamp behavior run <other> <method>as a child process and waits for it. - Run that method with
swamp behavior run.
Actual: the child waits about 60 s, then exits 75, datastore_v3_writer_busy, naming the parent's pid. Expected: the child joins the parent's lease and runs, as it does for per-behavior locks.
Measured on swamp 20261120.161258 (sha 7b758e05).
Cause
- The token hand-off lives in
src/domain/datastore/lock_holder_marker.ts(SWAMP_LOCK_HOLDER_TOKENS, line 41;childLockEnv). It carries per-behavior lock tokens only. Nothing there covers the writer lease. - The writer lease is reference-counted per process (
src/infrastructure/datastore_v3/v3_writer_lock.ts:138,:153-178), so a child process can't share it today.
Suggested fix
Extend the hand-off to the writer lease: the parent passes a lease token in the child's environment, and the child's holdV3Writer joins the parent's hold rather than taking a new one, while the parent is alive and still holds it. Check against the checkout protection, the writer marker and interrupted-writer recovery, which assume one writing process per checkout.
This is part of the v3 write-model decision in #4993 (the whole-command lease hold). If #4993 moves to a per-commit lease, this changes shape, so decide them together.
Version
swamp 20261120.161258 (sha 7b758e05). Code references to main at e52c839ba.
Open
No activity in this phase yet.
Sign in to post a ripple.