#![allow(clippy::disallowed_methods)]
use std::path::Path;
#[test]
fn p1_long_term_philosophy_documented() {
let claude_md = include_str!("../CLAUDE.md");
let has_architecture_docs = claude_md.contains("Sovereign")
|| claude_md.contains("Architecture")
|| claude_md.contains("realizar")
|| claude_md.contains("trueno");
assert!(
has_architecture_docs,
"P1 FALSIFIED: No long-term architecture philosophy documented in CLAUDE.md"
);
}
#[test]
fn p1b_architecture_specs_exist() {
let spec_dir = Path::new("docs/specifications");
assert!(
spec_dir.exists(),
"P1 FALSIFIED: No specifications directory exists"
);
let has_specs = std::fs::read_dir(spec_dir)
.map(|entries| entries.filter_map(Result::ok).count() > 0)
.unwrap_or(false);
assert!(has_specs, "P1 FALSIFIED: No specification files found");
}
#[test]
fn p2_continuous_flow_streaming() {
let has_stream_module = Path::new("src/audio/stream.rs").exists();
let lib_rs = include_str!("../src/lib.rs");
let has_streaming_ref = lib_rs.contains("stream") || lib_rs.contains("chunk");
assert!(
has_stream_module || has_streaming_ref,
"P2 FALSIFIED: No streaming architecture found"
);
}
#[test]
fn p3_pull_system_lazy_loading() {
let cargo_toml = include_str!("../Cargo.toml");
let has_mmap = cargo_toml.contains("memmap2");
let v2_has_lazy = Path::new("src/format/v2.rs").exists();
assert!(
has_mmap || v2_has_lazy,
"P3 FALSIFIED: No lazy loading (pull system) capability found"
);
}
#[test]
fn p4_heijunka_level_workload() {
let mel_path = Path::new("src/audio/mel.rs");
if mel_path.exists() {
let mel_rs = std::fs::read_to_string(mel_path).expect("Failed to read mel.rs");
let has_chunking =
mel_rs.contains("chunk") || mel_rs.contains("hop_length") || mel_rs.contains("frame");
assert!(
has_chunking,
"P4 FALSIFIED: Audio processing lacks chunk-based workload leveling"
);
}
}
#[test]
fn p5_jidoka_quality_gates() {
let ci_path = Path::new(".github/workflows/ci.yml");
assert!(ci_path.exists(), "P5 FALSIFIED: No CI configuration found");
let ci_config = std::fs::read_to_string(ci_path).expect("read ci.yml");
let has_tests = ci_config.contains("cargo test");
let has_clippy = ci_config.contains("clippy");
assert!(
has_tests && has_clippy,
"P5 FALSIFIED: CI lacks quality gates (tests: {}, clippy: {})",
has_tests,
has_clippy
);
}
#[test]
fn p5b_validate_command_exists() {
let validate_path = Path::new("crates/apr-cli/src/commands/validate.rs");
assert!(
validate_path.exists(),
"P5 FALSIFIED: No validate command implementation"
);
}
#[test]
fn p6_standardized_tasks_makefile() {
let makefile_path = Path::new("Makefile");
assert!(makefile_path.exists(), "P6 FALSIFIED: No Makefile found");
let makefile = std::fs::read_to_string(makefile_path).expect("read Makefile");
let has_test = makefile.contains("test:");
let has_build = makefile.contains("build:") || makefile.contains("release:");
assert!(
has_test || has_build,
"P6 FALSIFIED: Makefile lacks standard targets"
);
}
#[test]
fn p6b_cargo_workflows_documented() {
let claude_md = include_str!("../CLAUDE.md");
let has_cargo_docs = claude_md.contains("cargo build")
|| claude_md.contains("cargo test")
|| claude_md.contains("Build Commands");
assert!(
has_cargo_docs,
"P6 FALSIFIED: Cargo workflows not documented in CLAUDE.md"
);
}
#[test]
fn p7_visual_control_inspection() {
let inspect_exists = Path::new("crates/apr-cli/src/commands/inspect.rs").exists();
let debug_exists = Path::new("crates/apr-cli/src/commands/debug.rs").exists();
assert!(
inspect_exists || debug_exists,
"P7 FALSIFIED: No visual inspection tools (inspect.rs or debug.rs)"
);
}
#[test]
fn p8_reliable_technology_rust() {
let cargo_toml = Path::new("Cargo.toml");
assert!(
cargo_toml.exists(),
"P8 FALSIFIED: Not a Rust project (no Cargo.toml)"
);
let cargo_content = include_str!("../Cargo.toml");
assert!(
cargo_content.contains("edition = "),
"P8 FALSIFIED: Invalid Cargo.toml (no edition)"
);
}
#[test]
fn p8b_no_unsafe_code() {
let cargo_toml = include_str!("../Cargo.toml");
let forbids_unsafe = cargo_toml.contains("unsafe_code")
&& (cargo_toml.contains("forbid") || cargo_toml.contains("deny"));
assert!(
forbids_unsafe,
"P8 FALSIFIED: unsafe_code is not forbidden in Cargo.toml lints"
);
}
#[test]
fn p9_grow_leaders_documentation() {
let has_book = Path::new("book").exists();
let has_docs = Path::new("docs").exists();
let has_readme = Path::new("README.md").exists();
assert!(
has_book || has_docs || has_readme,
"P9 FALSIFIED: No documentation for learning"
);
}
#[test]
fn p10_develop_people_guidelines() {
let has_contributing = Path::new("CONTRIBUTING.md").exists();
let has_claude_md = Path::new("CLAUDE.md").exists();
assert!(
has_contributing || has_claude_md,
"P10 FALSIFIED: No contributor guidelines (CONTRIBUTING.md or CLAUDE.md)"
);
}
#[test]
fn p11_respect_partners_license() {
let has_license = Path::new("LICENSE").exists()
|| Path::new("LICENSE.md").exists()
|| Path::new("LICENSE-MIT").exists()
|| Path::new("LICENSE-APACHE").exists();
assert!(
has_license,
"P11 FALSIFIED: No license file (partner respect requires clear licensing)"
);
}
#[test]
fn p11b_dependencies_credited() {
let cargo_toml = include_str!("../Cargo.toml");
assert!(
cargo_toml.contains("[dependencies]"),
"P11 FALSIFIED: No dependencies section (all partners should be tracked)"
);
}
#[test]
fn p12_genchi_genbutsu_debugging() {
let has_debug = Path::new("crates/apr-cli/src/commands/debug.rs").exists();
let has_trace = Path::new("crates/apr-cli/src/commands/trace.rs").exists();
let has_profile = Path::new("crates/apr-cli/src/commands/profile.rs").exists();
assert!(
has_debug || has_trace || has_profile,
"P12 FALSIFIED: No debugging/profiling tools (genchi genbutsu requires seeing)"
);
}
#[test]
fn p13_decide_slowly_versioned_spec() {
let spec_path =
Path::new("docs/specifications/archive/apr-whisper-and-cookbook-support-eoy-2025.md");
if spec_path.exists() {
let spec = std::fs::read_to_string(spec_path).expect("read spec");
let has_version = spec.contains("v1.")
|| spec.contains("v2.")
|| spec.contains("v3.")
|| spec.contains("version");
assert!(
has_version,
"P13 FALSIFIED: Specification lacks version history (decisions should be deliberate)"
);
}
}
#[test]
fn p14_hansei_reflection() {
let spec_path =
Path::new("docs/specifications/archive/apr-whisper-and-cookbook-support-eoy-2025.md");
if spec_path.exists() {
let spec = std::fs::read_to_string(spec_path).expect("read spec");
let has_issue_refs = spec.contains("GH-") || spec.contains("github.com");
assert!(
has_issue_refs,
"P14 FALSIFIED: No issue tracking references (hansei requires reflection on problems)"
);
}
}
#[test]
fn p14b_change_history() {
let has_changelog = Path::new("CHANGELOG.md").exists()
|| Path::new("CHANGES.md").exists()
|| Path::new("HISTORY.md").exists();
let has_git = Path::new(".git").exists();
assert!(
has_changelog || has_git,
"P14 FALSIFIED: No change history (hansei requires learning from past)"
);
}
#[test]
fn toyota_principles_summary() {
let principles = [
"P1: Long-Term Philosophy - ✅ Documented architecture",
"P2: Continuous Flow - ✅ Streaming architecture",
"P3: Pull Systems - ✅ Lazy/mmap loading",
"P4: Level Workload - ✅ Chunk-based processing",
"P5: Stop to Fix - ✅ CI quality gates",
"P6: Standardized Tasks - ✅ Makefile + docs",
"P7: Visual Control - ✅ Inspect/debug tools",
"P8: Reliable Technology - ✅ Rust + no unsafe",
"P9: Grow Leaders - ✅ Documentation",
"P10: Develop People - ✅ Contributor guides",
"P11: Respect Partners - ✅ Licensing",
"P12: Go and See - ✅ Debugging tools",
"P13: Decide Slowly - ✅ Versioned specs",
"P14: Relentless Reflection - ✅ Issue tracking",
];
for p in &principles {
eprintln!("{}", p);
}
assert_eq!(principles.len(), 14, "Should verify all 14 principles");
}