package semantic import "testing" // TestFastPathDerivationInvariant asserts that every development-pool row's // stored fast-path flag exactly matches what the production fast path derives // today (DeriveFastPath runs TryFastPath over the stage-0 grammars with the // experiment's act allowlist). Frozen holdout rows are preserved verbatim // across merges and are exempt — their drift is reported, never silently // rewritten. A stale development value is a corpus-build error. func TestFastPathDerivationInvariant(t *testing.T) { exs, err := LoadCorpus() if err != nil { t.Fatalf("load corpus: %v", err) } _, dev, _ := FrozenHoldoutSplit(exs) devSet := make(map[string]bool, len(dev)) for _, e := range dev { devSet[e.SourceID] = true } stale := 0 for _, e := range exs { if !devSet[e.SourceID] { continue } if got := DeriveFastPath(e.Text).Matched; got != e.FastPathResolved { t.Errorf("dev row %s (route=%s) fast_path_resolved=%v but router derives %v: %q", e.SourceID, e.Route, e.FastPathResolved, got, e.Text) stale++ } } if stale > 0 { t.Fatalf("%d development rows have stale fast-path metadata", stale) } }