Skip to content

Lift the Diagnostic out of the orchestrator into src/WcdDiagnostic.ps1 - #31

Merged
DireDoch merged 1 commit into
mainfrom
fix/16-lift-diagnostic-out-of-orchestrator
Sep 3, 2026
Merged

DireDoch merged 1 commit into
mainfrom
fix/16-lift-diagnostic-out-of-orchestrator

Conversation

@DireDoch

@DireDoch DireDoch commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Closes #16.

What moved

The 13 functions that decide what the technician reads, lifted byte for byte out
of src/Invoke-WcdConfiguration.ps1 into src/WcdDiagnostic.ps1:
Get-WcdSeverityRank, Get-WcdResultsForSteps, Get-WcdStrongestResult,
Format-WcdRemedy, Get-WcdAggregateDetail, New-WcdDiagnosticEntry,
Resolve-WcdAutomaticEntry, Get-WcdModuleStatusKind, Format-WcdModuleLine,
Format-WcdChecklistLine, Write-WcdSectionHeader,
Get-WcdFinalChecklistEntries, Get-WcdFinalDiagnosticLines.

Read-WcdChoice, Read-WcdComputerName, Wait-WcdForEnter and
Resolve-WcdExecutionOptions stayed: they are the console, not the Diagnostic.

The orchestrator dot-sources the new file beside WcdHelpers.ps1. No behaviour
changes; the moved block is identical to what was removed.

The $T problem

Took the second option from the issue: the functions still read $script:T.
Rather than hand-copy a $T into the test file and let it drift, the test lifts
the real assignment out of the orchestrator's AST and evaluates it with
$ScriptUI = 'EN'. The assertions therefore run against the strings a
technician actually sees, and a renamed key breaks the test instead of passing
silently.

Tests

tests/WcdDiagnostic.Tests.ps1, 16 tests, covering every box on the issue:

  • a declined prompt (ApplicationsSkip) yields a Manual Step
  • a Step filtered by Environment yields Not Applicable, not a warning
  • a Step that could not run yields a failure, with its remediation
  • a Step handed back to the technician (MANUAL) yields a Manual Step, not a failure
  • an Optional Application Target that is absent yields a note, not a warning
  • a Module reporting some but not all of its planned Steps yields a warning naming the missing one
  • Format-WcdRemedy with a key absent from $T.Remedy renders nothing
  • Format-WcdRemedy with mismatched RemedyArgs returns the template, not a throw
  • plus severity ordering, worst-result aggregation, and the history-log rendering

tests/Help.Tests.ps1 still green: comment-based help came across intact.

Verified

Run locally on PowerShell 7.4.6:

  • Invoke-Pester ./tests/*.Tests.ps1 — 128 passed, 2 failed. Both failures are
    the pre-existing Windows-only ones (New-WinUserLanguageList,
    Get-CimInstance) that also fail on main from Linux; CI runs
    windows-latest, where they pass.
  • Invoke-ScriptAnalyzer -Path . -Recurse -Settings ./PSScriptAnalyzerSettings.psd1 — clean.

One small change that is not a pure move

FatalHelpersMissing now takes the filename as {0}, since there are two files
to dot-source. The rendered sentence for WcdHelpers.ps1 is unchanged, so
console output stays byte-identical.

Left out

docs/manual.typ has two Typst diagrams of the src/ tree that still show two
files. Adding a row means shifting every coordinate in both and rebuilding the
committed PDF — out of scope here, worth its own issue. The README tree is
updated.

🤖 Generated with Claude Code

The 13 functions that decide what the technician actually reads lived in
Invoke-WcdConfiguration.ps1, where nothing could reach them: dot-sourcing the
script runs the whole run. So the three-way "skip" CONTEXT.md works hardest to
pin down - declined prompt is a Manual Step, filtered by Form Factor or
Environment is Not Applicable, could-not-run is a failure - was the only rule
with no test behind it.

A pure move, byte for byte. The new file is dot-sourced beside WcdHelpers.ps1
and still reads $T from script scope; the test file sets $script:T in BeforeAll
by lifting the real assignment out of the orchestrator's AST, so the tests
assert against the strings a technician actually sees rather than a copy that
drifts.

Read-WcdChoice, Read-WcdComputerName, Wait-WcdForEnter and
Resolve-WcdExecutionOptions stay put: they are the console, not the Diagnostic.

FatalHelpersMissing now names the file it could not find, since there are two.
The rendered sentence is unchanged.

Closes #16

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@DireDoch
DireDoch merged commit 78b62c2 into main Sep 3, 2026
3 checks passed
@DireDoch
DireDoch deleted the fix/16-lift-diagnostic-out-of-orchestrator branch September 3, 2026 20:25
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.

Lift the Diagnostic out of the orchestrator into src/WcdDiagnostic.ps1

1 participant