pub struct SchemaRegistry { /* private fields */ }Expand description
Persistent store for trained ModelArtifacts.
Backed by a single portable .zsm binary file (b"ZSM\x01" magic +
bincode-serialized HashMap). The file is written atomically on every
mutation, a .zsm.tmp file is written first then renamed into place, so a
crash during flush can never leave a partially-written registry.
The registry is small in practice (< 1 000 entries), so nearest-neighbor lookup performs a full linear scan without an index.
Implementations§
Source§impl SchemaRegistry
impl SchemaRegistry
Sourcepub fn open(path: &Path) -> Result<Self, ZerError>
pub fn open(path: &Path) -> Result<Self, ZerError>
Open (or create) a registry at the given .zsm file path.
If the file does not exist yet it is created on the first Self::save call.
Sourcepub fn save(&self, artifact: &ModelArtifact) -> Result<(), ZerError>
pub fn save(&self, artifact: &ModelArtifact) -> Result<(), ZerError>
Persist a trained model artifact. Overwrites any existing artifact with the same schema hash and atomically flushes to disk.
Sourcepub fn get_exact(
&self,
fingerprint: &SchemaFingerprint,
) -> Result<Option<ModelArtifact>, ZerError>
pub fn get_exact( &self, fingerprint: &SchemaFingerprint, ) -> Result<Option<ModelArtifact>, ZerError>
Exact lookup by schema hash. Returns None if no matching artifact exists.
Sourcepub fn get_nearest(
&self,
fingerprint: &SchemaFingerprint,
) -> Result<Option<(ModelArtifact, f32)>, ZerError>
pub fn get_nearest( &self, fingerprint: &SchemaFingerprint, ) -> Result<Option<(ModelArtifact, f32)>, ZerError>
Nearest-neighbor lookup: returns the closest artifact and its distance.
Performs a full linear scan, acceptable because the registry is expected to hold far fewer than 1 000 entries.
Returns None when the registry is empty.
Sourcepub fn lookup_startup_mode(
&self,
fingerprint: &SchemaFingerprint,
) -> Result<StartupMode, ZerError>
pub fn lookup_startup_mode( &self, fingerprint: &SchemaFingerprint, ) -> Result<StartupMode, ZerError>
Determine the startup mode for an incoming dataset given its fingerprint.
exact hash match → WarmLoad (skip EM entirely)
distance ≤ 0.25 → WarmStart (2–3 EM iterations from saved init)
distance > 0.25 / empty → ColdStart (full EM from priors)