Skip to content

fix: Make schema registry building fully deterministic#1220

Merged
nathan-stender merged 1 commit into
mainfrom
fix/deterministic-schema-registry
Jun 2, 2026
Merged

fix: Make schema registry building fully deterministic#1220
nathan-stender merged 1 commit into
mainfrom
fix/deterministic-schema-registry

Conversation

@nathan-stender

Copy link
Copy Markdown
Collaborator

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

  • All 734 parser tests pass
  • All 379 discover_vendor + schema tests pass
  • Determinism proven: building registry with sorted-forward vs sorted-reverse file lists produces identical results for all 105 schema $ids
  • nM resolves correctly regardless of iteration order
  • Lint passes

🤖 Generated with Claude Code

The `_get_registry()` function used `Path.rglob()` without sorting, making
schema resolution dependent on filesystem iteration order. This caused the
flow-cytometry bundled units schema (771 defs, missing nM) to override the
standalone (773 defs, has nM) on platforms where rglob returned adm/ before
qudt/, breaking Biacore T200 Control validation with nM concentrations.

Two fixes applied:
- Sort rglob results for consistent iteration order across all platforms
- Use size comparison for ALL registrations (standalone and bundled), with
  standalone schemas winning ties over bundled copies

Verified deterministic by comparing forward vs reverse iteration — produces
identical results regardless of file discovery order.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nathan-stender
nathan-stender requested a review from a team as a code owner June 2, 2026 18:38
@nathan-stender
nathan-stender requested a review from tamargrey June 2, 2026 18:38
@nathan-stender
nathan-stender merged commit 105c4a9 into main Jun 2, 2026
9 checks passed
@nathan-stender
nathan-stender deleted the fix/deterministic-schema-registry branch June 2, 2026 20:02
nathan-stender added a commit that referenced this pull request Jun 2, 2026
### Fixed

- Make schema registry building fully deterministic (#1220)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants