Expand description
Schema inference and validation. infer_schema walks records to discover
field types and cardinalities; validate_record checks a record against a
schema; schema_to_yaml renders a schema to YAML for persistence.
Structs§
- Collection
Schema - Schema for a single collection (a folder + optional filter).
- Field
Schema - Schema for a single field.
- Vault
Schema - Top-level schema file structure.
- Violation
- A single validation violation.
Constants§
- DEFAULT_
EXPRS - Recognised values for
FieldSchema::default_expr. Any other value is rejected at schema load time. Resolution to a concreteValuehappens inresolve_default_exprbelow;CreateBuildercalls it at the moment a record is created. - SCHEMA_
FILENAME - Canonical filename for the persisted schema, relative to the vault root.
CLI and MCP both load
<vault>/vaultdb-schema.yamlvia this constant.
Functions§
- infer_
schema - Infer a schema from a set of records.
- is_
valid_ date - True if
sparses as a calendar date inYYYY-MM-DDform, with the month and day in valid ranges. Does NOT do leap-year validation —2024-02-30passes today; a stricter check can come in Phase 8 if the false-negative cost ever materialises. - is_
valid_ url - True if
sparses as an absolute URL (i.e. has a scheme likehttps,http,mailto,file, …). Relative URLs are rejected on purpose — a vault field declaredtype: urlshould be navigable on its own. - is_
valid_ wikilink - True if
sis a syntactically valid wikilink:[[target]], with optional|aliasand/or#section. Target must be non-empty and must not contain]]. Does NOT verify the target exists in the vault — that requires aLinkGraphand is out of scope for v1. - load_
schema - Load schema from a file.
- resolve_
default_ expr - Resolve a
default_exprkeyword to a concreteValueusing wall-clock now. ReturnsSchemaErrorfor unknown keywords (defence-in-depth —load_schemarejects these earlier, but the helper stays safe to call from any code path). - schema_
path - Resolve the schema file path for a vault root.
- schema_
to_ yaml - Serialize a schema to YAML string.
- validate_
record - Validate a record’s fields against a collection schema.
- validate_
schema_ consistency - Cross-collection consistency checks. Runs after
validate_schema_defaultsat schema load. Rejects schemas where two folder-overlapping collections (one folder is==or an ancestor of the other) declare the same field name in mutually unsatisfiable ways: - validate_
schema_ defaults - Walk every field in every collection and check that any declared
defaults are well-formed. Exposed publicly so consumers that build a
VaultSchemain code (not by loading a file) can run the same check.