Learn

Architecture

One protocol engine, used unchanged by the HTTP gateway, the simulator and the browser sandbox, and the packages built around it.

On this page

The whole project hangs on one decision: the forwarder logic exists exactly once, in @idem/core, and everything else gives it something to run on. The production gateway, the simulator and the browser sandbox do not each implement the protocol. They run the same class with different links and a different clock (ADR-001).

Topology#

The smallest useful deployment is a star: agents, one edge forwarder, the producer. The experiments on multi-hop behaviour use a tree, with a regional forwarder between the edges and the producer.

Tree topology: four agents, two edge forwarders, one regional forwarder and the producer. Interests travel toward the producer and Data returns on the same path.agentsedge forwardersPIT · CS · FIBregional forwardercaches public Data onlyproducerruns tools, signs
The tree topology. An Interest climbs toward the producer and the Data comes back down the same path; any forwarder on the way that holds a fresh copy answers instead.
  • Agents are consumers. They speak plain MCP to the edge, or IDEM over HTTP if they use the verifying client.
  • The edge is each consumer's first hop. It is the only node that sees whose request it is, so it is the only one that keeps private Data, partitioned by authorization context.
  • A regional forwarder aggregates and caches across edges. It stores public Data only.
  • The producer runs the tools, names the results itself and signs them.

A call to a tool that is not cacheable does not take a different road. It travels the same links as a plain call, with no PIT entry and no cache entry, and each forwarder it crosses emits bypass.

Packages#

Package dependencies: gateway, sim and the planned ndn package depend on core; mcp depends on gateway and core; the web app uses mcp, gateway, sim and core.@idem/mcpapps/web@idem/gateway@idem/sim@idem/ndn@idem/coreWeb APIs only: browser, Node, Vercel, simulatorplanned (M6)MCP bindingsite, sandbox, demo routesHTTPsimulator
What depends on what. An arrow points from a package to the one it uses.
PackageResponsibilityRuns in
@idem/corenames, canonicalization, JCS, digests, signed Data and manifests, the trust store, the forwarder engine (PIT, CS, FIB) and its events, the clocks, a transport-agnostic Producer and the consumer helpersbrowser, Node, Vercel, simulator
@idem/gatewayIDEM over HTTP: a producer handler, an HTTP forwarder (edge or regional) and a verifying client. Everything is a Web-standard (Request) => Promise<Response>browser (client), Node, Vercel
@idem/mcpthe MCP binding: a producer and an edge as MCP endpoints, and verification of results received over MCPNode, Vercel
@idem/sima deterministic discrete-event simulator: topologies, links with delay, loss and bandwidth, seeded workloads, metricsNode (experiments), browser (sandbox)
@idem/ndnthe native binding over NDN (NDNts): name mapping, the Interest/Data codec, NDN Ed25519 signatures, a producer that wraps Producer and a verifying consumer. PIT and CS are the NDN forwarder'sNode, browser
apps/webthis site: landing page, sandbox, docs, results, and the demo producer and edge as routesVercel

The dependency rule is strict. core depends on nothing but Web APIs (WebCrypto, TextEncoder, fetch, URL) and imports no node:* module, which is what lets it run unchanged in a browser tab. sim, gateway and ndn depend only on core (ndn also on NDNts); mcp depends on core and gateway. Nothing depends on apps/web.

One engine#

The rules of protocol §7 live in one class, Forwarder. It is parameterized by everything that differs between environments:

ParameterProduction gatewaySimulator and sandbox
faces (Face: send, onReceive)an HTTP request per downstream, an HTTP client per upstreamvirtual links with delay, loss and bandwidth
clock (Clock)RealClock: wall time and platform timersVirtualClock: discrete events, deterministic for a seed
cs (ContentStore)MemoryContentStore, a byte-budgeted LRU; the interface allows another storethe same class
trust (TrustStore)manifests fetched from the producera manifest built in the run
onEventtraces returned to the caller in the idem-trace headerthe sandbox's canvas and log; the experiments' metrics

Because the clock is injected, a simulation does not sleep: it jumps from event to event. Because WebCrypto is asynchronous, VirtualClock awaits each timer's callback before running the next one, so signing and verifying never reorder events and a run with a given seed is reproducible.

The event stream#

Every observable action of a forwarder is a typed event. Nothing else is measured: the sandbox draws these events and the experiments count them.

