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. Embedded builtins

A <workspace_root>/.memstead.cache/schemas/ layer used to sit between them, meant to hold schemas extracted from installed archives. Nothing ever populated it; the install path stages into the backend’s schema source instead. workspace_root is kept in the signature because callers thread it and a storage-rooted layer belongs here if one returns.

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.