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

GitHub aien-dev/aien-sovereign-core-mv#52 (code only)

closed derived 0e2f3730ae93f92b #52

Imported from GitHub aien-dev/aien-sovereign-core-mv#52 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 00809cec5e5eb04287b520b1bcebfe19a9148951 · Head c5bad4015e365e1e63e747a523bb651f48450d0a

Apply it

git checkout -b patch-0e2f3730ae93f92b 00809cec5e5eb04287b520b1bcebfe19a9148951
curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/0e2f3730ae93f92b.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aien-sovereign-core-mv
52
c5bad4015e365e1e63e747a523bb651f48450d0a
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":52,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/52","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:23Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/Cargo.lock b/Cargo.lock
index 46f4dbba..9da24f52 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -68,6 +68,14 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "aien-platform"
+version = "0.1.0"
+dependencies = [
+ "serde",
+ "spin",
+]
+
 [[package]]
 name = "aien-scheduler"
 version = "0.1.0"
@@ -3228,6 +3236,15 @@ dependencies = [
  "tracing-subscriber",
 ]
 
+[[package]]
+name = "spin"
+version = "0.9.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e"
+dependencies = [
+ "lock_api",
+]
+
 [[package]]
 name = "spm_precompiled"
 version = "0.1.4"
diff --git a/Cargo.toml b/Cargo.toml
index 2f5bb3d2..9fa7d519 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,6 +23,7 @@ members = [
     "crates/aien-kv-cache",
     "crates/aien-scheduler",
     "crates/aien-security",
+    "crates/aien-platform",
 ]
 
 [workspace.package]
