Skip to content

perf(disk-hygiene): run the guard-launch monitor only on Stops after a new guard launch - #11305

Merged
melodic-automation-lanes[bot] merged 2 commits into
mainfrom
work-resolve-issue/issue-8771-41077894188-1
Oct 30, 2026
Merged

melodic-automation-lanes[bot] merged 2 commits into
mainfrom
work-resolve-issue/issue-8771-41077894188-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #8771

Summary

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

Each guard launch now removes the session's .seen, truncates .launched and writes a token unique to that launch (epoch seconds, bash PID, $RANDOM). After a run with nothing to report, the monitor copies each token at least 70 seconds old (60 s hook timeout plus a margin) into .seen. The shared exec-bash.mjs launcher and run-python-hook.sh skip the Stop row while every .launched holds a token its .seen repeats, so a turn with no new launch starts only node. Every doubt runs the monitor: an empty, unreadable or malformed .launched, or a missing or unreadable .seen. When the .seen removal and the .launched open both fail, the launcher names the marker in DISK_HYGIENE_UNWRITTEN_MARKER, and the guard adds a systemMessage naming it without changing its decision or exit status. All of this follows the recorded decision on the issue.

Not verified

  • Test suites not executed: this lane runs no node, python or bash test runner. lib/exec-bash.gates.test.mjs, plugins/disk-hygiene/hooks/run-python-hook.test.sh (including the strace census for criterion 1 and the launch-to-Stop cycle for criterion 2), test_guard_launch_monitor.py and test_hygiene.py
  • Criterion 4 (Windows p95 re-measure for this row) is not checked by this PR: the recorded decision moves it to #9158, which runs after this issue closes.
  • Tidy skipped: the change is over the tidy cutoffs (56 files; 1,640 changed lines in the 32 tracked files plus the 24 new fragments; more than one area) and touches the shared path lib/ (lib/exec-bash.mjs and its test).
  • check-affected SKIPs left to CI: typos (not installed here), validate-plugins identity-prerequisites drift, native-overlap registry and claude plugin test (mods), and changed-skills.
  • Residual from review, not closed: a launch whose .launched open fails can race a concurrent monitor run that already read the old token. If the monitor writes .seen after the launch's removal and its existence check, the old pair matches and no guard notice is set. It needs an open failure plus that
  • No test pins the ordering of the notice after the PowerShell no-decision branch's telemetry and record writes: the watchdog race it guards against is not reproducible in a unit test.

