66 lines
6.2 KiB
PowerShell
66 lines
6.2 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
$taskRoot = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot '../..')).Path
|
|
Set-Location -LiteralPath $taskRoot
|
|
$outDir = Join-Path $PSScriptRoot 'strong-preflight-d61-r1'
|
|
if (Test-Path -LiteralPath $outDir) { throw 'Refuse existing receipt directory' }
|
|
New-Item -ItemType Directory -Path $outDir | Out-Null
|
|
function Sha([string]$path) { (Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash.ToLowerInvariant() }
|
|
function Identity([string]$path) { [ordered]@{ path=$path; bytes=(Get-Item -LiteralPath $path).Length; sha256=(Sha $path) } }
|
|
$gateRoot = Join-Path $taskRoot '.local/allocation-union-20260912'
|
|
$closed = Get-Content -LiteralPath (Join-Path $gateRoot 'full-d61f1f3.result.json') -Raw | ConvertFrom-Json
|
|
if ($closed.source -ne 'd61f1f38779ab70a77efcde523ae31c432aefcfd' -or $closed.exit -ne 0 -or $closed.changed_inputs.Count -ne 0) { throw 'd61 full gate is not closed cleanly' }
|
|
$manifest = Get-Content -LiteralPath (Join-Path $gateRoot $closed.inputs) -Raw | ConvertFrom-Json
|
|
$oldManifest = Get-Content -LiteralPath (Join-Path $gateRoot 'full-42511f0.inputs.json') -Raw | ConvertFrom-Json
|
|
$scoped = @($manifest.inputs | Where-Object { $_.path.StartsWith('crates/oa-core/') -or $_.path.StartsWith('.cargo/') -or $_.path -in @('Cargo.toml','Cargo.lock','rust-toolchain.toml') })
|
|
$verified = foreach ($item in $scoped) {
|
|
$actual = Sha (Join-Path $taskRoot $item.path)
|
|
$prior = @($oldManifest.inputs | Where-Object path -EQ $item.path)
|
|
if ($actual -ne $item.sha256 -or $prior.Count -ne 1 -or $prior[0].sha256 -ne $actual) { throw "Core/config input identity mismatch: $($item.path)" }
|
|
$item
|
|
}
|
|
$sourceScopes = @('crates/oa-core', '.cargo', 'Cargo.toml', 'Cargo.lock', 'rust-toolchain.toml')
|
|
$committedChanges = & git diff --name-only $closed.source HEAD -- @sourceScopes
|
|
if ($LASTEXITCODE -ne 0 -or $committedChanges) { throw 'Current committed core/config differs from closed d61' }
|
|
$workChanges = & git status --porcelain --untracked-files=all -- @sourceScopes
|
|
if ($LASTEXITCODE -ne 0 -or $workChanges) { throw 'Current core/config contains local changes' }
|
|
$head = (& git rev-parse HEAD).Trim()
|
|
$priorBuildPath = Join-Path $taskRoot '.local/native-qa/delete-oracle-warning-fix-42511f0/build.json'
|
|
$priorBuild = Get-Content -LiteralPath $priorBuildPath -Raw | ConvertFrom-Json
|
|
$corePath = Join-Path $taskRoot 'target/debug/deps/liboa_core-145180297aa692e4.rlib'
|
|
$coreRecord = @($priorBuild.files | Where-Object { $_.path -like '*liboa_core-145180297aa692e4.rlib' })
|
|
if ($coreRecord.Count -ne 1 -or (Sha $corePath) -ne $coreRecord[0].sha256 -or $coreRecord[0].sha256 -ne 'd395dbe1f761d41bce3cb850f44cdc0343b0db172bd03abf89e455c44f4b7e86') { throw 'Exact prior core rlib identity mismatch' }
|
|
$probe = Join-Path $PSScriptRoot 'preflight.rs'
|
|
$fixture = Join-Path $PSScriptRoot 'lifecycle-native.arcadia'
|
|
if ((Sha $probe) -ne 'bf2eb9b908ae36198d15d47ae79d56e4bb181f506598cc4e76a76175041f633e') { throw 'Prepared probe changed' }
|
|
if ((Sha $fixture) -ne '998a2fd3e2474e72fc013f4da422e49bad61e118de62eccfbd71bf06b863ce7f') { throw 'Prepared fixture changed' }
|
|
$rustBin = Join-Path $taskRoot '.local/toolchain/rustup/toolchains/stable-x86_64-pc-windows-gnullvm/bin'
|
|
$runtimeBin = Join-Path $taskRoot '.local/toolchain/llvm-mingw-20260908-ucrt-x86_64/bin'
|
|
$rustc = Join-Path $rustBin 'rustc.exe'
|
|
$linker = Join-Path $runtimeBin 'clang.exe'
|
|
$env:PATH = $runtimeBin + ';' + $rustBin + ';' + $env:PATH
|
|
Copy-Item -LiteralPath $probe -Destination (Join-Path $outDir 'preflight-source.rs')
|
|
Copy-Item -LiteralPath $fixture -Destination (Join-Path $outDir 'fixture-source.arcadia.txt')
|
|
Copy-Item -LiteralPath (Join-Path $gateRoot 'full-d61f1f3.result.json') -Destination (Join-Path $outDir 'closed-full-d61-result.json')
|
|
Copy-Item -LiteralPath $priorBuildPath -Destination (Join-Path $outDir 'prior-core-build.json')
|
|
Copy-Item -LiteralPath $PSCommandPath -Destination (Join-Path $outDir 'run-driver.ps1')
|
|
$verified | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath (Join-Path $outDir 'verified-core-config-inputs.json') -Encoding utf8
|
|
$binary = Join-Path $outDir 'lifecycle-preflight.exe'
|
|
$arguments = @('--edition=2024','-D','warnings','-C',('linker=' + $linker),'-L',('dependency=' + (Join-Path $taskRoot 'target/debug/deps')),'--extern',('oa_core=' + $corePath),$probe,'-o',$binary)
|
|
$start = [DateTimeOffset]::UtcNow.ToString('o')
|
|
& $rustc @arguments 1> (Join-Path $outDir 'build.stdout.log') 2> (Join-Path $outDir 'build.stderr.log')
|
|
$buildExit = $LASTEXITCODE
|
|
$files = @((Identity $probe),(Identity $fixture),(Identity $corePath),(Identity $rustc),(Identity $linker),(Identity (Join-Path $runtimeBin 'libunwind.dll')),(Identity (Join-Path $gateRoot $closed.inputs)),(Identity $priorBuildPath))
|
|
if (Test-Path -LiteralPath $binary) { $files += (Identity $binary) }
|
|
$build = [ordered]@{ scope='Compile prepared fixture preflight only; no core rebuild. Exact prior 42511f0 rlib retained; 110 core/config/lock files match closed d61 full gate and current committed bytes.'; full_gate_source=$closed.source; current_head=$head; verified_input_count=$verified.Count; start=$start; end=[DateTimeOffset]::UtcNow.ToString('o'); command=@($rustc)+$arguments; exit=$buildExit; files=$files; path_prefixes=@($runtimeBin,$rustBin) }
|
|
$build | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath (Join-Path $outDir 'build.json') -Encoding utf8
|
|
if ($buildExit -ne 0) { Get-Content -LiteralPath (Join-Path $outDir 'build.stderr.log'); exit $buildExit }
|
|
$runStart = [DateTimeOffset]::UtcNow.ToString('o')
|
|
& $binary $fixture 1> (Join-Path $outDir 'run.stdout.log') 2> (Join-Path $outDir 'run.stderr.log')
|
|
$runExit = $LASTEXITCODE
|
|
$run = [ordered]@{ start=$runStart; end=[DateTimeOffset]::UtcNow.ToString('o'); command=@($binary,$fixture); exit=$runExit; binary_sha256=(Sha $binary); probe_sha256=(Sha $probe); fixture_sha256_after=(Sha $fixture); stdout_sha256=(Sha (Join-Path $outDir 'run.stdout.log')); stderr_sha256=(Sha (Join-Path $outDir 'run.stderr.log')); core_rlib_sha256_after=(Sha $corePath) }
|
|
$run | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath (Join-Path $outDir 'run.json') -Encoding utf8
|
|
$run | ConvertTo-Json -Depth 5
|
|
Get-Content -LiteralPath (Join-Path $outDir 'run.stdout.log')
|
|
Get-Content -LiteralPath (Join-Path $outDir 'run.stderr.log')
|
|
exit $runExit
|