pub struct BehavioralIntegrity {
pub equivalence_score: f64,
pub syscall_match: f64,
pub timing_variance: f64,
pub semantic_equiv: f64,
pub violations: Vec<MetamorphicViolation>,
pub timestamp: DateTime<Utc>,
pub test_count: u32,
pub model_id: String,
}Expand description
Behavioral integrity metrics for model promotion gates
Tracks multiple dimensions of behavioral consistency to determine if a model is ready for promotion to production.
Fields§
§equivalence_score: f64Overall equivalence score (0.0 - 1.0) Measures how well the model’s behavior matches expected patterns
syscall_match: f64Syscall pattern match score (0.0 - 1.0) Measures consistency of system call patterns during inference
timing_variance: f64Timing variance score (0.0 - 1.0, lower = more consistent) Measures consistency of inference timing
semantic_equiv: f64Semantic equivalence score (0.0 - 1.0) Measures semantic consistency of model outputs
violations: Vec<MetamorphicViolation>List of metamorphic violations detected
timestamp: DateTime<Utc>Timestamp when metrics were collected
test_count: u32Number of test cases evaluated
model_id: StringModel version or identifier being evaluated
Implementations§
Source§impl BehavioralIntegrity
impl BehavioralIntegrity
Sourcepub fn new(
equivalence_score: f64,
syscall_match: f64,
timing_variance: f64,
semantic_equiv: f64,
model_id: impl Into<String>,
) -> Self
pub fn new( equivalence_score: f64, syscall_match: f64, timing_variance: f64, semantic_equiv: f64, model_id: impl Into<String>, ) -> Self
Create new behavioral integrity metrics
Sourcepub fn perfect(model_id: impl Into<String>) -> Self
pub fn perfect(model_id: impl Into<String>) -> Self
Create perfect behavioral integrity (all scores = 1.0, variance = 0.0)
Sourcepub fn add_violation(&mut self, violation: MetamorphicViolation)
pub fn add_violation(&mut self, violation: MetamorphicViolation)
Add a metamorphic violation
Sourcepub fn with_test_count(self, count: u32) -> Self
pub fn with_test_count(self, count: u32) -> Self
Set the test count
Sourcepub fn composite_score(&self) -> f64
pub fn composite_score(&self) -> f64
Calculate the composite integrity score
Weighted average of all metrics (timing variance is inverted)
Sourcepub fn passes_gate(&self, threshold: f64) -> bool
pub fn passes_gate(&self, threshold: f64) -> bool
Check if the model passes promotion gate
Requires:
- Composite score >= threshold (default 0.9)
- No critical violations
- Timing variance < 0.2
Sourcepub fn has_critical_violations(&self) -> bool
pub fn has_critical_violations(&self) -> bool
Check if there are any critical violations
Sourcepub fn violation_counts(&self) -> ViolationCounts
pub fn violation_counts(&self) -> ViolationCounts
Get count of violations by severity level
Sourcepub fn violations_by_type(
&self,
) -> HashMap<MetamorphicRelationType, Vec<&MetamorphicViolation>>
pub fn violations_by_type( &self, ) -> HashMap<MetamorphicRelationType, Vec<&MetamorphicViolation>>
Get violations grouped by relation type
Sourcepub fn most_severe_violation(&self) -> Option<&MetamorphicViolation>
pub fn most_severe_violation(&self) -> Option<&MetamorphicViolation>
Get the most severe violation, if any
Sourcepub fn assessment(&self) -> IntegrityAssessment
pub fn assessment(&self) -> IntegrityAssessment
Get a human-readable assessment
Trait Implementations§
Source§impl Clone for BehavioralIntegrity
impl Clone for BehavioralIntegrity
Source§fn clone(&self) -> BehavioralIntegrity
fn clone(&self) -> BehavioralIntegrity
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BehavioralIntegrity
impl Debug for BehavioralIntegrity
Source§impl<'de> Deserialize<'de> for BehavioralIntegrity
impl<'de> Deserialize<'de> for BehavioralIntegrity
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 BehavioralIntegrity
impl PartialEq for BehavioralIntegrity
Source§impl Serialize for BehavioralIntegrity
impl Serialize for BehavioralIntegrity
impl StructuralPartialEq for BehavioralIntegrity
Auto Trait Implementations§
impl Freeze for BehavioralIntegrity
impl RefUnwindSafe for BehavioralIntegrity
impl Send for BehavioralIntegrity
impl Sync for BehavioralIntegrity
impl Unpin for BehavioralIntegrity
impl UnwindSafe for BehavioralIntegrity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more