$ErrorActionPreference = 'Stop'

$root = Join-Path $PSScriptRoot '..\ParkrobTrajplanner\PathSmoothing'
$sourcePath = Join-Path $root 'Contracts\SmoothedPathPointSource.cs'
$evidencePath = Join-Path $root 'Test\Fixtures\local-g2-diagnostic-single-turn.json'

function Assert-True($Actual, [string]$Message) {
    if (-not $Actual) { throw $Message }
}

$source = Get-Content -Raw -Encoding UTF8 $sourcePath
Assert-True ($source -match 'LocalG2Transition\s*=\s*4') `
    'LocalG2Transition must retain serialized value 4 for diagnostic evidence compatibility.'

$evidence = Get-Content -Raw -Encoding UTF8 $evidencePath | ConvertFrom-Json
foreach ($point in $evidence.CandidatePoints) {
    Assert-True ($point.Source -eq 4) 'Diagnostic evidence points must use the LocalG2Transition serialized value.'
}

Write-Output 'Local G2 diagnostic serialization contract checks passed.'
