//! Standalone quality-matrix runner for THIS repo (knut).
//!
//! Runs the reusable `nornir-testmatrix` engine over the current directory,
//! persists the rows to `target/quality-matrix.jsonl`, and prints the rendered
//! human matrix. A human or CI can get knut's own quality matrix with:
//!
//! ```text
//! cargo run -p knut-bifrost --example quality_matrix
//! ```
//!
//! NOTE: this shells `cargo build/test/clippy/...` under the hood (one process
//! per aspect), so it is intentionally NOT part of `cargo test` — running
//! cargo-inside-cargo is slow and recursive. Run it on demand only.

use std::path::Path;

use nornir_testmatrix::{render_matrix, Aspect, JsonFileSink, TestSink};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let repo_root = Path::new(".");

    eprintln!("running quality matrix (Aspect::DEFAULT) over {repo_root:?} ...");
    let rows = nornir_testmatrix::run_full_matrix(repo_root, Aspect::DEFAULT);

    let out_path = Path::new("target").join("quality-matrix.jsonl");
    let sink = JsonFileSink::new(&out_path);
    sink.append(&rows)?;
    eprintln!("wrote {} rows -> {}", rows.len(), out_path.display());

    println!("{}", render_matrix(&rows));
    Ok(())
}
