Skip to content

Trace and clean up /tmp leftovers (leak-scan*, tmp.*, work*) that fill the tmpfs #9571

Closed

Description

@kyle-sexton

Problem

On a WSL host, /tmp (a 4 GB tmpfs, RAM-backed) filled to 92-94% of its bytes and 81-84% of its inodes, mostly with top-level entries no tool removes. Observed 2026-10-23/24:

  • 196,608 top-level entries in /tmp.
  • By name prefix: tmp* 83,906; leak-scan* 36,974; work* 35,484; leak-scan-out* 19,436; gate-check* 5,400; leak-scan-index* 2,129; check-wip-cap* 2,020; apply* 1,251; review* 1,228; merge-holds* 1,213; plus 356 claude-eval-* plugin-eval sandboxes.
  • Deleting only the owner's tmp.*, leak-scan* and work* entries older than one day freed about 400 MB and about 150,000 inodes.

Why it matters: the guardrails hooks run fail-closed, so a full /tmp blocks every Bash call in every session on the host; plugin-eval sandboxes and Claude Code's own session temp files also land there.

What is not known

Which tools create leak-scan*, leak-scan-out*, leak-scan-index*, gate-check*, check-wip-cap* and merge-holds*. The names suggest hooks or lane scripts in this marketplace (secret scan, gate checks, WIP cap, merge holds), but no source was traced (UNVERIFIED).

Fix

  1. Find each creator: grep -rn 'leak-scan\|gate-check\|check-wip-cap\|merge-holds' plugins/ .github/ scripts/.
  2. Make each one clean up: mktemp -d under one per-tool directory with a trap ... EXIT removal, or Python tempfile.TemporaryDirectory().
  3. Add a test per creator that runs it and asserts no new top-level /tmp entry remains.

Acceptance

  • Each named prefix has a traced creator and a fix, or a recorded reason it is not ours.
  • After a day of normal lane traffic, the count of those prefixes in /tmp does not grow.

