[CmdletBinding()] param( [Parameter(Mandatory = $false)] [string]$RepositoryRoot ) $ErrorActionPreference = 'Stop' if (-not $RepositoryRoot) { $RepositoryRoot = Split-Path -Parent $PSScriptRoot } $RepositoryRoot = [IO.Path]::GetFullPath($RepositoryRoot) $ledgerPath = Join-Path $RepositoryRoot 'capability-ledger\plant3d-p-rec-annot-commands.json' $sourcePath = Join-Path $RepositoryRoot 'audits\p-rec-annot-v1.0.4\evidence\commands.csv' & (Join-Path $PSScriptRoot 'Build-CapabilityLedger.ps1') -RepositoryRoot $RepositoryRoot -OutputPath $ledgerPath | Out-Null $ledger = Get-Content -LiteralPath $ledgerPath -Raw -Encoding utf8 | ConvertFrom-Json $required = 'id','sourceProduct','sourceComponent','userPurpose','launchMethod','dependencies','resources','projectConstraints','legacyStatus','targetComponent','owner','migrationStatus','verificationMethod','runtimeEvidence','knownDifferences','decision' $expected = (Import-Csv -LiteralPath $sourcePath | Where-Object { $_.File -notmatch '(^|\\)_archive(\\|$)' } | Select-Object -ExpandProperty Command -Unique).Count if ($ledger.schemaVersion -ne 1) { throw 'CAPABILITY_LEDGER_SCHEMA_VERSION_INVALID' } if ($ledger.capabilities.Count -ne $expected) { throw "CAPABILITY_LEDGER_COUNT_MISMATCH: expected $expected, got $($ledger.capabilities.Count)" } if (($ledger.capabilities.id | Select-Object -Unique).Count -ne $ledger.capabilities.Count) { throw 'CAPABILITY_LEDGER_DUPLICATE_ID' } foreach ($capability in $ledger.capabilities) { foreach ($field in $required) { if (-not $capability.PSObject.Properties.Name.Contains($field)) { throw "CAPABILITY_LEDGER_REQUIRED_FIELD_MISSING: $($capability.id):$field" } } } $accepted = @($ledger.capabilities | Where-Object { $_.decision -eq 'MIGRATED_RUNTIME_VERIFIED' }) if ($accepted.Count -ne 2 -or ($accepted.id -notcontains 'PLANT3D-2019-CMD-PXP-AAV') -or ($accepted.id -notcontains 'PLANT3D-2019-CMD-PXP-OA')) { throw 'CAPABILITY_LEDGER_REFERENCE_VERTICAL_MISSING' } Write-Output "CAPABILITY_LEDGER_VALIDATED=$ledgerPath" Write-Output "CAPABILITY_COUNT=$($ledger.capabilities.Count)"