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 / aien-capability / src / ids.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 sha2::{Digest, Sha256}; |
| 17 | |
| 18 | /// SHA-256 digest used for catalogs, policies, and capability identity. |
| 19 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
| 20 | pub struct Digest32(pub [u8; 32]); |
| 21 | |
| 22 | impl Digest32 { |
| 23 | pub fn of(bytes: &[u8]) -> Self { |
| 24 | let hashed = Sha256::digest(bytes); |
| 25 | let mut out = [0u8; 32]; |
| 26 | out.copy_from_slice(&hashed); |
| 27 | Self(out) |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | /// Stable idempotency key for one external effect attempt. |
| 32 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
| 33 | pub struct EffectId(pub [u8; 16]); |
| 34 | |
| 35 | impl EffectId { |
| 36 | pub fn from_label(label: &str) -> Self { |
| 37 | let digest = Digest32::of(label.as_bytes()); |
| 38 | let mut id = [0u8; 16]; |
| 39 | id.copy_from_slice(&digest.0[..16]); |
| 40 | Self(id) |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | /// Admitted MCP (or other) provider. Enrollment lives outside J-Space. |
| 45 | #[derive(Clone, Debug, PartialEq, Eq, Hash)] |
| 46 | pub struct ProviderId(String); |
| 47 | |
| 48 | impl ProviderId { |
| 49 | pub fn new(name: impl Into<String>) -> Self { |
| 50 | Self(name.into()) |
| 51 | } |
| 52 | |
| 53 | pub fn as_str(&self) -> &str { |
| 54 | &self.0 |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | impl std::fmt::Display for ProviderId { |
| 59 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 60 | f.write_str(&self.0) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /// Branchable execution state that a winning plan commits into. |
| 65 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
| 66 | pub struct WorldId(pub u64); |
| 67 | |
| 68 | /// J-Space node that produced a staged effect. |
| 69 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
| 70 | pub struct JNodeId(pub u64); |