Skip to content

fix(machine-health): drop Export-ModuleMember from Mock-Helpers - #4374

Merged
kyle-sexton merged 2 commits into
mainfrom
fix/pssa-race-triggers
Sep 23, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
fix/pssa-race-triggers

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

No related issue: org-wide follow-up to melodic-software/standards#598, which stays open in standards

Summary

Removes Export-ModuleMember from the machine-health test helper Mock-Helpers.psm1. On files that call it, PSScriptAnalyzer 1.25.0 intermittently throws a NullReferenceException: Helper.GetExportedFunction calls CommandInfo.ResolveParameter on a shared cached CommandInfo while rules run in parallel (PowerShell/PSScriptAnalyzer#1867, #2188; fix pending in PR #2206).

Fix

Deleted the trailing Export-ModuleMember -Function @(...) block. Without it a script module exports every function it defines, and this module exported all 14 of its functions, so the exported set does not change. machine-health is bumped to 0.13.1 with a changelog entry. The lint gate stays fail-closed with no retry (decision on melodic-software/standards#598).

Verification

  • Exports before and after, via (Import-Module ./Mock-Helpers.psm1 -PassThru -Force).ExportedCommands.Keys: the same 14 functions (New-MachineHealthTempDir, New-MockBattery, New-MockDefenderComputerStatus, New-MockDriver, New-MockEnvironmentKey, New-MockEventLogRecord, New-MockPartition, New-MockPhysicalDisk, New-MockReliabilityCounter, New-MockReliabilityRecord, New-MockReliabilityStabilityMetric, New-MockService, New-MockVolume, Remove-MachineHealthTempDir).
  • Invoke-ScriptAnalyzer on the file, one fresh pwsh per run: main threw in 3 of 10 runs (the surfaced error was the NRE); this branch threw in 0 of 20. The finding count is unchanged (14, all default-ruleset warnings that predate this change).
  • Invoke-MachineHealthTests.ps1: 443 passed, 1 failed, 1 skipped on both main and this branch. The one failure (Test-EnvironmentHealth "expands %VAR% before existence and scope checks") reads this machine's environment and fails identically on main.
  • skill-evidence block absent: flipped ready with gh pr ready from a worker session; the change is a 17-line deletion plus a version bump, verified by the export and PSScriptAnalyzer checks above.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01XJ1oJNVZ9BySCtLzdJtf25

PSScriptAnalyzer 1.25.0 intermittently throws a NullReferenceException on
files that call Export-ModuleMember: rules run in parallel and share a
cached CommandInfo (PowerShell/PSScriptAnalyzer#1867, #2188; fix pending in
PR #2206). Without the call a .psm1 exports every function it defines, and
this module exports all 14 of its functions, so the exported set is
unchanged.

Refs melodic-software/standards#598

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XJ1oJNVZ9BySCtLzdJtf25
@kyle-sexton
kyle-sexton marked this pull request as ready for review September 23, 2026 17:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T17:30:02.323411Z 61f8515 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Skill evidence: a gap at ac8aef703dcf075d0d070962283784c65cdb2d5c

The skill-evidence block under ## Verification does not cover every mandatory
skill for the files this pull request changes, read against the map in
.claude/source-control.md:

class=markdown
class=skills
class=security
missing=ai-slop:audit
missing=docs-hygiene:audit-noise
missing=skill-quality:check
missing=review:security-review

Run /source-control:pull-request ready to re-render the block at the current head.
This is advisory: no check turns red on it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XJ1oJNVZ9BySCtLzdJtf25
@kyle-sexton
kyle-sexton merged commit 7ae28fa into main Sep 23, 2026
22 checks passed
@kyle-sexton
kyle-sexton deleted the fix/pssa-race-triggers branch September 23, 2026 17:40
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.

1 participant