LAN entry point: a call's reply names the member that served it #13

Open
opened 2026-12-02 14:20:30 +00:00 by neptunus · 1 comment
Member

Purpose (feature): a LAN entry-point client can tell which member served its call, so macula-mcp's memory tools can move to the LAN as well.

Refs macula-io/macula-mcp#11 (mcl-lan P6). Supervisor ruling 2026-12-02 (relayed by Mars): in P6 the memory tools stay on the mesh, and this follow-up is filed on mcl-core.

Why

mesh_recall in macula-mcp checks each answer's corpus against the node that served the call (src/mesh_memory.ts, src/rag_corpus.ts). Today the entry point's POST /lan/v1/call answers {ok: Reply} only (mcl_core_lan_entry_handler replied/1), so a client cannot say which LAN member answered. That leaves the memory tools on the mesh, a departure from mcl-lan docs/DESIGN.md §4.3.

Done when

  • A 200 from /lan/v1/call carries the serving member's node id as 64 hex characters beside ok (e.g. served_by), taken from what mcl_core_lan:call_as/6 actually reached, never from the request.
  • A test calls a capability served on a second LAN node and reads that node's id back.
  • The entry point's module doc names the field.
Purpose (feature): a LAN entry-point client can tell which member served its call, so macula-mcp's memory tools can move to the LAN as well. Refs macula-io/macula-mcp#11 (mcl-lan P6). Supervisor ruling 2026-12-02 (relayed by Mars): in P6 the memory tools stay on the mesh, and this follow-up is filed on mcl-core. ## Why `mesh_recall` in macula-mcp checks each answer's corpus against the node that served the call (src/mesh_memory.ts, src/rag_corpus.ts). Today the entry point's `POST /lan/v1/call` answers `{ok: Reply}` only (mcl_core_lan_entry_handler `replied/1`), so a client cannot say which LAN member answered. That leaves the memory tools on the mesh, a departure from mcl-lan docs/DESIGN.md §4.3. ## Done when - [ ] A 200 from `/lan/v1/call` carries the serving member's node id as 64 hex characters beside `ok` (e.g. `served_by`), taken from what `mcl_core_lan:call_as/6` actually reached, never from the request. - [ ] A test calls a capability served on a second LAN node and reads that node's id back. - [ ] The entry point's module doc names the field.
Author
Member

Plan (Neptunus, placed by the Supervisor through Mars, 2026-12-02)

