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 / CONTEXT.md
| 1 | # aien-sovereign-core |
| 2 | |
| 3 | The Rust workspace for the AIEN host runtime on Linux (DGX Spark target): the `aien` command line, a single-process runtime daemon, the inference ABI and scheduler, and the supporting services around them. This file lists what exists and who owns what. It makes no claim that any part is complete or released; the README states the release state, and `docs/audits/` in aien-architecture holds the integration audit. |
| 4 | |
| 5 | Ownership: this repository has no `CODEOWNERS` file, so per-component owners are not recorded here (UNVERIFIED who owns each crate). Cross-repo plans and decisions are owned by aien-architecture (`PLAN_AUTHORITY.md`, `CURRENT_EXECUTION_PLAN.md`, ADRs). Decisions made in this repo live in `docs/adr/`. |
| 6 | |
| 7 | ## Language |
| 8 | |
| 9 | **Runtime daemon**: |
| 10 | The long-running process started by `aien start` (it runs as `aien --daemon`). It owns the model, the KV memory and the socket the command line talks to. Code: `crates/aien-runtime`, started from `crates/aien-cli/src/commands.rs`. |
| 11 | _Avoid_: server, service |
| 12 | |
| 13 | **Approval desk**: |
| 14 | The operator's approval step for effects. It is required by default; a desk key created by `aien compose desk-key --create 1` must exist before the daemon starts. Code: `aien-runtime/src/compose/bridge.rs`, `approved_auth.rs`. |
| 15 | _Avoid_: login, auth |
| 16 | |
| 17 | **Objective record**: |
| 18 | The operator's written objective, stored as `objectives/<id>.json` under the provenance folder, re-read by the daemon when a grant is bound to it. Code: `aien-runtime/src/objective.rs`, `aien-cli/src/objective.rs`. |
| 19 | _Avoid_: task, ticket |
| 20 | |
| 21 | **Compose home**: |
| 22 | The state folder holding the desk key and composition state (`AIEN_COMPOSE_DIR`, else under `AIEN_RUNTIME_STATE_DIR`, else XDG state, else `~/.local/state/aien-runtime/compose`). |
| 23 | |
| 24 | **Candidate**: |
| 25 | The release candidate this tree may be released as, named in `release/candidate.toml` with its model digests and source pins. `omega.lock` pins the omega commit that is linked. Changed only with aien-architecture's candidate manifest. |
| 26 | |
| 27 | **Generation controller**: |
| 28 | The one module that runs a generation for any model: it keeps the sequence ledger (history and position), reuses a prefix, rewinds, exports and restores the KV cache, picks each token, applies constraints, stops and streams. Written once; drives a forward pass through the `ForwardPass` trait (ADR 0004). Planned code: `aien-inference-abi`, type `GenerationController<M>`. |
| 29 | _Avoid_: engine, sequence driver, inference loop, runtime (that word means the daemon) |
| 30 | |
| 31 | **Forward pass**: |
| 32 | One model's implementation behind the seam: its weights, layer maths, kernels, attention path and cache, prefill strategy, decode graph, output head, traces and mutants. The 30B MoE, the 8B dense and the host fake are each one forward pass. It never loops over tokens itself. |
| 33 | _Avoid_: engine, model (ambiguous with the weights file), backend |
| 34 | |
| 35 | **KV geometry**: |
| 36 | The numbers that fix the KV cache's layout and payload bytes (layers, query heads, KV heads, head width, rope theta, block size), produced from a model's config and read by every cache constructor and by persistence. Type `KvGeometry` (ADR 0004). Model-independent: no cache code reads `Qwen3MoeConfig` directly. |
| 37 | _Avoid_: config, shape, dims |
| 38 | |
| 39 | **Head**: |
| 40 | The pending output a forward call leaves behind for one position, from which the next token is chosen. Read once, as either the chip's own argmax or the full logits. One after prefill, one per decoded token. |
| 41 | _Avoid_: pending token, logits buffer, output (overloaded) |
| 42 | |
| 43 | **Step rule**: |
| 44 | What a constraint allows at one decode step: anything, an allowed set of token ids, one forced token, or finish. Applied by the generation controller between the head and the sampler. Type `StepRule` (ADR 0004). |
| 45 | _Avoid_: mask (that is one way to apply a rule, not the rule), grammar |
| 46 | |
| 47 | **Host fake**: |
| 48 | The test-only forward pass that runs with no chip and no weights, on a real host KV cache, with tokens that depend on every stored KV row. Used to test the generation controller end to end, including constraints and persistence. Type `EchoChainModel` (ADR 0004). |
| 49 | _Avoid_: mock, stub (the serve-http stub engine is a different thing) |
| 50 | |
| 51 | ## Components (from crate descriptions) |
| 52 | |
| 53 | Runtime and inference |
| 54 | - `aien-runtime`: single-process runtime spine (daemon, compose bridge, objective and desk logic). |
| 55 | - `aien-cli`: the `aien` command line and terminal agent harness. |
| 56 | - `aien-inference-abi`, `aien-abi-core`, `aien-inference-runtime`, `aien-inference-service`: inference ABI, backend trait, weights loader, service protocols. |
| 57 | - `aien-kv-cache`, `aien-scheduler`: paged KV cache and continuous-batching scheduler. |
| 58 | - `aien-omega-gpu`, `aien-omega-compose`: bindings to the omega GPU matmul engine and omega composition (pinned by `omega.lock`). |
| 59 | - `aien-platform`, `aien-platform-linux`: platform ABI and the Linux / GB10 driver cell. |
| 60 | |
| 61 | Identity, memory, evidence |
| 62 | - `aien-allen`, `aien-allen-memory`, `aien-allen-profile`: ALLEN identity gate, scoped memory, persona profile. |
| 63 | - `cortex-rs`, `cortex-encoder-rs`, `cortex-path-m1`: Cortex memory engine, embeddings, a read-only retrieval experiment. |
| 64 | - `aien-capability`, `aien-mcp`, `aien-security`: tool and effect descriptors, MCP sessions, security abstractions. |
| 65 | - `aien-proof`, `aien-closure`, `aien-trace`, `aien-dual-observation`, `aien-replay`, `aien-campaign-verifier`, `crumbs`: test board, closure check, correlation trace, observation snapshot, transcript reader, campaign verifier, curriculum substrate. |
| 66 | |
| 67 | Services and tools |
| 68 | - `spark-*` crates (cockpit, supervisor, debugger, harness, aegis, hive, dream, mail, discord hub, harvester, inquisitor, adapters, crumbs) and `rad-id-sync`, `aien-switchboard`, `aien-drive`: supporting services and tools; see each crate's Cargo description. |
| 69 | - `tools/aien-verify`: independent verifier of the whole-system end-to-end run folders; standard library only. Tests: `tools/aien-verify/tests/run.sh` (run in CI). |
| 70 | |
| 71 | ## Where things are |
| 72 | |
| 73 | - Release machinery: `install.sh`, `scripts/check-release-candidate.sh`, `scripts/package-release.sh`, `docs/release/`. |
| 74 | - First-run steps for an operator: `docs/FIRST_RUN.md`. |
| 75 | - End-to-end and campaign material: `scripts/whole_system_e2e.sh`, `docs/campaigns/`. |