Skip to content

fix(disk-hygiene): remove stopped inventory partials and keep only the newest three reports - #17819

Merged
kyle-sexton merged 3 commits into
mainfrom
work-resolve-issue/issue-17085-44866406152-1
Nov 21, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
work-resolve-issue/issue-17085-44866406152-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #17085

Summary

Opened by the work-resolve-issue lane. The run's own summary:

hygiene.py inventory now names its partial inventory-<stamp>.jsonl.<pid>.<hex>.tmp, installs a SIGTERM handler inside run_inventory that raises SystemExit so the existing finally unlinks the partial (the previous handler is restored afterward), and at start deletes partials whose writer PID is gone while leaving legacy no-PID names alone. After a run that passes validation it keeps the newest 3 reports, counting each .jsonl with its .json summary as one pair, and deletes older pairs. This builds the owner's recorded decision on #17085; the smaller inventory format is out of scope and the row format is unchanged. Design choices: PID liveness uses os.kill(pid, 0) on POSIX (ProcessLookupError or OverflowError means dead, any other OSError counts as alive) and OpenProcess on Windows, where only ERROR_INVALID_PARAMETER counts as dead, because os.kill with signal 0 on Windows would terminate the target process. Pruning is skipped when validation fails, so a run of failed reports cannot delete the last good one; this reads the done-when's 'after a successful inventory' as a validated one.

Not verified

  • test_hygiene.py was not run: this lane's Bash runs only the named wrappers, with no Python interpreter, so the suite is left to the PR's CI
  • The Windows OpenProcess path of process_alive is covered only by test_own_pid_is_alive; the claim that a nonexistent PID fails with ERROR_INVALID_PARAMETER is not on the Microsoft page read, so any other failure is treated as alive and the file is kept
  • tidy: the ai-slop detector script could not run (Bash runs only the named wrappers), so pass 5 was a rubric read only; no findings. The other passes ran: one simplify edit (path.stem in prune_inventory_reports), no comments to delete, and two residue proposals left unapplied: the 'except OSError:…
  • build/lint: no Python lint or type check ran locally beyond check-affected; ruff, mypy and the test suite run in the PR's CI

Fix

  • plugins/disk-hygiene/skills/clean/scripts/hygiene.py: import signal; add INVENTORY_REPORTS_KEPT, INVENTORY_STEM, INVENTORY_PARTIAL, process_alive, sweep_orphaned_inventory_partials, prune_inventory_reports and _exit_on_sigterm; run_inventory sweeps dead-writer partials at start, names the partial…
  • plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py: tests for the PID in the partial name, the dead-PID sweep (live-PID and legacy partials kept), process_alive on its own PID and on a reaped child or oversized PID (POSIX), keep-3 pruning by pair, and a SIGTERM during the walk that leaves no…
  • plugins/disk-hygiene/skills/clean/reference/scan-flags.md: the --deep section states the keep-3 retention and the partial cleanup
  • .changes/disk-hygiene/work-resolve-issue-issue-17085-44866406152-1-739e7433.md: patch changelog fragment under Fixed

Verification

