Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/spark-rsi-mv/blob/main/src/meta/benchmark_suite.rs # spark-rsi-mv Native Rust recursive self-improvement engine with paired bootstrap evaluation and cryptographic ledger Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `spark-rsi-mv / src / meta / benchmark_suite.rs` 118 lines ยท 4011 bytes Raw Blame History 1 use serde::{Deserialize, Serialize}; 2 3 #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] 4 pub struct MetaBenchmarkMetrics { 5 pub discovery_rate_per_sec: f64, 6 pub hypothesis_validity_ratio: f64, 7 pub compute_efficiency_score: f64, 8 pub cycle_latency_ms: f64, 9 pub memory_peak_rss_kb: u64, 10 } 11 12 impl MetaBenchmarkMetrics { 13 pub fn new( 14 discovery_rate_per_sec: f64, 15 hypothesis_validity_ratio: f64, 16 compute_efficiency_score: f64, 17 cycle_latency_ms: f64, 18 memory_peak_rss_kb: u64, 19 ) -> Self { 20 Self { 21 discovery_rate_per_sec, 22 hypothesis_validity_ratio, 23 compute_efficiency_score, 24 cycle_latency_ms, 25 memory_peak_rss_kb, 26 } 27 } 28 } 29 30 #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] 31 pub struct MetaBenchmarkComparison { 32 pub parent_metrics: MetaBenchmarkMetrics, 33 pub candidate_metrics: MetaBenchmarkMetrics, 34 pub discovery_rate_delta_pct: f64, 35 pub hypothesis_validity_delta_pct: f64, 36 pub latency_delta_pct: f64, 37 pub passed_non_inferiority: bool, 38 pub passed_amplification: bool, 39 } 40 41 pub struct MetaBenchmarkSuite; 42 43 impl MetaBenchmarkSuite { 44 pub fn evaluate_candidate( 45 parent: &MetaBenchmarkMetrics, 46 candidate: &MetaBenchmarkMetrics, 47 non_inferiority_margin_pct: f64, 48 ) -> MetaBenchmarkComparison { 49 let discovery_rate_delta_pct = if parent.discovery_rate_per_sec > 0.0 { 50 ((candidate.discovery_rate_per_sec - parent.discovery_rate_per_sec) 51 / parent.discovery_rate_per_sec) 52 * 100.0 53 } else { 54 0.0 55 }; 56 57 let hypothesis_validity_delta_pct = if parent.hypothesis_validity_ratio > 0.0 { 58 ((candidate.hypothesis_validity_ratio - parent.hypothesis_validity_ratio) 59 / parent.hypothesis_validity_ratio) 60 * 100.0 61 } else { 62 0.0 63 }; 64 65 let latency_delta_pct = if parent.cycle_latency_ms > 0.0 { 66 ((candidate.cycle_latency_ms - parent.cycle_latency_ms) / parent.cycle_latency_ms) 67 * 100.0 68 } else { 69 0.0 70 }; 71 72 // Non-inferiority: hypothesis validity and discovery rate must not regress worse than margin 73 let passed_non_inferiority = hypothesis_validity_delta_pct >= -non_inferiority_margin_pct 74 && latency_delta_pct <= non_inferiority_margin_pct; 75 76 // Amplification: at least one developmental capability must improve significantly (>= 5.0%) 77 let passed_amplification = discovery_rate_delta_pct >= 5.0 78 || hypothesis_validity_delta_pct >= 5.0 79 || latency_delta_pct <= -5.0; 80 81 MetaBenchmarkComparison { 82 parent_metrics: parent.clone(), 83 candidate_metrics: candidate.clone(), 84 discovery_rate_delta_pct, 85 hypothesis_validity_delta_pct, 86 latency_delta_pct, 87 passed_non_inferiority, 88 passed_amplification, 89 } 90 } 91 } 92 93 #[cfg(test)] 94 mod tests { 95 use super::*; 96 97 #[test] 98 fn test_meta_benchmark_comparison_pass() { 99 let parent = MetaBenchmarkMetrics::new(10.0, 0.80, 1.0, 500.0, 4096); 100 let candidate = MetaBenchmarkMetrics::new(12.0, 0.85, 1.2, 450.0, 4096); 101 102 let cmp = MetaBenchmarkSuite::evaluate_candidate(&parent, &candidate, 1.0); 103 assert!(cmp.passed_non_inferiority); 104 assert!(cmp.passed_amplification); 105 assert!(cmp.discovery_rate_delta_pct >= 19.0); 106 assert!(cmp.latency_delta_pct <= -10.0); 107 } 108 109 #[test] 110 fn test_meta_benchmark_comparison_fails_regression() { 111 let parent = MetaBenchmarkMetrics::new(10.0, 0.80, 1.0, 500.0, 4096); 112 let regressed = MetaBenchmarkMetrics::new(8.0, 0.70, 0.8, 600.0, 4096); 113 114 let cmp = MetaBenchmarkSuite::evaluate_candidate(&parent, ®ressed, 1.0); 115 assert!(!cmp.passed_non_inferiority); 116 assert!(!cmp.passed_amplification); 117 } 118 }