|
| 1 | +param( |
| 2 | + [string]$FixturePath, |
| 3 | + [string]$StageAnchorContractPath, |
| 4 | + [string]$LogPath |
| 5 | +) |
| 6 | + |
| 7 | +$projectRoot= (Resolve-Path (Join-Path$PSScriptRoot'..\..')).Path |
| 8 | +$sampleDir=Join-Path$projectRoot'05_NUMBERS/test_outputs/samples' |
| 9 | +$canonicalRoot=Join-Path$projectRoot'05_NUMBERS/test_outputs/canonical' |
| 10 | +$packetRoot=Join-Path$projectRoot'05_NUMBERS/test_outputs/packets' |
| 11 | + |
| 12 | +if (-not$FixturePath) { |
| 13 | +$FixturePath=Join-Path$PSScriptRoot'sample_project_fixture.json' |
| 14 | +} |
| 15 | +if (-not$StageAnchorContractPath) { |
| 16 | +$StageAnchorContractPath=Join-Path$PSScriptRoot'stage_anchor_contract.json' |
| 17 | +} |
| 18 | +if (-not$LogPath) { |
| 19 | +$LogPath=Join-Path$projectRoot'05_NUMBERS/test_outputs/validation_harness.log' |
| 20 | +} |
| 21 | + |
| 22 | +New-Item-ItemType Directory -Force -Path $sampleDir,$canonicalRoot,$packetRoot|Out-Null |
| 23 | + |
| 24 | +$fixture=Get-Content-LiteralPath $FixturePath-Raw |ConvertFrom-Json |
| 25 | +$contract=Get-Content-LiteralPath $StageAnchorContractPath-Raw |ConvertFrom-Json |
| 26 | + |
| 27 | +if ($fixture.documents.Count-lt2) { |
| 28 | +throw'Fixture must define at least two documents.' |
| 29 | +} |
| 30 | + |
| 31 | +$docAPath=Join-Path$sampleDir$fixture.documents[0].name |
| 32 | +$docBPath=Join-Path$sampleDir$fixture.documents[1].name |
| 33 | +$fixture.documents[0].content |Set-Content-LiteralPath $docAPath-Encoding utf8 |
| 34 | +$fixture.documents[1].content |Set-Content-LiteralPath $docBPath-Encoding utf8 |
| 35 | + |
| 36 | +$registerScript=Join-Path$projectRoot'02_EXODUS/runtime/intake/register_sources.ps1' |
| 37 | +$canonicalScript=Join-Path$projectRoot'02_EXODUS/runtime/canonicalize/canonicalize_sources.ps1' |
| 38 | +$extractScript=Join-Path$projectRoot'02_EXODUS/runtime/extract/extract_statements.ps1' |
| 39 | +$traceScript=Join-Path$projectRoot'02_EXODUS/runtime/trace/build_trace_links.ps1' |
| 40 | +$discrepancyScript=Join-Path$projectRoot'02_EXODUS/runtime/discrepancy/detect_discrepancies.ps1' |
| 41 | +$queueScript=Join-Path$projectRoot'02_EXODUS/runtime/review/rebuild_review_queue.ps1' |
| 42 | +$packetScript=Join-Path$projectRoot'02_EXODUS/runtime/export/export_review_packet.ps1' |
| 43 | +$manifestScript=Join-Path$projectRoot'02_EXODUS/runtime/state/write_run_manifest.ps1' |
| 44 | +$surfaceScript=Join-Path$projectRoot'02_EXODUS/runtime/review/start_review_surface.ps1' |
| 45 | + |
| 46 | +$registrationOut=Join-Path$sampleDir'validation_registration.json' |
| 47 | +$canonicalMetaOut=Join-Path$sampleDir'validation_canonical_meta.json' |
| 48 | +$extractionOut=Join-Path$sampleDir'validation_extraction_record.json' |
| 49 | +$traceOut=Join-Path$sampleDir'validation_trace_record.json' |
| 50 | +$discrepancyOut=Join-Path$sampleDir'validation_discrepancy_record.json' |
| 51 | +$queueOut=Join-Path$sampleDir'validation_review_queue_index.json' |
| 52 | +$stateIndexOut=Join-Path$sampleDir'validation_project_state_index.json' |
| 53 | +$manifestOut=Join-Path$sampleDir'validation_packet_manifest.json' |
| 54 | +$runManifestOut=Join-Path$sampleDir'validation_run_manifest.json' |
| 55 | +$reviewStateOut=Join-Path$sampleDir'validation_review_surface_state.json' |
| 56 | + |
| 57 | +& powershell -ExecutionPolicy Bypass -File $registerScript-InputPath $docAPath-RegistrationOut $registrationOut|Out-Null |
| 58 | +if ($LASTEXITCODE-ne0) { throw'register_sources failed in validation harness' } |
| 59 | + |
| 60 | +& powershell -ExecutionPolicy Bypass -File $canonicalScript-RegistrationPath $registrationOut-CanonicalRoot $canonicalRoot-CanonicalMetaOut $canonicalMetaOut|Out-Null |
| 61 | +if ($LASTEXITCODE-ne0) { throw'canonicalize_sources failed in validation harness' } |
| 62 | + |
| 63 | +& powershell -ExecutionPolicy Bypass -File $extractScript-CanonicalMetaPath $canonicalMetaOut-ExtractionOut $extractionOut|Out-Null |
| 64 | +if ($LASTEXITCODE-ne0) { throw'extract_statements failed in validation harness' } |
| 65 | + |
| 66 | +& powershell -ExecutionPolicy Bypass -File $traceScript-ExtractionRecordPath $extractionOut-TraceOut $traceOut|Out-Null |
| 67 | +if ($LASTEXITCODE-ne0) { throw'build_trace_links failed in validation harness' } |
| 68 | + |
| 69 | +& powershell -ExecutionPolicy Bypass -File $discrepancyScript-ExtractionRecordPath $extractionOut-TraceRecordPath $traceOut-DiscrepancyOut $discrepancyOut|Out-Null |
| 70 | +if ($LASTEXITCODE-ne0) { throw'detect_discrepancies failed in validation harness' } |
| 71 | + |
| 72 | +& powershell -ExecutionPolicy Bypass -File $queueScript-DiscrepancyRecordPath $discrepancyOut-QueueOut $queueOut-StateIndexOut $stateIndexOut|Out-Null |
| 73 | +if ($LASTEXITCODE-ne0) { throw'rebuild_review_queue failed in validation harness' } |
| 74 | + |
| 75 | +& powershell -ExecutionPolicy Bypass -File $packetScript-DiscrepancyRecordPath $discrepancyOut-TraceRecordPath $traceOut-PacketRoot $packetRoot-ManifestOut $manifestOut|Out-Null |
| 76 | +if ($LASTEXITCODE-ne0) { throw'export_review_packet failed in validation harness' } |
| 77 | + |
| 78 | +& powershell -ExecutionPolicy Bypass -File $manifestScript-QueueIndexPath $queueOut-ManifestOut $manifestOut-RunManifestOut $runManifestOut|Out-Null |
| 79 | +if ($LASTEXITCODE-ne0) { throw'write_run_manifest failed in validation harness' } |
| 80 | + |
| 81 | +$surfaceOutput=& powershell -ExecutionPolicy Bypass -File $surfaceScript-QueueIndexPath $queueOut-PacketManifestPath $manifestOut-ReviewStateOut $reviewStateOut-LogPath $LogPath |
| 82 | +if ($LASTEXITCODE-ne0) { throw'start_review_surface failed in validation harness' } |
| 83 | + |
| 84 | +$addressRules=Get-Content-LiteralPath (Join-Path$projectRoot'02_EXODUS/runtime/canonicalize/addressing_rules.json') -Raw |ConvertFrom-Json |
| 85 | +$addressAnchor=$addressRules.anchor |
| 86 | + |
| 87 | +if (-not ($surfaceOutput-match'machine_proposed')) { throw'machine_proposed missing' } |
| 88 | +if (-not ($surfaceOutput-match'human_accepted')) { throw'human_accepted missing' } |
| 89 | + |
| 90 | +$output=@( |
| 91 | +'FILESYSTEM_AUTHORITY_READY', |
| 92 | +$addressAnchor, |
| 93 | +'machine_proposed', |
| 94 | +'human_accepted', |
| 95 | +'ARGUS_TRACE_VALIDATION_PASS' |
| 96 | +) |
| 97 | + |
| 98 | +foreach ($requiredin$contract.required_anchors) { |
| 99 | +if ($output-notcontains$required) { |
| 100 | +throw"Required stage anchor missing: $required" |
| 101 | + } |
| 102 | +} |
| 103 | + |
| 104 | +$output|Set-Content-LiteralPath $LogPath-Encoding utf8 |
| 105 | +$output|Write-Output |
0 commit comments