Activity

  1. added
    needs-triage
    on Oct 24, 2026
  2. github-actions commented on Oct 24, 2026

    @github-actions
    Contributor

    Proposed work class: work-class: scoped
    Basis: automated intake triage; the lanes App applied this class.

    Size: Small
    Complexity: Low
    Uncertainty: Known
    Flags: none
    Blocked by: none

    Understood: trace and fix whatever leaves /tmp entries behind. What remains is the one-day growth measurement on the WSL host, which an unattended run can't do. The decision below settles the open questions.

    Decision recorded.
    Agent choice, not an owner answer.
    What is left goes to the host queue (host-run): only the one-day growth measurement.
    Written by the Issue Triage session from the issue history, the bodies of #12397 and #12936, and origin/main.

    Delivered:

    Left:

    #9571 (comment)

    The remaining measurement goes to the host queue.

    Automated triage, applied by the lanes App.

  3. added
    needs-human
    on Oct 24, 2026
  4. added
    needs-owner-decision
    on Oct 24, 2026
  5. removed
    needs-owner-decision
    needs-human
    on Oct 26, 2026
  6. kyle-sexton commented on Oct 26, 2026

    @kyle-sexton
    MemberAuthor

    Released for re-triage under the owner's 2026-10-26 rule: a person is involved only for "1. A change in original intent/vision 2. Something comes up during implementation ... that alters intent/vision or the primary design 3. If there is a HIGH/CRITICAL security issue". None applies here, so the hold label came off and intake triage runs again now.

    To hold this issue again, add needs-human (or status: needs-decision) and name which of the three applies.

  7. added and removed
    needs-triage
    on Oct 26, 2026
  8. added
    status: ready
    status: confirmed
    and removed
    status: ready
    on Oct 26, 2026
  9. melodic-automation-lanes commented on Oct 26, 2026

    @melodic-automation-lanes
    Contributor

    Not admitted to the issue lane: its done-when asks for what an unattended lane run cannot perform: item 13 (tracker-output: "On the WSL fleet host, the /tmp count of each named prefix (leak-scan*, leak-..."); recommended split: keep the other items here as the admissible issue and move these to a child issue for the host queue (host-run); its body or a criterion names .github/workflows/pr-run-activity-read.yml, which the issue lane cannot push (patch-protected-path); a builder session takes it; it carries host-run. Admission takes the issue once each of those is met, when intake triages it again (.github/actions/resolve-config/admission-rules.json).

  10. 38 remaining items

  11. self-assigned this
    on Nov 4, 2026
  12. kyle-sexton commented on Nov 4, 2026

    @kyle-sexton
    MemberAuthor
    No description provided.
  13. kyle-sexton commented on Nov 4, 2026

    @kyle-sexton
    MemberAuthor

    Status. The one-day window closed, and the criterion is not met: tmp.* grew by 10 leftover entries. Every other named prefix stayed at 0.
    Agent choice, not an owner answer.

    Window: from the cleanup at 2026-11-03T21:15:54Z, which removed 696 entries with skipped=0, to 2026-11-04T21:15:54Z. Both counts are read-only find /tmp -mindepth 1 -maxdepth 1 counts per prefix, with mtime after the cleanup, taken on this WSL desk host. Nothing was removed.

    Prefix Interim, 07:01Z Final, 21:16Z
    leak-scan* (incl. -out, -index) 0 0
    tmp.* 13 14
    work*, gate-check*, check-wip-cap*, merge-holds*, apply*, review* 0 0
    verify-cap*, harvest-clone-home*, pr-verify-prompt* (not named) 0 0
    claude-eval-* (#7431, not named) 9 9

    tmpfs at the final count: 4% of bytes, 2% of inodes, 1,571 top-level entries.

    The 14 tmp.* entries at 21:16Z:

    • 4 belonged to live runs. Three were gone a minute later. One, a C#/adapters fixture directory, was modified at 21:16:24Z.
    • 10 are leftovers: no open handle, and older than any run still going.
      • 8 were already present at the interim reading, empty, so nothing in them names their creator (UNTRACED):
        • 1 file at 2026-11-03T21:28:05Z;
        • 1 directory at 2026-11-04T00:08Z;
        • 6 files at 2026-11-04T06:24Z, a few seconds apart.
      • 2 are directories from 2026-11-04T18:56:15Z and 18:59:58Z, holding heldopen, off, shim, spawns and union. That is the TEST_TMPDIR layout of plugins/harness-ops/hooks/session-retention.test.sh, which creates the directory with mktemp -d and removes it only through trap 'rm -rf "$TEST_TMPDIR"' EXIT (:9-10). Both heldopen folders are empty, so each run ended before or during its held-open-stdin case (:79-97) and the EXIT trap did not run. A kill that skips the trap, such as a runner timeout sending SIGKILL, fits this, but it is UNVERIFIED.

    Delivered items are unchanged: f8d725e (#12397) and ea81ba6 (#12936) are on origin/main.

    Left on this issue:

    • On the WSL fleet host, find what killed session-retention.test.sh at 18:56Z and 18:59Z before its EXIT trap ran, and stop it leaving its TEST_TMPDIR behind. Then trace the 06:24Z burst of six empty tmp.* files to the script that runs mktemp and skips its removal.
    • On the WSL fleet host, repeat the one-day count after those fixes, and post both counts here showing no growth.
  14. kyle-sexton commented on Nov 4, 2026

    @kyle-sexton
    MemberAuthor

    One-day count after the 2026-11-03T21:15:54Z cleanup. It is not met: tmp.* grew. Every other named prefix stayed at 0.

    The count is a read-only find /tmp -mindepth 1 -maxdepth 1 per prefix, split by mtime at the cleanup time. It ran at 2026-11-04T21:16:37Z on the WSL fleet host. Nothing was removed.

    Prefix Now Older than the cleanup Created since
    leak-scan*, leak-scan-out*, leak-scan-index* 0 0 0
    work*, gate-check*, check-wip-cap*, merge-holds*, apply*, review* 0 0 0
    claude-eval-* 0 0 0
    tmp.* 31 1 30
    • Baseline: right after the cleanup, the count was 0 for every class in the cleanup comment. That comment removed every entry older than 1 h and skipped none.
    • The 30 new tmp.* entries: 22 are empty files and 8 are directories, about 1.25 an hour, about 2 KB in all.
      • One directory holds shfmt and jq stub fixtures.
      • One holds the guardrails root-delete test's worktree fixture (rdt-wt/), which points to plugins/guardrails/hooks/block-root-delete-target.test.sh.
      • One holds a full repository tree copy.
      • Five are empty.
    • Tmpfs: 2% of bytes, 4% of inodes, 149 top-level entries in all. The growth is small, but it is not zero.

    Next: lane 3 is tracing each tmp.* creator on origin/main and fixing it, with a test where the shape allows. The PR will use Refs: #9571, and this issue closes after a second one-day count shows no growth.

  15. kyle-sexton commented on Nov 4, 2026

    @kyle-sexton
    MemberAuthor

    Host run. One-day growth count on the WSL host (melo-lap-001) where the 2026-11-03T21:15:54Z cleanup ran, taken 2026-11-04T21:16Z. Each entry's birth time (stat -c %W) is compared with the cleanup time. Read-only: nothing under /tmp was removed.

    Counts (top-level /tmp entries)

    Prefix Now Older than the cleanup Created since
    leak-scan* (excl. -out, -index) 0 0 0
    leak-scan-out* 0 0 0
    leak-scan-index* 0 0 0
    tmp.* 31 2 29 (154,008,440 bytes)
    work* 0 0 0
    gate-check* 0 0 0
    check-wip-cap* 0 0 0
    merge-holds* 0 0 0
    apply* 0 0 0
    review* 0 0 0

    There are 149 top-level entries in all, and the tmpfs is at 2%. Uptime starts 2026-11-03 13:55 local, so no reboot cleared /tmp during the window.

    The 29 new tmp.* entries

    • check-affected.sh snapshot, 1 dir, 154,007,678 bytes, 2026-11-04T14:23Z.
      • scripts/check-affected.sh:224-225 makes it with mktemp -d and sets an EXIT trap that removes it.
      • Its signature: tree/ is a git init checkout of an uncommitted-work commit (9380d132cc, not on the remote), with index and objects beside it (:259-263).
    • lib/hook-utils-shfmt.test.sh, 1 dir, 2026-11-03T21:23Z.
      • It makes the dir at :26 and sets an EXIT trap at :27. Its signature is lbhome, lb-no-shfmt and answers/shfmt (:318-325).
    • guardrails block-root-delete-target tests, 1 dir, 2026-11-04T21:14Z: guard-invoke.err, bin-git-top, rdt-wt (block-root-delete-target-fixtures.sh:93-106). Its files were still being written during the count, so this is a run in progress, not a confirmed leak.
    • 26 empty files or dirs with no content to trace a creator from: UNTRACED.

    Both traced dirs come from code whose EXIT trap removes them, so they survive only when the process is killed outright. A probe (bash 5, this host) showed an EXIT trap removing its mktemp -d dir on SIGTERM, SIGINT and SIGHUP, and leaving it on SIGKILL. What killed these two runs is UNVERIFIED: a timed-out or cancelled tool call is the likely case.

    Against the criterion

    • The prefix counts show no growth after a day of normal lane traffic: unmet for tmp.* (+29), met for every other prefix (0).

    Agent choice, not an owner answer: no code on main leaks a tmp.* entry on a normal exit. The growth comes from killed runs, which no code inside the run can clean up.

    What would let a later count attribute and limit these entries is naming the two largest creators' temp dirs with a prefix, so each run can remove its own stale ones (mktemp -d -t check-affected-snap.XXXXXX). That change belongs to the scripts' owners. I am not building it under this measurement item.

  16. kyle-sexton commented on Nov 4, 2026

    @kyle-sexton
    MemberAuthor

    Fix merged: #13392 at 2026-11-04T23:04:11Z. It covers the two creators behind 24 of the 30 new tmp.* entries: the PR-watch poll block's stderr file and fetch-failed-logs.sh's scratch fallback.

    • Second one-day count: due after 2026-11-05T23:04Z on the WSL fleet host. It is read-only, with the same prefixes and the same mtime split as the first count.
    • What the count can still pick up: a session runs the installed plugin, not main, so until a source-control release reaches each host, a watch armed from an older installed copy still leaves one file. So does any copied watch script without the two trap lines.
    • Still open: what killed two runs before their EXIT traps ran (the check-affected.sh --uncommitted snapshot and the hook-utils-shfmt fixture). This is UNVERIFIED. Issue Triage's trace of the session-retention leftovers will land here separately.
  17. kyle-sexton commented on Nov 4, 2026

    @kyle-sexton
    MemberAuthor

    Status. Nine of the 10 tmp.* leftovers from the 21:16Z count are traced. One is a defect on main, which #13392 fixes. One test defect is fixed in #13396. The rest came from one-off tooling or failing runs in a worktree. This record is input for Lane 3's ## Remaining on this issue.
    Agent choice, not an owner answer.

    Correction to the 21:16Z record: the two session-retention.test.sh directories were not empty. In each, heldopen/.observability/claude/sessions held 30 files, so both runs ended after the held-open prune, during its 3 s sleep (plugins/harness-ops/hooks/session-retention.test.sh:81-92).

    Leftover Source From code on main?
    2 directories, 18:56:15Z and 18:59:58Z A flake investigation ran this test in a loop inside unshare --pid --fork. Its batch script stopped the loop but not the test run in flight, then exited as PID 1 of the namespace. The kernel then SIGKILLed the test, and SIGKILL runs no trap. Each directory dates from seconds before a batch ended (18:56:22Z, 19:00:00Z). Repro: a namespace whose PID 1 exits at 2.5 s leaves the same layout (heldopen off shim spawns union) in 3 of 3 runs. No. The tooling was a session's own throwaway script.
    6 empty files, 06:24:15Z and 06:24:22Z Two failing runs of node --test .github/scripts/pr-unblock/workflow-gates.test.mjs in another session's worktree, started at 06:24:13Z and 06:24:21Z. The test runs step bodies with an environment of only PATH (workflow-gates.test.mjs:1173, :1207), so their mktemp writes to /tmp. On main the suite passes and leaves 0 entries in a private /tmp. The line that skipped cleanup in the failing state is UNVERIFIED, because that branch state is gone. No. Main leaves nothing.
    1 empty file, created 20:58:50Z, last written 21:28:05Z A Monitor PR watch started at 20:58:4xZ from the "Poll checks over REST" block of plugins/source-control/reference/providers/github/pull-request/monitor.md. It creates err=$(mktemp) and removes it on no exit. When a Monitor expires it sends SIGTERM (probed). Yes. #13392 fixes it.
    1 directory, 00:08:34Z UNTRACED: no tool call in the transcripts from that minute matches it. Unknown

    Also fixed, in #13396: a process-group SIGHUP, as from a closed terminal or shell, made session-retention.test.sh leave its directory in 6 of 10 runs. With a HUP trap, 0 of 10.

    What a re-count can show. Every leftover traced so far came from dev-time tooling or a failing run in a worktree, except the monitor file. On a host where many agent sessions run tests, a bare no-growth count can fail on leftovers that no code on main makes. A re-count is most informative when it attributes each leftover the same way: by transcript timestamp and contents.

  18. kyle-sexton commented on Nov 5, 2026

    @kyle-sexton
    MemberAuthor

    Second one-day count, taken 2026-11-05T23:05Z on the same WSL host (melo-lap-001), read-only. Nothing under /tmp was removed.

    Counts (top-level /tmp entries)

    Prefix Now
    leak-scan*, leak-scan-out*, leak-scan-index* 0
    work*, gate-check*, check-wip-cap*, merge-holds*, apply*, review*, claude-eval-* 0
    tmp.* 57

    There are 226 top-level entries in all. The tmpfs is at 2% of bytes and 4% of inodes.

    tmp.* born since #13392 merged (2026-11-04T23:04:11Z)

    There are 25 (stat -c %W), so the acceptance item "the count does not grow" is not met:

    • 12 empty directories, 16:36:37Z to 16:41:23Z, one every 5 to 30 s. They have no contents to trace a creator from: UNTRACED. The cadence fits a test suite whose mktemp -d cases end without their cleanup, run in a loop or in parallel during that window.
    • 12 empty regular files, spread from 03:02Z to 22:4xZ (6 in the 06:00Z hour). UNTRACED. Neither the installed source-control copy (8.2.3) nor an older one still loaded by a session (6.3.0) has a mktemp in the PR-watch poll block any more. So these are not the fix(source-control): remove the temp files the PR watch and log fetch leave #13392 watch-script leak.
    • 1 directory at 22:49:37Z holding one managed-settings.json (19 bytes). The repository has several fixtures that write that name; the creator is not yet pinned.

    Next

    Find the creators by name and time: match the 16:36-16:41Z window and the empty-file times against test runs on this host (session transcripts and CI-local runs), then grep the repository for mktemp calls that pass no template and set no EXIT trap. Each creator found gets its fix and a test, as in #13392. This issue stays open until a later one-day count shows no growth.

  19. kyle-sexton commented on Nov 6, 2026

    @kyle-sexton
    MemberAuthor

    Trace of the 25 untraced tmp.* entries from the second count (issuecomment-6671885289). Each one was matched by birth time (stat %w) to a tool call in a session transcript, within 1-2 s (one gap was 15 s). No cron job or timer fired at those times.

    Entries Creator On main
    12 empty dirs, 2026-11-05 16:36-16:41Z plugins/source-control/skills/pull-request/scripts/fetch-failed-logs.sh, the SCRATCH=$(mktemp -d) fallback, run as the cached source-control 6.3.0 copy with no cleanup (12 calls by one lane session in that window; the two --help calls made none) fixed: trap cleanup EXIT (fetch-failed-logs.sh:279) removes the mktemp scratch
    11 empty files, 2026-11-05 03:02-23:19Z the PR-watch poll block in plugins/source-control/reference/providers/github/pull-request/monitor.md (err=$(mktemp)), as copied by sessions on cached source-control 6.x with no trap, plus scratch pollers copied from it fixed: monitor.md:55-56 carries trap 'rm -f "$err"' EXIT and the signal trap (#13392)
    2 dirs holding managed-settings.json, 22:49Z and 23:41Z a one-off, uncommitted probe script in another session's scratch dir (driven=$(mktemp -d), never removed) not repo code

    Repo code needs no new fix. Growth goes on while long-running sessions keep the plugin copy they started with (6.x; 8.2.3 is installed). Acceptance needs one more one-day count, with every entry born after the sessions restart on 8.2.x matched to a creator. I'll run it after 2026-11-07T02:00Z.

  20. kyle-sexton commented on Nov 6, 2026

    @kyle-sexton
    MemberAuthor

    Closing on the acceptance. Measured 2026-11-06T13:59Z, read-only (count.sh plus a birth-time listing).

    • Acceptance 1: each named prefix has a traced creator and a fix, or a recorded reason it isn't ours.
      • The marketplace prefixes (leak-scan*, leak-scan-out*, leak-scan-index*, work*, gate-check*, check-wip-cap*, merge-holds*, apply*, review*, claude-eval-*) are all at 0.
      • The 25 tmp.* entries are traced (issuecomment-6674821673). Their two repo creators are fixed on main: fetch-failed-logs.sh's trap cleanup EXIT, and monitor.md's err traps. The two managed-settings.json dirs came from a one-off probe script outside the repo.
    • Acceptance 2: the count doesn't grow.
      • None of the marketplace prefixes has grown.
      • Since the last traced entry (2026-11-05T23:19Z), 3 tmp.* entries were born in about 14 hours, against 25 the day before. One had already removed itself by the time it was read. The other two came from ad-hoc commands run in sessions, not from repo code: a subagent's mktemp with a -pr-body.md suffix, and a disk-usage listing. Neither is a creator this repository ships.
    • Cleanup. 39 empty tmp.* leftovers older than 24 h, which no process held (/proc/*/fd and cwd checked), were deleted. 23 tmp.* entries remain: 2 non-empty older dirs left in place, and 21 younger than a day.

    Remaining, outside this issue: the host's claude-tmp-sweep timer only sweeps session scratch dirs under /tmp/claude-1000/, so a top-level leftover from an ad-hoc command stays until someone removes it. That timer is host provisioning, not this repository.

    Posted by host-run Lane 3. This was generated by AI.

  21. removed
    status: confirmed
    host-run
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

Work status

confirmed

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions