{"record":{"id":"0b6de71a8cf77ce2","repo":"BoundaryML/baml","slug":"baml-cache-sampled-verify-the-incremental-cache-served-a","errorCode":null,"errorMessage":"BAML_CACHE_SAMPLED_VERIFY: the incremental cache served a STALE callable-throws seed for `{rel}` ({} served vs {} honest bytes). This is a cache-soundness bug — a warm build would infer different throws than a clean one. Re-run with BAML_CACHE_VERIFY=1 for the full compare and please report this (file `{rel}`, artifact: callable-throws fragment).","messagePattern":"BAML_CACHE_SAMPLED_VERIFY: the incremental cache served a STALE callable-throws seed for `(.+?)` \\((.+?) served vs (.+?) honest bytes\\)\\. This is a cache-soundness bug — a warm build would infer different throws than a clean one\\. Re-run with BAML_CACHE_VERIFY=1 for the full compare and please report this \\(file `(.+?)`, artifact: callable-throws fragment\\)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/bytecode_cache.rs","lineNumber":2194,"sourceCode":"                    fresh.len(),\n                );\n            }\n        }\n\n        // (2) Served `callable_throws` fragment vs an honest derivation. The\n        // served copy is the manifest-resident blob (what the seeds project\n        // from); an empty fragment seeds nothing, so there is no served\n        // artifact to check.\n        if let Some(fragment) = plan.clean_fragments.get(rel)\n            && !fragment.is_empty()\n        {\n            let honest =\n                baml_db::baml_compiler2_hir_ty::package_interface::export_callable_throws_fragment(\n                    honest_db, sf,\n                );\n            let honest_bytes = borsh::to_vec(&honest)?;\n            if honest_bytes != *fragment {\n                anyhow::bail!(\n                    \"BAML_CACHE_SAMPLED_VERIFY: the incremental cache served a STALE \\\n                     callable-throws seed for `{rel}` ({} served vs {} honest bytes). This is a \\\n                     cache-soundness bug — a warm build would infer different throws than a clean \\\n                     one. Re-run with BAML_CACHE_VERIFY=1 for the full compare and please report \\\n                     this (file `{rel}`, artifact: callable-throws fragment).\",\n                    fragment.len(),\n                    honest_bytes.len(),\n                );\n            }\n        }\n        Ok(())\n    }\n\n    /// Install the immutable stdlib typed-interface seed (a per-toolchain\n    /// build constant). Returns whether the seed was served; gated off under\n    /// `BAML_CACHE_VERIFY` so the oracle exercises the honest path.\n    pub(crate) fn seed_stdlib_interface(&self, db: &mut ProjectDatabase) -> bool {\n        !Self::verify_enabled()","sourceCodeStart":2176,"sourceCodeEnd":2212,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/bytecode_cache.rs#L2176-L2212","documentation":"Sampled verification re-derives a file's callable-throws fragment honestly and compares its borsh bytes with the cached seed. On mismatch the incremental cache served a stale callable-throws seed, meaning a warm build would infer different throws than a clean one. This is flagged as a cache-soundness bug to report.","triggerScenarios":"Build with sampled verify where borsh::to_vec(export_callable_throws_fragment(honest_db, sf)) != *fragment for a file the plan considered clean.","commonSituations":"Changing `throws` declarations in dependency files without the taint closure dirtying dependents; stale caches reused after compiler upgrades; CI restoring caches across branches.","solutions":["Clear the incremental cache directory and rebuild clean.","Re-run with BAML_CACHE_VERIFY=1 for the full comparison before reporting.","Report the repro to baml maintainers; the seed should never diverge for a truly clean file."],"exampleFix":"# before\nbaml build  # warm cache, stale throws seed\n# after\nrm -rf .baml && BAML_CACHE_VERIFY=1 baml build","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = build() {\n    if e.to_string().contains(\"STALE callable-throws seed\") {\n        fs::remove_dir_all(\".baml\");\n        return build();\n    }\n    return Err(e);\n}","preventionTips":["Wipe cache after changing throws declarations anywhere in the project","Pin one compiler version per cache; regenerate after upgrades","Use clean builds for release/verification runs"],"tags":["cache","throws-analysis","incremental-compilation","cache-soundness"],"backgroundTag":"checksum-mismatch","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}