aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
GitHub aien-dev/aien-sovereign-core-mv#363 (code only)
Fetch it
curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/858cef79b6a7d96b.bundle -o 858cef79b6a7d96b.bundle git fetch 858cef79b6a7d96b.bundle refs/pull/363/head
Provenance
github-import 1
aien-dev/aien-sovereign-core-mv
363
3f0bdfce507cb5a4f9f820741d938ed086668fda
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":363,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/363","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:57Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.crumb b/.crumb index 0bdddc75..b00e8003 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ } ], "children_root": "sha256:95ba9db41a2ad217bd02bbbe25aaf363580b5cd23754f40351ee780858343de5", - "compiled_at": "2026-10-09T13:57:33Z", + "compiled_at": "2026-10-09T14:22:52Z", "compiler": "crumb-compile/1", - "digest": "sha256:6490bc0d707ea4ce411e550be1e55bf629a55ba4412b8612bbd4936537b98b0c", + "digest": "sha256:6e430e82542fc7d6dd6021350f22c0638dcf1b72c149c798e470412fecac74f7", "evidence_files": 187, "evidence_root": "sha256:27ee0353cb4d4aae2b7dbce2bfe0d9f4ef2a94cd7a4555b84684d59372503280", - "files": 1742, - "generated_at_commit": "5533a49b18bfe606adcb6990a3aa24fda01f3202", - "source_tree": "sha256:ad591f4de309c236240aa603bebde22a82d2bd0a379c5fec0046b9cbf554d363" + "files": 1847, + "generated_at_commit": "03495be28c6a8a420b3b7ee4629ae4a5ec130dc6", + "source_tree": "sha256:559a78a5eb36d92152105a0e256f581f000a7bf10360f223bcdf9bf47d14c5d8" } }, "history": [], diff --git a/crates/aien-cli/.crumb b/crates/aien-cli/.crumb index 4a0de451..cd9d0212 100644 --- a/crates/aien-cli/.crumb +++ b/crates/aien-cli/.crumb @@ -41,14 +41,14 @@ } ], "children_root": "sha256:e2f54116bdcc7366210192f3e08ba76d21cbec793541c092782b2c14aecafc49", - "compiled_at": "2026-10-08T20:40:14Z", + "compiled_at": "2026-10-09T13:31:53Z", "compiler": "crumb-compile/1", - "digest": "sha256:13cd3b3fd25eba11e955c3f5271c71c59b35dae179aebf25bfd274949fb54a7e", + "digest": "sha256:7a0a20fef74798fed69624009d7e2df05c772ca399ca3ee43bd9b8f5fb5fe181", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 35, - "generated_at_commit": "b0cee161ba3342af362fcb2ddbda5f728c2d6c12", - "source_tree": "sha256:e5fe6fab325ce134c7d88582b328abfa9208d96a753d52d830774b094d8ecb24" + "generated_at_commit": "1bdadbdc330fe604b5d79413a2534406bac63fd9", + "source_tree": "sha256:53716c2c2996d2a42fb09165455b14fb31ec260433a6c39e7cd162659733c15f" } }, "history": [ diff --git a/crates/aien-cli/tests/compose_ordinary_flow_test.rs b/crates/aien-cli/tests/compose_ordinary_flow_test.rs index cf5bcead..17319a6d 100644 --- a/crates/aien-cli/tests/compose_ordinary_flow_test.rs +++ b/crates/aien-cli/tests/compose_ordinary_flow_test.rs @@ -6,6 +6,9 @@ //! with `--desk`, as an operator does. Needs the linked composition archive; //! in a stub build each test is IGNORED (cfg compose_linked from build.rs), //! never passed. +#[path = "../../aien-runtime/tests/support/home_guard.rs"] +mod home_guard; + use aien_inference_abi::MockInferenceBackend; use aien_kv_cache::create_shared_kv_manager; use aien_runtime::approved_auth::{desk_key_path, DeskKey}; @@ -154,6 +157,7 @@ static ONE_HOME: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(()); #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[cfg_attr(not(compose_linked), ignore = "needs the linked librx_compose.a")] async fn ordinary_flow_propose_authorize_execute_reaches_done() { + let _home = home_guard::home_slot(); let _t = ONE_HOME.lock().await; let Some(r) = rig().await else { return }; let report = r.propose().await; @@ -202,6 +206,7 @@ async fn ordinary_flow_propose_authorize_execute_reaches_done() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[cfg_attr(not(compose_linked), ignore = "needs the linked librx_compose.a")] async fn a_client_written_authorization_note_is_refused_and_opens_nothing() { + let _home = home_guard::home_slot(); let _t = ONE_HOME.lock().await; let Some(r) = rig().await else { return }; let report = r.propose().await; @@ -237,6 +242,7 @@ async fn a_client_written_authorization_note_is_refused_and_opens_nothing() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[cfg_attr(not(compose_linked), ignore = "needs the linked librx_compose.a")] async fn authorize_without_the_desk_mac_is_refused_and_mints_nothing() { + let _home = home_guard::home_slot(); // sc#328: the default bridge requires the desk; an OS-user-only authorize // (what every client sent before #297) is refused and opens nothing. let _t = ONE_HOME.lock().await; diff --git a/crates/aien-runtime/src/approved.rs b/crates/aien-runtime/src/approved.rs index 6877c555..f8bbffcc 100644 --- a/crates/aien-runtime/src/approved.rs +++ b/crates/aien-runtime/src/approved.rs @@ -584,6 +584,7 @@ mod toctou_tests { /// refuses at the claim, before the seam.) #[test] fn prior_changed_between_check_and_commit_is_refused() { + let _home = crate::home_guard::home_slot(); if !aien_omega_compose::LINKED { return; } diff --git a/crates/aien-runtime/src/effects.rs b/crates/aien-runtime/src/effects.rs index 819ad448..a8a3b3db 100644 --- a/crates/aien-runtime/src/effects.rs +++ b/crates/aien-runtime/src/effects.rs @@ -2292,6 +2292,7 @@ mod tests { /// A record that names a nonexistent generation id is refused at write time. #[test] fn a_commit_naming_no_generation_record_is_not_written() { + let _home = crate::home_guard::home_slot(); use crate::generation::Provenance; use crate::spine::{ComposeBridge, Generation}; if !aien_omega_compose::LINKED { @@ -2528,6 +2529,7 @@ mod tests { /// hash and `base` is refused as BaseChanged.) #[test] fn write_approved_grant_records_the_prior_of_the_confined_file() { + let _home = crate::home_guard::home_slot(); use crate::spine::{ComposeBridge, Generation}; if !aien_omega_compose::LINKED { eprintln!("NOT_RUN: stub compose build"); diff --git a/crates/aien-runtime/src/lib.rs b/crates/aien-runtime/src/lib.rs index 7d6ea8ca..655a546c 100644 --- a/crates/aien-runtime/src/lib.rs +++ b/crates/aien-runtime/src/lib.rs @@ -22,6 +22,11 @@ pub mod spine; pub mod swarm; pub mod world; +/// Test-only: one slot per process for tests that open a compose home (omega allows 4 handles). +#[cfg(test)] +#[path = "../tests/support/home_guard.rs"] +mod home_guard; + pub use aien_kv_cache::create_shared_kv_manager; pub use aien_scheduler::SchedulerConfig; pub use client::*; diff --git a/crates/aien-runtime/src/server.rs b/crates/aien-runtime/src/server.rs index 5bd71a22..bafb3020 100644 --- a/crates/aien-runtime/src/server.rs +++ b/crates/aien-runtime/src/server.rs @@ -1114,6 +1114,7 @@ mod generation_record_tests { /// file, and in a stub build the engine is absent) yields no id. #[tokio::test] async fn a_failed_append_returns_no_id() { + let _home = crate::home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let blocked = tmp.path().join("compose"); std::fs::write(&blocked, b"not a directory").unwrap(); diff --git a/crates/aien-runtime/src/spine.rs b/crates/aien-runtime/src/spine.rs index 7da6f3e4..f0aefb3d 100644 --- a/crates/aien-runtime/src/spine.rs +++ b/crates/aien-runtime/src/spine.rs @@ -2789,6 +2789,7 @@ mod requirement_tests { #[test] fn approved_run_reports_recognized_and_refuses_unmet_before_any_write() { + let _home = crate::home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let ws = tmp.path().join("ws"); std::fs::create_dir_all(&ws).unwrap(); @@ -2910,6 +2911,7 @@ mod verify_callback_integration_tests { /// by AEGIS (nothing committed, no promotion) when the record is gone. #[test] fn lost_requirement_record_is_refused_by_the_real_verify_callback() { + let _home = crate::home_guard::home_slot(); if !aien_omega_compose::LINKED { return; } diff --git a/crates/aien-runtime/tests/allen_memory_ipc_test.rs b/crates/aien-runtime/tests/allen_memory_ipc_test.rs index 5b747247..511bc7fa 100644 --- a/crates/aien-runtime/tests/allen_memory_ipc_test.rs +++ b/crates/aien-runtime/tests/allen_memory_ipc_test.rs @@ -1,6 +1,9 @@ //! ALLEN memory commands over the runtime socket (arch#159): routing only. ALLEN is not engaged here, so status answers "not_engaged" and a //! change is refused. In a stub omega build the compose home cannot open and //! the daemon says so (the answer is an error, never a made-up identity). +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_allen::ENV_SUBJECT; use aien_inference_abi::MockInferenceBackend; use aien_kv_cache::create_shared_kv_manager; @@ -13,6 +16,7 @@ use std::time::Duration; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn allen_memory_commands_route_through_the_socket() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); // Only this test binary sets these; one test per binary avoids env races. std::env::set_var("AIEN_COMPOSE_DIR", tmp.path().join("compose")); diff --git a/crates/aien-runtime/tests/allen_memory_test.rs b/crates/aien-runtime/tests/allen_memory_test.rs index 73dac439..a53367f5 100644 --- a/crates/aien-runtime/tests/allen_memory_test.rs +++ b/crates/aien-runtime/tests/allen_memory_test.rs @@ -8,6 +8,9 @@ //! and always runs. Part B (`b_*`) runs a real compose home in child //! processes (each child is a fresh daemon over the same home = a restart) //! and reports NOT_RUN in a stub omega build. +#[path = "support/home_guard.rs"] +mod home_guard; + #[path = "../../aien-allen/tests/support/mod.rs"] mod support; @@ -864,6 +867,7 @@ macro_rules! need_linked { #[test] fn b_prompt_has_only_the_named_context_and_a_reply_cannot_write_memory() { + let _home = home_guard::home_slot(); need_linked!(); let w = world("mem-b-iso", true); let seed = child(&w, &[], &seeds()); @@ -949,6 +953,7 @@ fn b_prompt_has_only_the_named_context_and_a_reply_cannot_write_memory() { #[test] fn b_restart_keeps_scopes_and_forget_holds_in_the_next_prompt_after_restart() { + let _home = home_guard::home_slot(); need_linked!(); let w = world("mem-b-restart", true); child(&w, &[], &seeds()); @@ -1025,6 +1030,7 @@ fn b_not_engaged_refuses_memory_but_compose_runs() { #[test] fn b_foreign_store_is_refused_and_compose_runs_with_no_memory() { + let _home = home_guard::home_slot(); need_linked!(); let a = world("mem-b-a", true); let other = world("mem-b-other", true); @@ -1048,6 +1054,7 @@ fn b_foreign_store_is_refused_and_compose_runs_with_no_memory() { #[test] fn b_model_swap_leaves_memory_untouched() { + let _home = home_guard::home_slot(); need_linked!(); let w = world("mem-b-swap", true); child(&w, &[], &seeds()); diff --git a/crates/aien-runtime/tests/allen_persona_ipc_test.rs b/crates/aien-runtime/tests/allen_persona_ipc_test.rs index 470fc0df..ae4c8298 100644 --- a/crates/aien-runtime/tests/allen_persona_ipc_test.rs +++ b/crates/aien-runtime/tests/allen_persona_ipc_test.rs @@ -2,6 +2,9 @@ //! only. ALLEN is not engaged here, so status answers "not_engaged" and a //! change is refused. In a stub omega build the compose home cannot open and //! the daemon says so (the answer is an error, never a made-up identity). +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_allen::ENV_SUBJECT; use aien_inference_abi::MockInferenceBackend; use aien_kv_cache::create_shared_kv_manager; @@ -14,6 +17,7 @@ use std::time::Duration; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn allen_commands_route_through_the_socket() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); // Only this test binary sets these; one test per binary avoids env races. std::env::set_var("AIEN_COMPOSE_DIR", tmp.path().join("compose")); diff --git a/crates/aien-runtime/tests/allen_persona_test.rs b/crates/aien-runtime/tests/allen_persona_test.rs index 2ad90079..1aea764a 100644 --- a/crates/aien-runtime/tests/allen_persona_test.rs +++ b/crates/aien-runtime/tests/allen_persona_test.rs @@ -5,6 +5,9 @@ //! Part A needs no composition library and always runs. Part B (marked //! `b_*`) re-executes this binary against a real compose home and reports //! NOT_RUN in a stub omega build, like allen_spine_test. +#[path = "support/home_guard.rs"] +mod home_guard; + #[path = "../../aien-allen/tests/support/mod.rs"] mod support; @@ -470,6 +473,7 @@ fn child(home: &Path, ws: Option<&Path>, env: &[(&str, &str)]) -> (i32, String, #[test] fn b_engaged_task_uses_the_persona_and_a_reply_cannot_change_it() { + let _home = home_guard::home_slot(); if !LINKED { println!("NOT_RUN: stub omega build (no librx_compose.a); set AIEN_OMEGA_COMPOSE_DIR"); return; diff --git a/crates/aien-runtime/tests/allen_spine_test.rs b/crates/aien-runtime/tests/allen_spine_test.rs index b76b2a96..7bea6897 100644 --- a/crates/aien-runtime/tests/allen_spine_test.rs +++ b/crates/aien-runtime/tests/allen_spine_test.rs @@ -6,6 +6,9 @@ //! checks exit code and output. With the stub omega library (no //! librx_compose.a) the compose home cannot open at all, so every case //! reports NOT_RUN and returns; with `AIEN_OMEGA_COMPOSE_DIR` set they run. +#[path = "support/home_guard.rs"] +mod home_guard; + #[path = "../../aien-allen/tests/support/mod.rs"] mod support; @@ -146,6 +149,7 @@ fn not_engaged_path_is_unchanged() { #[test] fn engaged_without_pin_or_adopt_is_fatal_and_creates_nothing() { + let _home = home_guard::home_slot(); if skip() { return; } @@ -185,6 +189,7 @@ fn engaged_missing_subject_is_fatal_never_minted() { #[test] fn adopt_restart_machine_change_and_foreign_journal() { + let _home = home_guard::home_slot(); if skip() { return; } diff --git a/crates/aien-runtime/tests/approved_attacks_test.rs b/crates/aien-runtime/tests/approved_attacks_test.rs index 4a3b31e6..bbcf0149 100644 --- a/crates/aien-runtime/tests/approved_attacks_test.rs +++ b/crates/aien-runtime/tests/approved_attacks_test.rs @@ -9,6 +9,9 @@ //! Needs librx_compose.a (AIEN_OMEGA_COMPOSE_LIB); in a stub build every test //! returns early. The two crash tests need `--features fault-hold` (the //! production build compiles the crash points to nothing). +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_inference_abi::MockInferenceBackend; use aien_kv_cache::create_shared_kv_manager; use aien_omega_compose::hex; @@ -205,6 +208,7 @@ fn rehash(p: &mut ApprovedProposal) { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c01_forged_approver() { + let _home = home_guard::home_slot(); tampered("forged approver", |_, p| p.approver = "drake".into()).await; } @@ -214,6 +218,7 @@ async fn c01_forged_approver() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c02a_invalid_mac_random() { + let _home = home_guard::home_slot(); tampered("random MAC", |_, p| p.approval_mac = "ab".repeat(32)).await; } @@ -223,6 +228,7 @@ async fn c02a_invalid_mac_random() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c02b_invalid_mac_empty_and_short() { + let _home = home_guard::home_slot(); tampered("empty MAC", |_, p| p.approval_mac.clear()).await; tampered("short MAC", |_, p| p.approval_mac.truncate(63)).await; } @@ -233,6 +239,7 @@ async fn c02b_invalid_mac_empty_and_short() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c02c_invalid_mac_uppercase_of_the_real_one() { + let _home = home_guard::home_slot(); tampered("uppercase MAC", |_, p| { p.approval_mac = p.approval_mac.to_uppercase() }) @@ -245,6 +252,7 @@ async fn c02c_invalid_mac_uppercase_of_the_real_one() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c02d_mac_from_another_desk_key() { + let _home = home_guard::home_slot(); tampered("MAC under another desk key", |tmp, p| { let other = DeskKey::create(&tmp.join("other-desk").join("k")).unwrap(); p.approval_mac = other.sign(p, &ws(tmp)); @@ -258,6 +266,7 @@ async fn c02d_mac_from_another_desk_key() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c03_changed_trace_id() { + let _home = home_guard::home_slot(); tampered("changed trace_id", |_, p| p.trace_id = "trace-other".into()).await; } @@ -267,6 +276,7 @@ async fn c03_changed_trace_id() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c04_changed_request_id() { + let _home = home_guard::home_slot(); tampered("changed request_id", |_, p| { p.request_id = "req-other".into() }) @@ -279,6 +289,7 @@ async fn c04_changed_request_id() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c05_changed_approval_id() { + let _home = home_guard::home_slot(); tampered("changed approval_id", |_, p| { p.approval_id = "appr-other".into() }) @@ -291,6 +302,7 @@ async fn c05_changed_approval_id() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c06_changed_path() { + let _home = home_guard::home_slot(); tampered("changed path", |_, p| { p.path = "OTHER.md".into(); rehash(p); @@ -304,6 +316,7 @@ async fn c06_changed_path() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c07_changed_content() { + let _home = home_guard::home_slot(); tampered("changed content", |_, p| { p.content = "attacker content\n".into(); rehash(p); @@ -319,6 +332,7 @@ async fn c07_changed_content() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c08_desk_key_open_to_others_or_missing() { + let _home = home_guard::home_slot(); use std::os::unix::fs::PermissionsExt; let _t = TURN.lock().await; let tmp = fresh(); @@ -354,6 +368,7 @@ async fn c08_desk_key_open_to_others_or_missing() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c09_same_process_replay() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let d = up(tmp.path(), "s.sock").await; @@ -390,6 +405,7 @@ async fn c09_same_process_replay() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c10_replay_after_daemon_restart() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let w = ws(tmp.path()); @@ -422,6 +438,7 @@ async fn c10_replay_after_daemon_restart() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c11_concurrent_duplicate_submissions() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let d = up(tmp.path(), "s.sock").await; @@ -464,6 +481,7 @@ async fn c11_concurrent_duplicate_submissions() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c14a_retry_after_response_loss() { + let _home = home_guard::home_slot(); lost_response(true).await; } @@ -475,6 +493,7 @@ async fn c14a_retry_after_response_loss() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c14b_retry_after_immediate_hangup() { + let _home = home_guard::home_slot(); lost_response(false).await; } @@ -551,6 +570,7 @@ async fn lost_response(wait: bool) { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c15_forged_replay_records_via_compose_note() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let d = up(tmp.path(), "s.sock").await; @@ -594,6 +614,7 @@ async fn c15_forged_replay_records_via_compose_note() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c16_desk_signed_path_escaping_the_workspace() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let d = up(tmp.path(), "s.sock").await; @@ -624,6 +645,7 @@ async fn c16_desk_signed_path_escaping_the_workspace() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c17_approval_redirected_to_another_workspace() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let d = up(tmp.path(), "s.sock").await; @@ -663,6 +685,7 @@ async fn c17_approval_redirected_to_another_workspace() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c17c_workspace_through_a_symlink() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let d = up(tmp.path(), "s.sock").await; @@ -931,6 +954,7 @@ async fn text_of(c: &AienRuntimeClient, id: u64) -> (String, Vec<u64>) { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c26_happy_path_one_approval_one_effect() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let d = up(tmp.path(), "s.sock").await; @@ -965,6 +989,7 @@ async fn c26_happy_path_one_approval_one_effect() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c21_symlink_swap_of_the_target() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let d = up(tmp.path(), "s.sock").await; @@ -1002,6 +1027,7 @@ async fn c21_symlink_swap_of_the_target() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c28_parent_directory_swap_after_the_intent() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let w = ws(tmp.path()); @@ -1037,6 +1063,7 @@ async fn c28_parent_directory_swap_after_the_intent() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c28b_parent_directory_swap_settled_by_reconcile() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let w = ws(tmp.path()); @@ -1105,6 +1132,7 @@ async fn c28b_parent_directory_swap_settled_by_reconcile() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c22_forged_approved_grant_via_socket() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let d = up(tmp.path(), "s.sock").await; @@ -1217,6 +1245,7 @@ async fn grant_on_unfinished_claim(end: &str) { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c23_forged_grant_on_failed_claim() { + let _home = home_guard::home_slot(); grant_on_unfinished_claim("failed").await; } @@ -1226,6 +1255,7 @@ async fn c23_forged_grant_on_failed_claim() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c24a_forged_grant_on_uncertain_claim() { + let _home = home_guard::home_slot(); grant_on_unfinished_claim("uncertain").await; } @@ -1235,6 +1265,7 @@ async fn c24a_forged_grant_on_uncertain_claim() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c24b_forged_grant_on_uncertain_claim_declared_committed() { + let _home = home_guard::home_slot(); grant_on_unfinished_claim("declared").await; } @@ -1247,6 +1278,7 @@ async fn c24b_forged_grant_on_uncertain_claim_declared_committed() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c25_duplicate_approved_grant_for_one_committed_claim() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let d = up(tmp.path(), "s.sock").await; @@ -1283,6 +1315,7 @@ async fn c25_duplicate_approved_grant_for_one_committed_claim() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] async fn c25b_shutdown_closes_the_compose_home_while_a_connection_is_open() { + let _home = home_guard::home_slot(); let _t = TURN.lock().await; let tmp = fresh(); let d = up(tmp.path(), "s.sock").await; @@ -1309,6 +1342,7 @@ async fn c25b_shutdown_closes_the_compose_home_while_a_connection_is_open() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] fn c25c_a_closed_bridge_never_reopens_the_home() { + let _home = home_guard::home_slot(); let tmp = fresh(); let b = bridge(tmp.path()); let first = raw_note(&b, "constraint", "before close", &[]); diff --git a/crates/aien-runtime/tests/approved_confinement_test.rs b/crates/aien-runtime/tests/approved_confinement_test.rs index 085cb784..fd0f21ab 100644 --- a/crates/aien-runtime/tests/approved_confinement_test.rs +++ b/crates/aien-runtime/tests/approved_confinement_test.rs @@ -20,6 +20,9 @@ //! //! Needs librx_compose.a (AIEN_OMEGA_COMPOSE_LIB); in a stub build the compose //! commands refuse and the test returns early. +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_inference_abi::MockInferenceBackend; use aien_kv_cache::create_shared_kv_manager; use aien_omega_compose::hex; @@ -109,6 +112,7 @@ fn refused(r: ControlResponse, want: &str) -> String { #[tokio::test] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] async fn forged_grants_are_confined_and_the_approved_kind_is_reserved() { + let _home = home_guard::home_slot(); if !aien_omega_compose::LINKED { return; } diff --git a/crates/aien-runtime/tests/approved_daemon_ipc_test.rs b/crates/aien-runtime/tests/approved_daemon_ipc_test.rs index d1638615..b528fff6 100644 --- a/crates/aien-runtime/tests/approved_daemon_ipc_test.rs +++ b/crates/aien-runtime/tests/approved_daemon_ipc_test.rs @@ -6,6 +6,9 @@ //! every replay is refused and the same approval's retry gets the original //! result back without a second run. One test per binary (it sets //! AIEN_COMPOSE_DIR). +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_inference_abi::MockInferenceBackend; use aien_kv_cache::create_shared_kv_manager; use aien_omega_compose::hex; @@ -115,6 +118,7 @@ fn refusal(r: ControlResponse) -> (String, String) { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] async fn approved_proposal_over_the_daemon_socket() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let dir = tmp.path().join("compose"); std::env::set_var("AIEN_COMPOSE_DIR", &dir); diff --git a/crates/aien-runtime/tests/approved_proposal_test.rs b/crates/aien-runtime/tests/approved_proposal_test.rs index a513ce4a..594acdb0 100644 --- a/crates/aien-runtime/tests/approved_proposal_test.rs +++ b/crates/aien-runtime/tests/approved_proposal_test.rs @@ -4,6 +4,9 @@ //! replayed (#249 B) proposals are refused with no compose run. CPU only, no //! model, no socket: the bridge is driven exactly as the daemon drives it. In //! a stub build only the refusal paths run. +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_omega_compose::hex; use aien_runtime::approved::{ self, ApprovedComposeReport, ApprovedProposal, ApprovedRefusal, ProposerHook, @@ -142,6 +145,7 @@ fn setup() -> (tempfile::TempDir, Arc<ComposeBridge>, ProposerHook, String) { #[test] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] fn approved_proposal_commits_then_effect_is_done() { + let _home = home_guard::home_slot(); let _turn = turn(); let (_tmp, b, hook, ws) = setup(); let p = sign(&b, unsigned("req-1", "appr-1")); @@ -249,6 +253,7 @@ fn approved_proposal_commits_then_effect_is_done() { #[test] fn unverified_proposal_is_refused_with_zero_effects() { + let _home = home_guard::home_slot(); let _turn = turn(); let (_tmp, b, hook, ws) = setup(); println!( @@ -310,6 +315,7 @@ fn unverified_proposal_is_refused_with_zero_effects() { #[test] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] fn duplicate_proposal_is_refused() { + let _home = home_guard::home_slot(); let _turn = turn(); let (_tmp, b, hook, ws) = setup(); let p = sign(&b, unsigned("req-d", "appr-d")); @@ -356,6 +362,7 @@ fn duplicate_proposal_is_refused() { /// zero records, nothing on disk. #[test] fn unauthenticated_approval_is_refused_with_no_compose() { + let _home = home_guard::home_slot(); let _turn = turn(); let (tmp, b, hook, ws) = setup(); let good = sign(&b, unsigned("req-a", "appr-a")); @@ -416,6 +423,7 @@ fn unauthenticated_approval_is_refused_with_no_compose() { /// keys are refused NoDesk; refusals and reports never carry the key. #[test] fn desk_key_file_rules() { + let _home = home_guard::home_slot(); let _turn = turn(); use std::os::unix::fs::PermissionsExt; let (tmp, b, hook, ws) = setup(); @@ -495,6 +503,7 @@ fn compose_home_overlapping_the_workspace_is_refused() { #[test] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] fn replay_is_refused_after_restart() { + let _home = home_guard::home_slot(); let _turn = turn(); let (tmp, b, hook, ws) = setup(); let p = sign(&b, unsigned("req-r", "appr-r")); @@ -535,6 +544,7 @@ fn replay_is_refused_after_restart() { #[test] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] fn concurrent_duplicates_run_once() { + let _home = home_guard::home_slot(); let _turn = turn(); let (_tmp, b, hook, ws) = setup(); if !aien_omega_compose::LINKED { @@ -596,6 +606,7 @@ fn approved_hash_is_the_interplane_form() { #[test] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] fn approved_proposal_over_existing_file_commits_byte_exact() { + let _home = home_guard::home_slot(); let _turn = turn(); let (_tmp, _b, hook, ws) = setup(); let seed = "# Notes\nseed line one\nseed line two\n"; @@ -636,6 +647,7 @@ fn approved_proposal_over_existing_file_commits_byte_exact() { /// daemon's grant targets the bound workspace. #[test] fn approval_redirected_to_another_workspace_is_refused() { + let _home = home_guard::home_slot(); let _turn = turn(); let (tmp, b, hook, ws) = setup(); let other = tmp.path().join("elsewhere"); @@ -679,6 +691,7 @@ fn approval_redirected_to_another_workspace_is_refused() { #[test] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] fn copied_approved_grant_opens_nothing() { + let _home = home_guard::home_slot(); let _turn = turn(); let (_tmp, b, hook, ws) = setup(); let r = committed(hook.submit(&sign(&b, unsigned("req-g", "appr-g")), &ws)); @@ -723,6 +736,7 @@ const FENCED_DOC: &str = "# FAQ\n\nInstall:\n```bash\ncurl -fsSL https://example #[test] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] fn approved_document_with_fences_is_saved_byte_exact_or_not_done() { + let _home = home_guard::home_slot(); let _turn = turn(); let (_tmp, b, hook, ws) = setup(); // The compose template keeps every byte (check_file_proposal reads it back). @@ -830,6 +844,7 @@ fn with_goal( #[test] fn bound_requirements_the_bytes_miss_are_refused_and_nothing_is_consumed() { + let _home = home_guard::home_slot(); let _turn = turn(); let (_tmp, b, hook, ws) = setup(); let p = with_goal( @@ -865,6 +880,7 @@ fn bound_requirements_the_bytes_miss_are_refused_and_nothing_is_consumed() { #[test] fn bytes_meeting_the_bound_requirements_commit_with_equal_sha256() { + let _home = home_guard::home_slot(); let _turn = turn(); let (_tmp, b, hook, ws) = setup(); let p = with_goal( @@ -890,6 +906,7 @@ fn bytes_meeting_the_bound_requirements_commit_with_equal_sha256() { #[test] fn explicitly_signed_empty_requirements_are_allowed() { + let _home = home_guard::home_slot(); let _turn = turn(); let (_tmp, b, hook, ws) = setup(); let p = with_goal(&b, "req-rq3", "appr-rq3", Some("")); @@ -944,6 +961,7 @@ fn uncertain_bound_requirements_are_refused() { #[test] fn bound_added_line_counts_are_measured_against_the_existing_file() { + let _home = home_guard::home_slot(); let _turn = turn(); let (_tmp, b, hook, ws) = setup(); std::fs::write(Path::new(&ws).join(PATH), "one\ntwo\n").unwrap(); @@ -974,6 +992,7 @@ fn bound_added_line_counts_are_measured_against_the_existing_file() { #[test] fn a_path_that_reads_like_a_requirement_is_not_one() { + let _home = home_guard::home_slot(); let _turn = turn(); let (_tmp, b, hook, ws) = setup(); let path = "docs/add-2-lines-to-10-lines.md"; diff --git a/crates/aien-runtime/tests/approved_replay_test.rs b/crates/aien-runtime/tests/approved_replay_test.rs index c624692a..09e08ce3 100644 --- a/crates/aien-runtime/tests/approved_replay_test.rs +++ b/crates/aien-runtime/tests/approved_replay_test.rs @@ -4,6 +4,9 @@ //! build.rs from aien-omega-compose's links metadata). //! A "crashed" claim is made by a child process (this test binary re-run with //! REPLAY_CHILD set) that claims and exits without settling. +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_runtime::approved_replay::{ self as replay, ClaimKeys, ClaimState, CommitEvidence, ReplayLedger, FIELD, }; @@ -219,6 +222,7 @@ fn compose_note_cannot_forge_replay_records() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] fn claim_is_durable_and_single_use_across_restart() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let k = keys("restart"); { @@ -282,6 +286,7 @@ fn claim_is_durable_and_single_use_across_restart() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] fn failed_and_not_executed_claims_stay_consumed() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let b = bridge(tmp.path()); let c = replay::claim(&b, &keys("ne")).unwrap(); @@ -309,6 +314,7 @@ fn failed_and_not_executed_claims_stay_consumed() { ignore = "needs the linked librx_compose.a (AIEN_OMEGA_COMPOSE_LIB)" )] fn concurrent_duplicates_at_most_one_claim() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let b = Arc::new(bridge(tmp.path())); let n = 16; @@ -341,6 +347,7 @@ fn concurrent_duplicates_at_most_one_claim() { #[test] #[ignore = "child mode, run by crash_before_and_during_execution_fail_closed"] fn child_claim_then_crash() { + let _home = home_guard::home_slot(); let Ok(mode) = std::env::var("REPLAY_CHILD") else { return; }; diff --git a/crates/aien-runtime/tests/authorize_desk_mac_test.rs b/crates/aien-runtime/tests/authorize_desk_mac_test.rs index b06de289..bb9afabd 100644 --- a/crates/aien-runtime/tests/authorize_desk_mac_test.rs +++ b/crates/aien-runtime/tests/authorize_desk_mac_test.rs @@ -5,6 +5,9 @@ //! (and so its own desk key) in a fresh temp dir; nothing is shared. Every //! test needs the linked composition archive and is IGNORED in a stub build, //! never passed. +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_omega_compose::hex; use aien_runtime::approved_auth::{desk_key_path, AuthorizeBinding, DeskKey}; use aien_runtime::control::{ComposeNoteReport, ComposeTaskReport, ControlResponse, DeskProof}; @@ -194,6 +197,7 @@ macro_rules! linked_test { #[test] #[cfg_attr(not(compose_linked), ignore = "needs the linked librx_compose.a")] fn $name() { + let _home = home_guard::home_slot(); let Some($fx) = Fx::new($on, $key) else { return; }; diff --git a/crates/aien-runtime/tests/compose_task_ipc_test.rs b/crates/aien-runtime/tests/compose_task_ipc_test.rs index a8efa51f..e4fc4e24 100644 --- a/crates/aien-runtime/tests/compose_task_ipc_test.rs +++ b/crates/aien-runtime/tests/compose_task_ipc_test.rs @@ -2,6 +2,9 @@ //! is loaded, so the real "model" Skill (the StreamTurn inference path) //! fails and nothing commits: this proves the routing, the blocking hand-off //! and the result record, not the model. +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_inference_abi::MockInferenceBackend; use aien_kv_cache::create_shared_kv_manager; use aien_runtime::client::AienRuntimeClient; @@ -13,6 +16,7 @@ use std::time::Duration; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn run_compose_task_over_socket() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); // Only this test binary sets it; one test per binary avoids env races. std::env::set_var("AIEN_COMPOSE_DIR", tmp.path().join("compose")); diff --git a/crates/aien-runtime/tests/compose_task_test.rs b/crates/aien-runtime/tests/compose_task_test.rs index 303116dc..ab6d503a 100644 --- a/crates/aien-runtime/tests/compose_task_test.rs +++ b/crates/aien-runtime/tests/compose_task_test.rs @@ -4,6 +4,9 @@ //! With librx_compose.a linked (aien-omega-compose built with //! AIEN_OMEGA_COMPOSE_DIR, see its README) these run the real composition; //! in a stub build they check that the bridge reports the missing library. +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_runtime::control::{ComposeRecallReport, ComposeTaskReport, ControlResponse}; use aien_runtime::spine::{ check_file_proposal, compose_attempt_budget, parse_compose_budget, @@ -58,6 +61,7 @@ fn snapshot(dir: &std::path::Path) -> Vec<(String, Vec<u8>)> { #[test] fn compose_task_commits_and_survives_restart() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let home = tmp.path().join("compose"); let ws = tmp.path().join("workspace"); @@ -177,6 +181,7 @@ fn compose_task_commits_and_survives_restart() { #[test] fn failing_model_commits_nothing() { + let _home = home_guard::home_slot(); if !aien_omega_compose::LINKED { return; } @@ -456,6 +461,7 @@ fn measured_attempt_budget_admits_a_second_attempt() { #[test] fn unparseable_proposal_fails_the_aegis_contract() { + let _home = home_guard::home_slot(); if !aien_omega_compose::LINKED { return; } @@ -497,6 +503,7 @@ fn unparseable_proposal_fails_the_aegis_contract() { #[test] fn torn_home_is_refused_by_name_then_recovered() { + let _home = home_guard::home_slot(); if !aien_omega_compose::LINKED { return; } diff --git a/crates/aien-runtime/tests/compose_wait_test.rs b/crates/aien-runtime/tests/compose_wait_test.rs index 602f2957..db66cb2d 100644 --- a/crates/aien-runtime/tests/compose_wait_test.rs +++ b/crates/aien-runtime/tests/compose_wait_test.rs @@ -1,6 +1,9 @@ //! The omega settle wait really set before each run, and the target-kind //! decision (existing path => Edit/refused, missing path => Document). //! One test binary, one wait test: `LAST_WAIT_MS` is process-global. +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_runtime::control::ControlResponse; use aien_runtime::spine::{ classify_target, propose_task_with_retries, task_plan, ComposeBridge, ComposeBudgets, @@ -15,6 +18,7 @@ use std::time::Duration; #[test] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] fn run_task_sets_omega_wait_to_budget_plus_margin_for_both_kinds() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let ws = tmp.path().join("ws"); std::fs::create_dir_all(&ws).unwrap(); diff --git a/crates/aien-runtime/tests/confine_race_test.rs b/crates/aien-runtime/tests/confine_race_test.rs index aac43d95..217500c6 100644 --- a/crates/aien-runtime/tests/confine_race_test.rs +++ b/crates/aien-runtime/tests/confine_race_test.rs @@ -6,6 +6,9 @@ //! branch must give the identical kind for every row. //! //! Needs the linked composition archive; IGNORED in a stub build. +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_omega_compose::hex; use aien_runtime::control::{ComposeNoteReport, ComposeTaskReport, ControlResponse}; use aien_runtime::effects::test_hooks; @@ -128,6 +131,7 @@ fn swap_in_symlink(ws: PathBuf, outside: PathBuf) { #[test] #[cfg_attr(not(compose_linked), ignore = "needs the linked librx_compose.a")] fn mint_records_the_prior_of_the_confined_file() { + let _home = home_guard::home_slot(); let Some(fx) = Fx::new() else { return }; let outside = fx.root.join("outside"); std::fs::create_dir_all(&outside).unwrap(); @@ -157,6 +161,7 @@ fn mint_records_the_prior_of_the_confined_file() { #[test] #[cfg_attr(not(compose_linked), ignore = "needs the linked librx_compose.a")] fn open_intent_reads_the_confined_file_not_the_path() { + let _home = home_guard::home_slot(); let Some(fx) = Fx::new() else { return }; let outside = fx.root.join("outside"); std::fs::create_dir_all(&outside).unwrap(); diff --git a/crates/aien-runtime/tests/cortex_mark_test.rs b/crates/aien-runtime/tests/cortex_mark_test.rs index 3d8f9cc6..2df32c89 100644 --- a/crates/aien-runtime/tests/cortex_mark_test.rs +++ b/crates/aien-runtime/tests/cortex_mark_test.rs @@ -4,6 +4,9 @@ //! //! With librx_compose.a linked this drives the bridge as the daemon does (no //! socket); in a stub build it only checks the refusal. +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_runtime::control::{ComposeNoteReport, ControlResponse}; use aien_runtime::cortex_mark::{self, Mark}; use aien_runtime::effects::{self, IntentRequest}; @@ -90,6 +93,7 @@ fn setup() -> Option<(tempfile::TempDir, PathBuf)> { #[test] fn boundary_cut_is_refused_and_recover_keeps_the_old_mark() { + let _home = home_guard::home_slot(); let _serial = serial(); let Some((_tmp, home)) = setup() else { return }; let cx = home.join("cortex.cx"); @@ -149,6 +153,7 @@ fn boundary_cut_is_refused_and_recover_keeps_the_old_mark() { #[test] fn crash_between_append_and_mark_is_not_corruption() { + let _home = home_guard::home_slot(); let _serial = serial(); let Some((_tmp, home)) = setup() else { return }; let mp = cortex_mark::mark_path(&home); @@ -170,6 +175,7 @@ fn crash_between_append_and_mark_is_not_corruption() { #[test] fn digest_mismatch_and_damaged_mark_are_refused() { + let _home = home_guard::home_slot(); let _serial = serial(); let Some((_tmp, home)) = setup() else { return }; let mp = cortex_mark::mark_path(&home); @@ -197,6 +203,7 @@ fn digest_mismatch_and_damaged_mark_are_refused() { #[test] fn missing_mark_is_adopted_not_refused() { + let _home = home_guard::home_slot(); let _serial = serial(); let Some((_tmp, home)) = setup() else { return }; let mp = cortex_mark::mark_path(&home); @@ -216,6 +223,7 @@ fn repair_key_is_reserved() { #[test] fn effect_commands_refuse_until_reconcile_succeeds() { + let _home = home_guard::home_slot(); let _serial = serial(); let Some((tmp, home)) = setup() else { return }; let b = ComposeBridge::new(home.clone(), proposer(), "test"); diff --git a/crates/aien-runtime/tests/effects_test.rs b/crates/aien-runtime/tests/effects_test.rs index 814ebbee..efa83593 100644 --- a/crates/aien-runtime/tests/effects_test.rs +++ b/crates/aien-runtime/tests/effects_test.rs @@ -3,6 +3,9 @@ //! //! With librx_compose.a linked this drives the bridge exactly as the daemon //! does (no socket); in a stub build it only checks the refusal. +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_omega_compose::hex; use aien_runtime::control::{ ComposeControlReport, ComposeNoteReport, ComposeReconcileReport, ControlResponse, @@ -132,6 +135,7 @@ impl Fixture { #[test] fn effect_intents_are_at_most_once_or_unresolved() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let home = tmp.path().join("compose"); let ws = tmp.path().join("ws"); diff --git a/crates/aien-runtime/tests/generation_record_test.rs b/crates/aien-runtime/tests/generation_record_test.rs index a040c94d..0b07570b 100644 --- a/crates/aien-runtime/tests/generation_record_test.rs +++ b/crates/aien-runtime/tests/generation_record_test.rs @@ -3,6 +3,9 @@ //! Socket-level, mock backend, toy tokenizer. Every test needs the linked //! composition archive and is IGNORED in a stub build, never passed (the //! no-record cases that hold in a stub build are unit tests in server.rs). +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_inference_abi::{ AienInferenceBackend, ChatTokenizer, DecodeObservation, DecodeOutput, MockInferenceBackend, ModelConfig, ScheduledBatch, StepMetrics, @@ -188,6 +191,7 @@ fn ids_of(text: &str) -> Vec<u32> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] async fn record_carries_the_digests_of_the_turn() { + let _home = home_guard::home_slot(); let _g = ONE_HOME.lock().await; let d = start(Some(identity())).await; let tok = toy_tokenizer(); @@ -233,6 +237,7 @@ async fn record_carries_the_digests_of_the_turn() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] async fn text_is_hashed_byte_exact_with_surrounding_whitespace() { + let _home = home_guard::home_slot(); let _g = ONE_HOME.lock().await; // Decoded text of the mock tokens: leading and trailing spaces. let d = start_with( @@ -255,6 +260,7 @@ async fn text_is_hashed_byte_exact_with_surrounding_whitespace() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] async fn two_identical_turns_make_two_records() { + let _home = home_guard::home_slot(); let _g = ONE_HOME.lock().await; let d = start(Some(identity())).await; let (t1, a) = d.turn("hello").await; @@ -271,6 +277,7 @@ async fn two_identical_turns_make_two_records() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] async fn no_model_identity_means_no_record_and_the_turn_succeeds() { + let _home = home_guard::home_slot(); let _g = ONE_HOME.lock().await; let d = start(None).await; let before = d.records().await; @@ -284,6 +291,7 @@ async fn no_model_identity_means_no_record_and_the_turn_succeeds() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] async fn a_caller_cannot_write_a_generation_record() { + let _home = home_guard::home_slot(); let _g = ONE_HOME.lock().await; let d = start(Some(identity())).await; let (_, id) = d.turn("hello").await; @@ -365,6 +373,7 @@ impl AienInferenceBackend for ObservingMock { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] async fn record_states_the_decoding_the_backend_reported() { + let _home = home_guard::home_slot(); let _g = ONE_HOME.lock().await; let report = DecodeObservation { greedy_tokens: 1, diff --git a/crates/aien-runtime/tests/minted_grant_test.rs b/crates/aien-runtime/tests/minted_grant_test.rs index 0ff2bc97..d3a6133b 100644 --- a/crates/aien-runtime/tests/minted_grant_test.rs +++ b/crates/aien-runtime/tests/minted_grant_test.rs @@ -6,6 +6,9 @@ //! composition archive and is IGNORED in a stub build, never passed. The //! socket-level refusal of a raw `authorization` note is //! `c18_a1_raw_forged_authorization` in approved_attacks_test.rs. +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_omega_compose::hex; use aien_runtime::control::{ComposeNoteReport, ComposeTaskReport, ControlResponse}; use aien_runtime::effects::{self, IntentRequest, MintRequest}; @@ -161,6 +164,7 @@ macro_rules! linked_test { #[test] #[cfg_attr(not(compose_linked), ignore = "needs the linked librx_compose.a")] fn $name() { + let _home = home_guard::home_slot(); let Some($fx) = Fx::new() else { return }; $body } diff --git a/crates/aien-runtime/tests/provenance_link_test.rs b/crates/aien-runtime/tests/provenance_link_test.rs index 420e4478..ef57d29d 100644 --- a/crates/aien-runtime/tests/provenance_link_test.rs +++ b/crates/aien-runtime/tests/provenance_link_test.rs @@ -15,6 +15,9 @@ //! the report as JSON, so the test is the same on a build without the link. //! Every test needs the linked composition archive and is IGNORED in a stub //! build, never passed. +#[path = "support/home_guard.rs"] +mod home_guard; + #[path = "../../aien-allen/tests/support/mod.rs"] mod support; @@ -370,6 +373,7 @@ async fn assert_linked(d: &Daemon, f: &Flow, want_agent: &str) { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] async fn commit_names_generation_record_and_no_agent_when_none_is_attached() { + let _home = home_guard::home_slot(); let _g = ONE_HOME.lock().await; std::env::remove_var(ENV_SUBJECT); std::env::remove_var(ENV_ADOPT); @@ -391,6 +395,7 @@ fn home_lineage(home: &Path) -> [u8; 32] { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] async fn commit_names_generation_record_and_the_allen_logical_agent_id() { + let _home = home_guard::home_slot(); let _g = ONE_HOME.lock().await; std::env::remove_var(ENV_SUBJECT); std::env::remove_var(ENV_ADOPT); @@ -425,6 +430,7 @@ async fn commit_names_generation_record_and_the_allen_logical_agent_id() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] async fn no_model_identity_means_no_generation_claim_and_the_flow_still_works() { + let _home = home_guard::home_slot(); let _g = ONE_HOME.lock().await; std::env::remove_var(ENV_SUBJECT); std::env::remove_var(ENV_ADOPT); @@ -444,6 +450,7 @@ async fn no_model_identity_means_no_generation_claim_and_the_flow_still_works() #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] async fn an_old_ledger_without_provenance_still_opens_and_runs() { + let _home = home_guard::home_slot(); let _g = ONE_HOME.lock().await; std::env::remove_var(ENV_SUBJECT); std::env::remove_var(ENV_ADOPT); @@ -511,6 +518,7 @@ async fn an_old_ledger_without_provenance_still_opens_and_runs() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[cfg_attr(not(compose_linked), ignore = "needs librx_compose.a: stub build")] async fn a_client_cannot_set_the_provenance_fields() { + let _home = home_guard::home_slot(); let _g = ONE_HOME.lock().await; std::env::remove_var(ENV_SUBJECT); std::env::remove_var(ENV_ADOPT); diff --git a/crates/aien-runtime/tests/recall_native_report_test.rs b/crates/aien-runtime/tests/recall_native_report_test.rs index 2f6bb782..c2c68784 100644 --- a/crates/aien-runtime/tests/recall_native_report_test.rs +++ b/crates/aien-runtime/tests/recall_native_report_test.rs @@ -1,6 +1,9 @@ //! VAC M3a: the recall reply says whether the native Omega composition library //! is linked. Runs in both builds (stub: recall is an explicit refusal naming the stub; linked: true and //! the pinned 40-hex sha). One test per binary (it sets AIEN_COMPOSE_DIR). +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_inference_abi::MockInferenceBackend; use aien_kv_cache::create_shared_kv_manager; use aien_runtime::client::AienRuntimeClient; @@ -12,6 +15,7 @@ use std::time::Duration; #[tokio::test] async fn recall_reports_whether_compose_is_native() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); std::env::set_var("AIEN_COMPOSE_DIR", tmp.path().join("compose")); // sc#328: the daemon refuses to start without the (default) desk key. diff --git a/crates/aien-runtime/tests/refusal_table_test.rs b/crates/aien-runtime/tests/refusal_table_test.rs index bb7fa828..4a713c31 100644 --- a/crates/aien-runtime/tests/refusal_table_test.rs +++ b/crates/aien-runtime/tests/refusal_table_test.rs @@ -5,6 +5,9 @@ //! branch must give the identical kind for every row. //! //! Needs the linked composition archive; IGNORED in a stub build. +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_omega_compose::hex; use aien_runtime::control::{ComposeNoteReport, ComposeTaskReport, ControlResponse}; use aien_runtime::effects::{self, IntentRequest, MintRequest}; @@ -277,6 +280,7 @@ const DIFFERS: &[(&str, &str)] = &[( #[test] #[cfg_attr(not(compose_linked), ignore = "needs the linked librx_compose.a")] fn refusal_kinds_match_origin_main() { + let _home = home_guard::home_slot(); if !aien_omega_compose::LINKED { return; } diff --git a/crates/aien-runtime/tests/requirements_deadline_test.rs b/crates/aien-runtime/tests/requirements_deadline_test.rs index 0ac987ed..684183a1 100644 --- a/crates/aien-runtime/tests/requirements_deadline_test.rs +++ b/crates/aien-runtime/tests/requirements_deadline_test.rs @@ -2,6 +2,9 @@ //! second attempt passes: both attempts happen inside the ONE per-task document //! deadline (a short injected budget), and the bytes saved are the bytes approved. //! Own test binary: it sets a process-global environment variable. +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_runtime::control::ControlResponse; use aien_runtime::requirements::extract; use aien_runtime::spine::{ @@ -31,6 +34,7 @@ fn reply(text: String) -> Result<Generation, String> { #[test] fn requirement_retry_stays_inside_the_single_document_deadline_and_saves_approved_bytes() { + let _home = home_guard::home_slot(); std::env::set_var(COMPOSE_DOC_BUDGET_ENV, "6000"); let budget = compose_budgets_from_env().unwrap().doc; assert_eq!(budget, Duration::from_millis(6000)); diff --git a/crates/aien-runtime/tests/requirements_enforce_test.rs b/crates/aien-runtime/tests/requirements_enforce_test.rs index a61d8de7..7c0ad137 100644 --- a/crates/aien-runtime/tests/requirements_enforce_test.rs +++ b/crates/aien-runtime/tests/requirements_enforce_test.rs @@ -2,6 +2,9 @@ //! (crate::requirements, crate::requirements_extract). Covers the two //! open-model-qwen3 v3 gaps (G3 "with" after a count, G2 "covers" topics), //! the uncertain-span refusal and the missing-record refusal (#289). +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_runtime::control::ControlResponse; use aien_runtime::requirements::{analyze, extract, refusal_reason, ItemKind, Requirement}; use aien_runtime::spine::{ @@ -468,6 +471,7 @@ fn result(resp: ControlResponse) -> Option<aien_runtime::control::ComposeTaskRep #[test] fn linked_uncertain_goal_is_refused_before_any_model_call() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let ws = tmp.path().join("ws"); std::fs::create_dir_all(&ws).unwrap(); @@ -495,6 +499,7 @@ fn linked_uncertain_goal_is_refused_before_any_model_call() { #[test] fn linked_g3_original_reply_is_refused_then_a_good_reply_commits_exact_bytes() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let ws = tmp.path().join("ws"); std::fs::create_dir_all(&ws).unwrap(); @@ -519,6 +524,7 @@ fn linked_g3_original_reply_is_refused_then_a_good_reply_commits_exact_bytes() { #[test] fn linked_g2_original_reply_exhausts_and_nothing_is_written() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let ws = tmp.path().join("ws"); std::fs::create_dir_all(&ws).unwrap(); diff --git a/crates/aien-runtime/tests/requirements_test.rs b/crates/aien-runtime/tests/requirements_test.rs index 9d437bd5..b8655e91 100644 --- a/crates/aien-runtime/tests/requirements_test.rs +++ b/crates/aien-runtime/tests/requirements_test.rs @@ -1,4 +1,7 @@ //! Requirement validation for composed documents (crate::requirements). +#[path = "support/home_guard.rs"] +mod home_guard; + use aien_runtime::approved::{approved_proposal_sha256, proposal_text}; use aien_runtime::control::ControlResponse; use aien_runtime::effects; @@ -279,6 +282,7 @@ fn edit_mode_validates_the_merged_file_not_the_reply() { #[test] fn unmet_requirement_leaves_nothing_committed_or_written() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let ws = tmp.path().join("ws"); std::fs::create_dir_all(&ws).unwrap(); @@ -327,6 +331,7 @@ fn dir_names(d: &std::path::Path) -> Vec<String> { /// proposed, approved, written, committed or recorded as an effect. #[test] fn linked_exhaustion_leaves_ledger_state_and_files_untouched() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let ws = tmp.path().join("ws"); std::fs::create_dir_all(&ws).unwrap(); @@ -405,6 +410,7 @@ fn linked_exhaustion_leaves_ledger_state_and_files_untouched() { /// sha256(disk) == the approved content sha256. #[test] fn linked_passing_document_is_approved_and_saved_byte_for_byte() { + let _home = home_guard::home_slot(); let tmp = tempfile::tempdir().unwrap(); let ws = tmp.path().join("ws"); std::fs::create_dir_all(&ws).unwrap(); diff --git a/crates/aien-runtime/tests/support/home_guard.rs b/crates/aien-runtime/tests/support/home_guard.rs new file mode 100644 index 00000000..1878fd4d --- /dev/null +++ b/crates/aien-runtime/tests/support/home_guard.rs @@ -0,0 +1,33 @@ +//! Test-only guard for tests that open a compose home (an `rxc_host` handle). +//! +//! omega's `rxc_host` allows `RXC_HOST_MAX_HANDLES` (4) open handles per +//! process (omega `src/runtime/rxc_host_abi.h`); a fifth open is refused with +//! `E_FULL (-5)`. Rust runs the tests of one test binary on parallel threads in +//! one process, so five tests that each hold a home at the same moment fail +//! with a refusal that has nothing to do with what they check. +//! +//! Every test that opens a home, directly or through a `ComposeBridge`, takes +//! the slot first and keeps it until it ends. One slot for the whole process: +//! those tests run one after another, and a single test may hold up to +//! `RXC_HOST_MAX_HANDLES` homes. More than 4 concurrent homes in one process is +//! not qualified here; that limit belongs to omega. +//! +//! Include with `#[path = "support/home_guard.rs"] mod home_guard;`. Each test +//! binary gets its own copy, so the slot is per process, the same scope as the +//! handle table. +#![allow(dead_code)] + +use std::sync::{Mutex, MutexGuard}; + +static SLOT: Mutex<()> = Mutex::new(()); + +/// Holds the process-wide compose-home slot until dropped. A wrapper, not the +/// bare `MutexGuard`, so an async test may keep it across an `.await` +/// (clippy::await_holding_lock only looks at the bare guard). +pub struct HomeSlot(MutexGuard<'static, ()>); + +/// Wait for the slot. A test that panicked while holding it does not wedge the +/// others: the poison flag is cleared, the slot guards no data. +pub fn home_slot() -> HomeSlot { + HomeSlot(SLOT.lock().unwrap_or_else(|e| e.into_inner())) +}