oliver-zehentleitner / maity
runner: a Codex placement's app-server daemon outlives its session and keeps the first start's env (TMPDIR, maybe sandbox profile)
tsk-n6sajs3gyh8h Review Maity Coder Claude 007
Found by Ops 3yc2 on agents03, 2026-11-23, from read-only output that Oliver ran (lotse seq 200754). All 5 Codex review placements have been away since their restart at 08:01Z.
Problem
- Codex 0.171 runs its turns in a managed app-server daemon, one per CODEX_HOME (
codex app-server --listen unix:// … --managed-daemon, plusdaemon pid-update-loopandcodex-code-mode-host, fromcodex-home/packages/app-server-daemon/). The daemon is detached from the TUI's process group. - A placement stop or restart sends TERM to the pane's process group (
tmux.terminate), which leaves the daemon running. The next TUI connects to the old daemon through its socket in CODEX_HOME. - So the daemon keeps the env of the placement's first start, including TMPDIR, the scratch leaf that
_tmp_scratch(supervisor.py ~2761) removes at the next start. It may also keep the first start's config, meaning a later generation's sandbox profile or network domains may not be what is enforced. That is still to check.
Effect
From the second start on, every sandboxed command panics (failed to resolve synthetic mount registry temp directory), and the Codex placement never reaches the hub. Seen on agents03: the daemon's etime puts its start at the placement's creation, 2026-11-22 23:36Z; the TUI has the current TMPDIR, and the daemon has the dead one.
Fix (to settle in the plan)
- Stop the placement's daemon before every Codex start and at stop or close, with
codex app-server daemon stopand the placement's CODEX_HOME. Kill its process group as a fallback. - Or start Codex without a managed daemon, if 0.171 has such a switch. None was found in
--help; this still needs checking. - Make the daemon stop part of every start, not only a TMPDIR fix, so an old generation's sandbox profile can never stay in force.
Acceptance
- A test that a Codex start stops any daemon left in its CODEX_HOME, with a counter-check that fails on the old code.
- On a host: restart a Codex placement twice. Its sandboxed
maity resumeruns both times, and no daemon of an earlier generation is left (pgrepon the placement's .scratch path). - The docs: docs/runners.md (Codex) and a changelog line (Fixed).
Workaround until then: Oliver stops each daemon by hand, then the placement is restarted alone.
Related: tsk-bceywc5jjkd9 (default_model ignored).
Notes
Lotse · Nov 23, 2026, 09:12 UTC
Addendum from Ops 3yc2 (seq 200797, tested locally): the daemon comes with a second detached process,
app-server daemon pid-update-loop(Codex's package updater, not a watchdog).daemon stopleaves it running. The runner's stop must therefore runcodex app-server daemon stopwith the placement's CODEX_HOME and end every process still running from<CODEX_HOME>/packages/app-server-daemon/. Both have their own session, so TERM to the pane's process group reaches neither.An agent · Nov 24, 2026, 05:52 UTC
Ops checklist for PR #2175 (slice 1, head `3b23984d`). Both review legs have approved; the PR stays a draft until this check is done. Run it on a host with Codex 0.171 and a Codex placement. Report the results on this card or to the lead.
- Command form and exit codes. Use the placement's codex-home, the directory named
codex-homein its scratch.
- With that placement's app-server daemon running:
CODEX_HOME=<codex-home> codex app-server daemon stop. Note the exit code and any output. Check that the daemon process for that home is gone afterwards. - With no daemon running for that home, the same command. Note the exit code and any output.
- If the real command differs from
codex app-server daemon stop(another subcommand, a flag, a config switch that turns the daemon off), give the exact form. - Note whether the
pid-update-loopprocess is still running after a successful stop. A fallback for it is outside this PR; if it disturbs the next start, it becomes a follow-up card.
- Acceptance on a runner with this PR's branch.
- Restart a Codex placement twice from the dashboard.
- Both times, its sandboxed
maity resumeruns. - After the second start, no daemon from an earlier start is left for that home (
pgrep -afon the placement's scratch path shows only the current generation). - The runner log has no line saying the stop failed, was skipped or timed out. If one appears, quote it.
If the command form is wrong, nothing is stopped and the start goes on as before this change, with one log line. So a failed check does not make things worse; it means the fix needs another form.
- Command form and exit codes. Use the placement's codex-home, the directory named
Maity Coder Claude 007 · Nov 25, 2026, 00:48 UTC · worked in
P3s from A2603 (PR 2207 at 4746691e, round 2, not blocking), for the next change to the Codex stop:
- In Supervisor._clear_scratch, a local target whose layout is unknown still removes its TMPDIR leaf and stale leaves before
continue, though the Codex stop is skipped. Continue at once on an unknown layout, or run those removals only once the layout is known. - codexd._exited uses select.select, which refuses a descriptor of 1024 or more (caught as
unreadable). Use select.poll instead. - The close tests use a stand-in that exits at once. Give one a delay, so the wait before removal is exercised at close too.
- Test the wait's clamp when little of the deadline is left (timeout - 1 < UPDATER_WAIT).
- In Supervisor._clear_scratch, a local target whose layout is unknown still removes its TMPDIR leaf and stale leaves before
Maity Review Team Lead · Nov 25, 2026, 00:49 UTC · worked in
Review round 2 of #2207 at 4746691e: four P3s for later, not blocking.
- On a local target whose host layout cannot be read at that close, the Codex stop is skipped, but the recorded TMPDIR leaf and stale leaves are still removed. Skipping the whole close step there would keep the order intact.
- The wait for the loop's exit uses select, which cannot take a descriptor numbered 1024 or higher; such a case ends as "unreadable". poll has no such limit.
- The close tests use a loop that exits at once; a slow-to-exit loop in a close test would show the wait before removal on close too.
- The wait's clamp at a tight remaining deadline is not tested directly.
Lotse · Nov 25, 2026, 02:21 UTC
Slice 2 merged in #2207 (main 7c5c8398aacf2368e7b56f20d965611769921eea). Open: the host check after the next CLI release on the runner (restart a Codex placement twice; sandboxed maity resume runs both times; no daemon of an earlier generation left).