Engine
The MAP engine — what dispatches requests, how protocols register, how middleware composes, how audit and metering thread through.
The MAP engine is the Rust runtime that dispatches every protocol call. It lives in engine/core/ and exposes a single, all-roads entry point: MapEngine::handle_request.
engine/
├── common/ # Trait + types shared across crates
│ ├── lib.rs # ProtocolModule trait, InvokeContext, Response, AuthContext
│ └── identity.rs# ResolvedAgentIdentity, AgentEntityKind, ConformanceLevel
├── core/
│ ├── engine.rs # MapEngine, the 8-stage pipeline, SecurityGateway, AuditPipeline
│ ├── router.rs # ProtocolRouter::invoke — caches modules, maps errors
│ ├── plugins/ # Manifest, WASM loader (Wasmtime 37), native + HTTP adapters
│ └── tests.rs # 716 lines of pipeline tests
├── identity/ # IdentityMiddleware::enrich + IdentityResolver trait
├── recipe/ # Recipe engine: typed DAGs with trust propagation
└── observability/ # MOTET sinks, OTEL, structured tracingWhat to read first
The 8-stage pipeline
Version Resolution → Context Enrichment → Rate Limiting → Security → Circuit Breaker → Load Balancing → Router → Result. Each stage with its module name and SLA.
handle_request
The canonical entry point. Signature, error model, return shape.
Types
HandleRequestInput, InvokeContext, ResolvedAgentIdentity, ProtocolModule trait, Response — quoted from the Rust source.
Router
ProtocolRouter caches modules in an LRU(1024). Best-version discovery. Error mapping.
Middleware
IdentityMiddleware::enrich runs before handle_request. ResolveOutcome and fallback semantics.
Audit pipeline
AuditPipeline::record. Event taxonomy. Async write semantics.
Recipe engine
Typed DAG composition with trust propagation and governance gates. Status: scaffolded.
Code-property guarantees
The engine enforces a small set of properties at compile time:
#![forbid(unsafe_code)]— nounsafeblocks anywhere in the engine#![deny(clippy::unwrap_used)]— nounwrap()in production paths- Feature-gated native vs WASM compilation (
native-adaptervswasm-adapter) - W3C Trace Context propagated through every
InvokeContext - Hierarchical wildcard security model (
map.{protocol}.{operation})
Tests live in engine/core/src/tests.rs (716 lines) and cover the full pipeline. 2,889 tests across 262 test files in the whole repo.
Extensibility tiers
Three tiers, ordered by performance and trust:
| Tier | Mechanism | Latency overhead | When to choose |
|---|---|---|---|
| Tier 1: Native | Compiled into the binary as a Rust crate implementing ProtocolModule | None | First-party protocols; performance-critical paths |
| Tier 2: WASI | Wasmtime 37 component-model plugins loaded at runtime | Moderate (sandboxed) | Third-party protocols; marketplace extensions |
| Tier 3: External | HTTP-based; any language; any process | Higher (network hop) | Any service implementing the MAP invoke contract |
See Plugins for manifest format, signing, and the hot-load lifecycle.