Skip to content

refactor(machine-health): simplify audit Windows lib helpers (7 of 9) - #15321

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14650

Summary

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

Applied behavior-preserving simplifications to 7 of the 15 listed machine-health audit Windows lib files: removed one-use temporaries, merged a two-stage pipeline, hoisted a repeated elapsed-time read, collapsed duplicated note-append and guard branches, and dropped a redundant null guard. The other 8 files are already tight, or are security-sensitive (the egress allowlist match, the elevated bootstrap whose function text is hashed into the launcher, the elevated-result import) where a rewrite carries risk for no clarity gain, so they stay unchanged. Outputs, exit codes, messages, parameters and exported names are unchanged.

Not verified

  • Pester suites for the touched files (Invoke-FindingCorrelation, Invoke-NativeCommand, Get-WingetPackageUpdate, Invoke-Discovery, Get-WindowsDiscoveryProbes, Invoke-CheckWithTimeout) were not run: this lane cannot run pwsh. Left to the PR's CI.
  • ci-status green is a PR CI check; left to the PR's CI.
  • Tidy pass 5 (/ai-slop:audit fix on the changelog fragment) skipped: its detector and digest-guard scripts are not among the commands this lane may run. The fragment's single line is the exact text the issue requires; a read of it shows no AI-writing tell. Tidy passes 1-4 ran: pass 1 found nothing…
  • Left unchanged on purpose: Get-RunDelta, Get-RunKeyEntry, Get-VendorUpdateCli, Get-WorstSeverity, Import-ElevatedResult, Invoke-CustomCheckClamp, Invoke-ElevatedBootstrap, Invoke-HealthCheckEnvelope. They are already compact, or a rewrite would touch security-sensitive logic…
  • git status lists 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 are not part of this change.
  • Build/lint for PowerShell (PSScriptAnalyzer) not run here: pwsh is unavailable in this lane. Left to the PR's CI.

Fix

  • plugins/machine-health/skills/audit/scripts/windows/lib/Get-WindowsDiscoveryProbes.ps1: inlined the one-use $certPath variable.
  • plugins/machine-health/skills/audit/scripts/windows/lib/Get-WingetPackageUpdate.ps1: merged the filter and map stages of the WinGet module path into one pipeline, and inlined the one-use $msg in the module-path catch (same verbose text).
  • plugins/machine-health/skills/audit/scripts/windows/lib/Invoke-AllowlistedWeb.ps1: inlined the one-use $err in Write-EgressLogLine's catch (same stderr text).
  • plugins/machine-health/skills/audit/scripts/windows/lib/Invoke-CheckWithTimeout.ps1: read the stopped stopwatch once into $elapsedMs instead of casting it in each of four returns.
  • plugins/machine-health/skills/audit/scripts/windows/lib/Invoke-Discovery.ps1: combined the two 'detected' guards into one short-circuit condition.
  • plugins/machine-health/skills/audit/scripts/windows/lib/Invoke-FindingCorrelation.ps1: flattened the severity-upgrade branch and replaced the duplicated primary/partner note-append blocks with one loop over the two (finding, note) pairs.
  • plugins/machine-health/skills/audit/scripts/windows/lib/Invoke-NativeCommand.ps1: dropped the redundant $null guard ($null -eq 0 is already false) and computed status inline.
  • .changes/machine-health/work-resolve-issue-issue-14650-42995338207-1-91f2e76f.md: new patch fragment, '### Changed' with 'Internal simplification, no behavior change.'

Verification

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

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

The run reports:

  • check-changelog-fragments: all 12 fragments valid (run before and after tidy).
  • check-changed-skills: plugins/machine-health/skills/audit PASS, 0 errors, 4 pre-existing warnings (description length, body length, token size, no Gotchas).
  • check-affected: 12 passed, 7 skipped over 8 changed files (no shell or Python changed; typos not installed).
  • Fresh-context subagent review of the full diff against the current files and their Pester tests: all seven edits equivalent; no test assertion affected. Two edge cases it named cannot occur today: an [int] overflow past ~24.8 days of elapsed time, and a rule returning a pscustomobject without…
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42995338207

Left out: the items under Not verified.

Related

#14650

Merge-Risk: max=MEDIUM demote=false head=2306016916503100a3be1141986f23c6a2845b32 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 2306016916503100a3be1141986f23c6a2845b32: read 8 of 8 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15321, no security issues found

I read every hunk of all 8 changed files in .claude-lane/pr.diff. This was a full review, not one limited to blocking findings, since this lane has not reviewed an earlier head.

