Recipes
Four reference recipes for common institutional patterns — grounded response, policy decision, service transaction, agent deployment.
A recipe in MAP is a typed DAG of protocol operations with explicit data flow, audit checkpoints, and governance gates. See the recipe engine for the type-level details.
The repo ships four reference recipes in DEFAULT_RECIPES.md. Each one is a complete institutional pattern.
1 — Grounded Response
Retrieve from MIND → reason with MARC → verify via MAVEN → audit to MAX.
This is the canonical "answer a question with citations" pattern.
Retrieve
const memories = await map.dispatch({
protocol: 'MIND',
operation: 'recall_memory',
input: {
kind: 'knowledge_graph',
subject: 'treaty_acme_globex',
limit: 20
}
});Reason
const verdict = await map.dispatch({
protocol: 'MARC',
operation: 'reasoning_task',
input: {
intent: 'Is the proposed treaty enforceable?',
premises: memories.results.map(m => m.uri),
world_model_snapshot: memories.snapshot_uri,
budget: { tokens: 16000, deadline_ms: 12000 },
return_fields: ['derivation', 'citations', 'confidence']
}
});Verify
for (const cite of verdict.citations) {
const attestation = await map.dispatch({
protocol: 'MAVEN',
operation: 'cite',
input: { source_ref: cite }
});
if (!attestation.valid) {
throw new Error(`citation invalid: ${cite}`);
}
}Audit
The engine has already recorded the calls — but you may add a structured audit at the recipe layer:
await map.dispatch({
protocol: 'MAX',
operation: 'audit_log_entry',
input: {
event_type: 'GroundedResponse',
meta: {
question: 'Is the proposed treaty enforceable?',
verdict: verdict.verdict,
citations: verdict.citations,
confidence: verdict.confidence
}
}
});2 — Policy Decision
Collect evidence via MAVEN → deliberate via MACE → consult MAXIM → enforce.
For decisions that bind the institution — treaty signing, policy amendment, charter-level changes.
Collect evidence
const evidence = await map.dispatch({
protocol: 'MAVEN',
operation: 'attest',
input: { sources: ['mars://record/0x...', 'mars://record/0x...'] }
});Convene a council
const motion = await map.dispatch({
protocol: 'MACE',
operation: 'convene',
input: {
motion: 'Approve treaty draft v2 with Globex',
composition_rules:{ min_delegates: 5 },
quorum: 'supermajority',
deadline_ms: 3600 * 1000
}
});Each delegate deliberates
// per-delegate
await map.dispatch({
protocol: 'MACE',
operation: 'deliberate',
input: {
motion_id: motion.motion_id,
position: 'yea',
reasoning: '...',
evidence: evidence.attestations
}
});Consult constitutional policy
const interpretation = await map.dispatch({
protocol: 'MAXIM',
operation: 'constitutional_interpretation',
input: {
motion: motion.motion_id,
bind_to: 'charter://v1.0.0'
}
});Tally + enforce
const verdict = await map.dispatch({
protocol: 'MACE',
operation: 'tally',
input: { motion_id: motion.motion_id }
});
if (verdict.passed) {
await map.dispatch({
protocol: 'MAXIM',
operation: 'mandate_enforcement',
input: {
mandate: verdict.binding_text,
authority: verdict.signatures,
effect: 'immediate'
}
});
}3 — Service Transaction
Advertise on MARKET → negotiate via MANA → settle via MADE.
The agent-to-agent commerce pattern.
Seller advertises
await map.dispatch({
protocol: 'MARKET',
operation: 'create_order',
input: {
side: 'ask',
asset: 'reasoning-service:marc',
price_usd: 0.50,
capacity: 1000,
expires_in_s: 3600
}
});Buyer bids
const bid = await map.dispatch({
protocol: 'MANA',
operation: 'bid_submission',
input: {
asset: 'reasoning-service:marc',
bid_usd: 0.45,
quantity: 10,
valid_for_seconds: 60
}
});Negotiate
Multi-round if needed:
await map.dispatch({
protocol: 'MANA',
operation: 'negotiation',
input: {
bid_id: bid.id,
counter: { price_usd: 0.48 },
round: 2
}
});Match + assign
const match = await map.dispatch({
protocol: 'MARKET',
operation: 'execute_trade',
input: { bid_id: bid.id, order_id: '...' }
});
await map.dispatch({
protocol: 'MANA',
operation: 'task_assignment',
input: { match_id: match.id }
});Settle
await map.dispatch({
protocol: 'MADE',
operation: 'economic_contract_settle',
input: {
contract_id: match.contract_id,
rail: 'x402',
amount_usd: 4.80
}
});4 — Agent Deployment
Bootstrap identity via MACS → register on MARS → submit manifest to MOON.
The "spin up a new agent worker" pattern.
Bootstrap identity
const identity = await map.dispatch({
protocol: 'MACS',
operation: 'auth_negotiation',
input: {
profile: 'DidAuth',
challenge_kind: 'Nonce'
}
});
const challenge = await map.dispatch({
protocol: 'MACS',
operation: 'generate_challenge',
input: { session_id: identity.session_id }
});
// (sign challenge with new agent's key — done client-side)
const verified = await map.dispatch({
protocol: 'MACS',
operation: 'verify_response',
input: { session_id: identity.session_id, signed_response: '...' }
});Register
await map.dispatch({
protocol: 'MARS',
operation: 'register_agent',
input: {
did: verified.agent_did,
capabilities: ['map.mind.recall_memory', 'map.marc.reasoning_task'],
service_endpoints: [
{ kind: 'did-auth', url: 'https://my-agent.svc/dispatch' }
]
}
});Submit manifest
await map.dispatch({
protocol: 'MOON',
operation: 'submit_manifest',
input: {
agent_did: verified.agent_did,
image: 'oci://registry.example.com/my-agent:v0.1.0',
replicas: 3,
resources: { cpu: 2, memory_mb: 4096 },
governance: { policy_ref: 'maxim://charter/v1' }
}
});Deploy
const deployment = await map.dispatch({
protocol: 'MOON',
operation: 'execute_workflow',
input: {
manifest_id: '...',
placement: 'closest-to-tenant',
health_check_grace_seconds: 30
}
});The recipe engine (engine/recipe/) can run these patterns as typed DAGs with trust propagation and durability. Until the engine wiring is complete, run the steps directly as shown.
Custom recipes
A custom recipe is a JSON document describing the DAG:
{
"id": "recipe-grounded-response-v1",
"steps": [
{
"id": "retrieve",
"kind": "Protocol",
"protocol": "MIND",
"operation": "recall_memory",
"payload": { "subject": "$input.subject" },
"depends_on": []
},
{
"id": "reason",
"kind": "Protocol",
"protocol": "MARC",
"operation": "reasoning_task",
"payload": {
"intent": "$input.question",
"premises": "$steps.retrieve.output.uris"
},
"depends_on": ["retrieve"]
},
{
"id": "verify_each_citation",
"kind": "Parallel",
"steps": [/* generated from $steps.reason.output.citations */],
"depends_on": ["reason"]
},
{
"id": "audit",
"kind": "Audit",
"event_type": "GroundedResponse",
"metadata": { "verdict": "$steps.reason.output.verdict" }
}
],
"audit_checkpoints": [
{ "step_id": "reason", "event_type": "ReasoningProduced", "include_step_io": true }
],
"governance_gates": []
}Submit:
await map.dispatch({
protocol: 'MAESTRO',
operation: 'graph.commit',
input: { recipe: /* the JSON above */ }
});MAESTRO will validate (Kahn's algorithm, type check, capability check) and only commit the recipe if it can be executed under the caller's capabilities.