Relationships
#5001 A child swamp run on a behavior its parent run holds waits out the lock timeout; docs say it skips the lock
Opened by skunk-ape · 11/22/2026
What happens
A method on behavior X holds X's per-behavior lock while it runs. If that method starts a separate swamp process (a shell step, the command/shell behavior, or Deno.Command) and the child runs a method on X, directly or through its own context.runModel, the child waits on the parent's lock. The parent is usually awaiting the child, so the two deadlock until the child hits the lock timeout (60 s by default) and exits 75.
The concurrency reference in the swamp skill says the opposite: "a child swamp command run from a shell step skips the per-behavior locks held for the run that started it". In the code only structural drains (waitForPerModelLocks, used by commands such as swamp data gc) consult the handed-down lock information (LockHolderMarker.lockRelation()). A per-behavior acquire (acquireModelLocks, FileLock) never does, so a per-behavior run in a child always waits.
Steps to reproduce
swamp inita repo with the default filesystem datastore.- Add an extension behavior
@repro/spawnerwith two methods:noop(returns{}), andgo, which runs a childswamp behavior run spw noopthroughDeno.Command, passingSWAMP_LOCK_TIMEOUT_MS=3000in the child's env, and throws if the child exits non-zero. swamp behavior create @repro/spawner spw, thenswamp behavior run spw go.
The child exits 75 with a lock timeout on .swamp/data/@repro/spawner/<id>/.lock, held by the parent's pid. Reproduced on swamp 20261120.161258.0.
Expected
- The concurrency reference describes what the code does: structural commands skip locks held for the run that started them, but a per-behavior run in a child process waits for them.
- A child's per-behavior lock request that finds the lock held for the run that started it (
lockRelation()returnsancestor) fails at once with a clear error. The error names the behavior, says the parent run holds it, and suggests callingcontext.runModelin-process instead (it reuses the lock the call chain holds) or moving the child into a workflow step of its own. That replaces a silent wait to the timeout.
Out of scope
Letting the child run under the parent's lock. That needs the child to join the parent's lease, so the child's writes stay fenced and published in team and custom datastores; it belongs with the work on a child process joining its parent's lease.
Open
No activity in this phase yet.
Sign in to post a ripple.