Skip to content

refactor(disk-hygiene): simplify guard_launch_monitor.py - #15154

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14452-42880138694-1
Nov 10, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14452-42880138694-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14452

Summary

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

Simplified guard_launch_monitor.py without changing what it does. The two constants that both held "destructive_guard.py" are now one. The plugin root is computed once and shared by _LIB_DIR and _CHECKER_HINT. _iter_guard_failures checks each record with fewer branches, and _run converts session_id to a string once and merges its two transcript-path early returns. _build_message now formats the dict _audit_fields already builds instead of reading the latest failure a second time. engine_context.py is left as it is: it is 70 lines with one small function and main(), and no cleanup in it would make it clearer without changing the output or the names its test patches.

Not verified

  • The Python unit tests (test_guard_launch_monitor.py, test_engine_context.py) and guard_launch_monitor.test.sh were not run directly: this lane's Bash allows only the named wrappers. They are left to the PR's CI; check-affected ran its local selection.
  • ruff lint of the touched file was not run directly (no interpreter or ruff call allowed in this lane). It is left to the PR's CI. The repo's ruff selection (E4, E7, E9, F) covers imports, statements and pyflakes, and the review found no unused or undefined name.
  • tidy-diff ran passes 1 to 3 (simplify, comments, residue) with no edits. It skipped pass 4 (docs-hygiene writing rules) because the fragment's only prose line is the exact text the issue requires. It skipped pass 5 (ai-slop:audit fix) because the lane's Bash allowlist refuses its detect.sh detector…
  • ci-status green on the PR is a PR CI check, not something this run can check.
  • The working tree has untracked dotfiles at the checkout root (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) that this run did not create; they look like sandbox mount placeholders and are not part of this change.

Fix

  • plugins/disk-hygiene/skills/clean/scripts/guard_launch_monitor.py: _GUARD_COMMAND_SUBSTRING and _GUARD_DISPLAY_NAME (same value) merged into _GUARD_SCRIPT. Plugin root computed once as _PLUGIN_ROOT, which _LIB_DIR and _CHECKER_HINT now use (_CHECKER_HINT has the same value). _FAILURE_TYPE names the…
  • .changes/disk-hygiene/work-resolve-issue-issue-14452-42880138694-1-70c7460d.md: new patch fragment (made with new-changelog-fragment), ### Changed with "Internal simplification, no behavior change."

Verification

The runner ran each check from the base copy against d8d2693:

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

