From d431330a2d9965bda989c515777042c610edeee1 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 21 Nov 2026 03:30:31 +0700 Subject: [PATCH 1/5] fix(P0 installer): fail closed after interrupted VB-CABLE vendor setup Guard uncertain UAC/vendor outcomes and damaged status records so later interactive upgrades cannot invoke the vendor REMOVE action. Preserve auto-install for genuinely missing devices, skip healthy installs, and add Windows detection fixture coverage. --- installer/ArSonMixVBCableInstall.ps1 | 31 +++++++++++++++++-- scripts/test_inno_graceful_update_windows.ps1 | 20 ++++++++++-- tests/windows_installer_contract_test.mjs | 9 ++++++ 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/installer/ArSonMixVBCableInstall.ps1 b/installer/ArSonMixVBCableInstall.ps1 index e42473f9e..9c418580e 100644 --- a/installer/ArSonMixVBCableInstall.ps1 +++ b/installer/ArSonMixVBCableInstall.ps1 @@ -35,14 +35,28 @@ function Read-BootEpoch($value) { } $dir=Join-Path $env:TEMP ("armix-cable-"+[guid]::NewGuid().ToString("N")) $pending=$false +$driverAttemptUncertain=$false +$vendorStarted=$false try { # A driver already queued for reboot must NOT be run again: the VB-Audio # setup utility can switch into REMOVE mode on a second invocation. $previous=$null if(Test-Path -LiteralPath $statusPath -PathType Leaf){ - $previous=Get-Content -LiteralPath $statusPath -Raw -ErrorAction Stop | ConvertFrom-Json + try { + $previous=Get-Content -LiteralPath $statusPath -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop + } catch { + # A damaged record may conceal an interrupted vendor install. Never + # assume the hardware is absent and run a setup with a REMOVE button. + Record "REPAIR_REQUIRED" "Previous VB-CABLE install status unreadable; inspect Windows Device Manager" + exit 3 + } } - $pending=$null -ne $previous -and $previous.state -eq 'PENDING_REBOOT' + $previousState=if($null -ne $previous){[string]$previous.state}else{""} + $pending=$previousState -eq 'PENDING_REBOOT' + # A prior invocation may have died after starting the vendor GUI but + # before recording its result. An uncertain or repair-required attempt + # must never launch the same setup automatically again. + $driverAttemptUncertain=$previousState -notin @("","ALREADY_PRESENT","FAILED","PENDING_REBOOT") $os=Get-CimInstance Win32_OperatingSystem -ErrorAction Stop $script:bootUtc=$os.LastBootUpTime.ToUniversalTime().ToString('o') if($pending){ @@ -76,6 +90,10 @@ try { Record "ALREADY_PRESENT" "VB-CABLE device already installed; vendor installer skipped" exit 0 } + if($driverAttemptUncertain){ + Record "REPAIR_REQUIRED" "Previous VB-CABLE install outcome uncertain; inspect Device Manager before manual recovery" + exit 3 + } if(-not (Test-Path -LiteralPath $Archive -PathType Leaf)){throw "Bundled driver ZIP absent"} $hash=(Get-FileHash -LiteralPath $Archive -Algorithm SHA256).Hash.ToLowerInvariant() if($hash -cne $ExpectedSha256.ToLowerInvariant()){throw "Pinned driver ZIP hash mismatch"} @@ -105,12 +123,19 @@ try { # Official reference manual requires the vendor GUI, admin and reboot. # No undocumented silent switches and no TrustedPublisher modification. $process=Start-Process -FilePath $setups[0].FullName -WorkingDirectory $setups[0].DirectoryName -Verb RunAs -Wait -PassThru + $vendorStarted=$true if($process.ExitCode -ne 0){throw ("Vendor installer returned "+$process.ExitCode)} Record "PENDING_REBOOT" "Reboot Windows, then verify CABLE Output and physical speaker" exit 0 } catch { # A failed OS/PnP query is not proof a recorded installation vanished. - if(-not $pending){Record "FAILED" $_.Exception.Message} + if($vendorStarted){ + # Nonzero vendor exit can mean partial driver changes. A subsequent + # auto-run could invoke REMOVE instead of INSTALL. + Record "REPAIR_REQUIRED" ("Vendor installation result uncertain: "+$_.Exception.Message) + } elseif(-not $pending -and -not $driverAttemptUncertain){ + Record "FAILED" $_.Exception.Message + } Write-Warning ("Optional VB-Audio driver step incomplete: "+$_.Exception.Message) exit 2 } finally { diff --git a/scripts/test_inno_graceful_update_windows.ps1 b/scripts/test_inno_graceful_update_windows.ps1 index 0e5595863..42c841e98 100644 --- a/scripts/test_inno_graceful_update_windows.ps1 +++ b/scripts/test_inno_graceful_update_windows.ps1 @@ -57,14 +57,28 @@ function Test-VBCableSmartDetection { @{Name='after-reboot'; Device='present'; Expected='ALREADY_PRESENT'; RecordedBoot=$boot.AddDays(-1)}, @{Name='missing-after-reboot'; Device='absent'; Expected='REPAIR_REQUIRED'; RecordedBoot=$boot.AddDays(-1)}, @{Name='missing'; Device='absent'; Expected='FAILED'; Reason='Bundled driver ZIP absent'}, - @{Name='query-failure'; Device='error'; Expected='FAILED'; Reason='Fixture PnP query denied'} + @{Name='query-failure'; Device='error'; Expected='FAILED'; Reason='Fixture PnP query denied'}, + @{Name='interrupted-uac-missing'; Device='absent'; Expected='REPAIR_REQUIRED'; PreviousState='AWAITING_UAC'}, + @{Name='interrupted-uac-present'; Device='present'; Expected='ALREADY_PRESENT'; PreviousState='AWAITING_UAC'}, + @{Name='repair-missing'; Device='absent'; Expected='REPAIR_REQUIRED'; PreviousState='REPAIR_REQUIRED'}, + @{Name='unknown-state-missing'; Device='absent'; Expected='REPAIR_REQUIRED'; PreviousState='UNKNOWN'}, + @{Name='corrupt-status'; Device='absent'; Expected='REPAIR_REQUIRED'; Corrupt=$true} )) { $env:APPDATA=Join-Path $work ("cable-"+$case.Name) $status=Join-Path $env:APPDATA "AR-MIX-Studio/VB-CABLE-STATUS.json" + $statusFixture=@{} if ($case.ContainsKey('RecordedBoot')) { + $statusFixture.state='PENDING_REBOOT' + $statusFixture.bootUtc=$case.RecordedBoot.ToString('o') + } + if ($case.ContainsKey('PreviousState')) { $statusFixture.state=$case.PreviousState } + if ($statusFixture.Count -gt 0 -or $case.ContainsKey('Corrupt')) { New-Item -ItemType Directory -Force -Path (Split-Path -Parent $status) | Out-Null - @{state='PENDING_REBOOT';bootUtc=$case.RecordedBoot.ToString('o')} | - ConvertTo-Json | Set-Content -LiteralPath $status + if ($case.ContainsKey('Corrupt')) { + '{ invalid incomplete installer status' | Set-Content -LiteralPath $status + } else { + $statusFixture | ConvertTo-Json | Set-Content -LiteralPath $status + } } # Deliberately absent payload: the missing-device case alone should # check for the archive. Presence and pending must return earlier. diff --git a/tests/windows_installer_contract_test.mjs b/tests/windows_installer_contract_test.mjs index a69905755..7874119c5 100644 --- a/tests/windows_installer_contract_test.mjs +++ b/tests/windows_installer_contract_test.mjs @@ -73,6 +73,15 @@ test('interactive Setup automatically checks for signed VB-CABLE while mixer lau assert.match(bootstrap, /previous\.PSObject\.Properties\['bootUtc'\]/); assert.match(bootstrap, /PENDING_REBOOT.*Restart Windows|Record "PENDING_REBOOT"/); assert.match(bootstrap, /Record "REPAIR_REQUIRED"/); + // Interrupted vendor/UAC attempts must not be treated as fresh installs; + // rerunning the vendor GUI can switch into destructive REMOVE mode. + assert.match(bootstrap, /previousState -notin/); + assert.match(bootstrap, /\$driverAttemptUncertain\)\{/); + assert.match(bootstrap, /\$vendorStarted=\$true/); + assert.match(bootstrap, /Vendor installation result uncertain/); + assert.match(isolatedSmoke, /interrupted-uac-missing/); + assert.match(isolatedSmoke, /interrupted-uac-present/); + assert.match(isolatedSmoke, /corrupt-status/); assert.match(bootstrap, /if\(\$all.Count -gt 0\)\{[\s\S]*?\$present \| Where-Object[\s\S]*?Record "ALREADY_PRESENT"[\s\S]*?exit 0/); assert.ok(bootstrap.indexOf("previous.state -eq 'PENDING_REBOOT'") < bootstrap.indexOf('Start-Process -FilePath $setups[0].FullName'), From 50f1a67995ef0c36a145e828cf5b5b3640501a10 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 21 Nov 2026 03:31:42 +0700 Subject: [PATCH 2/5] test(installer): align pending-reboot contracts and reject malformed prior state Keep old PENDING_REBOOT behavior asserted by the source contract, and treat valid JSON lacking a recognized state as an uncertain previous attempt instead of a fresh install. --- installer/ArSonMixVBCableInstall.ps1 | 9 ++++++--- tests/windows_installer_contract_test.mjs | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/installer/ArSonMixVBCableInstall.ps1 b/installer/ArSonMixVBCableInstall.ps1 index 9c418580e..54bdd7ca1 100644 --- a/installer/ArSonMixVBCableInstall.ps1 +++ b/installer/ArSonMixVBCableInstall.ps1 @@ -41,7 +41,8 @@ try { # A driver already queued for reboot must NOT be run again: the VB-Audio # setup utility can switch into REMOVE mode on a second invocation. $previous=$null - if(Test-Path -LiteralPath $statusPath -PathType Leaf){ + $hadPreviousStatus=Test-Path -LiteralPath $statusPath -PathType Leaf + if($hadPreviousStatus){ try { $previous=Get-Content -LiteralPath $statusPath -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop } catch { @@ -51,12 +52,14 @@ try { exit 3 } } - $previousState=if($null -ne $previous){[string]$previous.state}else{""} + $previousState=if($null -ne $previous -and $null -ne $previous.PSObject.Properties['state']){ + [string]$previous.state + }else{""} $pending=$previousState -eq 'PENDING_REBOOT' # A prior invocation may have died after starting the vendor GUI but # before recording its result. An uncertain or repair-required attempt # must never launch the same setup automatically again. - $driverAttemptUncertain=$previousState -notin @("","ALREADY_PRESENT","FAILED","PENDING_REBOOT") + $driverAttemptUncertain=$hadPreviousStatus -and $previousState -notin @("ALREADY_PRESENT","FAILED","PENDING_REBOOT") $os=Get-CimInstance Win32_OperatingSystem -ErrorAction Stop $script:bootUtc=$os.LastBootUpTime.ToUniversalTime().ToString('o') if($pending){ diff --git a/tests/windows_installer_contract_test.mjs b/tests/windows_installer_contract_test.mjs index 7874119c5..5e967421b 100644 --- a/tests/windows_installer_contract_test.mjs +++ b/tests/windows_installer_contract_test.mjs @@ -69,7 +69,7 @@ test('interactive Setup automatically checks for signed VB-CABLE while mixer lau assert.match(bootstrap, /Get-PnpDevice -PresentOnly/); assert.match(bootstrap, /Get-PnpDevice -ErrorAction Stop/); assert.match(bootstrap, /Get-CimInstance Win32_OperatingSystem/); - assert.match(bootstrap, /previous\.state -eq 'PENDING_REBOOT'/); + assert.match(bootstrap, /previousState -eq 'PENDING_REBOOT'/); assert.match(bootstrap, /previous\.PSObject\.Properties\['bootUtc'\]/); assert.match(bootstrap, /PENDING_REBOOT.*Restart Windows|Record "PENDING_REBOOT"/); assert.match(bootstrap, /Record "REPAIR_REQUIRED"/); @@ -83,7 +83,7 @@ test('interactive Setup automatically checks for signed VB-CABLE while mixer lau assert.match(isolatedSmoke, /interrupted-uac-present/); assert.match(isolatedSmoke, /corrupt-status/); assert.match(bootstrap, /if\(\$all.Count -gt 0\)\{[\s\S]*?\$present \| Where-Object[\s\S]*?Record "ALREADY_PRESENT"[\s\S]*?exit 0/); - assert.ok(bootstrap.indexOf("previous.state -eq 'PENDING_REBOOT'") < + assert.ok(bootstrap.indexOf("previousState -eq 'PENDING_REBOOT'") < bootstrap.indexOf('Start-Process -FilePath $setups[0].FullName'), 'pending reboot must be checked before launching a setup that can remove installed cable'); assert.match(bootstrap, /-Verb RunAs/); From e2220661e797b3d6f22478eeef157c615d0ac3fd Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 21 Nov 2026 04:15:23 +0700 Subject: [PATCH 3/5] fix(P0 VB-CABLE): preserve uncertainty after vendor ShellExecute failure Record unrecoverable handoff failures as REPAIR_REQUIRED, not automatic retry; recognize healthy already-installed cable despite corrupted previous JSON; exercise real script control flow with offline synthetic signed-fixture handoff and rerun guards. No actual driver execution in CI. --- installer/ArSonMixVBCableInstall.ps1 | 33 ++++++++++------ scripts/test_inno_graceful_update_windows.ps1 | 38 +++++++++++++++++-- tests/windows_installer_contract_test.mjs | 14 +++++-- 3 files changed, 67 insertions(+), 18 deletions(-) diff --git a/installer/ArSonMixVBCableInstall.ps1 b/installer/ArSonMixVBCableInstall.ps1 index 54bdd7ca1..2a11dbc2a 100644 --- a/installer/ArSonMixVBCableInstall.ps1 +++ b/installer/ArSonMixVBCableInstall.ps1 @@ -36,7 +36,8 @@ function Read-BootEpoch($value) { $dir=Join-Path $env:TEMP ("armix-cable-"+[guid]::NewGuid().ToString("N")) $pending=$false $driverAttemptUncertain=$false -$vendorStarted=$false +$unreadablePreviousStatus=$false +$vendorHandoffAttempted=$false try { # A driver already queued for reboot must NOT be run again: the VB-Audio # setup utility can switch into REMOVE mode on a second invocation. @@ -46,10 +47,10 @@ try { try { $previous=Get-Content -LiteralPath $statusPath -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop } catch { - # A damaged record may conceal an interrupted vendor install. Never - # assume the hardware is absent and run a setup with a REMOVE button. - Record "REPAIR_REQUIRED" "Previous VB-CABLE install status unreadable; inspect Windows Device Manager" - exit 3 + # A damaged record may conceal an interrupted vendor installation. + # Defer the decision until PnP: a healthy, already-installed cable must + # still be recognized, but a missing cable must never reach vendor setup. + $unreadablePreviousStatus=$true } } $previousState=if($null -ne $previous -and $null -ne $previous.PSObject.Properties['state']){ @@ -59,7 +60,8 @@ try { # A prior invocation may have died after starting the vendor GUI but # before recording its result. An uncertain or repair-required attempt # must never launch the same setup automatically again. - $driverAttemptUncertain=$hadPreviousStatus -and $previousState -notin @("ALREADY_PRESENT","FAILED","PENDING_REBOOT") + $driverAttemptUncertain=$unreadablePreviousStatus -or + ($hadPreviousStatus -and $previousState -notin @("ALREADY_PRESENT","FAILED","PENDING_REBOOT")) $os=Get-CimInstance Win32_OperatingSystem -ErrorAction Stop $script:bootUtc=$os.LastBootUpTime.ToUniversalTime().ToString('o') if($pending){ @@ -94,7 +96,12 @@ try { exit 0 } if($driverAttemptUncertain){ - Record "REPAIR_REQUIRED" "Previous VB-CABLE install outcome uncertain; inspect Device Manager before manual recovery" + $detail=if($unreadablePreviousStatus){ + "Previous VB-CABLE install record unreadable; inspect Device Manager before manual recovery" + }else{ + "Previous VB-CABLE install outcome uncertain; inspect Device Manager before manual recovery" + } + Record "REPAIR_REQUIRED" $detail exit 3 } if(-not (Test-Path -LiteralPath $Archive -PathType Leaf)){throw "Bundled driver ZIP absent"} @@ -123,19 +130,21 @@ try { throw "VB-Audio Authenticode signature unavailable or invalid" } Record "AWAITING_UAC" "Windows may request approval to install the missing VB-Audio driver" + # Once handed to Windows/ShellExecute, a thrown exception does not prove + # the vendor process never ran. Keep the on-disk attempt fail-closed. + $vendorHandoffAttempted=$true # Official reference manual requires the vendor GUI, admin and reboot. # No undocumented silent switches and no TrustedPublisher modification. $process=Start-Process -FilePath $setups[0].FullName -WorkingDirectory $setups[0].DirectoryName -Verb RunAs -Wait -PassThru - $vendorStarted=$true if($process.ExitCode -ne 0){throw ("Vendor installer returned "+$process.ExitCode)} Record "PENDING_REBOOT" "Reboot Windows, then verify CABLE Output and physical speaker" exit 0 } catch { # A failed OS/PnP query is not proof a recorded installation vanished. - if($vendorStarted){ - # Nonzero vendor exit can mean partial driver changes. A subsequent - # auto-run could invoke REMOVE instead of INSTALL. - Record "REPAIR_REQUIRED" ("Vendor installation result uncertain: "+$_.Exception.Message) + if($vendorHandoffAttempted){ + # A failure or nonzero exit at/after handoff may still have installed + # drivers. Never overwrite AWAITING_UAC with retryable FAILED. + Record "REPAIR_REQUIRED" ("Vendor handoff/install result uncertain: "+$_.Exception.Message) } elseif(-not $pending -and -not $driverAttemptUncertain){ Record "FAILED" $_.Exception.Message } diff --git a/scripts/test_inno_graceful_update_windows.ps1 b/scripts/test_inno_graceful_update_windows.ps1 index 42c841e98..c984a733f 100644 --- a/scripts/test_inno_graceful_update_windows.ps1 +++ b/scripts/test_inno_graceful_update_windows.ps1 @@ -46,8 +46,16 @@ function Test-VBCableSmartDetection { if ($case.Device -eq 'absent' -or ($case.Device -eq 'offline' -and $PresentOnly)) { return } [pscustomobject]@{FriendlyName="CABLE Output (VB-Audio Virtual Cable)";Status="OK"} } - # Guard the fixture from every attempt to launch a vendor process. - function Start-Process { throw "Unexpected vendor launch in detection fixture" } + # Mock vendor handoff: no real device, driver, elevation, or external EXE. + $script:vendorHandoffCount=0 + function Start-Process { + $script:vendorHandoffCount++ + throw "Fixture vendor handoff failure before process handle" + } + function Get-AuthenticodeSignature { + [CmdletBinding()] param([string]$LiteralPath) + [pscustomobject]@{Status='Valid';SignerCertificate=[pscustomobject]@{Subject='CN=VB-Audio'}} + } try { foreach ($case in @( @{Name='healthy'; Device='present'; Expected='ALREADY_PRESENT'}, @@ -62,7 +70,9 @@ function Test-VBCableSmartDetection { @{Name='interrupted-uac-present'; Device='present'; Expected='ALREADY_PRESENT'; PreviousState='AWAITING_UAC'}, @{Name='repair-missing'; Device='absent'; Expected='REPAIR_REQUIRED'; PreviousState='REPAIR_REQUIRED'}, @{Name='unknown-state-missing'; Device='absent'; Expected='REPAIR_REQUIRED'; PreviousState='UNKNOWN'}, - @{Name='corrupt-status'; Device='absent'; Expected='REPAIR_REQUIRED'; Corrupt=$true} + @{Name='corrupt-status'; Device='absent'; Expected='REPAIR_REQUIRED'; Corrupt=$true}, + @{Name='corrupt-status-but-healthy'; Device='present'; Expected='ALREADY_PRESENT'; Corrupt=$true}, + @{Name='empty-json-status'; Device='absent'; Expected='REPAIR_REQUIRED'; PreviousState=''} )) { $env:APPDATA=Join-Path $work ("cable-"+$case.Name) $status=Join-Path $env:APPDATA "AR-MIX-Studio/VB-CABLE-STATUS.json" @@ -89,6 +99,28 @@ function Test-VBCableSmartDetection { Assert-Condition ($result.reason -ceq $case.Reason) "VB-CABLE reason mismatch for $($case.Name)" } } + Assert-Condition ($script:vendorHandoffCount -eq 0) "Preflight PnP fixtures unexpectedly launched vendor" + # Use a synthetic ZIP and a mocked signature to enter the *real* + # setup handoff code without ever executing a driver or showing UAC. + $source=Join-Path $work 'vendor-handoff-source' + New-Item -ItemType Directory -Force -Path $source | Out-Null + foreach($name in @('VBCABLE_Setup_x64.exe','README.txt','LICENSE.txt','setup.ini','manifest.txt')){ + [IO.File]::WriteAllText((Join-Path $source $name), "FAKE_FIXTURE_ONLY_$name") + } + $archive=Join-Path $work 'synthetic-vendor.zip' + Add-Type -AssemblyName System.IO.Compression.FileSystem + [IO.Compression.ZipFile]::CreateFromDirectory($source,$archive) + $sha=(Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash + $env:APPDATA=Join-Path $work 'cable-vendor-handoff' + $record=Join-Path $env:APPDATA 'AR-MIX-Studio/VB-CABLE-STATUS.json' + & $bootstrap -Archive $archive -ExpectedSha256 $sha + $outcome=Get-Content -LiteralPath $record -Raw | ConvertFrom-Json + Assert-Condition ($outcome.state -ceq 'REPAIR_REQUIRED') "Failed vendor handoff became retryable: $($outcome.state)" + Assert-Condition ($script:vendorHandoffCount -eq 1) "Fixture did not reach single mocked vendor handoff" + & $bootstrap -Archive $archive -ExpectedSha256 $sha + $outcome=Get-Content -LiteralPath $record -Raw | ConvertFrom-Json + Assert-Condition ($outcome.state -ceq 'REPAIR_REQUIRED') "Repeated setup did not remain fail-closed" + Assert-Condition ($script:vendorHandoffCount -eq 1) "Repeat setup incorrectly relaunched uncertain vendor installer" } finally { $env:APPDATA=$originalAppData } diff --git a/tests/windows_installer_contract_test.mjs b/tests/windows_installer_contract_test.mjs index 5e967421b..7f97dcf4f 100644 --- a/tests/windows_installer_contract_test.mjs +++ b/tests/windows_installer_contract_test.mjs @@ -77,11 +77,19 @@ test('interactive Setup automatically checks for signed VB-CABLE while mixer lau // rerunning the vendor GUI can switch into destructive REMOVE mode. assert.match(bootstrap, /previousState -notin/); assert.match(bootstrap, /\$driverAttemptUncertain\)\{/); - assert.match(bootstrap, /\$vendorStarted=\$true/); - assert.match(bootstrap, /Vendor installation result uncertain/); + assert.match(bootstrap, /\$vendorHandoffAttempted=\$true/); + assert.match(bootstrap, /if\(\$vendorHandoffAttempted\)/); + assert.match(bootstrap, /Vendor handoff\/install result uncertain/); + assert.ok(bootstrap.indexOf('Record "AWAITING_UAC"') < + bootstrap.indexOf('$vendorHandoffAttempted=$true') && + bootstrap.indexOf('$vendorHandoffAttempted=$true') < + bootstrap.indexOf('Start-Process -FilePath $setups[0].FullName'), + 'vendor handoff must become fail-closed before invoking ShellExecute'); assert.match(isolatedSmoke, /interrupted-uac-missing/); assert.match(isolatedSmoke, /interrupted-uac-present/); - assert.match(isolatedSmoke, /corrupt-status/); + assert.match(isolatedSmoke, /corrupt-status-but-healthy/); + assert.match(isolatedSmoke, /cable-vendor-handoff/); + assert.match(isolatedSmoke, /vendorHandoffCount -eq 1/); assert.match(bootstrap, /if\(\$all.Count -gt 0\)\{[\s\S]*?\$present \| Where-Object[\s\S]*?Record "ALREADY_PRESENT"[\s\S]*?exit 0/); assert.ok(bootstrap.indexOf("previousState -eq 'PENDING_REBOOT'") < bootstrap.indexOf('Start-Process -FilePath $setups[0].FullName'), From 14824d2ccc6019a70c391011290ae86f0e5b9844 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 21 Nov 2026 04:16:39 +0700 Subject: [PATCH 4/5] test(installer): share vendor handoff counter across invoked PowerShell scopes --- scripts/test_inno_graceful_update_windows.ps1 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/test_inno_graceful_update_windows.ps1 b/scripts/test_inno_graceful_update_windows.ps1 index c984a733f..1fbb99eee 100644 --- a/scripts/test_inno_graceful_update_windows.ps1 +++ b/scripts/test_inno_graceful_update_windows.ps1 @@ -47,9 +47,9 @@ function Test-VBCableSmartDetection { [pscustomobject]@{FriendlyName="CABLE Output (VB-Audio Virtual Cable)";Status="OK"} } # Mock vendor handoff: no real device, driver, elevation, or external EXE. - $script:vendorHandoffCount=0 + $global:ArSonMixTestVendorHandoffCount=0 function Start-Process { - $script:vendorHandoffCount++ + $global:ArSonMixTestVendorHandoffCount++ throw "Fixture vendor handoff failure before process handle" } function Get-AuthenticodeSignature { @@ -99,7 +99,7 @@ function Test-VBCableSmartDetection { Assert-Condition ($result.reason -ceq $case.Reason) "VB-CABLE reason mismatch for $($case.Name)" } } - Assert-Condition ($script:vendorHandoffCount -eq 0) "Preflight PnP fixtures unexpectedly launched vendor" + Assert-Condition ($global:ArSonMixTestVendorHandoffCount -eq 0) "Preflight PnP fixtures unexpectedly launched vendor" # Use a synthetic ZIP and a mocked signature to enter the *real* # setup handoff code without ever executing a driver or showing UAC. $source=Join-Path $work 'vendor-handoff-source' @@ -116,13 +116,14 @@ function Test-VBCableSmartDetection { & $bootstrap -Archive $archive -ExpectedSha256 $sha $outcome=Get-Content -LiteralPath $record -Raw | ConvertFrom-Json Assert-Condition ($outcome.state -ceq 'REPAIR_REQUIRED') "Failed vendor handoff became retryable: $($outcome.state)" - Assert-Condition ($script:vendorHandoffCount -eq 1) "Fixture did not reach single mocked vendor handoff" + Assert-Condition ($global:ArSonMixTestVendorHandoffCount -eq 1) "Fixture did not reach single mocked vendor handoff" & $bootstrap -Archive $archive -ExpectedSha256 $sha $outcome=Get-Content -LiteralPath $record -Raw | ConvertFrom-Json Assert-Condition ($outcome.state -ceq 'REPAIR_REQUIRED') "Repeated setup did not remain fail-closed" - Assert-Condition ($script:vendorHandoffCount -eq 1) "Repeat setup incorrectly relaunched uncertain vendor installer" + Assert-Condition ($global:ArSonMixTestVendorHandoffCount -eq 1) "Repeat setup incorrectly relaunched uncertain vendor installer" } finally { $env:APPDATA=$originalAppData + Remove-Variable -Name ArSonMixTestVendorHandoffCount -Scope Global -ErrorAction SilentlyContinue } Write-Host 'VBCABLE_SMART_DETECTION_PASS' } From d5af909a18bb3a346104fe0bf1e663739ab0312e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 21 Nov 2026 04:16:49 +0700 Subject: [PATCH 5/5] test(installer): align source contract to cross-script vendor handoff probe --- tests/windows_installer_contract_test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/windows_installer_contract_test.mjs b/tests/windows_installer_contract_test.mjs index 7f97dcf4f..721fa469d 100644 --- a/tests/windows_installer_contract_test.mjs +++ b/tests/windows_installer_contract_test.mjs @@ -89,7 +89,7 @@ test('interactive Setup automatically checks for signed VB-CABLE while mixer lau assert.match(isolatedSmoke, /interrupted-uac-present/); assert.match(isolatedSmoke, /corrupt-status-but-healthy/); assert.match(isolatedSmoke, /cable-vendor-handoff/); - assert.match(isolatedSmoke, /vendorHandoffCount -eq 1/); + assert.match(isolatedSmoke, /ArSonMixTestVendorHandoffCount -eq 1/); assert.match(bootstrap, /if\(\$all.Count -gt 0\)\{[\s\S]*?\$present \| Where-Object[\s\S]*?Record "ALREADY_PRESENT"[\s\S]*?exit 0/); assert.ok(bootstrap.indexOf("previousState -eq 'PENDING_REBOOT'") < bootstrap.indexOf('Start-Process -FilePath $setups[0].FullName'),