Skip to content

Commit 7edf471

Browse files
committed
feat: Revise LNMP architecture documentation for enhanced clarity and detail in module responsibilities and data flow
1 parent e4d15bc commit 7edf471

1 file changed

Lines changed: 82 additions & 88 deletions

File tree

spec/architecture-and-flow.md

Lines changed: 82 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,136 @@
1-
# LNMP Architecture & Flow: The Digital Organism
1+
# LNMP Protocol Architecture (v0.5.14)
22

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.
44

5-
## 1. The Anatomy (Layered Architecture)
5+
## 1. The Protocol Stack (The Centipede)
66

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.
88

99
```mermaid
1010
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)"]
1313
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]
1817
19-
App <--> SFE
20-
SFE <--> LLB
21-
LLB <--> LLM
18+
App -->|"Intent"| SFE
19+
SFE -->|"FIDs"| LLB
20+
LLB -->|"Context"| LLM((AI Model))
2221
end
2322
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)"]
2625
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]
2929
end
3030
31-
%% LAYER 3: CAPABILITIES (Physiology)
32-
subgraph Layer3 ["💪 3. CAPABILITY LAYER (Body)"]
31+
%% --- LAYER 3: CAPABILITIES (EXTENSIONS) ---
32+
subgraph L3 ["3. Capability Layer (Extensions)"]
3333
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]
3737
38-
Spatial --- Emb
39-
Emb --- Quant
38+
Spatial -.-> Core
39+
Emb -.-> Core
40+
Quant -.-> Emb
4041
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)"]
4445
direction TB
45-
San[lnmp-sanitize: Hygiene]
46-
Env[lnmp-envelope: Identity]
46+
Env[lnmp-envelope: Identity/Trace]
4747
end
4848
49-
%% LAYER 5: TRANSPORT (Circulation)
50-
subgraph Layer5 ["📡 5. TRANSPORT LAYER (Vascular)"]
49+
%% --- LAYER 5: TRANSPORT & ROUTING ---
50+
subgraph L5 ["5. Network Layer (Transport)"]
5151
direction TB
52-
Net[lnmp-net: Routing/QoS]
52+
Net[lnmp-net: QoS/Routing]
5353
Trans[lnmp-transport: Bindings]
54+
Ext[External Network]
5455
end
5556
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
6160
Codec ==> Env
6261
Env ==> Net
6362
Net ==> Trans
64-
65-
%% CONNECTION REFINEMENTS
66-
App --> SFE
67-
SFE --> LLB
68-
LLB --> LLM
63+
Trans ==> Ext
6964
70-
%% Capability Connections
71-
LnmpCore -.-> Spatial
72-
LnmpCore -.-> Emb
73-
Emb -.-> Quant
74-
75-
%% Defense / Transport Connections
76-
San -.-> LnmpCore
65+
%% --- INPUT FLOW ---
7766
Ext -.-> San
78-
Trans -.-> Ext
79-
80-
%% STYLING
67+
San -.-> Core
68+
8169
%% 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;
8772
```
8873

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. |
9689

9790
---
9891

99-
## 2. The Cycle of Life (DNA Helix Flow)
92+
## 2. The Data Flow (The DNA Helix)
10093

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").
10295

10396
```mermaid
10497
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)
107100
108-
Note over A,B: PHASE 1: RECOGNITION (Handshake)
101+
Note over A,B: PHASE 1: DNA BONDING (Sync)
109102
110103
A->>B: 🟡 Hello (Protocol v0.5)
111104
B-->>A: 🟢 Welcome (Registry v1.2)
112105
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
121114
end
122115
123-
A->>B: 🟡 Bond Established
116+
A->>B: 🟡 Ready (Bonded)
124117
125-
Note over A,B: PHASE 2: SYNTHESIS (Data Exchange)
118+
Note over A,B: PHASE 2: SYNTHESIS (Exchange)
126119
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)
129122
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)
133127
end
134128
135-
B-->>A: 📦 [Msg: Result] [Meta: Status=OK]
129+
B-->>A: 📦 [Msg: Response] [Meta: Confidence=0.99]
136130
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]
140134
end
141135
end
142136

0 commit comments

Comments
 (0)