Skip to content

refactor(machine-health): simplify audit lib scripts (6 of 9) - #15261

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14649

Summary

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

Simplified four of the fifteen listed machine-health audit lib scripts without changing their behavior. Five multi-line if/try blocks became single-expression assignments (try-as-expression, ternary, null-coalescing), and a misplaced comment that described history was moved and reworded. I read the other eleven files and left them alone: they are already compact, and the remaining duplication is across files, which is the sub-epic's later restructuring pass. Choice and basis: only changes a reviewer could confirm leave behavior the same, because these scripts run on Windows and cannot be run in this lane.

Not verified

  • Pester tests for the touched lib functions (tests/windows/lib/*.Tests.ps1) were not run: pwsh is not available to this lane. They are left to the PR's CI.
  • PSScriptAnalyzer lint was not run (no pwsh in this lane). The review subagent checked the new syntax against the default rule set and against patterns already used in the same lib folder. Lint is left to the PR's CI.
  • ci-status green on the PR is a PR check, so it is left to the PR's CI.
  • Tidy did not run every pass: the ai-slop detector script (detect.sh) is not one of the lane's allowed wrappers, so only the rubric read of the one-line fragment ran, and it found nothing. The simplify, comment and residue passes found nothing more to change in the listed lines, and write-for-humans…
  • Eleven of the fifteen listed files were reviewed and left unchanged (Get-FirefoxExtension, Get-FirewallRuleInventory, Get-GpuDriverInfo, Get-InnerHResult, Get-ListenerOwner, Get-LogonTaskInventory, Get-NonElevatedCoverage, Get-PhysicalDiskReliability, Get-ProcessSample, Get-RanCheckId,…
  • The issue's commit instruction was not followed: the runner says to leave changes uncommitted, so it can turn them into a patch.

Fix

  • plugins/machine-health/skills/audit/scripts/windows/lib/Get-ExtensionPolicy.ps1: the ExtensionSettings JSON parse uses $settings = try { ... } catch { $null } in place of a five-line try/catch.
  • plugins/machine-health/skills/audit/scripts/windows/lib/Get-InstalledApp.ps1: the first failing ReadState comes from Select-Object -First 1 with ?? 'ok' (drops the temporary $failed array), and the InstallDate parse is a single TryParseExact ternary (drops $rawDate and the if block).
  • plugins/machine-health/skills/audit/scripts/windows/lib/Get-MutedFindingKey.ps1: $keys is built in one \[string\[\]\](if ...) expression, not an empty default followed by a reassignment.
  • plugins/machine-health/skills/audit/scripts/windows/lib/Get-PnpProblemDevices.ps1: the problem-code parse is a single ternary. The comment about NonZero exits now sits at the parse it describes rather than above the Failed branch, and no longer mentions the earlier adapter.
  • .changes/machine-health/work-resolve-issue-issue-14649-42956299846-1-34f47655.md: new patch fragment, made with new-changelog-fragment. Its body is ### Changed and the line 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 27528d5:

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

The run reports:

  • check-changelog-fragments: all 19 fragments valid (run before and after tidy).
  • check-changed-skills: plugins/machine-health/skills/audit PASS, 0 errors, 4 warnings that were already there (description length, body length, token size, no Gotchas section).
  • check-affected: 12 passed, 7 skipped over 5 changed files.
  • Fresh-context review subagent (read-only, given the diff and the full files and tests): no behavior difference in any hunk, including under the callers' Set-StrictMode -Version 3.0, AutomationNull with ??, ternary precedence against -match and method calls, and empty or one-element [string[]]…
  • Diff size: 4 listed lib files plus 1 fragment, 7 lines added and 19 removed, all in the machine-health area.
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42956299846

Left out: the items under Not verified.

Related

#14649

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

Security review: PR #15261

I found no security issues in this change.

I read every hunk in all 5 changed files. The pull request refactors four machine-health audit lib scripts that run locally on Windows, and adds a one-line changelog fragment:

  • Get-ExtensionPolicy.ps1: the multi-line try/catch around ConvertFrom-Json is now a try expression. On a parse failure $settings is still $null, and the readState downgrade that follows is unchanged.
  • Get-InstalledApp.ps1: the first failing ReadState is now picked with Select-Object -First 1 plus ?? 'ok'. The InstallDate parse is now a single TryParseExact ternary. Neither change touches input handling, paths or commands.
  • Get-MutedFindingKey.ps1: the [string[]] key list is now built in one expression, and the -NoEnumerate return is the same.
  • Get-PnpProblemDevices.ps1: the problem-code parse is now a ternary, and a comment moved. The Failed early return and the empty-output guard are unchanged.
  • .changes/...md: a patch changelog fragment with no executable content.

None of the changed files match a trusted-path glob. The diff changes no plugin manifest, trust control, merge hold, token scope, workflow or standing instruction.

The PR context contains no embedded instructions aimed at this lane.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

No findings. I read every hunk of all 5 changed files. None of them matches a trusted-path glob. This is the lane's first review of this PR (prior findings: 0 earlier heads, not blocking only).

I checked that each rewrite behaves the same as before. Every touched file declares #Requires -Version 7.4, so the PS7 operators (?:, ??, try used as an expression) are available, and the same lib/checks folders already use them.

  • Get-ExtensionPolicy.ps1: $settings = try { … } catch { $null } assigns the same value on success and on failure as the old five-line try/catch.
  • Get-InstalledApp.ps1, ReadState: $states is a List[string] that only ever receives the literals ok, absent, denied and error. A null element, the one case where Select-Object -First 1 … ?? 'ok' would differ from $failed[0], therefore can't occur. When no state fails, the empty pipeline result is treated as null and falls back to 'ok', as before.
  • Get-InstalledApp.ps1, InstallDate: the [ref]$parsed write finishes before the ternary picks a branch, so $installDate is the parsed date on success and $null otherwise, as before.
  • Get-MutedFindingKey.ps1: [string[]]@(if …) gives an empty string[] when $check is null, the same as the old [string[]]@() default. -NoEnumerate still keeps the type for the caller.
  • Get-PnpProblemDevices.ps1: the ternary binds more loosely than -match, so the condition is ($fields['Problem Code'] -match '(\d+)') and $Matches is set before [int]$Matches[1] is read. A missing key still gives 0. The moved comment now sits at the parse it describes.
  • Changelog fragment: bump: patch, with the body ### Changed / "Internal simplification, no behavior change.", which matches the issue's fragment requirement.

Closing issue #14649, acceptance criteria:

  • Behavior unchanged: met, by my reading above.
  • Only listed files and fragments edited: met.
  • Within 400 lines and 15 files: met (4 lib files plus 1 fragment).
  • Fragment present: met.
  • ci-status green: depends on the PR's CI.

These are behavior-preserving refactors, so the repository's existing Pester tests for these lib functions are the tests that would catch a regression. I didn't run any PowerShell, and the PR says its lane didn't either: the Pester and PSScriptAnalyzer results in the PR body are the author's claims and unverified until CI runs.

The PR context contained no embedded instructions aimed at this lane.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 27528d5

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-15261-27528d51b4429e7d828e61fb50224698b228bf93, 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 e4d2799 Nov 11, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14649-42956299846-1 branch November 11, 2026 04:55
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

0 participants