cookie_agent_models/catalog/
bootstrap.rs1use sha2::{Digest as _, Sha256};
2
3use super::CatalogError;
4
5pub const MODELS_DEV_BOOTSTRAP_COMMIT: &str = "c3057690bbb8bd41cafdefadcd2a7b958e2a4642";
6pub const MODELS_DEV_BOOTSTRAP_BYTES: usize = 3_567_054;
7pub const MODELS_DEV_BOOTSTRAP_SHA256: &str =
8 "d65af0b058204954f6b08af537fa13e91f251c618d69d8c20a2d5915731d482a";
9pub const MODELS_DEV_BOOTSTRAP_SOURCE: &str =
10 "https://github.com/anomalyco/models.dev@c3057690bbb8bd41cafdefadcd2a7b958e2a4642";
11pub const MODELS_DEV_BOOTSTRAP: &[u8] = include_bytes!("../../catalog/models-dev.json");
12
13pub(crate) fn validated_bootstrap() -> Result<&'static [u8], CatalogError> {
14 let digest = format!("{:x}", Sha256::digest(MODELS_DEV_BOOTSTRAP));
15 if MODELS_DEV_BOOTSTRAP.len() == MODELS_DEV_BOOTSTRAP_BYTES
16 && digest == MODELS_DEV_BOOTSTRAP_SHA256
17 {
18 Ok(MODELS_DEV_BOOTSTRAP)
19 } else {
20 Err(CatalogError::new(
21 "bootstrap_integrity_failed",
22 "bundled catalog bootstrap integrity check failed",
23 ))
24 }
25}