Skip to content

refactor(machine-health): simplify audit Windows lib helpers (8 of 9) - #14887

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14651

Summary

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

Applied behavior-preserving simplifications to three of the 14 listed files. Invoke-TrendAnalysis now folds its two duplicated WARN->CRIT upgrade blocks into one reason-then-apply step. Read-BrowserJsonFile shares one error return for a parse failure and a non-object root. Get-SnapshotField drops a redundant null test, and Get-NewFindingKey drops a dead pre-assignment. The other 11 files were reviewed and left alone: they were already tight, or the only candidate edits would have changed edge-case behavior. Two edits, $Detail ?? {} in New-UnknownCheckResult and -ccontains replacing the ordinal HashSet in New-InvalidCatalogEntryResult, were reverted after review found that they change output for some direct-call inputs (array unrolling, and culture-aware vs ordinal string comparison).

Not verified

  • The Pester suites under plugins/machine-health/skills/audit/tests/windows were not run: this lane has no pwsh and allows no interpreter, so they are left to the PR's CI.
  • PSScriptAnalyzer lint on the touched .ps1 files was not run: no pwsh in this lane. Left to the PR's CI.
  • Review note, unconfirmed and judged unreachable: in Invoke-TrendAnalysis, if setting $r.severity failed without throwing (for example a getter-only ScriptProperty with ErrorActionPreference not Stop), the old code could add a second drivers 'repeat' note and the new code adds at most one. Check…
  • tidy-diff pass 5: the ai-slop deterministic detector (detect.sh) was not run because this lane's Bash allows only the named wrappers. The one-line fragment got a rubric read only, with no findings.
  • ci-status green is left to the PR's CI.
  • Untracked root dotfiles (.bashrc, .bash_profile, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) appeared in git status. This run did not create them and left them alone, so they should be kept out of the patch.

Fix

  • plugins/machine-health/skills/audit/scripts/windows/lib/Invoke-TrendAnalysis.ps1: the trend-delta and drivers CodeIntegrity-repeat upgrades now pick one reason (if/elseif under a single WARN test) and share one block that sets adjusted_from, severity CRIT and the note; same notes text and…
  • plugins/machine-health/skills/audit/scripts/windows/lib/New-ExtensionRecord.ps1: Read-BrowserJsonFile's catch sets $data to $null and falls through to the existing non-hashtable check, which returns the same State='error' object.
  • plugins/machine-health/skills/audit/scripts/windows/lib/New-RunSnapshot.ps1: Get-SnapshotField drops $null -eq $Object -or (already covered by -isnot [pscustomobject]) and uses a ternary for the property value; Get-NewFindingKey drops an unused $previous = $null.
  • .changes/machine-health/work-resolve-issue-issue-14651-42715395034-1-17c37047.md: patch fragment, ### Changed / - Internal simplification, no behavior change.

Verification

The runner ran each check from the base copy against 7140f08:

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

The run reports:

  • check-changelog-fragments: all 26 fragments valid (ran before and after tidy and after the review fixes)
  • check-changed-skills: plugins/machine-health/skills/audit PASS, 0 errors, 4 pre-existing warnings about SKILL.md size and description length
  • check-affected: 12 passed, 7 skipped (tools not installed or CI-only), 0 failed
  • fresh-context review subagent over the whole diff: found two confirmed edge-case behavior differences (New-UnknownCheckResult ?? vs if-statement array unrolling; New-InvalidCatalogEntryResult -ccontains culture comparison vs ordinal HashSet). Both hunks were reverted and git diff --stat now…
  • tidy-diff over the changed hunks: no further edits; the fragment text is required word for word by the issue
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42715395034

Left out: the items under Not verified.

Related

#14651

Merge-Risk: max=MEDIUM demote=false head=7140f0810245e825410f8a9a7bcbd10a0037992f rubric=8.3.0 rater=claude-opus-5-5 checker=claude-opus-5-5

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

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 7140f0810245e825410f8a9a7bcbd10a0037992f: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #14887

No security issues found.

I read every hunk of all 4 changed files. None of them matches a trusted-path glob, and none is a plugin manifest, workflow, trust control or instruction surface.

  • .changes/machine-health/...17c37047.md is a patch changelog fragment. It is prose only.
  • Invoke-TrendAnalysis.ps1 merges two blocks that raise WARN to CRIT into one: it picks a reason first, then applies it. This changes how a local audit labels its own findings. No input crosses a trust boundary, and no command, path or credential is involved.
  • In New-ExtensionRecord.ps1, a JSON parse failure now sets $data = $null and falls through to the existing -isnot [hashtable] check, which returns the same State = 'error' object. Parse failures are still rejected, so this check fails closed exactly as before.
  • In New-RunSnapshot.ps1, Get-SnapshotField drops the $null -eq $Object test. $null -isnot [pscustomobject] is already true, so the function still returns $null. The dead $previous = $null pre-assignment is also removed. There is no security impact.

None of these changes adds an injection point, touches a secret or token, grants authority, or removes a guardrail.

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

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed 7140f0810245e825410f8a9a7bcbd10a0037992f: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read all 4 changed files in full, along with the code they call and the existing Pester tests.

Behavior-preservation check (my own reading of the code; I did not run Pester or PSScriptAnalyzer):

  • Invoke-TrendAnalysis.ps1: Before the change, a second block upgraded a drivers check on a CodeIntegrity repeat. It ran only while severity was still WARN, meaning the trend-delta upgrade had not already fired. The new if/elseif under one WARN test runs the repeat check in exactly those cases: no delta, a KEV name-only match, or a trend that is not worsening. The guard changed from if ($upgrade) to if ($reason), which is safe because $deltaText is only set to a non-empty "<key>: <sign><delta> vs prior" string (L140). The note text, adjusted_from and severity come out the same. Tests in tests/windows/lib/Invoke-TrendAnalysis.Tests.ps1 cover the delta upgrade, the KEV exclusion and the drivers repeat upgrade, so a regression here would fail a test.
  • New-ExtensionRecord.ps1: When parsing fails, the catch block now sets $data = $null and falls through to the existing -isnot [hashtable] check. That check returns the same State = 'error' object as before.
  • New-RunSnapshot.ps1: $null -isnot [pscustomobject] is already true, so the removed $null -eq test was redundant. The ternary returns the same values as the old if/else. The removed $previous = $null was dead code because the catch block returns, so StrictMode never reads an unset $previous.

Closing issue #14651:

  • The changes stay within the listed files.
  • The diff is far under the 400-line and 15-file limits.
  • The changelog fragment has bump: patch and the required ### Changed / "Internal simplification, no behavior change." text.
  • ci-status green is left to CI. The author says Pester and lint were not run in their lane; that is author-claimed and I have not checked it.

No embedded instructions were found in the PR context.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 7140f08

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-14887-7140f0810245e825410f8a9a7bcbd10a0037992f, expires on 2026-12-09.

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
Merged via the queue into main with commit 57f6abc Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14651-42715395034-1 branch November 10, 2026 01:08
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 (8 of 9)

0 participants