The runner ran each check from the base copy against 223f61b:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • check-changelog-fragments: all 4 fragments valid
  • check-changed-skills: clean skill PASS, 0 errors, 3 pre-existing size warnings
  • check-affected: 15 passed, 8 skipped (typos not installed, comment-hygiene fetch blocked, size-check script missing, checks that run the checked tree's own code)
  • fresh-context review subagent: one confirmed finding (an oversized PID in a partial name raised OverflowError from os.kill and crashed every later run), fixed by treating OverflowError as not alive, with a test; its question on pruning after a validation failure was resolved by pruning only when…
  • read https: //docs.python.org/3/library/os.html#os.kill: on Windows, any signal other than CTRL_C_EVENT/CTRL_BREAK_EVENT terminates the target via TerminateProcess, so process_alive does not call os.kill there
  • read https: //docs.python.org/3/library/signal.html: signal.signal returns the previous handler, raises ValueError off the main thread, accepts SIGTERM on Windows; Python installs a default handler for SIGINT (KeyboardInterrupt) but none for SIGTERM; handlers run in the main thread
  • read https: //learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-openprocess: OpenProcess returns NULL on failure with the reason in GetLastError; ERROR_INVALID_PARAMETER for PID 0, ERROR_ACCESS_DENIED for protected processes
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/44866406152

Left out: the items under Not verified.

Related

#17085

Lane-Activity: work-resolve-issue/resolve-issue
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head 223f61bec841d53cc80d2c61d0f69daa0ce083e8. No person needs to act: a lane clears this reason, and the next scheduled run judges it again.

pr-merge's gate refuses its verifier verdict (verify:missing)

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 726f9505eb6cdd78177f0b67a6691f9a7aecaf54: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #17819, incremental since 21713656

I found no security issues in this push.

Scope: I read the whole change to the one file in scope, plugins/disk-hygiene/skills/clean/scripts/test_owner_registry.py.

What changed: a new test, test_the_inventory_sweep_and_prune_remove_only_inventory_files, parses the source of sweep_orphaned_inventory_partials and prune_inventory_reports and checks three things:

  • each function makes exactly one delete call, and it is the expected one;
  • each keeps its name-pattern guard (INVENTORY_PARTIAL.fullmatch or INVENTORY_STEM.fullmatch);
  • each keeps its process-liveness or retention guard (process_alive or INVENTORY_REPORTS_KEPT).

This adds a check that pins what those two delete paths may remove. It loosens nothing.

Why it is safe:

  • The file is test code only.
  • It matches none of the trusted paths.
  • It is not a trust control, a merge hold, a plugin manifest or a standing instruction.
  • It adds no command, network, token, credential or untrusted-input handling.

This review was blocking only, because this lane already reviewed an earlier head. Nothing qualified at any severity. No hold applies, and the change spends nothing.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 726f9505eb6cdd78177f0b67a6691f9a7aecaf54: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Code review (incremental, blocking only)

Scope: one file changed since 21713656: plugins/disk-hygiene/skills/clean/scripts/test_owner_registry.py. This lane already reviewed an earlier head, so this review reports blocking findings only.

Prior finding resolved. The earlier inline finding was Fail a change that loosens a check: the DELETERS allowlist had gained sweep_orphaned_inventory_partials and prune_inventory_reports with no pin on what they delete (discussion_r4651379318). The new test test_the_inventory_sweep_and_prune_remove_only_inventory_files fixes it. It follows the style of the existing pin tests:

  • One removal each. Using the same DELETIONS | {"remove"} filter, it asserts the only deletion call in each function is the expected one: path.unlink, or (directory / f'{stem}{suffix}').unlink.
  • Guards present. It asserts each function's source still contains its guards: INVENTORY_PARTIAL.fullmatch and process_alive, or INVENTORY_STEM.fullmatch and INVENTORY_REPORTS_KEPT.

I compared the expected strings with hygiene.py#L5192-L5218, and they match what ast.unparse produces. ast.unparse writes f-strings with single quotes, which is why the expected string uses them. I did not run the test, since this lane has no shell.

Not raised (blocking-only mode): the prior finding also asked for the comment above DELETERS (L361-363) to say what the two new entries remove. It still doesn't. That gap is advisory only, so this review drops it.

Blocking findings: none.

Spend: none.

Loosened checks would be marked: fail (the default, because the prompt has no loosened_check_verdict: line); patterns: 0. The citation requirement was not checked, because the prompt has no loosened_check_decision_record: line. The new test tightens the earlier loosening; it does not loosen anything.

Verifier dropped 0 of 0 candidates.

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/fix-ci

Run 44878957551, attempt 1

Field Value
Model rung 1
Leg handoff
Run job success
Activity step success
Commits pushed none (read lane)
Run 44878957551

Failed GitHub API calls

No failed call recorded by the run job's scripts.

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/apply-patch

Run 44878957551, attempt 1

Field Value
Model rung 1
Leg base
Run job success
Activity step skipped
Commits pushed none recorded
Run 44878957551

Failed GitHub API calls

No failed call recorded by the run job's scripts.

@melodic-automation-lanes

melodic-automation-lanes Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

The pr-unblock lane stopped fix-ci on this pull request: the lane could fix a failing check only by weakening a required check, and the head has no fresh fixer round left (it ran one, or an earlier lane stop already spent its same-head retry), so a session builder takes it. The lane labels it needs-session for a session builder, who makes the change this lane cannot, and the run ends in a failing pr-unblock/fix-ci status on the head the lane gated.

When a retry on this head can change the outcome, the lane runs one on its own, up to its per-head cap, and edits this comment if it stops again; a run that does not stop clears the status. When no retry can (a review thread the lane does not take or settle, or a failing check after the retries are spent), a person resolves the threads or gets the checks green, then dispatches the workflow below: that run finds the cause gone and clears the status. On a pull request the lanes App opened, the dispatchers start that run once per stop; on any other, a person does. A new commit to the branch starts clean.

To run it again on this head now, dispatch the pr-unblock workflow:

gh workflow run pr-unblock.yml -R melodic-software/claude-code-plugins -f pr-number=17819 -f activity=fix-ci

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/report-escalation

Run 44880970964, attempt 1

Field Value
Model rung 0
Leg base
Run job failure
Activity step skipped
Commits pushed none recorded
Run 44880970964

Failed GitHub API calls

No failed call recorded by the run job's scripts.

@melodic-automation-lanes melodic-automation-lanes Bot added the needs-session A pr-unblock stop a session builder takes: a change the lane cannot make. Not an owner stop. label Nov 21, 2026
…ters

The owner-registry guard fails any shipped deletion outside DELETERS.
#17085's recorded owner decision asks the inventory to delete partials
whose writer is gone and to keep only the newest reports, which this PR
builds in sweep_orphaned_inventory_partials and prune_inventory_reports.
Both delete only inventory files in the inventory's own directory, so
they join DELETERS, the reviewed edit the guard's docstring names for
widening what the engine may delete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton kyle-sexton removed the needs-session A pr-unblock stop a session builder takes: a change the lane cannot make. Not an owner stop. label Nov 21, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 1 inline finding(s) on 217136560efe37dbe2c0e69184ffe384e4496aa9; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/address-feedback

Run 44880970964, attempt 1

Field Value
Model rung 0
Leg handoff
Run job success
Activity step success
Commits pushed none (read lane)
Run 44880970964

Failed GitHub API calls

No failed call recorded by the run job's scripts.

Adding the two helpers to DELETERS let each delete any path with the
guard still green. Like the other non-lane deleters, each now has a pin:
the sweep's only removal is path.unlink behind INVENTORY_PARTIAL.fullmatch
and process_alive, and the prune's only removal is the stem's report pair
behind INVENTORY_STEM.fullmatch and INVENTORY_REPORTS_KEPT, the two
deletions #17085's owner decision Q117 names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/publish-feedback

Run 44880970964, attempt 1

Field Value
Model rung 0
Leg base
Run job failure
Activity step skipped
Commits pushed none recorded
Run 44880970964

Failed GitHub API calls

No failed call recorded by the run job's scripts.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit 3893691 Nov 21, 2026
61 of 62 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-17085-44866406152-1 branch November 21, 2026 08:12
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 6, survived 1, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 86%; mutation score 86%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/disk-hygiene/skills/clean/scripts/hygiene.py 6 1 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/disk-hygiene/skills/clean/scripts/hygiene.py:5165 ROR productive input-gap

The run's summary has the full report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(disk-hygiene): stopped inventory leaves a multi-GB .tmp and inventories are never pruned

1 participant