use serde::Serialize;
use truth::default_truth_store;

// Note: truth_router() was a stub wrapper around a single /context route
// that nothing called — v1/mod.rs wires get(truth::context) directly
// onto its own router. Removed 2026-04-24 along with its #[allow(dead_code)]
// attribute; the handler below is the real surface.

#[derive(Serialize)]
pub struct ContextResponse {
    pub task_classes: Vec<String>,
    pub rules: Vec<RuleInfo>,
}

#[derive(Serialize)]
pub struct RuleInfo {
    pub id: String,
    pub task_class: String,
    pub description: String,
}

pub async fn context() -> axum::Json<ContextResponse> {
    let store = default_truth_store();
    
    let task_classes: Vec<String> = vec![
        "staffing.fill".to_string(),
        "staffing.rescue".to_string(),
        "staffing.sms_draft".to_string(),
        "staffing.any".to_string(),
    ];
    
    let mut rules = Vec::new();
    for tc in &task_classes {
        for rule in store.get_rules(tc) {
            rules.push(RuleInfo {
                id: rule.id.clone(),
                task_class: rule.task_class.clone(),
                description: rule.description.clone(),
            });
        }
    }
    
    axum::Json(ContextResponse {
        task_classes,
        rules,
    })
}