docs.rs failed to build lnmp-net-0.5.16
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
lnmp-net-0.5.13
lnmp-net
Network behavior standardization for LNMP agent networks.
FID Registry: All examples use official Field IDs from
registry/fids.yaml.
Overview
LNMP-Net provides semantic message classification, Quality of Service (QoS) primitives, and intelligent routing decisions for LLM and agent networks. It builds on top of the LNMP ecosystem without replacing existing serialization or transport layers.
What LNMP-Net Does
- Message Classification: Categorize messages as Event/State/Command/Query/Alert
- QoS Primitives: Priority (0-255) and TTL (time-to-live) for network behavior
- Intelligent Routing: ECO profile for deciding LLM vs. local processing
- Token Optimization: Reduce LLM API calls by 90%+ while maintaining quality
What LNMP-Net Is NOT
- ❌ A new binary format (uses existing LNMP)
- ❌ A transport layer (uses lnmp-transport)
- ❌ A replacement for LLM reasoning (assists in routing decisions)
Quick Start
use ;
use EnvelopeBuilder;
use ;
// Create a record
let mut record = new;
record.add_field;
// Wrap with envelope (timestamp required for TTL/freshness)
let envelope = new
.timestamp
.source
.build;
// Create network message
let msg = new;
// Make routing decision
let policy = default; // ECO profile, threshold=0.7
let decision = policy.decide.unwrap;
match decision
Message Kinds
LNMP-Net defines 5 semantic message types:
| Kind | Purpose | Default Priority | Default TTL | LLM Routing |
|---|---|---|---|---|
| Event | Sensor data, telemetry | 100 | 5s | Via importance scoring |
| State | System state snapshots | 100 | 10s | Via importance scoring |
| Command | Imperative actions | 150 | 2s | Local processing |
| Query | Information requests | 120 | 5s | Local first, complex → LLM |
| Alert | Critical warnings | 255 | 1s | Always → LLM |
Each kind has sensible defaults tuned for typical use cases.
Routing Logic (ECO Profile)
The RoutingPolicy implements Energy/Token Optimization:
- Expired messages →
Drop(no point processing stale data) - Alerts with high priority (>200) →
SendToLLM(critical path) - Events/State: Compute importance score → threshold check
- Score =
(priority / 255) * 0.5 + sfe_score * 0.5 - If score ≥ threshold →
SendToLLM - Else →
ProcessLocally
- Score =
- Commands/Queries →
ProcessLocally(unless complex)
Example: Importance Scoring
use RoutingPolicy;
let policy = default; // threshold = 0.7
// High priority event (fresh timestamp)
let high_priority_msg = with_qos;
let importance = policy.base_importance.unwrap;
// importance ≈ 0.8 → SendToLLM
// Low priority event
let low_priority_msg = with_qos;
let importance = policy.base_importance.unwrap;
// importance ≈ 0.3 → ProcessLocally
Features
serde(optional): Enable serde serialization support
[]
= { = "0.5.7", = ["serde", "transport"] }
Transport Integration
LNMP-Net provides standard header mappings for common protocols via the transport feature:
| Transport | Kind | Priority | TTL | Class |
|---|---|---|---|---|
| HTTP | X-LNMP-Kind |
X-LNMP-Priority |
X-LNMP-TTL |
X-LNMP-Class |
| Kafka | lnmp.kind |
lnmp.priority |
lnmp.ttl |
lnmp.class |
| NATS | lnmp-kind |
lnmp-priority |
lnmp-ttl |
lnmp-class |
| gRPC | lnmp-kind |
lnmp-priority |
lnmp-ttl |
lnmp-class |
Example: HTTP Headers
use ;
// Encode
let headers = net_to_http_headers?;
// Decode
let = http_headers_to_net_meta?;
Integration with LNMP Ecosystem
LNMP-Net seamlessly integrates with existing modules:
┌─────────────────────────────────────┐
│ LNMP-Net Layer │ ← MessageKind, Priority, TTL, Class
├─────────────────────────────────────┤
│ lnmp-llb │ lnmp-sfe │ lnmp-san │ ← LLM Bridge, SFE Scoring, Sanitize
├─────────────────────────────────────┤
│ lnmp-envelope │ ← Timestamp, Source, TraceID
├─────────────────────────────────────┤
│ lnmp-core │ ← LnmpRecord (data)
├─────────────────────────────────────┤
│ lnmp-transport │ ← HTTP, Kafka, gRPC, NATS
└─────────────────────────────────────┘
Advanced Usage
Custom Routing Policy
use RoutingPolicy;
// Very selective policy (high threshold)
let strict_policy = new
.with_always_route_alerts
.with_drop_expired;
// Permissive policy (low threshold)
let permissive_policy = new;
Message with Domain Class
use NetMessageBuilder;
let msg = new
.priority
.ttl_ms
.class // Domain classification
.build;
Architecture
See spec/lnmp-net-v1.md for complete specification.
License
MIT