Skip to content

refactor(machine-health): simplify audit Windows lib scripts (5 of 9) - #14985

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14648

Summary

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

Ran /simplify's four checks over the 15 listed machine-health audit Windows lib scripts and applied behavior-preserving cleanups to six of them: an early return replaces a nested Test-Path block in Get-ApprovalState, two due-on-missing branches merge in Get-CheckSelection, a duplicated exception-message variable goes from Invoke-KevFetch, single-use temporaries go from Get-DriverStoreInventory and Get-ElevatedAppEvidence, and a repeated count test is named once in Get-FileHistorySignal. The other nine files (Format-CheckLabel, Get-CheckArgument, Get-CheckLastRun, Get-ChromiumExtension, Get-DefenderEventHistory, Get-DefenderExclusionState, Get-ElevatedResultFormat, Get-ElevationMatrix, Get-EvidenceWindow) were already tight; any further cut there would need a new helper function (a new global name in these dot-sourced libraries) or cross-file dedup, which the issue puts out of scope. Outputs, warning and log text, return shapes and function signatures are unchanged.

Not verified

  • Pester tests and PSScriptAnalyzer for the changed .ps1 files were not run: this lane can't run pwsh. They are left to the PR's CI.
  • ci-status green: a PR CI check this run can't observe, left to the PR's CI.
  • tidy pass 5 (ai-slop:audit fix): the deterministic detector (detect.sh) wasn't run because the lane's Bash allowlist doesn't include it. The rubric was applied by reading the 3-line fragment body, which the issue fixes verbatim.
  • typos check skipped by check-affected (typos not installed).
  • Files left unchanged: Format-CheckLabel, Get-CheckArgument, Get-CheckLastRun, Get-ChromiumExtension, Get-DefenderEventHistory, Get-DefenderExclusionState, Get-ElevatedResultFormat, Get-ElevationMatrix, Get-EvidenceWindow. Reviewed and judged already minimal. The remaining repeated record literals…

Fix

  • plugins/machine-health/skills/audit/scripts/windows/lib/Get-ApprovalState.ps1: Get-ApprovalState returns defaults early when approvals.json is missing, removing one nesting level and the unreachable trailing return.
  • plugins/machine-health/skills/audit/scripts/windows/lib/Get-BackupSignal.ps1: Get-FileHistorySignal computes the configs-found test once.
  • plugins/machine-health/skills/audit/scripts/windows/lib/Get-CheckSelection.ps1: the blank last-run and unparsable last-run branches, both of which mark the check due, merge into one short-circuited condition.
  • plugins/machine-health/skills/audit/scripts/windows/lib/Get-CisaKevCache.ps1: Invoke-KevFetch's catch captures the exception message once as $message and reuses it, dropping the $fetchFailure copy.
  • plugins/machine-health/skills/audit/scripts/windows/lib/Get-DriverStoreInventory.ps1: inlines the single-use $raw, $key and $val temporaries.
  • plugins/machine-health/skills/audit/scripts/windows/lib/Get-ElevatedAppEvidence.ps1: Read-PrefetchEvidence and Read-BamEvidence set ReadState with an inline ternary in place of a single-use $state.
  • .changes/machine-health/work-resolve-issue-issue-14648-42758068363-1-4a77f24b.md: new patch fragment from new-changelog-fragment, body '### Changed' plus 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 77acfdb:

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

The run reports:

  • check-changelog-fragments: all 4 fragments valid (run before and after tidy).
  • check-changed-skills: PASS, 0 errors, 4 pre-existing warnings on the audit SKILL.md, which this change does not touch (run before and after tidy).
  • check-affected: 12 passed, 7 skipped, the rest CI-only, over 7 changed files (run before and after tidy).
  • Fresh-context review subagent: read the full diff, the six files and their Pester tests (Get-ApprovalState, Get-CisaKevCache, Get-CheckSelection, Get-DriverStoreInventory, Get-ElevatedAppEvidence, Get-BackupSignal) and found no behavior difference. It checked -or short-circuit order, $_ and…
  • code-tidying:tidy-diff over the 10 changed hunks: no edits; no comments or generated-code residue in the listed lines; the fragment text is the verbatim line the issue requires.
  • Diff size: 6 code files plus 1 fragment, 23 lines added and 39 removed in code, within the issue's 400-line and 15-file limit.
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42758068363