diff --git a/crates/aien-platform/Cargo.toml b/crates/aien-platform/Cargo.toml
new file mode 100644
index 00000000..19533e81
--- /dev/null
+++ b/crates/aien-platform/Cargo.toml
@@ -0,0 +1,19 @@
+[package]
+name = "aien-platform"
+version.workspace = true
+edition.workspace = true
+license.workspace = true
+authors.workspace = true
+repository.workspace = true
+description = "Pure no_std capability and compute platform ABI for the AIEN and SparkOS runtime"
+
+[dependencies]
+serde = { version = "1.0", default-features = false, features = ["alloc", "derive"], optional = true }
+
+[features]
+default = ["alloc"]
+alloc = []
+serde = ["dep:serde"]
+
+[dev-dependencies]
+spin = "0.9"
diff --git a/crates/aien-platform/src/compute.rs b/crates/aien-platform/src/compute.rs
new file mode 100644
index 00000000..91888043
--- /dev/null
+++ b/crates/aien-platform/src/compute.rs
@@ -0,0 +1,44 @@
+use crate::PlatformError;
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct DeviceAddress(pub u64);
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct BufferLayout {
+    pub size: usize,
+    pub align: usize,
+}
+
+impl BufferLayout {
+    pub const fn new(size: usize, align: usize) -> Self {
+        Self { size, align }
+    }
+}
+
+pub trait UnifiedBuffer {
+    fn len(&self) -> usize;
+    fn is_empty(&self) -> bool {
+        self.len() == 0
+    }
+    fn device_address(&self) -> DeviceAddress;
+    fn as_ptr(&self) -> *const u8;
+    fn as_mut_ptr(&mut self) -> *mut u8;
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct Fence(pub u64);
+
+pub struct ComputeWork<'a> {
+    pub kernel_id: u32,
+    pub input_buffer: DeviceAddress,
+    pub output_buffer: DeviceAddress,
+    pub params: &'a [u8],
+}
+
+pub trait ComputeDevice {
+    type Buffer: UnifiedBuffer;
+
+    fn alloc(&self, layout: BufferLayout) -> Result<Self::Buffer, PlatformError>;
+    fn submit(&self, work: ComputeWork<'_>) -> Result<Fence, PlatformError>;
+    fn synchronize(&self, fence: Fence) -> Result<(), PlatformError>;
+}
diff --git a/crates/aien-platform/src/lib.rs b/crates/aien-platform/src/lib.rs
new file mode 100644
index 00000000..191286da
--- /dev/null
+++ b/crates/aien-platform/src/lib.rs
@@ -0,0 +1,115 @@
+//! Pure no_std platform traits and capability abstractions for the AIEN and SparkOS runtime.
+//! Eliminates POSIX/Linux concepts (PathBuf, Command, sockets, threads, procfs) from core cognition and scheduling.
+
+#![no_std]
+
+extern crate alloc;
+
+use alloc::string::String;
+
+pub mod compute;
+pub mod memory;
+pub mod objects;
+pub mod queue;
+pub mod runtime;
+pub mod task;
+pub mod telemetry;
+
+pub use compute::{BufferLayout, ComputeDevice, ComputeWork, DeviceAddress, Fence, UnifiedBuffer};
+pub use memory::{MemoryEntity, MemoryService, RecallQuery, RecallResult};
+pub use objects::{ObjectId, ObjectRef, ObjectStore, ObjectWrite};
+pub use queue::{InferenceWork, KvHandle, ModelHandle, Priority, QueueError, SequenceId, Ticks, WorkQueue};
+pub use runtime::Runtime;
+pub use task::{TaskExecutor, TaskRequest, TaskResult};
+pub use telemetry::{TelemetrySnapshot, TelemetrySource};
+
+/// Fundamental platform error enumeration free of host OS dependencies.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum PlatformError {
+    OutOfMemory,
+    DeviceUnavailable,
+    InvalidLayout,
+    QueueFull,
+    QueueEmpty,
+    TaskRejected(String),
+    ObjectNotFound(ObjectId),
+    AccessDenied,
+    HardwareFault(String),
+    UnsupportedOperation,
+}
+
+impl core::fmt::Display for PlatformError {
+    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+        match self {
+            Self::OutOfMemory => write!(f, "Platform error: out of physical/unified memory"),
+            Self::DeviceUnavailable => write!(f, "Platform error: compute device unavailable"),
+            Self::InvalidLayout => write!(f, "Platform error: invalid buffer layout or alignment"),
+            Self::QueueFull => write!(f, "Platform error: work queue capacity exceeded"),
+            Self::QueueEmpty => write!(f, "Platform error: work queue empty"),
+            Self::TaskRejected(msg) => write!(f, "Platform error: task execution rejected: {}", msg),
+            Self::ObjectNotFound(id) => write!(f, "Platform error: object {:?} not found", id),
+            Self::AccessDenied => write!(f, "Platform error: capability access denied"),
+            Self::HardwareFault(msg) => write!(f, "Platform error: hardware fault: {}", msg),
+            Self::UnsupportedOperation => write!(f, "Platform error: unsupported operation on target substrate"),
+        }
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use alloc::string::ToString;
+
+    #[test]
+    fn test_platform_error_display() {
+        assert_eq!(
+            PlatformError::OutOfMemory.to_string(),
+            "Platform error: out of physical/unified memory"
+        );
+        assert_eq!(
+            PlatformError::DeviceUnavailable.to_string(),
+            "Platform error: compute device unavailable"
+        );
+        assert_eq!(
+            PlatformError::QueueFull.to_string(),
+            "Platform error: work queue capacity exceeded"
+        );
+        assert_eq!(
+            PlatformError::AccessDenied.to_string(),
+            "Platform error: capability access denied"
+        );
+        assert_eq!(
+            PlatformError::TaskRejected("timeout".into()).to_string(),
+            "Platform error: task execution rejected: timeout"
+        );
+    }
+
+    #[test]
+    fn test_queue_priority_ordering() {
+        assert!(Priority::Realtime > Priority::Interactive);
+        assert!(Priority::Interactive > Priority::Normal);
+        assert!(Priority::Normal > Priority::Background);
+    }
+
+    #[test]
+    fn test_buffer_layout() {
+        let layout = BufferLayout::new(4096, 128);
+        assert_eq!(layout.size, 4096);
+        assert_eq!(layout.align, 128);
+    }
+
+    #[test]
+    fn test_telemetry_snapshot() {
+        let snap = TelemetrySnapshot {
+            architecture: "aarch64".into(),
+            target: "gb10".into(),
+            clock_ticks: 1_000_000,
+            memory_used_bytes: 1024 * 1024 * 100,
+            memory_total_bytes: 1024 * 1024 * 1024 * 128,
+            active_sequences: 8,
+        };
+        assert_eq!(snap.architecture, "aarch64");
+        assert_eq!(snap.target, "gb10");
+        assert_eq!(snap.active_sequences, 8);
+    }
+}
diff --git a/crates/aien-platform/src/memory.rs b/crates/aien-platform/src/memory.rs
new file mode 100644
index 00000000..1d69ad1e
--- /dev/null
+++ b/crates/aien-platform/src/memory.rs
@@ -0,0 +1,24 @@
+use crate::PlatformError;
+use alloc::string::String;
+use alloc::vec::Vec;
+
+pub struct RecallQuery<'a> {
+    pub text: &'a str,
+    pub space: &'a str,
+    pub limit: usize,
+}
+
+pub struct MemoryEntity {
+    pub id: [u8; 16],
+    pub canonical_name: String,
+    pub content: String,
+    pub score: f32,
+}
+
+pub struct RecallResult {
+    pub entities: Vec<MemoryEntity>,
+}
+
+pub trait MemoryService {
+    fn recall(&self, query: RecallQuery<'_>) -> Result<RecallResult, PlatformError>;
+}
diff --git a/crates/aien-platform/src/objects.rs b/crates/aien-platform/src/objects.rs
new file mode 100644
index 00000000..4a07b73b
--- /dev/null
+++ b/crates/aien-platform/src/objects.rs
@@ -0,0 +1,20 @@
+use crate::PlatformError;
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct ObjectId(pub [u8; 32]);
+
+pub struct ObjectRef<'a> {
+    pub id: ObjectId,
+    pub data: &'a [u8],
+}
+
+pub struct ObjectWrite<'a> {
+    pub id: Option<ObjectId>,
+    pub data: &'a [u8],
+    pub tags: &'a [&'a str],
+}
+
+pub trait ObjectStore {
+    fn read(&self, id: ObjectId) -> Result<ObjectRef<'_>, PlatformError>;
+    fn commit(&self, object: ObjectWrite<'_>) -> Result<ObjectId, PlatformError>;
+}
diff --git a/crates/aien-platform/src/queue.rs b/crates/aien-platform/src/queue.rs
new file mode 100644
index 00000000..96292ed9
--- /dev/null
+++ b/crates/aien-platform/src/queue.rs
@@ -0,0 +1,54 @@
+pub type SequenceId = u64;
+pub type Ticks = u64;
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub enum Priority {
+    Background = 0,
+    Normal = 1,
+    Interactive = 2,
+    Realtime = 3,
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct ModelHandle(pub u32);
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct KvHandle(pub u64);
+
+/// The fundamental scheduling unit of SparkOS: tokens are the workload, not processes.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct InferenceWork {
+    pub sequence: SequenceId,
+    pub model: ModelHandle,
+    pub kv: KvHandle,
+    pub priority: Priority,
+    pub deadline: Option<Ticks>,
+    pub branch_parent: Option<SequenceId>,
+    pub next_token_budget: u32,
+}
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum QueueError {
+    Full,
+    Empty,
+    InvalidSequence(SequenceId),
+}
+
+impl core::fmt::Display for QueueError {
+    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+        match self {
+            Self::Full => write!(f, "WorkQueue error: queue capacity exceeded"),
+            Self::Empty => write!(f, "WorkQueue error: queue empty"),
+            Self::InvalidSequence(id) => write!(f, "WorkQueue error: invalid sequence id {}", id),
+        }
+    }
+}
+
+pub trait WorkQueue {
+    fn push(&self, work: InferenceWork) -> Result<(), QueueError>;
+    fn pop(&self) -> Option<InferenceWork>;
+    fn len(&self) -> usize;
+    fn is_empty(&self) -> bool {
+        self.len() == 0
+    }
+}
diff --git a/crates/aien-platform/src/runtime.rs b/crates/aien-platform/src/runtime.rs
new file mode 100644
index 00000000..ede4f1cb
--- /dev/null
+++ b/crates/aien-platform/src/runtime.rs
@@ -0,0 +1,105 @@
+use crate::compute::ComputeDevice;
+use crate::queue::WorkQueue;
+
+/// Zero-cost, statically dispatched inference runtime.
+/// Avoids dynamic vtables across the platform boundary for maximum inlining and zero context switching.
+pub struct Runtime<D, Q>
+where
+    D: ComputeDevice,
+    Q: WorkQueue,
+{
+    pub device: D,
+    pub queue: Q,
+}
+
+impl<D, Q> Runtime<D, Q>
+where
+    D: ComputeDevice,
+    Q: WorkQueue,
+{
+    pub const fn new(device: D, queue: Q) -> Self {
+        Self { device, queue }
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use crate::compute::*;
+    use crate::queue::*;
+    use crate::PlatformError;
+    use alloc::vec;
+    use alloc::vec::Vec;
+
+    struct MockBuffer(Vec<u8>);
+    impl UnifiedBuffer for MockBuffer {
+        fn len(&self) -> usize {
+            self.0.len()
+        }
+        fn device_address(&self) -> DeviceAddress {
+            DeviceAddress(self.0.as_ptr() as u64)
+        }
+        fn as_ptr(&self) -> *const u8 {
+            self.0.as_ptr()
+        }
+        fn as_mut_ptr(&mut self) -> *mut u8 {
+            self.0.as_mut_ptr()
+        }
+    }
+
+    struct MockDevice;
+    impl ComputeDevice for MockDevice {
+        type Buffer = MockBuffer;
+
+        fn alloc(&self, layout: BufferLayout) -> Result<Self::Buffer, PlatformError> {
+            Ok(MockBuffer(vec![0u8; layout.size]))
+        }
+
+        fn submit(&self, _work: ComputeWork<'_>) -> Result<Fence, PlatformError> {
+            Ok(Fence(1))
+        }
+
+        fn synchronize(&self, _fence: Fence) -> Result<(), PlatformError> {
+            Ok(())
+        }
+    }
+
+    struct MockQueue(spin::Mutex<Vec<InferenceWork>>);
+    impl WorkQueue for MockQueue {
+        fn push(&self, work: InferenceWork) -> Result<(), QueueError> {
+            self.0.lock().push(work);
+            Ok(())
+        }
+        fn pop(&self) -> Option<InferenceWork> {
+            self.0.lock().pop()
+        }
+        fn len(&self) -> usize {
+            self.0.lock().len()
+        }
+    }
+
+    #[test]
+    fn test_statically_dispatched_runtime() {
+        let device = MockDevice;
+        let queue = MockQueue(spin::Mutex::new(Vec::new()));
+        let runtime = Runtime::new(device, queue);
+
+        let buf = runtime.device.alloc(BufferLayout::new(1024, 64)).unwrap();
+        assert_eq!(buf.len(), 1024);
+
+        let work = InferenceWork {
+            sequence: 1,
+            model: ModelHandle(10),
+            kv: KvHandle(100),
+            priority: Priority::Interactive,
+            deadline: Some(500),
+            branch_parent: None,
+            next_token_budget: 32,
+        };
+
+        runtime.queue.push(work.clone()).unwrap();
+        assert_eq!(runtime.queue.len(), 1);
+        let popped = runtime.queue.pop().unwrap();
+        assert_eq!(popped, work);
+    }
+}
diff --git a/crates/aien-platform/src/task.rs b/crates/aien-platform/src/task.rs
new file mode 100644
index 00000000..9dd39c53
--- /dev/null
+++ b/crates/aien-platform/src/task.rs
@@ -0,0 +1,20 @@
+use crate::PlatformError;
+use alloc::string::String;
+use alloc::vec::Vec;
+
+pub struct TaskRequest<'a> {
+    pub capability_token: u64,
+    pub command_tag: &'a str,
+    pub payload: &'a [u8],
+    pub timeout_ticks: Option<u64>,
+}
+
+pub struct TaskResult {
+    pub exit_code: i32,
+    pub output: Vec<u8>,
+    pub error_log: Option<String>,
+}
+
+pub trait TaskExecutor {
+    fn execute(&self, task: TaskRequest<'_>) -> Result<TaskResult, PlatformError>;
+}
diff --git a/crates/aien-platform/src/telemetry.rs b/crates/aien-platform/src/telemetry.rs
new file mode 100644
index 00000000..bb883b12
--- /dev/null
+++ b/crates/aien-platform/src/telemetry.rs
@@ -0,0 +1,16 @@
+use crate::PlatformError;
+use alloc::string::String;
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct TelemetrySnapshot {
+    pub architecture: String,
+    pub target: String,
+    pub clock_ticks: u64,
+    pub memory_used_bytes: usize,
+    pub memory_total_bytes: usize,
+    pub active_sequences: usize,
+}
+
+pub trait TelemetrySource {
+    fn snapshot(&self) -> Result<TelemetrySnapshot, PlatformError>;
+}