EventEmitted when
interest_inan Interest arrives on a face
cs_hita fresh Data in the Content Store answers it (carries the Data's ageMs)
pit_aggregatethe name is already pending; the face joins the entry (carries the number waiting)
upstream_outa new PIT entry is created and the Interest is sent to the next hop
data_ina Data arrives from upstream (carries its size)
verify_ok, verify_failthe signature and content digest were checked (carries the time it took)
cs_insert, cs_evicta Data enters the Content Store, or leaves it to make room
pit_satisfythe Data is delivered to every waiting face (carries how many)
pit_expirea PIT entry's lifetime ran out; the waiters get TIMEOUT
dropan Interest or Data is discarded, with a reason (digest_mismatch, hop_limit, loop, unsolicited, ...)
bypassa call or Interest goes through without PIT or CS state, with a reason

Flows#

A miss, with aggregation#

Three agents ask for the same page at almost the same moment.

  1. Agent 1 calls fetch_page(url). The edge canonicalizes the arguments and computes the name N. The CS has nothing for N and the PIT has no entry: the edge creates one, looks up the producer in the FIB and sends the Interest upstream (upstream_out).
  2. Agent 2 calls fetch_page with an equivalent URL. Canonicalization yields the same name N. The PIT already has N: the edge adds agent 2 to the entry (pit_aggregate, 2 waiting). Nothing is sent.
  3. Agent 3 does the same (pit_aggregate, 3 waiting).
  4. The producer runs the tool once, computes N itself from the arguments, signs the result and returns the Data.
  5. The edge verifies the signature (verify_ok), stores the Data (cs_insert), delivers it to the three waiting faces (pit_satisfy, 3 faces) and removes the PIT entry.

A hit#

A fourth agent asks for the same page while the Data is still fresh. The edge computes N, finds a fresh Data in the CS and answers at once (cs_hit), with ageMs updated. The producer is not contacted. The agent still verifies the signature: a cache hit is not trusted more than a fresh answer.

A tool with a side effect#

send_email is not marked cacheable in the manifest. The consumer does not build an Interest for it; the call goes through the edge as a plain call and the edge emits bypass. Two identical send_email calls send two emails, as they should.

Bindings#

A binding is how names, Interests and Data are carried between nodes. The protocol defines two (protocol §9).

HTTP overlay#

Implemented in @idem/gateway and @idem/mcp. Every hop is an HTTP exchange, and the exchange itself correlates an answer with its request.

WhoRouteBody → response
producerGET /.well-known/idem.jsonthe signed manifest
producerGET /idem/v1/toolsthe tool list, in the shape of tools/list
producer, forwarderPOST /idem/v1/interestan Interest → a Data, or { code, message }
producer, forwarderPOST /idem/v1/call{ producer, tool, args } → a CallToolResult (passthrough)
forwarderGET /idem/v1/manifest/<producer>the manifest this node trusts
forwarderGET /idem/v1/tools/<producer>the producer's tool list, proxied

Three headers matter. Authorization: Bearer carries the end user's credential hop by hop to the producer. idem-forwarder marks a request sent by a forwarder; its absence tells a node that the sender is a consumer and that this node is its edge. idem-trace, on responses, lists the events the request caused at each hop: it is diagnostic only and never trusted.

Over MCP itself the same objects ride in _meta. A producer served by createMcpProducer returns the normal CallToolResult and attaches the signature under _meta["dev.idem/data"]. A client that does not know IDEM ignores _meta, so the binding is backward compatible. And an edge served by createMcpEdge is a plain MCP endpoint: any agent can connect to it and each tools/call enters the forwarder engine as a consumer request.

Native NDN#

Implemented in @idem/ndn (ADR-026); not yet run on NFD, which is the next step (Mini-NDN, E4). An IDEM name becomes an NDN name, one GenericNameComponent per part, and the Interest's ApplicationParameters carry the canonical arguments as JCS bytes. NDN appends its own ParametersSha256DigestComponent after the args-digest, so two equivalent calls get the same native name exactly when they get the same IDEM name. The Data's Content is the JCS envelope { content, meta, signature }, and the packet is also signed with NDN's Ed25519 by the producer's key, so a consumer checks both signatures. NFD's own PIT and Content Store do the aggregation and caching; because they key by name alone, with no authorization context, private tools never use this binding and stay on the overlay.

Where each piece runs#

ComponentLocallyDeployed
Demo producera route of the dev servera function: /api/producer/* (IDEM over HTTP and /api/producer/mcp)
Edge gatewaya route of the dev serverfunctions: /api/edge/* (IDEM over HTTP) and /api/mcp (plain MCP)
Simulator and enginethe browserthe browser: the sandbox costs the server nothing
Experimentslocal Node, Dockernot deployed

The API of each package is in the API reference.