Skip to content

Commit 531e684

Browse files
committed
feat: Revise architecture documentation to enhance clarity and detail on LNMP protocol structure and data flow
1 parent 28d4566 commit 531e684

1 file changed

Lines changed: 119 additions & 100 deletions

File tree

spec/architecture-and-flow.md

Lines changed: 119 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,148 @@
1-
# LNMP Architecture & Flow Visualization
1+
# LNMP Architecture & Flow: The Digital Organism
22

3-
This document visualizes the "DNA-like" structure of the LNMP protocol, showing how Semantic Field Engine (SFE), Registry, Codec, and Transport layers synchronize to enable Agent-to-Agent (A2A) and Model-to-Model (M2M) communication.
3+
This document provides a comprehensive, end-to-end visualization of the LNMP protocol. It maps the technical modules to "biological" systems to illustrate how LNMP functions not just as a data format, but as a living language for AI agents.
44

5-
## The LNMP Centipede (Protocol Stack)
5+
## 1. The Anatomy of LNMP (Module Map)
66

7-
The protocol operates like a biological organism where each segment has a specific function, connected by a central nervous system (The Core).
7+
Each crate in the ecosystem serves a critical physiological function in the digital organism.
88

99
```mermaid
1010
graph TD
11-
subgraph "Agent A (Brain)"
12-
A_Ctx[Context / Intent]
13-
A_SFE[SFE: Semantic Field Engine]
11+
%% Brain & Intent
12+
subgraph "Cortex (Higher Function)"
13+
App[Application Logic]
14+
SFE[lnmp-sfe: Semantic Field Engine]
15+
App -->|Intent/Context| SFE
1416
end
1517
16-
subgraph "Protocol Stack (The DNA Spine)"
17-
Core[LNMP Core: Universal Types & Registry]
18-
Codec[LNMP Codec: Binary/Chemical Encoding]
19-
Trans[LNMP Transport: Neural/Network Pathways]
18+
%% Core System
19+
subgraph "DNA & Nervous System (The Core)"
20+
Core[lnmp-core: Types & Registry]
21+
Codec[lnmp-codec: Encoding & Rules]
2022
end
2123
22-
subgraph "Agent B (Brain)"
23-
B_SFE[SFE: Semantic Field Engine]
24-
B_Ctx[Action / Understanding]
24+
%% Body & Capabilities
25+
subgraph "Physiology (Capabilities)"
26+
Spatial[lnmp-spatial: Proprioception/Space]
27+
Emb[lnmp-embedding: Memory/Vector]
28+
Quant[lnmp-quant: Efficiency/Compression]
29+
end
30+
31+
%% Protection & Transport
32+
subgraph "Immune & Circulatory System"
33+
Env[lnmp-envelope: Cell Wall & Identity]
34+
Net[lnmp-net: Networking/Flow]
35+
Net -->|TCP/QUIC| Ext[External World]
2536
end
2637
2738
%% Connections
28-
A_Ctx -->|Contextualizes| A_SFE
29-
A_SFE -->|Maps to FIDs| Core
30-
Core -->|Serializes| Codec
31-
Codec -->|Encapsulates| Trans
39+
SFE -->|Maps Meaning to FIDs| Core
40+
Core -->|Defines Structure| Codec
3241
33-
Trans <==>|Bi-Directional Flow| Trans
42+
Codec -->|Serializes| Env
43+
Env -->|Encapsulates| Net
3444
35-
Trans -->|Decapsulates| Codec
36-
Codec -->|Deserializes| Core
37-
Core -->|Resolves FIDs| B_SFE
38-
B_SFE -->|Understands| B_Ctx
39-
40-
%% Styling
41-
style Core fill:#f96,stroke:#333
42-
style Codec fill:#69f,stroke:#333
43-
style Trans fill:#9f9,stroke:#333
45+
Spatial -->|Extends| Core
46+
Emb -->|Extends| Core
47+
Quant -->|Optimizes| Emb
4448
```
4549

