Skip to main content

mongreldb_core/
certification.rs

1//! Production certification harness inventory (spec section 14.6, Stage 5F).
2//!
3//! Enumerates the required test classes and points at the in-repo suites that
4//! satisfy them. This module is not a test runner — it is a durable checklist
5//! the Stage 5 gate and operators can query.
6
7use serde::{Deserialize, Serialize};
8
9/// One certification class from spec §14.6.
10#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
11pub struct CertificationClass {
12    /// Class name.
13    pub name: &'static str,
14    /// Spec category.
15    pub category: CertificationCategory,
16    /// In-repo evidence paths (tests, workflows, benches).
17    pub evidence: &'static [&'static str],
18    /// Whether a smoke entry point exists in-tree today.
19    pub smoke_ready: bool,
20}
21
22/// Top-level certification category.
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
24pub enum CertificationCategory {
25    /// Unit/property tests.
26    UnitProperty,
27    /// Fuzz targets.
28    Fuzz,
29    /// Crash-at-hook matrix.
30    CrashHooks,
31    /// Consensus simulation.
32    ConsensusSim,
33    /// Reference-model transaction checker.
34    TxnChecker,
35    /// Chaos cluster.
36    Chaos,
37    /// Performance suites with provenance.
38    Perf,
39}
40
41/// The full inventory of certification classes.
42pub fn certification_inventory() -> Vec<CertificationClass> {
43    vec![
44        CertificationClass {
45            name: "encoding_round_trips",
46            category: CertificationCategory::UnitProperty,
47            evidence: &[
48                "crates/mongreldb-log/tests/envelope.rs",
49                "crates/mongreldb-types",
50            ],
51            smoke_ready: true,
52        },
53        CertificationClass {
54            name: "mvcc_visibility",
55            category: CertificationCategory::UnitProperty,
56            evidence: &["crates/mongreldb-core/tests/isolation.rs"],
57            smoke_ready: true,
58        },
59        CertificationClass {
60            name: "timestamp_ordering",
61            category: CertificationCategory::UnitProperty,
62            evidence: &[
63                "crates/mongreldb-types/src/hlc.rs",
64                "crates/mongreldb-consensus/tests/hlc_monotonicity.rs",
65            ],
66            smoke_ready: true,
67        },
68        CertificationClass {
69            name: "routing",
70            category: CertificationCategory::UnitProperty,
71            evidence: &[
72                "crates/mongreldb-cluster/src/tablet.rs",
73                "crates/mongreldb-cluster/src/routing.rs",
74            ],
75            smoke_ready: true,
76        },
77        CertificationClass {
78            name: "transaction_state_machine",
79            category: CertificationCategory::UnitProperty,
80            evidence: &[
81                "crates/mongreldb-core/tests/txn_*.rs",
82                "crates/mongreldb-cluster/src/dist_txn.rs",
83            ],
84            smoke_ready: true,
85        },
86        CertificationClass {
87            name: "catalog_mutations",
88            category: CertificationCategory::UnitProperty,
89            evidence: &["crates/mongreldb-core/tests/catalog_commands.rs"],
90            smoke_ready: true,
91        },
92        CertificationClass {
93            name: "protocol_decode_fuzz",
94            category: CertificationCategory::Fuzz,
95            evidence: &["crates/mongreldb-protocol/src/envelope.rs"],
96            smoke_ready: true,
97        },
98        CertificationClass {
99            name: "wal_log_decode",
100            category: CertificationCategory::Fuzz,
101            evidence: &["crates/mongreldb-core/tests/fault_injection.rs"],
102            smoke_ready: true,
103        },
104        CertificationClass {
105            name: "snapshot_decode",
106            category: CertificationCategory::Fuzz,
107            evidence: &["crates/mongreldb-consensus/src/state_machine.rs"],
108            smoke_ready: true,
109        },
110        CertificationClass {
111            name: "crash_at_hooks",
112            category: CertificationCategory::CrashHooks,
113            evidence: &[
114                "crates/mongreldb-fault",
115                "crates/mongreldb-cluster/src/split.rs",
116                "crates/mongreldb-cluster/src/merge.rs",
117                "crates/mongreldb-cluster/src/cluster_backup.rs",
118            ],
119            smoke_ready: true,
120        },
121        CertificationClass {
122            name: "consensus_sim",
123            category: CertificationCategory::ConsensusSim,
124            evidence: &[
125                "crates/mongreldb-sim",
126                "crates/mongreldb-consensus/tests/chaos.rs",
127            ],
128            smoke_ready: true,
129        },
130        CertificationClass {
131            name: "reference_model_txn_checker",
132            category: CertificationCategory::TxnChecker,
133            evidence: &[
134                "crates/mongreldb-core/tests/isolation.rs",
135                "crates/mongreldb-cluster/src/dist_txn.rs",
136            ],
137            smoke_ready: true,
138        },
139        CertificationClass {
140            name: "chaos_cluster",
141            category: CertificationCategory::Chaos,
142            evidence: &[
143                "crates/mongreldb-consensus/tests/chaos.rs",
144                "crates/mongreldb-cluster/tests/runtime.rs",
145            ],
146            smoke_ready: true,
147        },
148        CertificationClass {
149            name: "perf_oltp_mixed",
150            category: CertificationCategory::Perf,
151            evidence: &[
152                "BENCHMARKS.md",
153                "crates/mongreldb-core/tests/qualification.rs",
154            ],
155            smoke_ready: true,
156        },
157        CertificationClass {
158            name: "perf_ai_rag",
159            category: CertificationCategory::Perf,
160            evidence: &[
161                "crates/mongreldb-core/examples/ai_retrieval_bench.rs",
162                "BENCHMARKS.md",
163            ],
164            smoke_ready: true,
165        },
166    ]
167}
168
169/// Smoke: every class is named and at least one evidence path is non-empty.
170pub fn inventory_smoke() -> Result<(), String> {
171    let inv = certification_inventory();
172    if inv.is_empty() {
173        return Err("empty certification inventory".into());
174    }
175    for c in &inv {
176        if c.name.is_empty() {
177            return Err("unnamed certification class".into());
178        }
179        if c.evidence.is_empty() {
180            return Err(format!("{} has no evidence paths", c.name));
181        }
182    }
183    Ok(())
184}
185
186#[cfg(test)]
187mod tests {
188    use super::*;
189
190    #[test]
191    fn inventory_covers_required_categories() {
192        inventory_smoke().unwrap();
193        let inv = certification_inventory();
194        for cat in [
195            CertificationCategory::UnitProperty,
196            CertificationCategory::Fuzz,
197            CertificationCategory::CrashHooks,
198            CertificationCategory::ConsensusSim,
199            CertificationCategory::TxnChecker,
200            CertificationCategory::Chaos,
201            CertificationCategory::Perf,
202        ] {
203            assert!(
204                inv.iter().any(|c| c.category == cat),
205                "missing category {cat:?}"
206            );
207        }
208        assert!(inv.iter().all(|c| c.smoke_ready));
209    }
210}