MAP Docs
Engine

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 tracing

What to read first

Code-property guarantees

The engine enforces a small set of properties at compile time:

  • #![forbid(unsafe_code)] — no unsafe blocks anywhere in the engine
  • #![deny(clippy::unwrap_used)] — no unwrap() in production paths
  • Feature-gated native vs WASM compilation (native-adapter vs wasm-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:

TierMechanismLatency overheadWhen to choose
Tier 1: NativeCompiled into the binary as a Rust crate implementing ProtocolModuleNoneFirst-party protocols; performance-critical paths
Tier 2: WASIWasmtime 37 component-model plugins loaded at runtimeModerate (sandboxed)Third-party protocols; marketplace extensions
Tier 3: ExternalHTTP-based; any language; any processHigher (network hop)Any service implementing the MAP invoke contract

See Plugins for manifest format, signing, and the hot-load lifecycle.

On this page