pub struct InjectionPolicy {
pub schema_version: u32,
pub reject_threshold: f64,
pub pattern_weight: f64,
pub model_weight: f64,
pub model_threshold: f64,
pub gate_attributions: Vec<String>,
pub fail_mode: FailMode,
}Expand description
Full injection-policy shape — every knob is independently overridable.
Fields§
§schema_version: u32Schema sentinel. Always 1 in v1.
reject_threshold: f64Blended-score threshold at or above which content is rejected.
pattern_weight: f64Weight of the pattern score in the blend.
model_weight: f64Weight of the model score in the blend.
model_threshold: f64Model score at or above which the model considers content injection.
gate_attributions: Vec<String>Source attributions that trigger the model pass (e.g. untrusted tiers).
fail_mode: FailModeBehaviour when the model pass cannot run.
Implementations§
Source§impl InjectionPolicy
impl InjectionPolicy
Sourcepub fn parse(body: &str) -> Result<Self, InjectionPolicyError>
pub fn parse(body: &str) -> Result<Self, InjectionPolicyError>
Parse an injection-policy TOML body.
§Errors
Returns InjectionPolicyError::Parse if the TOML is malformed or
carries unknown keys, InjectionPolicyError::SchemaVersionMismatch if
the schema sentinel disagrees, or InjectionPolicyError::InvalidWeight
if any weight is non-finite/negative or a threshold falls outside
0.0..=1.0.
Sourcepub fn blend(&self, pattern: f64, model: Option<f64>) -> f64
pub fn blend(&self, pattern: f64, model: Option<f64>) -> f64
Blend the pattern score with an optional model score into 0.0..=1.0.
With no model score, the clamped pattern score is returned. Otherwise the
weighted mean (pw·pattern + mw·model) / (pw + mw) is returned, clamped.
If both weights are zero (degenerate config), the pattern score is used.
Sourcepub fn model_gated_for(&self, attribution: &str) -> bool
pub fn model_gated_for(&self, attribution: &str) -> bool
Whether the (more expensive) model pass should run for attribution.
Trait Implementations§
Source§impl Clone for InjectionPolicy
impl Clone for InjectionPolicy
Source§fn clone(&self) -> InjectionPolicy
fn clone(&self) -> InjectionPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InjectionPolicy
impl Debug for InjectionPolicy
Source§impl Default for InjectionPolicy
impl Default for InjectionPolicy
Source§impl<'de> Deserialize<'de> for InjectionPolicy
impl<'de> Deserialize<'de> for InjectionPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for InjectionPolicy
impl PartialEq for InjectionPolicy
Source§fn eq(&self, other: &InjectionPolicy) -> bool
fn eq(&self, other: &InjectionPolicy) -> bool
self and other values to be equal, and is used by ==.