interplane.Get Omega
Read in your language

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

branch main Branches Tags History

aien-sovereign-core-mv / crates / aien-cli / tests / test_cli_runtime_ipc.rs

120 lines · 4166 bytes Raw Blame History
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//! Integration tests for AIEN CLI and runtime IPC protocol.
17
18use aien_inference_abi::MockInferenceBackend;
19use aien_runtime::client::AienRuntimeClient;
20use aien_runtime::control::LaunchSwarmReq;
21use aien_runtime::server::AienRuntimeServer;
22use aien_runtime::spine::AienRuntimeSpine;
23use aien_runtime::{create_shared_kv_manager, SchedulerConfig};
24use std::time::Duration;
25use tempfile::TempDir;
26
27#[tokio::test]
28async fn test_cli_runtime_ipc_lifecycle() {
29 let temp_dir = TempDir::new().expect("Failed to create tempdir");
30 let socket_path = temp_dir.path().join("aien-test.sock");
31 std::env::set_var("AIEN_RUNTIME_SOCK", socket_path.to_str().unwrap());
32 // Keep the idempotency log out of the shared /tmp default used by a live runtime.
33 std::env::set_var("AIEN_RUNTIME_STATE_DIR", temp_dir.path());
34 // sc#328: the daemon refuses to start without the (default) desk key.
35 std::env::set_var("AIEN_COMPOSE_DIR", temp_dir.path().join("compose"));
36 aien_runtime::approved_auth::DeskKey::create(&aien_runtime::approved_auth::desk_key_path(
37 &temp_dir.path().join("compose"),
38 ))
39 .unwrap();
40
41 let kv_manager = create_shared_kv_manager(512, 16);
42 let sched_cfg = SchedulerConfig {
43 max_batch_size: 32,
44 max_batch_tokens: 2048,
45 max_prefill_tokens: 1024,
46 prefill_chunk_size: 64,
47 chunk_prefill: true,
48 watermark_blocks: 8,
49 };
50
51 let spine = AienRuntimeSpine::new(256, sched_cfg, kv_manager);
52 let server = AienRuntimeServer::new(spine, &socket_path);
53
54 let server_handle = tokio::spawn(async move {
55 let backend = MockInferenceBackend::new(1);
56 server.run(backend).await
57 });
58
59 let client = AienRuntimeClient::default_client();
60 let mut ready = false;
61 for _ in 0..50 {
62 if client.is_alive().await {
63 ready = true;
64 break;
65 }
66 tokio::time::sleep(Duration::from_millis(20)).await;
67 }
68 assert!(
69 ready,
70 "Runtime server must become alive on designated socket"
71 );
72
73 // 1. Check status
74 let status = client
75 .get_status()
76 .await
77 .expect("Status query must succeed");
78 assert_eq!(status.active_sequences, 0);
79
80 // 2. Launch swarm
81 let prompt: Vec<u32> = (1..=16).collect();
82 let req = LaunchSwarmReq {
83 model_handle: 1,
84 branch_count: 4,
85 max_active_sequences: 8,
86 max_tokens_per_branch: 8,
87 root_world_id: 0,
88 priority: 1,
89 prompt_tokens: prompt,
90 };
91
92 let swarm_id = client.launch_swarm(req).await.expect("Launch must succeed");
93 assert_eq!(swarm_id, 1);
94
95 // 3. Inspect swarm
96 let swarm_status = client
97 .inspect_swarm(swarm_id)
98 .await
99 .expect("Inspect must succeed");
100 // The mock backend may finish all branches before this request lands, so
101 // assert the swarm-scoped invariant rather than a still-running count.
102 assert!(
103 swarm_status.active_sequences <= 4,
104 "at most the 4 launched branches"
105 );
106 assert_eq!(
107 swarm_status.active_swarms == 1,
108 swarm_status.active_sequences > 0,
109 "swarm is active exactly while it has running branches"
110 );
111
112 // 4. Clean shutdown
113 client.shutdown().await.expect("Shutdown must succeed");
114 server_handle
115 .await
116 .expect("Server task panicked")
117 .expect("Server exited with error");
118 assert_eq!((), ());
119 assert!(!socket_path.exists(), "Socket must be removed on shutdown");
120}