use crate::ResolvedProfile;
use crate::canonical::project_resolved_profile;
use animsmith_core::LoadedSource;
use animsmith_core::engine_contract::EngineContractError;
use animsmith_core::prediction::{
PredictionContractError, PredictionProvenanceV1, RawSourceBindingV1,
};
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum PredictionProvenanceProjectionError {
#[error("resolved engine evidence is invalid: {0}")]
EngineContract(#[from] EngineContractError),
#[error("prediction provenance is invalid: {0}")]
PredictionContract(#[from] PredictionContractError),
}
pub fn project_prediction_provenance_v1(
profile: &ResolvedProfile,
source: &LoadedSource,
) -> Result<PredictionProvenanceV1, PredictionProvenanceProjectionError> {
let (profile_contract, settings_contract) = project_resolved_profile(profile)?;
let raw_source = RawSourceBindingV1::from_source(source.source_facts());
Ok(PredictionProvenanceV1::new(
profile_contract,
profile.source_format(),
settings_contract,
raw_source,
source.dependency_closure().clone(),
)?)
}