weavatrix-refactor-plan 0.1.1

Evidence metadata, validation profiles, and canonical fingerprints for Weavatrix refactor plans
Documentation
use std::path::{Path, PathBuf};

#[test]
fn production_modules_stay_within_300_lines() {
    let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("src");
    let mut pending = vec![root];
    let mut oversized = Vec::new();
    while let Some(directory) = pending.pop() {
        for entry in std::fs::read_dir(directory).unwrap() {
            let path = entry.unwrap().path();
            if path.is_dir() {
                pending.push(path);
            } else if path.extension().is_some_and(|value| value == "rs") {
                check_lines(&path, &mut oversized);
            }
        }
    }
    assert!(
        oversized.is_empty(),
        "production Rust modules exceed 300 lines: {oversized:?}"
    );
}

fn check_lines(path: &Path, oversized: &mut Vec<(PathBuf, usize)>) {
    let lines = std::fs::read_to_string(path).unwrap().lines().count();
    if lines > 300 {
        oversized.push((path.to_path_buf(), lines));
    }
}