Commit 105c4a9
fix: Make schema registry building fully deterministic (#1220)
## Summary
- Fixes non-deterministic schema resolution in `_get_registry()` that
caused `nM` unit validation failures on some platforms (Linux CI) but
not others (macOS)
- `Path.rglob()` returns files in OS/filesystem-dependent order. When
the flow-cytometry bundled units schema (771 defs, missing `nM`) was
processed before the standalone (773 defs, has `nM`), the old first-wins
logic for standalone registration prevented the correct schema from
being used
- Sorts `rglob` results for consistent iteration order across all
platforms
- Applies size comparison uniformly to both standalone and bundled
schemas, with standalone winning on ties (21 tie cases exist across the
schema set)
- Verified fully deterministic: forward vs reverse iteration produces
byte-identical registry contents
## Root Cause
The standalone registration path used `if schema_id not in
schemas_by_id` (first-wins, no size check), while the bundled path used
`if bundled_size > sizes_by_id.get(...)` (largest-wins). When a bundled
subset was encountered first, the standalone could never override it.
## Test plan
- [x] All 734 parser tests pass
- [x] All 379 discover_vendor + schema tests pass
- [x] Determinism proven: building registry with sorted-forward vs
sorted-reverse file lists produces identical results for all 105 schema
`$id`s
- [x] `nM` resolves correctly regardless of iteration order
- [x] Lint passes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent ce359b4 commit 105c4a9
1 file changed
Lines changed: 15 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
276 | 279 | | |
277 | 280 | | |
278 | 281 | | |
279 | 282 | | |
280 | 283 | | |
281 | 284 | | |
282 | 285 | | |
| 286 | + | |
283 | 287 | | |
284 | | - | |
| 288 | + | |
285 | 289 | | |
286 | 290 | | |
287 | 291 | | |
288 | 292 | | |
289 | 293 | | |
290 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
291 | 299 | | |
292 | | - | |
| 300 | + | |
| 301 | + | |
293 | 302 | | |
294 | 303 | | |
295 | 304 | | |
296 | 305 | | |
297 | 306 | | |
298 | 307 | | |
299 | | - | |
| 308 | + | |
| 309 | + | |
300 | 310 | | |
301 | 311 | | |
| 312 | + | |
302 | 313 | | |
303 | 314 | | |
304 | 315 | | |
| |||
0 commit comments