diff --git a/crates/xtask/src/main.rs b/crates/xtask/src/main.rs index e988fd07..2b6e3004 100644 --- a/crates/xtask/src/main.rs +++ b/crates/xtask/src/main.rs @@ -19,6 +19,7 @@ use std::path::{Path, PathBuf}; mod bench; mod binedge; mod binnames; +mod brainread; mod diskfloor; mod perjob; mod pickaudit; @@ -52,6 +53,7 @@ fn main() { check_phase_a_profile_parity(); check_operator_text_space_runs(); check_unique_bin_names(); + check_brain_read_policy(); eprintln!("xtask check: OK"); } // "site" (the Pages publish-tree assembler) RETIRED with the public @@ -216,10 +218,7 @@ mod cli_reference_tests { #[test] fn api_standin_injects_once_at_any_depth_and_only_for_the_root_verb() { assert_eq!(help_args(&path(&["seal"])), path(&["seal"])); - assert_eq!( - help_args(&path(&["api"])), - path(&["api", "--adapter", "x"]) - ); + assert_eq!(help_args(&path(&["api"])), path(&["api", "--adapter", "x"])); assert_eq!( help_args(&path(&["api", "seal"])), path(&["api", "--adapter", "x", "seal"]) @@ -626,6 +625,17 @@ fn check_unique_bin_names() { std::process::exit(1); } +// [impl->REQ-BRAIN-READ-BOUNDED-PER-CALL] +fn check_brain_read_policy() { + match brainread::check(&repo_root()) { + Ok(line) => eprintln!("{line}"), + Err(diag) => { + eprintln!("xtask check: FAILED -- Brain read policy\n{diag}"); + std::process::exit(1); + } + } +} + /// The generated public pages the internal-code scan walks — a const rather /// than a local literal, so a test can assert a page JOINED the scan. A const /// held BESIDE a local array would prove only that the const names the page @@ -858,12 +868,16 @@ mod heavy_integration_tests { #[test] fn the_criterion_reads_a_real_daemon_or_brain_tree_through_any_formatting() { // `spt daemon run`, on one line and split across lines (rustfmt does both). - assert!(spawns_daemon_tree(r#"Command::new(spt).args(["daemon", "run"]).spawn()"#)); + assert!(spawns_daemon_tree( + r#"Command::new(spt).args(["daemon", "run"]).spawn()"# + )); assert!(spawns_daemon_tree( "cmd.args([\n \"daemon\",\n \"run\",\n]);" )); // The brain tree, spawned as a child or driven in-process. - assert!(spawns_daemon_tree(r#"let mut args = vec!["daemon", "brain"];"#)); + assert!(spawns_daemon_tree( + r#"let mut args = vec!["daemon", "brain"];"# + )); assert!(spawns_daemon_tree("supervise_brain(\n &broker,\n)")); // Prose ABOUT the supervisor is not a call to it, and neither is an import. assert!(!spawns_daemon_tree( @@ -894,13 +908,17 @@ mod heavy_integration_tests { // and .config/nextest.toml did not. let nextest = "(package(spt-daemon) & kind(test) & binary(/^(twohost)$/))"; let golden = "(package(spt-daemon) & kind(test) & binary(/^(twohost|twohost_web)$/))"; - assert_eq!(names_only_in(golden, nextest), vec!["twohost_web".to_owned()]); + assert_eq!( + names_only_in(golden, nextest), + vec!["twohost_web".to_owned()] + ); assert!(names_only_in(nextest, golden).is_empty()); } #[test] fn the_expression_is_read_from_the_line_that_actually_carries_it() { - let nextest = "filter = 'package(spt) & kind(bin)'\nfilter = '(package(spt-daemon) & kind(test))'\n"; + let nextest = + "filter = 'package(spt) & kind(bin)'\nfilter = '(package(spt-daemon) & kind(test))'\n"; assert_eq!( heavy_expression(nextest, "filter = '"), Some("(package(spt-daemon) & kind(test))") @@ -2695,7 +2713,10 @@ mod docs_token_gate_tests { assert!(tokens.contains(&"ADR-0019"), "ADR-#### flagged: {tokens:?}"); assert!(tokens.contains(&"F-011"), "F-### flagged: {tokens:?}"); assert!(tokens.contains(&"M8-W5"), "M#-W# flagged: {tokens:?}"); - assert!(tokens.contains(&"releases#237"), "releases#* flagged: {tokens:?}"); + assert!( + tokens.contains(&"releases#237"), + "releases#* flagged: {tokens:?}" + ); assert_eq!(hits.iter().find(|(_, t)| t == "REQ-KICK-1").unwrap().0, 2); assert_eq!(hits.iter().find(|(_, t)| t == "releases#237").unwrap().0, 6); } @@ -2716,16 +2737,20 @@ mod docs_token_gate_tests { #[cfg(test)] mod changelog_page_tests { - use super::{changelog_page, forbidden_codes_in, gen_changelog, repo_root, PUBLISHED_DOC_PATHS}; + use super::{ + changelog_page, forbidden_codes_in, gen_changelog, repo_root, PUBLISHED_DOC_PATHS, + }; // [unit->REQ-DOCS-CHANGELOG-PAGE] #[test] fn traceability_comments_are_stripped_and_changelog_is_scanned() { let source = concat!( "# Changelog\n\n", - "\n", + "\n", "- Messages reach their destination.\n", - "\n", + "\n", "- Empty queues remain quiet.\n", ); let out = changelog_page(source); @@ -2753,12 +2778,14 @@ mod changelog_page_tests { fn non_comment_lines_preserve_bytes_and_order() { let source = concat!( "# Changelog\n\n", - "\n", + "\n", "## [1.2.3] - 2026-09-06\n\n", "- Keep **formatting**, `--flags`, and café → 東京. \n", " - Keep issue context (releases#222).\n", "\n```text\n\tliteral spacing\n```\n", - "\n", + "\n", "Last line stays last.\n", ); let expected = concat!( @@ -2831,11 +2858,11 @@ mod adapter_docs_schema_tests { // [unit->REQ-WEB-ADAPTER-DOCS-FACET] #[test] fn checked_in_schema_publishes_docs_dir_without_internal_codes() { - let schema = std::fs::read_to_string( - repo_root().join("crates/spt-runtime/manifest.schema.json"), - ) - .expect("checked-in manifest schema"); - let schema: serde_json::Value = serde_json::from_str(&schema).expect("valid manifest schema"); + let schema = + std::fs::read_to_string(repo_root().join("crates/spt-runtime/manifest.schema.json")) + .expect("checked-in manifest schema"); + let schema: serde_json::Value = + serde_json::from_str(&schema).expect("valid manifest schema"); let docs_dir = schema .pointer("/$defs/Adapter/properties/docs_dir") .expect("manifest schema must publish [adapter].docs_dir"); @@ -3156,7 +3183,8 @@ fn claim_trees_match(cwd_tree: &Path, pool_tree: &Path) -> bool { #[cfg(windows)] fn same_path(a: &Path, b: &Path) -> bool { - a.to_string_lossy().eq_ignore_ascii_case(&b.to_string_lossy()) + a.to_string_lossy() + .eq_ignore_ascii_case(&b.to_string_lossy()) } #[cfg(not(windows))]