Skip to content

Runs leave Factory skills and session scratch files in /tmp: 17 GB on stephens.page #2278

Closed

Description

@JacobStephens2

This was generated by AI during triage.

Agent Brief

Category: enhancement
Summary: Runs leave files in the shared /tmp that nothing removes: Factory skills directories from Commands that end without cleanup, and the scratch files sessions write there. On stephens.page they reached 22 GB.

Current behavior:

On 2026-11-18, stephens.page's /tmp held 22 GB; 17 GB of it was more than two days old, with about 11,500 entries, and pushed the root disk to 91%. Clearing those entries by hand freed 16 GB (91% → 82%). Two kinds of leftover:

  1. Factory skills directories (thirdshift-skills-XXXXXX). skills::written_out() (src/skills.rs) writes the Factory skills to a tempfile directory held in a static WRITTEN. skills::remove_written() drops it from the normal end paths (src/command.rs, src/processes.rs, src/processes/review.rs, src/skill.rs, src/trial.rs). A Command that dies by signal, is killed, or whose host or VM restarts never reaches those paths, and a static is not dropped at exit, so its directory stays. Unit tests leave 24 Factory skills directories in the temp directory on every run #1913 fixed the unit-test leak (the daily count fell from 192 on 11-06 to 1–12 after 11-10), but the production leak remains:

    Host thirdshift-skills-* in /tmp Created since 2026-11-11
    stephens.page 2,348 (1.4 GB) 15
    thirdshift.app 1,928 (1.1 GB) 29
    orchestrate 3,454 (260 MB) 4
    dev 969 (53 MB) 0
    factory 18 (11 MB) 18

    They come in bursts with identical timestamps (factory: 7 at 2026-11-12 09:15, 3 at 2026-11-14 17:31), which fits several Commands dying together.

  2. Session scratch files. Sessions write their logs, builds and reproductions straight into /tmp (/tmp/issue-188-main-d1-extension.log, /tmp/issue244-rooms-final.log and the like). Nothing removes them. The entries older than two days on stephens.page included issue* (543 entries, 132 MB), pr-* (245), repro-* (17, 1.2 GB), a thirdshift-2050-base-target build (812 MB), and 4,980 scheduling-* test fixtures from voice-agent-scheduling sessions (278 MB). Only Triage runs set a session-specific TMPDIR (src/sandbox/triage.rs).

Desired behavior (recommended; confirm before moving to ready-for-agent):

  • Each Command gets one scratch directory, and every session it starts runs with TMPDIR pointing inside it. The Factory skills go there too. The Command removes it when it ends, as it removes its worktree.
  • Like the orphaned reservations released since 0.37.0 (Notice a reservation whose owning process has died #1959), a Command's startup removes scratch directories, including stale thirdshift-skills-*, that belong to a Command on this host whose process is gone, and logs what it removed.
  • Session prompts and Factory skills keep using mktemp, so their files land in that TMPDIR; any guidance that names /tmp literally should use $TMPDIR.

Questions for the Day shift:

  1. Should the scratch directory live under the system temp directory or under ~/.thirdshift, where its disk use is easier to see and to keep out of other users' way?
  2. Should startup clean-up remove only directories it can tie to a dead Command, or also thirdshift-skills-* directories older than a cutoff (for example 2 days) left by versions before this change?
  3. Should a retained worktree (a Paused Command or Recovery) keep its scratch directory until it is continued or dismissed, so its logs stay available?

Key interfaces:

  • skills::written_out / remove_written and the static WRITTEN in src/skills.rs.
  • Session launch, where the environment is set for each Harness (src/sandbox.rs sets TMPDIR=/tmp for sandboxed sessions).
  • The orphan-detection used for reservations (Notice a reservation whose owning process has died #1959), reused to find dead Commands' scratch directories.

Acceptance criteria:

  • A session's TMPDIR is inside its Command's scratch directory, and a session that writes mktemp files leaves nothing in the system /tmp after the Command ends.
  • A Command stopped with SIGTERM removes its scratch directory; one killed with SIGKILL has it removed by the next Command on that host, with a log line.
  • A live Command's scratch directory is never removed by another.
  • Factory skills are written inside the scratch directory, not as a separate thirdshift-skills-* directory.
  • Docs updated where they describe what a Run leaves on the host.

Out of scope:

Activity

  1. added
    enhancement
    ready-for-human
    on Nov 18, 2026
  2. JacobStephens2 commented on Nov 18, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI during triage.

    Decisions (Day shift, 2026-11-18)

    1. Location: the per-Command scratch directory lives under ~/.thirdshift (for example ~/.thirdshift/scratch/<command identity>/), not the system temp directory, so its disk use is visible beside the logs and stays in the user's own space. Sessions' TMPDIR points inside it; the Factory skills are written there too.
    2. Legacy clean-up: yes. Startup clean-up also removes thirdshift-skills-* directories in the system temp directory older than a cutoff (2 days), left by versions before this change. Guard: remove only directories owned by the current user whose contents are exactly the Factory skills layout thirdshift writes (thirdshift-* skill folders and LICENSE), so nothing a user put there is touched. Users' own skills live in repositories' .agents/skills and are never in scope.
    3. Retained work: a Paused Command, or a failed one with a Recovery command, keeps its scratch directory until it is continued or dismissed, so its logs stay available; dismissing or completing the continuation removes it.

    Extra acceptance criteria:

    • Scratch directories are created under ~/.thirdshift/scratch/, one per Command.
    • A thirdshift-skills-* directory older than 2 days, owned by the user and matching the Factory skills layout, is removed at startup with a log line; one with any other content is left alone.
    • A Paused or failed Command's scratch directory survives until the Command is continued or dismissed, then is removed.

    Moved to ready-for-agent.

  3. added
    ready-for-agent
    in-progress
    and removed
    ready-for-human
    ready-for-agent
    on Nov 18, 2026
  4. removed
    in-progress
    on Nov 18, 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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions