pub struct HealthScore {
pub total_checks: u32,
pub passed: u32,
pub warnings: u32,
pub failed: u32,
pub percentage: u32,
pub overall_status: HealthStatus,
}Expand description
A quantitative summary of environment health.
use limitless_cli::models::{CheckStatus, DiagnosticResult, HealthScore, HealthStatus};
let checks = vec![
DiagnosticResult::new("Runtime Check", CheckStatus::Pass, "Node found"),
DiagnosticResult::new("Env Audit", CheckStatus::Warn, "1 missing var"),
DiagnosticResult::new("Port Scan", CheckStatus::Fail, "8080 blocked"),
];
let score = HealthScore::from_results(&checks);
assert_eq!(score.total_checks, 3);
assert_eq!(score.percentage, 33);
assert_eq!(score.overall_status, HealthStatus::Critical);
assert!(score.validate().is_ok());Fields§
§total_checks: u32Total number of checks performed.
passed: u32Number of checks that passed.
warnings: u32Number of checks that warned.
failed: u32Number of checks that failed.
percentage: u32Overall score as a percentage (0–100). 100 when no checks ran.
overall_status: HealthStatusAggregate classification derived from percentage.
Implementations§
Source§impl HealthScore
impl HealthScore
Sourcepub fn from_results(results: &[DiagnosticResult]) -> Self
pub fn from_results(results: &[DiagnosticResult]) -> Self
Computes a HealthScore from a slice of results.
percentage = round(passed / total * 100)Healthywhen percentage ≥ 85Cautionwhen percentage ≥ 60Criticalotherwise
Sourcepub fn from_counts(passed: u32, warnings: u32, failed: u32) -> Self
pub fn from_counts(passed: u32, warnings: u32, failed: u32) -> Self
Computes a HealthScore from raw check counts.
Sourcepub fn recompute(self) -> Self
pub fn recompute(self) -> Self
Recomputes derived fields from total_checks, passed,
warnings, and failed. This is the canonical way to rebuild a
deserialized score whose percentage/overall_status may be stale.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validates internal consistency. Returns an error message when the
counts do not sum to total_checks, percentage is out of range,
or percentage does not match the pass ratio.
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Whether the overall status is HealthStatus::Healthy.