Skip to main content

adze_runtime_governance_api/
lib.rs

1//! Runtime-facing governance API for parser selection and BDD snapshot reporting.
2//!
3//! This crate intentionally keeps parser/backend selection and feature-flag
4//! diagnostics in one place, so downstream crates (runtime, runtime2,
5//! adapters, and fixtures) can share a stable surface.
6
7#![forbid(unsafe_op_in_unsafe_fn)]
8#![deny(missing_docs)]
9#![cfg_attr(feature = "strict_api", deny(unreachable_pub))]
10#![cfg_attr(not(feature = "strict_api"), warn(unreachable_pub))]
11#![cfg_attr(feature = "strict_docs", deny(missing_docs))]
12#![cfg_attr(not(feature = "strict_docs"), allow(missing_docs))]
13
14pub use adze_runtime_governance::{
15    BddGovernanceSnapshot, BddPhase, BddScenario, BddScenarioStatus,
16    GLR_CONFLICT_PRESERVATION_GRID, ParserBackend, ParserFeatureProfile,
17    bdd_governance_matrix_for_current_profile, bdd_governance_matrix_for_profile,
18    bdd_governance_matrix_for_runtime, bdd_governance_matrix_for_runtime2,
19    bdd_governance_matrix_for_runtime2_profile, bdd_progress_report_for_current_profile,
20    bdd_status_line_for_current_profile, current_backend_for, parser_feature_profile_for_runtime,
21    resolve_backend_for_profile, runtime_governance_snapshot,
22};
23
24pub use adze_runtime_governance::{
25    GLR_CONFLICT_FALLBACK, bdd_governance_snapshot, bdd_progress, bdd_progress_report,
26    bdd_progress_report_with_profile, bdd_progress_report_with_profile_runtime,
27    bdd_progress_status_line, describe_backend_for_conflicts,
28};
29
30#[cfg(test)]
31mod tests {
32    use super::*;
33
34    #[test]
35    fn current_backend_matches_selection_logic() {
36        assert_eq!(current_backend_for(false), ParserBackend::select(false));
37
38        #[cfg(feature = "glr")]
39        {
40            assert_eq!(current_backend_for(true), ParserBackend::select(true));
41        }
42    }
43
44    #[test]
45    fn current_profile_helpers_are_callable() {
46        let report = bdd_progress_report_for_current_profile(BddPhase::Runtime, "Runtime");
47        assert!(report.contains("Runtime"));
48        assert!(report.contains("Governance status:"));
49
50        let status = bdd_status_line_for_current_profile(BddPhase::Runtime);
51        assert!(status.starts_with("runtime:"));
52
53        let profile = parser_feature_profile_for_runtime();
54        let snapshot = runtime_governance_snapshot(BddPhase::Runtime);
55        assert_eq!(snapshot.profile, profile);
56    }
57
58    #[test]
59    fn current_profile_matches_cfg() {
60        let profile = parser_feature_profile_for_runtime();
61        assert_eq!(profile.pure_rust, cfg!(feature = "pure-rust"));
62        assert_eq!(
63            profile.tree_sitter_standard,
64            cfg!(feature = "tree-sitter-standard")
65        );
66        assert_eq!(
67            profile.tree_sitter_c2rust,
68            cfg!(feature = "tree-sitter-c2rust")
69        );
70        assert_eq!(profile.glr, cfg!(feature = "glr"));
71    }
72
73    #[test]
74    fn status_line_is_stable_shape() {
75        let status = bdd_status_line_for_current_profile(BddPhase::Runtime);
76        let profile = parser_feature_profile_for_runtime();
77        assert!(status.contains("runtime"));
78        assert!(status.contains(&format!("{}", profile)));
79    }
80}