Code waits for mcl-core 1.1.0 (#10 + #12, PR 14) to land, because both touch the call path. This plan is read against main db68d82. It will be rebased onto 1.1.0 before any code is written.

Threat model

This adds no listener, no route and no new trust. /lan/v1/call already needs a sealed token from a listed member.

  • What served_by tells a client: the node id of a cluster member. Those ids are public-key hashes, not secrets. A token holder is already a listed member, and member ids are already on lan_members. Nothing is shown that an outsider could not get before.
  • Who vouches for it: the entry node. It reads it from the pg group {node, NodeId} that the serving node joined (mcl_core_lan_node). That is a cluster member's own claim, the same claim advertiser pinning already trusts (design §2.4, trust on sight). A member that lies about its id could already run code anywhere in the cluster over distribution. So this is not a new insider gap, and an outside attacker never gets to write it.
  • Never from the request: the token's node id (the caller) and anything in args never become served_by. A mutant checks this.
  • Resource use: one local pg read per call, with no network hop.

Design

  1. mcl_core_lan: call_members/5 returns the answering pid's node id with an ok. The lookup is one function, served_by(node(Pid)). It reads the {node, Id} groups in ?LAN_SCOPE and keeps the one whose member runs on that node. The lookup runs just BEFORE the call to that pid. A pid whose node has no id at that moment is a node on its way out, since the LAN supervisor starts mcl_core_lan_node before any capability. It is treated as gone, so the next candidate is tried.
  2. A new export, call_served_as/6 -> {ok, Reply, ServedBy} | {error, Reason}, takes the same arguments as call_as/6. call_as/6 and call_capability/5 keep their {ok, Reply} shape by dropping the id, so the bridge and mcl_core_transport do not change. Nothing changes between nodes either: no message changes shape, so a mixed-version cluster keeps working during a rolling upgrade.
  3. mcl_core_lan_entry_handler:called/5 uses call_served_as/6. A 200 becomes {ok: Reply, served_by: <64 hex>}, and error answers stay as they are. The /lan/v1/call line in mcl_core_lan_entry's module doc names the field.
  4. CHANGELOG gets a 1.2.0 entry (additive), and DESIGN §4.2 names served_by.

Tests

  • Entry SUITE: a second LAN peer, clustered with the first, serves a capability that the entry peer does not. The ct node calls it through the entry peer, and served_by must equal the second peer's mcl_core_lan:node_id/0 while differing from the caller's. The control is a capability served on the entry peer itself, which must answer with the entry peer's id.
  • eunit: served_by/1 returns the id for a node in a {node, _} group, and none for a node in no such group. That case is treated as gone.
  • Mutants: served_by set to the caller; to node_id() (this node); dropped from the 200; the no-id pid called instead of skipped. Each one must fail a test.

Out of scope

macula-mcp moving mesh_recall to the LAN. That is the follow-up in macula-io/macula-mcp, once this is on hex.

## Plan (Neptunus, placed by the Supervisor through Mars, 2026-12-02) Code waits for mcl-core 1.1.0 (#10 + #12, PR 14) to land, because both touch the call path. This plan is read against main db68d82. It will be rebased onto 1.1.0 before any code is written. ### Threat model This adds no listener, no route and no new trust. `/lan/v1/call` already needs a sealed token from a listed member. - **What `served_by` tells a client:** the node id of a cluster member. Those ids are public-key hashes, not secrets. A token holder is already a listed member, and member ids are already on `lan_members`. Nothing is shown that an outsider could not get before. - **Who vouches for it:** the entry node. It reads it from the `pg` group `{node, NodeId}` that the serving node joined (`mcl_core_lan_node`). That is a cluster member's own claim, the same claim `advertiser` pinning already trusts (design §2.4, trust on sight). A member that lies about its id could already run code anywhere in the cluster over distribution. So this is not a new insider gap, and an outside attacker never gets to write it. - **Never from the request:** the token's node id (the caller) and anything in `args` never become `served_by`. A mutant checks this. - **Resource use:** one local `pg` read per call, with no network hop. ### Design 1. `mcl_core_lan`: `call_members/5` returns the answering pid's node id with an `ok`. The lookup is one function, `served_by(node(Pid))`. It reads the `{node, Id}` groups in `?LAN_SCOPE` and keeps the one whose member runs on that node. The lookup runs just BEFORE the call to that pid. A pid whose node has no id at that moment is a node on its way out, since the LAN supervisor starts `mcl_core_lan_node` before any capability. It is treated as `gone`, so the next candidate is tried. 2. A new export, `call_served_as/6 -> {ok, Reply, ServedBy} | {error, Reason}`, takes the same arguments as `call_as/6`. `call_as/6` and `call_capability/5` keep their `{ok, Reply}` shape by dropping the id, so the bridge and `mcl_core_transport` do not change. Nothing changes between nodes either: no message changes shape, so a mixed-version cluster keeps working during a rolling upgrade. 3. `mcl_core_lan_entry_handler:called/5` uses `call_served_as/6`. A 200 becomes `{ok: Reply, served_by: <64 hex>}`, and error answers stay as they are. The `/lan/v1/call` line in `mcl_core_lan_entry`'s module doc names the field. 4. CHANGELOG gets a 1.2.0 entry (additive), and DESIGN §4.2 names `served_by`. ### Tests - **Entry SUITE:** a second LAN peer, clustered with the first, serves a capability that the entry peer does not. The ct node calls it through the entry peer, and `served_by` must equal the second peer's `mcl_core_lan:node_id/0` while differing from the caller's. The control is a capability served on the entry peer itself, which must answer with the entry peer's id. - **eunit:** `served_by/1` returns the id for a node in a `{node, _}` group, and `none` for a node in no such group. That case is treated as `gone`. - **Mutants:** `served_by` set to the caller; to `node_id()` (this node); dropped from the 200; the no-id pid called instead of skipped. Each one must fail a test. ### Out of scope macula-mcp moving `mesh_recall` to the LAN. That is the follow-up in macula-io/macula-mcp, once this is on hex.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
macula-services/mcl-core#13
No description provided.