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
aien-sovereign-core-mv / crates / aien-runtime / tests / allen_persona_ipc_test.rs
| 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | //! ALLEN persona profile commands over the runtime socket (arch#159): routing |
| 17 | //! only. ALLEN is not engaged here, so status answers "not_engaged" and a |
| 18 | //! change is refused. In a stub omega build the compose home cannot open and |
| 19 | //! the daemon says so (the answer is an error, never a made-up identity). |
| 20 | #[path = "support/home_guard.rs"] |
| 21 | mod home_guard; |
| 22 | |
| 23 | use aien_allen::ENV_SUBJECT; |
| 24 | use aien_inference_abi::MockInferenceBackend; |
| 25 | use aien_kv_cache::create_shared_kv_manager; |
| 26 | use aien_runtime::client::AienRuntimeClient; |
| 27 | use aien_runtime::control::{ControlCommand, ControlResponse}; |
| 28 | use aien_runtime::server::AienRuntimeServer; |
| 29 | use aien_runtime::spine::AienRuntimeSpine; |
| 30 | use aien_scheduler::SchedulerConfig; |
| 31 | use std::time::Duration; |
| 32 | |
| 33 | #[tokio::test(flavor = "multi_thread", worker_threads = 2)] |
| 34 | async fn allen_commands_route_through_the_socket() { |
| 35 | let _home = home_guard::home_slot(); |
| 36 | let tmp = tempfile::tempdir().unwrap(); |
| 37 | // Only this test binary sets these; one test per binary avoids env races. |
| 38 | std::env::set_var("AIEN_COMPOSE_DIR", tmp.path().join("compose")); |
| 39 | // sc#328: the daemon refuses to start without the (default) desk key. |
| 40 | aien_runtime::approved_auth::DeskKey::create(&aien_runtime::approved_auth::desk_key_path( |
| 41 | &tmp.path().join("compose"), |
| 42 | )) |
| 43 | .unwrap(); |
| 44 | std::env::remove_var(ENV_SUBJECT); |
| 45 | let socket = tmp.path().join("runtime.sock"); |
| 46 | let cfg = SchedulerConfig { |
| 47 | max_batch_size: 8, |
| 48 | max_batch_tokens: 1024, |
| 49 | prefill_chunk_size: 64, |
| 50 | watermark_blocks: 4, |
| 51 | chunk_prefill: true, |
| 52 | max_prefill_tokens: 1024, |
| 53 | }; |
| 54 | let spine = AienRuntimeSpine::new(64, cfg, create_shared_kv_manager(256, 16)); |
| 55 | let server = AienRuntimeServer::new(spine, &socket); |
| 56 | let handle = tokio::spawn(async move { server.run(MockInferenceBackend::new(1)).await }); |
| 57 | let client = AienRuntimeClient::new(&socket); |
| 58 | let mut alive = false; |
| 59 | for _ in 0..100 { |
| 60 | if client.is_alive().await { |
| 61 | alive = true; |
| 62 | break; |
| 63 | } |
| 64 | tokio::time::sleep(Duration::from_millis(20)).await; |
| 65 | } |
| 66 | assert!(alive); |
| 67 | let linked = aien_omega_compose::LINKED; |
| 68 | |
| 69 | let st = client |
| 70 | .send_command(ControlCommand::AllenStatus) |
| 71 | .await |
| 72 | .unwrap(); |
| 73 | match (st, linked) { |
| 74 | (ControlResponse::AllenStatusReport(s), true) => { |
| 75 | assert_eq!(s.identity, "not_engaged"); |
| 76 | assert_eq!(s.model, "model:StreamTurn-path"); |
| 77 | assert_eq!(s.unsupported, vec!["avatar", "voice"]); |
| 78 | } |
| 79 | (ControlResponse::Error(e), false) => assert!(e.contains("not linked"), "{e}"), |
| 80 | (o, l) => panic!("unexpected {o:?} (linked={l})"), |
| 81 | } |
| 82 | let set = client |
| 83 | .send_command(ControlCommand::AllenProfileSet { |
| 84 | expected_revision: 0, |
| 85 | changes: aien_allen_profile::Changes { |
| 86 | name: Some("Nova".into()), |
| 87 | ..Default::default() |
| 88 | }, |
| 89 | }) |
| 90 | .await |
| 91 | .unwrap(); |
| 92 | match (set, linked) { |
| 93 | (ControlResponse::AllenRefused(r), true) => assert_eq!(r.code, "not_engaged"), |
| 94 | (ControlResponse::Error(e), false) => assert!(e.contains("not linked"), "{e}"), |
| 95 | (o, l) => panic!("unexpected {o:?} (linked={l})"), |
| 96 | } |
| 97 | assert!(!tmp.path().join("compose.allen-profile").exists()); |
| 98 | let _ = client.send_command(ControlCommand::Shutdown).await; |
| 99 | let _ = tokio::time::timeout(Duration::from_secs(5), handle).await; |
| 100 | } |