Scope. The PR makes behavior-preserving refactors to seven PowerShell helpers under plugins/machine-health/skills/audit/scripts/windows/lib/ and adds one changelog fragment. None of the changed files matches a trusted-path glob. It changes no plugin manifest, workflow, trust control, merge hold or standing instruction.

What I checked:

  • Invoke-AllowlistedWeb.ps1: only the stderr message in Write-EgressLogLine's catch block changed. A temporary variable was inlined and the text is the same. The allowlist match and the egress logic are untouched.
  • Invoke-NativeCommand.ps1: $code -eq 0 ? 'Ok' : 'NonZero' gives the same result as the old $null -ne $code -and $code -eq 0. $code comes from $LASTEXITCODE, and $null -eq 0 is false. How commands are resolved and called (Get-Command -CommandType Application, the splatted $ArgumentList) did not change, so this opens no new injection path.
  • Invoke-FindingCorrelation.ps1: severity upgrades only when upgrade_primary_to is set and ranks higher, as before. A note is still appended only when it is set. This only affects how findings are reported.
  • Invoke-CheckWithTimeout.ps1, Invoke-Discovery.ps1, Get-WingetPackageUpdate.ps1, Get-WindowsDiscoveryProbes.ps1: the timer reading moved into one variable, two guard checks were merged into one short-circuit condition, two pipeline stages were merged, and a one-use path variable was inlined. Timeout, job cleanup and probe handling behave the same, and no input reaches anything new.
  • The .changes/ fragment is changelog text only.

PR context. The PR description contains no embedded instruction aimed at the review lane.

The review used no subagents and no part of it was skipped.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read every hunk in all 8 changed files and checked each edit against the code around it at head. Each one keeps the old behaviour:

  • Get-WindowsDiscoveryProbes.ps1: $certPath was used only once and is now inlined. Nothing else reads it.
  • Get-WingetPackageUpdate.ps1:
    • The filter and map steps are now one pipeline, giving the same @()-wrapped array.
    • The module-path $msg was a local used only in the Write-Verbose line, and that verbose text is unchanged. The fallback builds its own messages ($err at L148 and its own $msg at L161), so nothing read the removed variable.
  • Invoke-AllowlistedWeb.ps1: $err is inlined and the stderr text is unchanged.
  • Invoke-CheckWithTimeout.ps1: $elapsedMs is read after $jobSw.Stop(), so all four returns get the same value as before.
  • Invoke-Discovery.ps1: the two detected guards are combined with -or. -or stops early, so the result is the same.
  • Invoke-FindingCorrelation.ps1:
    • The severity upgrade still runs only when upgrade_primary_to is set, because -and stops early.
    • @(@(target, note_primary), @(partner, note_partner)) produces two 2-element pairs. Splitting each pair into two variables and skipping empty notes copies the two old note blocks.
    • The only rule today (wu-reboot-retry-loop) returns a hashtable, so a missing key reads as $null the same way it did before.
  • Invoke-NativeCommand.ps1: $code -eq 0 ? 'Ok' : 'NonZero' gives the same result as the old $null -ne $code -and $code -eq 0 check, because $null -eq 0 is false. The ternary operator needs PowerShell 7, and the file's callers (the orchestrator and lib) all declare #Requires -Version 7.4.
  • Changelog fragment: a patch bump under ### Changed with the exact line the issue asks for.

Closing issue #14650 acceptance criteria

  • Behavior unchanged: met, as above. Existing Pester suites cover these helpers. The author says no test assertions needed changing; I did not run the tests.
  • Edits only listed files and fragments: met. All 7 edited scripts are on the issue's list.
  • Within 400 lines / 15 files: met (7 hand-edited files, well under 400 lines).
  • ci-status green: left to the PR's CI. The author says it was not checked; I can't check it either.
  • Fragment for machine-health: met.

The author's verification (check-changelog-fragments, check-changed-skills, and the subagent equivalence review) is their own claim, and I did not confirm it myself. Pester and PSScriptAnalyzer were not run, and the author says so.

No plugin manifest changes, no changed file on a trusted path, no prior findings, no settled threads. Spend: none.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 2306016

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-15321-2306016916503100a3be1141986f23c6a2845b32, 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 35a905b Nov 11, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14650-42995338207-1 branch November 11, 2026 10:56
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 35a905b8d62f52a6cb611c4c7052ea6d9d93bd64; 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 (7 of 9)

0 participants