46-
## The Connectivity DNA Helix (E2E Flow)
50+
### 🧬 Structural Meaning
51+
* **lnmp-core (The DNA):** The immutable truths. FIDs (Field IDs) are the genetic codons (A, C, G, T) that define meaning efficiently.
52+
* **lnmp-sfe (The Brain):** Translates abstract "thoughts" (User Intent) into genetic instructions (FIDs).
53+
* **lnmp-envelope (The Cell Wall):** Protects the payload. Contains the Identity (Source), Timestamp, and Trace ID. It ensures the "cell" is distinct and traceable.
54+
* **lnmp-quant (Metabolism):** Optimizes energy usage by compressing heavy vector data (Embeddings) up to 32x, allowing the organism to "think" faster and lighter.
55+
* **lnmp-spatial (Proprioception):** Gives the agent a sense of "self" in physical or virtual space.
56+
57+
---
58+
59+
## 2. The Cycle of Life: E2E Data Flow
60+
61+
This diagram illustrates the complete journey of a "Thought" becoming an "Action" across the network.
62+
63+
### Stage A: Conception (Intent Formation)
64+
* **Source:** Agent A wants to say *"Move to coordinates (10, 20) quickly."*
65+
* **SFE:** Maps concepts -> FIDs: `Action=Move`, `Pos=[10,20]`, `Urgency=High`.
66+
67+
### Stage B: DNA Transcription (Encoding)
68+
* **Core:** Validates values against the Registry (e.g., `Pos` must be `:fa` FloatArray).
69+
* **Codec:** Transcribes these values into compact Binary LNMP (The "RNA" strand).
70+
71+
### Stage C: Cellular Transport (Encapsulation)
72+
* **Envelope:** Wraps the Binary payload. Adds headers: `Source: AgentA`, `TraceID: xyz-123`, `Time: 1734438000`.
73+
* **Net:** Transmits the envelope over the wire (Bloodstream).
4774

48-
This sequence diagram illustrates the "Double Helix" interaction between two agents. The strands are connected by protocol bonds (Negotiation, Sync, Data).
75+
### Stage D: Reception & Perception
76+
* **Agent B** receives the pulse.
77+
* **Envelope:** Verifies Identity (Source). "This is safe."
78+
* **Codec:** Decodes binary back to structured data.
79+
* **SFE:** "Feeling" the data. Resolves FIDs back to concepts.
80+
* **Spatial:** Updates internal world model. "Agent A is moving."
4981

5082
```mermaid
5183
sequenceDiagram
52-
participant A as Agent A (Client)
53-
participant B as Agent B (Service)
54-
55-
Note over A,B: Phase 1: Recognition (Discovery & Handshake)
56-
57-
A->>B: 🟡 Hello (Protocol v0.5)
58-
B-->>A: 🟢 Welcome (Capabilities + Registry v1.2)
59-
60-
rect rgb(20, 20, 30)
61-
Note left of A: DNA Bonding: Schema Alignment
62-
A->>A: Check Registry Sync
63-
alt Registry Mismatch
64-
A->>B: 🔴 RequestRegistryDelta(v1.0 -> v1.2)
65-
B-->>A: 🔵 RegistryDelta (New FIDs defined)
66-
A->>A: Apply Delta & Compile
67-
end
68-
end
69-
70-
A->>B: 🟡 Ready (Schema Negotiated)
71-
72-
Note over A,B: Phase 2: Synthesis (Data Exchange)
84+
participant Mind as 🧠 Agent Mind
85+
participant SFE as 🔮 SFE (Translator)
86+
participant Core as 🧬 Core/Codec
87+
participant Env as 🛡️ Envelope
88+
participant Net as 📡 Network
89+
90+
%% Sending
91+
Note over Mind, Net: 1. OUTBOUND FLOW (Expression)
92+
Mind->>SFE: Intent: "Move(10, 20)"
93+
SFE->>Core: Lookup FIDs (Move=100, x=256...)
94+
Core->>Core: Validate Types (:fa, :s)
95+
Core->>Env: Payload (Binary DNA)
96+
Env->>Env: Seal (Add Trace/Source)
97+
Env->>Net: Dispatch (Packet)
98+
99+
%% Network Transit
100+
Net-->>Net: ⚡ Transmission ⚡
101+
102+
%% Receiving
103+
Note over Mind, Net: 2. INBOUND FLOW (Perception)
104+
Net->>Env: Receive (Packet)
105+
Env->>Env: Verify Identity
106+
Env->>Core: Unwrap Payload
107+
Core->>SFE: Decode DNA to FIDs
108+
SFE->>Mind: Semantic Concept: "Target Moving"
73109
74-
loop Stream / Bi-Directional
75-
A->>B: 📦 [Msg: Prompt] + [Ctx: Temperature=0.7] (FIDs: 10, 768)
76-
77-
rect rgb(40, 40, 50)
78-
Note right of B: Semantic Processing
79-
B->>B: Decode -> Resolve FIDs -> Inference
80-
end
81-
82-
B-->>A: 📦 [Msg: Response] + [Meta: Complexity=0.9] (FIDs: 11, 41)
83-
84-
opt Spatial Context (Multimodal)
85-
A->>B: 🧊 [Spatial: Position + Vector] (F256, F512)
86-
B-->>A: 🧊 [Spatial: New Coordinates]
87-
end
110+
opt Spatial Reflex
111+
Mind->>Mind: Update Spatial Index
88112
end
89-
90-
Note over A,B: Phase 3: Termination
91-
92-
A->>B: 🔴 Close Session
93-
B-->>A: 🔴 Ack
94113
```
95114

