aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / docs / 03-flows.md
| 1 | # Canonical Flows |
| 2 | |
| 3 | ## 1. Normal inference |
| 4 | |
| 5 | ```mermaid |
| 6 | sequenceDiagram |
| 7 | participant U as User |
| 8 | participant C as Control Plane |
| 9 | participant R as Runtime |
| 10 | participant X as Cortex |
| 11 | participant I as Inference |
| 12 | participant W as World |
| 13 | |
| 14 | U->>C: message |
| 15 | C->>R: submit turn |
| 16 | R->>X: retrieve relevant context |
| 17 | X-->>R: evidence + memories |
| 18 | R->>I: tokenized request |
| 19 | I-->>R: token deltas |
| 20 | R->>W: record state transition |
| 21 | R-->>C: stream output |
| 22 | C-->>U: response |
| 23 | ``` |
| 24 | |
| 25 | ## 2. Skill and tool resolution |
| 26 | |
| 27 | ```mermaid |
| 28 | flowchart LR |
| 29 | OBJ[Objective] --> JS[J-Space] |
| 30 | JS --> SR[Skill Router] |
| 31 | SR --> CG[Capability Graph] |
| 32 | CG --> CF[Constraint Filter] |
| 33 | CF --> TOP[Top candidate skills/tools] |
| 34 | TOP --> JS |
| 35 | JS --> F[Fabric Placement] |
| 36 | F --> EX[Executor] |
| 37 | ``` |
| 38 | |
| 39 | ## 3. MCP discovery vs effect authority |
| 40 | |
| 41 | ```mermaid |
| 42 | flowchart TD |
| 43 | S[MCP Server] <-->|persistent session| SM[aien-mcp Session Manager] |
| 44 | SM --> D[Discovery Lane] |
| 45 | SM --> SC[Speculation-Safe Lane] |
| 46 | SM --> ED[Effect Driver Lane] |
| 47 | |
| 48 | D --> CG[Capability Graph] |
| 49 | CG --> JS[J-Space] |
| 50 | SC --> JS |
| 51 | |
| 52 | JS -->|stage irreversible intent| A[AEGIS] |
| 53 | A -->|AuthorizedEffect| EB[Effect Broker] |
| 54 | EB --> ED |
| 55 | ``` |
| 56 | |
| 57 | J-Space never owns the MCP session. `aien-mcp` owns protocol/session state. |
| 58 | |
| 59 | ## 4. Irreversible effect |
| 60 | |
| 61 | ```mermaid |
| 62 | sequenceDiagram |
| 63 | participant J as J-Space |
| 64 | participant A as AEGIS |
| 65 | participant E as Effect Broker |
| 66 | participant D as Driver |
| 67 | participant X as External System |
| 68 | participant W as World |
| 69 | participant P as Provenance |
| 70 | |
| 71 | J->>J: choose winning World |
| 72 | J->>A: EffectIntent |
| 73 | A-->>J: AuthorizedEffect |
| 74 | J->>E: AuthorizedEffect |
| 75 | E->>D: execute |
| 76 | D->>X: external operation |
| 77 | X-->>D: result |
| 78 | D-->>E: execution result |
| 79 | E->>P: receipt |
| 80 | P-->>E: signed evidence |
| 81 | E->>W: finalize commit |
| 82 | ``` |
| 83 | |
| 84 | ## 5. Secret resolution |
| 85 | |
| 86 | ```mermaid |
| 87 | flowchart LR |
| 88 | TC[ToolCall] --> CR[CredentialRef] |
| 89 | CR --> A[AEGIS] |
| 90 | A --> FP[Fabric Placement] |
| 91 | FP --> B[Broker on selected Machine] |
| 92 | B --> V[Vault] |
| 93 | V --> B |
| 94 | B --> CHILD[Call-scoped execution] |
| 95 | ``` |
| 96 | |
| 97 | Raw values must not enter prompts, J-Space, World state, Cortex, logs, or receipts. |
| 98 | |
| 99 | ## 6. Distributed J-Space |
| 100 | |
| 101 | ```mermaid |
| 102 | flowchart TD |
| 103 | ROOT[Parent World] --> A[Candidate A] |
| 104 | ROOT --> B[Candidate B] |
| 105 | ROOT --> C[Candidate C] |
| 106 | |
| 107 | A --> M1[Machine 1] |
| 108 | B --> M2[Machine 2] |
| 109 | C --> M3[Machine 3] |
| 110 | |
| 111 | M1 --> J[Judge] |
| 112 | M2 --> J |
| 113 | M3 --> J |
| 114 | |
| 115 | J --> WIN[Winning World] |
| 116 | WIN --> AUTH[AEGIS / Commit] |
| 117 | ``` |
| 118 | |
| 119 | ## 7. Machine join |
| 120 | |
| 121 | ```mermaid |
| 122 | sequenceDiagram |
| 123 | participant N as New Machine |
| 124 | participant F as Fabric |
| 125 | participant C as Capability Graph |
| 126 | participant S as Scheduler |
| 127 | |
| 128 | N->>F: authenticated join |
| 129 | F->>N: topology probes |
| 130 | N-->>F: capabilities + model/tool cache |
| 131 | F->>C: publish provider set |
| 132 | C->>S: placement options updated |
| 133 | ``` |
| 134 | |
| 135 | ## 8. Machine failure |
| 136 | |
| 137 | ```mermaid |
| 138 | flowchart LR |
| 139 | TASK[Work Lease] --> M[Machine] |
| 140 | M -->|lease expires| F[Fabric] |
| 141 | F --> R[Reconstruct from durable refs] |
| 142 | R --> M2[Another Machine] |
| 143 | ``` |
| 144 | |
| 145 | Never require remote RAM to be the only source of truth for recoverable work. |
| 146 | |
| 147 | ## 9. RSI optimization |
| 148 | |
| 149 | ```mermaid |
| 150 | flowchart LR |
| 151 | T[Telemetry] --> RSI[RSI] |
| 152 | B[Benchmarks] --> RSI |
| 153 | C[Cortex Lessons] --> RSI |
| 154 | RSI --> H[Hypothesis] |
| 155 | H --> CA[Candidate] |
| 156 | CA --> E[Evaluators] |
| 157 | E --> CAN[Canary] |
| 158 | CAN -->|pass| P[Promote] |
| 159 | CAN -->|fail| RB[Rollback] |
| 160 | ``` |