Skip to content

Reap sandbox processes left in an exited harness session - #55

Merged
LikC1606 merged 1 commit into
mainfrom
fix/orphan-sandbox-reaping
Nov 28, 2026
Merged

LikC1606 merged 1 commit into
mainfrom
fix/orphan-sandbox-reaping

Conversation

@LikC1606

Copy link
Copy Markdown
Collaborator

Five bwrap processes were left running on the host after harness sessions ended. They were Codex filesystem-helper sandboxes. Codex starts them in a separate process group inside the app-server session. bwrap 0.9.0 sets PR_SET_PDEATHSIG only after the child reads its start eventfd. If the launcher is killed between clone and that write, the child waits forever. The child is pid 1 of its own PID namespace, so only SIGKILL stops it. TheoremOS confirmed a stop by probing only the process group, so it reported these runs as stopped.

When closing a session and when confirming that it stopped, TheoremOS now also looks for live processes left in the exited leader's session and kills them with SIGKILL. Before killing, it checks that the session id was not reused: at least one member must have started no later than the recorded leader exit. Each pid is checked again right before the signal. Codex, Claude Code, OpenCode and CLI sessions record the exit time at spawn. While such processes remain, confirmation returns the new reason process-session-active.

Codex solo research still runs without a PID namespace. Forcing isolateProcess there would change its filesystem view, and the session sweep already covers this path.

Testing

  • New tests reproduce a session member in a separate process group. Both fail without the fix and pass with it.
  • Focused session, harness and team tests pass: 33 files, 537 passed, 11 skipped. tsc --noEmit and the headless bundle build pass.
  • An end-to-end race against real bwrap, using a fake Codex that kills its launcher at a random delay of 0 to 3 ms, left no processes behind. On Node, 500 trials produced 10 orphans and all were reaped. On Bun, 1200 trials produced 25 orphans and all were reaped.

Running campaigns use frozen build manifests and pick this up only after a release.

🤖 Generated with Claude Code

Codex starts its filesystem-helper sandbox in a separate process group inside
the app-server session. bwrap 0.9.0 arms PR_SET_PDEATHSIG only after the
child reads its start eventfd, so a launcher killed between clone and that
write strands the child forever. The stop check only probed the process
group and reported such runs as stopped.

Closing and stop confirmation now also find live members of the exited
leader's session and SIGKILL them. A member that started no later than the
recorded leader exit proves the session id was not reused, and each pid is
re-read before the signal. Confirmation returns process-session-active while
members remain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LikC1606
LikC1606 merged commit 889644a into main Nov 28, 2026
4 checks passed
LikC1606 added a commit that referenced this pull request Nov 28, 2026
…sions (#56)

Since #54 a batch of same-file declarations shares one verification
deadline. When the batch timed out, every attribution was blocked and the
check rejected the first declaration instead of retrying in isolation. In
continuation seeding, tryBatch rethrew that error and aborted the seed.
A batch that only hit its deadline, or that reached a verification
checkpoint, now falls back to per-declaration checks with their own
deadlines. tryBatch also falls back on other batch check failures, so each
candidate records its own result as before batching.

Since #55, a child first tracked after it had exited got the current
uptime as its exit tick. A later session that reused its pid as sid could
then pass the continuity check and be SIGKILLed. Only an exit observed
while tracked now bounds the session, and the detached proof-environment
helper is tracked at spawn.

Co-authored-by: Zhenhao Liu <176368005+LikC1606@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@LikC1606
LikC1606 deleted the fix/orphan-sandbox-reaping branch December 1, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant