Skip to main content

Module compiler

Module compiler 

Source
Expand description

The ModelCompiler: turns a complete model plus CLI options into an immutable GenerationPlan.

Compilation is two concerns woven together:

  • Selection — --tables/--exclude globs choose the tables to generate; a selected table whose required parent was excluded is a GEN-EXCLUDED-DEPENDENCY error reporting the full dependency path.

  • Exact counts — every selected table gets a single resolved integer row count. Roots resolve from their model count through the global --scale/--rows control, a per-table --table-rows/--table-scale override, and finally the --max-rows cap. Relationship children derive from their final parent count times the stored fan-out mean — the global control is never applied a second time — then take their own override and cap. Fractional targets are stochastically rounded on a stable per-table StreamId::rounding stream, so a run is reproducible.

  • Ownership, types, and dependencies — every column gets exactly one owner: an explicit generator, a table planner, a declared relationship, a database default, or the database itself (identity/serial, computed, or a bare integer primary key). Two owners claiming one column is a GEN-COLUMN-OWNER-CONFLICT; a column no rule or structural schema fact can supply is a GEN-COLUMN-OWNER-MISSING. Generators/modifiers are type-checked against their descriptor’s accepted families, and the column/planner read→write graph is scanned for cycles (GEN-COLUMN-CYCLE), except a cycle a single planner owns end-to-end.

Errors are gathered, not short-circuited: a model with a count conflict and three excluded dependencies reports all four. Warnings (e.g. a --max-rows cap) survive a successful compile via GenerationPlan::diagnostics.

Structs§

CompileOptions
The CLI-supplied knobs a compile honors, mapping one-to-one onto the generation command’s count and selection flags.
ModelCompiler
Compiles a SyntheticModel into a GenerationPlan.
TableCountOverride
A single per-table count override from the CLI (--table-rows or --table-scale).

Enums§

TableCountKind
The two shapes of a per-table count override.