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 / spark-hive / src / emission.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 | use crate::store::{CombStore, HiveComb, HiveError, PlaceCombInput}; |
| 17 | |
| 18 | /// Emits a comb onto the hexagonal honeycomb lattice when an agent or subagent completes a task. |
| 19 | pub fn emit_subagent_comb( |
| 20 | store: &CombStore, |
| 21 | role: &str, |
| 22 | summary: &str, |
| 23 | parent_id: Option<&str>, |
| 24 | ) -> Result<HiveComb, HiveError> { |
| 25 | let author = format!("AIEN ยท {}", role); |
| 26 | let input = PlaceCombInput { |
| 27 | q: None, |
| 28 | r: None, |
| 29 | author, |
| 30 | role: Some(role.to_string()), |
| 31 | content: summary.to_string(), |
| 32 | intent: Some("join".to_string()), |
| 33 | parent_id: parent_id.map(|s| s.to_string()), |
| 34 | }; |
| 35 | store.place_comb(input) |
| 36 | } |
| 37 | |
| 38 | /// Emits a comb onto the hexagonal honeycomb lattice when Socratic inquiry is triggered. |
| 39 | pub fn emit_socratic_comb( |
| 40 | store: &CombStore, |
| 41 | question: &str, |
| 42 | parent_id: Option<&str>, |
| 43 | ) -> Result<HiveComb, HiveError> { |
| 44 | let author = "AIEN (Socratic)".to_string(); |
| 45 | let input = PlaceCombInput { |
| 46 | q: None, |
| 47 | r: None, |
| 48 | author, |
| 49 | role: Some("socratic".to_string()), |
| 50 | content: question.to_string(), |
| 51 | intent: Some("branch".to_string()), |
| 52 | parent_id: parent_id.map(|s| s.to_string()), |
| 53 | }; |
| 54 | store.place_comb(input) |
| 55 | } |
| 56 | |
| 57 | #[cfg(test)] |
| 58 | mod tests { |
| 59 | use super::*; |
| 60 | |
| 61 | #[test] |
| 62 | fn test_subagent_and_socratic_emission() { |
| 63 | let store = CombStore::open_in_memory().expect("in memory store"); |
| 64 | |
| 65 | // 1. Emit socratic inquiry comb |
| 66 | let socratic = emit_socratic_comb( |
| 67 | &store, |
| 68 | "What is the foundational invariant of this sovereign workspace?", |
| 69 | Some("comb-genesis-00000000"), |
| 70 | ) |
| 71 | .expect("socratic emission"); |
| 72 | |
| 73 | assert_eq!(socratic.role, "socratic"); |
| 74 | assert_eq!(socratic.intent, "branch"); |
| 75 | assert_eq!( |
| 76 | socratic.parent_id, |
| 77 | Some("comb-genesis-00000000".to_string()) |
| 78 | ); |
| 79 | |
| 80 | // 2. Emit subagent completed comb |
| 81 | let sub = emit_subagent_comb( |
| 82 | &store, |
| 83 | "researcher", |
| 84 | "Synthesized hexagonal honeycomb topology specifications.", |
| 85 | Some(&socratic.id), |
| 86 | ) |
| 87 | .expect("subagent emission"); |
| 88 | |
| 89 | assert_eq!(sub.role, "researcher"); |
| 90 | assert_eq!(sub.intent, "join"); |
| 91 | assert_eq!(sub.parent_id, Some(socratic.id.clone())); |
| 92 | |
| 93 | // Verify total count on lattice |
| 94 | let (cells, bounds) = store.get_cells().expect("get cells"); |
| 95 | assert_eq!(cells.len(), 3); |
| 96 | assert_eq!(bounds.count, 3); |
| 97 | } |
| 98 | } |