Skip to content

hide-ai: sweep private CODEX_HOME directories left by an owner that died without Drop #116

Closed

Description

@yansfil

What happened

PR #92 gives every codex app-server session a private CODEX_HOME at $TMPDIR/hide-ai-codex-home-<owner pid>-<nanos> (hide-ai/src/codex.rs, CodexHome), and removes it in Drop.
The 2026-09-20 live verification of that PR showed two things the design did not account for:

  • The directory is not "a symlink and nothing else" for long: within a second the app-server writes installation_id, .sandbox_migration, models_cache.json (228 KB), five sqlite databases with WAL/shm files (state_5.sqlite-wal alone 1.9 MB), shell_snapshots/, skills/ and tmp/ beside the auth.json symlink. Measured 2.5 to 5 MB per session on codex-cli 0.155.1. No sessions/ rollout appears, so no transcript is left; the size is the point here, not privacy.
  • An owner that dies without running Drop leaves all of it behind, and nothing sweeps it. On the verification machine two such directories from one dead pid (hide-ai-codex-home-71225-*, 3.0 MB and 2.9 MB) were already on disk before the run. The CI test kill_dash_nine_on_the_owner_leaves_no_survivors performs exactly that kill, so every run of the Rust test lane leaves one more.

docs/AI_PROVIDERS.md states the gap since #92 ("An owner that dies without running Drop ... leaves its directory behind, and nothing sweeps them yet").

What you expected

A resident process owns what it starts and releases it on every exit path, including the one where the owner itself is killed (engineering principle 14; oh-my-principle process practice).
The kill -9 path cannot run Drop, so the release has to happen from the next owner: when CodexAppServerBackend creates a new private home, it should remove sibling hide-ai-codex-home-<pid>-* directories whose <pid> is no longer alive (or is alive but is not a hide-ai process, since pids are reused).
A sweep bounded to that prefix under $TMPDIR keeps the blast radius to directories this crate named.

Log one structured line per removed directory (ai.codex_home.swept, with the dead pid and the byte count) so a leak that the sweep is cleaning every start is visible rather than silent.

Steps to reproduce

  1. bash scripts/verify-cargo.sh test (runs kill_dash_nine_on_the_owner_leaves_no_survivors).
  2. ls -d "$TMPDIR"/hide-ai-codex-home-* and du -sh them: one 0700 directory per killed owner, with no live process of that pid.
  3. Run CODEX_HOME=$HOME/.codex HOME=$(mktemp -d) target/release/hide-agent-context-labels verify-provider --provider codex: a new home is created and removed, the stale ones stay.

Versions

Diagnostics

Tree and directory listings from the live run are in the local run directory agents/runs/ai-process-ownership/live-codex-verification/ (process-tree.txt, rerun.process-tree.txt); run artifacts are not committed.

Related: #82 (Part A landed in #92; this is a Part A follow-up, independent of the Part B broker work).

Activity

  1. added
    bug
    rust
    on Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugrust

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions