Expand description
Schema loader — reads on-disk schema directories (or in-memory YAML) into
validated Schema values with edge_weights resolved.
Three validation layers coordinate here:
- Structural (serde +
deny_unknown_fields) — handled by the deserialize. - Semantic (this module) — cross-field rules listed in
SchemaLoadError. - Editor (JSON Schemas) — generated by
emit_json_schemas, consumed by schema authors via# yaml-language-server: $schema=....
Structs§
- Heading
KeyViolation - One
(type, key, heading, derived_key)tuple in aSchemaLoadError::SectionHeadingMismatchrefusal.
Enums§
- Metadata
Polarity Format - The metadata-field polarity generation of a sealed package —
decided by the presence of the package’s format marker
(
schema-format.json), never by heuristics over the document body. - Schema
Load Error
Constants§
- SCHEMA_
FORMAT_ MARKER_ CONTENT - The marker file’s canonical content.
- SCHEMA_
FORMAT_ MARKER_ FILE - The format-marker file name sealed alongside a schema package on
the genuinely sealed surfaces — the
__MEMSTEADref, published.memarchives (the export carries it, the archive validator admits it, the archive loader honors it), and new builtin version directories. Presence ⇒MetadataPolarityFormat::RequiredOptIn; absence ⇒ legacy. Content is informative JSON; presence is the contract.
Functions§
- check_
reserved_ metadata_ keys - Author/install-path check: refuse a schema whose types declare
an engine-reserved metadata-field key (
type/mem/id). Reads the raw pre-merge declaration list the loader records (TypeDefinition::declared_metadata_keys) so the engine-injected base fields never false-positive. - check_
section_ formats - Refuse a schema whose section-format declarations are defective —
the install / strict-validation half of the loader-honesty rule.
Same posture as
check_reserved_metadata_keys: install and strict validation call this and refuse (naming EVERY problem of the first defective section); boot and sealed-schema loads must NOT — the recordedformat_problemssurface as health findings instead, and the defective declaration is never enforced. - check_
section_ heading_ roundtrip - Refuse a schema in which any declared section’s heading does not
derive back to that section’s declared key. Collects every
offending
(type, key, heading, derived_key)tuple — a schema with one good and one bad section is refused whole, and the author sees the complete list in one round. - load_
schema_ from_ dir - Load a schema from a directory containing
schema.yamlandtypes/*.yaml. - load_
schema_ from_ memory - Load a schema from in-memory YAML strings — legacy sealed
semantics (an absent required/optional key means required).
Use
load_schema_from_memory_with_formatwhen the caller knows the package’s format generation from its marker. - load_
schema_ from_ memory_ with_ format - Load a schema from in-memory YAML strings with an explicit metadata-polarity format generation (from the sealed package’s format marker).
- load_
sealed_ package - Load a sealed schema package from its
(relative-path, bytes)file list — the shape every sealed surface carries: a published.memarchive’s.memstead/schema/tree, the git-branch__MEMSTEAD:schemas/<name>@<version>/tree, a built-in version directory. Paths are package-relative (schema.yaml,types/<stem>.yaml,schema-format.json); anything else is ignored. - reserved_
metadata_ field_ keys - Engine-invariant metadata-field keys reserved against schema use —
the entity’s identity/discriminator triple.
typeis the engine-set frontmatter discriminator;memandidare the entity’s structural identity, owned by the engine’s id grammar and mount routing. One reservation, one behaviour: no installable schema may declare any of them (seecheck_reserved_metadata_keys), and the engine write paths refuse them as caller-supplied metadata. - reserved_
section_ keys - Engine-invariant section keys reserved against schema use. The
parser’s auto-managed
## Relationshipssection is the only entry today. - validate_
schema_ name - Author-time access to the schema-name shape rule — the same check
the loader runs on a manifest’s
name:. Exposed so scaffolding tooling (memstead schema new) can refuse a bad name up front with the loader’s own reason string instead of a drifting copy of the grammar. - with_
format_ marker - Append the format marker to a package’s file list if absent — the seal-path helper every installer runs so sealed copies carry their generation.