test harness + Get-PCProfile: alias-aware lookups for rename reorg

Phase 5 + 6 of the gea-shopfloor-* rename.

Get-PCProfile.ps1: when the legacy profileKey ("Standard-Machine",
"CMM", etc.) is missing from siteConfig.pcProfiles, walks the alias
group and returns the first matching new key ("gea-shopfloor-collections",
"gea-shopfloor-cmm", etc.). Vice versa: a fleet PC writing the new
string finds its profile under the old key. Same alias map shape as
GE-Enforce + Install-FromManifest, kept in sync manually for now -
extract to shared file later if drift becomes a problem.

matrix.json: adds 3 new rows for gea-shopfloor-nocollections,
gea-shopfloor-common (Timeclock+Lab merge), gea-shopfloor-heattreat
(placeholder). Existing rows for legacy names retained; the new
verify-state alias resolution lets either be requested.

verify-state.ps1: Test-MatrixEntryMatches walks the alias map so
harness invocation with "Standard Machine" or "gea-shopfloor-collections"
both resolve to the same matrix row.

Smoke-tested via qga-as-SYSTEM on win11: legacy Standard/Machine,
new gea-shopfloor-collections, and new gea-shopfloor-nocollections
all return 10/10 pass against current VM state.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-05-04 07:29:32 -04:00
parent 285d81edc4
commit c890e5b46c
3 changed files with 95 additions and 1 deletions

View File

@@ -25,7 +25,34 @@ if (-not (Test-Path -LiteralPath $MatrixPath)) {
}
$matrix = Get-Content -LiteralPath $MatrixPath -Raw | ConvertFrom-Json
$entry = $matrix.pcTypes | Where-Object { $_.PCType -eq $PCType -and ($_.PCSubType -eq $PCSubType -or [string]::IsNullOrEmpty($_.PCSubType)) } | Select-Object -First 1
# Alias resolution mirrors the GE-Enforce + Get-PCProfile alias maps so
# the harness can be invoked with either legacy ("Standard","CMM",...)
# or new ("gea-shopfloor-collections","gea-shopfloor-cmm",...) names
# and find the right matrix row.
$pcTypeAliasGroups = @(
@{ keys = @('Standard-Machine','gea-shopfloor-collections') },
@{ keys = @('Standard-Machine-NoCollections','gea-shopfloor-nocollections') },
@{ keys = @('Standard-Timeclock','Lab','gea-shopfloor-common') },
@{ keys = @('CMM','gea-shopfloor-cmm') },
@{ keys = @('Keyence','gea-shopfloor-keyence') },
@{ keys = @('WaxAndTrace','gea-shopfloor-waxtrace') },
@{ keys = @('Genspect','gea-shopfloor-genspect') },
@{ keys = @('Display','gea-shopfloor-display') },
@{ keys = @('Heattreat','gea-shopfloor-heattreat') },
@{ keys = @('Shopfloor') }
)
function Test-MatrixEntryMatches {
param($Entry, [string]$Type, [string]$SubType)
$entryKey = if ($Entry.PCSubType) { "$($Entry.PCType)-$($Entry.PCSubType)" } else { $Entry.PCType }
$requestKey = if ($SubType) { "$Type-$SubType" } else { $Type }
if ($entryKey -ieq $requestKey) { return $true }
foreach ($g in $pcTypeAliasGroups) {
if ($g.keys -icontains $entryKey -and $g.keys -icontains $requestKey) { return $true }
}
return $false
}
$entry = $matrix.pcTypes | Where-Object { Test-MatrixEntryMatches -Entry $_ -Type $PCType -SubType $PCSubType } | Select-Object -First 1
if (-not $entry) {
Write-Host "[FAIL] no matrix entry for PCType=$PCType PCSubType=$PCSubType"
exit 1