adze_governance_runtime_core/
lib.rs1#![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_governance_runtime_profile_core::{
16 ParserBackend, ParserFeatureProfile, parser_feature_profile_for_runtime,
17 parser_feature_profile_for_runtime2, resolve_backend_for_profile,
18};
19pub use adze_governance_runtime_reporting::{
20 BddGovernanceMatrix, BddGovernanceSnapshot, BddPhase, BddScenario, BddScenarioStatus,
21 GLR_CONFLICT_FALLBACK, GLR_CONFLICT_PRESERVATION_GRID, bdd_governance_snapshot, bdd_progress,
22 bdd_progress_report, bdd_progress_report_with_profile,
23 bdd_progress_report_with_profile_runtime, bdd_progress_status_line,
24 describe_backend_for_conflicts,
25};
26
27pub fn bdd_progress_report_for_profile(
29 phase: BddPhase,
30 phase_title: &str,
31 profile: ParserFeatureProfile,
32) -> String {
33 BddGovernanceMatrix::new(phase, profile, GLR_CONFLICT_PRESERVATION_GRID).report(phase_title)
34}
35
36pub const fn bdd_governance_matrix_for_profile(
38 phase: BddPhase,
39 profile: ParserFeatureProfile,
40) -> BddGovernanceMatrix {
41 BddGovernanceMatrix::new(phase, profile, GLR_CONFLICT_PRESERVATION_GRID)
42}
43
44pub const fn bdd_governance_matrix_for_runtime() -> BddGovernanceMatrix {
46 bdd_governance_matrix_for_profile(BddPhase::Runtime, parser_feature_profile_for_runtime())
47}
48
49pub const fn bdd_governance_matrix_for_runtime2(
51 phase: BddPhase,
52 pure_rust_glr: bool,
53) -> BddGovernanceMatrix {
54 bdd_governance_matrix_for_profile(phase, parser_feature_profile_for_runtime2(pure_rust_glr))
55}
56
57pub fn bdd_progress_status_line_for_profile(
59 phase: BddPhase,
60 profile: ParserFeatureProfile,
61) -> String {
62 bdd_governance_matrix_for_profile(phase, profile).status_line()
63}
64
65#[cfg(test)]
66mod tests {
67 use super::*;
68
69 #[test]
70 fn profile_backend_helper_matches_report_apis() {
71 let profile = parser_feature_profile_for_runtime2(true);
72 let report = bdd_progress_report_for_profile(BddPhase::Runtime, "Runtime", profile);
73 let status = bdd_progress_status_line_for_profile(BddPhase::Runtime, profile);
74
75 assert!(report.contains("Runtime"));
76 assert!(status.contains("runtime:"));
77 }
78
79 #[test]
80 fn bdd_governance_matrix_for_runtime_uses_runtime_phase() {
81 let matrix = bdd_governance_matrix_for_runtime();
82 assert_eq!(matrix.phase, BddPhase::Runtime);
83 assert_eq!(matrix.profile, parser_feature_profile_for_runtime());
84 assert!(!matrix.scenarios.is_empty());
85 }
86
87 #[test]
88 fn bdd_governance_matrix_for_runtime2_both_toggles() {
89 let enabled = bdd_governance_matrix_for_runtime2(BddPhase::Core, true);
90 assert_eq!(enabled.phase, BddPhase::Core);
91 assert!(enabled.profile.glr);
92 assert!(enabled.profile.pure_rust);
93
94 let disabled = bdd_governance_matrix_for_runtime2(BddPhase::Runtime, false);
95 assert_eq!(disabled.phase, BddPhase::Runtime);
96 assert!(!disabled.profile.glr);
97 assert!(!disabled.profile.pure_rust);
98 }
99
100 #[test]
101 fn bdd_governance_matrix_for_profile_with_both_phases() {
102 let profile = ParserFeatureProfile::current();
103 let core = bdd_governance_matrix_for_profile(BddPhase::Core, profile);
104 let runtime = bdd_governance_matrix_for_profile(BddPhase::Runtime, profile);
105 assert_eq!(core.phase, BddPhase::Core);
106 assert_eq!(runtime.phase, BddPhase::Runtime);
107 assert_eq!(core.profile, runtime.profile);
108 }
109
110 #[test]
111 fn bdd_progress_status_line_for_profile_format() {
112 let profile = parser_feature_profile_for_runtime2(false);
113 let core_status = bdd_progress_status_line_for_profile(BddPhase::Core, profile);
114 let runtime_status = bdd_progress_status_line_for_profile(BddPhase::Runtime, profile);
115 assert!(core_status.starts_with("core:"));
116 assert!(runtime_status.starts_with("runtime:"));
117 }
118
119 #[test]
120 fn bdd_progress_report_for_profile_includes_title() {
121 let profile = parser_feature_profile_for_runtime2(true);
122 let report = bdd_progress_report_for_profile(BddPhase::Core, "Core GLR", profile);
123 assert!(report.contains("Core GLR"));
124 }
125
126 #[test]
127 fn runtime2_profile_tree_sitter_flags_are_off() {
128 let profile = parser_feature_profile_for_runtime2(true);
129 assert!(!profile.tree_sitter_standard);
130 assert!(!profile.tree_sitter_c2rust);
131
132 let profile_off = parser_feature_profile_for_runtime2(false);
133 assert!(!profile_off.tree_sitter_standard);
134 assert!(!profile_off.tree_sitter_c2rust);
135 }
136}