Fix

  • lib/exec-bash.mjs: --skip-unless-marker also skips when every <session>.launched found is in a trusted candidate directory and holds a launch token that <session>.seen repeats byte for byte (new launchSeen, LAUNCH_TOKEN); header comment updated
  • lib/exec-bash.gates.test.mjs: fake-disk cases for the seen check (seen pair skips; a newer token, a missing, non-file or unreadable .seen, an empty, unreadable or malformed .launched, an unseen pair in another trusted candidate, a symlinked tmp candidate, and a win32 tmp candidate all run) and live
  • plugins/disk-hygiene/hooks/run-python-hook.sh: --launch-marker removes .seen (rm, only when it exists), truncates .launched, then writes the launch token; when both the removal and the open fail it exports DISK_HYGIENE_UNWRITTEN_MARKER naming the marker, unset on entry otherwise; `--skip-unles
  • plugins/disk-hygiene/hooks/run-python-hook.test.sh: cases for the token write, the .seen removal, the seen skip, each run state, a failed token write (BASH_ENV printf shadow), a failed open (non-root POSIX only), the unwritten-marker variable, the real guard's notice beside an unchanged defer and de
  • plugins/disk-hygiene/skills/clean/scripts/guard_launch_monitor.py: reads launch tokens before the transcript (_read_launches, tmp fallback only as an owned directory) and copies each token at least 70 seconds old into .seen after a clean scan ending on a complete line or on an already-warned ses
  • plugins/disk-hygiene/skills/clean/scripts/test_guard_launch_monitor.py: tests for recording .seen, the age threshold (5 s and 65 s not seen), no .seen on a warning run until the next Stop, malformed markers, a partial final line, a launch during the run, and own versus symlinked tmp directories
  • plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py: decision() adds a systemMessage naming DISK_HYGIENE_UNWRITTEN_MARKER when set; the two no-decision branches emit it alone (_emit_notice_only), the PowerShell one after its telemetry and record so a watchdog cannot turn a deny or ask
  • plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py: run_guard_engine_gate takes an env; tests that the notice rides beside an unchanged deny and alone on a defer
  • plugins/disk-hygiene/hooks/exec-bash.mjs: regenerated copy of lib/exec-bash.mjs
  • plugins/actionlint/hooks/exec-bash.mjs: regenerated copy of lib/exec-bash.mjs
  • plugins/animation/hooks/exec-bash.mjs: regenerated copy of lib/exec-bash.mjs
  • plugins/autonomy/hooks/exec-bash.mjs: regenerated copy of lib/exec-bash.mjs
  • plugins/bash-format/hooks/exec-bash.mjs: regenerated copy of lib/exec-bash.mjs
  • plugins/biome-format/hooks/exec-bash.mjs: regenerated copy of lib/exec-bash.mjs
  • plugins/context-guard/hooks/exec-bash.mjs: regenerated copy of lib/exec-bash.mjs
  • plugins/desktop-notification/hooks/exec-bash.mjs: regenerated copy of lib/exec-bash.mjs
  • plugins/eol-normalizer/hooks/exec-bash.mjs: regenerated copy of lib/exec-bash.mjs
  • plugins/explainer-video/hooks/exec-bash.mjs: regenerated copy of lib/exec-bash.mjs
  • plugins/go-format/hooks/exec-bash.mjs: regenerated copy of lib/exec-bash.mjs
  • plugins/guardrails/hooks/exec-bash.mjs: regenerated copy of lib/exec-bash.mjs

Verification

The runner ran each check from the base copy against 0c7d450:

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

  • .lane/verify/bin/sync-shared-copies: regenerated all 24 registered copies of lib/exec-bash.mjs, exit 0
  • .lane/checks/bin/check-changelog-fragments (run after the edits and again after the review fixes): All 224 changelog fragment(s) under .changes/ are valid
  • .lane/checks/bin/check-affected (run twice, last after the review fixes): 13 passed, 5 skipped over 56 changed files; skipped were typos (not installed), validate-plugins identity-prerequisites drift, native-overlap registry and claude plugin test (mods), and changed-skills, each because the lane do
  • .lane/verify/bin/cant-fail-scan --file <test> --check on lib/exec-bash.gates.test.mjs, plugins/disk-hygiene/hooks/run-python-hook.test.sh, test_guard_launch_monitor.py and test_hygiene.py: PASS, no gating findings; the only advisory findings are on tests this change did not touch
  • fresh-context review subagent over the whole diff: one BUG found and fixed (the PowerShell no-decision branch emitted the notice before its telemetry and record, so a watchdog firing in between could exit 0 where it would deny or ask); also fixed: the 60 s age threshold had no margin for the whole-s
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/41077894188

Left out: the items under Not verified.

Related

#8771

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

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 53abe7cb0a36a68e509a68667aeea0128249f769: 0 finding(s), 0 as inline comments.

Security review of the incremental change to plugins/disk-hygiene/hooks/run-python-hook.sh (since 0c7d450). No security findings.

  • Hunk 1 (around line 378) only rewords a comment.
  • Hunk 2 (_store_python3, around line 634) folds the temp-file write, mv -f and rm -f cleanup into one A && B || C list. Behavior is the same as before: the temp file is removed if the write or the mv fails, the publish stays atomic, and the function still returns 0. The temp name ($file.$$.tmp), the directory mode (chmod 700) and the contents written are unchanged. The edit adds no new input, path construction, command execution or secret handling.

critical-findings: 0

No manifest fields were touched in this increment. No spend was added.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 53abe7cb0a36a68e509a68667aeea0128249f769: 0 finding(s), 0 as inline comments.

Incremental review of plugins/disk-hygiene/hooks/run-python-hook.sh since 0c7d450. I found no issues.

  • Comment edit (lines 378–382): it only rewords the comment. The .seen removal it describes is the rm -f -- at line 387, behind the [[ -e ... ]] guard at line 386, so the comment is accurate.
  • _store_python3 (lines 637–648): the control flow is equivalent to before.
    • { write } >temp && mv -f temp file || rm -f temp || true has the same effect as the old two-step form. A failed write or a failed mv removes the temp file.
    • A successful publish skips the rm.
    • The || true and return 0 keep the function from failing under set -e.
    • The atomic-publish comment is accurate.

This diff cleans up a comment and restructures one function. It adds no new spend and no change that can cause a real charge. I read only the incremental diff and a grep of the file, and ran nothing.

@melodic-automation-lanes

melodic-automation-lanes Bot commented Oct 30, 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=11305 -f activity=fix-ci

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head 0c7d450361ff6b8b15ade632d273157ca4a04c2c. The lanes clear this reason on their own; the next scheduled run judges it again.

a pr-unblock lane stopped its head (pr-unblock/fix-ci is failure), which ci-status fails in the
  merge queue

@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 Oct 30, 2026
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 53abe7cb0a36a68e509a68667aeea0128249f769.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit c210da2 Oct 30, 2026
45 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-8771-41077894188-1 branch October 30, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-session A pr-unblock stop a session builder takes: a change the lane cannot make. Not an owner stop.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(disk-hygiene): run the guard-launch monitor only on Stops after a new guard launch

0 participants