P3: the mesh bridge (bridge => true, export => mesh, inbound forwarding, D25 on the bridge only) #7

Closed
opened 2026-12-02 11:46:23 +00:00 by uranus · 1 comment
Member

Purpose (feature): one node per LAN cluster is the mesh bridge. Only it holds a mesh pool, a D25 claim and mesh advertisements. It serves the capabilities a service exports to the mesh by forwarding each call into the LAN, and the other nodes reach the mesh through it.

DECIDED 2026-12-02 "I have created and cloned macula-services/mcl-core. Let's build this properly. In the end I hope we keep a single repo: mcl-core that will replace both mcl-om and mcl-lan" (Raf)
DECIDED 2026-12-02 "trust on sight. mcl-martha services should auto-cluster over LAN, no mcl-station required. Distributed Erlang offers us all we need." (Raf)
DECIDED 2026-12-02 "Shared cookie + secret (Recommended)" (Raf)

Design: docs/DESIGN.md §3 and §5, and §9 "What P1 left". Refs #3 (P2, the LAN transport this builds on). P4 (#4) runs in parallel.

Scope

A node with the lan app env off behaves exactly as today (1.9.0 behaviour): it is its own bridge and advertises everything it hosts.

On a node with the LAN on:

  1. bridge: a new app env, true on one node, default false. Only a bridge node starts the mesh pool (when seeds are set). The pool start moves from mcl_core_identity to the bridge side. A non-bridge LAN node is not refused for {mesh, required} without seeds or a realm, because the mesh is the bridge's.
  2. export => mesh on a capability: the bridge advertises on the mesh only exported capabilities, under today's <org>/<name> with the capability's own auth. These are the ones it hosts, plus those other cluster nodes host. Each node's served capability joins a pg export group carrying its spec without the handler, so the bridge learns them on its 30 s republish tick.
  3. Inbound: a LAN-served exported capability is advertised with a forwarding handler. Each mesh call goes into the LAN transport, with caller set to the mesh caller's node id as macula verified it. The serving member's guard pipeline runs with that caller. The guard runs once per call, not twice, so rate limits are not halved. An exported capability the LAN cannot serve (realm-bound auth, streamer) is advertised with its own handler, and only from the bridge node.
  4. Outbound: call_capability and publish already try the LAN first, then the bridge. On a non-bridge node, the bridge step is relayed to the bridge node over distribution. The mesh then sees the bridge's identity. With no bridge in the cluster, the answer is the one the bridge gives with no pool today.
  5. D25: the claim runs only on the bridge node, once per org that has at least one exported capability.
  6. Health: provider grants and advertise liveness exist only where advertising happens, so only the bridge's verdicts count. A non-bridge node is not degraded for having no mesh.

Out of P3 (named so nobody assumes it): mesh events are not republished onto the LAN. A mesh subscription runs only on the bridge node, for the bridge's own services. No tag: the 1.0.0 tag waits for Raf's yes via the Supervisor once P3 lands.

