|
| 1 | +from pathlib import Path |
| 2 | + |
| 3 | + |
| 4 | +def once(text: str, old: str, new: str, label: str) -> str: |
| 5 | + n = text.count(old) |
| 6 | + if n != 1: |
| 7 | + raise SystemExit(f"{label}: expected exactly one anchor, found {n}") |
| 8 | + return text.replace(old, new, 1) |
| 9 | + |
| 10 | + |
| 11 | +libp = Path("crates/ogar-vocab/src/lib.rs") |
| 12 | +s = libp.read_text() |
| 13 | + |
| 14 | +# all_promoted_classes() is an ordered structural mirror of class_ids::ALL. |
| 15 | +# Weather occupies 0x04XX, immediately after 0x02XX commerce and before OCR. |
| 16 | +s = once( |
| 17 | + s, |
| 18 | + " unicharset(),\n", |
| 19 | + " weather_cell(),\n weather_static_cell(),\n unicharset(),\n", |
| 20 | + "all_promoted_classes weather builders", |
| 21 | +) |
| 22 | + |
| 23 | +# The domain routing test intentionally enumerates reserved/unassigned blocks. |
| 24 | +# 0x04 has now been authoritatively allocated; only 0x05-0x06 remain unassigned. |
| 25 | +s = once( |
| 26 | + s, |
| 27 | + " // Unassigned blocks (4-6).\n" |
| 28 | + " assert_eq!(canonical_concept_domain(0x0400), ConceptDomain::Unassigned);\n" |
| 29 | + " assert_eq!(canonical_concept_domain(0x0600), ConceptDomain::Unassigned);\n", |
| 30 | + " // Weather / Atmosphere block (0x04), then still-unassigned 0x05-0x06.\n" |
| 31 | + " assert_eq!(canonical_concept_domain(0x0400), ConceptDomain::Weather);\n" |
| 32 | + " assert_eq!(canonical_concept_domain(0x0401), ConceptDomain::Weather);\n" |
| 33 | + " assert_eq!(canonical_concept_domain(0x0500), ConceptDomain::Unassigned);\n" |
| 34 | + " assert_eq!(canonical_concept_domain(0x0600), ConceptDomain::Unassigned);\n", |
| 35 | + "domain allocation test", |
| 36 | +) |
| 37 | +libp.write_text(s) |
| 38 | + |
| 39 | +# This is a count fuse for the global codebook, not a palette-only count. The |
| 40 | +# two canonical weather rows legitimately move it from 91 to 93; the 0x17XX |
| 41 | +# exclusion assertion remains unchanged and continues to prove the actual rule. |
| 42 | +cp = Path("crates/ogar-vocab/src/capability_registry.rs") |
| 43 | +c = cp.read_text() |
| 44 | +c = once( |
| 45 | + c, |
| 46 | + " assert_eq!(crate::class_ids::ALL.len(), 91);\n", |
| 47 | + " assert_eq!(crate::class_ids::ALL.len(), 93);\n", |
| 48 | + "global codebook count fuse", |
| 49 | +) |
| 50 | +cp.write_text(c) |
0 commit comments