#![cfg_attr(coverage_nightly, coverage(off))]
pub mod automation;
pub mod config;
pub mod enforcement;
pub mod enhanced_parser;
pub mod events;
pub mod foundation;
pub mod github_actions;
pub mod integration_tests;
pub mod intelligence;
pub mod metrics;
pub mod onboarding;
pub mod performance;
#[cfg(feature = "prometheus-metrics")]
pub mod prometheus_exporter;
use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::time::Duration;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub enum QualityMode {
Observe = 0,
Advise = 1,
Guide = 2,
Enforce = 3,
Extreme = 4,
}
impl QualityMode {
#[must_use]
pub fn recommended_progression() -> Vec<(Self, Duration)> {
vec![
(Self::Observe, Duration::from_secs(14 * 24 * 60 * 60)),
(Self::Advise, Duration::from_secs(30 * 24 * 60 * 60)),
(Self::Guide, Duration::from_secs(60 * 24 * 60 * 60)),
(Self::Enforce, Duration::from_secs(90 * 24 * 60 * 60)),
]
}
}
pub struct ProductionSystem {
pub monitor: foundation::QualityMonitor,
pub assistant: intelligence::QualityAssistant,
pub enforcer: enforcement::ErrorBudgetEnforcer,
pub automator: automation::ConservativeAutomator,
}
pub struct ResearchSystem {
pub property_synthesizer: Option<Box<dyn PropertySynthesizer>>,
pub formal_verifier: Option<Box<dyn FormalVerifier>>,
pub ml_refactorer: Option<Box<dyn MLRefactorer>>,
pub autonomous_agent: Option<Box<dyn AutonomousAgent>>,
}
pub trait PropertySynthesizer: Send + Sync {
fn synthesize_properties(&self, func: &str) -> Vec<String>;
fn infer_invariants(&self, traces: &[String]) -> Vec<String>;
fn regression_properties(&self, bug: &str) -> Vec<String>;
}
pub trait FormalVerifier: Send + Sync {
fn verify_complexity_bound(&self, ast: &str, bound: u32) -> bool;
fn verify_equivalence(&self, before: &str, after: &str) -> bool;
fn verify_no_panics(&self, func: &str) -> bool;
}
pub trait MLRefactorer: Send + Sync {
fn train(&mut self, examples: &[(String, String, f64)]);
fn suggest_refactoring(&self, code: &str) -> Vec<String>;
fn predict_success(&self, refactoring: &str) -> f64;
}
pub trait AutonomousAgent: Send + Sync {
fn plan_campaign(&self, codebase: &str) -> String;
fn execute_campaign(&self, campaign: &str) -> Result<()>;
fn update_model(&mut self, outcome: &str);
}
pub struct UnifiedQualitySystem {
pub production: ProductionSystem,
pub research: ResearchSystem,
pub philosophy: QualityPhilosophy,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QualityPhilosophy {
pub immediate_value: bool,
pub human_centric: bool,
pub gradual_adoption: bool,
pub continuous_learning: bool,
}
impl Default for QualityPhilosophy {
fn default() -> Self {
Self {
immediate_value: true,
human_centric: true,
gradual_adoption: true,
continuous_learning: true,
}
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_quality_mode_progression() {
let progression = QualityMode::recommended_progression();
assert_eq!(progression.len(), 4);
assert_eq!(progression[0].0, QualityMode::Observe);
assert_eq!(progression[3].0, QualityMode::Enforce);
}
#[test]
fn test_quality_philosophy_default() {
let philosophy = QualityPhilosophy::default();
assert!(philosophy.immediate_value);
assert!(philosophy.human_centric);
assert!(philosophy.gradual_adoption);
assert!(philosophy.continuous_learning);
}
}