//! Smoke test for Phase 9 LlmEngine::extract_content_tags.
//!
//! Gated behind the same `LUMOTIA_LLM_TEST_MODEL` env var as the existing
//! smoke.rs test so neither runs in default `cargo test` runs (model
//! load is heavy). Run explicitly with:
//!
//!     LUMOTIA_LLM_TEST_MODEL=/path/to/model.gguf cargo test -p lumotia-llm \
//!         --test content_tags_smoke -- --nocapture

use std::env;
use std::path::PathBuf;

use lumotia_llm::{is_valid_intent, LlmEngine, LlmModelId};

#[test]
fn extract_content_tags_returns_valid_pair() {
    let model_path = match env::var("LUMOTIA_LLM_TEST_MODEL") {
        Ok(path) => PathBuf::from(path),
        Err(_) => {
            eprintln!("LUMOTIA_LLM_TEST_MODEL not set — skipping");
            return;
        }
    };

    let engine = LlmEngine::new();
    engine
        .load_model(LlmModelId::Qwen3_5_2B_Q4, &model_path, true)
        .expect("load model");

    let transcript = "Tomorrow I need to run through the grant application one more time \
                      and make sure the figures add up. I also need to book a slot with \
                      Rachmann for the Mac test and email Andrew about the meeting window.";
    let tags = engine
        .extract_content_tags(transcript)
        .expect("extract_content_tags");

    assert!(tags.topic.len() >= 3, "topic present: {tags:?}");
    assert!(
        tags.topic
            .chars()
            .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '-'),
        "topic lowercase + slugged: {tags:?}",
    );
    assert!(
        is_valid_intent(&tags.intent),
        "intent in closed set: {tags:?}",
    );
}
