feat: health consistency agent — 4 data integrity checks, GET /health/consistency

This commit is contained in:
Accusys
2026-05-19 02:17:27 +08:00
parent c95de97762
commit 538eea6406
4 changed files with 355 additions and 0 deletions

View File

@@ -865,6 +865,19 @@ async fn health_detailed(State(state): State<AppState>) -> Json<DetailedHealthRe
})
}
async fn health_consistency(
State(state): State<AppState>,
) -> Result<Json<crate::core::health_agent::ConsistencyReport>, (StatusCode, String)> {
let report = crate::core::health_agent::run_consistency_checks(&state.db).await;
if report.checks.iter().any(|c| c.count > 0) {
tracing::warn!(
"[HEALTH] Consistency issues found: {}",
report.checks.iter().filter(|c| c.count > 0).map(|c| format!("{}={}", c.check, c.count)).collect::<Vec<_>>().join(", ")
);
}
Ok(Json(report))
}
async fn login(
State(state): State<AppState>,
Json(req): Json<LoginRequest>,
@@ -3761,6 +3774,7 @@ pub async fn start_server(host: &str, port: u16) -> anyhow::Result<()> {
.merge(search_routes()) // Smart search drill-down
.merge(universal_search_routes()) // Universal / frames / persons search
.route("/health/detailed", get(health_detailed))
.route("/health/consistency", get(health_consistency))
.layer(axum::middleware::from_fn_with_state(
state.api_state.clone(),
unified_auth,