pub fn load_derived(
db: &mut QueryDb,
snapshot_sha256: [u8; 32],
path: &Path,
workspace_root: &Path,
) -> Result<LoadOutcome, LoadError>Expand description
Load a derived file at path into a pristine [QueryDb].
§Staged-validation + infallible-commit contract (spec §5.7)
- Path validation happens before any file IO.
- All fallible work (file open, header decode, magic/version check, SHA
match, entry stream decode) runs in the validation phase and returns
Err(...)without touching the DB. - Once all entries are staged successfully, [
QueryDb::commit_staged_load] is called. That function is infallible by construction — it contains no?, noResult-bearing call, and nomap_err. - After commit,
cold_load_allowedis flipped tofalseto prevent a second load from overwriting the committed state.
§Errors
LoadError::PathSafety— path fails workspace validation.LoadError::NotFound— file does not exist (ENOENT).LoadError::Io— other IO errors.LoadError::Corrupt— magic mismatch, version mismatch, or truncated entry stream.LoadError::StaleSnapshot— SHA-256 in the header doesn’t matchsnapshot_sha256.LoadError::AlreadyLoaded— a successful load has already been applied todb.