|
1 | | -# LNMP Architecture & Flow: The Digital Organism |
| 1 | +# LNMP Protocol Architecture (v0.5.14) |
2 | 2 |
|
3 | | -This document illustrates the LNMP protocol (v0.5.14) as a highly structured biological system. It combines a clean, layered anatomical view with a detailed physiological flow. |
| 3 | +This document defines the structural architecture of the LNMP protocol, mapping the **12 ecosystem crates** into a unified layered model. |
4 | 4 |
|
5 | | -## 1. The Anatomy (Layered Architecture) |
| 5 | +## 1. The Protocol Stack (The Centipede) |
6 | 6 |
|
7 | | -The protocol is organized into distinct functional layers, ensuring separation of concerns and modular efficiency. |
| 7 | +The LNMP architecture is composed of 5 vertical layers. Each layer has a specific responsibility and communicates only with adjacent layers. |
8 | 8 |
|
9 | 9 | ```mermaid |
10 | 10 | graph TD |
11 | | - %% LAYER 1: COGNITION (The Brain) |
12 | | - subgraph Layer1 ["🧠 1. COGNITIVE LAYER (Cortex)"] |
| 11 | + %% --- LAYER 1: APPLICATION & INTELLIGENCE --- |
| 12 | + subgraph L1 ["1. Application Layer (Intelligence)"] |
13 | 13 | direction TB |
14 | | - App[Application] |
15 | | - SFE[lnmp-sfe: Semantic Engine] |
16 | | - LLB[lnmp-llb: Language Bridge] |
17 | | - LLM((LLM Model)) |
| 14 | + App[User Application] |
| 15 | + SFE[lnmp-sfe: Semantic Field Engine] |
| 16 | + LLB[lnmp-llb: LLM Bridge] |
18 | 17 | |
19 | | - App <--> SFE |
20 | | - SFE <--> LLB |
21 | | - LLB <--> LLM |
| 18 | + App -->|"Intent"| SFE |
| 19 | + SFE -->|"FIDs"| LLB |
| 20 | + LLB -->|"Context"| LLM((AI Model)) |
22 | 21 | end |
23 | 22 |
|
24 | | - %% LAYER 2: CORE (The DNA) |
25 | | - subgraph Layer2 ["🧬 2. CORE LAYER (Nucleus)"] |
| 23 | + %% --- LAYER 2: CORE & PRESENTATION --- |
| 24 | + subgraph L2 ["2. Core Layer (Definition)"] |
26 | 25 | direction TB |
27 | | - LnmpCore[lnmp-core: Registry] |
28 | | - Codec[lnmp-codec: Transcription] |
| 26 | + Core[lnmp-core: Registry & Types] |
| 27 | + Codec[lnmp-codec: Serialization] |
| 28 | + San[lnmp-sanitize: Input Filter] |
29 | 29 | end |
30 | 30 |
|
31 | | - %% LAYER 3: CAPABILITIES (Physiology) |
32 | | - subgraph Layer3 ["💪 3. CAPABILITY LAYER (Body)"] |
| 31 | + %% --- LAYER 3: CAPABILITIES (EXTENSIONS) --- |
| 32 | + subgraph L3 ["3. Capability Layer (Extensions)"] |
33 | 33 | direction LR |
34 | | - Spatial[lnmp-spatial] |
35 | | - Emb[lnmp-embedding] |
36 | | - Quant[lnmp-quant] |
| 34 | + Spatial[lnmp-spatial: 3D/Geo] |
| 35 | + Emb[lnmp-embedding: Vectors] |
| 36 | + Quant[lnmp-quant: Compression] |
37 | 37 | |
38 | | - Spatial --- Emb |
39 | | - Emb --- Quant |
| 38 | + Spatial -.-> Core |
| 39 | + Emb -.-> Core |
| 40 | + Quant -.-> Emb |
40 | 41 | end |
41 | | -
|
42 | | - %% LAYER 4: DEFENSE (Immune System) |
43 | | - subgraph Layer4 ["🛡️ 4. DEFENSE LAYER (Immunity)"] |
| 42 | + |
| 43 | + %% --- LAYER 4: DEFENSE & IDENTITY --- |
| 44 | + subgraph L4 ["4. Session Layer (Defense)"] |
44 | 45 | direction TB |
45 | | - San[lnmp-sanitize: Hygiene] |
46 | | - Env[lnmp-envelope: Identity] |
| 46 | + Env[lnmp-envelope: Identity/Trace] |
47 | 47 | end |
48 | 48 |
|
49 | | - %% LAYER 5: TRANSPORT (Circulation) |
50 | | - subgraph Layer5 ["📡 5. TRANSPORT LAYER (Vascular)"] |
| 49 | + %% --- LAYER 5: TRANSPORT & ROUTING --- |
| 50 | + subgraph L5 ["5. Network Layer (Transport)"] |
51 | 51 | direction TB |
52 | | - Net[lnmp-net: Routing/QoS] |
| 52 | + Net[lnmp-net: QoS/Routing] |
53 | 53 | Trans[lnmp-transport: Bindings] |
| 54 | + Ext[External Network] |
54 | 55 | end |
55 | 56 |
|
56 | | - %% MAIN SPINE (Vertical Integration) |
57 | | - %% Node-to-Node connections drive the layout, no need for Layer-to-Layer links |
58 | | - SFE ==> LnmpCore |
59 | | - |
60 | | - LnmpCore ==> Codec |
| 57 | + %% --- VERTICAL FLOW (THE SPINE) --- |
| 58 | + SFE ==> Core |
| 59 | + Core ==> Codec |
61 | 60 | Codec ==> Env |
62 | 61 | Env ==> Net |
63 | 62 | Net ==> Trans |
64 | | -
|
65 | | - %% CONNECTION REFINEMENTS |
66 | | - App --> SFE |
67 | | - SFE --> LLB |
68 | | - LLB --> LLM |
| 63 | + Trans ==> Ext |
69 | 64 | |
70 | | - %% Capability Connections |
71 | | - LnmpCore -.-> Spatial |
72 | | - LnmpCore -.-> Emb |
73 | | - Emb -.-> Quant |
74 | | -
|
75 | | - %% Defense / Transport Connections |
76 | | - San -.-> LnmpCore |
| 65 | + %% --- INPUT FLOW --- |
77 | 66 | Ext -.-> San |
78 | | - Trans -.-> Ext |
79 | | -
|
80 | | - %% STYLING |
| 67 | + San -.-> Core |
| 68 | + |
81 | 69 | %% STYLING |
82 | | - style Layer1 fill:#e3f2fd,stroke:#1565c0,stroke-width:2px |
83 | | - style Layer2 fill:#fff8e1,stroke:#fbc02d,stroke-width:2px |
84 | | - style Layer3 fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px |
85 | | - style Layer4 fill:#ffebee,stroke:#c62828,stroke-width:2px |
86 | | - style Layer5 fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px |
| 70 | + classDef layer fill:#f9f9f9,stroke:#333,stroke-width:2px; |
| 71 | + class L1,L2,L3,L4,L5 layer; |
87 | 72 | ``` |
88 | 73 |
|
89 | | -### 🧬 Guide to Layers |
90 | | - |
91 | | -1. **Cognitive Layer:** Where "meaning" happens. `lnmp-sfe` translates intent to FIDs; `lnmp-llb` compresses text for the LLM. |
92 | | -2. **Core Layer:** The source of truth. `lnmp-core` holds the Registry; `lnmp-codec` handles binary encoding. |
93 | | -3. **Capability Layer:** Extends the core with superpowers. `spatial` (Location), `embedding` (Memory), `quant` (Efficiency). |
94 | | -4. **Defense Layer:** Protects the organism. `lnmp-sanitize` cleans input; `lnmp-envelope` signs and wraps packets. |
95 | | -5. **Transport Layer:** Moves the data. `lnmp-net` prioritizes traffic; `lnmp-transport` binds to HTTP/Kafka. |
| 74 | +### Module Responsibilities |
| 75 | + |
| 76 | +| Layer | Module | Responsibility | |
| 77 | +| :--- | :--- | :--- | |
| 78 | +| **1. App** | `lnmp-sfe` | **Translator:** Converts human intent/concepts into Protocol FIDs. | |
| 79 | +| | `lnmp-llb` | **Optimizer:** Formats data for LLM context windows (ShortForm). | |
| 80 | +| **2. Core** | `lnmp-core` | **Authority:** Holds the FID Registry and Type Definitions. | |
| 81 | +| | `lnmp-codec` | **Encoder:** Handles Binary/Text serialization. | |
| 82 | +| | `lnmp-sanitize` | **Filter:** Cleans "dirty" input before strict parsing. | |
| 83 | +| **3. Cap** | `lnmp-spatial` | **Sense:** Provides coordinate systems and spatial math. | |
| 84 | +| | `lnmp-embedding` | **Memory:** Manages high-dimensional vector data. | |
| 85 | +| | `lnmp-quant` | **Efficiency:** Compresses vectors (up to 32x) for transport. | |
| 86 | +| **4. Def** | `lnmp-envelope` | **Identity:** Signs packets, adds Trace IDs and Timestamps. | |
| 87 | +| **5. Net** | `lnmp-net` | **Router:** Classifies messages (Alert/Log) and assigns QoS. | |
| 88 | +| | `lnmp-transport` | **Binding:** Maps LNMP concepts to HTTP/Kafka/gRPC. | |
96 | 89 |
|
97 | 90 | --- |
98 | 91 |
|
99 | | -## 2. The Cycle of Life (DNA Helix Flow) |
| 92 | +## 2. The Data Flow (The DNA Helix) |
100 | 93 |
|
101 | | -How a message comes alive and travels between agents. |
| 94 | +This sequence illustrates the lifecycle of a message, showing how two agents sync ("Bonding") and exchange data ("Synthesis"). |
102 | 95 |
|
103 | 96 | ```mermaid |
104 | 97 | sequenceDiagram |
105 | | - participant A as 🧬 Agent A |
106 | | - participant B as 🧬 Agent B |
| 98 | + participant A as 👤 Agent A (Sender) |
| 99 | + participant B as 🤖 Agent B (Receiver) |
107 | 100 | |
108 | | - Note over A,B: PHASE 1: RECOGNITION (Handshake) |
| 101 | + Note over A,B: PHASE 1: DNA BONDING (Sync) |
109 | 102 | |
110 | 103 | A->>B: 🟡 Hello (Protocol v0.5) |
111 | 104 | B-->>A: 🟢 Welcome (Registry v1.2) |
112 | 105 | |
113 | | - rect rgb(20, 30, 40) |
114 | | - Note left of A: DNA Bonding |
115 | | - A->>A: Registry Mismatch? |
116 | | - opt Sync Required |
117 | | - A->>B: 🔴 RequestDelta |
118 | | - B-->>A: 🔵 RegistryDelta |
119 | | - A->>A: Apply & Compile |
120 | | - end |
| 106 | + rect rgb(240, 240, 240) |
| 107 | + Note left of A: Compatibility Check |
| 108 | + A->>A: Local v1.0 vs Remote v1.2 |
| 109 | + alt Registry Mismatch |
| 110 | + A->>B: 🔴 RequestDelta |
| 111 | + B-->>A: 🔵 RegistryDelta (New FIDs) |
| 112 | + A->>A: Apply & Recompile |
| 113 | + end |
121 | 114 | end |
122 | 115 | |
123 | | - A->>B: 🟡 Bond Established |
| 116 | + A->>B: 🟡 Ready (Bonded) |
124 | 117 | |
125 | | - Note over A,B: PHASE 2: SYNTHESIS (Data Exchange) |
| 118 | + Note over A,B: PHASE 2: SYNTHESIS (Exchange) |
126 | 119 | |
127 | | - loop Stream Interaction |
128 | | - A->>B: 📦 [Env: TraceID] [Msg: Action] (FIDs: 10, 100) |
| 120 | + loop Real-time Interaction |
| 121 | + A->>B: 📦 [Env: TraceID] [Msg: Intent] (FIDs: 10, 100) |
129 | 122 | |
130 | | - rect rgb(40, 50, 60) |
131 | | - Note right of B: Processing |
132 | | - B->>B: Verify -> Decode -> Understand -> Act |
| 123 | + rect rgb(230, 240, 255) |
| 124 | + Note right of B: Internal Processing |
| 125 | + B->>B: Net (QoS) -> Env (Verify) -> Codec (Decode) |
| 126 | + B->>B: Core (Validate) -> SFE (Understand) |
133 | 127 | end |
134 | 128 | |
135 | | - B-->>A: 📦 [Msg: Result] [Meta: Status=OK] |
| 129 | + B-->>A: 📦 [Msg: Response] [Meta: Confidence=0.99] |
136 | 130 | |
137 | | - opt Spatial Reflex (Multimodal) |
138 | | - A->>B: 🧊 [Spatial: Vector] (F256) |
139 | | - B-->>A: 🧊 [Spatial: Update] |
| 131 | + opt Spatial Reflex |
| 132 | + A->>B: 🧊 [Spatial: Position Update] (F256) |
| 133 | + B-->>A: 🧊 [Spatial: New Coordinates] |
140 | 134 | end |
141 | 135 | end |
142 | 136 | |
|
0 commit comments