clm-kernel 0.0.24

Cubical Logic Model (CLM) sovereign execution engine, CPN-VM, and Cordis spatiotemporal substrate
Documentation
//! Integration Test: Layer 0 Serde Loader against all 12 chapter directories.
//! Sprint 389 — DV-389-01.

use clm_rust_core::layer0::{ClmLoader, ParsedClmAst};
use std::path::PathBuf;

#[test]
fn test_clm_loader_parses_all_chapters() {
    let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
    let chapters_dir = manifest_dir
        .parent()
        .and_then(|p| p.parent())
        .map(|p| p.join("tests").join("chapters"))
        .unwrap_or_else(|| manifest_dir.join("../../tests/chapters"));

    assert!(chapters_dir.exists(), "tests/chapters directory must exist at {:?}", chapters_dir);

    let chapter_dirs = [
        "chapter_00_prologue",
        "chapter_01_arithmetic",
        "chapter_02_handle",
        "chapter_03_llm",
        "chapter_04_load_dir",
        "chapter_05_reflection",
        "chapter_06_lambda",
        "chapter_07_network",
        "chapter_08_P2P",
        "chapter_09_DSL",
        "chapter_10_service",
        "chapter_11_cicd",
    ];

    let mut total_parsed = 0;

    for ch in &chapter_dirs {
        let dir_path = chapters_dir.join(ch);
        if !dir_path.exists() {
            continue;
        }

        let results = ClmLoader::load_chapter_dir(&dir_path);
        assert!(results.is_ok(), "Failed to load chapter {}: {:?}", ch, results.err());

        let asts: Vec<ParsedClmAst> = results.unwrap();
        for ast in &asts {
            assert!(ast.content_hash.is_some(), "AST must compute content hash");
            let name = ast.display_name();
            assert!(!name.is_empty(), "AST must have non-empty display name");
            total_parsed += 1;
        }
    }

    println!("Successfully parsed {} CLM chapter manifests across 12 chapters!", total_parsed);
    assert!(total_parsed >= 20, "Expected at least 20 manifests parsed across chapters, got {}", total_parsed);
}