The run reports:

  • check-changelog-fragments: all 6 fragments valid (run before and after tidy)
  • check-changed-skills: CHECK-SKILL clean PASS, 0 errors, 3 warnings that were there before this change (description length, body length, token count)
  • check-affected: 13 passed, 6 skipped over 2 changed files (run before and after tidy)
  • fresh-context review subagent over git-read diff HEAD: no behavior difference found. It confirmed the output text, exit paths and every module attribute test_guard_launch_monitor.py and test_hygiene.py patch or read (_read_new, _write_marker, _resolve_data_root, _run, _CHECKER_HINT,…
  • diff size: 2 files (1 code file, 1 fragment), about 60 changed lines, 1 area (disk-hygiene)
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42880138694

Left out: the items under Not verified.

Related

#14452

Merge-Risk: max=MEDIUM demote=false head=d8d2693bf580578f7e103c858a3e0db6e388e705 rubric=8.3.5 rater=claude-opus-5-5 checker=claude-opus-5-5

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read every hunk of both changed files: guard_launch_monitor.py and the new changelog fragment. I also read the head file around the changed functions. The refactor behaves the same as before:

  • except ValueError: json.JSONDecodeError is a subclass of ValueError, so the narrower clause catches the same errors as the old tuple.
  • _iter_guard_failures: each merged condition and the inverted final yield filter the same records as before.
  • Transcript-path guard in _run: the merged check is equivalent. An empty string passes isinstance(..., str) and then fails os.path.isfile(""), so it still returns early. None and non-string values still return early too.
  • session_id: it is converted with str() once. Every callee received str(session_id) before, so they all get the same value.
  • _build_message(audit_fields): _audit_fields builds exit_code, duration_ms and stderr (through _format_stderr) from failures[-1], which is what the old body computed. The warning text does not change. _audit_fields has no side effects, so calling it earlier changes nothing.
  • Constants: _CHECKER_HINT keeps its value, now built from _PLUGIN_ROOT. _GUARD_SCRIPT replaces two constants that held the same string. A search of the repo found nothing outside the changed file that uses the removed names (_GUARD_COMMAND_SUBSTRING, _GUARD_DISPLAY_NAME, the module's _PLUGIN_ROOT_TEXT) or calls _build_message. destructive_guard.py has its own _PLUGIN_ROOT_TEXT and is not affected.

Closing issue #14452 acceptance criteria

  • Behavior unchanged: met, based on reading the code. I did not run the tests. The author says the unit tests and ruff were not run and were left to CI.
  • Edits only listed files plus fragments: met.
  • Within 400 lines and 15 files: met (2 files, about 60 lines).
  • ci-status green: not something this lane can check.
  • Fragment with bump: patch, ### Changed and the required line: met.

The PR leaves engine_context.py unchanged, with a stated reason. The issue's acceptance criteria don't require editing it.

No plugin manifest changed. No embedded instructions were found in the PR context.

@github-actions

Copy link
Copy Markdown
Contributor

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

Security review: PR #15154 (refactor(disk-hygiene): simplify guard_launch_monitor.py)

I found no security issues.

I read every hunk of both changed files:

  • .changes/disk-hygiene/…-70c7460d.md: a new changelog fragment (bump: patch, prose only). It has no security-relevant surface.
  • plugins/disk-hygiene/skills/clean/scripts/guard_launch_monitor.py: this is the monitor that warns when destructive_guard.py failed to launch or exited non-zero. That makes it a detection control for a guard, so I checked it for any lost detection rather than skipping it as a refactor. I compared the base and head logic:
    • _iter_guard_failures: catching ValueError alone still covers json.JSONDecodeError, which is a subclass of it. The merged isinstance/type checks keep the same filter: attachment → hook_non_blocking_error → a command string containing destructive_guard.py. Nothing that matched before is now dropped.
    • _run: merging the early returns keeps the same behaviour. An empty or non-string transcript_path still returns early, because os.path.isfile("") is False. Converting session_id to a string once gives the same values as the earlier per-call str().
    • _build_message: it now formats the _audit_fields dict. At head, exit_code, duration_ms and stderr there come from the same latest failure through the same _format_stderr, so the warning text is unchanged (guard_launch_monitor.py:381-398).
    • _CHECKER_HINT / _PLUGIN_ROOT: same value, now computed once. The old names _GUARD_COMMAND_SUBSTRING, _GUARD_DISPLAY_NAME and _PLUGIN_ROOT_TEXT have no other readers in this file. destructive_guard.py defines its own _PLUGIN_ROOT_TEXT, which this change does not touch.

No changed file matches a trusted-path glob, and the diff changes no plugin manifest, trust control or standing instruction. The PR context contains no embedded directives aimed at this lane.

Prior findings: none (0 earlier heads reviewed, so this was a full review, not blocking-only).

critical-findings: 0

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head d8d2693bf580578f7e103c858a3e0db6e388e705, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for d8d2693

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-15154-d8d2693bf580578f7e103c858a3e0db6e388e705, expires on 2026-12-10.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit 1445909 Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14452-42880138694-1 branch November 10, 2026 19:56
@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/guard_launch_monitor.py 6 1 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/disk-hygiene/skills/clean/scripts/guard_launch_monitor.py:354 LCR 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.

Simplify the clean disk-hygiene plugin code

0 participants