From c9f509e161f5fdd0f0e54ded61eb2bc829e3fbc1 Mon Sep 17 00:00:00 2001 From: cflmy Date: Sat, 21 Nov 2026 17:10:13 +0800 Subject: [PATCH] test(cli): guard the platform-neutral strict child boundary Add an architecture test that rejects direct marker_present/verify_active references from the CLI and keeps the Linux-only functions out of the marqdo-sandbox crate root. Windows cross-target cargo check now compiles the whole workspace (macOS cross-check is blocked only by ring's Darwin C/asm build on this Linux host; its cfg(not(linux)) path is the same one Windows exercises). This completes the step 3 verification for the CI/security RFC B01. --- crates/cli/tests/architecture_boundaries.rs | 51 +++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/crates/cli/tests/architecture_boundaries.rs b/crates/cli/tests/architecture_boundaries.rs index 9e03449..94231a4 100644 --- a/crates/cli/tests/architecture_boundaries.rs +++ b/crates/cli/tests/architecture_boundaries.rs @@ -221,3 +221,54 @@ fn tree_digest(root: &Path) -> Result { } Ok(hex::encode(hasher.finalize())) } + +/// The CLI must consume the platform-neutral strict-child API. Direct use of +/// the Linux-only `marker_present`/`verify_active` symbols reintroduces the +/// macOS/Windows `E0425` build break (RFC-CI-0001 B01). +#[test] +fn cli_uses_only_the_platform_neutral_strict_child_api() { + let root = repo_root(); + let run = read(&root.join("crates/cli/src/commands/run.rs")); + assert!( + run.contains("inspect_strict_child"), + "run.rs must use marqdo_sandbox::inspect_strict_child" + ); + for source in walk_rs(&root.join("crates/cli/src")) { + let text = read(&source); + for forbidden in ["marker_present", "verify_active"] { + assert!( + !text.contains(forbidden), + "{} references Linux-only `{forbidden}`; use StrictChildState instead", + source.display() + ); + } + } + let sandbox = read(&root.join("crates/marqdo-sandbox/src/lib.rs")); + assert!( + sandbox.contains("pub fn inspect_strict_child"), + "the sandbox crate must expose inspect_strict_child" + ); + assert!( + !sandbox.contains("pub use linux::{marker_present"), + "the Linux-only marker functions must not be re-exported from the crate root" + ); +} + +fn walk_rs(root: &Path) -> Vec { + let mut files = Vec::new(); + let mut stack = vec![root.to_path_buf()]; + while let Some(directory) = stack.pop() { + let entries = std::fs::read_dir(&directory) + .unwrap_or_else(|error| panic!("read_dir {}: {error}", directory.display())); + for entry in entries { + let entry = entry.expect("directory entry"); + let path = entry.path(); + if path.is_dir() { + stack.push(path); + } else if path.extension().and_then(|value| value.to_str()) == Some("rs") { + files.push(path); + } + } + } + files +}