router/semantic: slice 23 corpus fast-path reconciliation — DeriveFastPath over the real router replaces the regex mirror, factory/merge validated, corpus rebuilt (dataset_hash unchanged), drift diagnostic and rerun tooling

This commit is contained in:
2026-09-08 04:02:00 +04:00
parent bb6bd8efb9
commit be71ac406b
12 changed files with 8460 additions and 7890 deletions
+28 -4
View File
@@ -92,13 +92,37 @@ func main() {
}
fmt.Fprintf(os.Stderr, "merged: %d examples (skipped %d duplicates)\n", len(merged), skipped)
// 5. Validate
// 5. Fast-path metadata must match the real router. V2 rows are derived
// by interactively-labeled construction; a stale manually-supplied value
// is a build error, never silently rewritten. Frozen holdout rows are
// preserved verbatim — report drift, do not touch them.
v2Checked, frozenChecked, frozenDrift := 0, 0, 0
for _, e := range merged {
derived := semantic.DeriveFastPath(e.Text).Matched
if frozenTexts[strings.TrimSpace(e.Text)] {
frozenChecked++
if derived != e.FastPathResolved {
frozenDrift++
fmt.Fprintf(os.Stderr, "frozen drift: %q stored=%v derived=%v\n", e.Text, e.FastPathResolved, derived)
}
continue
}
v2Checked++
if derived != e.FastPathResolved {
log.Fatalf("v2 row (source=%s source_id=%s) fast_path_resolved=%v but router derives %v: %q",
e.Source, e.SourceID, e.FastPathResolved, derived, e.Text)
}
}
fmt.Fprintf(os.Stderr, "fast-path check: v2 rows %d OK, frozen rows %d (drift %d, reported only)\n",
v2Checked, frozenChecked, frozenDrift)
// 6. Validate
if err := semantic.ValidateCorpus(merged); err != nil {
log.Fatalf("validation failed: %v", err)
}
fmt.Fprintf(os.Stderr, "validation: OK\n")
// 6. Compute dataset hash
// 7. Compute dataset hash
texts := make([]string, len(merged))
for i, e := range merged {
texts[i] = e.Text
@@ -107,7 +131,7 @@ func main() {
h := sha256.Sum256([]byte(strings.Join(texts, "\n")))
datasetHash := hex.EncodeToString(h[:16])
// 7. Stats
// 8. Stats
routeCounts := make(map[semantic.SemanticRoute]int)
fpCount, resCount := 0, 0
for _, e := range merged {
@@ -124,7 +148,7 @@ func main() {
}
fmt.Fprintf(os.Stderr, "fast-path: %d residual: %d\n", fpCount, resCount)
// 8. Write merged corpus
// 9. Write merged corpus
outEnv := semantic.CorpusEnvelope{
SchemaVersion: 1,
Name: "semantic_coarse_route_v1",