96-
## Module Interactions (The Organism)
115+
---
116+
117+
## 3. The "Centipede" Topology (Multi-Agent Harmony)
97118

98-
How the Rust crates interact internally to produce the "Life Logic".
119+
LNMP allows multiple modules to connect like segments of a centipede, moving in unison.
99120

100121
```mermaid
101-
classDiagram
102-
class Application {
103-
+Context
104-
+Intent
105-
}
106-
107-
class LnmpSFE {
108-
+ConceptMapper
109-
+ContextAnalyst
110-
+fid_lookup()
111-
}
112-
113-
class LnmpCore {
114-
+FidRegistry
115-
+LnmpRecord
116-
+LnmpValue
117-
}
118-
119-
class LnmpCodec {
120-
+SchemaNegotiator
121-
+BinaryEncoder
122-
+BinaryDecoder
123-
}
124-
125-
Application --> LnmpSFE : Uses
126-
LnmpSFE --> LnmpCore : Definitions
127-
LnmpSFE --> LnmpCodec : Serializes
128-
LnmpCore <|-- LnmpCodec : Implements Types
122+
graph LR
123+
subgraph "Agent Cluster"
124+
A[Agent Node] <-->|Sync| B[Agent Node]
125+
B <-->|Sync| C[Agent Node]
126+
C <-->|Sync| A
127+
end
128+
129+
subgraph "Shared Reality (Registry)"
130+
Reg((Registry Source))
131+
end
132+
133+
A -.->|Pull Schema| Reg
134+
B -.->|Pull Schema| Reg
135+
C -.->|Pull Schema| Reg
136+
137+
style Reg fill:#f96,stroke:#333,stroke-width:4px
129138
```
139+
140+
* **Synchronization:** Unlike strict APIs (Rest/JSON), LNMP agents share a "genetic link" (The Registry). If the Registry evolves (new FIDs), all agents evolve their understanding instantly without breaking the connection.
141+
* **M2M (Machine-to-Machine):** High-speed, low-latency binary stream.
142+
* **A2A (Agent-to-Agent):** High-context, semantic meaning exchange.
143+
144+
## 4. Why This Structure?
145+
146+
1. **Semantic Density:** By separating the *definition* (Registry) from the *transmission* (Binary), we achieve maximum information density. We don't send keys like `"temperature"`, we send `768`.
147+
2. **Evolutionary Safety:** Old agents ignore new FIDs (Junk DNA), while new agents utilize them. This allows the system to evolve organically without "breaking changes".
148+
3. **Universal Grounding:** Through `lnmp-spatial` and `lnmp-core`, all agents agree on fundamental truths (Time, Space, Identity), preventing hallucinations in multi-agent collaboration.

0 commit comments

Comments
 (0)