param([Parameter(Mandatory=$true)][string]$Stage) $ErrorActionPreference = 'Stop' if ($Stage -notin @('before', 'after')) { throw 'Stage must be before or after' } $taskWorkspace = 'C:\Users\User\Documents\Git\ARCADIA-Studio\.local\scenario-layout-ytr83r-20260913' $taskOutput = Join-Path $PSScriptRoot "inputs-complete-$Stage.json" if (Test-Path -LiteralPath $taskOutput) { throw "Refusing to replace $taskOutput" } Push-Location -LiteralPath $taskWorkspace try { $taskPaths = @('Cargo.toml', 'Cargo.lock') + @(rg --files crates docs examples build harness/fixtures harness/experiments/textual-authoring-20260911) if ($LASTEXITCODE -ne 0) { throw 'Input enumeration failed' } $taskEntries = @($taskPaths | Sort-Object -Unique | ForEach-Object { $taskItem = Get-Item -LiteralPath $_ [ordered]@{ path = $_.Replace('\', '/'); bytes = $taskItem.Length; sha256 = (Get-FileHash -Algorithm SHA256 -LiteralPath $_).Hash.ToLowerInvariant() } }) $taskRecord = [ordered]@{ capturedUtc = [DateTime]::UtcNow.ToString('o') workspace = $taskWorkspace base = (git rev-parse HEAD) branch = (git branch --show-current) count = $taskEntries.Count files = $taskEntries } $taskRecord | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath $taskOutput -Encoding utf8 if ($Stage -eq 'after') { $taskBefore = Get-Content -Raw -LiteralPath (Join-Path $PSScriptRoot 'inputs-complete-before.json') | ConvertFrom-Json $taskDifferences = @(Compare-Object ($taskBefore.files | ConvertTo-Json -Depth 5 -Compress) ($taskEntries | ConvertTo-Json -Depth 5 -Compress)) if ($taskDifferences.Count) { throw 'Verification inputs changed during gates' } } Write-Output "Captured $($taskEntries.Count) inputs: $Stage" } finally { Pop-Location }