Patent Pending: STARGA Inc. US Provisional Patent Application
MAP is a line-oriented protocol designed for AI agents to interact with MIND tooling. It enables agents to compile, patch, query, and validate IR modules via a simple request-response pattern.
Heads-up: there are two unrelated "MAP"s in the MIND ecosystem.
This page
MAP: Mind AI Protocol
The agent ↔ tooling wire protocol described below.
RFC 0014 / RFC 0016
MAP: Metadata-Attachment-Pair
The key/value epilogue on mic@2.1 compact IR and mic@3 binary IR that carries evidence-chain attestation (evidence_chain.trace_hash etc.). See /docs/mic + /docs/stability.
The collision is historical; the two surfaces serve different layers (agent protocol vs. IR provenance) and do not interact.
Design Principles
Line-oriented
Each request/response is a single line (with optional heredoc for large payloads)Sequence numbers
Every request has a sequence number for reliable correlation4.3x fewer tokens
than JSON-RPC for the same operations (measured on the reference benchmark below)Stateful sessions
Server maintains module state between requests
Benchmark: MAP vs JSON-RPC
| Protocol | Size (bytes) | Tokens | vs JSON-RPC |
|---|---|---|---|
| JSON-RPC | 1,004 | 251 | baseline |
| MAP | 234 | 58 | 4.3x fewer tokens |
Tokens, same session
- JSON-RPC251
- MAP58
Size in bytes, same session
- JSON-RPC1,004
- MAP234
On this benchmark session MAP saves 193 tokens compared to JSON-RPC, a 77% reduction in protocol token overhead for the same operations. Actual savings depend on session shape; large payloads (heredoc bodies) dominate either protocol.
Protocol Format
# Request format
@<seq> <command> [args...]
# Response format (success)
=<seq> ok [data...]
# Response format (error)
=<seq> err msg="<error message>"
# Response format (error, with a stable machine-matchable code)
=<seq> err code=<code> msg="<error message>"Commands
| Command | Description | Example |
|---|---|---|
| hello | Establish session, negotiate versions | @1 hello mic=1 map=1 |
| load | Load MIC module into session | @2 load <<EOF...EOF |
| patch | Insert/modify nodes in module | @3 patch after=N5 N6 relu N5 T0 |
| check | Validate current module | @4 check |
| dump | Export current module as MIC | @5 dump |
| query | Query node information | @6 query N5 |
| bye | Close session | @7 bye |
Example Session
@1 hello mic=1 map=1=1 ok version=1.0.0 mic=1 map=1 features=[patch,check,dump,query]@2 load <<EOF … EOF=2 ok nodes=3@3 patch after=N2 N3 mul N2 N2 T0=3 ok@4 check=4 ok valid=true nodes=4@5 dump=5 ok <<EOF … EOF@6 bye=6 ok
@n pairs with =n. Full transcript below.# Client establishes connection
@1 hello mic=1 map=1
# Server responds with capabilities
=1 ok version=1.0.0 mic=1 map=1 features=[patch,check,dump,query]
# Client loads a module
@2 load <<EOF
mic@1
T0 f32
N0 const.f32 1.0 T0
N1 const.f32 2.0 T0
N2 add N0 N1 T0
O N2
EOF
=2 ok nodes=3
# Client patches the module
@3 patch after=N2 N3 mul N2 N2 T0
=3 ok
# Client validates the module
@4 check
=4 ok valid=true nodes=4
# Client exports the module
@5 dump
=5 ok <<EOF
mic@1
T0 f32
N0 const.f32 1.0 T0
N1 const.f32 2.0 T0
N2 add N0 N1 T0
N3 mul N2 N2 T0
O N3
EOF
# Client closes session
@6 bye
=6 okSession Modes
Mode
strict
All operations validated immediately
Mode
lenient
Allow partial modules, validate on check
Error Codes
# Version mismatch
=1 err msg="version mismatch: server supports mic=1 map=1"
# Parse error
=2 err msg="parse error at line 3: unknown opcode 'foo'"
# Invalid reference
=3 err msg="invalid reference: N99 not defined"
# Validation error
=4 err msg="type mismatch: expected f32, got i64"Resource budgets
The MAP server is long-lived, stateful, and accepts untrusted input from agents. Because a session persists across many requests and holds a resident module in memory, the server enforces explicit, named budgets so a hostile or buggy peer cannot exhaust memory or CPU. Each is enforced with a structured error: the server never panics, aborts, or silently truncates.
| Budget | Default | Code |
|---|---|---|
| Single line size | 1 MiB | E101 |
| Heredoc body size | 16 MiB | E102 |
| Module node count | 1,000,000 | E103 |
| Patch operations per session | 100,000 | E104 |
Bounded parsing.
An oversized physical line is rejected before any command is dispatched, and the body of an over-budget heredoc is drained until its closingEOFso it is never reinterpreted as protocol commands.Pre-commit node check.
load.mic,patch.insert, andpatch.replacecount the candidate module's nodes and reject it before it becomes resident, so a rejected operation leaves session state unchanged.Per-session patch budget.
The counter is charged on every mutatingpatch.*call and reset to zero onbye.
These transport-layer codes live in their own space (E005 unknown command, E101–E104 budget rejections) and never overlap the four-digit E1xxx–E5xxx compiler diagnostics documented on the Errors page.
Running the MAP Server
# Start MAP server on stdio
mind-ai
# Start MAP server on TCP port
mind-ai --tcp 9999
# Connect with netcat
nc localhost 9999Integration with AI Agents
MAP is designed for integration with AI code assistants. The protocol enables agents to:
- Incrementally build neural network architectures
- Validate changes before committing
- Query existing module structure
- Export production-ready MIC files
Learn More
See the full MAP specification at RFC-0002: Mind AI Protocol.