use super::super::source::validate_role_artifact_source;
use crate::deployment_truth::{
PromotionArtifactLevelV1, RolePromotionInputV1, RolePromotionReadinessV1, SafetyFindingV1,
SafetySeverityV1,
};
pub(super) fn collect_role_findings(
input: &RolePromotionInputV1,
readiness: &RolePromotionReadinessV1,
blockers: &mut Vec<SafetyFindingV1>,
warnings: &mut Vec<SafetyFindingV1>,
) {
if let Err(err) = validate_role_artifact_source(&input.source) {
blockers.push(super::super::super::promotion_finding(
"promotion_artifact_source_invalid",
err.to_string(),
SafetySeverityV1::HardFailure,
&input.role,
));
}
if input.role != input.source.role {
blockers.push(super::super::super::promotion_finding(
"promotion_source_role_mismatch",
format!(
"promotion input role {} does not match artifact source role {}",
input.role, input.source.role
),
SafetySeverityV1::HardFailure,
&input.role,
));
}
if input.require_byte_identical_wasm && readiness.byte_identical_wasm != Some(true) {
blockers.push(super::super::super::promotion_finding(
"promotion_wasm_digest_mismatch",
"promotion requires byte-identical wasm but source and target digests differ or are incomplete",
SafetySeverityV1::HardFailure,
&input.role,
));
}
if input.require_target_embedded_config
&& readiness
.target_canonical_embedded_config_sha256
.as_deref()
.is_none_or(str::is_empty)
{
blockers.push(super::super::super::promotion_finding(
"promotion_target_embedded_config_missing",
"promotion requires target canonical embedded config but target plan has no digest",
SafetySeverityV1::HardFailure,
&input.role,
));
}
if input.promotion_level == PromotionArtifactLevelV1::SealedWasm
&& readiness.embedded_config_identical != Some(true)
{
blockers.push(super::super::super::promotion_finding(
"promotion_sealed_wasm_embedded_config_mismatch",
"sealed wasm promotion requires embedded config identity to be acceptable for the target",
SafetySeverityV1::HardFailure,
&input.role,
));
}
if readiness.restage_required {
warnings.push(super::super::super::promotion_finding(
"promotion_target_store_restage_required",
"target artifact store does not already contain the artifact; restaging is required",
SafetySeverityV1::Warning,
&input.role,
));
}
}