{"record":{"id":"46c86adc113dc567","repo":"astrid-runtime/astrid","slug":"corpus-input-changed-after-the-baseline-snapshot","errorCode":null,"errorMessage":"corpus input changed after the baseline snapshot; rerun against immutable inputs","messagePattern":"corpus input changed after the baseline snapshot; rerun against immutable inputs","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-chunker-evidence/src/corpus.rs","lineNumber":429,"sourceCode":"    fn finish(self) -> FileSnapshot {\n        FileSnapshot {\n            logical_bytes: self.bytes_read,\n            identity: *self.hasher.finalize().as_bytes(),\n        }\n    }\n}\n\nimpl FileSnapshot {\n    fn from_bytes(bytes: &[u8]) -> Result<Self> {\n        Ok(Self {\n            logical_bytes: u64::try_from(bytes.len())?,\n            identity: *blake3::hash(bytes).as_bytes(),\n        })\n    }\n\n    fn validate(self, observed: Self) -> Result<()> {\n        if self != observed {\n            bail!(\n                \"corpus input changed after the baseline snapshot; rerun against immutable inputs\"\n            );\n        }\n        Ok(())\n    }\n}\n\nimpl<R: Read> Read for HashingReader<R> {\n    fn read(&mut self, buffer: &mut [u8]) -> std::io::Result<usize> {\n        let read = self.inner.read(buffer)?;\n        self.hasher.update(&buffer[..read]);\n        self.bytes_read = self\n            .bytes_read\n            .checked_add(u64::try_from(read).map_err(std::io::Error::other)?)\n            .ok_or_else(|| std::io::Error::other(\"corpus byte count overflow\"))?;\n        Ok(read)\n    }\n}","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-chunker-evidence/src/corpus.rs#L411-L447","documentation":"`Baseline::validate` compares a previously captured baseline snapshot struct against a freshly observed one with full equality; any difference (size, blake3 identity, file list) bails. The library treats baseline mutation as invalid evidence and demands a rerun against immutable inputs.","triggerScenarios":"Calling `baseline.validate(observed)` when any `Input`'s logical bytes or blake3 identity hash differ from the baseline — i.e. files were edited, appended, truncated, or added/removed after the snapshot was taken.","commonSituations":"Rerunning the benchmark after modifying corpus files, datasets regenerated by scripts between runs, files on mutable network shares, or clocks/jobs touching files mid-run.","solutions":["Restore the corpus files to the state recorded in the baseline (e.g. `git checkout -- <corpus dir>`)","Regenerate the baseline snapshot deliberately if the new content is intended","Pin inputs: copy the corpus to a read-only location and rerun against that copy"],"exampleFix":"// before\nlet corpus = Corpus::from_directory(...)?; // files were edited since baseline\nbaseline.validate(corpus.snapshot()?)?;\n// after\nstd::process::Command::new(\"git\").args([\"checkout\", \"--\", \"corpus/\"]).status()?;\nlet corpus = Corpus::from_directory(...)?;\nbaseline.validate(corpus.snapshot()?)?;","handlingStrategy":"validation","validationCode":"let observed = corpus.snapshot()?;\nif observed != baseline { regenerate_or_restore_baseline(); } else { baseline.validate(observed)?; }","typeGuard":"fn matches_baseline(observed: &Snapshot, baseline: &Baseline) -> bool { baseline == observed }","tryCatchPattern":"match baseline.validate(observed) {\n    Ok(()) => proceed(),\n    Err(e) if e.to_string().contains(\"changed after the baseline snapshot\") => {\n        eprintln!(\"inputs mutated; restoring from git and rerunning\");\n        restore_corpus_from_git();\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep corpus inputs in git and `git status --porcelain` clean before benchmarking","Copy corpora to read-only storage before runs","Never edit dataset files between baseline capture and validation"],"tags":["rust","corpus","checksum","immutability"],"backgroundTag":"checksum-mismatch","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}