Files
CM95/scripts/cm95_japan_v1_4_7_finalize_existing.ps1

154 lines
5.9 KiB
PowerShell

param(
[string]$ProjectRoot = "D:\React\cm93-mysql-importer-starter"
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
function Step([string]$Text) {
Write-Host ""
Write-Host "======================================================================"
Write-Host $Text
Write-Host "======================================================================"
}
function Run([string]$Label, [scriptblock]$Action) {
Step $Label
& $Action
$Code = $LASTEXITCODE
if ($null -ne $Code -and $Code -ne 0) {
throw "$Label FAILED (exit=$Code)"
}
}
Set-Location $ProjectRoot
$Python = ".\.venv\Scripts\python.exe"
$Cm95Pbf = ".\.venv\Scripts\cm95pbf.exe"
$Plan = ".\build\production\cm95_production_plan_japan_full_detail_v1_4_6.json"
$ReleaseRoot = ".\build\releases"
$Disposition = ".\config\mappings\cm95_gap_disposition_japan_dataset_1_v1.yaml"
$ExpectedPlanId = "6bc3c1352da347b77256c83d8ab3b771fcde151d70332e8d96c6e50605cb5d8f"
$ExpectedReleaseId = "cm95-d1-62a85bd40d3a-6bc3c1352da3"
$ExpectedBuilder = "cm95pbf-builder/0.4.6-spatial-candidate-query"
foreach ($Path in @($Python,$Cm95Pbf,$Plan,$Disposition)) {
if (-not (Test-Path $Path)) {
throw "Missing required path: $Path"
}
}
Run "STEP 0A - pip install v1.4.7 editable" {
& $Python -m pip install -e .
}
Run "STEP 0B - CM95 v1.4.7 preflight" {
& $Python ".\tools\cm95_v1_4_7_preflight.py"
}
Step "STEP 1 - Verify existing v1.4.6 plan / release identity"
$PlanObj = Get-Content $Plan -Raw | ConvertFrom-Json
if ([string]$PlanObj.plan_id -ne $ExpectedPlanId) {
throw "Unexpected plan_id: $($PlanObj.plan_id)"
}
if ([string]$PlanObj.release_id -ne $ExpectedReleaseId) {
throw "Unexpected release_id: $($PlanObj.release_id)"
}
if ([string]$PlanObj.builder_contract_version -ne $ExpectedBuilder) {
throw "Unexpected builder contract: $($PlanObj.builder_contract_version)"
}
Write-Host "Plan ID : $($PlanObj.plan_id)"
Write-Host "Release ID : $($PlanObj.release_id)"
Write-Host "Builder : $($PlanObj.builder_contract_version)"
Write-Host "PBF rebuild : NO"
Step "STEP 2 - Verify existing production is already 27038/27038 PASS"
$StatusText = (
& $Cm95Pbf status-production `
--plan $Plan `
--release-root $ReleaseRoot |
Out-String
).Trim()
if ($LASTEXITCODE -ne 0) { throw "status-production failed" }
Write-Host $StatusText
$S = $StatusText | ConvertFrom-Json
if ([int]$S.jobs -ne 27038 -or
[int]$S.attempts -ne 27038 -or
[int64]$S.output_features -ne 2974375 -or
[int]$S.pbf_files -ne 27030 -or
[int]$S.states.PASS -ne 27038) {
throw "Existing production baseline does not match expected completed v1.4.6 release"
}
$ReleaseDir = Join-Path $ReleaseRoot $ExpectedReleaseId
$AuditJson = ".\build\production\cm95_nav_name_conflicts_v1_4_7_precheck.json"
$AuditCsv = ".\build\production\cm95_nav_name_conflicts_v1_4_7_precheck.csv"
Run "STEP 3 - Re-audit the 10 trace occurrences / 4 unique ambiguous outputs" {
& $Python ".\tools\cm95_nav_name_conflict_audit_v1.py" `
--release-dir $ReleaseDir `
--profile delivery `
--output-json $AuditJson `
--output-csv $AuditCsv
}
$A = Get-Content $AuditJson -Raw | ConvertFrom-Json
if ([int]$A.report_name_conflict_occurrences -ne 10 -or
[int]$A.trace_name_conflict_occurrences -ne 10 -or
[int]$A.unique_conflict_outputs -ne 4 -or
[int]$A.affected_tiles -ne 3) {
throw "Nav name conflict baseline changed unexpectedly"
}
Run "STEP 4 - Finalize EXISTING PBF release with audited ambiguous-name omission gate" {
& $Cm95Pbf finalize-production `
--plan $Plan `
--release-root $ReleaseRoot `
--style ".\config\style\style.navsea-delivery-full-semantic-unified-20260808-cm95-v1.json" `
--sprite-json ".\config\sprite\semantic-sprite-20260808.json" `
--gap-disposition $Disposition
}
$Manifest = Join-Path $ReleaseDir "release_manifest_v1.json"
if (-not (Test-Path $Manifest)) {
throw "release manifest missing: $Manifest"
}
$F = Get-Content $Manifest -Raw | ConvertFrom-Json
if ([string]$F.status -ne "PASS") {
throw "release manifest status != PASS"
}
if ([string]$F.nav_name_conflict_audit.overall -ne "PASS") {
throw "nav_name_conflict_audit != PASS"
}
if ([int]$F.nav_name_conflict_audit.report_occurrences -ne 10 -or
[int]$F.nav_name_conflict_audit.trace_occurrences -ne 10 -or
[int]$F.nav_name_conflict_audit.safe_omission_occurrences -ne 10 -or
[int]$F.nav_name_conflict_audit.unique_conflict_outputs -ne 4 -or
[int]$F.nav_name_conflict_audit.affected_tiles -ne 3 -or
[int]$F.nav_name_conflict_audit.labeled_conflict_occurrences -ne 0 -or
[int]$F.nav_name_conflict_audit.missing_pbf_occurrences -ne 0) {
throw "audited ambiguous-name omission counts differ from expected baseline"
}
if ([int64]$F.planned_output_features -ne 2974375 -or
[int64]$F.decoded_pbf_features -ne 2974375) {
throw "feature count changed unexpectedly"
}
if ([string]$F.style_sprite_contract.overall -ne "PASS") {
throw "style/sprite contract != PASS"
}
Step "CM95 JAPAN v1.4.7 FINALIZE COMPLETE / PASS"
Write-Host "Release ID : $ExpectedReleaseId"
Write-Host "PBF rebuilt : NO"
Write-Host "Jobs : 27038 / 27038 PASS"
Write-Host "Decoded features : $($F.decoded_pbf_features)"
Write-Host "Ambiguous-name occurrences: $($F.nav_name_conflict_audit.report_occurrences)"
Write-Host "Unique ambiguous outputs : $($F.nav_name_conflict_audit.unique_conflict_outputs)"
Write-Host "Labels safely omitted : $($F.nav_name_conflict_audit.safe_omission_occurrences)"
Write-Host "Unsafe labels : $($F.nav_name_conflict_audit.labeled_conflict_occurrences)"
Write-Host "Style/Sprite : $($F.style_sprite_contract.overall)"
Write-Host "Semantic completeness : $($F.semantic_completeness)"
Write-Host "FINAL STATUS : $($F.status)"
Write-Host "Manifest : $Manifest"