$ErrorActionPreference = 'Stop' . ./.local/toolchain/env.ps1 $env:CARGO_BUILD_JOBS = '1' $evidenceRoot = Join-Path (Get-Location) '.local/text-navigation-integration-20260911' foreach ($gateName in @('outline1','core1','clippy1')) { $prior = Get-Content -Raw -LiteralPath (Join-Path $evidenceRoot "$gateName-status.json") | ConvertFrom-Json if ($prior.exitCode -ne 0) { throw "Required prior gate failed: $gateName" } } function Invoke-RecordedNative { param([string]$Name,[string]$Executable,[string[]]$Arguments) $stdout = Join-Path $evidenceRoot "$Name-stdout.log" $stderr = Join-Path $evidenceRoot "$Name-stderr.log" $status = Join-Path $evidenceRoot "$Name-status.json" if ((Test-Path $stdout) -or (Test-Path $stderr) -or (Test-Path $status)) { throw "Refusing overwrite $Name" } $started = [DateTime]::UtcNow.ToString('o') & $Executable @Arguments 1> $stdout 2> $stderr $code = $LASTEXITCODE [ordered]@{started=$started;finished=[DateTime]::UtcNow.ToString('o');exitCode=$code;executable=$Executable;args=$Arguments;buildJobs=1} | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath $status Get-Content -LiteralPath $stderr if ($Name -ne 'artifacts1') { Get-Content -LiteralPath $stdout } if ($code -ne 0) { exit $code } } $records = Get-Content -Raw -LiteralPath (Join-Path $evidenceRoot 'query-bindings.json') | ConvertFrom-Json $bindings = @{} $dependencyDirectories = @() foreach ($r in $records) { if ((Get-FileHash -LiteralPath $r.rlib).Hash -ne $r.sha256) { throw 'Bound artifact changed' } if ((Get-FileHash -LiteralPath $r.matchedDependencyRlib).Hash -ne $r.sha256) { throw 'Matched dependency artifact changed' } foreach ($fp in $r.fingerprints) { if ((Get-FileHash -LiteralPath $fp.original).Hash -ne $fp.sha256 -or (Get-FileHash -LiteralPath $fp.copy).Hash -ne $fp.sha256) { throw 'Bound fingerprint changed' } } $bindings[$r.crate] = $r.rlib $dependencyDirectories += Split-Path $r.matchedDependencyRlib } $uniqueDirectories = @($dependencyDirectories | Sort-Object -Unique) if ($uniqueDirectories.Count -ne 1) { throw 'Dependency directory mismatch' } $dependencies = $uniqueDirectories[0] $source = Join-Path $evidenceRoot 'source_symbols-v2-utf8.rs' if ((Get-FileHash -LiteralPath $source).Hash -ne '86666C8390F0C63EC75B045366494A80D0ECDE82924F2BAC312AFD01675AEE56') { throw 'Query source changed' } $binary = Join-Path $evidenceRoot 'source-symbols-v2-utf8-tests.exe' Invoke-RecordedNative 'query-compile2' 'rustc' @('--edition=2024','--crate-name','source_symbols_v2','--test','-Dwarnings','-C','linker=clang.exe',$source,'--extern',"oa_core=$($bindings['oa_core'])",'--extern',"serde_json=$($bindings['serde_json'])",'-L',"dependency=$dependencies",'-o',$binary) Invoke-RecordedNative 'query-tests2' $binary @('--test-threads=1') [ordered]@{sourceSha256=(Get-FileHash -LiteralPath $source).Hash;binarySha256=(Get-FileHash -LiteralPath $binary).Hash;binaryBytes=(Get-Item -LiteralPath $binary).Length} | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $evidenceRoot 'query-artifacts2.json')