Skip to main content

Module schema_registry

Module schema_registry 

Source
Expand description

Events track, slice 3c (#980): the cross-build schema registry’s reconciliation logic — verifying a project’s live event shapes against a committed bynk.schema.lock, keyed by qualified event name, storing each event’s field shape (name, type, whether the field has a default) and its current schema version. Every build reconciles the live shape against the stored one and either leaves the version alone, bumps it (a purely additive change), or fails the build (a change that isn’t safely additive).

P4.0 (#1113, [DECISION A]): the document shape itself — SchemaRegistry, EventEntry, FieldShape, and their parse/serialize — moved to bynk_project::schema_registry; bynk-emit/src/project/schema_registry.rs re-exports it there, unchanged, for every existing schema_registry::X call site in project.rs.

P5.3 (design/tracks/semantics-in-the-checker.md §6): reconcile and its helpers moved here from that same bynk-emit module — category 1 of bynk-check/src/analysis.rs’s own seven-category residual-gap accounting (“gap in name only”: reconcile only ever ran under SchemaLock::On, and the analyse path always passed SchemaLock::Off, so relocating it changes nothing observable — see that module’s doc for why R3.5 still requires the move). bynk-emit’s run_checks is now this function’s caller, not its owner, the same way P4.0/P4.1 turned project.rs into a caller of bynk-project/bynk-check throughout.

P5.5 (§6, §3.2’s “eighth site”): parse_or_diagnose moved here too — bynk.project.schema_registry_corrupt, a real CompileError::new construction the seven-category accounting above didn’t cover (it isn’t a whole-project check, it’s the read step immediately before reconcile), found and scoped by name in §3.2 rather than left for a future sweep to rediscover. bynk_project::schema_registry::parse itself — the document-shape parse — stays in bynk-project (P4.0); only the diagnostic construction on its error path moves, the same split reconcile’s own move drew between document shape and checking.

Functions§

parse_or_diagnose
Parse bynk.schema.lock’s content, diagnosing a corrupt file as bynk.project.schema_registry_corrupt rather than handing the caller a bare String to wrap itself. existing/project_root are exactly bynk_project::schema_registry::parse’s own parameters — None (no lock file yet) always succeeds with a fresh, empty registry.
reconcile
Reconcile every event across every unit against the given registry. Returns the updated registry document and the effective schema version for each event, keyed the same way as the document itself (<unit>.<EventName>). Diagnostics for a mismatched @schema(N) or a non-additive change are pushed onto errors.