74 lines
5.6 KiB
PowerShell
74 lines
5.6 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
$taskRoot = (Resolve-Path (Join-Path $PSScriptRoot '../..')).Path
|
|
$qaRoot = Join-Path $taskRoot 'storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742'
|
|
$prepared = Join-Path $qaRoot 'public/build-line07-submit-feedback-prepared-20261015'
|
|
$build = Join-Path $qaRoot 'public/build'
|
|
$before = Join-Path $PSScriptRoot 'line07-submit-feedback-before-20261015'
|
|
$receiptPath = Join-Path $PSScriptRoot 'line07-submit-feedback-QA-20261015.json'
|
|
if (Test-Path -LiteralPath $receiptPath) { throw 'Preserve existing receipt.' }
|
|
if (-not (Test-Path -LiteralPath (Join-Path $prepared 'manifest.json'))) { throw 'Prepared manifest missing.' }
|
|
$hash = { param($path) (Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash }
|
|
$protected = Get-Content -LiteralPath (Join-Path $before 'active-protected-hashes.json') -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
foreach ($entry in $protected.PSObject.Properties) {
|
|
if ((& $hash (Join-Path $taskRoot $entry.Name)) -cne $entry.Value) { throw "Protected file changed: $($entry.Name)" }
|
|
}
|
|
$oldManifestHash = & $hash (Join-Path $before 'manifest.json')
|
|
if ((& $hash (Join-Path $build 'manifest.json')) -cne $oldManifestHash) { throw 'QA manifest changed during preparation.' }
|
|
$oldSource = Get-Content -LiteralPath (Join-Path $before 'business-wizard.tsx') -Raw -Encoding UTF8
|
|
$newSourcePath = Join-Path $qaRoot 'resources/js/pages/investment/business-wizard.tsx'
|
|
$newSource = Get-Content -LiteralPath $newSourcePath -Raw -Encoding UTF8
|
|
$guardPattern = '(?s)disabled=\{\s*busy\s*\|\|\s*!consent\s*\|\|\s*confirmation !== record.code\s*\|\|.*?\}\s*onClick=\{\(\) => void submit\(\)\}'
|
|
$oldGuard = [regex]::Match($oldSource, $guardPattern).Value
|
|
$newGuard = [regex]::Match($newSource, $guardPattern).Value
|
|
if (-not $oldGuard -or $oldGuard -cne $newGuard) { throw 'Submission guard changed.' }
|
|
$preparedFiles = @(Get-ChildItem -LiteralPath $prepared -Recurse -File)
|
|
$copies = @()
|
|
foreach ($file in $preparedFiles) {
|
|
$relative = $file.FullName.Substring($prepared.Length + 1)
|
|
if ($relative -eq 'manifest.json') { continue }
|
|
$destination = Join-Path $build $relative
|
|
if (Test-Path -LiteralPath $destination) {
|
|
if ((& $hash $destination) -cne (& $hash $file.FullName)) { throw "Immutable asset conflict: $relative" }
|
|
} else { $copies += @{source=$file.FullName; destination=$destination} }
|
|
}
|
|
$businessChunks = @(Get-ChildItem -LiteralPath (Join-Path $prepared 'assets') -File -Filter 'business-wizard-*.js')
|
|
if ($businessChunks.Count -ne 1 -or -not (Select-String -LiteralPath $businessChunks[0].FullName -SimpleMatch 'Para disponibilizar o botão de submissão:' -Quiet)) { throw 'Feedback missing from compiled wizard.' }
|
|
foreach ($copy in $copies) {
|
|
$parent = Split-Path -Parent $copy.destination
|
|
if (-not (Test-Path -LiteralPath $parent)) { New-Item -ItemType Directory -Path $parent | Out-Null }
|
|
Copy-Item -LiteralPath $copy.source -Destination $copy.destination
|
|
}
|
|
$pendingManifest = Join-Path $build 'manifest.line07-submit-feedback.pending'
|
|
if (Test-Path -LiteralPath $pendingManifest) { throw 'Preserve pending manifest.' }
|
|
Copy-Item -LiteralPath (Join-Path $prepared 'manifest.json') -Destination $pendingManifest
|
|
$previousManifest = Join-Path $build 'manifest.line07-submit-feedback.previous'
|
|
if (Test-Path -LiteralPath $previousManifest) { throw 'Preserve previous manifest.' }
|
|
foreach ($manifestPath in @($pendingManifest, (Join-Path $build 'manifest.json'), $previousManifest)) {
|
|
if (-not ([IO.Path]::GetFullPath($manifestPath).StartsWith([IO.Path]::GetFullPath($build) + [IO.Path]::DirectorySeparatorChar))) { throw 'QA manifest path guard failed.' }
|
|
}
|
|
[IO.File]::Replace($pendingManifest, (Join-Path $build 'manifest.json'), $previousManifest)
|
|
foreach ($entry in $protected.PSObject.Properties) {
|
|
if ((& $hash (Join-Path $taskRoot $entry.Name)) -cne $entry.Value) { throw "Protected file changed: $($entry.Name)" }
|
|
}
|
|
Copy-Item -LiteralPath $newSourcePath -Destination (Join-Path $PSScriptRoot 'line07-submit-feedback-QA-business-wizard-20261015.tsx')
|
|
$receipt = [ordered]@{
|
|
recorded_at_UTC=[DateTime]::UtcNow.ToString('o'); base_review='396c691930bc';
|
|
scope='QA only: explain why the existing submission button is disabled; guards unchanged';
|
|
source_file='resources/js/pages/investment/business-wizard.tsx';
|
|
old_QA_source_sha256=(& $hash (Join-Path $before 'business-wizard.tsx'));
|
|
new_QA_source_sha256=(& $hash $newSourcePath);
|
|
old_QA_manifest_sha256=$oldManifestHash;
|
|
new_QA_manifest_sha256=(& $hash (Join-Path $build 'manifest.json'));
|
|
prepared_assets=$preparedFiles.Count; old_assets_preserved=$true; atomic_QA_manifest_switch=$true;
|
|
backup_source_and_manifest_verified=$true;
|
|
type_check_exit=0; prepared_build_exit=0; compiled_feedback_present=$true;
|
|
original_disabled_guard_unchanged=$true; server_submission_and_authorization_unchanged=$true;
|
|
browser_inventory=@{apps=0; browsers=0}; live_browser_reason_not_observed=$true;
|
|
root_source_bundle_and_matrix_unchanged=$true; QA_database_changes=0; active_changes=0;
|
|
submission_executed_by_agent=$false; visual_acceptance_complete=$false; final_candidate=$false;
|
|
activation_authorized=$false;
|
|
reversal='Restore private-QA source and public/build/manifest.json from line07-submit-feedback-before-20261015; old chunks retained.'
|
|
}
|
|
[IO.File]::WriteAllText($receiptPath, ($receipt | ConvertTo-Json -Depth 8), [Text.UTF8Encoding]::new($false))
|
|
[pscustomobject]$receipt | Select-Object scope,type_check_exit,prepared_build_exit,compiled_feedback_present,root_source_bundle_and_matrix_unchanged,submission_executed_by_agent | ConvertTo-Json
|