Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/crates/aien-security/src/network.rs # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / crates / aien-security / src / network.rs` 110 lines ยท 4072 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 //! Network purpose classification and egress governance for AIEN. 17 18 use serde::{Deserialize, Serialize}; 19 use thiserror::Error; 20 21 /// Explicit classification for all outbound network requests. 22 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] 23 pub enum NetworkPurpose { 24 /// Outbound call to a user-configured model inference API or proxy. 25 UserRequestedApi, 26 /// Explicit repository or state synchronization with configured peers. 27 PeerSynchronization, 28 /// Operator-directed download of model weights or tokenizer assets. 29 ModelDownload, 30 /// Optional check for signed software release updates. 31 UpdateCheck, 32 /// Unsolicited usage metrics, analytics, beacons, or behavioral tracking. 33 Telemetry, // no-telemetry 34 } 35 36 impl NetworkPurpose { 37 /// Check whether this network purpose is permitted by policy. 38 pub fn is_permitted(&self) -> bool { 39 !matches!(self, NetworkPurpose::Telemetry) // no-telemetry 40 } 41 42 /// Descriptive name of the network purpose. 43 pub fn as_str(&self) -> &'static str { 44 match self { 45 NetworkPurpose::UserRequestedApi => "UserRequestedApi", 46 NetworkPurpose::PeerSynchronization => "PeerSynchronization", 47 NetworkPurpose::ModelDownload => "ModelDownload", 48 NetworkPurpose::UpdateCheck => "UpdateCheck", 49 NetworkPurpose::Telemetry => "Telemetry", // no-telemetry 50 } 51 } 52 } 53 54 /// Errors occurring during network policy evaluation and routing. 55 #[derive(Debug, Error, PartialEq, Eq)] 56 pub enum NetworkSecurityError { 57 #[error("Outbound destination forbidden by no-telemetry policy")] 58 TelemetryForbidden, // no-telemetry 59 #[error("Egress destination '{0}' is not allowed for purpose '{1}'")] 60 DestinationDisallowed(String, &'static str), 61 #[error("Network operation blocked by air-gap deployment profile")] 62 AirGapBlocked, 63 } 64 65 /// A declared outbound network intent subject to security governance. 66 #[derive(Debug, Clone, Serialize, Deserialize)] 67 pub struct NetworkIntent { 68 pub destination_url: String, 69 pub purpose: NetworkPurpose, 70 pub context: String, 71 } 72 73 impl NetworkIntent { 74 pub fn new(destination_url: impl Into, purpose: NetworkPurpose) -> Self { 75 Self { 76 destination_url: destination_url.into(), 77 purpose, 78 context: String::new(), 79 } 80 } 81 82 pub fn with_context(mut self, context: impl Into) -> Self { 83 self.context = context.into(); 84 self 85 } 86 } 87 88 /// Evaluates network intent against constitutional network policy. 89 pub fn enforce_network_purpose(intent: &NetworkIntent) -> Result<(), NetworkSecurityError> { 90 let is_forbidden = matches!(intent.purpose, NetworkPurpose::Telemetry); // no-telemetry 91 if is_forbidden { 92 tracing::error!( 93 target: "security::network_audit", 94 destination = %intent.destination_url, 95 purpose = %intent.purpose.as_str(), 96 context = %intent.context, 97 "BLOCKED: Outbound request rejected by no-telemetry policy" 98 ); 99 return Err(NetworkSecurityError::TelemetryForbidden); // no-telemetry 100 } 101 102 tracing::debug!( 103 target: "security::network_audit", 104 destination = %intent.destination_url, 105 purpose = %intent.purpose.as_str(), 106 "Permitted outbound request under approved network purpose" 107 ); 108 109 Ok(()) 110 }