Skip to content

Commit 597939a

Browse files
authored
Merge pull request #101 from AdaWorldAPI/claude/code-review-SMMuY
feat: add 33 integration proofs verifying architectural claims
2 parents 1e87be8 + 428fea8 commit 597939a

8 files changed

Lines changed: 1814 additions & 4 deletions

File tree

.github/workflows/proof.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# =============================================================================
2+
# LadybugDB — Integration Proof Suite
3+
# =============================================================================
4+
# Runs the mathematical proof tests that verify ladybug-rs architectural
5+
# claims against the published literature (Berry-Esseen, NARS, Pearl, etc.)
6+
#
7+
# Three test suites:
8+
# proof_foundation — 13 proofs (F-1 through F-7c)
9+
# proof_reasoning_ladder — 8 proofs (RL-1 through RL-8)
10+
# proof_tactics — 12 proofs (T-01 through T-34)
11+
#
12+
# Total: 33 proofs verifying cognitive substrate invariants.
13+
# =============================================================================
14+
15+
name: Proof Suite
16+
17+
on:
18+
push:
19+
branches: [main]
20+
paths:
21+
- 'src/**'
22+
- 'tests/proof_*.rs'
23+
- 'Cargo.toml'
24+
- 'Cargo.lock'
25+
pull_request:
26+
branches: [main]
27+
paths:
28+
- 'src/**'
29+
- 'tests/proof_*.rs'
30+
- 'Cargo.toml'
31+
- 'Cargo.lock'
32+
workflow_dispatch:
33+
34+
env:
35+
CARGO_TERM_COLOR: always
36+
RUSTFLAGS: "-D warnings"
37+
38+
jobs:
39+
proof-foundation:
40+
name: Foundation Proofs (F-1 through F-7)
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: dtolnay/rust-toolchain@stable
45+
- uses: Swatinem/rust-cache@v2
46+
- name: Run foundation proofs
47+
run: cargo test --test proof_foundation -- --test-threads=1 -v
48+
49+
proof-reasoning-ladder:
50+
name: Reasoning Ladder Proofs (RL-1 through RL-8)
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
- uses: dtolnay/rust-toolchain@stable
55+
- uses: Swatinem/rust-cache@v2
56+
- name: Run reasoning ladder proofs
57+
run: cargo test --test proof_reasoning_ladder -- --test-threads=1 -v
58+
59+
proof-tactics:
60+
name: Tactics Proofs (T-01 through T-34)
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v4
64+
- uses: dtolnay/rust-toolchain@stable
65+
- uses: Swatinem/rust-cache@v2
66+
- name: Run tactics proofs
67+
run: cargo test --test proof_tactics -- --test-threads=1 -v
68+
69+
proof-summary:
70+
name: Proof Summary
71+
needs: [proof-foundation, proof-reasoning-ladder, proof-tactics]
72+
runs-on: ubuntu-latest
73+
if: always()
74+
steps:
75+
- name: Check results
76+
run: |
77+
echo "============================================"
78+
echo " LADYBUG-RS PROOF SUITE RESULTS"
79+
echo "============================================"
80+
echo ""
81+
echo " Foundation: ${{ needs.proof-foundation.result }}"
82+
echo " Reasoning Ladder: ${{ needs.proof-reasoning-ladder.result }}"
83+
echo " Tactics: ${{ needs.proof-tactics.result }}"
84+
echo ""
85+
if [ "${{ needs.proof-foundation.result }}" = "success" ] && \
86+
[ "${{ needs.proof-reasoning-ladder.result }}" = "success" ] && \
87+
[ "${{ needs.proof-tactics.result }}" = "success" ]; then
88+
echo " ALL PROOF SUITES PASSED"
89+
else
90+
echo " SOME PROOF SUITES FAILED"
91+
exit 1
92+
fi
93+
echo "============================================"

src/bin/proof_report.rs

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
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+
}

src/core/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
mod fingerprint;
44
pub mod simd;
5-
mod vsa;
5+
pub mod vsa;
66
mod buffer;
77
mod scent;
88

0 commit comments

Comments
 (0)