Code generation

The pub.layers.* record models under lairs/records/_generated/ are generated from the vendored Layers lexicons. They are committed to the repository but never edited by hand because regeneration overwrites manual changes. The generator preserves detail (descriptions, optionality, refined value types, integer ranges, knownValues, union discriminators) that a hand-written model would drop.

For a user-facing walkthrough with every flag, see Vendoring and codegen. Generated models explains the rationale.

The pipeline

The pipeline uses two CLI commands:

uv run lairs vendor --from <layers-checkout>/lexicons/pub/layers   # copy lexicons in
uv run lairs gen                                                   # generate models
uv run lairs gen --check                                           # drift gate

Reproducibility and the drift gate

The vendored lexicon tree hash is recorded in lairs/lexicons/MANIFEST.toml and embedded in each generated module. This hash ties the committed models to a recorded lexicon snapshot. The manifest records the currently vendored release as layers_version.

lairs gen --check is the drift gate. Run it after any change that could affect generation (a re-vendor, or a change to lairs/_codegen/) and before committing. If it fails, run lairs gen and commit the regenerated modules together with the change that caused them.

Changing lexicons or the generator

Never hand-edit a file under lairs/records/_generated/. If a model comes out wrong, the fix belongs in the lexicon or in the generator, not in the output.