Skip to main content

collect_schema_source

Function collect_schema_source 

Source
pub fn collect_schema_source(
    workspace_root: Option<&Path>,
    workspace_schemas_dir: Option<&Path>,
    schema_ref: &SchemaRef,
) -> Result<Vec<SchemaSourceFile>, SchemaSourceError>
Expand description

Resolve the schema pinned by schema_ref to a sorted set of source files ready to embed under .memstead/schema/ in a mem archive.

The returned vector is sorted by archive_path so archive bytes are deterministic — callers don’t need to re-sort.

Resolution order (first match wins):

  1. <workspace_schemas_dir>/<name>/ (when provided)
  2. <workspace_root>/.memstead.cache/schemas/<name>-<version>/ (when workspace_root is provided)
  3. Embedded builtins

When every filesystem layer misses, the returned NotFound lists every concrete path that was consulted so callers (and agents) can inspect the resolution trace without re-walking the filesystem.