You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your ses
8000
sion.Dismiss alert
{{ message }}
Repository navigation
PTY lock admission is too blunt: surface a locked state with recovery #244
handlesTerminal in packages/deck/app/lib/runner/registry.server.ts treats an existing .runner.lock, or any lstatSync error on it, as "a PTY session owns this agent", whatever the instance flag says. This is deliberate fail-closed behaviour (it prevents two writers on one conversation), but it is blunt. Follow-up to #241.
Situations wrongly blocked
The PTY flag is off on purpose (MC_PTY_RUNNER=0 or unset) and a lock is left from a prior run: tmux is blocked, but with the flag off Deck also refuses PTY start, recovery and controls.
A stale lock after a crash, before recovery has run.
A filesystem error (EACCES, EPERM, ELOOP) on the lock path is treated as an active PTY session.
What the user sees
A blank terminal viewport, refused compose sends ("The PTY session is not running or no longer opted in"), wake and push silently dropped, and no Start or Stop controls. There is no recovery route in the UI.
Proposed behaviour
Flag-aware and liveness-checked: with the flag off, block tmux only while a live child holds the lock. If the lock is provably stale, allow recovery.
A distinct "locked" state with a reason and a recovery action, not a blank viewport.
A filesystem error on the lock path must not claim PTY ownership by itself. Show an error state instead.
Align .runtime handling: agent_opts_into_pty in packages/base/bin/runtime-launch.sh checks .runner and .runner.lock but not .runtime, while Deck's opt-in requires .runtime to be unset or claude. An agent with another runtime and a .runner file is skipped by the base scripts while Deck refuses to start it, stranding it.
Guardrails
Never allow a second writer. "Provably stale" must meet the spec's recovery rule (reclaim only when recovery proves there was no spawn or confirms the group is gone), and flock failures stay fail-closed. The change is to surface a state with a recovery action, not to loosen admission.
The current spec defines the existing behaviour as intended, so this needs a spec amendment before code.
Two minor, fail-safe follow-ups from reviewing the recovery fix in #241 (both fail closed, neither risks a second writer):
packages/deck/app/lib/runner/lock.server.ts: the readFileSync of /proc/<pid>/environ during the leaderless-group scan is not wrapped. If a descendant exits mid-scan it throws ENOENT, which aborts a recovery that would otherwise have succeeded. Treat a vanished member as gone and carry on.
packages/deck/app/lib/runner/lock.server.ts: if the recorded leader PID is recycled by an unrelated process, the birth-time mismatch makes verification return false immediately and skips the leaderless-descendant scan, leaving the agent locked until manual cleanup. Safe, but worth a recovery path in the same locked-state work.
Two more items from Devin's review of the recovery fix in #241:
Restricted procfs (hidepid=1): verifyGroup reads /proc entries for unrelated users, and one denied read aborts leaderless recovery even when every group member is readable. Same fix as the vanished-descendant case: skip unreadable non-members, refuse only if a member cannot be verified.
Add a real process-group test for leaderless recovery (spawn leader and descendant, kill the leader, assert the survivor is verified through the inherited session marker and the claim is removed only after the group is gone), since the current tests mock /proc and process.kill.
Activity
simon-inkie commentedon Nov 22, 2026
Two minor, fail-safe follow-ups from reviewing the recovery fix in #241 (both fail closed, neither risks a second writer):
packages/deck/app/lib/runner/lock.server.ts: thereadFileSyncof/proc/<pid>/environduring the leaderless-group scan is not wrapped. If a descendant exits mid-scan it throws ENOENT, which aborts a recovery that would otherwise have succeeded. Treat a vanished member as gone and carry on.packages/deck/app/lib/runner/lock.server.ts: if the recorded leader PID is recycled by an unrelated process, the birth-time mismatch makes verification return false immediately and skips the leaderless-descendant scan, leaving the agent locked until manual cleanup. Safe, but worth a recovery path in the same locked-state work.simon-inkie commentedon Nov 22, 2026
Two more items from Devin's review of the recovery fix in #241:
hidepid=1):verifyGroupreads/procentries for unrelated users, and one denied read aborts leaderless recovery even when every group member is readable. Same fix as the vanished-descendant case: skip unreadable non-members, refuse only if a member cannot be verified./procandprocess.kill.