param([ValidateSet('list','focused','all','clippy')][string]$Stage) $ErrorActionPreference='Stop' $taskWorkspace='C:\Users\User\Documents\Git\ARCADIA-Studio\.local\scenario-layout-ytr83r-20260913' Push-Location -LiteralPath $taskWorkspace try { . 'C:\Users\User\Documents\Git\ARCADIA-Studio\.local\toolchain\env.ps1' $env:CARGO_TARGET_DIR='C:\Users\User\Documents\Git\ARCADIA-Studio\.local\scenario-core-target-20260913' $taskArgs=switch($Stage){ 'list' { @('test','-p','oa-core','--lib','--locked','--offline','--','--list') } 'focused' { @('test','-p','oa-core','--lib','--locked','--offline','--','scenario_layout','--nocapture','--test-threads=1') } 'all' { @('test','-p','oa-core','--all-targets','--locked','--offline') } 'clippy' { @('clippy','-p','oa-core','--all-targets','--locked','--offline','--','-D','warnings') } } $taskLog=Join-Path $PSScriptRoot ($Stage+'.log') $taskReceipt=Join-Path $PSScriptRoot ($Stage+'-receipt.json') if((Test-Path -LiteralPath $taskLog) -or (Test-Path -LiteralPath $taskReceipt)){throw 'Preserve previous gate; choose a new output directory'} $taskBase=git rev-parse HEAD $taskStart=[DateTime]::UtcNow.ToString('o') & cargo @taskArgs 2>&1 | Tee-Object -FilePath $taskLog $taskExit=$LASTEXITCODE $taskText=Get-Content -Raw -LiteralPath $taskLog $taskSelection=$true $taskCount=$null if($Stage -eq 'list'){ $taskCount=[regex]::Matches($taskText,'(?m)^[^\r\n]*scenario_layout[^\r\n]+: test\r?$').Count $taskSelection=$taskCount -eq 26 } if($Stage -eq 'focused'){ $taskSelection=$taskText -match 'test result: ok\. 26 passed; 0 failed; 0 ignored;' } [ordered]@{command=('cargo '+($taskArgs -join ' '));base=$taskBase;workspace=$taskWorkspace;target=$env:CARGO_TARGET_DIR;startUtc=$taskStart;endUtc=[DateTime]::UtcNow.ToString('o');cargoExitCode=$taskExit;selectedTests=$taskCount;selectionValid=$taskSelection}|ConvertTo-Json|Set-Content -LiteralPath $taskReceipt -Encoding utf8 if($taskExit -ne 0){exit $taskExit} if(-not $taskSelection){throw 'Test membership/result does not match 26 new model/reference/source lifecycle cases'} }finally{Pop-Location}