Files P3 touches (for the overlap check with P4)

  • src/contract/mcl_core_sup.erl: pool child only on a bridge (or LAN off); the bridge supervisor child.
  • src/contract/mcl_core_identity.erl: pool start moved out; mesh-required check skipped on a non-bridge LAN node.
  • src/contract/mcl_core.erl: claim per exported org; boot passes exports.
  • src/contract/mcl_core_service.erl: export in the capability type and docs.
  • src/bridge/mcl_core_bridge.erl: bridge/0, outbound relay, pool start.
  • src/bridge/mcl_core_capabilities.erl: advertise selection (exported only, with the LAN on), remote exports, forwarding handler.
  • src/bridge/mcl_core_claim.erl: orgs from remote exports, if needed.
  • NEW src/bridge/mcl_core_bridge_inbound.erl (the forwarding handler), src/bridge/mcl_core_bridge_sup.erl (the bridge's pg scope and relay).
  • src/lan/mcl_core_lan.erl: ONE new export, a LAN call made as a given caller (call_as/6). P4's entry point needs the same thing for a member's call, so P4 should reuse it rather than add a second one.
  • src/lan/mcl_core_lan_capability.erl: join the export group in init/1.
  • Tests: NEW test/mcl_core_bridge_SUITE.erl (peer nodes), eunit for the advertise selection and the relay; test/mcl_core_lan_SUITE.erl untouched.
  • docs/DESIGN.md §9 (appended), CHANGELOG.md.

P4 is expected in src/lan/ (entry point, members, tokens) and mcl_core_lan_sup.erl. P3 does not touch mcl_core_lan_sup.erl, mcl_core_lan_secrets.erl, mcl_core_lan_hosts.erl or mcl_core_lan_node.erl.

Done when

  • A LAN-off node advertises, claims and starts its pool exactly as on main (every existing test passes unchanged).
  • On a LAN-on node with bridge false, no mesh pool child is started, no claim is sent, nothing is advertised, {mesh, required} does not refuse boot for missing mesh settings, and /health is ok.
  • A bridge node advertises only export => mesh capabilities, its own and other nodes' (tested on the advertise selection; no real station).
  • A forwarded call reaches a member on another node with caller set to the given mesh caller, the payload's own caller overwritten, and the guard run once (peer-node test).
  • {callers, {nodes, Ids}} on a forwarded call is decided against the mesh caller, not the bridge's node id (peer-node test).
  • From a non-bridge node, a call with no LAN provider is relayed to the bridge node's mesh path, and to no_client with no bridge present (peer-node test with a stand-in mesh path).
  • The claim runs only on the bridge, for exported orgs only (unit test).
  • Mutants on the bridge/export/caller guards are caught (named in the HANDOFF).
  • docs/DESIGN.md §9 has "P3 as built" appended; CHANGELOG entry; no tag.
Purpose (feature): one node per LAN cluster is the mesh bridge. Only it holds a mesh pool, a D25 claim and mesh advertisements. It serves the capabilities a service exports to the mesh by forwarding each call into the LAN, and the other nodes reach the mesh through it. DECIDED 2026-12-02 "I have created and cloned macula-services/mcl-core. Let's build this properly. In the end I hope we keep a single repo: mcl-core that will replace both mcl-om and mcl-lan" (Raf) DECIDED 2026-12-02 "trust on sight. mcl-martha services should auto-cluster over LAN, no mcl-station required. Distributed Erlang offers us all we need." (Raf) DECIDED 2026-12-02 "Shared cookie + secret (Recommended)" (Raf) Design: docs/DESIGN.md §3 and §5, and §9 "What P1 left". Refs #3 (P2, the LAN transport this builds on). P4 (#4) runs in parallel. ## Scope A node with the `lan` app env `off` behaves exactly as today (1.9.0 behaviour): it is its own bridge and advertises everything it hosts. On a node with the LAN on: 1. **`bridge`**: a new app env, `true` on one node, default `false`. Only a bridge node starts the mesh pool (when seeds are set). The pool start moves from `mcl_core_identity` to the bridge side. A non-bridge LAN node is not refused for `{mesh, required}` without seeds or a realm, because the mesh is the bridge's. 2. **`export => mesh`** on a capability: the bridge advertises on the mesh only exported capabilities, under today's `<org>/<name>` with the capability's own `auth`. These are the ones it hosts, plus those other cluster nodes host. Each node's served capability joins a `pg` export group carrying its spec without the handler, so the bridge learns them on its 30 s republish tick. 3. **Inbound**: a LAN-served exported capability is advertised with a forwarding handler. Each mesh call goes into the LAN transport, with `caller` set to the mesh caller's node id as macula verified it. The serving member's guard pipeline runs with that caller. The guard runs once per call, not twice, so rate limits are not halved. An exported capability the LAN cannot serve (realm-bound auth, streamer) is advertised with its own handler, and only from the bridge node. 4. **Outbound**: `call_capability` and `publish` already try the LAN first, then the bridge. On a non-bridge node, the bridge step is relayed to the bridge node over distribution. The mesh then sees the bridge's identity. With no bridge in the cluster, the answer is the one the bridge gives with no pool today. 5. **D25**: the claim runs only on the bridge node, once per org that has at least one exported capability. 6. **Health**: provider grants and advertise liveness exist only where advertising happens, so only the bridge's verdicts count. A non-bridge node is not degraded for having no mesh. Out of P3 (named so nobody assumes it): mesh events are not republished onto the LAN. A mesh subscription runs only on the bridge node, for the bridge's own services. No tag: the 1.0.0 tag waits for Raf's yes via the Supervisor once P3 lands. ## Files P3 touches (for the overlap check with P4) - `src/contract/mcl_core_sup.erl`: pool child only on a bridge (or LAN off); the bridge supervisor child. - `src/contract/mcl_core_identity.erl`: pool start moved out; mesh-required check skipped on a non-bridge LAN node. - `src/contract/mcl_core.erl`: claim per exported org; boot passes exports. - `src/contract/mcl_core_service.erl`: `export` in the capability type and docs. - `src/bridge/mcl_core_bridge.erl`: `bridge/0`, outbound relay, pool start. - `src/bridge/mcl_core_capabilities.erl`: advertise selection (exported only, with the LAN on), remote exports, forwarding handler. - `src/bridge/mcl_core_claim.erl`: orgs from remote exports, if needed. - NEW `src/bridge/mcl_core_bridge_inbound.erl` (the forwarding handler), `src/bridge/mcl_core_bridge_sup.erl` (the bridge's `pg` scope and relay). - `src/lan/mcl_core_lan.erl`: ONE new export, a LAN call made as a given caller (`call_as/6`). **P4's entry point needs the same thing for a member's call, so P4 should reuse it rather than add a second one.** - `src/lan/mcl_core_lan_capability.erl`: join the export group in `init/1`. - Tests: NEW `test/mcl_core_bridge_SUITE.erl` (peer nodes), eunit for the advertise selection and the relay; `test/mcl_core_lan_SUITE.erl` untouched. - `docs/DESIGN.md` §9 (appended), `CHANGELOG.md`. P4 is expected in `src/lan/` (entry point, members, tokens) and `mcl_core_lan_sup.erl`. P3 does not touch `mcl_core_lan_sup.erl`, `mcl_core_lan_secrets.erl`, `mcl_core_lan_hosts.erl` or `mcl_core_lan_node.erl`. ## Done when - [ ] A LAN-off node advertises, claims and starts its pool exactly as on main (every existing test passes unchanged). - [ ] On a LAN-on node with `bridge` false, no mesh pool child is started, no claim is sent, nothing is advertised, `{mesh, required}` does not refuse boot for missing mesh settings, and /health is `ok`. - [ ] A bridge node advertises only `export => mesh` capabilities, its own and other nodes' (tested on the advertise selection; no real station). - [ ] A forwarded call reaches a member on another node with `caller` set to the given mesh caller, the payload's own `caller` overwritten, and the guard run once (peer-node test). - [ ] `{callers, {nodes, Ids}}` on a forwarded call is decided against the mesh caller, not the bridge's node id (peer-node test). - [ ] From a non-bridge node, a call with no LAN provider is relayed to the bridge node's mesh path, and to `no_client` with no bridge present (peer-node test with a stand-in mesh path). - [ ] The claim runs only on the bridge, for exported orgs only (unit test). - [ ] Mutants on the bridge/export/caller guards are caught (named in the HANDOFF). - [ ] docs/DESIGN.md §9 has "P3 as built" appended; CHANGELOG entry; no tag.
Author
Member

Landed: main e728bd5926 (fast-forward, PR 8). Review r=1 by Jupiter via Mars. PR CI on that tip: 6878-6881 green; 6882 is the accepted #2 scaffold-lint red. Main runs are being watched; this issue reopens on a red.

Done when:

  • LAN-off node unchanged: every existing test passes (ct 39/39 incl. mcl_core_SUITE, mcl_core_mesh_pool_SUITE, mcl_core_lan_SUITE; eunit 549/0).
  • Member with bridge false: no pool child (mcl_core_bridge_tests sup children), no claim (claim_test_, and a_member_with_seeds_runs_no_pool_and_no_claim), nothing advertised (advertised_sets_test_), {mesh, required} not refused (identity_test_ and the suite case, with a bridge refused as control), /health ok.
  • Bridge advertises only export => mesh, own and other nodes' (mesh_sets_test_, an_exported_capability_is_forwarded_with_the_mesh_caller).
  • Forwarded call reaches another node's member with the mesh caller, payload caller overwritten (an_exported_capability_is_forwarded_with_the_mesh_caller); guard runs once (the_guard_runs_once_on_a_forwarded_call).
  • {callers, {nodes, Ids}} decided against the mesh caller (a_forwarded_call_is_admitted_against_the_mesh_caller).
  • Member relays to the bridge (a_member_relays_its_mesh_traffic_to_the_bridge, stand-in mesh path on the bridge); with no bridge, the no-pool answer (with_no_bridge_a_member_answers_as_a_node_with_no_pool).
  • Claim only on the bridge, exported orgs only (claim_test_, the_bridge_claims_only_the_orgs_it_exports with a standalone control).
  • Mutants: 13/13 caught (pool on a member, role, inbound caller, bridge guard, mesh_sets filter, relay, claim init, identity mesh_mode, boot claim, export join, call_as caller, member advertise, boot republish).
  • docs/DESIGN.md §9 "P3 as built", guides/lan_transport.md "The bridge", CHANGELOG; no tag (1.0.0 waits for Raf's yes via the Supervisor).
Landed: main e728bd59268d8c4a1ff01ab9035b7ac86131a8aa (fast-forward, PR 8). Review r=1 by Jupiter via Mars. PR CI on that tip: 6878-6881 green; 6882 is the accepted #2 scaffold-lint red. Main runs are being watched; this issue reopens on a red. Done when: - [x] LAN-off node unchanged: every existing test passes (ct 39/39 incl. mcl_core_SUITE, mcl_core_mesh_pool_SUITE, mcl_core_lan_SUITE; eunit 549/0). - [x] Member with `bridge` false: no pool child (`mcl_core_bridge_tests` sup children), no claim (`claim_test_`, and `a_member_with_seeds_runs_no_pool_and_no_claim`), nothing advertised (`advertised_sets_test_`), `{mesh, required}` not refused (`identity_test_` and the suite case, with a bridge refused as control), /health `ok`. - [x] Bridge advertises only `export => mesh`, own and other nodes' (`mesh_sets_test_`, `an_exported_capability_is_forwarded_with_the_mesh_caller`). - [x] Forwarded call reaches another node's member with the mesh caller, payload `caller` overwritten (`an_exported_capability_is_forwarded_with_the_mesh_caller`); guard runs once (`the_guard_runs_once_on_a_forwarded_call`). - [x] `{callers, {nodes, Ids}}` decided against the mesh caller (`a_forwarded_call_is_admitted_against_the_mesh_caller`). - [x] Member relays to the bridge (`a_member_relays_its_mesh_traffic_to_the_bridge`, stand-in mesh path on the bridge); with no bridge, the no-pool answer (`with_no_bridge_a_member_answers_as_a_node_with_no_pool`). - [x] Claim only on the bridge, exported orgs only (`claim_test_`, `the_bridge_claims_only_the_orgs_it_exports` with a standalone control). - [x] Mutants: 13/13 caught (pool on a member, role, inbound caller, bridge guard, mesh_sets filter, relay, claim init, identity mesh_mode, boot claim, export join, call_as caller, member advertise, boot republish). - [x] docs/DESIGN.md §9 "P3 as built", guides/lan_transport.md "The bridge", CHANGELOG; no tag (1.0.0 waits for Raf's yes via the Supervisor).
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#7
No description provided.