interplane.Get Omega
Read in your language

aien-architecture-mv

Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.

Brought by drakestapleton

branch main Branches Tags History

aien-architecture-mv / docs / archive / plans / 2026-09-22 / AIEN_COMPLETE_SYSTEM_ARCHITECTURE.md

3393 lines · 70081 bytes Raw Blame History Rendered
1> **SUPERSEDED / HISTORICAL — DO NOT USE AS AN ACTIVE IMPLEMENTATION PLAN**
2>
3> Original path: `AIEN_COMPLETE_SYSTEM_ARCHITECTURE.md`
4>
5> Archived on 2026-09-27 during plan consolidation. The active cross-project execution plan is [CURRENT_EXECUTION_PLAN.md](../../../../CURRENT_EXECUTION_PLAN.md), governed by [PLAN_AUTHORITY.md](../../../../PLAN_AUTHORITY.md).
6>
7> Retained for provenance only.
8
9---
10
11# AIEN Complete System Architecture
12## Universal Local AI Runtime, Heterogeneous Compute Fabric, Skills/Tools, J-Space, Security, Memory, Provenance, and Self-Improvement
13
14**Document status:** Architecture RFC / implementation roadmap
15**Snapshot date:** September 22, 2026
16**Primary composition root reviewed:** `aien-spark/aien-sovereign-core`
17**Current public `main` snapshot reviewed:** `cacf2264b52cac20ba0ac6aee55fcde9110d97b6`
18**Naming convention:** Physical hosts are always referred to as **Machine 1**, **Machine 2**, **Machine 3**, and so on. Hardware type is metadata, not identity.
19
20---
21
22# 1. Executive Summary
23
24AIEN should become a **single logical AI system that can use every compatible machine, accelerator, model, skill, tool, memory store, and verifier available to it without making any one hardware vendor, model vendor, cloud service, or protocol the center of the architecture**.
25
26The project already contains unusually strong pieces:
27
28- a native Rust runtime spine,
29- scheduler and sequence lifecycle,
30- branchable/paged KV state,
31- native transformer execution,
32- Unix-domain-socket operator control,
33- Cortex memory,
34- AEGIS policy enforcement,
35- signed evaluation receipts and TPM-oriented signing primitives,
36- RSI candidate evaluation and promotion,
37- multiple Rust MCP servers,
38- benchmark/provenance infrastructure,
39- cockpit/operator interfaces,
40- harness/debugger/inquisitor subsystems,
41- model adapters,
42- and a growing set of real effect integrations.
43
44The largest remaining problem is no longer “can AIEN run inference?” It is **composition**.
45
46AIEN still needs one canonical layer that answers all of the following:
47
481. **What work needs to happen?**
492. **What skill or tool can perform it?**
503. **Which Machine can perform it?**
514. **Which model or accelerator should be used?**
525. **Can the work be explored in parallel branches?**
536. **What state belongs to each branch?**
547. **What effects are permitted?**
558. **How do we prove what actually happened?**
569. **What should be remembered?**
5710. **How should the system improve from the result?**
58
59The target architecture is therefore:
60
61```mermaid
62flowchart TD
63 U[User / Operator / API] --> C[AIEN Control Plane]
64 C --> R[AIEN Runtime]
65 R --> JS[J-Space Planner and Judge]
66 JS --> SR[Skill Router]
67 SR --> CG[Capability Graph]
68
69 CG --> NT[Native AIEN Tools]
70 CG --> MCP[MCP Broker]
71 CG --> FP[Fabric-Provided Tools]
72
73 JS --> IF[Inference Runtime]
74 IF --> MC[Model Capsule Registry]
75 IF --> AD[Accelerator Dispatch]
76
77 AD --> M1[Machine 1]
78 AD --> M2[Machine 2]
79 AD --> M3[Machine 3]
80 AD --> MN[Machine N]
81
82 M1 --> FAB[AIEN Fabric]
83 M2 --> FAB
84 M3 --> FAB
85 MN --> FAB
86
87 NT --> AE[AEGIS Authorization]
88 MCP --> AE
89 FP --> AE
90
91 AE --> EB[Effect Broker]
92 EB --> EXT[External World]
93
94 R --> W[World Store]
95 JS --> W
96 EB --> W
97
98 W --> P[Signed Provenance]
99 P --> CX[Cortex]
100 CX --> R
101
102 R --> RSI[RSI Optimizer]
103 RSI --> H[Harness / Inquisitor / Benchmarks]
104 H --> R
105```
106
107The central design principle is:
108
109> **AIEN is one logical runtime. Machines are interchangeable capability providers. Models are interchangeable inference providers. MCP is an adapter. Tools are atomic capabilities. Skills are composed procedures. J-Space is the branch-and-judge planning substrate. Worlds hold state. AEGIS verifies. The Effect Broker adapter performs verified irreversible actions. Provenance proves. Cortex remembers. RSI improves.**
110
111---
112
113
114# 1A. Resolved Architecture Decisions After Sovereign Manifesto Review
115
116The `open-humanity/docs/SOVEREIGN_MANIFESTO.md` establishes several architectural invariants that directly affect MCP, secrets, Fabric placement, and speculative execution:
117
118- local-first execution,
119- compiled Rust/Mojo core services,
120- zero telemetry,
121- zero plaintext secrets on disk,
122- hardware-backed vaulting,
123- durable memory,
124- encrypted peer cooperation.
125
126The following decisions are therefore **closed** for the target architecture.
127
128## Decision 1: `aien-mcp` lives inside `aien-sovereign-core`
129
130Canonical location:
131
132```text
133aien-sovereign-core/
134└── crates/
135 └── aien-mcp/
136```
137
138Do **not** create a separate canonical MCP repository first.
139
140Reasons:
141
1421. MCP is part of AIEN's runtime capability plane, not an independent product.
1432. It must share canonical types with `aien-capability`, `aien-policy`, `aien-vault`, `aien-fabric`, `aien-world`, and provenance.
1443. Keeping it in the composition root prevents another source-of-truth split.
1454. Existing MCP implementations in `spark-debugger` and `aien-harness` should migrate into adapters/tests around `aien-mcp`.
1465. A separate public SDK crate or mirror can be published later from the canonical source if external adoption warrants it.
147
148Do not start this work by mixing it into unrelated local edits on `fix/golden-path-gaps`. Create a clean feature branch from the appropriate synchronized base once the golden-path work is committed or isolated.
149
150Recommended branch:
151
152```text
153feat/aien-mcp-broker
154```
155
156## Decision 2: AEGIS applies to every capability provider
157
158Every tool invocation crosses the same canonical authorization envelope regardless of provider:
159
160```text
161Native Tool
162MCP Tool
163Fabric Tool
164WASM Tool
165Process Tool
166HTTP Tool
167 │
168 ▼
169Capability Invocation
170 │
171 ▼
172AEGIS
173 │
174 ├── deny
175 └── allow
176 │
177 ▼
178 Executor
179```
180
181This does **not** mean every read operation requires human approval.
182
183It means every provider enters the same policy boundary. Policy may deterministically auto-allow safe/read-only operations.
184
185The result is one policy model and one receipt family rather than separate trust models for MCP, native tools, and remote Machines.
186
187The MCP broker **routes**. It does not become an alternative policy authority.
188
189## Decision 3: Third-party servers may request environment variables, but AIEN configuration never stores the plaintext value
190
191Third-party compatibility requires handling servers that expect environment variables such as:
192
193```text
194GITHUB_TOKEN
195DATABASE_URL
196API_KEY
197```
198
199AIEN should accept the **binding requirement**, not a plaintext value.
200
201Example:
202
203```rust
204CredentialRef {
205 provider: CredentialProvider::Vault,
206 name: "github.operator",
207 scope: CredentialScope::MachineResolvable,
208 delivery: CredentialDelivery::ChildEnv {
209 variable: "GITHUB_TOKEN",
210 },
211}
212```
213
214The stored configuration contains only the reference.
215
216At execution time:
217
218```text
219ToolCall
220 ↓
221AEGIS
222 ↓
223Fabric placement
224 ↓
225MCP Broker on selected Machine
226 ↓
227Vault resolve
228 ↓
229launch one child with one ephemeral variable
230 ↓
231child exits
232 ↓
233credential value discarded
234```
235
236The model, J-Space state, tool arguments, World records, logs, Cortex, and provenance receipts never contain the resolved secret.
237
238### Important limitation
239
240A bearer token must exist in plaintext **somewhere in volatile memory** when an HTTP client or legacy child process actually authenticates with it.
241
242Therefore the realistic invariant is:
243
244> No plaintext secret at rest, in configuration, prompts, logs, receipts, or long-lived caches; plaintext is materialized only at the smallest possible execution boundary for the shortest possible time.
245
246Preferred delivery order:
247
2481. broker-owned authentication, where the child never sees the token;
2492. short-lived OAuth/access token owned by the broker;
2503. inherited file descriptor / pipe / local socket when supported;
2514. call-scoped child environment variable only for legacy compatibility.
252
253Environment-variable delivery should be tagged as a higher exposure class.
254
255## Decision 4: Credential scope participates in Fabric placement
256
257A TPM-backed vault is physically local.
258
259A credential that exists only on one Machine cannot magically resolve elsewhere.
260
261Do not hard-code a Machine ID into every semantic tool request. Instead, make **credential scope** part of placement constraints.
262
263```rust
264pub enum CredentialScope {
265 FabricResolvable,
266 MachineBound(MachineId),
267 OperatorBound(OperatorId),
268 SessionBound(SessionId),
269}
270```
271
272Resolution:
273
274```text
275Tool requires github.operator
276 ↓
277Capability Graph
278 ↓
279Credential Resolver
280 ↓
281Which Machines can satisfy it?
282 ↓
283Fabric Scheduler
284 ↓
285eligible Machine selected
286```
287
288If Machine 2 cannot resolve the required credential, Machine 2 is not an eligible placement.
289
290This is a scheduling constraint, not a late runtime surprise.
291
292## Decision 5: Every tool declares effect semantics before J-Space may route it
293
294J-Space must not infer side effects from a tool name.
295
296Each tool declares an explicit effect set.
297
298Recommended model:
299
300```rust
301bitflags! {
302 pub struct ToolEffects: u32 {
303 const PURE = 0;
304 const READ_FILESYSTEM = 1 << 0;
305 const READ_NETWORK = 1 << 1;
306 const SPAWN_PROCESS = 1 << 2;
307 const WORLD_MUTATION = 1 << 3;
308 const LOCAL_EPHEMERAL = 1 << 4;
309 const EXTERNAL_WRITE = 1 << 5;
310 const EXTERNAL_IRREVERSIBLE= 1 << 6;
311 const SECRET_BEARING = 1 << 7;
312 }
313}
314```
315
316J-Space policy:
317
318| Effect type | Speculative J-Space execution |
319|---|---|
320| Pure | Yes |
321| Read-only | Yes |
322| Local ephemeral | Yes, sandboxed |
323| Process spawn | Yes when sandboxed and bounded |
324| World mutation | Yes, but only inside a draft World |
325| External write | Stage intent only until winner |
326| External irreversible | Never execute on speculative branch |
327| Secret-bearing | Only through brokered isolated execution |
328
329Example: `debug_scan` is not simply "read-only" because it may spawn local checks and probe services. Its descriptor should declare the actual operations, for example:
330
331```text
332READ_FILESYSTEM
333READ_NETWORK
334SPAWN_PROCESS
335LOCAL_EPHEMERAL
336```
337
338That lets J-Space execute it safely as a bounded evaluator without treating it as an externally visible write.
339
340The universal rule is:
341
342> J-Space may explore freely inside reversible Worlds. External reality changes only after selection, AEGIS authorization, and commit through the Effect Broker.
343
344---
345
346# 2. Architectural Principles
347
348## 2.1 Hardware must not define AIEN
349
350AIEN must not require CUDA, NVIDIA, Apple, AMD, a cloud provider, or a single machine.
351
352The runtime should depend only on a hardware-neutral accelerator interface.
353
354A Machine advertises capabilities such as:
355
356```rust
357pub struct MachineCapabilities {
358 pub machine_id: MachineId,
359 pub cpu_arch: CpuArch,
360 pub cpu_cores: u16,
361 pub memory_total_bytes: u64,
362 pub memory_available_bytes: u64,
363 pub accelerators: Vec<AcceleratorCaps>,
364 pub supported_dtypes: DTypeSet,
365 pub models_cached: Vec<ModelDigest>,
366 pub tool_providers: Vec<ToolProviderId>,
367 pub thermal_state: ThermalState,
368 pub power_state: PowerState,
369}
370```
371
372The scheduler should reason over capabilities, not brand names.
373
374---
375
376## 2.2 One logical system, many physical processes
377
378AIEN should **not** attempt to stretch one operating-system process or one address space across multiple machines.
379
380Instead:
381
382- every Machine runs an `aien-node`,
383- all Machines participate in one logical Fabric,
384- state identifiers are global,
385- memory ownership remains local,
386- work can move,
387- failed Machines can be replaced,
388- content is addressed by digest,
389- and state can be reconstructed from durable roots.
390
391```mermaid
392flowchart LR
393 CP[Logical AIEN Runtime]
394
395 CP --> M1[Machine 1]
396 CP --> M2[Machine 2]
397 CP --> M3[Machine 3]
398 CP --> M4[Machine 4]
399
400 M1 <-->|QUIC / trusted transport| M2
401 M2 <-->|QUIC / trusted transport| M3
402 M3 <-->|QUIC / trusted transport| M4
403 M1 <-->|content / work / state| M4
404```
405
406---
407
408## 2.3 Tools are not skills
409
410**Tool:** one atomic capability.
411
412Examples:
413
414- `filesystem.read`
415- `filesystem.write`
416- `process.execute`
417- `git.diff`
418- `git.commit`
419- `mail.send`
420- `browser.navigate`
421- `cortex.search`
422- `database.query`
423
424**Skill:** a reusable procedure that can invoke multiple tools and can contain planning, success criteria, verification rules, and J-Space strategy.
425
426Examples:
427
428- `software.debug.rust`
429- `software.review.pull_request`
430- `software.implement.feature`
431- `research.deep`
432- `communication.answer_email`
433- `operations.release`
434
435This distinction must become canonical.
436
437---
438
439## 2.4 MCP is compatibility, not the core architecture
440
441MCP is useful and important, but AIEN should not make the internal runtime depend on MCP semantics.
442
443The canonical path should be:
444
445```text
446AIEN Capability ABI
447 ├── Native Tool adapter
448 ├── MCP adapter
449 ├── HTTP/OpenAPI adapter
450 ├── WASM Component adapter
451 ├── Process adapter
452 └── Fabric Remote Tool adapter
453```
454
455The model sees **AIEN capabilities**, not raw MCP topology.
456
457---
458
459## 2.5 Effects are transactional
460
461Models, skills, tools, and J-Space branches should be able to propose actions.
462
463Only a dedicated effect boundary should perform irreversible external actions.
464
465```mermaid
466flowchart LR
467 A[Agent / Skill / J-Space] --> I[EffectIntent]
468 I --> G[AEGIS]
469 G -->|deny| D[Stop]
470 G -->|allow| B[Effect Broker]
471 B --> E[External System]
472 E --> R[Execution Receipt]
473 R --> W[World Commit]
474 W --> P[Signed Provenance]
475```
476
477---
478
479## 2.6 Memory is not execution state
480
481Cortex should remember durable knowledge and evidence.
482
483Worlds should represent branchable runtime state.
484
485KV state should represent inference state.
486
487J-Space should represent candidate/evaluation/search state.
488
489They should reference one another by stable IDs, not collapse into one database.
490
491---
492
493# 3. Current AIEN Project: What Exists Today
494
495This section distinguishes current implementation from the target architecture.
496
497## 3.1 `aien-sovereign-core`
498
499Current workspace members include:
500
501- `aien-cli`
502- `spark-cockpit-rs`
503- `cortex-rs`
504- `spark-hive`
505- `spark-supervisor`
506- `spark-discord-hub`
507- `spark-debugger`
508- `spark-harness`
509- `spark-dream`
510- `spark-adapters`
511- `spark-crumbs`
512- `spark-inquisitor`
513- `spark-max-cabi`
514- `spark-max-rs`
515- `cortex-encoder-rs`
516- `spark-mail-rs`
517- `spark-harvester`
518- `spark-aegis`
519- `aien-inference-abi`
520- `aien-kv-cache`
521- `aien-scheduler`
522- `aien-security`
523- `aien-platform`
524- `aien-platform-linux`
525- `aien-runtime`
526- `rad-id-sync`
527- `aien-inference-protocol`
528- `aien-inference-runtime`
529
530The current public `main` has already connected native chat to the runtime socket and connected the native runtime to scheduler/KV/streaming paths.
531
532### Keep
533
534`aien-sovereign-core` should remain the **canonical composition root** and product repo.
535
536### Change
537
538It should stop containing hardware-specific assumptions at core interfaces. Hardware-specific code should become an accelerator implementation behind a portable ABI.
539
540---
541
542## 3.2 Native inference runtime
543
544### Already implemented
545
546The runtime now has:
547
548- prompt submission,
549- completion sinks,
550- scheduler integration,
551- branchable sequences,
552- shared KV prefix state,
553- native transformer path,
554- token streaming,
555- physical block reclamation,
556- hardware execution tests.
557
558### Current gap
559
560The visible inference ABI still uses a production tensor shape centered around `Vec<f32>` and an `&[f32]` backend interface.
561
562That is unsuitable for large quantized models because BF16/F16 weights are expanded into FP32.
563
564### Target
565
566Replace the weight ABI with typed storage views and a compiled Model Capsule.
567
568---
569
570## 3.3 Cortex
571
572Cortex already contains:
573
574- logical spaces,
575- entities,
576- claims,
577- session/event ledgers,
578- evidence relationships,
579- summaries/hypotheses,
580- storage concurrency,
581- provenance-related data.
582
583### Keep
584
585Cortex remains the durable memory/knowledge layer.
586
587### Change
588
589Cortex should not become:
590
591- the task scheduler,
592- World state,
593- J-Space,
594- or the tool registry.
595
596It should receive structured results from those systems.
597
598---
599
600## 3.4 AEGIS
601
602AEGIS already contains:
603
604- deterministic pre-dispatch checks,
605- probe-policy evaluation,
606- workspace containment,
607- tool/skill gating,
608- a `SkillRegistry`,
609- vault resolution.
610
611### Current architectural problem
612
613`SkillRegistry` currently mixes tools and skills.
614
615Built-ins such as `read_file`, `write_file`, `bash_eval`, `git_status`, and `cortex_recall` are atomic tools, not high-level skills.
616
617Its current handler form is effectively local-process execution:
618
619```rust
620Arc<dyn Fn(serde_json::Value) -> Result<String, String> + Send + Sync>
621```
622
623That does not naturally support Fabric placement.
624
625### Target
626
627Move definitions into a Capability Graph. AEGIS verifies calls against capability contracts but does not own routing or placement.
628
629---
630
631## 3.5 MCP
632
633### Already implemented
634
635AIEN already has at least two hand-written Rust MCP servers:
636
6371. `spark-debugger`
6382. `aien-harness`
639
640Both implement stdio JSON-RPC and expose `initialize`, `tools/list`, and `tools/call`.
641
642`spark-debugger` advertises protocol version `2024-11-05`.
643
644### Not yet implemented
645
646There is no evidence of a single canonical:
647
648- MCP client,
649- MCP broker,
650- remote server registry,
651- current-spec MCP implementation,
652- OAuth broker,
653- Fabric-aware MCP placement,
654- Capability Graph integration,
655- unified provenance wrapper.
656
657### Target
658
659Create one `aien-mcp` subsystem using the official Rust `rmcp` SDK.
660
661---
662
663## 3.6 Vault/secrets
664
665AEGIS already has `VaultResolver` and prefers:
666
667```text
668atlas-vault get <KEY>
669```
670
671### Gap
672
673It currently falls back to environment variables.
674
675That means “zero plaintext secrets” is a policy goal, but not yet a universally enforced runtime property.
676
677### Target
678
679Production mode must be `VaultOnly`.
680
681Environment fallback should exist only in explicit development/test mode.
682
683---
684
685## 3.7 Provenance
686
687`aien-protocols` already contains:
688
689- SHA-256 digest helpers,
690- provenance types,
691- P-256 signing,
692- evaluation receipts,
693- software signers,
694- TPM-oriented signers,
695- Merkle roots,
696- canary rollback/evaluation receipts.
697
698### Gap
699
700The World lifecycle is not yet the canonical signed provenance object for every external effect.
701
702### Target
703
704Use the existing protocol package to create signed World Commit envelopes rather than inventing another receipt system.
705
706---
707
708## 3.8 RSI
709
710RSI already contains:
711
712- proposal generation,
713- candidate evaluation,
714- judge process,
715- signed evaluation receipts,
716- canary safety envelope,
717- rollback,
718- promotion gate.
719
720### Target
721
722RSI remains **out of the hot runtime path**.
723
724It should optimize:
725
726- kernel plans,
727- scheduling heuristics,
728- skill routing,
729- model placement,
730- tool selection,
731- cache policies,
732
733but never mutate live execution without signed evaluation and rollout gates.
734
735---
736
737## 3.9 Harness / Debugger / Inquisitor
738
739These are valuable but overlapping.
740
741### Harness
742
743Useful for:
744
745- deterministic workflow gates,
746- schema validation,
747- failure replay,
748- evaluation.
749
750### Debugger
751
752Useful for:
753
754- runtime diagnostics,
755- service checks,
756- security invariant audits,
757- MCP exposure.
758
759### Inquisitor
760
761Useful for:
762
763- constitutional/diff auditing,
764- evaluator integration,
765- canary checks.
766
767### Target
768
769Do not merge their semantics into one giant crate.
770
771Instead, expose all three as **evaluators/tools through the Capability Graph**.
772
773---
774
775# 4. Target Repository/Crate Topology
776
777The following is the recommended long-term structure.
778
779```text
780aien-sovereign-core/
781└── crates/
782 ├── aien-runtime
783 ├── aien-control
784 ├── aien-protocols
785 ├── aien-model
786 ├── aien-inference
787 ├── aien-accelerator
788 ├── aien-kv
789 ├── aien-sequence
790 ├── aien-world
791 ├── aien-jspace
792 ├── aien-capability
793 ├── aien-skill-router
794 ├── aien-tool-runtime
795 ├── aien-mcp
796 ├── aien-effect-broker
797 ├── aien-policy
798 ├── aien-vault
799 ├── aien-fabric
800 ├── aien-node
801 ├── aien-provenance
802 ├── aien-observability
803 └── aien-cli
804```
805
806Satellite repos can continue to exist for focused distribution, but canonical source should live in the composition root or be generated from it.
807
808---
809
810# 5. The Complete Runtime Flow
811
812## 5.1 Normal conversational turn
813
814```mermaid
815sequenceDiagram
816 participant User
817 participant CLI as AIEN Control
818 participant Runtime
819 participant Router as Model Router
820 participant Inference
821 participant Cortex
822 participant World
823
824 User->>CLI: message
825 CLI->>Runtime: StreamTurn
826 Runtime->>Cortex: retrieve relevant memory
827 Cortex-->>Runtime: evidence/context refs
828 Runtime->>Router: choose model + Machine
829 Router->>Inference: submit prompt
830 Inference-->>Runtime: token stream
831 Runtime->>World: record logical turn
832 Runtime-->>CLI: token deltas
833 CLI-->>User: response
834```
835
836---
837
838## 5.2 Skill/tool turn
839
840```mermaid
841sequenceDiagram
842 participant Model
843 participant J as J-Space
844 participant SR as Skill Router
845 participant CG as Capability Graph
846 participant F as Fabric
847 participant A as AEGIS
848 participant T as Tool Runtime
849 participant W as World
850
851 Model->>J: objective / proposed action
852 J->>SR: request procedure
853 SR->>CG: retrieve relevant skills
854 CG-->>SR: candidates
855 SR-->>J: top candidates
856 J->>CG: resolve required tools
857 CG->>F: find providers
858 F-->>CG: eligible Machines
859 J->>A: authorize planned call
860 A-->>J: allow/deny
861 J->>T: execute authorized call
862 T-->>J: ToolResult
863 J->>W: commit branch result
864```
865
866---
867
868## 5.3 External effect turn
869
870```mermaid
871sequenceDiagram
872 participant Agent
873 participant J as J-Space
874 participant A as AEGIS
875 participant B as Effect Broker
876 participant E as External System
877 participant P as Provenance
878 participant W as World
879
880 Agent->>J: propose external action
881 J->>A: EffectIntent
882 A-->>J: AuthorizedEffect
883 J->>B: AuthorizedEffect
884 B->>E: perform action
885 E-->>B: external result
886 B->>P: create receipt digest
887 P-->>B: signed receipt
888 B->>W: finalize World commit
889```
890
891---
892
893# 6. Universal Machine Fabric
894
895## 6.1 Concept
896
897Every physical computer runs:
898
899```text
900aien-node
901```
902
903A node joins one Fabric and advertises:
904
905- CPU resources,
906- accelerator resources,
907- memory,
908- model cache,
909- tools,
910- skill implementations,
911- operating-system capabilities,
912- network quality,
913- current load,
914- thermal/power state.
915
916Machines are generic logical identities:
917
918```text
919Machine 1
920Machine 2
921Machine 3
922Machine 4
923...
924```
925
926Example:
927
928```text
929Machine 1
930 CPU architecture: arm64
931 accelerator: GPU
932 unified memory: true
933 memory: 128 GiB
934 cached models: A, B
935
936Machine 2
937 CPU architecture: arm64
938 accelerator: GPU
939 memory: 48 GiB
940 cached models: B, C
941
942Machine 3
943 CPU architecture: x86_64
944 accelerator: none
945 memory: 64 GiB
946 tools: build, git, database
947
948Machine 4
949 CPU architecture: arm64
950 accelerator: GPU
951 tools: platform-specific-build
952```
953
954No higher layer should need to know product names.
955
956---
957
958## 6.2 Node capability structure
959
960```rust
961pub struct NodeAdvertisement {
962 pub machine: MachineId,
963 pub identity: WorkloadIdentity,
964 pub hardware: HardwareCapabilities,
965 pub accelerators: Vec<AcceleratorCaps>,
966 pub tools: Vec<ToolProvider>,
967 pub skills: Vec<SkillProvider>,
968 pub models: Vec<ModelDigest>,
969 pub resources: ResourceState,
970 pub network: NetworkState,
971}
972```
973
974---
975
976## 6.3 Transport
977
978Recommended initial transport:
979
980- QUIC
981- Rust `quinn`
982- TLS 1.3
983- mutually authenticated node identity
984- multiplexed control/data streams
985- optional datagrams for telemetry/heartbeats.
986
987Why QUIC:
988
989- encrypted by default,
990- stream multiplexing,
991- no TCP head-of-line blocking across independent streams,
992- portable across Linux/macOS/Windows,
993- pure Rust implementation available.
994
995For LAN discovery:
996
997- mDNS/DNS-SD.
998
999For more advanced direct peer connectivity later:
1000
1001- Iroh or libp2p concepts can be adopted selectively.
1002
1003Do not begin with a complicated WAN peer-to-peer overlay.
1004
1005---
1006
1007## 6.4 Network topology model
1008
1009```rust
1010pub struct FabricLink {
1011 pub from: MachineId,
1012 pub to: MachineId,
1013 pub latency_us: u64,
1014 pub jitter_us: u64,
1015 pub bandwidth_bps: u64,
1016 pub loss_ppm: u32,
1017 pub transport: TransportClass,
1018}
1019```
1020
1021The scheduler should maintain a weighted graph.
1022
1023```mermaid
1024graph LR
1025 M1[Machine 1] -- "low latency / high bandwidth" --> M2[Machine 2]
1026 M2 -- "medium latency" --> M3[Machine 3]
1027 M1 -- "high latency" --> M4[Machine 4]
1028 M3 -- "medium bandwidth" --> M4
1029```
1030
1031---
1032
1033## 6.5 Preferred distributed work granularity
1034
1035### Best over normal LAN/Wi-Fi
1036
1037- independent J-Space branches,
1038- tool execution,
1039- verifier work,
1040- speculative candidates,
1041- embeddings,
1042- compilation/tests,
1043- document processing,
1044- model replicas.
1045
1046### Use only on very fast interconnects
1047
1048- tensor parallelism,
1049- layer pipeline parallelism,
1050- fine-grained activation transfer.
1051
1052This is crucial.
1053
1054A slow Machine can help the Fabric if it receives coarse work.
1055
1056It can hurt the Fabric if every token depends on it.
1057
1058---
1059
1060# 7. Portable Accelerator Architecture: No CUDA Dependency
1061
1062## 7.1 Requirement
1063
1064AIEN core must not contain a mandatory CUDA dependency.
1065
1066NVIDIA hardware may use NVIDIA drivers under a portable runtime, but AIEN's source/runtime contracts should not be CUDA-shaped.
1067
1068---
1069
1070## 7.2 Target interface
1071
1072```rust
1073pub trait Accelerator: Send + Sync {
1074 fn capabilities(&self) -> DeviceCapabilities;
1075
1076 fn load_model(
1077 &mut self,
1078 capsule: &ModelCapsule,
1079 ) -> Result<ModelHandle>;
1080
1081 fn submit(
1082 &mut self,
1083 plan: &ExecutionPlan,
1084 ) -> Result<ExecutionFence>;
1085
1086 fn fork_kv(
1087 &mut self,
1088 parent: SequenceId,
1089 child: SequenceId,
1090 ) -> Result<()>;
1091
1092 fn reclaim(
1093 &mut self,
1094 sequence: SequenceId,
1095 ) -> Result<()>;
1096}
1097```
1098
1099---
1100
1101## 7.3 Backend strategy
1102
1103### Tier 1: optimized CPU
1104
1105Always available.
1106
1107- x86-64 SIMD
1108- arm64 SIMD
1109- multithreaded
1110- quantized kernels
1111
1112### Tier 2: Mojo accelerator
1113
1114Primary portable accelerator path where supported.
1115
1116Target:
1117
1118- NVIDIA GPU
1119- AMD GPU
1120- Apple GPU
1121
1122### Tier 3: broad GPU fallback later
1123
1124If needed, investigate IREE/Vulkan for hardware not covered well by Mojo.
1125
1126IREE's Vulkan deployment supports multiple GPU vendors and operating systems, but should be treated as an optional portability layer, not another mandatory runtime.
1127
1128---
1129
1130## 7.4 Do not expose vendor-specific APIs to the scheduler
1131
1132Bad:
1133
1134```rust
1135if gpu.is_blackwell() { ... }
1136```
1137
1138Good:
1139
1140```rust
1141if caps.fp4 && plan.supports_fp4() { ... }
1142else if caps.bf16 { ... }
1143else { ... }
1144```
1145
1146---
1147
1148# 8. Model Capsules
1149
1150## 8.1 Why
1151
1152The runtime should not parse arbitrary model repositories and reshape thousands of tensors on every startup.
1153
1154Model installation should be a compile/pack phase.
1155
1156```text
1157source model
1158 ↓
1159aien model pack
1160 ↓
1161validated Model Capsule
1162 ↓
1163content-addressed chunks
1164 ↓
1165runtime-ready
1166```
1167
1168---
1169
1170## 8.2 Capsule contents
1171
1172```rust
1173pub struct ModelCapsuleManifest {
1174 pub model_digest: Digest32,
1175 pub architecture: ArchitectureId,
1176 pub tokenizer_digest: Digest32,
1177 pub template_digest: Digest32,
1178 pub config_digest: Digest32,
1179
1180 pub max_context: u32,
1181 pub tensor_layout: TensorLayoutVersion,
1182 pub quantization: QuantizationSpec,
1183
1184 pub shards: Vec<ShardRef>,
1185 pub required_kernels: Vec<KernelCapability>,
1186}
1187```
1188
1189---
1190
1191## 8.3 Distribution
1192
1193Model data should be split into content-addressed chunks.
1194
1195```text
1196Model A
1197├── chunk 000 -> digest
1198├── chunk 001 -> digest
1199├── chunk 002 -> digest
1200└── ...
1201```
1202
1203When Machine 3 joins:
1204
1205```text
1206Machine 3 already has 73% of Model A.
1207Transfer only missing chunks.
1208```
1209
1210Content-addressed transfer could initially be built over the same QUIC fabric.
1211
1212Later, `iroh-blobs`-style verified chunk streaming is useful prior art.
1213
1214---
1215
1216## 8.4 Persistent prompt roots
1217
1218Common AIEN system prompts should be tokenized and prefixed once.
1219
1220```text
1221model + tokenizer + chat template + system prompt + policy
1222 ↓
1223 PrefixRootId
1224```
1225
1226New sessions fork from the prefix root.
1227
1228This uses AIEN's branch-native KV architecture to avoid repeated prefill.
1229
1230---
1231
1232# 9. Sequence/KV Architecture
1233
1234## 9.1 Canonical state
1235
1236```text
1237SequenceId
1238 ├── token lineage
1239 ├── KV block table
1240 ├── parent sequence
1241 ├── model handle
1242 └── owning Machine
1243```
1244
1245A fork should:
1246
1247- copy metadata,
1248- increment block references,
1249- share physical prefix pages,
1250- perform copy-on-write only when divergence requires it.
1251
1252---
1253
1254## 9.2 Global vs local identity
1255
1256A Sequence ID may be globally known.
1257
1258The actual KV pages remain local to their owning Machine.
1259
1260```text
1261Sequence 981
1262owner = Machine 2
1263prefix = PrefixRoot 12
1264world = World 771
1265```
1266
1267If Machine 2 disappears, AIEN reconstructs from durable token lineage and model identity.
1268
1269Do not implement distributed shared memory for KV.
1270
1271---
1272
1273# 10. J-Space
1274
1275## 10.1 Definition
1276
1277J-Space is the **typed evaluation/search space over possible World transitions**.
1278
1279It is not:
1280
1281- a memory database,
1282- a replacement for WorldStore,
1283- a replacement for Cortex,
1284- an arbitrary graph database,
1285- a token-level tree that always runs.
1286
1287It exists when AIEN has multiple plausible choices and needs to compare them.
1288
1289---
1290
1291## 10.2 Core node
1292
1293```rust
1294pub struct JNode {
1295 pub id: JNodeId,
1296 pub parent: Option<JNodeId>,
1297
1298 pub world: WorldId,
1299 pub sequence: SequenceId,
1300 pub memory_view: MemoryViewId,
1301
1302 pub proposal: ProposalRef,
1303 pub score: ScoreVector,
1304 pub constraints: ConstraintState,
1305
1306 pub evidence_root: Digest32,
1307 pub evaluator_set: EvaluatorSetId,
1308 pub status: JNodeStatus,
1309}
1310```
1311
1312---
1313
1314## 10.3 Multi-objective score
1315
1316Do not collapse everything into one untraceable scalar.
1317
1318```rust
1319pub struct ScoreVector {
1320 pub task_quality: f32,
1321 pub verifier_confidence: f32,
1322 pub safety_margin: f32,
1323 pub latency_cost: f32,
1324 pub compute_cost: f32,
1325 pub memory_cost: f32,
1326 pub uncertainty: f32,
1327}
1328```
1329
1330Pareto filtering can remove dominated candidates before expensive judges run.
1331
1332---
1333
1334## 10.4 J-Space flow
1335
1336```mermaid
1337flowchart TD
1338 P[Parent State] --> A[Candidate A]
1339 P --> B[Candidate B]
1340 P --> C[Candidate C]
1341 P --> D[Candidate D]
1342
1343 A --> CF[Cheap Filters]
1344 B --> CF
1345 C --> CF
1346 D --> CF
1347
1348 CF --> PR[Prune Dominated / Invalid]
1349 PR --> V[Verifier Batch]
1350 V --> J[Judge]
1351 J --> W[Winner]
1352 W --> WC[World Commit]
1353```
1354
1355---
1356
1357## 10.5 Fabric-aware J-Space
1358
1359```mermaid
1360flowchart LR
1361 ROOT[J-Space Root] --> A[Branch A]
1362 ROOT --> B[Branch B]
1363 ROOT --> C[Branch C]
1364
1365 A --> M1[Machine 1]
1366 B --> M2[Machine 2]
1367 C --> M3[Machine 3]
1368
1369 M1 --> J[Judge]
1370 M2 --> J
1371 M3 --> J
1372
1373 J --> WIN[Winning World Transition]
1374```
1375
1376This is a major potential differentiator.
1377
1378Most distributed inference systems focus on splitting one model computation.
1379
1380AIEN can distribute **reasoning alternatives and executable Worlds**.
1381
1382---
1383
1384# 11. Capability Graph
1385
1386## 11.1 Purpose
1387
1388The Capability Graph answers:
1389
1390> What can AIEN do, what does it require, where can it run, what effects can it cause, and what can satisfy this request?
1391
1392A flat hash map will not scale.
1393
1394---
1395
1396## 11.2 Canonical names
1397
1398Tools:
1399
1400```text
1401filesystem.read
1402filesystem.write
1403
1404process.execute
1405
1406git.status
1407git.diff
1408git.commit
1409git.push
1410
1411github.issue.read
1412github.pull_request.create
1413
1414mail.read
1415mail.send
1416
1417memory.cortex.search
1418memory.cortex.write
1419
1420database.query
1421
1422browser.navigate
1423browser.extract
1424
1425build.rust
1426test.rust
1427build.apple
1428```
1429
1430Skills:
1431
1432```text
1433software.debug.rust
1434software.implement.feature
1435software.review.pull_request
1436research.deep
1437communication.answer_email
1438operations.release
1439```
1440
1441---
1442
1443## 11.3 Skill descriptor
1444
1445```rust
1446pub struct SkillDescriptor {
1447 pub id: SkillId,
1448 pub name: CanonicalName,
1449 pub version: Version,
1450
1451 pub description: String,
1452 pub domain: DomainId,
1453 pub family: SkillFamilyId,
1454 pub tags: Vec<Tag>,
1455 pub intents: Vec<Intent>,
1456
1457 pub required_tools: Vec<ToolRequirement>,
1458 pub required_capabilities: CapabilitySet,
1459
1460 pub input_schema: SchemaId,
1461 pub output_schema: SchemaId,
1462
1463 pub potential_effects: EffectSet,
1464 pub cost_profile: CostProfile,
1465 pub examples: Vec<ExampleId>,
1466
1467 pub digest: Digest32,
1468}
1469```
1470
1471---
1472
1473## 11.4 Tool descriptor
1474
1475```rust
1476pub struct ToolDescriptor {
1477 pub id: ToolId,
1478 pub name: CanonicalName,
1479 pub version: Version,
1480
1481 pub input_schema: SchemaId,
1482 pub output_schema: SchemaId,
1483
1484 pub effects: EffectSet,
1485 pub requirements: ResourceRequirements,
1486
1487 pub deterministic: bool,
1488 pub retryable: bool,
1489 pub idempotency: IdempotencyClass,
1490}
1491```
1492
1493---
1494
1495# 12. Skill Router
1496
1497## 12.1 The routing problem
1498
1499If AIEN eventually has 10,000 capabilities, sending all of them into the model context is inefficient and harms tool selection.
1500
1501A 2026 paper on semantic MCP tool discovery reports strong results from retrieving only a few relevant tools instead of presenting the entire catalog, with large token savings and high retrieval hit rates.
1502
1503The principle is sound even if AIEN develops its own benchmark.
1504
1505---
1506
1507## 12.2 Progressive routing
1508
1509```mermaid
1510flowchart TD
1511 Q[Intent] --> L0[Level 0: exact alias / deterministic]
1512 L0 -->|unresolved| L1[Level 1: tags / lexical]
1513 L1 -->|ambiguous| L2[Level 2: semantic retrieval]
1514 L2 -->|ambiguous| L3[Level 3: small router model]
1515 L3 -->|complex| L4[Level 4: J-Space planning]
1516
1517 L0 --> C[Candidate Set]
1518 L1 --> C
1519 L2 --> C
1520 L3 --> C
1521 L4 --> C
1522
1523 C --> F[Constraint Filter]
1524 F --> T[3-10 relevant capabilities]
1525```
1526
1527Most requests should stop before the expensive levels.
1528
1529---
1530
1531## 12.3 Constraint filtering
1532
1533Before the model sees candidates, eliminate impossible choices:
1534
1535- unavailable Machine,
1536- missing operating-system capability,
1537- missing credential,
1538- denied policy,
1539- incompatible model,
1540- excessive memory,
1541- excessive latency,
1542- tool not installed,
1543- offline remote provider.
1544
1545---
1546
1547## 12.4 Historical routing feedback
1548
1549Cortex may store routing experience:
1550
1551```text
1552request class
1553selected skill
1554Machine placement
1555latency
1556success/failure
1557judge score
1558operator correction
1559```
1560
1561Cortex informs ranking.
1562
1563It does **not** become the authoritative capability registry.
1564
1565---
1566
1567# 13. Skill Packs
1568
1569Human operators need a manageable abstraction above individual tools.
1570
1571Example packs:
1572
1573```text
1574AIEN Base
1575├── filesystem
1576├── process
1577├── memory
1578└── network
1579
1580Developer Pack
1581├── git
1582├── repository hosting
1583├── compilation
1584├── testing
1585└── debugging
1586
1587Research Pack
1588├── web
1589├── papers
1590├── citations
1591└── synthesis
1592
1593Communication Pack
1594├── mail
1595├── calendar
1596└── messaging
1597
1598Platform Build Pack
1599├── native build tools
1600├── simulator
1601└── signing
1602```
1603
1604A Machine may advertise entire packs plus individual exceptions.
1605
1606---
1607
1608# 14. MCP Architecture
1609
1610## 14.1 What MCP is
1611
1612MCP is a protocol that lets AI clients communicate with servers exposing:
1613
1614- tools,
1615- resources,
1616- prompts,
1617- and related capabilities.
1618
1619It does not require Python or TypeScript.
1620
1621The official Rust MCP SDK (`rmcp`) is current, async, and supports both client and server use.
1622
1623---
1624
1625## 14.2 Current AIEN MCP state
1626
1627### Implemented
1628
1629`spark-debugger`:
1630- Rust
1631- stdio
1632- JSON-RPC
1633- initialize
1634- tools/list
1635- tools/call
1636
1637`aien-harness`:
1638- Rust
1639- stdio
1640- JSON-RPC
1641- initialize
1642- tools/list
1643- tools/call
1644
1645### Problem
1646
1647These are separate hand-maintained protocol implementations.
1648
1649---
1650
1651## 14.3 Target MCP subsystem
1652
1653Canonical source location:
1654
1655```text
1656aien-sovereign-core/crates/aien-mcp
1657```
1658
1659The existing hand-written MCP servers remain compatibility fixtures during migration; canonical protocol/client/broker behavior moves into this crate.
1660
1661```text
1662aien-mcp
1663├── client
1664├── server
1665├── broker
1666├── registry
1667├── stdio transport
1668├── streamable HTTP transport
1669├── auth
1670├── vault credential provider
1671├── AEGIS adapter
1672├── Capability Graph adapter
1673├── Fabric adapter
1674└── provenance adapter
1675```
1676
1677Use official `rmcp` rather than expanding manual JSON-RPC matching.
1678
1679---
1680
1681## 14.4 MCP is translated into AIEN capabilities
1682
1683```mermaid
1684flowchart LR
1685 S[MCP Server] --> MB[MCP Broker]
1686 MB --> AD[Capability Adapter]
1687 AD --> CG[Capability Graph]
1688 CG --> SR[Skill Router]
1689 SR --> JS[J-Space]
1690```
1691
1692The inverse direction allows AIEN-native tools to be exported as MCP when external clients need them.
1693
1694---
1695
1696# 15. Secret Architecture
1697
1698## 15.1 Model must never see raw credentials
1699
1700```mermaid
1701flowchart LR
1702 M[Model] --> TC[ToolCall]
1703 TC --> CR[CredentialRef]
1704 CR --> A[AEGIS]
1705 A --> B[Credential Broker]
1706 B --> V[Vault]
1707 V --> B
1708 B --> R[Authenticated Request]
1709```
1710
1711The model receives:
1712
1713```text
1714CredentialRef("service.operator")
1715```
1716
1717not:
1718
1719```text
1720actual-secret-value
1721```
1722
1723---
1724
1725## 15.2 Production vault policy
1726
1727```rust
1728pub enum SecretPolicy {
1729 VaultOnly,
1730 VaultThenEnvironmentForDevelopment,
1731}
1732```
1733
1734Production must reject implicit environment fallback.
1735
1736A third-party process that explicitly requires an environment variable may receive a **call-scoped child-only injection** from a `CredentialRef`, after AEGIS authorization and Fabric placement. This is a compatibility delivery mechanism, not a configuration source. Raw values must never be serialized into AIEN configuration, World state, J-Space, logs, Cortex, or provenance.
1737
1738---
1739
1740## 15.3 Network identity
1741
1742For Fabric identity, study and borrow from SPIFFE/SPIRE:
1743
1744- workload identity,
1745- short-lived credentials,
1746- runtime attestation,
1747- mTLS.
1748
1749AIEN does not necessarily need to deploy full SPIRE initially.
1750
1751A small AIEN-native identity layer can use the same principles:
1752
1753```text
1754Machine identity key
1755 ↓
1756node enrollment
1757 ↓
1758short-lived session certificate
1759 ↓
1760mTLS/QUIC peer authentication
1761```
1762
1763---
1764
1765# 16. AEGIS Authorization Architecture
1766
1767AEGIS should evolve from pattern checks into a typed authorization plane.
1768
1769Recommended combination:
1770
17711. deterministic hard invariants,
17722. Cedar-style declarative policy,
17733. optional semantic/probe evaluation,
17744. operator approval for high-risk effects.
1775
1776Cedar is especially attractive because:
1777
1778- it is written in Rust,
1779- separates policy from application logic,
1780- supports principal/action/resource/context decisions,
1781- is designed for fast authorization.
1782
1783Example conceptual request:
1784
1785```text
1786principal = Agent::"researcher-17"
1787action = Tool::"mail.send"
1788resource = RecipientDomain::"external"
1789context = {
1790 world_id,
1791 skill_id,
1792 jnode_id,
1793 operator_session,
1794 risk_score
1795}
1796```
1797
1798---
1799
1800# 17. Effect Broker
1801
1802## 17.1 Why a separate process
1803
1804If all external effects are available directly inside `aien-runtime`, a bug can bypass policy.
1805
1806The stronger design is:
1807
1808```text
1809aien-runtime
1810 no unrestricted external effects
1811 │
1812 │ authorized typed UDS/QUIC
1813 ▼
1814aien-effect-broker
1815 │
1816 ▼
1817external systems
1818```
1819
1820The broker is small enough to audit aggressively.
1821
1822---
1823
1824## 17.2 Effect types
1825
1826```rust
1827pub enum ExternalEffect {
1828 SendMessage,
1829 PublishGit,
1830 Deploy,
1831 Purchase,
1832 DeleteRemoteResource,
1833 ModifyExternalRecord,
1834}
1835```
1836
1837Local reversible operations can remain World-local.
1838
1839---
1840
1841## 17.3 Typestate
1842
1843```text
1844EffectIntent<T>
1845 ↓
1846CheckedEffect<T>
1847 ↓
1848AuthorizedEffect<T>
1849 ↓
1850ExecutedEffect<T>
1851 ↓
1852CommittedEffect<T>
1853```
1854
1855An SMTP or Git-push implementation should accept only `AuthorizedEffect<T>`.
1856
1857---
1858
1859# 18. World Architecture
1860
1861## 18.1 Purpose
1862
1863World = branchable, transactional execution state.
1864
1865A World references:
1866
1867- object root,
1868- filesystem root,
1869- token root,
1870- memory view,
1871- capability set,
1872- effect intents,
1873- lineage.
1874
1875---
1876
1877## 18.2 Target World commit
1878
1879```rust
1880pub struct WorldCommit {
1881 pub world: WorldId,
1882 pub parent: Option<WorldCommitId>,
1883 pub sequence_number: u64,
1884
1885 pub object_root: Digest32,
1886 pub filesystem_root: Digest32,
1887 pub token_root: Digest32,
1888 pub memory_root: Digest32,
1889
1890 pub effects_root: Digest32,
1891 pub evidence_root: Digest32,
1892
1893 pub model_digest: Digest32,
1894 pub tokenizer_digest: Digest32,
1895 pub policy_digest: Digest32,
1896 pub runtime_build_digest: Digest32,
1897
1898 pub jspace_decision: Option<JDecisionId>,
1899
1900 pub signer: SignerIdentity,
1901 pub signature: Signature,
1902}
1903```
1904
1905---
1906
1907# 19. Signed Provenance
1908
1909## 19.1 Reuse existing AIEN protocol code
1910
1911AIEN already has:
1912
1913- P-256 signers,
1914- TPM signer concepts,
1915- evaluation receipts,
1916- Merkle roots.
1917
1918Do not create a second unrelated format.
1919
1920---
1921
1922## 19.2 DSSE/in-toto-compatible envelope
1923
1924Borrow the DSSE principle:
1925
1926- authenticate payload type,
1927- authenticate payload bytes,
1928- avoid fragile canonicalization assumptions,
1929- allow multiple signatures.
1930
1931This improves interoperability with broader provenance tooling.
1932
1933---
1934
1935## 19.3 Do not hardware-sign every event
1936
1937Use:
1938
19391. short-lived in-memory session signer,
19402. Merkle-batched commits,
19413. periodic hardware-rooted checkpoint.
1942
1943```mermaid
1944flowchart TD
1945 R1[Receipt 1] --> M[Merkle Root]
1946 R2[Receipt 2] --> M
1947 R3[Receipt 3] --> M
1948 RN[Receipt N] --> M
1949 M --> H[Hardware Anchor]
1950```
1951
1952This avoids making hardware signing the latency bottleneck.
1953
1954---
1955
1956# 20. Cortex Memory Integration
1957
1958## 20.1 Memory planes
1959
1960Recommended memory layers:
1961
1962### Working memory
1963Current sequence / World-local state.
1964
1965### Episodic memory
1966Sessions, actions, outcomes, failures.
1967
1968### Semantic memory
1969Entities, claims, stable facts.
1970
1971### Procedural memory
1972Skill routing outcomes, successful plans, reusable tactics.
1973
1974### Provenance memory
1975Evidence and signed receipts.
1976
1977---
1978
1979## 20.2 Memory flow
1980
1981```mermaid
1982flowchart LR
1983 E[Execution] --> EV[Events]
1984 EV --> C[Cortex Ingress]
1985 C --> EP[Episodic]
1986 C --> SM[Semantic]
1987 C --> PM[Procedural]
1988 C --> PR[Provenance]
1989
1990 EP --> R[Recall]
1991 SM --> R
1992 PM --> R
1993 PR --> R
1994
1995 R --> RT[Runtime Context]
1996```
1997
1998---
1999
2000# 21. Durable Workflows
2001
2002Some AIEN tasks may last minutes, hours, or days.
2003
2004Temporal demonstrates the value of durable execution that resumes after process/network failure.
2005
2006AIEN does not have to embed Temporal itself, especially if the objective is a compact local Rust stack.
2007
2008But it should adopt the same key pattern:
2009
2010```text
2011workflow state
2012+ deterministic transition
2013+ append-only event log
2014+ replay
2015+ idempotent activity
2016```
2017
2018The Harness already moves in this direction.
2019
2020Recommended new core:
2021
2022```rust
2023pub trait DurableWorkflow {
2024 type State;
2025 type Event;
2026
2027 fn apply(state: &mut Self::State, event: &Self::Event);
2028}
2029```
2030
2031All irreversible activities emit receipts and can be re-associated during replay.
2032
2033---
2034
2035# 22. Plugin and Third-Party Tool Isolation
2036
2037Native Rust tools are fastest, but third-party extensions cannot all be trusted.
2038
2039Use Wasmtime/WASI Component Model as an optional sandboxed plugin class.
2040
2041Why:
2042
2043- portable,
2044- cross-language,
2045- explicit imports/exports,
2046- restricted filesystem/network capabilities,
2047- embeddable in Rust.
2048
2049Architecture:
2050
2051```text
2052Tool package
2053 ↓
2054trusted native?
2055 ├── yes -> NativeToolExecutor
2056 └── no -> WASM Component Executor
2057 ↓
2058 capability grants
2059```
2060
2061MCP tools and process tools should also execute under explicit capability restrictions.
2062
2063---
2064
2065# 23. Observability
2066
2067Adopt OpenTelemetry concepts rather than inventing unrelated metric names.
2068
2069AIEN should emit:
2070
2071- traces,
2072- metrics,
2073- structured events,
2074- profiling data.
2075
2076Key dimensions:
2077
2078```text
2079machine.id
2080world.id
2081sequence.id
2082jspace.id
2083jnode.id
2084skill.id
2085tool.id
2086model.digest
2087accelerator.class
2088effect.class
2089policy.decision
2090```
2091
2092Never record sensitive prompt/tool content by default.
2093
2094Content logging must be opt-in.
2095
2096---
2097
2098# 24. RSI Integration
2099
2100RSI should consume telemetry and benchmark evidence.
2101
2102```mermaid
2103flowchart LR
2104 T[Telemetry] --> RSI[RSI]
2105 B[Benchmarks] --> RSI
2106 C[Cortex Lessons] --> RSI
2107
2108 RSI --> H[Hypothesis]
2109 H --> CA[Candidate Artifact]
2110 CA --> E[Evaluators]
2111 E --> CR[Canary]
2112 CR -->|pass| P[Promote]
2113 CR -->|fail| RB[Rollback]
2114```
2115
2116RSI may optimize:
2117
2118- skill retrieval,
2119- scheduling,
2120- placement,
2121- batch widths,
2122- J-Space pruning thresholds,
2123- kernel plans,
2124- model quantization choice,
2125- cache policy.
2126
2127---
2128
2129# 25. Market Gap Analysis
2130
2131The market contains strong products for individual layers, but the combination AIEN is targeting remains unusual.
2132
2133## Gap 1: Universal heterogeneous AI fabric
2134
2135### Existing approaches
2136
2137- Exo: automatic device discovery and heterogeneous local model partitioning.
2138- llama.cpp RPC: exposes remote compute devices and distributes model/KV state.
2139- MLX distributed: serious multi-machine communication including low-latency interconnects.
2140- Ray/Dask: mature heterogeneous resource scheduling.
2141
2142### What they solve
2143
2144They prove that:
2145
2146- heterogeneous local clusters are practical,
2147- resource-aware scheduling works,
2148- remote accelerators can contribute,
2149- topology matters.
2150
2151### Remaining market gap
2152
2153A local fabric that combines:
2154
2155- inference,
2156- agent branches,
2157- tools,
2158- skills,
2159- state Worlds,
2160- safety policy,
2161- provenance,
2162- memory,
2163- and self-improvement
2164
2165under one typed runtime.
2166
2167### AIEN implementation
2168
2169Build `aien-fabric` in Rust.
2170
2171Start with coarse-grained work:
2172
2173- J-Space branches,
2174- tool execution,
2175- model replicas.
2176
2177Add tensor/model sharding only after topology metrics prove it is worthwhile.
2178
2179---
2180
2181## Gap 2: Skill routing at very large capability counts
2182
2183### Existing approaches
2184
2185Agent frameworks typically expose tool lists and workflows.
2186
2187MCP standardizes tool discovery.
2188
2189Research now demonstrates semantic retrieval for large MCP tool catalogs.
2190
2191### Remaining gap
2192
2193A router that combines:
2194
2195- semantic relevance,
2196- hard capability requirements,
2197- current Machine availability,
2198- AEGIS policy,
2199- secrets availability,
2200- historical success,
2201- model requirements,
2202- latency and cost.
2203
2204### AIEN implementation
2205
2206Build `aien-capability` + `aien-skill-router`.
2207
2208Use multi-stage routing:
2209
22101. deterministic alias,
22112. metadata,
22123. lexical,
22134. embedding,
22145. small router model,
22156. J-Space.
2216
2217This is a real differentiator because routing is tied to execution reality, not just textual similarity.
2218
2219---
2220
2221## Gap 3: Secure MCP as a capability adapter
2222
2223### Existing approaches
2224
2225The official Rust MCP SDK supports current MCP client/server behavior and authentication features.
2226
2227### AIEN current state
2228
2229Two hand-written Rust MCP servers already exist.
2230
2231### Remaining gap
2232
2233A single broker where:
2234
2235- MCP tools become AIEN capabilities,
2236- credentials remain vault handles,
2237- AEGIS gates calls,
2238- Fabric can place calls,
2239- World/provenance wraps results.
2240
2241### AIEN implementation
2242
2243Build `aien-mcp` around `rmcp`.
2244
2245Retire duplicate protocol loops after migration.
2246
2247---
2248
2249## Gap 4: Portable accelerator runtime without CUDA-shaped architecture
2250
2251### Existing approaches
2252
2253- Mojo provides portable accelerator programming across supported GPU families.
2254- IREE/Vulkan provides broad vendor/OS coverage.
2255- llama.cpp/ggml supports many hardware backends.
2256
2257### Remaining gap
2258
2259A branch-native agent runtime whose core scheduler/KV/World logic is hardware-independent while high-performance kernels remain portable.
2260
2261### AIEN implementation
2262
2263Rust control plane + Mojo kernels + optimized CPU.
2264
2265IREE/Vulkan can be evaluated later for unsupported accelerator classes.
2266
2267No mandatory CUDA build dependency.
2268
2269---
2270
2271## Gap 5: Branch-native test-time search with executable state
2272
2273### Existing approaches
2274
2275Research on test-time scaling shows value from:
2276
2277- candidate sampling,
2278- verification,
2279- search over partial states,
2280- inference-time verification.
2281
2282Inference servers already implement prefix reuse.
2283
2284### Remaining gap
2285
2286Most systems treat candidates as text completions.
2287
2288AIEN can treat them as:
2289
2290```text
2291Sequence
2292+ World
2293+ memory view
2294+ tool plan
2295+ evidence
2296+ policy state
2297```
2298
2299### AIEN implementation
2300
2301Build J-Space as first-class typed state.
2302
2303This may be AIEN's strongest technical differentiator.
2304
2305---
2306
2307## Gap 6: Effect-aware agent transactions
2308
2309### Existing approaches
2310
2311Agent SDKs increasingly include sandboxes and tool controls.
2312
2313Authorization engines such as Cedar provide policy decisions.
2314
2315### Remaining gap
2316
2317A local agent runtime in which:
2318
2319- speculative branches do not leak effects,
2320- external actions require typed authorization,
2321- the effect boundary is non-bypassable,
2322- the resulting World commit is signed.
2323
2324### AIEN implementation
2325
2326`aien-effect-broker` + AEGIS + World commits.
2327
2328---
2329
2330## Gap 7: Signed, branch-aware agent provenance
2331
2332### Existing approaches
2333
2334in-toto/DSSE provides strong supply-chain attestation patterns.
2335
2336### Remaining gap
2337
2338Runtime provenance spanning:
2339
2340```text
2341model
2342→ reasoning branch
2343→ tools
2344→ external effect
2345→ World transition
2346→ memory
2347```
2348
2349### AIEN implementation
2350
2351Extend current `aien-provenance` and evaluation receipts into World Commit attestations.
2352
2353---
2354
2355## Gap 8: Local self-improvement that is actually gated
2356
2357### Existing approaches
2358
2359Auto-tuning and agent optimization exist, but safe autonomous promotion remains difficult.
2360
2361### AIEN current advantage
2362
2363RSI already has:
2364
2365- judge,
2366- canary,
2367- rollback,
2368- signed evaluation.
2369
2370### Remaining gap
2371
2372Connect it to the full runtime telemetry and signed World evidence without letting RSI mutate the hot path directly.
2373
2374---
2375
2376# 26. Competitive Positioning
2377
2378AIEN should not try to win by saying:
2379
2380> another agent framework
2381
2382or:
2383
2384> another inference server
2385
2386or:
2387
2388> another MCP host
2389
2390Those categories are crowded.
2391
2392A more defensible technical category is:
2393
2394> **A universal branch-native AI runtime that turns multiple Machines into one capability-aware local AI system.**
2395
2396The differentiation stack is:
2397
2398```text
2399heterogeneous Fabric
2400 +
2401portable inference
2402 +
2403branch-native KV
2404 +
2405World transactions
2406 +
2407J-Space search
2408 +
2409Capability Graph
2410 +
2411skill routing
2412 +
2413MCP compatibility
2414 +
2415AEGIS effect safety
2416 +
2417signed provenance
2418 +
2419Cortex memory
2420 +
2421RSI optimization
2422```
2423
2424The combination matters more than any individual feature.
2425
2426---
2427
2428# 27. Proposed Core Types
2429
2430```rust
2431pub struct MachineId(pub [u8; 16]);
2432pub struct WorldId(pub u64);
2433pub struct SequenceId(pub u64);
2434pub struct JSpaceId(pub u64);
2435pub struct JNodeId(pub u64);
2436pub struct SkillId(pub Digest32);
2437pub struct ToolId(pub Digest32);
2438pub struct ModelDigest(pub Digest32);
2439pub struct ReceiptId(pub Digest32);
2440```
2441
2442Everything crossing process or Machine boundaries should use stable typed IDs.
2443
2444---
2445
2446# 28. Suggested Crate Responsibilities
2447
2448## `aien-capability`
2449
2450Owns:
2451
2452- tool/skill descriptors,
2453- capability IDs,
2454- schemas,
2455- requirements,
2456- effect classes.
2457
2458Does not execute.
2459
2460---
2461
2462## `aien-skill-router`
2463
2464Owns:
2465
2466- indexes,
2467- retrieval,
2468- ranking,
2469- constraint filtering,
2470- routing telemetry.
2471
2472Does not perform effects.
2473
2474---
2475
2476## `aien-tool-runtime`
2477
2478Owns:
2479
2480- native Rust executor,
2481- WASM executor,
2482- process adapter,
2483- HTTP adapter.
2484
2485Does not authorize.
2486
2487---
2488
2489## `aien-mcp`
2490
2491Owns:
2492
2493- MCP client/server,
2494- transport,
2495- schema translation,
2496- auth negotiation,
2497- broker.
2498
2499Does not own secrets.
2500
2501---
2502
2503## `aien-vault`
2504
2505Owns:
2506
2507- secret references,
2508- vault access,
2509- short-lived secret leases,
2510- redaction.
2511
2512Does not expose arbitrary secret strings to models.
2513
2514---
2515
2516## `aien-policy`
2517
2518Owns:
2519
2520- deterministic invariants,
2521- Cedar policies,
2522- probe integration,
2523- approval requirements.
2524
2525---
2526
2527## `aien-effect-broker`
2528
2529Owns:
2530
2531- irreversible external side effects.
2532
2533Small, heavily audited process.
2534
2535---
2536
2537## `aien-fabric`
2538
2539Owns:
2540
2541- membership,
2542- node identity,
2543- topology,
2544- capability advertisement,
2545- task placement,
2546- leases,
2547- failover.
2548
2549---
2550
2551## `aien-jspace`
2552
2553Owns:
2554
2555- candidate branches,
2556- evaluation,
2557- Pareto pruning,
2558- judges,
2559- branch lifecycle.
2560
2561---
2562
2563## `aien-world`
2564
2565Owns:
2566
2567- branchable transactional state,
2568- commits,
2569- lineage,
2570- rollback roots.
2571
2572---
2573
2574# 29. Detailed Implementation Plan
2575
2576## Phase 0: Establish invariants
2577
2578Before new features:
2579
25801. Declare hardware-neutral interfaces.
25812. Declare Tool vs Skill semantics.
25823. Declare World vs Cortex vs J-Space separation.
25834. Declare vault-only production secrets.
25845. Declare that external effects cannot bypass the broker.
25856. Declare stable protocol types.
2586
2587Acceptance:
2588
2589- architecture tests compile without any vendor-specific type in core scheduler APIs.
2590
2591---
2592
2593## Phase 1: Capability Graph
2594
2595Build:
2596
2597```text
2598aien-capability
2599aien-skill-router
2600```
2601
2602Migrate AEGIS `SkillRegistry` definitions into Tool descriptors.
2603
2604Keep adapters so existing calls continue working.
2605
2606Acceptance:
2607
2608- 1,000 synthetic tools indexed.
2609- routing returns top 5.
2610- impossible capabilities filtered before model use.
2611- tool definitions never all enter the context.
2612
2613---
2614
2615## Phase 2: Canonical MCP broker
2616
2617Build `aien-mcp` with `rmcp`.
2618
2619Import existing:
2620
2621- debugger MCP tools,
2622- harness MCP tools.
2623
2624Acceptance:
2625
2626- stdio server works.
2627- stdio client works.
2628- Streamable HTTP works.
2629- tools/resources/prompts map into Capability Graph.
2630- MCP server failure cannot crash runtime.
2631- credentials are references, not config secrets.
2632
2633---
2634
2635## Phase 3: Vault-only production mode
2636
2637Refactor:
2638
2639```rust
2640VaultResolver
2641```
2642
2643to explicit policy.
2644
2645Acceptance:
2646
2647- production test fails when secret exists only in environment.
2648- logs never contain resolved value.
2649- model/tool schemas never contain resolved value.
2650- secret lease expires/zeroizes where practical.
2651
2652---
2653
2654## Phase 4: Effect Broker
2655
2656Move mail first.
2657
2658Then Git publish.
2659
2660Add mock driver for golden-path tests.
2661
2662Acceptance:
2663
2664- runtime process cannot execute test external effect directly.
2665- denied action yields zero broker driver calls.
2666- allowed action yields one receipt.
2667- receipt becomes part of World commit.
2668
2669---
2670
2671## Phase 5: Signed World commits
2672
2673Extend `aien-provenance`.
2674
2675Acceptance:
2676
2677- every committed external effect has:
2678 - parent World,
2679 - effect root,
2680 - policy digest,
2681 - runtime build digest,
2682 - signer identity.
2683- verification detects tampering.
2684
2685---
2686
2687## Phase 6: Model Capsule + portable weight ABI
2688
2689Replace production `Vec<f32>` weight ownership.
2690
2691Build:
2692
2693- typed tensor views,
2694- quantized storage,
2695- mmap/chunk loading,
2696- capsule manifest.
2697
2698Acceptance:
2699
2700- large model does not expand all weights to FP32.
2701- model startup is deterministic and fingerprinted.
2702- same capsule works across at least CPU and one accelerator implementation.
2703
2704---
2705
2706## Phase 7: Portable accelerator
2707
2708Build/finish:
2709
2710- optimized CPU kernels,
2711- Mojo batch kernels,
2712- paged attention,
2713- quantized matmul,
2714- sampling.
2715
2716Retain old accelerator path only as comparison until parity/performance is proven.
2717
2718Acceptance:
2719
2720- no mandatory CUDA toolkit dependency.
2721- CPU path passes oracle tests.
2722- Mojo path passes parity.
2723- unsupported hardware fails clearly or uses CPU.
2724
2725---
2726
2727## Phase 8: `aien-node` + Fabric
2728
2729Build:
2730
2731- Machine identity,
2732- mDNS discovery,
2733- QUIC control transport,
2734- capability advertisement,
2735- topology probes,
2736- work leases.
2737
2738Acceptance:
2739
2740- Machine 2 can join Machine 1 automatically.
2741- Machine 2 disappears; work lease expires and reschedules.
2742- all control traffic is mutually authenticated.
2743
2744---
2745
2746## Phase 9: Distributed branch execution
2747
2748Before distributed tensor parallelism, dispatch J-Space branches.
2749
2750Acceptance:
2751
2752```text
2753Machine 1 creates 4 candidate branches.
2754Machine 2 executes branch 2.
2755Machine 3 executes branch 3.
2756All results return with signed evidence.
2757Judge chooses winner.
2758Non-winning Worlds are reclaimed.
2759```
2760
2761---
2762
2763## Phase 10: J-Space
2764
2765Build first version using meaningful decision boundaries, not token-by-token MCTS.
2766
2767Acceptance:
2768
2769- branch candidate state references World/Sequence IDs rather than cloning.
2770- cheap filters remove invalid branches.
2771- judge outcome is reproducible.
2772- effects cannot occur on speculative branches.
2773- winner can commit atomically.
2774
2775---
2776
2777## Phase 11: Content-addressed model distribution
2778
2779Chunk Model Capsules.
2780
2781Acceptance:
2782
2783- second Machine only downloads missing chunks.
2784- chunks verify by digest.
2785- corrupted chunk is rejected.
2786- model cache survives restart.
2787
2788---
2789
2790## Phase 12: Fine-grained distributed inference
2791
2792Only now investigate:
2793
2794- layer pipeline parallelism,
2795- tensor parallelism,
2796- speculative cross-Machine decode,
2797- RDMA.
2798
2799Enable only where measured topology predicts a gain.
2800
2801---
2802
2803# 30. Benchmark Plan
2804
2805AIEN needs metrics that measure the system it is actually trying to build.
2806
2807## Inference
2808
2809- prompt tokens/sec
2810- decode tokens/sec
2811- TTFT
2812- inter-token latency
2813- GPU/accelerator utilization
2814- memory amplification
2815- KV bytes copied
2816- prefix reuse ratio
2817
2818## J-Space
2819
2820- candidates/sec
2821- time-to-best-valid-answer
2822- branches explored
2823- branches pruned
2824- verifier latency
2825- winner quality
2826- KV sharing ratio
2827- memory per branch
2828
2829## Fabric
2830
2831- discovery time
2832- Machine join latency
2833- control RTT
2834- bandwidth
2835- failover latency
2836- work migration time
2837- model chunk reuse
2838- scheduler placement quality
2839
2840## Skills/tools
2841
2842- routing latency
2843- top-k hit rate
2844- tool schema token count
2845- task success rate
2846- wrong-tool rate
2847- policy-denial rate
2848
2849## Provenance/security
2850
2851- signing overhead
2852- verification overhead
2853- broker overhead
2854- policy latency
2855- bypass tests
2856- secret exposure tests
2857
2858---
2859
2860# 31. Golden Path
2861
2862The final release gate should prove:
2863
2864```mermaid
2865flowchart TD
2866 U[User request] --> SR[Skill Router]
2867 SR --> JS[J-Space]
2868 JS --> F[Fabric]
2869 F --> M[Selected Machine]
2870 M --> INF[Native Inference]
2871 INF --> TC[Tool Call]
2872 TC --> A[AEGIS]
2873 A --> EB[Effect Broker]
2874 EB --> W[World Commit]
2875 W --> P[Signed Provenance]
2876 P --> C[Cortex]
2877 C --> UO[Streamed User Output]
2878```
2879
2880The golden path must use:
2881
2882- real model,
2883- real tokenizer,
2884- real routing,
2885- real policy,
2886- real effect boundary,
2887- real receipt,
2888- real World commit,
2889- real Cortex recall/store,
2890- no simulated bypass assertions.
2891
2892---
2893
2894# 32. Failure Model
2895
2896AIEN must expect:
2897
2898- Machine departure,
2899- network partition,
2900- model unavailable,
2901- tool provider unavailable,
2902- MCP server crash,
2903- secret unavailable,
2904- policy denial,
2905- judge disagreement,
2906- stale World,
2907- duplicate operation,
2908- corrupted model chunk,
2909- accelerator fallback,
2910- verifier failure.
2911
2912Every subsystem must have explicit behavior for these cases.
2913
2914---
2915
2916# 33. Machine Failure Recovery
2917
2918A remote branch should be reconstructible from:
2919
2920```text
2921model digest
2922+ token lineage
2923+ World root
2924+ memory view
2925+ tool/evidence refs
2926```
2927
2928Do not require remote RAM contents to survive.
2929
2930Use leases:
2931
2932```rust
2933pub struct WorkLease {
2934 pub task: TaskId,
2935 pub machine: MachineId,
2936 pub expires_at: Timestamp,
2937 pub attempt: u32,
2938}
2939```
2940
2941Expired work can be rescheduled.
2942
2943External effects use idempotency keys and must never be blindly replayed.
2944
2945---
2946
2947# 34. What Not to Build
2948
2949Avoid the following:
2950
2951## Distributed shared memory
2952
2953Do not pretend network RAM is local RAM.
2954
2955## One giant “AIEN database”
2956
2957Do not merge World, Cortex, J-Space, tools, and telemetry into one table system.
2958
2959## All-tools-in-prompt
2960
2961Do not put thousands of tool schemas into context.
2962
2963## Model-owned secrets
2964
2965Do not expose raw API credentials to prompts or model-visible tool arguments.
2966
2967## Direct effects from speculative branches
2968
2969Only winning, authorized transactions may externalize.
2970
2971## Hardware-vendor logic in the core scheduler
2972
2973Hardware is capability metadata.
2974
2975## Hand-maintaining the entire MCP protocol
2976
2977Use the official Rust SDK.
2978
2979## Fine-grained distributed inference over poor networks
2980
2981Prefer branch-level work unless topology supports finer partitioning.
2982
2983---
2984
2985# 35. Recommended Technology Adoption Matrix
2986
2987| Need | Adopt / Study | AIEN Role |
2988|---|---|---|
2989| MCP protocol | official Rust `rmcp` | compatibility broker |
2990| Fine-grained authorization | Cedar | policy engine under AEGIS |
2991| Workload identity concepts | SPIFFE/SPIRE | Fabric identity design |
2992| QUIC | Quinn | initial Fabric transport |
2993| P2P/content distribution | Iroh concepts | later model chunk distribution |
2994| Sandboxed plugins | Wasmtime/WASI | third-party tool runtime |
2995| Broad GPU fallback | IREE/Vulkan | optional later backend |
2996| Local distributed inference patterns | Exo, llama.cpp RPC, MLX | topology/partitioning prior art |
2997| General resource scheduling | Ray/Dask patterns | scheduling prior art, not runtime dependency |
2998| Durable execution | Temporal patterns | event/replay semantics |
2999| Provenance envelope | in-toto/DSSE | signed World envelope compatibility |
3000| Observability | OpenTelemetry | trace/metric semantics |
3001
3002---
3003
3004# 36. What AIEN Should Build Itself
3005
3006The following are core differentiators and should not be outsourced wholesale:
3007
30081. **World abstraction**
30092. **J-Space**
30103. **branch-native Sequence/KV lifecycle**
30114. **Capability Graph**
30125. **Skill Router**
30136. **AIEN Fabric scheduling semantics**
30147. **effect transaction model**
30158. **World-integrated provenance**
30169. **Cortex/World/J-Space integration**
301710. **RSI optimization loop**
3018
3019Use external libraries for protocols and primitives.
3020
3021Own the AIEN semantics.
3022
3023---
3024
3025# 37. Flagship Technical Story
3026
3027A compelling demonstration of the complete architecture would be:
3028
3029```text
30301. Machine 1 starts AIEN.
30312. Machine 2 joins.
30323. Machine 3 joins.
30334. Capability Graph updates automatically.
30345. A user asks AIEN to solve a complex task.
30356. J-Space generates multiple strategies.
30367. Branches execute on different Machines.
30378. One Machine runs a platform-specific tool unavailable elsewhere.
30389. An MCP tool is dynamically routed through the broker.
303910. No model sees a raw secret.
304011. AEGIS blocks one unsafe branch.
304112. The judge selects the best valid branch.
304213. The Effect Broker performs the approved external action.
304314. A signed World commit proves the result.
304415. Cortex stores the lesson.
304516. RSI records whether the routing/placement could be improved.
304617. One Machine disconnects.
304718. AIEN continues running.
3048```
3049
3050That demonstration communicates the architecture much better than a synthetic chat benchmark.
3051
3052---
3053
3054# 38. Short Architecture Reference
3055
3056```text
3057USER / API
3058 ↓
3059CONTROL PLANE
3060 ↓
3061RUNTIME
3062 ↓
3063J-SPACE
3064 ↓
3065SKILL ROUTER
3066 ↓
3067CAPABILITY GRAPH
3068 ↓
3069FABRIC SCHEDULER
3070 ↓
3071MACHINE 1 / MACHINE 2 / MACHINE 3 / ...
3072 ↓
3073TOOL / MODEL / VERIFIER EXECUTION
3074 ↓
3075AEGIS
3076 ↓
3077EFFECT BROKER
3078 ↓
3079WORLD COMMIT
3080 ↓
3081SIGNED PROVENANCE
3082 ↓
3083CORTEX
3084 ↓
3085RSI / BENCHMARK FEEDBACK
3086```
3087
3088---
3089
3090# 39. Priority Order
3091
3092If the goal is to maximize architectural leverage, build in this order:
3093
30941. **Capability ABI**
30952. **Skill Router**
30963. **Canonical Rust MCP broker**
30974. **Vault-only production secret policy**
30985. **Effect Broker**
30996. **Signed World Commit**
31007. **Model Capsule / typed weight ABI**
31018. **Portable accelerator interface**
31029. **aien-node / Fabric**
310310. **distributed branch execution**
310411. **J-Space**
310512. **content-addressed model distribution**
310613. **fine-grained distributed inference**
310714. **RSI optimization across all of the above**
3108
3109This ordering creates useful product value at every stage.
3110
3111---
3112
3113# 40. Gap Summary
3114
3115## Already strong
3116
3117- native Rust runtime
3118- scheduler
3119- branchable inference state
3120- KV sharing
3121- streaming
3122- Cortex
3123- AEGIS
3124- evaluation/provenance primitives
3125- RSI canary/rollback
3126- Rust MCP proofs
3127- benchmark culture
3128
3129## Partial / fragmented
3130
3131- MCP
3132- skills/tools
3133- secrets
3134- effect gating
3135- provenance
3136- model loading
3137- hardware abstraction
3138- operator composition
3139
3140## Missing or not yet first-class
3141
3142- Capability Graph
3143- Skill Router
3144- Fabric
3145- Machine identity and placement
3146- Model Capsule
3147- portable accelerator contract
3148- signed World commits
3149- non-bypassable Effect Broker
3150- J-Space
3151- distributed branch execution
3152- content-addressed model distribution
3153- one canonical observability schema
3154
3155---
3156
3157# 41. Final Architectural Definition
3158
3159AIEN should ultimately be understood as:
3160
3161> **A universal, branch-native AI runtime that treats models, tools, skills, memory, machines, and accelerators as discoverable capabilities inside one secure local compute fabric. It can explore multiple Worlds in parallel, judge them in J-Space, execute approved effects through a non-bypassable policy boundary, prove resulting state transitions cryptographically, remember useful outcomes in Cortex, and improve its own routing and execution through gated RSI.**
3162
3163The most important implementation discipline is to keep these responsibilities separate:
3164
3165```text
3166Model → proposes
3167J-Space → compares
3168Skill → describes procedure
3169Tool → performs atomic operation
3170Router → finds capability
3171Fabric → finds Machine
3172AEGIS → authorizes
3173Broker → performs effect
3174World → records state
3175Provenance → proves
3176Cortex → remembers
3177RSI → improves
3178```
3179
3180That separation is the architecture.
3181
3182---
3183
3184# 42. Research Sources and Prior Art
3185
3186The following current sources informed the gap analysis and implementation choices.
3187
3188## AIEN repositories
3189
3190- Sovereign Manifesto: https://github.com/aien-spark/open-humanity/blob/main/docs/SOVEREIGN_MANIFESTO.md
3191
3192- https://github.com/aien-spark/aien-sovereign-core
3193- https://github.com/aien-spark/aien-protocols
3194- https://github.com/aien-spark/aegis-runtime
3195- https://github.com/aien-dev/cortex-rs
3196- https://github.com/aien-spark/spark-rsi
3197- https://github.com/aien-dev/spark-debugger
3198- https://github.com/aien-dev/aien-harness
3199- https://github.com/aien-dev/spark-inquisitor
3200- https://github.com/aien-dev/spark-hive
3201- https://github.com/aien-spark/benchmarks
3202- https://github.com/aien-dev/aien-local-stack
3203
3204## Distributed compute and inference
3205
3206- Exo: https://github.com/exo-explore/exo
3207- llama.cpp RPC: https://github.com/ggml-org/llama.cpp/blob/master/tools/rpc/README.md
3208- MLX distributed: https://github.com/ml-explore/mlx/blob/main/docs/src/usage/distributed.rst
3209- Ray scheduling: https://docs.ray.io/en/latest/ray-core/scheduling/
3210- Dask distributed: https://distributed.dask.org/
3211
3212## Portable execution
3213
3214- IREE Vulkan: https://iree.dev/guides/deployment-configurations/gpu-vulkan/
3215- Wasmtime: https://docs.wasmtime.dev/
3216- Wasmtime Component Model: https://docs.wasmtime.dev/api/wasmtime/component/
3217
3218## MCP
3219
3220- MCP organization: https://github.com/modelcontextprotocol
3221- Official Rust SDK: https://github.com/modelcontextprotocol/rust-sdk
3222- Rust SDK docs: https://rust.sdk.modelcontextprotocol.io/
3223
3224## Authorization and identity
3225
3226- Cedar: https://github.com/cedar-policy/cedar
3227- Cedar docs: https://docs.cedarpolicy.com/
3228- SPIFFE/SPIRE: https://spiffe.io/
3229
3230## Provenance
3231
3232- in-toto Attestation: https://github.com/in-toto/attestation
3233- DSSE envelope concepts: https://github.com/in-toto/attestation/blob/main/spec/v1/envelope.md
3234
3235## Observability
3236
3237- OpenTelemetry semantic conventions: https://opentelemetry.io/docs/specs/semconv/
3238- OpenTelemetry GenAI observability: https://opentelemetry.io/blog/2026/genai-observability/
3239
3240## Tool routing and test-time scaling
3241
3242- Semantic MCP tool discovery: https://arxiv.org/abs/2603.20313
3243- Test-time scaling survey: https://arxiv.org/abs/2608.04001
3244- Inference-time verification: https://arxiv.org/abs/2601.15808
3245
3246## Durable execution
3247
3248- Temporal: https://docs.temporal.io/
3249
3250---
3251
3252# 43. Immediate Next Engineering Ticket Set
3253
3254For implementation agents, the following tickets are concrete enough to start.
3255
3256## Ticket A: `aien-capability`
3257
3258Create canonical Tool and Skill descriptors.
3259
3260Deliver:
3261
3262- typed IDs,
3263- schemas,
3264- effect classes,
3265- resource requirements,
3266- version/digest semantics,
3267- serialization tests.
3268
3269---
3270
3271## Ticket B: `aien-skill-router`
3272
3273Deliver:
3274
3275- deterministic alias lookup,
3276- tags/lexical index,
3277- semantic index interface,
3278- hard constraint filter,
3279- top-k output,
3280- routing receipts.
3281
3282Benchmark 1,000 / 10,000 capability catalogs.
3283
3284---
3285
3286## Ticket C: `aien-mcp`
3287
3288Use `rmcp`.
3289
3290Deliver:
3291
3292- client,
3293- server,
3294- stdio,
3295- Streamable HTTP,
3296- mapping to ToolDescriptor,
3297- import existing Debugger/Harness MCP tools.
3298
3299---
3300
3301## Ticket D: `aien-vault`
3302
3303Deliver production `VaultOnly`.
3304
3305Remove implicit environment fallback from production.
3306
3307Return `CredentialRef`, not secrets, to callers above broker level.
3308
3309---
3310
3311## Ticket E: `aien-effect-broker`
3312
3313Move mail first.
3314
3315Then Git publish.
3316
3317Add mock driver for golden-path tests.
3318
3319---
3320
3321## Ticket F: Signed World Commit v1
3322
3323Extend `aien-provenance`.
3324
3325Use Merkle roots and existing signer interfaces.
3326
3327---
3328
3329## Ticket G: Model Capsule v1
3330
3331Support:
3332
3333- TinyLlama for oracle,
3334- one useful long-context model family,
3335- typed BF16/quantized tensor views,
3336- tokenizer/template digest,
3337- no FP32 expansion in production.
3338
3339---
3340
3341## Ticket H: Portable Accelerator v1
3342
3343Deliver:
3344
3345- CPU backend,
3346- Mojo backend,
3347- backend parity suite,
3348- no mandatory CUDA build dependency.
3349
3350---
3351
3352## Ticket I: Fabric v1
3353
3354Deliver:
3355
3356- `aien-node`,
3357- Machine IDs,
3358- mDNS discovery,
3359- QUIC connection,
3360- identity,
3361- capability advertisement,
3362- topology metrics.
3363
3364---
3365
3366## Ticket J: Distributed J-Space prototype
3367
3368Deliver:
3369
3370- root candidate,
3371- 3 branches,
3372- dispatch to multiple Machines,
3373- cheap verifier,
3374- winning World commit,
3375- losing branch cleanup.
3376
3377This single prototype will test almost every major architectural boundary.
3378
3379---
3380
3381# 44. Closing Rule
3382
3383Whenever a new subsystem is proposed, ask:
3384
33851. Is this **state**, **memory**, **planning**, **capability**, **placement**, **policy**, **effect**, or **evidence**?
33862. Which existing subsystem already owns that responsibility?
33873. Can it be represented as a typed protocol instead of a new daemon?
33884. Can it execute on any Machine?
33895. Can it fail without corrupting the logical AIEN system?
33906. Can its effects be rolled back or proven?
33917. Does it improve the end-to-end system, or merely add another layer?
3392
3393If those questions remain explicit, AIEN can grow to a very large system without becoming an unmaintainable collection of overlapping agents and services.