use super::*;
#[derive(Component, Debug, Clone, Default)]
pub struct ToolSensitivities(pub std::collections::HashMap<String, leviath_core::TaintLevel>);
#[derive(Resource, Default)]
pub struct PolicyGate(pub leviath_core::PolicyConfig);
#[derive(Resource, Clone)]
pub struct GateScriptRules(pub std::sync::Arc<crate::taint::ScriptRuleChecker>);
pub(crate) fn taint_block_message(decision: &leviath_core::taint::GateDecision) -> String {
match decision {
leviath_core::taint::GateDecision::Blocked {
taint_level,
clearance,
tool_name,
source_regions,
} => format!(
"[blocked] Tool '{tool_name}' would send {taint_level:?}-level data over a channel \
cleared only for {clearance:?} (tainted by: {}). Add an allowlist rule with \
`lev policy add` to permit it.",
if source_regions.is_empty() {
"context".to_string()
} else {
source_regions.join(", ")
}
),
leviath_core::taint::GateDecision::Allowed => "[blocked] tool call denied".to_string(),
}
}