Files
ARCADIA-Studio/harness/experiments/contextual-source-native-20260911/method/launch-contextual-source-v1.ps1
T

33 lines
2.6 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$stageRepo = 'C:\Users\User\Documents\Git\ARCADIA-Studio'
$stageRoot = Join-Path $stageRepo '.local/native-qa/contextual-source-20260911-v1'
$stageInputs = Join-Path $stageRepo '.local/contextual-source-20260911'
if (Test-Path -LiteralPath $stageRoot) { throw 'Native stage already exists.' }
if (Get-Process -Name arcadia-studio -ErrorAction SilentlyContinue) { throw 'Another Studio process exists.' }
$sourceManifest = Get-Content -Raw -LiteralPath (Join-Path $stageInputs 'focused5-inputs.json') | ConvertFrom-Json
foreach ($entry in $sourceManifest.inputs) {
if ((Get-FileHash -Algorithm SHA256 -LiteralPath (Join-Path $stageRepo $entry.path)).Hash -ne $entry.sha256) { throw "Frozen input differs: $($entry.path)" }
}
$guiManifest = Get-Content -Raw -LiteralPath (Join-Path $stageInputs 'gui-verified/manifest.json') | ConvertFrom-Json
foreach ($entry in $guiManifest.artifacts) {
if ((Get-FileHash -Algorithm SHA256 -LiteralPath (Join-Path $stageInputs "gui-verified/$($entry.file)")).Hash -ne $entry.sha256) { throw "GUI artifact differs: $($entry.file)" }
}
New-Item -ItemType Directory -Path "$stageRoot/bin", "$stageRoot/profile/local", "$stageRoot/profile/roaming" | Out-Null
foreach ($entry in $guiManifest.artifacts) { Copy-Item -LiteralPath (Join-Path $stageInputs "gui-verified/$($entry.file)") -Destination "$stageRoot/bin" }
Copy-Item -LiteralPath (Join-Path $stageRepo 'harness/fixtures/staged-source-authoring/base') -Destination "$stageRoot/work" -Recurse
$originalPath = $env:PATH
$originalAppData = $env:APPDATA
$originalLocalAppData = $env:LOCALAPPDATA
try {
$env:PATH = "$stageRoot/bin;$env:SystemRoot\System32;$env:SystemRoot"
$env:APPDATA = "$stageRoot/profile/roaming"
$env:LOCALAPPDATA = "$stageRoot/profile/local"
$guiProcess = Start-Process -FilePath "$stageRoot/bin/arcadia-studio.exe" -WorkingDirectory "$stageRoot/bin" -WindowStyle Hidden -PassThru -RedirectStandardOutput "$stageRoot/stdout.log" -RedirectStandardError "$stageRoot/stderr.log"
[pscustomobject]@{ pid=$guiProcess.Id; startedUtc=[DateTimeOffset]::UtcNow.ToString('o'); sourceManifest="$stageInputs/focused5-inputs.json"; artifacts=$guiManifest.artifacts; executable="$stageRoot/bin/arcadia-studio.exe"; appData=$env:APPDATA; localAppData=$env:LOCALAPPDATA; runtimePath=$env:PATH; baseline=(Get-ChildItem -LiteralPath "$stageRoot/work" -File | Get-FileHash -Algorithm SHA256 | Select-Object Path,Hash) } | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath "$stageRoot/launch.json"
$guiProcess | Select-Object Id, ProcessName
} finally {
$env:PATH=$originalPath
$env:APPDATA=$originalAppData
$env:LOCALAPPDATA=$originalLocalAppData
}