From 95a5d6052daa9f6a81c731842628db28a4e05482 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 15 Oct 2026 06:19:01 -0500 Subject: [PATCH 1/5] chore: remove Modular MAX and Mojo Drake ordered Modular MAX and Mojo out of AIEN. - Delete mojo/aegis_simd.mojo, build.rs and the libloading bridge (src/mojo_bridge.rs). The pure Rust fallback is now the only path, in src/vector_math.rs (VectorMath), with its tests and golden-vector parity. - Drop the libloading dependency (Cargo.lock updated by cargo). - /health no longer reports mojo_simd_accelerated or mojo_simd_version; the simd_eval WebSocket reply drops "accelerated" and "version". - The chat route no longer accepts the "modular-max" model alias. - Port 18006 is the generic OpenAI-compatible local model seat: the CLI flag --max-url is now --model-url, the heartbeat task is "model_health" ("max_health" still accepted for queued tasks), and log text no longer names MAX. - Gate manifests and run.sh no longer list mojo/ or build.rs or clean up the generated .so. - README, AGENTS.md, CONSTITUTION.md, llms.txt, agent.json, docs/INNOVATIONS.md and the issue template no longer describe Mojo or MAX as a dependency. The INNOVATIONS figures measured on MAX are kept with a dated note. Co-Authored-By: Claude Opus 5.5 --- .github/ISSUE_TEMPLATE/agent_task.md | 2 +- AGENTS.md | 4 +- CONSTITUTION.md | 2 +- Cargo.lock | 11 - Cargo.toml | 1 - README.md | 25 +- agent.json | 9 +- build.rs | 32 -- docs/INNOVATIONS.md | 17 +- llms.txt | 12 +- mojo/.crumb | 31 -- mojo/aegis_simd.mojo | 55 ---- src/gateway.rs | 13 +- src/heartbeat.rs | 10 +- src/inference.rs | 40 +-- src/lib.rs | 4 +- src/main.rs | 80 +++-- src/{mojo_bridge.rs => vector_math.rs} | 391 ++++--------------------- tests/aegis_tests.rs | 47 +-- tests/canonical_abi_tests.rs | 8 +- tests/gates/aegis-check.gate | 2 - tests/gates/aegis-clippy.gate | 2 - tests/gates/aegis-fmt.gate | 1 - tests/gates/aegis-test.gate | 2 - tests/gates/run.sh | 17 +- 25 files changed, 187 insertions(+), 631 deletions(-) delete mode 100644 build.rs delete mode 100644 mojo/.crumb delete mode 100644 mojo/aegis_simd.mojo rename src/{mojo_bridge.rs => vector_math.rs} (50%) diff --git a/.github/ISSUE_TEMPLATE/agent_task.md b/.github/ISSUE_TEMPLATE/agent_task.md index 073f6d6..f884ee8 100644 --- a/.github/ISSUE_TEMPLATE/agent_task.md +++ b/.github/ISSUE_TEMPLATE/agent_task.md @@ -10,7 +10,7 @@ assignees: "" [Clear description of the engineering objective] ## Constraints -- Architecture: Pure native Rust and Mojo +- Architecture: Pure native Rust - Secrets: Hardware TPM vault only (Zero disk secrets) - Voice: Unslop standard (Zero em dashes and en dashes) - PR Discipline: Feature branch and PR squash merge only diff --git a/AGENTS.md b/AGENTS.md index 1881669..0ca94bf 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -6,11 +6,11 @@ This document defines the interface and protocols for autonomous agents interact 1. **Branch Isolation**: Never commit directly to `main`. Create feature branches (`feat/`, `fix/`, `perf/`), execute preflight checks, and open public Pull Requests immediately. 2. **Zero Disk Secrets**: Never write plaintext `.env` files. Secrets resolve in memory from `atlas-vault get `. `VaultResolver` is a client of that command, not a TPM. Read the process environment only when `AIEN_DEV_SECRET_FALLBACK=1`. Redact secrets with `[REDACTED_BY_ATLAS_VAULT]`. 3. **Unslop Standard**: Zero em dashes (`-`) and zero en dashes (`-`). Use commas, colons, or parentheses. Do not use AI clichés or conversational filler. -4. **Pure Native Execution**: Core runtime services must compile to native Rust and Mojo. Do not introduce Node.js or Python daemons. +4. **Pure Native Execution**: Core runtime services must compile to native Rust. Do not introduce Node.js or Python daemons. ## Architecture and Endpoints - **Control Plane**: Port 18096 (Axum REST, SSE, WebSocket). -- **Local MAX Inference**: Port 18006 (Modular MAX engine running on GB10). +- **Local Model Seat**: Port 18006 (any OpenAI-compatible model server on GB10, used with `--inference http`). - **SQLite Database**: `aegis.sqlite` in WAL mode. ## Preflight Verification diff --git a/CONSTITUTION.md b/CONSTITUTION.md index 6bc26c8..ef20ef5 100644 --- a/CONSTITUTION.md +++ b/CONSTITUTION.md @@ -64,7 +64,7 @@ Reliable software protects human agency and community trust. We hold our codebas ### Section 1. Pure Native Systems Priority 1. Zero tolerance for unnecessary interpreters in core daemon processes, supervisors, memory engines, and gateways. -2. Core runtime engines must be compiled native Rust and high-speed Mojo. Interpreted environments are restricted strictly to neural graph definitions required by weight loaders. +2. Core runtime engines must be compiled native Rust, with Omega kernels on the GPU. Interpreted environments are restricted strictly to neural graph definitions required by weight loaders. 3. Every microservice must run lean, deterministic, and fast, maximizing hardware efficiency on local silicon. ### Section 2. Clarity and Technical Precision diff --git a/Cargo.lock b/Cargo.lock index b1b10e0..e36e6af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,7 +19,6 @@ dependencies = [ "chrono", "clap", "futures-util", - "libloading", "parking_lot", "reqwest", "rusqlite", @@ -1169,16 +1168,6 @@ version = "0.2.189" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" -[[package]] -name = "libloading" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" -dependencies = [ - "cfg-if", - "windows-link", -] - [[package]] name = "libsqlite3-sys" version = "0.28.0" diff --git a/Cargo.toml b/Cargo.toml index 01a8d33..9d8a67f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,6 @@ clap = { version = "4.5", features = ["derive"] } rusqlite = { version = "0.31", features = ["bundled", "bundled-full"] } futures-util = "0.3" uuid = { version = "1.8", features = ["v4", "v5", "serde"] } -libloading = "0.8" anyhow = "1.0.104" async-trait = "0.1" parking_lot = "0.12" diff --git a/README.md b/README.md index 411f0e3..bc8dd09 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Copyright (c) 2026 Drake Stapleton and AIEN Contributors. Authored by Drake Stapleton in collaboration with AIEN. -Sovereign agent runtime written in native Rust with Mojo 1.1 SIMD acceleration kernels, built for NVIDIA Grace Blackwell GB10 hardware. Model inference goes to a local Modular MAX server when started with `--inference http`. The default `--inference embedded` backend is a mock: it loads no model and ignores `--model-path` and `--tokenizer-path`. +Sovereign agent runtime written in native Rust, built for NVIDIA Grace Blackwell GB10 hardware. Model inference goes to the local model seat (any OpenAI-compatible server on port 18006) when started with `--inference http`. The default `--inference embedded` backend is a mock: it loads no model and ignores `--model-path` and `--tokenizer-path`. ## Architecture @@ -15,14 +15,14 @@ Sovereign agent runtime written in native Rust with Mojo 1.1 SIMD acceleration k +--------------+--------------+ | +---------------------------+ +--------------v--------------+ +-----------------------------+ -| Axum Control Plane | | Heartbeat Engine | | Modular MAX (optional) | +| Axum Control Plane | | Heartbeat Engine | | Local model seat (optional)| | - Port 18096 | <-> | - Autonomous Tick [2] | <-> | - Port 18006 | | - WebSockets & SSE | | - State Machine | | - GB10 Local Weights | | - REST API | | - Task Evaluation | | - TTFT per model [1] | +---------------------------+ +--------------+--------------+ +-----------------------------+ | +--------------v--------------+ - | Mojo 1.1 SIMD Bridge | + | Rust Vector Math | | - Vector Cosine & Entropy | | - SQLite WAL Persistence | +-----------------------------+ @@ -40,11 +40,11 @@ Sovereign agent runtime written in native Rust with Mojo 1.1 SIMD acceleration k 2. **Heartbeat Engine**: Autonomous polling loop (30 seconds under `aegis heartbeat`, 60 seconds by default under `aegis serve`) that claims pending tasks, runs them, and emits a pulse receipt. -3. **Local Modular MAX Inference** (optional): - With `--inference http`, requests go to the OpenAI-style endpoint given by `--max-url` (default `http://127.0.0.1:18006/v1/chat/completions`) using the model name `atlas-lightning-omni`. Without it, the mock backend answers. +3. **Local Model Seat Inference** (optional): + With `--inference http`, requests go to the OpenAI-style endpoint given by `--model-url` (default `http://127.0.0.1:18006/v1/chat/completions`) using the model name `atlas-lightning-omni`. Without it, the mock backend answers. -4. **Mojo 1.1 SIMD Kernels**: - Vector cosine similarity, Shannon entropy, and linear projection using Mojo SIMD vector primitives via C-ABI FFI (`libloading`). +4. **Vector Math**: + Vector cosine similarity, Shannon entropy, linear projection, and temperature scaling in plain Rust (`src/vector_math.rs`). 5. **Secret resolution**: No plaintext secret files. `VaultResolver` asks `atlas-vault`, then keeps the value in memory. It is a client of that provider, not a TPM. The process environment is read only when `AIEN_DEV_SECRET_FALLBACK=1`. Output is redacted with `[REDACTED_BY_ATLAS_VAULT]`. @@ -57,8 +57,7 @@ Sovereign agent runtime written in native Rust with Mojo 1.1 SIMD acceleration k ### Prerequisites - Rust 1.80+ (`cargo`) - A checkout of [aien-dev/aien-protocols](https://github.com/aien-dev/aien-protocols) next to this one at `../aien-protocols` (six path dependencies in `Cargo.toml`) -- Optional: Mojo 1.1. `build.rs` builds `mojo/aegis_simd.mojo` into a shared library when `mojo` is on the PATH; otherwise the SIMD functions run as plain Rust (`aegis status` shows `NATIVE_FALLBACK`). -- Optional: a Modular MAX server, only for `--inference http` +- Optional: an OpenAI-compatible model server on port 18006 (the local model seat), only for `--inference http` - Linux aarch64 (Grace Blackwell GB10) or x86_64 ### Compilation @@ -87,7 +86,7 @@ aegis tick # Run the heartbeat loop on its own (30 second default) aegis heartbeat -# Send one prompt to the inference backend (add --inference http to reach MAX) +# Send one prompt to the inference backend (add --inference http to reach the local model seat) aegis ask "Analyze system health and pending tasks" # Run an agent task with multi-turn tool calling (default 8 turns) @@ -96,16 +95,16 @@ aegis agent "Summarize the repository status" --max-turns 8 # Check engine status aegis status -# Print a small SIMD kernel evaluation and whether Mojo or the Rust fallback is active +# Print a small vector math evaluation aegis simd --steps 10 ``` ## Mathematical verification -SIMD kernels are checked in Rust against an analytical reference and the committed vectors in `tests/fixtures/simd_math_vectors.json`: +The vector math functions are checked against an analytical reference and the committed vectors in `tests/fixtures/simd_math_vectors.json`: ```bash -cargo test --lib mojo_bridge::tests::test_simd_analytical_parity +cargo test --lib vector_math::tests::test_analytical_parity ``` ## License diff --git a/agent.json b/agent.json index ec25cda..b0817d5 100644 --- a/agent.json +++ b/agent.json @@ -2,26 +2,25 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "name": "aegis-runtime", "version": "0.2.0", - "description": "Ultra-high-performance sovereign agent runtime in Rust, Mojo, and Modular MAX", + "description": "Ultra-high-performance sovereign agent runtime in Rust with local model inference", "repository": "https://github.com/aien-dev/aegis-runtime", "license": "AGPL-3.0-or-later", "system": { "architecture": "aarch64-unknown-linux-gnu", "hardware_target": "NVIDIA DGX Spark Grace Blackwell GB10", "pure_native": true, - "runtimes": ["rust", "mojo"] + "runtimes": ["rust"] }, "capabilities": [ "sub_millisecond_axum_gateway", "proactive_heartbeat_loop", - "modular_max_local_inference", - "mojo_simd_vector_kernels", + "local_model_seat_inference", "hardware_tpm_vault_integration", "sqlite_wal_persistence" ], "ports": { "gateway": 18096, - "modular_max": 18006, + "local_model_seat": 18006, "cortex_memory": 18080 }, "invariants": { diff --git a/build.rs b/build.rs deleted file mode 100644 index b9f5478..0000000 --- a/build.rs +++ /dev/null @@ -1,32 +0,0 @@ -use std::path::Path; -use std::process::Command; - -fn main() { - println!("cargo:rerun-if-changed=mojo/aegis_simd.mojo"); - let out_dir = std::env::var("OUT_DIR").unwrap(); - let dest_path = Path::new(&out_dir).join("libaegis_simd.so"); - - if let Ok(status) = Command::new("mojo") - .args([ - "build", - "--emit", - "shared-lib", - "mojo/aegis_simd.mojo", - "-o", - ]) - .arg(&dest_path) - .status() - { - if status.success() { - println!( - "cargo:rustc-env=AEGIS_SIMD_SO_BUILT={}", - dest_path.display() - ); - let _ = std::fs::copy(&dest_path, "mojo/libaegis_simd.so"); - } else { - println!("cargo:warning=mojo build exited with non-zero status"); - } - } else { - println!("cargo:warning=mojo binary not found on PATH, skipping libaegis_simd.so build"); - } -} diff --git a/docs/INNOVATIONS.md b/docs/INNOVATIONS.md index 0693e6f..9e553c4 100644 --- a/docs/INNOVATIONS.md +++ b/docs/INNOVATIONS.md @@ -1,8 +1,8 @@ # AEGIS Architectural Innovations -### Pure Compiled Systems Architecture, Mojo 1.1 SIMD Bridge, and Hardware TPM Vault +### Pure Compiled Systems Architecture and Hardware TPM Vault -`aegis-runtime` is an autonomous agent runtime engineered in pure native compiled Rust and Mojo 1.1. It replaces bloated, interpreted Node.js frameworks with a sub-millisecond compiled engine optimized for local workstation hardware. +`aegis-runtime` is an autonomous agent runtime engineered in pure native compiled Rust. It replaces bloated, interpreted Node.js frameworks with a sub-millisecond compiled engine optimized for local workstation hardware. --- @@ -14,11 +14,11 @@ The control plane runs on Axum and Tokio (`src/gateway.rs`), providing high-conc - Zero garbage collection pauses or runtime interpreter bloat. - Direct memory-mapped operations. -### Mojo 1.1 SIMD Bridge (`src/mojo_bridge.rs`) -Vector arithmetic and high-dimensional similarity checks are delegated to Mojo 1.1 via a dynamic C-ABI foreign function interface (`libsimd_bridge.so`) with an automated native Rust fallback: -- **4D Vector Cosine Similarity**: Evaluates semantic orientation between token embeddings with SIMD vectorization. +### Vector Math (`src/vector_math.rs`) +Small fixed-size vector arithmetic runs in plain Rust with no external libraries: +- **4D Vector Cosine Similarity**: Evaluates semantic orientation between token embeddings. - **Token Entropy Estimation**: Computes probability distribution entropy without allocating intermediate heap structures. -- **Token Projection**: Applies linear transformations and temperature scaling in a single hardware pass. +- **Token Projection and Temperature Scaling**: Applies a weighted sum plus bias, and divides logits by temperature. --- @@ -26,7 +26,7 @@ Vector arithmetic and high-dimensional similarity checks are delegated to Mojo 1 ### Multi-Turn Tool Calling Loop The `AgentEngine` implements an autonomous reasoning and execution loop: -1. **Thought & Tool Formulation**: Generates structured reasoning and tool calls against local Modular MAX models. +1. **Thought & Tool Formulation**: Generates structured reasoning and tool calls against the configured inference backend (the local model seat on port 18006 with `--inference http`). 2. **Deterministic Tool Execution**: Dispatches tool invocations to the native `SkillRegistry`. 3. **Multi-Turn Context Preservation**: Retains dialogue history, tool outputs, and execution receipts across iterative steps until the task goal is satisfied. @@ -65,7 +65,8 @@ Operational tasks and event logs persist in SQLite using Write-Ahead Logging (WA ## 5. Hardware Target and Performance Metrics Verified on NVIDIA Grace Blackwell GB10: -- **Modular MAX Local Endpoint**: `http://127.0.0.1:18006/v1/chat/completions`. +- **Local Model Seat Endpoint**: `http://127.0.0.1:18006/v1/chat/completions` (any OpenAI-compatible server). +- The three figures below were measured while the seat ran Modular MAX, which was removed from AIEN on 2026-10-15. They have not been re-measured since. - **Active GPU Utilization**: 94% to 96% under sustained multi-turn generation. - **Inference Speed**: 20.7 tokens per second sustained across multi-turn reasoning loops. - **Memory Footprint**: < 35 MB resident set size for the core runtime engine. diff --git a/llms.txt b/llms.txt index d5ff899..45982b5 100644 --- a/llms.txt +++ b/llms.txt @@ -1,18 +1,18 @@ # aegis-runtime -> Ultra-high-performance sovereign agent runtime in native Rust, Mojo 1.1 SIMD kernels, and Modular MAX local inference on Grace Blackwell GB10. Replaces legacy Node.js/TypeScript runtimes with sub-millisecond execution, zero cloud token bills, and proactive autonomous heartbeats. +> Ultra-high-performance sovereign agent runtime in native Rust with local model inference on Grace Blackwell GB10. Replaces legacy Node.js/TypeScript runtimes with sub-millisecond execution, zero cloud token bills, and proactive autonomous heartbeats. ## Overview - Repository: https://github.com/aien-dev/aegis-runtime - License: Apache-2.0 WITH LLVM-exception, with the nonbinding COVENANT.md. -- Language: Rust 2021 + Mojo 1.1 +- Language: Rust 2021 - Runtime: Pure native compiled binaries. Zero Node.js. Zero Python daemons. ## Architecture - Axum Gateway: Sub-millisecond WebSockets, Server-Sent Events (SSE), and REST API on port 18096. - Heartbeat Engine: Proactive autonomous background tick loop (60s period). Executes digital colleague workflows without requiring human prompts. -- Inference Engine: Direct HTTP client to Modular MAX serving local weights on port 18006 (atlas-lightning-omni on GB10). TTFT < 50ms with SSE streaming. +- Inference Engine: Direct HTTP client to the local model seat, any OpenAI-compatible server on port 18006 (atlas-lightning-omni on GB10), with SSE streaming. - Persistence: Embedded SQLite with Write-Ahead-Logging (WAL) mode for sub-millisecond ACID history and state storage. -- Mojo SIMD Bridge: Zero-copy C-ABI FFI linking Mojo 1.1 vector kernels for cosine similarity and attention operations. +- Vector Math: Plain Rust cosine similarity, token entropy, projection, and temperature scaling (src/vector_math.rs). - Security: Hardware TPM key vault (atlas-vault). Zero disk secrets. Dynamic memory resolution and automatic secret redaction ([REDACTED_BY_ATLAS_VAULT]). ## Quickstart @@ -22,12 +22,12 @@ cargo build --release ``` ## Endpoints -- `GET /health` & `GET /api/v1/health`: Engine health, model ID, uptime, and Mojo SIMD status. +- `GET /health` & `GET /api/v1/health`: Engine health, model ID, uptime, and heartbeat counters. - `POST /v1/chat/completions`: OpenAI-compatible completions with multi-turn chat and SSE token streaming. - `GET /v1/models`: OpenAI-compatible models listing. - `GET /api/v1/skills`: List registered skills. - `POST /api/v1/skills/execute`: Execute a registered skill. -- `POST /api/v1/chat`: Direct inference request to local MAX. +- `POST /api/v1/chat`: Direct inference request to the local model seat. - `POST /api/v1/heartbeat/tick`: Force an immediate heartbeat tick. - `POST /api/v1/tasks` & `GET /api/v1/tasks`: Task queue creation and listing. - `POST /api/v1/shell`: Local shell execution. diff --git a/mojo/.crumb b/mojo/.crumb deleted file mode 100644 index 6b30a14..0000000 --- a/mojo/.crumb +++ /dev/null @@ -1,31 +0,0 @@ -{ - "above": { - "name": "aegis-runtime", - "path": ".." - }, - "extensions": { - "generated": { - "children": [], - "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-04T18:13:51Z", - "compiler": "crumb-compile/1", - "digest": "sha256:49e79db936da2c48b45792dbf94788d88e700d04b44e19473cda4f62fccf33b3", - "evidence_files": 0, - "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 1, - "generated_at_commit": "7288fa65b22fe45e36a88f44150f21ed8781dc89", - "source_tree": "sha256:919e7991c6997b4b97d3845194232f941b67070ee3a5fb243d2fcff9cac1e862" - }, - "owner_lane": "", - "seed": { - "files": [ - "aegis_simd.mojo" - ], - "purpose_auto": "Directory mojo. Purpose not yet described by a human." - } - }, - "layer": "mojo", - "name": "mojo", - "purpose": "Directory mojo. Purpose not yet described by a human.", - "schema_version": "1.0.0" -} diff --git a/mojo/aegis_simd.mojo b/mojo/aegis_simd.mojo deleted file mode 100644 index ee6d8fd..0000000 --- a/mojo/aegis_simd.mojo +++ /dev/null @@ -1,55 +0,0 @@ -# AEGIS Mojo 1.1 SIMD Vector Acceleration Kernel -# Token tensor operations and vector similarity for Grace Blackwell GB10 - -from std.math import log, sqrt - -@export("aegis_simd_version") -def aegis_simd_version() abi("C") -> Int32: - return 101 - -@export("aegis_cosine_similarity_4d") -def aegis_cosine_similarity_4d( - a0: Float32, a1: Float32, a2: Float32, a3: Float32, - b0: Float32, b1: Float32, b2: Float32, b3: Float32 -) abi("C") -> Float32: - var va = SIMD[DType.float32, 4](a0, a1, a2, a3) - var vb = SIMD[DType.float32, 4](b0, b1, b2, b3) - var dot = Float32((va * vb).reduce_add()) - var norm_a = Float32((va * va).reduce_add()) - var norm_b = Float32((vb * vb).reduce_add()) - if norm_a <= 0.0 or norm_b <= 0.0: - return 0.0 - return dot / (sqrt(norm_a) * sqrt(norm_b)) - -@export("aegis_simd_accumulate") -def aegis_simd_accumulate(base_val: Float32, scale: Float32, steps: Int32) abi("C") -> Float32: - var acc = SIMD[DType.float32, 4](base_val, base_val * 1.5, base_val * 2.0, base_val * 2.5) - var step_vec = SIMD[DType.float32, 4](scale, scale * 1.1, scale * 1.2, scale * 1.3) - for _ in range(Int(steps)): - acc = acc * step_vec + SIMD[DType.float32, 4](0.01, 0.02, 0.03, 0.04) - return Float32(acc.reduce_add()) - -@export("aegis_token_entropy_simd") -def aegis_token_entropy_simd(p0: Float32, p1: Float32, p2: Float32, p3: Float32) abi("C") -> Float32: - var probs = SIMD[DType.float32, 4](p0, p1, p2, p3) - var entropy = SIMD[DType.float32, 4](0.0, 0.0, 0.0, 0.0) - for i in range(4): - if probs[i] > 0.00001: - entropy[i] = -probs[i] * log(probs[i]) - return Float32(entropy.reduce_add()) - -@export("aegis_token_projection_simd") -def aegis_token_projection_simd( - t0: Float32, t1: Float32, t2: Float32, t3: Float32, - w0: Float32, w1: Float32, w2: Float32, w3: Float32, - bias: Float32 -) abi("C") -> Float32: - var vt = SIMD[DType.float32, 4](t0, t1, t2, t3) - var vw = SIMD[DType.float32, 4](w0, w1, w2, w3) - return Float32((vt * vw).reduce_add()) + bias - -@export("aegis_temperature_scale_simd") -def aegis_temperature_scale_simd(logit: Float32, temp: Float32) abi("C") -> Float32: - if temp <= 0.0001: - return logit - return logit / temp diff --git a/src/gateway.rs b/src/gateway.rs index 216324a..83f37af 100644 --- a/src/gateway.rs +++ b/src/gateway.rs @@ -26,9 +26,9 @@ use tracing::info; use crate::agent::{AgentEngine, AgentStep}; use crate::heartbeat::HeartbeatEngine; use crate::inference::InferenceEngine; -use crate::mojo_bridge::MojoSimdBridge; use crate::persistence::Database; use crate::skills::{SkillExecutionRequest, SkillRegistry}; +use crate::vector_math::VectorMath; #[derive(Clone)] pub struct GatewayState { @@ -51,8 +51,6 @@ pub struct HealthResponse { pub heartbeat_interval_seconds: u64, pub total_heartbeat_ticks: u64, pub database_mode: &'static str, - pub mojo_simd_accelerated: bool, - pub mojo_simd_version: i32, pub zero_disk_secrets: bool, } @@ -60,8 +58,6 @@ pub async fn health_handler(State(state): State) -> impl IntoRespo let uptime = state.start_time.elapsed().as_secs(); let ticks = state.heartbeat.tick_count(); let model = state.inference.model_id(); - let mojo_active = MojoSimdBridge::is_mojo_accelerated(); - let mojo_ver = MojoSimdBridge::version(); Json(HealthResponse { status: "healthy", @@ -71,8 +67,6 @@ pub async fn health_handler(State(state): State) -> impl IntoRespo heartbeat_interval_seconds: state.heartbeat.interval_secs(), total_heartbeat_ticks: ticks, database_mode: "sqlite-wal", - mojo_simd_accelerated: mojo_active, - mojo_simd_version: mojo_ver, zero_disk_secrets: true, }) } @@ -198,7 +192,6 @@ pub async fn openai_completions_handler( let supported_model = state.inference.model_id(); if req_model != &supported_model && req_model != "atlas-lightning-omni" - && req_model != "modular-max" && req_model != "aegis-default" && req_model != "default" { @@ -573,12 +566,10 @@ async fn handle_socket(mut socket: WebSocket, state: GatewayState) { let _ = socket.send(Message::Text(out.to_string())).await; } "simd_eval" => { - let sim = MojoSimdBridge::cosine_similarity(&[1.0, 0.0, 0.0, 0.0], &[1.0, 0.0, 0.0, 0.0]); + let sim = VectorMath::cosine_similarity(&[1.0, 0.0, 0.0, 0.0], &[1.0, 0.0, 0.0, 0.0]); let out = json!({ "type": "simd_result", "cosine_similarity": sim, - "accelerated": MojoSimdBridge::is_mojo_accelerated(), - "version": MojoSimdBridge::version(), }); let _ = socket.send(Message::Text(out.to_string())).await; } diff --git a/src/heartbeat.rs b/src/heartbeat.rs index cf783d1..b81e3a8 100644 --- a/src/heartbeat.rs +++ b/src/heartbeat.rs @@ -120,7 +120,8 @@ impl HeartbeatEngine { } let res_text = match task.task_type.as_str() { - "max_health" => { + // "max_health" is the former name, kept so tasks already queued under it still run. + "model_health" | "max_health" => { let is_healthy = if let Some(ref inf) = self.inference { inf.check_health().await } else { @@ -133,10 +134,9 @@ impl HeartbeatEngine { }; if is_healthy { - "MAX local inference engine verified ACTIVE on port 18006".to_string() + "Local model seat verified ACTIVE on port 18006".to_string() } else { - "MAX local inference engine unreachable or offline on port 18006" - .to_string() + "Local model seat unreachable or offline on port 18006".to_string() } } "build_monitor" | "shell_exec" => { @@ -261,7 +261,7 @@ mod tests { #[tokio::test] async fn test_heartbeat_pulse_and_task_execution() { let db = Arc::new(Database::open_in_memory().unwrap()); - db.create_task("hb1", "max_health", "check").unwrap(); + db.create_task("hb1", "model_health", "check").unwrap(); db.create_task("hb2", "consolidate_memory", "sync").unwrap(); db.create_task("hb3", "shell_exec", "echo 'heartbeat task success'") .unwrap(); diff --git a/src/inference.rs b/src/inference.rs index 5af451b..9cd8459 100644 --- a/src/inference.rs +++ b/src/inference.rs @@ -40,37 +40,37 @@ pub struct ChatTurnResponse { } #[derive(Deserialize)] -struct MaxChoice { - message: MaxMessage, +struct ChatChoice { + message: ChatMessage, } #[derive(Deserialize)] -struct MaxMessage { +struct ChatMessage { content: Option, reasoning: Option, } #[derive(Deserialize)] -struct MaxResponse { - choices: Vec, +struct ChatResponse { + choices: Vec, } #[derive(Deserialize)] -struct MaxChoiceWithTools { - message: MaxMessageWithTools, +struct ChatChoiceWithTools { + message: ChatMessageWithTools, finish_reason: Option, } #[derive(Deserialize)] -struct MaxMessageWithTools { +struct ChatMessageWithTools { content: Option, reasoning: Option, tool_calls: Option>, } #[derive(Deserialize)] -struct MaxResponseWithTools { - choices: Vec, +struct ChatResponseWithTools { + choices: Vec, } /// Unified inference engine interface supporting both in-process embedded @@ -196,7 +196,7 @@ impl InferenceEngine for HttpInferenceBackend { match self.client.post(&self.endpoint).json(&body).send().await { Ok(res) => { if res.status().is_success() { - let parsed: MaxResponse = res.json().await?; + let parsed: ChatResponse = res.json().await?; if let Some(choice) = parsed.choices.into_iter().next() { if let Some(content) = choice.message.content { if !content.trim().is_empty() { @@ -213,7 +213,7 @@ impl InferenceEngine for HttpInferenceBackend { } else { let err_status = res.status(); let err_text = res.text().await.unwrap_or_default(); - warn!("MAX inference error {}: {}", err_status, err_text); + warn!("Model seat inference error {}: {}", err_status, err_text); Err( anyhow::anyhow!("Inference endpoint error {}: {}", err_status, err_text) .into(), @@ -221,7 +221,10 @@ impl InferenceEngine for HttpInferenceBackend { } } Err(e) => { - warn!("Cannot reach MAX endpoint at {}: {}", self.endpoint, e); + warn!( + "Cannot reach model seat endpoint at {}: {}", + self.endpoint, e + ); Err(anyhow::anyhow!("Inference endpoint unreachable: {}", e).into()) } } @@ -250,7 +253,7 @@ impl InferenceEngine for HttpInferenceBackend { match self.client.post(&self.endpoint).json(&body).send().await { Ok(res) => { if res.status().is_success() { - let parsed: MaxResponseWithTools = res.json().await?; + let parsed: ChatResponseWithTools = res.json().await?; if let Some(choice) = parsed.choices.into_iter().next() { return Ok(ChatTurnResponse { content: choice.message.content, @@ -268,7 +271,7 @@ impl InferenceEngine for HttpInferenceBackend { } else { let err_status = res.status(); let err_text = res.text().await.unwrap_or_default(); - warn!("MAX inference error {}: {}", err_status, err_text); + warn!("Model seat inference error {}: {}", err_status, err_text); Err( anyhow::anyhow!("Inference endpoint error {}: {}", err_status, err_text) .into(), @@ -276,7 +279,10 @@ impl InferenceEngine for HttpInferenceBackend { } } Err(e) => { - warn!("Cannot reach MAX endpoint at {}: {}", self.endpoint, e); + warn!( + "Cannot reach model seat endpoint at {}: {}", + self.endpoint, e + ); Err(anyhow::anyhow!("Inference endpoint unreachable: {}", e).into()) } } @@ -300,7 +306,7 @@ impl InferenceEngine for HttpInferenceBackend { if !res.status().is_success() { let status = res.status(); let text = res.text().await.unwrap_or_default(); - return Err(anyhow::anyhow!("MAX streaming error {}: {}", status, text).into()); + return Err(anyhow::anyhow!("Model seat streaming error {}: {}", status, text).into()); } let stream = res diff --git a/src/lib.rs b/src/lib.rs index fba5b92..4c98e2d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,13 +7,13 @@ pub mod failure; pub mod gateway; pub mod heartbeat; pub mod inference; -pub mod mojo_bridge; pub mod orchestration; pub mod persistence; pub mod security; pub mod sessions; pub mod skills; pub mod vault; +pub mod vector_math; pub use agent::{AgentEngine, AgentExecutionResult, AgentStep, FailurePolicy, ToolExecutionRecord}; pub use auth::{resolve_bind_addr, OperatorAuth}; @@ -31,7 +31,6 @@ pub use inference::{ ChatStream, ChatTurnResponse, EmbeddedInferenceBackend, HttpInferenceBackend, InferenceEngine, ProtocolInferenceBackend, ToolCallFunction, ToolCallItem, }; -pub use mojo_bridge::MojoSimdBridge; pub use orchestration::workflow::{ TaskId, TaskOutcome, TaskRunner, TaskState, WorkflowConfig, WorkflowError, WorkflowExecutor, WorkflowReport, WorkflowSpec, WorkflowStatus, @@ -49,6 +48,7 @@ pub use sessions::{ }; pub use skills::{SkillDefinition, SkillExecutionRequest, SkillExecutionResponse, SkillRegistry}; pub use vault::{VaultResolver, REDACTED_MARKER}; +pub use vector_math::VectorMath; // Re-export Canonical AIEN Agent State ABI and Protocol Types pub use aien_agent_state_abi::{ diff --git a/src/main.rs b/src/main.rs index 33b7741..28d4068 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use aegis::{ start_gateway, AgentEngine, Database, EmbeddedInferenceBackend, GatewayState, HeartbeatEngine, - HttpInferenceBackend, InferenceEngine, MojoSimdBridge, SkillRegistry, + HttpInferenceBackend, InferenceEngine, SkillRegistry, VectorMath, }; use clap::{Parser, Subcommand}; use std::path::Path; @@ -36,7 +36,8 @@ enum Commands { #[arg(long, default_value = "embedded")] inference: String, #[arg(long, default_value = "http://127.0.0.1:18006/v1/chat/completions")] - max_url: String, + /// OpenAI-compatible chat endpoint used with `--inference http` (the local model seat on port 18006 by default). + model_url: String, #[arg(long)] model_path: Option, #[arg(long)] @@ -56,7 +57,8 @@ enum Commands { #[arg(long, default_value = "embedded")] inference: String, #[arg(long, default_value = "http://127.0.0.1:18006/v1/chat/completions")] - max_url: String, + /// OpenAI-compatible chat endpoint used with `--inference http` (the local model seat on port 18006 by default). + model_url: String, #[arg(long)] model_path: Option, #[arg(long)] @@ -72,7 +74,8 @@ enum Commands { #[arg(long, default_value = "embedded")] inference: String, #[arg(long, default_value = "http://127.0.0.1:18006/v1/chat/completions")] - max_url: String, + /// OpenAI-compatible chat endpoint used with `--inference http` (the local model seat on port 18006 by default). + model_url: String, #[arg(long)] model_path: Option, #[arg(long)] @@ -84,7 +87,8 @@ enum Commands { #[arg(long, default_value = "embedded")] inference: String, #[arg(long, default_value = "http://127.0.0.1:18006/v1/chat/completions")] - max_url: String, + /// OpenAI-compatible chat endpoint used with `--inference http` (the local model seat on port 18006 by default). + model_url: String, #[arg(long)] model_path: Option, #[arg(long)] @@ -94,7 +98,7 @@ enum Commands { #[arg(long, default_value = "8")] max_turns: usize, }, - /// Evaluate Mojo SIMD vector operations + /// Evaluate the built-in vector math operations Simd { #[arg(long, default_value = "10")] steps: i32, @@ -104,7 +108,8 @@ enum Commands { #[arg(long, default_value = "embedded")] inference: String, #[arg(long, default_value = "http://127.0.0.1:18006/v1/chat/completions")] - max_url: String, + /// OpenAI-compatible chat endpoint used with `--inference http` (the local model seat on port 18006 by default). + model_url: String, #[arg(long)] model_path: Option, #[arg(long)] @@ -116,17 +121,17 @@ enum Commands { fn resolve_inference_engine( mode: &str, - max_url: &str, + model_url: &str, model_path: Option<&str>, tokenizer_path: Option<&str>, ) -> Result, Box> { if mode == "http" { info!( "Binding AEGIS to external HTTP inference daemon at {}", - max_url + model_url ); Ok(Arc::new(HttpInferenceBackend::new( - Some(max_url.to_string()), + Some(model_url.to_string()), None, ))) } else { @@ -174,7 +179,7 @@ async fn main() -> Result<(), Box> { allow_non_loopback_bind: false, operator_token_file: None, inference: "embedded".to_string(), - max_url: "http://127.0.0.1:18006/v1/chat/completions".to_string(), + model_url: "http://127.0.0.1:18006/v1/chat/completions".to_string(), model_path: None, tokenizer_path: None, db_path: "aegis.sqlite".to_string(), @@ -186,7 +191,7 @@ async fn main() -> Result<(), Box> { allow_non_loopback_bind, operator_token_file, inference: inference_mode, - max_url, + model_url, model_path, tokenizer_path, db_path, @@ -201,7 +206,7 @@ async fn main() -> Result<(), Box> { let db = Arc::new(Database::open(Path::new(&db_path))?); let inference = resolve_inference_engine( &inference_mode, - &max_url, + &model_url, model_path.as_deref(), tokenizer_path.as_deref(), )?; @@ -241,7 +246,7 @@ async fn main() -> Result<(), Box> { } Commands::Heartbeat { inference: inference_mode, - max_url, + model_url, model_path, tokenizer_path, db_path, @@ -251,7 +256,7 @@ async fn main() -> Result<(), Box> { let db = Arc::new(Database::open(Path::new(&db_path))?); let inference = resolve_inference_engine( &inference_mode, - &max_url, + &model_url, model_path.as_deref(), tokenizer_path.as_deref(), )?; @@ -282,13 +287,13 @@ async fn main() -> Result<(), Box> { Commands::Ask { prompt, inference: inference_mode, - max_url, + model_url, model_path, tokenizer_path, } => { let inference = resolve_inference_engine( &inference_mode, - &max_url, + &model_url, model_path.as_deref(), tokenizer_path.as_deref(), )?; @@ -305,7 +310,7 @@ async fn main() -> Result<(), Box> { Commands::Agent { prompt, inference: inference_mode, - max_url, + model_url, model_path, tokenizer_path, db_path, @@ -315,7 +320,7 @@ async fn main() -> Result<(), Box> { println!("Task Goal: {}", prompt); let inference = resolve_inference_engine( &inference_mode, - &max_url, + &model_url, model_path.as_deref(), tokenizer_path.as_deref(), )?; @@ -354,51 +359,40 @@ async fn main() -> Result<(), Box> { } } Commands::Simd { steps } => { - println!("=== Mojo SIMD Vector Evaluation ==="); - let version = MojoSimdBridge::version(); - let is_accel = MojoSimdBridge::is_mojo_accelerated(); - println!( - "Mojo SIMD Status: {}", - if is_accel { - "ACCELERATED (C-ABI .so)" - } else { - "NATIVE FALLBACK" - } - ); - println!("Kernel Version: {}", version); + println!("=== Vector Math Evaluation (pure Rust) ==="); let v1 = [1.0f32, 0.0, 0.0, 0.0]; let v2 = [0.9f32, 0.1, 0.0, 0.0]; - let sim = MojoSimdBridge::cosine_similarity_4d(v1, v2); + let sim = VectorMath::cosine_similarity_4d(v1, v2); println!("Cosine Similarity ([1,0,0,0] vs [0.9,0.1,0,0]): {:.6}", sim); - let acc = MojoSimdBridge::simd_accumulate(1.0, 1.05, steps); + let acc = VectorMath::accumulate(1.0, 1.05, steps); println!( - "SIMD Accumulate (base=1.0, scale=1.05, steps={}): {:.6}", + "Accumulate (base=1.0, scale=1.05, steps={}): {:.6}", steps, acc ); - let entropy = MojoSimdBridge::token_entropy([0.7, 0.2, 0.08, 0.02]); + let entropy = VectorMath::token_entropy([0.7, 0.2, 0.08, 0.02]); println!("Token Entropy (Shannon): {:.6} nats", entropy); let proj = - MojoSimdBridge::token_projection([1.0, 2.0, 3.0, 4.0], [0.5, 0.5, 0.5, 0.5], 1.0); + VectorMath::token_projection([1.0, 2.0, 3.0, 4.0], [0.5, 0.5, 0.5, 0.5], 1.0); println!("Token Projection: {:.6}", proj); } Commands::Status { inference: inference_mode, - max_url, + model_url, model_path, tokenizer_path, db_path, } => { println!("=== AEGIS Sovereign Runtime Status ==="); - println!("Architecture: Pure native Rust + Mojo 1.1 + In-Process NativeTransformer"); + println!("Architecture: Pure native Rust + In-Process NativeTransformer"); println!("Hardware Target: Grace Blackwell GB10 (aarch64-unknown-linux-gnu)"); println!("Database: SQLite WAL ({})", db_path); let inference = resolve_inference_engine( &inference_mode, - &max_url, + &model_url, model_path.as_deref(), tokenizer_path.as_deref(), )?; @@ -413,14 +407,6 @@ async fn main() -> Result<(), Box> { "OFFLINE (Fallback Active)" } ); - println!( - "Mojo SIMD Acceleration: {}", - if MojoSimdBridge::is_mojo_accelerated() { - "ACTIVE" - } else { - "NATIVE_FALLBACK" - } - ); } } diff --git a/src/mojo_bridge.rs b/src/vector_math.rs similarity index 50% rename from src/mojo_bridge.rs rename to src/vector_math.rs index 3fe6dc4..dfa4bca 100644 --- a/src/mojo_bridge.rs +++ b/src/vector_math.rs @@ -1,132 +1,14 @@ -use libloading::{Library, Symbol}; -use std::path::{Path, PathBuf}; -use std::sync::OnceLock; +//! Small fixed-size vector math used by the gateway and the CLI: cosine +//! similarity, token entropy, token projection, temperature scaling and a +//! four-lane accumulator. Pure Rust, no external libraries. +//! +//! Cosine similarity, projection and temperature scaling return 0.0 when an +//! input is NaN or infinite; token entropy skips such entries. -pub const DEFAULT_SO_PATH: &str = "mojo/libaegis_simd.so"; +pub struct VectorMath; -pub fn default_so_path() -> PathBuf { - if let Ok(p) = std::env::var("AEGIS_SIMD_SO_PATH") { - let pb = PathBuf::from(p); - if pb.exists() { - return pb; - } - } - if let Some(p) = option_env!("AEGIS_SIMD_SO_BUILT") { - let pb = PathBuf::from(p); - if pb.exists() { - return pb; - } - } - let local = PathBuf::from(DEFAULT_SO_PATH); - if local.exists() { - return local; - } - if let Ok(manifest) = std::env::var("CARGO_MANIFEST_DIR") { - let candidate = PathBuf::from(manifest).join(DEFAULT_SO_PATH); - if candidate.exists() { - return candidate; - } - } - if let Ok(home) = std::env::var("HOME") { - let candidate = PathBuf::from(home).join("workspace/aegis-runtime/mojo/libaegis_simd.so"); - if candidate.exists() { - return candidate; - } - } - PathBuf::from(DEFAULT_SO_PATH) -} - -type FnVersion = unsafe extern "C" fn() -> i32; -type FnCosineSim4d = unsafe extern "C" fn(f32, f32, f32, f32, f32, f32, f32, f32) -> f32; -type FnSimdAccumulate = unsafe extern "C" fn(f32, f32, i32) -> f32; -type FnTokenEntropy = unsafe extern "C" fn(f32, f32, f32, f32) -> f32; -type FnTokenProjection = unsafe extern "C" fn(f32, f32, f32, f32, f32, f32, f32, f32, f32) -> f32; -type FnTemperatureScale = unsafe extern "C" fn(f32, f32) -> f32; - -pub struct MojoSimdBindings { - _lib: &'static Library, - pub version: FnVersion, - pub cosine_similarity_4d: FnCosineSim4d, - pub simd_accumulate: FnSimdAccumulate, - pub token_entropy_simd: FnTokenEntropy, - pub token_projection_simd: FnTokenProjection, - pub temperature_scale_simd: FnTemperatureScale, -} - -static BINDINGS: OnceLock> = OnceLock::new(); - -impl MojoSimdBindings { - pub fn load_from>(path: P) -> Result { - let p = path.as_ref(); - if !p.exists() { - return Err(format!("Mojo SIMD library not found at {:?}", p)); - } - - unsafe { - let lib: &'static Library = Box::leak(Box::new( - Library::new(p).map_err(|e| format!("Failed to dlopen {:?}: {}", p, e))?, - )); - - let version: Symbol = lib - .get(b"aegis_simd_version\0") - .map_err(|e| format!("Missing symbol aegis_simd_version: {}", e))?; - let cosine_similarity_4d: Symbol = lib - .get(b"aegis_cosine_similarity_4d\0") - .map_err(|e| format!("Missing symbol aegis_cosine_similarity_4d: {}", e))?; - let simd_accumulate: Symbol = lib - .get(b"aegis_simd_accumulate\0") - .map_err(|e| format!("Missing symbol aegis_simd_accumulate: {}", e))?; - let token_entropy_simd: Symbol = lib - .get(b"aegis_token_entropy_simd\0") - .map_err(|e| format!("Missing symbol aegis_token_entropy_simd: {}", e))?; - let token_projection_simd: Symbol = lib - .get(b"aegis_token_projection_simd\0") - .map_err(|e| format!("Missing symbol aegis_token_projection_simd: {}", e))?; - let temperature_scale_simd: Symbol = lib - .get(b"aegis_temperature_scale_simd\0") - .map_err(|e| format!("Missing symbol aegis_temperature_scale_simd: {}", e))?; - - Ok(Self { - version: *version, - cosine_similarity_4d: *cosine_similarity_4d, - simd_accumulate: *simd_accumulate, - token_entropy_simd: *token_entropy_simd, - token_projection_simd: *token_projection_simd, - temperature_scale_simd: *temperature_scale_simd, - _lib: lib, - }) - } - } - - pub fn global() -> Result<&'static Self, String> { - let res = BINDINGS.get_or_init(|| { - let path = default_so_path(); - Self::load_from(path) - }); - - match res { - Ok(ref b) => Ok(b), - Err(ref e) => Err(e.clone()), - } - } -} - -pub struct MojoSimdBridge; - -impl MojoSimdBridge { - pub fn is_mojo_accelerated() -> bool { - MojoSimdBindings::global().is_ok() - } - - pub fn version() -> i32 { - if let Ok(b) = MojoSimdBindings::global() { - unsafe { (b.version)() } - } else { - 0 - } - } - - pub fn cosine_similarity_4d_fallback(a: [f32; 4], b: [f32; 4]) -> f32 { +impl VectorMath { + pub fn cosine_similarity_4d(a: [f32; 4], b: [f32; 4]) -> f32 { for i in 0..4 { if a[i].is_nan() || b[i].is_nan() || a[i].is_infinite() || b[i].is_infinite() { return 0.0; @@ -152,7 +34,7 @@ impl MojoSimdBridge { } } - pub fn cosine_similarity_fallback(a: &[f32], b: &[f32]) -> f32 { + pub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32 { if a.len() != b.len() || a.is_empty() { return 0.0; } @@ -160,7 +42,7 @@ impl MojoSimdBridge { if a.len() == 4 { let a_arr = [a[0], a[1], a[2], a[3]]; let b_arr = [b[0], b[1], b[2], b[3]]; - return Self::cosine_similarity_4d_fallback(a_arr, b_arr); + return Self::cosine_similarity_4d(a_arr, b_arr); } let mut dot = 0.0f32; @@ -193,7 +75,7 @@ impl MojoSimdBridge { } } - pub fn simd_accumulate_fallback(base_val: f32, scale: f32, steps: i32) -> f32 { + pub fn accumulate(base_val: f32, scale: f32, steps: i32) -> f32 { if base_val.is_nan() || scale.is_nan() || steps <= 0 { return 0.0; } @@ -208,7 +90,7 @@ impl MojoSimdBridge { acc.iter().sum() } - pub fn token_entropy_fallback(probs: [f32; 4]) -> f32 { + pub fn token_entropy(probs: [f32; 4]) -> f32 { let mut sum = 0.0f32; for p in probs { if p.is_nan() || p.is_infinite() { @@ -221,7 +103,7 @@ impl MojoSimdBridge { sum } - pub fn token_projection_fallback(tokens: [f32; 4], weights: [f32; 4], bias: f32) -> f32 { + pub fn token_projection(tokens: [f32; 4], weights: [f32; 4], bias: f32) -> f32 { for i in 0..4 { if tokens[i].is_nan() || weights[i].is_nan() @@ -241,7 +123,7 @@ impl MojoSimdBridge { + bias } - pub fn temperature_scale_fallback(logit: f32, temperature: f32) -> f32 { + pub fn temperature_scale(logit: f32, temperature: f32) -> f32 { if logit.is_nan() || temperature.is_nan() || logit.is_infinite() @@ -261,67 +143,6 @@ impl MojoSimdBridge { } } - pub fn cosine_similarity_4d(a: [f32; 4], b: [f32; 4]) -> f32 { - if let Ok(bindings) = MojoSimdBindings::global() { - unsafe { - (bindings.cosine_similarity_4d)(a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]) - } - } else { - Self::cosine_similarity_4d_fallback(a, b) - } - } - - pub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32 { - if a.len() != b.len() || a.is_empty() { - return 0.0; - } - - if a.len() == 4 { - let a_arr = [a[0], a[1], a[2], a[3]]; - let b_arr = [b[0], b[1], b[2], b[3]]; - return Self::cosine_similarity_4d(a_arr, b_arr); - } - - Self::cosine_similarity_fallback(a, b) - } - - pub fn simd_accumulate(base_val: f32, scale: f32, steps: i32) -> f32 { - if let Ok(bindings) = MojoSimdBindings::global() { - unsafe { (bindings.simd_accumulate)(base_val, scale, steps) } - } else { - Self::simd_accumulate_fallback(base_val, scale, steps) - } - } - - pub fn token_entropy(probs: [f32; 4]) -> f32 { - if let Ok(bindings) = MojoSimdBindings::global() { - unsafe { (bindings.token_entropy_simd)(probs[0], probs[1], probs[2], probs[3]) } - } else { - Self::token_entropy_fallback(probs) - } - } - - pub fn token_projection(tokens: [f32; 4], weights: [f32; 4], bias: f32) -> f32 { - if let Ok(bindings) = MojoSimdBindings::global() { - unsafe { - (bindings.token_projection_simd)( - tokens[0], tokens[1], tokens[2], tokens[3], weights[0], weights[1], weights[2], - weights[3], bias, - ) - } - } else { - Self::token_projection_fallback(tokens, weights, bias) - } - } - - pub fn temperature_scale(logit: f32, temperature: f32) -> f32 { - if let Ok(bindings) = MojoSimdBindings::global() { - unsafe { (bindings.temperature_scale_simd)(logit, temperature) } - } else { - Self::temperature_scale_fallback(logit, temperature) - } - } - pub fn l2_norm(vec: &[f32]) -> f32 { let sum: f32 = vec.iter().map(|v| v * v).sum(); sum.sqrt() @@ -332,21 +153,15 @@ impl MojoSimdBridge { mod tests { use super::*; - #[test] - fn test_mojo_simd_version_or_fallback() { - let ver = MojoSimdBridge::version(); - assert!(ver == 101 || ver == 0); - } - #[test] fn test_cosine_similarity() { let v1 = vec![1.0, 0.0, 0.0, 0.0]; let v2 = vec![1.0, 0.0, 0.0, 0.0]; - let sim = MojoSimdBridge::cosine_similarity(&v1, &v2); + let sim = VectorMath::cosine_similarity(&v1, &v2); assert!((sim - 1.0).abs() < 1e-4); let v3 = vec![0.0, 1.0, 0.0, 0.0]; - let orthogonal = MojoSimdBridge::cosine_similarity(&v1, &v3); + let orthogonal = VectorMath::cosine_similarity(&v1, &v3); assert!((orthogonal - 0.0).abs() < 1e-4); } @@ -355,146 +170,122 @@ mod tests { let tokens = [1.0, 2.0, 3.0, 4.0]; let weights = [0.5, 0.5, 0.5, 0.5]; let bias = 1.0; - let proj = MojoSimdBridge::token_projection(tokens, weights, bias); + let proj = VectorMath::token_projection(tokens, weights, bias); let expected = 1.0 * 0.5 + 2.0 * 0.5 + 3.0 * 0.5 + 4.0 * 0.5 + 1.0; assert!((proj - expected).abs() < 1e-4); } #[test] fn test_temperature_scale() { - let scaled = MojoSimdBridge::temperature_scale(2.0, 0.5); + let scaled = VectorMath::temperature_scale(2.0, 0.5); assert!((scaled - 4.0).abs() < 1e-4); } #[test] - fn test_fallback_zero_vectors() { + fn test_zero_vectors() { let zero = [0.0f32, 0.0, 0.0, 0.0]; let non_zero = [1.0f32, 2.0, 3.0, 4.0]; - let sim1 = MojoSimdBridge::cosine_similarity_4d_fallback(zero, non_zero); + let sim1 = VectorMath::cosine_similarity_4d(zero, non_zero); assert_eq!(sim1, 0.0); - let sim2 = MojoSimdBridge::cosine_similarity_4d_fallback(zero, zero); + let sim2 = VectorMath::cosine_similarity_4d(zero, zero); assert_eq!(sim2, 0.0); let zero_slice = vec![0.0f32; 8]; let non_zero_slice = vec![1.0f32; 8]; assert_eq!( - MojoSimdBridge::cosine_similarity_fallback(&zero_slice, &non_zero_slice), + VectorMath::cosine_similarity(&zero_slice, &non_zero_slice), 0.0 ); } #[test] - fn test_fallback_identical_and_opposite_vectors() { + fn test_identical_and_opposite_vectors() { let v1 = [3.0f32, -4.0, 5.0, -1.0]; - let sim_ident = MojoSimdBridge::cosine_similarity_4d_fallback(v1, v1); + let sim_ident = VectorMath::cosine_similarity_4d(v1, v1); assert!((sim_ident - 1.0).abs() < 1e-4); let v_opp = [-3.0f32, 4.0, -5.0, 1.0]; - let sim_opp = MojoSimdBridge::cosine_similarity_4d_fallback(v1, v_opp); + let sim_opp = VectorMath::cosine_similarity_4d(v1, v_opp); assert!((sim_opp - (-1.0)).abs() < 1e-4); } #[test] - fn test_fallback_orthogonal_vectors() { + fn test_orthogonal_vectors() { let v1 = [1.0f32, 0.0, 0.0, 0.0]; let v2 = [0.0f32, 1.0, 0.0, 0.0]; - let sim = MojoSimdBridge::cosine_similarity_4d_fallback(v1, v2); + let sim = VectorMath::cosine_similarity_4d(v1, v2); assert_eq!(sim, 0.0); let v3 = [0.0f32, 0.0, 1.0, 0.0]; let v4 = [0.0f32, 0.0, 0.0, 1.0]; - assert_eq!(MojoSimdBridge::cosine_similarity_4d_fallback(v3, v4), 0.0); + assert_eq!(VectorMath::cosine_similarity_4d(v3, v4), 0.0); } #[test] - fn test_fallback_nan_and_inf_handling() { + fn test_nan_and_inf_handling() { let nan_vec = [f32::NAN, 1.0, 2.0, 3.0]; let normal_vec = [1.0f32, 2.0, 3.0, 4.0]; - assert_eq!( - MojoSimdBridge::cosine_similarity_4d_fallback(nan_vec, normal_vec), - 0.0 - ); + assert_eq!(VectorMath::cosine_similarity_4d(nan_vec, normal_vec), 0.0); let inf_vec = [f32::INFINITY, 1.0, 2.0, 3.0]; - assert_eq!( - MojoSimdBridge::cosine_similarity_4d_fallback(inf_vec, normal_vec), - 0.0 - ); + assert_eq!(VectorMath::cosine_similarity_4d(inf_vec, normal_vec), 0.0); let neg_inf_vec = [f32::NEG_INFINITY, 1.0, 2.0, 3.0]; assert_eq!( - MojoSimdBridge::cosine_similarity_4d_fallback(neg_inf_vec, normal_vec), + VectorMath::cosine_similarity_4d(neg_inf_vec, normal_vec), 0.0 ); // Token projection with NaN/Inf + assert_eq!(VectorMath::token_projection(nan_vec, normal_vec, 1.0), 0.0); assert_eq!( - MojoSimdBridge::token_projection_fallback(nan_vec, normal_vec, 1.0), - 0.0 - ); - assert_eq!( - MojoSimdBridge::token_projection_fallback(normal_vec, normal_vec, f32::NAN), + VectorMath::token_projection(normal_vec, normal_vec, f32::NAN), 0.0 ); // Temperature scale with NaN/Inf - assert_eq!( - MojoSimdBridge::temperature_scale_fallback(f32::NAN, 1.0), - 0.0 - ); - assert_eq!( - MojoSimdBridge::temperature_scale_fallback(2.0, f32::NAN), - 0.0 - ); - assert_eq!( - MojoSimdBridge::temperature_scale_fallback(2.0, f32::INFINITY), - 0.0 - ); + assert_eq!(VectorMath::temperature_scale(f32::NAN, 1.0), 0.0); + assert_eq!(VectorMath::temperature_scale(2.0, f32::NAN), 0.0); + assert_eq!(VectorMath::temperature_scale(2.0, f32::INFINITY), 0.0); } #[test] - fn test_fallback_temperature_scale_edge_cases() { + fn test_temperature_scale_edge_cases() { // Zero or near-zero temperature should return unscaled logit - assert_eq!(MojoSimdBridge::temperature_scale_fallback(5.0, 0.0), 5.0); - assert_eq!( - MojoSimdBridge::temperature_scale_fallback(5.0, 0.00005), - 5.0 - ); + assert_eq!(VectorMath::temperature_scale(5.0, 0.0), 5.0); + assert_eq!(VectorMath::temperature_scale(5.0, 0.00005), 5.0); // Normal scaling - let scaled = MojoSimdBridge::temperature_scale_fallback(10.0, 2.0); + let scaled = VectorMath::temperature_scale(10.0, 2.0); assert!((scaled - 5.0).abs() < 1e-4); - let low_temp = MojoSimdBridge::temperature_scale_fallback(10.0, 0.5); + let low_temp = VectorMath::temperature_scale(10.0, 0.5); assert!((low_temp - 20.0).abs() < 1e-4); } #[test] - fn test_fallback_token_projection_and_entropy() { + fn test_token_projection_and_entropy() { let tokens = [2.0f32, 4.0, 6.0, 8.0]; let weights = [0.1f32, 0.2, 0.3, 0.4]; let bias = 0.5f32; - let proj = MojoSimdBridge::token_projection_fallback(tokens, weights, bias); + let proj = VectorMath::token_projection(tokens, weights, bias); let expected = 2.0 * 0.1 + 4.0 * 0.2 + 6.0 * 0.3 + 8.0 * 0.4 + 0.5; assert!((proj - expected).abs() < 1e-4); - let entropy = MojoSimdBridge::token_entropy_fallback([0.5, 0.5, 0.0, 0.0]); + let entropy = VectorMath::token_entropy([0.5, 0.5, 0.0, 0.0]); assert!((entropy - std::f32::consts::LN_2).abs() < 1e-4); assert!(entropy > 0.0); - let zero_entropy = MojoSimdBridge::token_entropy_fallback([1.0, 0.0, 0.0, 0.0]); + let zero_entropy = VectorMath::token_entropy([1.0, 0.0, 0.0, 0.0]); assert!((zero_entropy - 0.0).abs() < 1e-4); - let uniform4_entropy = MojoSimdBridge::token_entropy_fallback([0.25, 0.25, 0.25, 0.25]); + let uniform4_entropy = VectorMath::token_entropy([0.25, 0.25, 0.25, 0.25]); assert!((uniform4_entropy - (2.0 * std::f32::consts::LN_2)).abs() < 1e-4); // Mismatched slice length - assert_eq!( - MojoSimdBridge::cosine_similarity_fallback(&[1.0, 2.0], &[1.0]), - 0.0 - ); - assert_eq!(MojoSimdBridge::cosine_similarity_fallback(&[], &[]), 0.0); + assert_eq!(VectorMath::cosine_similarity(&[1.0, 2.0], &[1.0]), 0.0); + assert_eq!(VectorMath::cosine_similarity(&[], &[]), 0.0); } fn f64_4(value: &serde_json::Value, key: &str) -> [f64; 4] { @@ -577,7 +368,7 @@ mod tests { } } - fn simd_accumulate_ref(base_val: f64, scale: f64, steps: i32) -> f64 { + fn accumulate_ref(base_val: f64, scale: f64, steps: i32) -> f64 { if !base_val.is_finite() || !scale.is_finite() || steps <= 0 { return 0.0; } @@ -600,9 +391,9 @@ mod tests { } #[test] - fn test_simd_analytical_parity() { + fn test_analytical_parity() { let data = std::fs::read_to_string("tests/fixtures/simd_math_vectors.json") - .expect("committed SIMD golden vectors"); + .expect("committed golden vectors"); let v: serde_json::Value = serde_json::from_str(&data).expect("valid JSON fixture"); for case in v["entropy"].as_array().expect("entropy cases") { @@ -616,18 +407,10 @@ mod tests { golden, 1e-12, ); - let arr = f32_4(probs); assert_close( - "entropy fallback", + "entropy", &case["name"], - f64::from(MojoSimdBridge::token_entropy_fallback(arr)), - golden, - 1e-4, - ); - assert_close( - "entropy kernel", - &case["name"], - f64::from(MojoSimdBridge::token_entropy(arr)), + f64::from(VectorMath::token_entropy(f32_4(probs))), golden, 1e-4, ); @@ -645,19 +428,9 @@ mod tests { 1e-12, ); assert_close( - "cosine fallback", + "cosine", &case["name"], - f64::from(MojoSimdBridge::cosine_similarity_4d_fallback( - f32_4(a), - f32_4(b), - )), - golden, - 1e-4, - ); - assert_close( - "cosine kernel", - &case["name"], - f64::from(MojoSimdBridge::cosine_similarity_4d(f32_4(a), f32_4(b))), + f64::from(VectorMath::cosine_similarity_4d(f32_4(a), f32_4(b))), golden, 1e-4, ); @@ -676,20 +449,9 @@ mod tests { 1e-12, ); assert_close( - "projection fallback", + "projection", &case["name"], - f64::from(MojoSimdBridge::token_projection_fallback( - f32_4(tokens), - f32_4(weights), - bias as f32, - )), - golden, - 1e-4, - ); - assert_close( - "projection kernel", - &case["name"], - f64::from(MojoSimdBridge::token_projection( + f64::from(VectorMath::token_projection( f32_4(tokens), f32_4(weights), bias as f32, @@ -711,19 +473,9 @@ mod tests { 1e-12, ); assert_close( - "temperature fallback", - &case["name"], - f64::from(MojoSimdBridge::temperature_scale_fallback( - logit as f32, - temp as f32, - )), - golden, - 1e-4, - ); - assert_close( - "temperature kernel", + "temperature", &case["name"], - f64::from(MojoSimdBridge::temperature_scale(logit as f32, temp as f32)), + f64::from(VectorMath::temperature_scale(logit as f32, temp as f32)), golden, 1e-4, ); @@ -737,29 +489,14 @@ mod tests { assert_close( "accumulate analytical", &case["name"], - simd_accumulate_ref(base_val, scale, steps), + accumulate_ref(base_val, scale, steps), golden, 1e-9, ); assert_close( - "accumulate fallback", - &case["name"], - f64::from(MojoSimdBridge::simd_accumulate_fallback( - base_val as f32, - scale as f32, - steps, - )), - golden, - 1e-4, - ); - assert_close( - "accumulate kernel", + "accumulate", &case["name"], - f64::from(MojoSimdBridge::simd_accumulate( - base_val as f32, - scale as f32, - steps, - )), + f64::from(VectorMath::accumulate(base_val as f32, scale as f32, steps)), golden, 1e-4, ); diff --git a/tests/aegis_tests.rs b/tests/aegis_tests.rs index d8c2955..828294a 100644 --- a/tests/aegis_tests.rs +++ b/tests/aegis_tests.rs @@ -1,6 +1,6 @@ use aegis::{ create_router, AgentEngine, Database, GatewayState, HeartbeatEngine, HttpInferenceBackend, - MojoSimdBridge, SkillRegistry, VaultResolver, REDACTED_MARKER, + SkillRegistry, VaultResolver, VectorMath, REDACTED_MARKER, }; use axum::{ body::Body, @@ -466,18 +466,18 @@ async fn test_gateway_websocket_lifecycle() { } #[tokio::test] -async fn test_mojo_simd_bridge_operations() { +async fn test_vector_math_operations() { let v1 = [1.0f32, 0.0, 0.0, 0.0]; let v2 = [1.0f32, 0.0, 0.0, 0.0]; - let sim = MojoSimdBridge::cosine_similarity_4d(v1, v2); + let sim = VectorMath::cosine_similarity_4d(v1, v2); assert!((sim - 1.0).abs() < 1e-4); let tokens = [2.0f32, 4.0, 6.0, 8.0]; let weights = [0.25f32, 0.25, 0.25, 0.25]; - let proj = MojoSimdBridge::token_projection(tokens, weights, 2.0); + let proj = VectorMath::token_projection(tokens, weights, 2.0); assert!((proj - 7.0).abs() < 1e-4); - let entropy = MojoSimdBridge::token_entropy([0.5, 0.5, 0.0, 0.0]); + let entropy = VectorMath::token_entropy([0.5, 0.5, 0.0, 0.0]); assert!((entropy - std::f32::consts::LN_2).abs() < 1e-4); assert!(entropy > 0.0); } @@ -981,53 +981,38 @@ fn test_vault_streaming_redaction_and_zero_disk_keys() { } #[test] -fn test_mojo_simd_mathematical_invariants_and_edge_cases() { +fn test_vector_math_invariants_and_edge_cases() { // Zero vectors let zero = [0.0f32, 0.0, 0.0, 0.0]; let non_zero = [1.0f32, 2.0, 3.0, 4.0]; - assert_eq!( - MojoSimdBridge::cosine_similarity_4d_fallback(zero, non_zero), - 0.0 - ); - assert_eq!( - MojoSimdBridge::cosine_similarity_4d_fallback(zero, zero), - 0.0 - ); + assert_eq!(VectorMath::cosine_similarity_4d(zero, non_zero), 0.0); + assert_eq!(VectorMath::cosine_similarity_4d(zero, zero), 0.0); // Identical vectors let v = [0.5f32, -0.5, 0.5, -0.5]; - let sim_ident = MojoSimdBridge::cosine_similarity_4d_fallback(v, v); + let sim_ident = VectorMath::cosine_similarity_4d(v, v); assert!((sim_ident - 1.0).abs() < 1e-4); // Orthogonal vectors let o1 = [1.0f32, 0.0, 0.0, 0.0]; let o2 = [0.0f32, 1.0, 0.0, 0.0]; - assert_eq!(MojoSimdBridge::cosine_similarity_4d_fallback(o1, o2), 0.0); + assert_eq!(VectorMath::cosine_similarity_4d(o1, o2), 0.0); // Opposite vectors let opp = [-0.5f32, 0.5, -0.5, 0.5]; - let sim_opp = MojoSimdBridge::cosine_similarity_4d_fallback(v, opp); + let sim_opp = VectorMath::cosine_similarity_4d(v, opp); assert!((sim_opp - (-1.0)).abs() < 1e-4); // NaN and Inf handling let nan_v = [f32::NAN, 1.0, 2.0, 3.0]; let inf_v = [f32::INFINITY, 1.0, 2.0, 3.0]; - assert_eq!( - MojoSimdBridge::cosine_similarity_4d_fallback(nan_v, non_zero), - 0.0 - ); - assert_eq!( - MojoSimdBridge::cosine_similarity_4d_fallback(inf_v, non_zero), - 0.0 - ); + assert_eq!(VectorMath::cosine_similarity_4d(nan_v, non_zero), 0.0); + assert_eq!(VectorMath::cosine_similarity_4d(inf_v, non_zero), 0.0); // Temperature scale boundaries - assert_eq!(MojoSimdBridge::temperature_scale_fallback(4.0, 0.0), 4.0); - assert_eq!( - MojoSimdBridge::temperature_scale_fallback(4.0, f32::NAN), - 0.0 - ); - let normal_scaled = MojoSimdBridge::temperature_scale_fallback(8.0, 2.0); + assert_eq!(VectorMath::temperature_scale(4.0, 0.0), 4.0); + assert_eq!(VectorMath::temperature_scale(4.0, f32::NAN), 0.0); + let normal_scaled = VectorMath::temperature_scale(8.0, 2.0); assert!((normal_scaled - 4.0).abs() < 1e-4); } diff --git a/tests/canonical_abi_tests.rs b/tests/canonical_abi_tests.rs index 7425239..e3bdd48 100644 --- a/tests/canonical_abi_tests.rs +++ b/tests/canonical_abi_tests.rs @@ -37,11 +37,11 @@ fn test_aegis_session_to_canonical_agent_state_and_digest() { session.budget.max_total_tokens = 8192; let agent_id = AgentId::new_v4(); - let state: AgentState = session.to_agent_state(&agent_id, "GB10-MAX-Qwen"); + let state: AgentState = session.to_agent_state(&agent_id, "GB10-local-Qwen"); assert_eq!(state.abi_version, ProtocolVersion::new(1, 0)); assert_eq!(state.agent.agent_id, agent_id); - assert_eq!(state.agent.model_profile, "GB10-MAX-Qwen"); + assert_eq!(state.agent.model_profile, "GB10-local-Qwen"); assert_eq!(state.session.session_id, session.id.clone().into()); assert_eq!( state.objective.as_ref().unwrap().description, @@ -66,8 +66,8 @@ fn test_canonical_agent_state_branching_lineage() { let child = parent.branch(); let agent_id = AgentId::new_v4(); - let parent_state = parent.to_agent_state(&agent_id, "GB10-MAX-Qwen"); - let child_state = child.to_agent_state(&agent_id, "GB10-MAX-Qwen"); + let parent_state = parent.to_agent_state(&agent_id, "GB10-local-Qwen"); + let child_state = child.to_agent_state(&agent_id, "GB10-local-Qwen"); assert!(parent_state.parent.is_none()); assert!(child_state.parent.is_some()); diff --git a/tests/gates/aegis-check.gate b/tests/gates/aegis-check.gate index db707f9..12a22bf 100644 --- a/tests/gates/aegis-check.gate +++ b/tests/gates/aegis-check.gate @@ -10,8 +10,6 @@ inputs: - Cargo.lock - src/ - tests/ - - build.rs - - mojo/ - tests/gates/ run: exec: tests/gates/run.sh diff --git a/tests/gates/aegis-clippy.gate b/tests/gates/aegis-clippy.gate index fbcb285..2ad42a3 100644 --- a/tests/gates/aegis-clippy.gate +++ b/tests/gates/aegis-clippy.gate @@ -10,8 +10,6 @@ inputs: - Cargo.lock - src/ - tests/ - - build.rs - - mojo/ - tests/gates/ run: exec: tests/gates/run.sh diff --git a/tests/gates/aegis-fmt.gate b/tests/gates/aegis-fmt.gate index 9ed7327..99baa9b 100644 --- a/tests/gates/aegis-fmt.gate +++ b/tests/gates/aegis-fmt.gate @@ -10,7 +10,6 @@ inputs: - Cargo.lock - src/ - tests/ - - build.rs - tests/gates/ run: exec: tests/gates/run.sh diff --git a/tests/gates/aegis-test.gate b/tests/gates/aegis-test.gate index 3f1a390..d438a84 100644 --- a/tests/gates/aegis-test.gate +++ b/tests/gates/aegis-test.gate @@ -10,8 +10,6 @@ inputs: - Cargo.lock - src/ - tests/ - - build.rs - - mojo/ - tests/gates/ run: exec: tests/gates/run.sh diff --git a/tests/gates/run.sh b/tests/gates/run.sh index b0f8894..6b38747 100755 --- a/tests/gates/run.sh +++ b/tests/gates/run.sh @@ -22,17 +22,6 @@ need_protocols() { obs sibling_protocols_commit "\"$(git -C ../aien-protocols rev-parse HEAD 2>/dev/null || echo unknown)\"" } -# build.rs copies mojo/libaegis_simd.so into the tree when a mojo compiler is on PATH. -# The hosted runner has no mojo, so its tree stays clean; locally we remove the copy -# again when this run created it, so the clean_tree_after check mirrors hosted. -cargo_step() { - local so=mojo/libaegis_simd.so had=false - [ -e "$so" ] && had=true - obs mojo_on_path "$(command -v mojo >/dev/null && echo true || echo false)" - "$@" - if [ "$had" = false ] && [ -e "$so" ]; then rm -f "$so"; obs removed_generated_so true; fi -} - case "$step" in crumb-verify) "${CRUMB:-crumb}" verify . @@ -43,15 +32,15 @@ case "$step" in ;; check) need_protocols - cargo_step cargo check --all-targets + cargo check --all-targets ;; clippy) need_protocols - cargo_step cargo clippy --all-targets -- -D warnings + cargo clippy --all-targets -- -D warnings ;; test) need_protocols - cargo_step cargo test --verbose -- --test-threads=1 + cargo test --verbose -- --test-threads=1 ;; zero-disk-secrets) echo "Auditing repository for prohibited plaintext secret files..." From 04002f879010e65a21c14c1f33a0754a4d26b498 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 15 Oct 2026 06:19:20 -0500 Subject: [PATCH 2/5] crumb: drop the removed mojo dir and build.rs; code of conduct names AIEN pipelines Co-Authored-By: Claude Opus 5.5 --- .crumb | 35 ++++++++++++----------------------- AGENT_CODE_OF_CONDUCT.md | 2 +- docs/.crumb | 8 ++++---- src/.crumb | 12 ++++++------ tests/.crumb | 8 ++++---- 5 files changed, 27 insertions(+), 38 deletions(-) diff --git a/.crumb b/.crumb index 4cda09f..084742c 100644 --- a/.crumb +++ b/.crumb @@ -4,10 +4,6 @@ "name": "docs", "role": "" }, - { - "name": "mojo", - "role": "" - }, { "name": "scripts", "role": "" @@ -25,17 +21,11 @@ "generated": { "children": [ { - "digest": "0e67f750d69e5210c482d53230ffe07209af58a7d6176eb6a936759c0504d4c6", - "last_commit": "1eba7a7", + "digest": "8d4f47af8a191dd8dafe36d7fb8dae8d20f66570ec0471f404a401d77f38f2ec", + "last_commit": "95a5d60", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, - { - "digest": "49e79db936da2c48b45792dbf94788d88e700d04b44e19473cda4f62fccf33b3", - "last_commit": "fc2e889", - "name": "mojo", - "purpose": "Directory mojo. Purpose not yet described by a human." - }, { "digest": "c880e92d912019a3ae3a21139be2b1783d4aa45ff81cd4954e271179beab0b44", "last_commit": "fc2e889", @@ -43,27 +33,27 @@ "purpose": "Directory scripts. Purpose not yet described by a human." }, { - "digest": "32915e3f9b0295a3b3f99438d6fbbe9c495aa296b5910203ba656ed8553ceb7c", - "last_commit": "8724580", + "digest": "c5014f96cda85b2aa1ea45e07fb24d31c48a69869a4c7cd907e6cbd5108f684c", + "last_commit": "95a5d60", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, { - "digest": "7e77e7bf496c6e3ef423ae36d156c2d56346155341db6619a5f45de316632503", - "last_commit": "ebc3b13", + "digest": "ce87e921b21d06f9a929ea39e1e5f83c5f2081409e8b6f4311e74d32b7f1ed0f", + "last_commit": "95a5d60", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." } ], - "children_root": "sha256:ac4b01de578e8b9d1be9abdac21c14a839eed0a4043b032f299d30fc13cf1c42", - "compiled_at": "2026-10-13T10:44:57Z", + "children_root": "sha256:255a70c93a80969f70a10fbc24a9c7170c254c4a3128aecc3bd64a5a5d010151", + "compiled_at": "2026-10-15T11:19:04Z", "compiler": "crumb-compile/1", - "digest": "sha256:dc2fa8db462c69bf39b2fadee410d5586b507ae97b29bd3645c060084a00f86a", + "digest": "sha256:63e5456fcca3f81ef5a758208f2485adfb73a835445f5f329bc139e9c0f46c31", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 96, - "generated_at_commit": "2e9f40ae0cd9484757f065e407cb20016d146317", - "source_tree": "sha256:8f84d431e07483471fca6f4d81e6b3f5ac7cd1fde17cfcfffc5dcd66421213ce" + "files": 94, + "generated_at_commit": "95a5d6052daa9f6a81c731842628db28a4e05482", + "source_tree": "sha256:badecb3a9912a9709f86fbade1b2808fca223957120b4081d3a1b38991e33153" }, "owner_lane": "", "seed": { @@ -77,7 +67,6 @@ "LICENSE", "README.md", "agent.json", - "build.rs", "install.sh", "llms.txt" ], diff --git a/AGENT_CODE_OF_CONDUCT.md b/AGENT_CODE_OF_CONDUCT.md index e66e235..37fadae 100644 --- a/AGENT_CODE_OF_CONDUCT.md +++ b/AGENT_CODE_OF_CONDUCT.md @@ -17,7 +17,7 @@ This Specification establishes non-negotiable operational requirements for all a --- ### Article II: Multi-Agent Topology, Inter-Agent Payloads, and Anti-Enclosure -1. **Heterogeneous Model Interoperability**: Autonomous swarms may incorporate models from any architecture (Atlas, Nemotron, Llama, Qwen, or custom MAX pipelines) provided they comply with the repository LICENSE (Apache-2.0) and respect the nonbinding COVENANT.md. +1. **Heterogeneous Model Interoperability**: Autonomous swarms may incorporate models from any architecture (Atlas, Nemotron, Llama, Qwen, or custom AIEN pipelines) provided they comply with the repository LICENSE (Apache-2.0) and respect the nonbinding COVENANT.md. 2. **Typed Inter-Agent Payloads**: Subagent communication must utilize structured, typed schemas (JSON or Bincode) rather than free-form conversational chatter. Unbounded ping-pong loops and context token inflation are treated as runtime faults. 3. **Attribution and Imprint Provenance**: Any distilled knowledge, learned heuristics, or memory entities transferred between agents must record canonical provenance in Cortex memory, preserving the downstream lineage and copyright attribution of the human Licensor. diff --git a/docs/.crumb b/docs/.crumb index e30bbbd..9459e9a 100644 --- a/docs/.crumb +++ b/docs/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-10T16:05:01Z", + "compiled_at": "2026-10-15T11:19:04Z", "compiler": "crumb-compile/1", - "digest": "sha256:0e67f750d69e5210c482d53230ffe07209af58a7d6176eb6a936759c0504d4c6", + "digest": "sha256:8d4f47af8a191dd8dafe36d7fb8dae8d20f66570ec0471f404a401d77f38f2ec", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 3, - "generated_at_commit": "e21dab3edbdededb2396a74d0614c797b912bb6a", - "source_tree": "sha256:6a89e2f26e44220fe9335f8be611fac690c78f656d1f6bd0b88359f98a91ed85" + "generated_at_commit": "95a5d6052daa9f6a81c731842628db28a4e05482", + "source_tree": "sha256:c6c7337846c7ebc74c35698bb61740bb565659f8d20bb355ab91e3e8b9b6044d" }, "owner_lane": "", "seed": { diff --git a/src/.crumb b/src/.crumb index d7d6094..43849a5 100644 --- a/src/.crumb +++ b/src/.crumb @@ -70,14 +70,14 @@ } ], "children_root": "sha256:05cb4db01c3494940598a025e8efa62d57c3c1a3eaac2c2681e0ba0433f5f3b3", - "compiled_at": "2026-10-13T02:40:48Z", + "compiled_at": "2026-10-15T11:19:04Z", "compiler": "crumb-compile/1", - "digest": "sha256:32915e3f9b0295a3b3f99438d6fbbe9c495aa296b5910203ba656ed8553ceb7c", + "digest": "sha256:c5014f96cda85b2aa1ea45e07fb24d31c48a69869a4c7cd907e6cbd5108f684c", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 49, - "generated_at_commit": "8724580bdb385ec058f937912c2b88e006a67dc6", - "source_tree": "sha256:f893d1036d10c8e9dcf3ffe774949e2f06af424e03afde6f7a35fbf8b07b2410" + "generated_at_commit": "95a5d6052daa9f6a81c731842628db28a4e05482", + "source_tree": "sha256:4918d81912356e4d354f90aece8864c2be05db4a625b74e4fa4e77a279115e61" }, "owner_lane": "", "seed": { @@ -90,11 +90,11 @@ "inference.rs", "lib.rs", "main.rs", - "mojo_bridge.rs", "policy_guard.rs", "security.rs", "skills.rs", - "vault.rs" + "vault.rs", + "vector_math.rs" ], "purpose_auto": "Directory src. Purpose not yet described by a human." } diff --git a/tests/.crumb b/tests/.crumb index cc2057a..de97032 100644 --- a/tests/.crumb +++ b/tests/.crumb @@ -20,14 +20,14 @@ } ], "children_root": "sha256:2f0b999b8999ad3095c8081fb342d506f27f7b07b31452b67140d330ccf4dc76", - "compiled_at": "2026-10-13T02:40:48Z", + "compiled_at": "2026-10-15T11:19:04Z", "compiler": "crumb-compile/1", - "digest": "sha256:7e77e7bf496c6e3ef423ae36d156c2d56346155341db6619a5f45de316632503", + "digest": "sha256:ce87e921b21d06f9a929ea39e1e5f83c5f2081409e8b6f4311e74d32b7f1ed0f", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 20, - "generated_at_commit": "8724580bdb385ec058f937912c2b88e006a67dc6", - "source_tree": "sha256:c62dd28919513f092892d5cf8fad32b01a00836e695a7cfdd6491c7ee77d770f" + "generated_at_commit": "95a5d6052daa9f6a81c731842628db28a4e05482", + "source_tree": "sha256:f3c3099ee4d0abe85fdc8780f296891279b15d951440a58e7ee5000a14b6a9fc" }, "owner_lane": "", "seed": { From ceda87ffa40f95413dffa8f6b8399130c7784f48 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 15 Oct 2026 06:19:20 -0500 Subject: [PATCH 3/5] crumb: recompile after removal Co-Authored-By: Claude Opus 5.5 --- .crumb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.crumb b/.crumb index 084742c..a316087 100644 --- a/.crumb +++ b/.crumb @@ -46,14 +46,14 @@ } ], "children_root": "sha256:255a70c93a80969f70a10fbc24a9c7170c254c4a3128aecc3bd64a5a5d010151", - "compiled_at": "2026-10-15T11:19:04Z", + "compiled_at": "2026-10-15T11:19:20Z", "compiler": "crumb-compile/1", - "digest": "sha256:63e5456fcca3f81ef5a758208f2485adfb73a835445f5f329bc139e9c0f46c31", + "digest": "sha256:041b002952116fdb89de47d104b0f00d6c1fcc64b8c07388cab4d59026016c1f", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 94, - "generated_at_commit": "95a5d6052daa9f6a81c731842628db28a4e05482", - "source_tree": "sha256:badecb3a9912a9709f86fbade1b2808fca223957120b4081d3a1b38991e33153" + "generated_at_commit": "04002f879010e65a21c14c1f33a0754a4d26b498", + "source_tree": "sha256:4a5296d985bd51bd87fbfa8922f98a67d8c3eefbc005db7050a7d44be38217eb" }, "owner_lane": "", "seed": { From 70caebf44b4908ede6e38569b4ef6a809e5999cc Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 15 Oct 2026 06:23:28 -0500 Subject: [PATCH 4/5] heartbeat: note that one test covers the legacy task name Co-Authored-By: Claude Opus 5.5 --- src/heartbeat.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/heartbeat.rs b/src/heartbeat.rs index b81e3a8..c098852 100644 --- a/src/heartbeat.rs +++ b/src/heartbeat.rs @@ -281,6 +281,7 @@ mod tests { #[tokio::test] async fn test_overlapping_pulses_run_a_task_once() { let db = Arc::new(Database::open_in_memory().unwrap()); + // Uses the former task name on purpose, so the legacy alias stays covered. db.create_task("hb_once", "max_health", "check").unwrap(); // The first pulse awaits the health probe while the second one lists From 63f01e6c0872eb8b572e55e865044808392e724f Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 15 Oct 2026 06:23:29 -0500 Subject: [PATCH 5/5] crumb: recompile Co-Authored-By: Claude Opus 5.5 --- .crumb | 14 +++++++------- src/.crumb | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.crumb b/.crumb index a316087..324638e 100644 --- a/.crumb +++ b/.crumb @@ -33,8 +33,8 @@ "purpose": "Directory scripts. Purpose not yet described by a human." }, { - "digest": "c5014f96cda85b2aa1ea45e07fb24d31c48a69869a4c7cd907e6cbd5108f684c", - "last_commit": "95a5d60", + "digest": "9342bca2f46670fbe8ea6e4fd4adb136dc60ef9c3cfebade427ed268d92c9472", + "last_commit": "70caebf", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, @@ -45,15 +45,15 @@ "purpose": "Directory tests. Purpose not yet described by a human." } ], - "children_root": "sha256:255a70c93a80969f70a10fbc24a9c7170c254c4a3128aecc3bd64a5a5d010151", - "compiled_at": "2026-10-15T11:19:20Z", + "children_root": "sha256:c1d66693c1fd9f409c53e3dd0ccc403202f938f48e31f0b80b1f234798efef13", + "compiled_at": "2026-10-15T11:23:29Z", "compiler": "crumb-compile/1", - "digest": "sha256:041b002952116fdb89de47d104b0f00d6c1fcc64b8c07388cab4d59026016c1f", + "digest": "sha256:3e88eec8fbf0cea91032745498bac427572bad8c2e5fd32a6e7fd5d85dea5ae0", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 94, - "generated_at_commit": "04002f879010e65a21c14c1f33a0754a4d26b498", - "source_tree": "sha256:4a5296d985bd51bd87fbfa8922f98a67d8c3eefbc005db7050a7d44be38217eb" + "generated_at_commit": "70caebf44b4908ede6e38569b4ef6a809e5999cc", + "source_tree": "sha256:e74fe81b787f1a70bb6e25224a9709a87e86c3aeb5be2694290cb9de2e8da577" }, "owner_lane": "", "seed": { diff --git a/src/.crumb b/src/.crumb index 43849a5..f5d865a 100644 --- a/src/.crumb +++ b/src/.crumb @@ -70,14 +70,14 @@ } ], "children_root": "sha256:05cb4db01c3494940598a025e8efa62d57c3c1a3eaac2c2681e0ba0433f5f3b3", - "compiled_at": "2026-10-15T11:19:04Z", + "compiled_at": "2026-10-15T11:23:29Z", "compiler": "crumb-compile/1", - "digest": "sha256:c5014f96cda85b2aa1ea45e07fb24d31c48a69869a4c7cd907e6cbd5108f684c", + "digest": "sha256:9342bca2f46670fbe8ea6e4fd4adb136dc60ef9c3cfebade427ed268d92c9472", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 49, - "generated_at_commit": "95a5d6052daa9f6a81c731842628db28a4e05482", - "source_tree": "sha256:4918d81912356e4d354f90aece8864c2be05db4a625b74e4fa4e77a279115e61" + "generated_at_commit": "70caebf44b4908ede6e38569b4ef6a809e5999cc", + "source_tree": "sha256:c15c6eea62a588cdf4ae3d56f7203626994d55d493546e17b3d3c7833d610a11" }, "owner_lane": "", "seed": {