babylon.kernel.schema_registry

Shared JSON Schema registry builder for $ref resolution.

Provides a single, directory-parameterized helper that walks a schemas directory, loads every *.schema.json file, and assembles a referencing.Registry keyed by each schema’s $id. This registry is what Draft 2020-12 validators consult to resolve $ref references between schema files.

This helper was extracted from two byte-identical private copies (babylon.intelligence.ai.persona_loader and babylon.engine.observers.schema_validator) so both call sites share one implementation. Each call site passes its own schemas directory.

See also

babylon.intelligence.ai.persona_loader: Persona loading call site. babylon.engine.observers.schema_validator: Observer-output call site.

Functions

build_schema_registry(schemas_dir)

Build a schema registry for $ref resolution.

babylon.kernel.schema_registry.build_schema_registry(schemas_dir)[source]

Build a schema registry for $ref resolution.

Lazily loads all schemas from schemas_dir and caches the result. The cache is keyed on the directory argument, so each distinct schemas directory is scanned at most once per process.

Parameters:

schemas_dir (Path) – Directory tree to scan recursively for *.schema.json files.

Return type:

Registry[Any]

Returns:

Registry containing all loaded schemas for $ref resolution.