Skip to content

refactor(machine-health): simplify audit Windows check scripts (2 of 9) - #15333

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14642-42997908742-1
Nov 11, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14642

Summary

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

Simplified four of the nine listed machine-health audit checks without changing behavior. Test-ClaudeTempRoot.ps1 drops two parameter self-aliases (PowerShell variable names are case-insensitive, so $budgetSeconds = $BudgetSeconds was a no-op), builds its candidate list in one expression and shares the task-output finding and New-HealthResult tail between its two verdict branches through a splatted outcome. Test-DiskHealth.ps1, Test-DriveRootLitter.ps1 and Test-Defender.ps1 swap assign-then-override ladders for if-expressions, merge the shared-baseline test in Get-RootResidue, replace the scriptblock render loop for the summary with two named candidates, and drop a guard that could never be false. The issue requires Test-CertExpiry, Test-ContainerDiskUsage, Test-DefenderExclusions and Test-DnsHealth to stay unchanged, so they are untouched. Test-BrowserExtensions.ps1 is also untouched because it had no simplification worth the risk.

Not verified

  • Pester suites for these checks (tests/windows/checks/*.Tests.ps1) were not run: this lane cannot run pwsh, so the PR's CI runs them
  • PSScriptAnalyzer lint not run locally (pwsh unavailable in this lane); left to the PR's CI
  • ci-status green is a PR CI check, left to the PR's CI
  • tidy recorded skipped: the docs-hygiene write-for-humans pass was not run on the changelog fragment, whose one line is text the issue mandates verbatim; the ai-slop detector (detect.sh) could not run in this lane, so pass 5 was a manual read only (no tells found, no edits)
  • Test-BrowserExtensions.ps1 left unchanged: it is already compact, and the remaining candidates were cosmetic

Fix

  • plugins/machine-health/skills/audit/scripts/windows/checks/Test-ClaudeTempRoot.ps1: removed no-op budget aliases (comments moved onto the params), one-expression candidate list, inlined single-use walk locals, shared finding/tail/result block with splatted RanSuccessfully/ErrorMessage, severity as…
  • plugins/machine-health/skills/audit/scripts/windows/checks/Test-DiskHealth.ps1: volume and health severities as single expressions; removed an always-true if ($summary) guard
  • plugins/machine-health/skills/audit/scripts/windows/checks/Test-DriveRootLitter.ps1: shared-baseline match tested once before the system/data split; severity as an if-expression; summary example rendering as two named candidates instead of a scriptblock loop
  • plugins/machine-health/skills/audit/scripts/windows/checks/Test-Defender.ps1: oldest-record fallback via ??
  • .changes/machine-health/work-resolve-issue-issue-14642-42997908742-1-7e3c017c.md: patch fragment, ### Changed with "Internal simplification, no behavior change."

Verification

The runner ran each check from the base copy against 230df5c:

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

The run reports:

  • check-changelog-fragments: all 11 fragments valid (run before and after tidy)
  • check-changed-skills: machine-health audit skill PASS, 0 errors, 4 pre-existing warnings about SKILL.md size and description (run before and after tidy)
  • check-affected: 12 passed, 7 skipped, the rest CI-only, over 5 changed files (run before and after tidy)
  • fresh-context review subagent over the full diff, focused on PowerShell semantics (case-insensitive variables, continue inside (foreach), splatting vs direct params, ?? vs truthiness, -or short-circuit, null pattern lists, summary candidate selection): no behavior change found
  • tidy-diff passes 1-3 over the code hunks: no further edits; comments in the listed lines carry constraints (class C) and stay
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42997908742

Left out: the items under Not verified.

Related

#14642

Merge-Risk: max=MEDIUM demote=false head=230df5c7006d2285c9d58045e3d7aa0875d21c5e rubric=8.4.2 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-security-review reviewed 230df5c7006d2285c9d58045e3d7aa0875d21c5e: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15333 (head 230df5c)

No security issues found. I read every hunk of all 5 changed files.

What changed. The PR refactors four read-only Windows health-check scripts under plugins/machine-health/skills/audit/scripts/windows/checks/ (Test-ClaudeTempRoot.ps1, Test-Defender.ps1, Test-DiskHealth.ps1, Test-DriveRootLitter.ps1) and adds a patch changelog fragment. The edits are:

  • if-expressions in place of assign-then-override severity ladders
  • ?? in place of an inline if
  • a splatted @outcome hashtable for RanSuccessfully / ErrorMessage
  • the shared-baseline pattern test hoisted in Get-RootResidue
  • the scriptblock render loop replaced with two named summary candidates

Why there is nothing to report:

  • Nothing new runs a command or touches the filesystem: no added command execution, path building, network calls, credential handling or writes. The existing Join-Path and Get-Item -LiteralPath calls, and the Get-Acl owner lookup, are unchanged.
  • No trust controls, workflows, manifests, userConfig keys, hooks or instruction surfaces are touched.
  • None of the 5 changed files matches the TRUSTED PATHS globs.
  • The PR deletes no standing instruction, so the instruction-surface lens does not apply.

I checked the Get-RootResidue reordering for equivalence. On system volumes it now runs the shared test, then the system test; before, it tested the combined list once. On data volumes the shared test still runs before the litter test. Either way the same entries are skipped, so nothing that used to be classified as residue is now hidden.

Embedded text. The PR context file holds no instruction aimed at this lane.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read every hunk of all 5 changed files and found no behavior change in the four simplified Windows checks.

Per file

  • Test-ClaudeTempRoot.ps1
    • Budget aliases: PowerShell variable names ignore case, so $budgetSeconds = $BudgetSeconds assigned the parameter to itself. Removing it leaves $budgetSeconds / $taskOutputBudgetSeconds in $CheckBody (L426, L474, L480) reading the same parameters.
    • Candidate list: @(foreach … { continue; [pscustomobject]… }) returns the same items. It also keeps .Count -eq 0 and [0] working when the list is empty or has one entry (L80–L83).
    • Shared result block (L518–L528): it runs the same Format-TaskOutputFinding cap arithmetic with the branch-local $summary / $tail as before. The splatted $outcome passes RanSuccessfully $false plus ErrorMessage on the incomplete path, and only RanSuccessfully $true on the complete path, which matches the old calls. The inlined walk locals feed the same detail fields.
  • Test-Defender.ps1: $oldestText is either ToString('o') or $null (L53), so ?? and the old truthiness test give the same result.
  • Test-DiskHealth.ps1:
    • Every branch assigns $summary a non-empty string (L136–L145), so the removed if ($summary) guard could never be false.
    • The combined $unhealthy test keeps both CRIT conditions.
    • The volume ladder is unchanged.
  • Test-DriveRootLitter.ps1:
    • On system roots, checking the shared baseline first and then the system baseline matches the old combined list. Data roots behave as before.
    • Test-NameMatchesAny accepts a $null / empty Patterns because the parameter is not mandatory and has [AllowEmptyCollection()]. So an empty baseline list that a function returns as $null behaves the same as before.
    • The summary picks full paths, then bare names, then lead plus tail, under the same 240-character cap as the old loop.
  • Changelog fragment: bump: patch, ### Changed, with the required line.

Closing issue #14642 acceptance criteria

  • Only listed files plus a fragment edited: met.
  • Test-CertExpiry, Test-ContainerDiskUsage, Test-DefenderExclusions and Test-DnsHealth unchanged: met.
  • Size limits: met, at about 70 changed lines in 5 files.
  • Fragment shape: met.
  • Behavior unchanged: met as far as reading the code shows. The existing Pester suite plugins/machine-health/skills/audit/tests/windows/checks/Test-ClaudeTempRoot.Tests.ps1 asserts on the UNKNOWN / ran_successfully paths.
  • ci-status green: left to CI.

Not verified: I could not run pwsh, Pester or PSScriptAnalyzer here. The PR's own "Verification" section is the author's claim and I have not checked it.

Other checks

  • No plugin manifest changed.
  • The path-scoped rules under .claude/rules/ that match these paths cover skill-body text and cost claims; none applies to these script edits.
  • No changed file matches a trusted path.
  • No billing or spend impact.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 230df5c

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-15333-230df5c7006d2285c9d58045e3d7aa0875d21c5e, expires on 2026-12-11.

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 11, 2026
Merged via the queue into main with commit 414ab13 Nov 11, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14642-42997908742-1 branch November 11, 2026 11:02
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 414ab13f4702f588a4608a10144e500504def252; later checks count it verified from this comment.

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 audit machine-health plugin code (2 of 9)

0 participants