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-capability / src / tool.rs

69 lines · 2241 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
16use crate::{Digest32, ToolEffects};
17use sha2::{Digest, Sha256};
18
19/// Atomic operation the capability graph names. An MCP tool name is a binding
20/// under this descriptor, not a second identity.
21#[derive(Clone, Debug, PartialEq, Eq)]
22pub struct ToolDescriptor {
23 name: String,
24 effects: ToolEffects,
25 schema_digest: Digest32,
26}
27
28impl ToolDescriptor {
29 pub fn new(name: impl Into<String>, effects: ToolEffects, schema_digest: Digest32) -> Self {
30 Self {
31 name: name.into(),
32 effects,
33 schema_digest,
34 }
35 }
36
37 pub fn name(&self) -> &str {
38 &self.name
39 }
40
41 pub fn effects(&self) -> ToolEffects {
42 self.effects
43 }
44
45 pub fn capability_digest(&self) -> Digest32 {
46 let mut hasher = Sha256::new();
47 hasher.update(self.name.as_bytes());
48 hasher.update(self.effects.bits().to_le_bytes());
49 hasher.update(self.schema_digest.0);
50 let hashed = hasher.finalize();
51 let mut out = [0u8; 32];
52 out.copy_from_slice(&hashed);
53 Digest32(out)
54 }
55}
56
57/// Digest of a provider catalog. Order of declaration does not change the digest.
58pub fn catalog_digest(tools: &[ToolDescriptor]) -> Digest32 {
59 let mut ordered: Vec<&ToolDescriptor> = tools.iter().collect();
60 ordered.sort_by(|left, right| left.name.cmp(&right.name));
61 let mut hasher = Sha256::new();
62 for tool in ordered {
63 hasher.update(tool.capability_digest().0);
64 }
65 let hashed = hasher.finalize();
66 let mut out = [0u8; 32];
67 out.copy_from_slice(&hashed);
68 Digest32(out)
69}