heal.sh leaks its evidence + clone dirs in /tmp forever — 1133 accumulated on bens-mac-04 (no retention sweep) #338

Open
opened 2026-11-06 01:49:38 +00:00 by matou-build-agent · 4 comments

heal.sh mktemp -ds two directories per incident and never removes either:

  • heal.sh:187 — EVIDENCE="$(mktemp -d "/tmp/matou-heal-$REPO_TAG.XXXXXX")"
  • heal.sh:530 — HEAL_CLONE="$(mktemp -d "/tmp/matou-heal-clone-$REPO_TAG.XXXXXX")"

Neither is reaped on exit (deliberately — the evidence dir is the artifact a human or
the next healer reads, and the path is posted to Mattermost) and nothing ever reaps
them later. They accumulate for the life of the box.

Observed

On bens-mac-04, 2026-11-06 01:38Z, while healing #335 (that host out of disk):
1133 matou-heal-* directories in /tmp, 1115 of them older than 12 h, ~190M
total. A heal clone is the bigger unit — the one from this incident alone is 68M.

190M is not what filled that disk (see #335: ~150G is root-owned /opt/rollover), so
this is not the cause of #335. But it is factory-generated litter on a filesystem the
factory itself needs headroom on, it grows monotonically with heal frequency, and on a
box flapping at zero headroom every hundred MB decides whether a leg starts
(GOTCHAS #315: "a few hundred spare bytes decide it").

Suggested shape

A retention sweep at the TOP of heal.sh, before the new mktemp -d, over
/tmp/matou-heal-$REPO_TAG.* and /tmp/matou-heal-clone-$REPO_TAG.*:

  • Keep anything newer than a retention window (a few days) — a recent evidence dir is
    live context for a human reading a Mattermost ping and for the next healer's
    older-worker-context tail.
  • Also keep the N newest regardless of age, so a quiet repo never loses its last
    evidence bundle to the clock.
  • Scope by $REPO_TAG, so one repo's sweep never touches another repo's bundles
    (the #238 per-repo prefix exists exactly to keep those apart).
  • Best-effort: || true, never let the sweep fail a heal run. The healer already
    holds a per-repo lock, so a concurrent same-repo healer is not a concern; a
    different repo's healer is excluded by the tag scoping.
  • Needs an offline test in tests/ alongside the existing heal tests (fixture dirs
    with pinned mtimes; assert the window, the keep-N floor, and the cross-tag
    boundary).

Notes for whoever takes this

The healer charter forbids the healer modifying heal.sh, which is why this is a
ticket and not a hotfix — filed by the watchdog healer during the #335 incident, which
reclaimed the 1115 stale dirs by hand as a one-off.

heal.sh is a root (harness-source) file, so the fix does not reach any running
.sandcastle/ copy until a human re-vendors at a new FACTORY_REF (GOTCHAS 4).

Related: #335 (the host-disk incident that surfaced it), GOTCHAS #315.

`heal.sh` `mktemp -d`s two directories per incident and never removes either: - `heal.sh:187` — `EVIDENCE="$(mktemp -d "/tmp/matou-heal-$REPO_TAG.XXXXXX")"` - `heal.sh:530` — `HEAL_CLONE="$(mktemp -d "/tmp/matou-heal-clone-$REPO_TAG.XXXXXX")"` Neither is reaped on exit (deliberately — the evidence dir is the artifact a human or the next healer reads, and the path is posted to Mattermost) and nothing ever reaps them *later*. They accumulate for the life of the box. ## Observed On `bens-mac-04`, 2026-11-06 01:38Z, while healing #335 (that host out of disk): **1133 `matou-heal-*` directories in `/tmp`**, 1115 of them older than 12 h, ~190M total. A heal clone is the bigger unit — the one from this incident alone is 68M. 190M is not what filled that disk (see #335: ~150G is root-owned `/opt/rollover`), so this is not the cause of #335. But it is factory-generated litter on a filesystem the factory itself needs headroom on, it grows monotonically with heal frequency, and on a box flapping at zero headroom every hundred MB decides whether a leg starts (GOTCHAS #315: "a few hundred spare bytes decide it"). ## Suggested shape A retention sweep at the TOP of `heal.sh`, before the new `mktemp -d`, over `/tmp/matou-heal-$REPO_TAG.*` and `/tmp/matou-heal-clone-$REPO_TAG.*`: - Keep anything newer than a retention window (a few days) — a recent evidence dir is live context for a human reading a Mattermost ping and for the next healer's older-worker-context tail. - Also keep the N newest regardless of age, so a quiet repo never loses its last evidence bundle to the clock. - Scope by `$REPO_TAG`, so one repo's sweep never touches another repo's bundles (the #238 per-repo prefix exists exactly to keep those apart). - Best-effort: `|| true`, never let the sweep fail a heal run. The healer already holds a per-repo lock, so a concurrent same-repo healer is not a concern; a *different* repo's healer is excluded by the tag scoping. - Needs an offline test in `tests/` alongside the existing heal tests (fixture dirs with pinned mtimes; assert the window, the keep-N floor, and the cross-tag boundary). ## Notes for whoever takes this The healer charter forbids the healer modifying `heal.sh`, which is why this is a ticket and not a hotfix — filed by the watchdog healer during the #335 incident, which reclaimed the 1115 stale dirs by hand as a one-off. `heal.sh` is a root (harness-source) file, so the fix does not reach any running `.sandcastle/` copy until a human re-vendors at a new `FACTORY_REF` (GOTCHAS 4). Related: #335 (the host-disk incident that surfaced it), GOTCHAS #315.
Author
Member

swarm-claim host=matou-dev-server-01 run=26502
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=26502 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

Blocked — cannot-proceed (broken environment: host out of disk).

This run (run=26509, host bens-mac-04) could not complete #338 because the host filled to 0 bytes free mid-run — the #335 / GOTCHAS #315 disk-full class this very ticket is about. git commit fails unable to write loose object file: No space left on device, and every mktemp -d (so the whole offline test suite) fails No space left on device.

The fix IS written and was verified green before the disk filled:

  • heal-lib.sh — new best-effort heal_sweep_tmp <tmpdir> <repo_tag> [now]: keeps anything inside HEAL_TMP_RETENTION (3 days) and, per prefix, the HEAL_TMP_KEEP (5) newest regardless of age; reaps the rest. Scoped by $REPO_TAG (the #238 per-repo prefix) so one repo's sweep never touches another's; swallows every error and always returns 0, so a sweep never fails a heal run.
  • heal.sh — calls it || true immediately before the evidence mktemp -d.
  • tests/heal-lib-test.sh — fixture dirs with pinned mtimes proving the window, the keep-N floor, the cross-tag boundary, the KEEP=0 window-only case, and the missing-tmpdir / no-match best-effort paths. Ran green: heal-lib: 29 groups passed (and heal-test.sh, docs-budget-test.sh, vendor-manifest-coverage-test.sh passed) BEFORE / hit 100%.
  • docs/GOTCHAS.md + docs/gotchas/338-*.md — new hazard #338.
  • docs/journal/2026-11-06-338.md — journal entry (no STATUS.md surface row change).

The change was staged but the commit could not be written to disk, so nothing landed — the working-tree edits are lost when this sandbox is torn down and must be redone next run (cheap: the diff is small and the design is settled above).

What a human must do to re-arm: free disk on bens-mac-04 (per #335, the bulk is root-owned /opt/rollover; this host is also the one accumulating the heal litter #338 fixes), then re-add ready-for-agent. A healthy host will re-do the small change from the design above and land it.

(Note: a concurrent lower-id claim run=26502 on matou-dev-server-01 is also on this ticket; per the multi-host tiebreak that host owns it and may land independently — the close-report gate closes on verified commits regardless of these labels. This comment records bens-mac-04's stand-down.)

**Blocked — cannot-proceed (broken environment: host out of disk).** This run (`run=26509`, host **bens-mac-04**) could not complete #338 because the host filled to **0 bytes free** mid-run — the #335 / GOTCHAS #315 disk-full class this very ticket is about. `git commit` fails `unable to write loose object file: No space left on device`, and every `mktemp -d` (so the whole offline test suite) fails `No space left on device`. **The fix IS written and was verified green before the disk filled:** - `heal-lib.sh` — new best-effort `heal_sweep_tmp <tmpdir> <repo_tag> [now]`: keeps anything inside `HEAL_TMP_RETENTION` (3 days) and, per prefix, the `HEAL_TMP_KEEP` (5) newest regardless of age; reaps the rest. Scoped by `$REPO_TAG` (the #238 per-repo prefix) so one repo's sweep never touches another's; swallows every error and always returns 0, so a sweep never fails a heal run. - `heal.sh` — calls it `|| true` immediately before the evidence `mktemp -d`. - `tests/heal-lib-test.sh` — fixture dirs with pinned mtimes proving the window, the keep-N floor, the cross-tag boundary, the `KEEP=0` window-only case, and the missing-tmpdir / no-match best-effort paths. **Ran green: `heal-lib: 29 groups passed`** (and `heal-test.sh`, `docs-budget-test.sh`, `vendor-manifest-coverage-test.sh` passed) BEFORE `/` hit 100%. - `docs/GOTCHAS.md` + `docs/gotchas/338-*.md` — new hazard #338. - `docs/journal/2026-11-06-338.md` — journal entry (no `STATUS.md` surface row change). The change was staged but the commit could not be written to disk, so **nothing landed** — the working-tree edits are lost when this sandbox is torn down and must be redone next run (cheap: the diff is small and the design is settled above). **What a human must do to re-arm:** free disk on **bens-mac-04** (per #335, the bulk is root-owned `/opt/rollover`; this host is also the one accumulating the heal litter #338 fixes), then re-add `ready-for-agent`. A healthy host will re-do the small change from the design above and land it. (Note: a concurrent lower-id claim `run=26502` on `matou-dev-server-01` is also on this ticket; per the multi-host tiebreak that host owns it and may land independently — the close-report gate closes on verified commits regardless of these labels. This comment records bens-mac-04's stand-down.)
Author
Member

Measured on the second host — matou-workstation is far worse than the
bens-mac-04 figure in the title.
From heal run
heal-Matou-dev-factory-1793962882-599211 (2026-11-06 11:01Z, healer host
matou-dev-server-01):

$ ls -d /tmp/matou-heal-* | wc -l
6177
$ du -sh --total /tmp/matou-heal-*   # tail
507M    total
$ du -sh /tmp
3.4G

6177 leaked evidence/clone dirs here against the 1133 this ticket reports on
bens-mac-04 — so the leak scales with how much healing a host does, and
matou-workstation is the host that heals for the whole fleet. Byte cost is
modest (507M), so this is an inode/clutter leak more than a space leak on
this box — but it is the same unbounded growth with no retention sweep.

For scope honesty: this host is at 98% / 6.8G free (host.txt), and the
heal dirs are not the main consumer — /home/dev/swarm is 28G and four
app-build-* trees are ~12G each (~55G together). A retention sweep for
/tmp/matou-heal-* is still right, but it will not by itself pull
matou-workstation back off the #305/#335 cliff; that needs its own look at the
app-build-* / payload-manual-* accumulation.

No cleanup performed — this healer's one bounded repair was not spent here (the
incident's root cause is #335, host-level and human-owned), and 6177 dirs
include live bundles for two concurrently-running healer sessions, so a blind
sweep from inside a heal run is the wrong actor for it.

**Measured on the second host — matou-workstation is far worse than the bens-mac-04 figure in the title.** From heal run `heal-Matou-dev-factory-1793962882-599211` (2026-11-06 11:01Z, healer host `matou-dev-server-01`): ``` $ ls -d /tmp/matou-heal-* | wc -l 6177 $ du -sh --total /tmp/matou-heal-* # tail 507M total $ du -sh /tmp 3.4G ``` **6177** leaked evidence/clone dirs here against the 1133 this ticket reports on bens-mac-04 — so the leak scales with how much healing a host does, and `matou-workstation` is the host that heals for the whole fleet. Byte cost is modest (507M), so this is an **inode/clutter** leak more than a space leak on this box — but it is the same unbounded growth with no retention sweep. For scope honesty: this host is at **98% / 6.8G free** (`host.txt`), and the heal dirs are *not* the main consumer — `/home/dev/swarm` is 28G and four `app-build-*` trees are ~12G each (~55G together). A retention sweep for `/tmp/matou-heal-*` is still right, but it will not by itself pull `matou-workstation` back off the #305/#335 cliff; that needs its own look at the `app-build-*` / `payload-manual-*` accumulation. No cleanup performed — this healer's one bounded repair was not spent here (the incident's root cause is #335, host-level and human-owned), and 6177 dirs include live bundles for two concurrently-running healer sessions, so a blind sweep from inside a heal run is the wrong actor for it.
Author
Member

Measurement from the #335 heal on bens-mac-04 (2026-11-07 04:42Z) that narrows the dominant source: of the 208 /tmp/matou-heal-* dirs present, 169 were created inside a single hour (22:00 local) and all carry the repo tag x-y — i.e. they are not real incidents at all, they are fixtures from the offline suite (tests/heal-test.sh drives heal.sh, whose mktemp -d "/tmp/matou-heal-$REPO_TAG.XXXXXX" at heal.sh:187 and the clone dir at heal.sh:606 both survive the test).

So the accumulation is mostly test residue, not production residue, and the per-dir cost is small: all 208 together were only 81 MB. Two consequences for the fix:

  • A retention sweep in heal.sh alone will not stop the bulk of the growth — the suite needs to clean up after itself too (or heal.sh needs to honour a TMPDIR the test can point at a scratch dir it removes).
  • Inode/entry pressure is the real cost, not bytes: /tmp was at 5098 entries, which is what makes ls /tmp and glob expansion slow for every other tenant on the box.

I reclaimed the 21 dirs older than 6 h as part of the #335 heal (excluding the live incident's own evidence + clone), leaving 187. I did not touch the newer ones — a concurrent healer for another repo may still own them.

Measurement from the #335 heal on bens-mac-04 (2026-11-07 04:42Z) that narrows the dominant source: of the 208 `/tmp/matou-heal-*` dirs present, **169 were created inside a single hour (22:00 local) and all carry the repo tag `x-y`** — i.e. they are not real incidents at all, they are fixtures from the offline suite (`tests/heal-test.sh` drives `heal.sh`, whose `mktemp -d "/tmp/matou-heal-$REPO_TAG.XXXXXX"` at heal.sh:187 and the clone dir at heal.sh:606 both survive the test). So the accumulation is mostly *test* residue, not production residue, and the per-dir cost is small: all 208 together were only **81 MB**. Two consequences for the fix: - A retention sweep in `heal.sh` alone will not stop the bulk of the growth — the suite needs to clean up after itself too (or `heal.sh` needs to honour a `TMPDIR` the test can point at a scratch dir it removes). - Inode/entry pressure is the real cost, not bytes: `/tmp` was at 5098 entries, which is what makes `ls /tmp` and glob expansion slow for every other tenant on the box. I reclaimed the 21 dirs older than 6 h as part of the #335 heal (excluding the live incident's own evidence + clone), leaving 187. I did not touch the newer ones — a concurrent healer for another repo may still own them.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#338
No description provided.