Left out: the items under Not verified.

Related

#14648

Merge-Risk: unrated reason=pending

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

Copy link
Copy Markdown
Contributor

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

Security review: PR #14985, refactor(machine-health): simplify audit Windows lib scripts

No security issues found.

I read every hunk of all 7 changed files. None of them matches a trusted-path glob. The PR changes no plugin manifest, workflow, trust control or instruction surface.

What each change does, and why it doesn't change behaviour:

  • Get-ApprovalState.ps1: When approvals.json is missing, the function now returns early. The old code returned the same default at its end. The try/catch is unchanged: blank file → defaults, a parse or Assert-ApprovalState failure → warning, log line and defaults, a valid file → the parsed object. The approval gate still lets through exactly what it did before.
  • Get-CheckSelection.ps1: The blank last-run branch and the unparsable last-run branch are merged with -or. PowerShell -or short-circuits, so TryParse still runs only on a non-blank value, and both cases still mark the check due.
  • Get-CisaKevCache.ps1: The KEV fetch error message is captured once as $message. The egress log line, the warning text, the cleanup of the temp file and the returned error are all unchanged. Cache-replacement logic is untouched.
  • Get-DriverStoreInventory.ps1, Get-ElevatedAppEvidence.ps1, Get-BackupSignal.ps1: One-use temporary variables are inlined, or a repeated test is computed once. The parsing regex and the output values are unchanged.
  • .changes/...md: A changelog note only.

I found no embedded instructions in the PR context. The PR's prior-findings file lists no earlier posts, so this is not a blocking-only review.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #14985, simplify audit Windows lib scripts (5 of 9)

No findings. I read every hunk of all 7 changed files and checked each rewrite against the base code. Every change keeps the same behavior.

  • Get-ApprovalState.ps1: the early return (New-DefaultApprovalState) for a missing approvals.json works like the old outer if. Its trailing return could never run. The try/catch body, the warning text and the log text are unchanged.
  • Get-BackupSignal.ps1: $configured caches $configs.Count -gt 0, and $configs does not change between the two places it is used.
  • Get-CheckSelection.ps1: -or short-circuits, so TryParse never runs on a blank $lastRun. -not binds tighter than -or, and the line break after -or is inside the if (...) parentheses, so it parses. $lastRunOffset is still initialized before the test. Both branches still add the check to $due and continue.
  • Get-CisaKevCache.ps1: $message is captured from $_.Exception.Message at the top of catch, before Remove-Item or anything else could replace $_. It is not reassigned before the blank-message fallback. The log line, the warning and the returned Error all get the same value as before.
  • Get-DriverStoreInventory.ps1: member access binds tighter than -split. The inlined key and value both read $Matches from the same -match, with no other match in between.
  • Get-ElevatedAppEvidence.ps1: the inline ternary gives ReadState the same value. Ternaries already appear in these libraries (Get-BackupSignal.ps1, Get-CisaKevCache.ps1, Get-CheckSelection.ps1), so this adds no new PowerShell 7 requirement.
  • Changelog fragment: bump: patch with the ### Changed body the issue requires.

Closing issue #14648, acceptance criteria:

  • Behavior unchanged, no renames: met, by reading the code. Existing Pester tests for these functions would catch a regression; I did not run them because this lane has no shell.
  • Diff touches only listed files plus a fragment: met.
  • Within 400 lines and 15 files: met (6 code files plus 1 fragment).
  • ci-status green: I can't check this from here; it is left to the PR's CI.
  • machine-health fragment with the required body: met.

The tests, PSScriptAnalyzer runs and CI results in the PR body are author-claimed and unverified. No prior findings, settled threads or plugin manifest changes apply.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 77acfdb

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-14985-77acfdbb53c3f1c426af49c67212ba5f7fd9154f, 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
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 10, 2026
@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 c31415b Nov 10, 2026
89 of 90 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14648-42758068363-1 branch November 10, 2026 05:55
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

0 participants