Skip to main content
← Back to list
01Issue
BugOpenSwamp CLIPublic
AssigneesNone

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

  1. swamp init a repo with the default filesystem datastore.
  2. Add an extension behavior @repro/spawner with two methods: noop (returns {}), and go, which runs a child swamp behavior run spw noop through Deno.Command, passing SWAMP_LOCK_TIMEOUT_MS=3000 in the child's env, and throws if the child exits non-zero.
  3. swamp behavior create @repro/spawner spw, then swamp 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

  1. 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.
  2. A child's per-behavior lock request that finds the lock held for the run that started it (lockRelation() returns ancestor) fails at once with a clear error. The error names the behavior, says the parent run holds it, and suggests calling context.runModel in-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.

02Bog Flow
◉OPEN○TRIAGED○IN PROGRESS○SHIPPED

Open

11/22/2026, 6:36:28 PM

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.