Schema Versioning
How BO4E schema releases map onto Rust modules, what rubo4e::current guarantees, and which imports to pin when enum membership must not move underneath you.
rubo4e exposes a single stable BO4E schema series (v202607), compiled conditionally behind the versioned feature flag.
πThree spellings of one release
BO4E names a release twice, and this crate needs a third name for it β the series, which is the granularity at which a module exists:
| Where | Spelling | Example |
|---|---|---|
| Git tag and schema directory | with v, full triple | v202607.1.0 |
| Rust module | with v, series only | rubo4e::v202607 |
The _version field inside a payload | no v, full triple | 202607.1.0 |
Bo4eTyped::SCHEMA_VERSION is the wire spelling, so it compares against a _version read off a message with no normalisation step β never against the tag.
The series β the bare YYYYMM prefix β is the one to dispatch on, because it is the one that maps onto a set of Rust types. Bo4eTyped::SCHEMA_SERIES is it.
Both are associated constants, so they are readable from a type alone:
use rubo4e::{current::Rechnung, Bo4eTyped};
assert_eq!(Rechnung::SCHEMA_VERSION, "202607.1.0");
assert_eq!(Rechnung::SCHEMA_SERIES, "202607");schema_version() and schema_series() are the same facts as methods.
πMulti-version Dispatch
When your storage layer persists a bo4e_version column alongside the JSON payload (common in JSONB-column designs), the idiomatic dispatch is a plain match β on the series, not on the exact release:
use rubo4e::{v202607, Bo4eTyped as _};
/// The `YYYYMM` prefix of a `_version` value: `"202607.1.0"` β `"202607"`.
fn series_of(wire_version: &str) -> &str {
wire_version.split('.').next().unwrap_or(wire_version)
}
fn process_rechnung(json: &str, bo4e_version: &str) -> Result<(), Box<dyn std::error::Error>> {
// `bo4e_version` is the payload's own `_version` β no `v` prefix.
match series_of(bo4e_version) {
"202607" => {
let r: v202607::Rechnung = serde_json::from_str(json)?;
// r.schema_series() == "202607" β always matches this arm
handle_v202607(r)
}
// Each further series is one more arm:
// "202701" => handle_v202701(serde_json::from_str::<v202701::Rechnung>(json)?),
_ => Err(format!("unsupported schema series: {bo4e_version}").into()),
}
}Do not match on the full _version. BO4E ships patch releases inside a series, so a sender one patch ahead stamps a string an equality match rejects, for a payload the v202607 types read perfectly. Bo4eTyped::SCHEMA_SERIES is exactly the value this match keys on.
There is no migration API and no cross-version type: two series have different field sets, and mapping between them is a decision about your data. AnyBo is the sum over the GeschΓ€ftsobjekte of one series (dispatch on _typ), not a version abstraction.
πVersion Module Layout
With the versioned feature enabled:
rubo4e::v202607::Vertrag // the v202607 series
rubo4e::v202607::Adresse
rubo4e::v202607::Sparte
rubo4e::current::Vertrag // moving alias β whichever series is newestBOs, COMs and enums all live in the version module. Without the versioned feature (not on by default) none of these paths exist:
cargo add rubo4e --features versionedπKnown Schema Series
| Series | Committed snapshot | Status | Released |
|---|---|---|---|
| v202607 | v202607.1.0 | Current stable | July 2026 |
The snapshot column is the exact BO4E tag src/generated/v202607/ was built from; it lives under generator/schemas/ and is committed, so the codegen is reproducible. It advances when BO4E ships a release inside the series β see the contract below.
πVersioning Scheme
BO4E uses vYYYYMM.minor.patch. Module names use the vYYYYMM prefix only:
v202607.1.0 β module: v202607
v202701.0.0 β module: v202701 (hypothetical next series)The generator pins the full tag for reproducibility but exposes only the series prefix in the public API.
A minor bump inside a series is not necessarily additive. BO4E removes enum values and whole types within a series, so anything treating one as a frozen value set will eventually be wrong. The contract below says what is stable.
πrubo4e::current β Moving Alias
rubo4e::current is a re-export module that always points to the newest schema series. Use it when you want the newest types.
use rubo4e::current::Vertrag; // equivalent to rubo4e::v202607::Vertrag todayPin to a concrete module if you need version-stability across crate updates:
use rubo4e::v202607::Vertrag; // stable even if rubo4e::current advancesπWhat pinning does, and does not, buy you
| Path | What a minor rubo4e bump can do to it |
|---|---|
rubo4e::v202607::Foo | Keep the series. Field names and types stay put; enum membership can still move, because BO4E itself moves it inside a series. |
rubo4e::current::Foo | Anything the above can do, plus jump to a new series β renamed fields, retyped fields, whole types added or removed. |
The Rust module path pins the series. The
rubo4eversion pins the values.
If a variant set must not move under you, pin the crate version (rubo4e = "=0.15.0") and upgrade deliberately. Importing rubo4e::v202607::Sparte keeps you off a new series, but does not freeze the enum.
Guard the shapes you depend on structurally, so a schema bump fails in CI:
- SQL
CHECK (col IN (...))lists generated from an enum's variants - Exhaustive
match/ mapping tables over an enum - Variant-count assertions (
assert_eq!(T::COUNT, N))
The built-in introspection surface (VARIANTS, COUNT, as_wire) is there for exactly this:
use rubo4e::{Bo4eEnum, v202607::Zaehlertyp};
// Structural drift guard β no magic number to update by hand:
#[test]
fn sql_check_list_covers_every_variant() {
let sql: Vec<&str> = load_check_list(); // your migration's CHECK list
for v in Zaehlertyp::VARIANTS {
assert!(sql.contains(&v.as_wire()), "CHECK list missing {}", v.as_wire());
}
}Note the direction: this asserts the CHECK list covers every variant, so an added variant fails it. To catch a removed one too, assert set equality instead.
πSchema-delta changelog
Every release that changes schema-derived enum membership or codelist coverage records it in the CHANGELOG.md Schema deltas section, in the form:
### Schema deltas (<old tag> β <new tag>)
- <Enum> +2 (NEW_A, NEW_B) -1 (REMOVED_C)
- <OtherEnum> +1 (NEW_D)
- removed enums: <Type>, <Type>Removals are listed as prominently as additions: they are the half that breaks a build. T::COUNT and T::VARIANTS turn the drift into a test failure the moment you upgrade.
πUpgrading within a series
For a BO4E release inside the current series the module path does not change:
just download-schemas <new tag> # vendors the snapshot under generator/schemas/
git rm -r generator/schemas/<old tag> # exactly one snapshot per series
just generate # discovers the tag from the directory
just ciThe generator rewrites every file in src/generated/v202607/ and deletes the ones the release retired, so a type BO4E drops leaves no orphan module behind.
The justfile, CI, tests and site config derive the tag from that directory name (tests/pinned_tag.rs enforces it), so the only manual edits are the table above and the changelog. Review git diff src/generated/ and record every membership change β removals especially β in the Schema deltas entry.
πAdding a New Schema Series
When BO4E's annual format-version cutover lands, with new or renamed types:
Download the schema snapshot using the provided script:
just download-schemas v202701.0.0Run the generator:
just generate v202701.0.0The generator writes
src/generated/v202701/with all types and automatically updatessrc/generated/mod.rs(by re-scanning the directory β no manual edit needed).In
src/lib.rs, add a versioned re-export module:#[cfg(feature = "versioned")] pub mod v202701 { pub use crate::generated::v202701::*; }Advance the
currentmodule to re-export the new series (it is a realpub mod, not apub use β¦ asalias, so IDE tooling resolves hovers asrubo4e::current::Foo):#[cfg(feature = "versioned")] pub mod current { pub use crate::generated::v202701::*; // was: v202607 }Advance every hand-written module that names a series. These are the ones the generator does not touch, and nothing in the compiler notices when one is left behind β the older module still exists and still type-checks, so the crate ships accessors for a series nobody is using:
File What it pins src/lib.rspub mod currentand thepub mod vYYYYMMre-exportssrc/convenience.rsZeitraum/Rechnung/Preisstaffelaccessorssrc/units.rsMengeneinheitdimensions andMengearithmeticsrc/timeseries.rsthe Bo4eTimeSeriesimpls forLastgang/Zeitreihesrc/validation/mod.rsimpl_validators!(vYYYYMM)andvalidation::currentvalidationkeeps a copy per series via theimpl_validators!macro; the other modules targetcurrentonly.tests/current_series_alignment.rsfails if any of them names a series other thancurrent's, or if a new file starts naming one without being added to this table.A schema-breaking rename will surface as a compile error in these modules, which is the intended behaviour β see Semantic Field Typing.
Update the Known Schema Series table in this document, and keep the retiring series listed until you remove its module.
Record a Schema deltas section in
CHANGELOG.mdlisting every enum whose membership changed and every codelist code added/removed (e.g.Zaehlertyp +2 (β¦)). DiffingT::VARIANTSbetween the two series makes this mechanical.
πSchema Breaking Changes
The BO4E annual format-version cutover can rename fields, change optionality, and add or remove whole types. What a given cutover changed is recorded in the CHANGELOG; the authoritative diff is between the snapshots under generator/schemas/.
The generator does not paper over such changes: a $ref, a "format", and "type": "number" are always authoritative, so a renamed or retyped field surfaces as a compile error rather than as a silent behaviour change. See Semantic Field Typing.