|
| 1 | +//! Proof Report Generator — runs all ladybug-rs proof suites and outputs results. |
| 2 | +//! |
| 3 | +//! Usage: `cargo run --bin proof_report` |
| 4 | +//! |
| 5 | +//! Executes `cargo test` for each proof suite and parses results into a |
| 6 | +//! formatted table showing pass/fail status for every proof. |
| 7 | +
|
| 8 | +use std::process::Command; |
| 9 | + |
| 10 | +/// A proof suite with its test binary name and expected proof IDs. |
| 11 | +struct ProofSuite { |
| 12 | + name: &'static str, |
| 13 | + test_name: &'static str, |
| 14 | + proofs: &'static [&'static str], |
| 15 | +} |
| 16 | + |
| 17 | +const SUITES: &[ProofSuite] = &[ |
| 18 | + ProofSuite { |
| 19 | + name: "Foundation", |
| 20 | + test_name: "proof_foundation", |
| 21 | + proofs: &[ |
| 22 | + "F-1 Berry-Esseen CLT (d=16384)", |
| 23 | + "F-2 Fisher sufficiency", |
| 24 | + "F-3 XOR self-inverse (exact)", |
| 25 | + "F-3b XOR commutativity/associativity", |
| 26 | + "F-4 Triangle inequality (metric)", |
| 27 | + "F-4b Metric axioms (identity, symmetry)", |
| 28 | + "F-5 Mexican hat shape", |
| 29 | + "F-5b Calibrated thresholds from CRP", |
| 30 | + "F-6 NARS revision monotonicity", |
| 31 | + "F-6b Revision commutativity", |
| 32 | + "F-7 ABBA causal retrieval", |
| 33 | + "F-7b Fusion quality (exact XOR roundtrip)", |
| 34 | + "F-7c Multi-fusion quality (N-way)", |
| 35 | + ], |
| 36 | + }, |
| 37 | + ProofSuite { |
| 38 | + name: "Reasoning Ladder", |
| 39 | + test_name: "proof_reasoning_ladder", |
| 40 | + proofs: &[ |
| 41 | + "RL-1 Parallel error isolation", |
| 42 | + "RL-2 NARS detects inconsistency", |
| 43 | + "RL-3 Collapse Gate HOLD/FLOW/BLOCK", |
| 44 | + "RL-5 Thinking style divergence (12 styles)", |
| 45 | + "RL-6 NARS abduction generates insight", |
| 46 | + "RL-7 Counterfactual divergence (Pearl Rung 3)", |
| 47 | + "RL-7b Different interventions differ", |
| 48 | + "RL-8 Parallel vs sequential probability", |
| 49 | + ], |
| 50 | + }, |
| 51 | + ProofSuite { |
| 52 | + name: "Tactics (PR #100)", |
| 53 | + test_name: "proof_tactics", |
| 54 | + proofs: &[ |
| 55 | + "T-01 Recursive expansion converges", |
| 56 | + "T-04 Reverse causal trace", |
| 57 | + "T-07 Adversarial critique detects weakness", |
| 58 | + "T-10 MetaCognition Brier calibration", |
| 59 | + "T-11 Contradiction detection", |
| 60 | + "T-15 CRP distribution from corpus", |
| 61 | + "T-20 Shadow parallel consensus", |
| 62 | + "T-24 Fusion quality (exact)", |
| 63 | + "T-25 Hamming Normal approximation", |
| 64 | + "T-28 Temporal Granger effect", |
| 65 | + "T-31 Counterfactual divergence", |
| 66 | + "T-34 Cross-domain fusion", |
| 67 | + ], |
| 68 | + }, |
| 69 | +]; |
| 70 | + |
| 71 | +fn main() { |
| 72 | + println!(); |
| 73 | + println!("=========================================================="); |
| 74 | + println!(" LADYBUG-RS INTEGRATION PROOF REPORT"); |
| 75 | + println!("=========================================================="); |
| 76 | + println!(); |
| 77 | + |
| 78 | + let mut total_pass = 0u32; |
| 79 | + let mut total_fail = 0u32; |
| 80 | + let mut total_skip = 0u32; |
| 81 | + |
| 82 | + for suite in SUITES { |
| 83 | + println!("----------------------------------------------------------"); |
| 84 | + println!(" {} ({} proofs)", suite.name, suite.proofs.len()); |
| 85 | + println!("----------------------------------------------------------"); |
| 86 | + |
| 87 | + let output = Command::new("cargo") |
| 88 | + .args(["test", "--test", suite.test_name, "--", "--test-threads=1"]) |
| 89 | + .output(); |
| 90 | + |
| 91 | + match output { |
| 92 | + Ok(result) => { |
| 93 | + let stdout = String::from_utf8_lossy(&result.stdout); |
| 94 | + let stderr = String::from_utf8_lossy(&result.stderr); |
| 95 | + let combined = format!("{}{}", stdout, stderr); |
| 96 | + |
| 97 | + // Count results from cargo test output |
| 98 | + let pass_count = combined.matches("... ok").count(); |
| 99 | + let fail_count = combined.matches("... FAILED").count(); |
| 100 | + let ignore_count = combined.matches("... ignored").count(); |
| 101 | + |
| 102 | + total_pass += pass_count as u32; |
| 103 | + total_fail += fail_count as u32; |
| 104 | + total_skip += ignore_count as u32; |
| 105 | + |
| 106 | + for proof in suite.proofs { |
| 107 | + let status = if fail_count == 0 { |
| 108 | + "PASS" |
| 109 | + } else { |
| 110 | + // Try to determine individual status from output |
| 111 | + // The test names in output don't map 1:1 to proof IDs, |
| 112 | + // so we report suite-level status |
| 113 | + "????" |
| 114 | + }; |
| 115 | + let icon = match status { |
| 116 | + "PASS" => "[OK]", |
| 117 | + "FAIL" => "[!!]", |
| 118 | + _ => "[??]", |
| 119 | + }; |
| 120 | + println!(" {} {}", icon, proof); |
| 121 | + } |
| 122 | + |
| 123 | + if fail_count > 0 { |
| 124 | + // Print failure details |
| 125 | + println!(); |
| 126 | + println!(" FAILURES:"); |
| 127 | + for line in combined.lines() { |
| 128 | + if line.contains("FAILED") || line.contains("panicked") { |
| 129 | + println!(" {}", line.trim()); |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | + } |
| 134 | + Err(e) => { |
| 135 | + println!(" ERROR: Could not run test suite: {}", e); |
| 136 | + total_fail += suite.proofs.len() as u32; |
| 137 | + for proof in suite.proofs { |
| 138 | + println!(" [!!] {}", proof); |
| 139 | + } |
| 140 | + } |
| 141 | + } |
| 142 | + println!(); |
| 143 | + } |
| 144 | + |
| 145 | + println!("=========================================================="); |
| 146 | + println!(" SUMMARY"); |
| 147 | + println!("=========================================================="); |
| 148 | + println!(" Total proofs: {}", total_pass + total_fail + total_skip); |
| 149 | + println!(" Passed: {}", total_pass); |
| 150 | + println!(" Failed: {}", total_fail); |
| 151 | + println!(" Skipped: {}", total_skip); |
| 152 | + println!(); |
| 153 | + |
| 154 | + if total_fail == 0 { |
| 155 | + println!(" ALL PROOFS PASSED"); |
| 156 | + } else { |
| 157 | + println!(" {} PROOF(S) FAILED", total_fail); |
| 158 | + std::process::exit(1); |
| 159 | + } |
| 160 | + |
| 161 | + println!("=========================================================="); |
| 162 | + println!(); |
| 163 | +} |
0 commit comments