The unit is named <package>.<stem> after the architecture’s package (the stem __init__ names the package itself), and its module path is derived from that name; the record holds neither. A dotted stem is a nested module (core.sub.mod.toml is <package>.core.sub.mod), so a module outside <source_dir>/<package>/ cannot be a unit.
If a required field is missing, a value has the wrong type, a key of the schema is unknown, a consumer kind is unknown, an intent id repeats or the stem is not a dotted module name (a part that is not an identifier, or __init__ as a part: the record of a package is <package dir>.toml). A missing or unknown pace is no error here: check reports it.
Examples
from pathlib import Pathfrom tempfile import TemporaryDirectoryfrom babregen import make_sample_repofrom babregen.spec import load_architecture, load_unitwith TemporaryDirectory() as tmp: root = make_sample_repo(Path(tmp) /"demo") arch = load_architecture(root /"regen"/"architecture.toml") unit = load_unit(root /"regen"/"units"/"core.calc.toml", arch)print(unit.name, unit.path, [item.idfor item in unit.intent])