Compare Windows maintenance state structurally and reject colliding object keys
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-15 14:41:30 +01:00
parent 456734000b
commit e6debe5ba6
2 changed files with 34 additions and 0 deletions
@@ -70,6 +70,19 @@ def controller():
# calibration/public-time-pin file or changes the six-field passive config.
marker = 'function State([bool]$new){\n'
prefix = replace_once(prefix, marker, marker + " if(Test-Path -LiteralPath (Join-Path $helperRoot 'time-attestation.json')){throw 'Separate time-pin provisioning required; passive bootstrap does not adopt it'}\n")
# Compare JSON objects by their contents; serialized member order is not
# identity. Arrays retain exact order and empty/null values stay distinct.
prefix = replace_once(prefix,
"function JsonEqual($a,$b){return(($a|ConvertTo-Json -Depth 40 -Compress)-ceq($b|ConvertTo-Json -Depth 40 -Compress))}",
r'''function CanonicalStateValue($value,[int]$depth=0){
if($depth-gt40){throw 'Bounded state comparison depth'}
if($null-eq$value){return $null}
if($value-is[Collections.IDictionary]){$result=[ordered]@{};foreach($key in @($value.Keys|Sort-Object -CaseSensitive)){if($key-isnot[string]-or$result.Contains($key)){throw 'Nonunique state object key'};$result[$key]=CanonicalStateValue $value[$key] ($depth+1)};return $result}
if($value-is[pscustomobject]){$result=[ordered]@{};foreach($property in @($value.PSObject.Properties|Sort-Object -Property Name -CaseSensitive)){if($property.Name-isnot[string]-or$result.Contains($property.Name)){throw 'Nonunique state object key'};$result[$property.Name]=CanonicalStateValue $property.Value ($depth+1)};return $result}
if($value-is[Collections.IEnumerable]-and$value-isnot[string]){$result=New-Object 'Collections.Generic.List[object]';foreach($item in $value){$result.Add((CanonicalStateValue $item ($depth+1)))};return ,$result.ToArray()}
return $value
}
function JsonEqual($a,$b){return((ConvertTo-Json -InputObject (CanonicalStateValue $a) -Depth 40 -Compress)-ceq(ConvertTo-Json -InputObject (CanonicalStateValue $b) -Depth 40 -Compress))}''')
native = prior.NATIVE.replace('RmmPipeNative', 'RmmSignedClockPairNative')
phases = prior.PHASES.replace('SystemPipeUpgrade.ps1', 'SignedClockPairUpgrade.ps1').replace('RmmPipeNative', 'RmmSignedClockPairNative')
# No implicit fallthrough may become an effect, even if a future caller