#Requires -Version 7.0 Set-StrictMode -Version Latest $ErrorActionPreference='Stop' $PSNativeCommandUseErrorActionPreference=$false $taskWorkspace='C:\Users\User\Documents\Git\ARCADIA-Studio\.local\scenario-spacing-ytr83r-20260913' $taskTarget='C:\Users\User\Documents\Git\ARCADIA-Studio\target' $taskPin='5d4a6a47ce1085b818498bb281a41c3bc6a83847' $toolchainEnv='C:\Users\User\Documents\Git\ARCADIA-Studio\.local\toolchain\env.ps1' function Hash-Input([string]$Path){(Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash.ToLowerInvariant()} $log=Join-Path $PSScriptRoot 'strict-preflight.log' $receipt=Join-Path $PSScriptRoot 'strict-preflight-receipt.json' $versionPath=Join-Path $PSScriptRoot 'toolchain-versions.json' foreach($p in @($log,$receipt,$versionPath)){if(Test-Path -LiteralPath $p){throw 'Preserve existing evidence; use a new directory for retries.'}} $cache=Get-Content -Raw -LiteralPath (Join-Path $PSScriptRoot 'cache-policy.json')|ConvertFrom-Json if($cache.base -cne $taskPin -or -not $cache.retainExistingTarget -or $cache.cleanRequested -or $cache.target -ine $taskTarget){throw 'Wrong reviewed cache policy'} # This standalone preflight deliberately has no test-executable dependency. & (Join-Path $PSScriptRoot 'capture.ps1') -Stage before $bound=@{} foreach($name in @('strict-preflight.ps1','capture.ps1','expected-inputs.json','enumeration.json','external-inputs.json','cache-policy.json','inputs-complete-before.json')){$bound[$name]=Hash-Input (Join-Path $PSScriptRoot $name)} Push-Location -LiteralPath $taskWorkspace try { & (Join-Path $PSScriptRoot 'capture.ps1') -Stage strict-preflight-before . $toolchainEnv $env:CARGO_TARGET_DIR=$taskTarget $env:CARGO_TERM_COLOR='never' $PSNativeCommandUseErrorActionPreference=$false $cargoVersion=@(& cargo --version --verbose 2>&1);$cargoVersionExit=$LASTEXITCODE $rustcVersion=@(& rustc --version --verbose 2>&1);$rustcVersionExit=$LASTEXITCODE $clippyVersion=@(& cargo clippy --version 2>&1);$clippyVersionExit=$LASTEXITCODE $clangVersion=@(& clang --version 2>&1);$clangVersionExit=$LASTEXITCODE [ordered]@{base=$taskPin;capturedUtc=[DateTime]::UtcNow.ToString('o');externalEnvironmentPath=$toolchainEnv;externalEnvironmentSha256=(Hash-Input $toolchainEnv);cargo=@($cargoVersion|ForEach-Object {$_.ToString()});cargoExitCode=$cargoVersionExit;rustc=@($rustcVersion|ForEach-Object {$_.ToString()});rustcExitCode=$rustcVersionExit;clippy=@($clippyVersion|ForEach-Object {$_.ToString()});clippyExitCode=$clippyVersionExit;clang=@($clangVersion|ForEach-Object {$_.ToString()});clangExitCode=$clangVersionExit;cargoPath=(Get-Command cargo).Source;rustcPath=(Get-Command rustc).Source;clangPath=(Get-Command clang).Source;cargoHome=$env:CARGO_HOME;rustupHome=$env:RUSTUP_HOME;rustupToolchain=$env:RUSTUP_TOOLCHAIN;buildJobs=$env:CARGO_BUILD_JOBS;incremental=$env:CARGO_INCREMENTAL}|ConvertTo-Json -Depth 8|Set-Content -LiteralPath $versionPath -Encoding utf8 if($cargoVersionExit -ne 0 -or $rustcVersionExit -ne 0 -or $clippyVersionExit -ne 0 -or $clangVersionExit -ne 0){throw 'Toolchain version query failed.'} $versionsHash=Hash-Input $versionPath $envHash=Hash-Input $toolchainEnv $args=@('clippy','-p','oa-desktop','-p','oa-server','--all-targets','--locked','--offline','--','-D','warnings') $start=[DateTime]::UtcNow.ToString('o');$cargoExit=-1;$failure=$null try{& cargo @args 2>&1|Tee-Object -FilePath $log;$cargoExit=$LASTEXITCODE}catch{$failure=$_.Exception.Message;if(-not(Test-Path -LiteralPath $log)){[IO.File]::WriteAllText($log,$failure)}} $end=[DateTime]::UtcNow.ToString('o');$unchanged=$false try{ & (Join-Path $PSScriptRoot 'capture.ps1') -Stage strict-preflight-after foreach($name in $bound.Keys){if((Hash-Input (Join-Path $PSScriptRoot $name)) -cne $bound[$name]){throw ('Recipe/input changed: '+$name)}} if((Hash-Input $versionPath) -cne $versionsHash -or (Hash-Input $toolchainEnv) -cne $envHash){throw 'Toolchain binding changed'} $unchanged=$true }catch{$failure=$_.Exception.Message} $after=Join-Path $PSScriptRoot 'inputs-complete-strict-preflight-after.json' [ordered]@{schema='scenario_strict_preflight_v1';stage='strict-preflight';base=$taskPin;workspace=$taskWorkspace;target=$taskTarget;command=('cargo '+($args -join ' '));arguments=$args;startUtc=$start;endUtc=$end;cargoExitCode=$cargoExit;inputsUnchanged=$unchanged;postflightFailure=$failure;passed=($cargoExit -eq 0 -and $unchanged -and $null -eq $failure);boundScriptAndInputHashes=$bound;externalEnvironmentPath=$toolchainEnv;externalEnvironmentSha256=$envHash;toolchainVersionsSha256=$versionsHash;rawLogSha256=(Hash-Input $log);beforeCaptureSha256=(Hash-Input (Join-Path $PSScriptRoot 'inputs-complete-strict-preflight-before.json'));afterCaptureSha256=if(Test-Path -LiteralPath $after){Hash-Input $after}else{$null};scope='Strict desktop/server all-targets preflight only; no desktop listing, test execution, GUI build, or test-executable acceptance.'}|ConvertTo-Json -Depth 10|Set-Content -LiteralPath $receipt -Encoding utf8 if($cargoExit -ne 0){exit $cargoExit} if(-not $unchanged -or $null -ne $failure){throw 'Preflight binding failed; inspect receipt.'} }finally{Pop-Location}