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-runtime / tests / runtime_socket_permissions_test.rs

73 lines · 2839 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//! The runtime socket accepts operator commands (launch, cancel, shutdown), so
17//! it must be reachable only by its owner.
18
19use aien_inference_abi::MockInferenceBackend;
20use aien_kv_cache::create_shared_kv_manager;
21use aien_runtime::client::AienRuntimeClient;
22use aien_runtime::server::AienRuntimeServer;
23use aien_runtime::spine::AienRuntimeSpine;
24use aien_scheduler::SchedulerConfig;
25use std::os::unix::fs::PermissionsExt;
26use std::time::Duration;
27
28#[tokio::test]
29async fn runtime_socket_is_owner_only() {
30 let dir = std::env::temp_dir().join(format!("aien-sock-perm-{}", std::process::id()));
31 let _ = std::fs::create_dir_all(&dir);
32 std::env::set_var("AIEN_RUNTIME_STATE_DIR", &dir);
33 // sc#328: the daemon refuses to start without the (default) desk key.
34 std::env::set_var("AIEN_COMPOSE_DIR", dir.join("compose"));
35 let key = aien_runtime::approved_auth::desk_key_path(&dir.join("compose"));
36 if !key.exists() {
37 aien_runtime::approved_auth::DeskKey::create(&key).unwrap();
38 }
39 let socket_path = dir.join("runtime.sock");
40
41 let scheduler_config = SchedulerConfig {
42 max_batch_size: 8,
43 max_batch_tokens: 512,
44 prefill_chunk_size: 64,
45 watermark_blocks: 4,
46 chunk_prefill: true,
47 max_prefill_tokens: 512,
48 };
49 let spine = AienRuntimeSpine::new(64, scheduler_config, create_shared_kv_manager(128, 16));
50 let server = AienRuntimeServer::new(spine, &socket_path);
51 let handle = tokio::spawn(async move { server.run(MockInferenceBackend::new(1)).await });
52
53 // Wait until the server answers: the file exists from bind(), but the
54 // mode is only final once the server is serving.
55 let client = AienRuntimeClient::new(&socket_path);
56 for _ in 0..250 {
57 if client.is_alive().await {
58 break;
59 }
60 tokio::time::sleep(Duration::from_millis(20)).await;
61 }
62 let mode = std::fs::metadata(&socket_path)
63 .ok()
64 .map(|meta| meta.permissions().mode() & 0o777);
65 handle.abort();
66 let _ = std::fs::remove_file(&socket_path);
67
68 assert_eq!(
69 mode,
70 Some(0o600),
71 "runtime socket must be owner read/write only"
72 );
73}