You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(disk-hygiene): stopped inventory leaves a multi-GB .tmp and inventories are never pruned #17085
disk-hygienehygiene.py inventory writes to inventory/inventory-<stamp>.jsonl.<id>.tmp in its plugin data directory and does not remove that file when the run is stopped. A home-directory inventory stopped with TaskStop on 2026-11-18 left a 5.19 GB .tmp behind (removed by hand). The completed inventory from 2026-10-12 (523 MB .jsonl) is also still kept, with no retention.
The disk-hygiene plugin was the third-largest plugin data directory on the host (5.4 GB), which is the kind of leftover it exists to find.
Proposed fix
Remove the partial .tmp on SIGTERM/SIGINT (and on the next start, any .tmp whose writer PID is gone).
Keep only the newest N inventories, or delete them after the report is read.
Consider a smaller inventory format for a home walk: 5 GB of JSONL for one home tree is larger than many of the leftovers it reports.
Size: Small
Complexity: Medium
Uncertainty: Known
Flags: none
Blocked by: none
Blast radius: disk-hygiene's hygiene.py run_inventory and test_hygiene.py; anyone running hygiene.py inventory.
Reversible: yes; revert the change. Pruned inventories are regenerable output.
Open questions: none
Decision recorded. Owner, 2026-11-20, typed in the owning session (verbatim): "I want to make sure that the recommendations are grounded in facts, data, metrics, and research from the latest consensus-based research from official, authoritative, and trusted sources, and just go with the recommendations there." The recommendation was checked against the code at origin/main and current official sources before this record; the decision below is the grounded one.
Q117 (CONFIRMED (sweep draft as written))
Go with the refinement's recommendations. (1) The partial's name carries the writer PID (inventory-<stamp>.jsonl.<pid>.<hex>.tmp). At the start of run_inventory, delete .tmp files in the inventory directory whose PID is not alive, and leave legacy names that carry no PID alone. (2) After a successful run, keep the newest 3 completed inventories, counting each .jsonl with its .json summary as one pair, and prune older pairs. Delete-after-read is out because nothing records a read. (3) Inside run_inventory, a SIGTERM handler raises SystemExit so the existing finally unlinks the partial. The old handler is restored afterward, and the test is POSIX-only. (4) A smaller inventory format is out of scope.
[quote truncated; the full decision is at the link]
Not admitted to the issue lane: no trusted-human acceptance criteria: a listed human must put the confirmed - [ ] criteria in the body or post them as their own comment, or, on an issue a listed human filed, intake's newest refinement comment must hold them unedited. Admission takes the issue once each of those is met, when intake triages it again (.github/actions/resolve-config/admission-rules.json).
melodic-automation-lanes commented on Nov 18, 2026
Refinement. A read-only run explored this repository, searched its issues and pull requests, and read the allowed docs to draft what follows. On an issue a listed human filed, it counts as the issue's spec once posted, while unedited; it is still model text, so check it.
Intended outcome: hygiene.py inventory removes its partial .tmp on SIGTERM/SIGINT, sweeps orphaned .tmp files at the next start, and keeps only the newest N inventories; a smaller format is handled separately.
How should orphaned .tmp files be matched at next start? The name is inventory-<stamp>.jsonl.<4-byte hex>.tmp and carries no writer PID, so a dead writer cannot be read from existing files.
RECOMMENDED: Put the PID in the new name (inventory-<stamp>.jsonl.<pid>.<hex>.tmp) and at the start of run_inventory delete .tmp files in the inventory directory whose PID is not alive; leave legacy names without a PID alone. Basis: plugins/disk-hygiene/skills/clean/scripts/hygiene.py:5184
Which retention form and what N? The issue offers keep the newest N or delete after the report is read, and a run cannot choose a number for deleting user files.
RECOMMENDED: Keep the newest 3 completed inventories, counting each .jsonl with its .json summary as a pair, and prune older pairs after a successful run; skip delete-after-read because nothing records that a report was read. Basis: judgment
How should SIGTERM be handled? Python's default SIGTERM ends the process without running the finally block, so the partial file survives; SIGINT raises KeyboardInterrupt and the finally unlinks it.
RECOMMENDED: Install a SIGTERM handler inside run_inventory that raises SystemExit so the existing finally unlinks the partial, and restore the old handler afterward. Windows has no real SIGTERM delivery, so test on POSIX only. Basis: plugins/disk-hygiene/skills/clean/scripts/hygiene.py:5187
Is item 3 (smaller inventory format) in scope? It says consider, has no done-when, and would change the row format that validate_report and the skill docs rely on.
RECOMMENDED: Out of scope here; file a separate issue for it, and this issue covers items 1 and 2 only. Basis: judgment
Sources read
plugins/disk-hygiene/skills/clean/scripts/hygiene.py:5157: run_inventory streams rows to a partial named inventory-<stamp>.jsonl.<hex>.tmp, os.replace on success, finally unlinks the partial; no signal handler and no pruning
plugins/disk-hygiene/skills/clean/scripts/hygiene.py:384: write_text_atomic uses the same tmp-then-replace pattern for the summary .json
plugins/disk-hygiene/skills/clean/scripts/hygiene.py:5222: summary inventory-<stamp>.json is written beside the rows and is also never pruned
plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py: no existing test covers run_inventory cleanup or retention
To answer, post a comment that starts with this line:
**Decision recorded.** <answer>
Automated refinement by the lanes App. Answer with a comment whose first line is **Decision recorded.**.
Decision recorded. Owner, 2026-11-20, typed in the owning session (verbatim): "I want to make sure that the recommendations are grounded in facts, data, metrics, and research from the latest consensus-based research from official, authoritative, and trusted sources, and just go with the recommendations there." The recommendation was checked against the code at origin/main and current official sources before this record; the decision below is the grounded one.
Q117 (CONFIRMED (sweep draft as written))
Go with the refinement's recommendations. (1) The partial's name carries the writer PID (inventory-<stamp>.jsonl.<pid>.<hex>.tmp). At the start of run_inventory, delete .tmp files in the inventory directory whose PID is not alive, and leave legacy names that carry no PID alone. (2) After a successful run, keep the newest 3 completed inventories, counting each .jsonl with its .json summary as one pair, and prune older pairs. Delete-after-read is out because nothing records a read. (3) Inside run_inventory, a SIGTERM handler raises SystemExit so the existing finally unlinks the partial. The old handler is restored afterward, and the test is POSIX-only. (4) A smaller inventory format is out of scope.
Basis
plugins/disk-hygiene/skills/clean/scripts/hygiene.py:5184 partial = ...{secrets.token_hex(4)}.tmp (no PID); :5187-5205 try / os.replace / finally: partial.unlink; no signal handler. Read via the Read tool; the file is identical to origin/main.
:5222 summary .json is written beside the rows, so "pair" is the right unit for retention
https://docs.python.org/3/library/signal.html (fetched 2026-11-20): "A small number of default handlers are installed: SIGPIPE is ignored ... and SIGINT is translated into a KeyboardInterrupt exception". So SIGTERM is left at SIG_DFL ("perform the default function for the signal"). That is the OS default action, termination on Unix, with no Python exception, so finally does not run. The page does not state SIGTERM's OS default; that part comes from the OS.
Dissent considered
none found. N=3 is judgment. The files are the plugin's own regenerable output under its data root, so N is a default the lane may set.
Confirmed done-when for the decision above (owner direction of 2026-11-20 recorded there).
In plugins/disk-hygiene/skills/clean/scripts/hygiene.py, run_inventory names its partial inventory-<stamp>.jsonl.<pid>.<hex>.tmp, carrying the writer PID.
At the start of run_inventory, .tmp files in the inventory directory whose PID is not alive are deleted, and legacy .tmp names that carry no PID are left alone.
After a successful inventory, run_inventory keeps the newest 3 completed inventories, counting each .jsonl with its .json summary as one pair, and prunes older pairs.
Inside run_inventory, a SIGTERM handler raises SystemExit so the existing finally unlinks the partial, and the previous SIGTERM handler is restored afterward.
plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py covers the dead-PID sweep (a live PID's partial and a legacy name are kept), the keep-3 pruning by pair, and a SIGTERM during run_inventory that leaves no partial; the SIGTERM test is POSIX-only (skipped where SIGTERM delivery is unavailable).
Activity
github-actions commentedon Nov 18, 2026
Size: Small
Complexity: Medium
Uncertainty: Known
Flags: none
Blocked by: none
Blast radius: disk-hygiene's hygiene.py
run_inventoryand test_hygiene.py; anyone runninghygiene.py inventory.Reversible: yes; revert the change. Pruned inventories are regenerable output.
Open questions: none
#17085 (comment)
This decision settles the open questions, and the confirmed done-when in the later comment is exact. I found no duplicate or merged fix.
Automated triage. A maintainer reviews it.
melodic-automation-lanes commentedon Nov 18, 2026
Not admitted to the issue lane: no trusted-human acceptance criteria: a listed human must put the confirmed
- [ ]criteria in the body or post them as their own comment, or, on an issue a listed human filed, intake's newest refinement comment must hold them unedited. Admission takes the issue once each of those is met, when intake triages it again (.github/actions/resolve-config/admission-rules.json).melodic-automation-lanes commentedon Nov 18, 2026
Refinement. A read-only run explored this repository, searched its issues and pull requests, and read the allowed docs to draft what follows. On an issue a listed human filed, it counts as the issue's spec once posted, while unedited; it is still model text, so check it.
Intended outcome: hygiene.py inventory removes its partial .tmp on SIGTERM/SIGINT, sweeps orphaned .tmp files at the next start, and keeps only the newest N inventories; a smaller format is handled separately.
Related work
Open questions
RECOMMENDED: Put the PID in the new name (inventory-<stamp>.jsonl.<pid>.<hex>.tmp) and at the start of run_inventory delete .tmp files in the inventory directory whose PID is not alive; leave legacy names without a PID alone. Basis: plugins/disk-hygiene/skills/clean/scripts/hygiene.py:5184
RECOMMENDED: Keep the newest 3 completed inventories, counting each .jsonl with its .json summary as a pair, and prune older pairs after a successful run; skip delete-after-read because nothing records that a report was read. Basis: judgment
RECOMMENDED: Install a SIGTERM handler inside run_inventory that raises SystemExit so the existing finally unlinks the partial, and restore the old handler afterward. Windows has no real SIGTERM delivery, so test on POSIX only. Basis: plugins/disk-hygiene/skills/clean/scripts/hygiene.py:5187
RECOMMENDED: Out of scope here; file a separate issue for it, and this issue covers items 1 and 2 only. Basis: judgment
Sources read
To answer, post a comment that starts with this line:
Automated refinement by the lanes App. Answer with a comment whose first line is
**Decision recorded.**.kyle-sexton commentedon Nov 21, 2026
Decision recorded. Owner, 2026-11-20, typed in the owning session (verbatim): "I want to make sure that the recommendations are grounded in facts, data, metrics, and research from the latest consensus-based research from official, authoritative, and trusted sources, and just go with the recommendations there." The recommendation was checked against the code at origin/main and current official sources before this record; the decision below is the grounded one.
Q117 (CONFIRMED (sweep draft as written))
Go with the refinement's recommendations. (1) The partial's name carries the writer PID (
inventory-<stamp>.jsonl.<pid>.<hex>.tmp). At the start ofrun_inventory, delete.tmpfiles in the inventory directory whose PID is not alive, and leave legacy names that carry no PID alone. (2) After a successful run, keep the newest 3 completed inventories, counting each.jsonlwith its.jsonsummary as one pair, and prune older pairs. Delete-after-read is out because nothing records a read. (3) Insiderun_inventory, a SIGTERM handler raisesSystemExitso the existingfinallyunlinks the partial. The old handler is restored afterward, and the test is POSIX-only. (4) A smaller inventory format is out of scope.Basis
partial = ...{secrets.token_hex(4)}.tmp(no PID); :5187-5205try/os.replace/finally: partial.unlink; no signal handler. Read via the Read tool; the file is identical to origin/main..jsonis written beside the rows, so "pair" is the right unit for retentionfinallydoes not run. The page does not state SIGTERM's OS default; that part comes from the OS.Dissent considered
none found. N=3 is judgment. The files are the plugin's own regenerable output under its data root, so N is a default the lane may set.
kyle-sexton commentedon Nov 21, 2026
Confirmed done-when for the decision above (owner direction of 2026-11-20 recorded there).
plugins/disk-hygiene/skills/clean/scripts/hygiene.py,run_inventorynames its partialinventory-<stamp>.jsonl.<pid>.<hex>.tmp, carrying the writer PID.run_inventory,.tmpfiles in the inventory directory whose PID is not alive are deleted, and legacy.tmpnames that carry no PID are left alone.run_inventorykeeps the newest 3 completed inventories, counting each.jsonlwith its.jsonsummary as one pair, and prunes older pairs.run_inventory, a SIGTERM handler raisesSystemExitso the existingfinallyunlinks the partial, and the previous SIGTERM handler is restored afterward.plugins/disk-hygiene/skills/clean/scripts/test_hygiene.pycovers the dead-PID sweep (a live PID's partial and a legacy name are kept), the keep-3 pruning by pair, and a SIGTERM duringrun_inventorythat leaves no partial; the SIGTERM test is POSIX-only (skipped where SIGTERM delivery is unavailable).test_hygiene.pypasses.melodic-automation-lanes commentedon Nov 21, 2026
{"v":1,"actor_id":337595936,"title_sha256":"b9b0a1a9cf741220753bfeda68b63139c50e9e3f32460fd210a4110e13e18925","body_sha256":"46f48f6eb16f184517e343bbf3f87d54ed45922aaf8da8eda1ee3fc37ecb9d63"}
melodic-automation-lanes commentedon Nov 21, 2026
{"v":1,"actor_id":337595936,"title_sha256":"b9b0a1a9cf741220753bfeda68b63139c50e9e3f32460fd210a4110e13e18925","body_sha256":"46f48f6eb16f184517e343bbf3f87d54ed45922aaf8da8eda1ee3fc37ecb9d63"}
github-actions commentedon Nov 21, 2026
github-actions commentedon Nov 21, 2026
test(disk-hygiene): list the inventory sweep and prune as engine dele…
test(disk-hygiene): pin what the inventory sweep and prune may delete