mcl-lan: macula services on a LAN, the mesh as a bridge
View SourceUranus, 2026-12-02, for Raf through the Supervisor. Package macula-services/mcl-lan#1. Design only: no code, no release, no box touched.
Raf, 2026-12-02: "mcl-om is really shorthand for "macula over mesh". Frankly, I am desillusioned with the idea of Internet traffic "over mesh". [...] I would rather re-focus on macula as being a decentralized system for LAN operations. so, maybe we need an mcl-lan version of mcl-om?"
DECIDED 2026-12-02 "yes, let uranus write it. Also: I have created and cloned macula-services/mcl-lan. Let him use that repo to write things up" 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." DECIDED 2026-12-02 "Shared cookie + secret (Recommended)" DECIDED 2026-12-02 "Three for failover (Recommended)" IDEA (Raf, 2026-12-02, no yes yet): "should we rename mcl-om to mcl-comms and fold both "-om" and "-lan" into it?" (§8)
Read at origin/main:
| repo | commit |
|---|---|
| mcl-om | a8e35a1 (v1.9.0) |
| macula | f8a467a0 |
| mcl-kanban | 506c843 |
| mcl-whiteboard | 509c6c5 |
| mcl-rag | 42fb5cd |
| mcl-mail | 26ef0a8 |
| mcl-graph | 0305fd0 |
| mcl-scribe | b88e564 |
| mcl-stations | 12b164d |
| mcl-ledger | 5175cf6 (empty: README, LICENSE, .gitignore) |
| mcl-martha | 77a0a36 |
| macula-mcp | 2cb8721 (v0.51.6) |
| martha | 15d2b527 |
| lazymartha | 50c6663 |
| macula-realm | 4196d68 |
Paths are relative to each repo. "Unconfirmed" means it was not checked in code. The starting points were the Supervisor's note ANALYSIS_2026-12-02_mcl-lan_Supervisor.md and the consolidation analysis with its LAN addendum (mcl-martha#1).
0. The answer
- One library, two transports. Keep one library. Its LAN transport is the default; its mesh code becomes an optional bridge. Services keep the API they call today (
mcl_om:boot/1,mcl_om:call_capability/4,mcl_om_pubsub:publish/2, thecallerkey in each payload). The library picks the transport. - On a LAN:
- nodes find each other by macula's gossip;
- a capability is an OTP
pggroup; - a call is a message to a member of that group;
- pubsub is a
pgbroadcast; - the caller's node id is written into the payload by the transport, as macula writes it today. No station, no realm, no DHT.
- Services barely change. mail and scribe change nothing. rag's 44 wire-codec calls, whiteboard's 15 publishes and scribe's call to rag already go through the library and move with it. What changes is 9 direct macula call sites in 4 services (§5), once mcl-stations leaves the bundle.
- The mesh stays for what is outside the LAN: the realm, other sites and public directories. One node per cluster runs the bridge, chosen by a per-node setting.
- Non-BEAM clients (Martha, lazymartha, macula-mcp) reach the cluster through an HTTP entry point that every node serves on its private LAN address. A member whose node id the owner put on the cluster's member list proves its key and gets a 15-minute token. The entry point then calls as that member, so mail and kanban see the same
callerthey see today. Browser UIs stay on loopback until there is a sign-in. - mcl-stations leaves the LAN bundle. It is a directory of mesh stations, and it stays where the mesh is.
- One rename at most. If Raf renames the library (§8), it happens in the same major release that brings the LAN transport, so services move once.
1. The split of mcl-om: contract, LAN transport, mesh bridge
1.1 What mcl-om 1.9.0 already is
- Several services per node.
mcl_om:boot/1takes a list, and each boot adds a service (src/mcl_om.erl:45-57). That was §2.5 step 2 of the consolidation plan. It has landed. - The mesh is already optional. The pool is a supervisor child only when station seeds are configured (
src/mcl_om_sup.erl:83-86). With no seeds,mesh_handles/0answers{error, mesh_unavailable}(src/mcl_om.erl:367-372).{mesh, optional}is the default (src/mcl_om.app.srcenv;src/mcl_om_identity.erl:118). - A singleton on distributed Erlang already exists:
global:register_name/3(src/mcl_om_singleton.erl:134-136). It was A3 package 3; it has landed too. - The handler path does not depend on the transport. A capability's handler is wrapped by
mcl_om_guard_pipeline:wrapper/3(src/mcl_om_capabilities.erl:914-916). That wrapper runs the guard stages, thenMod:handle_request(Payload, State)(src/mcl_om_guard_pipeline.erl:64-80). Only its host, amacula_responsechild, is mesh-shaped (src/mcl_om_capabilities.erl:926-927). - The mesh-bound parts are:
- advertising a capability:
Provider:advertise_direct(...)(src/mcl_om_capabilities.erl:926) andmacula:put_record(:1087); - finding and calling one: a DHT lookup (
:1328), thenmacula:call_station/8(:1430); - the D25 claim:
macula:call(Pool, Realm, ?CLAIM_PROCEDURE, ...)(src/mcl_om_claim.erl:190); - the pool:
macula:connect/2(src/mcl_om_identity.erl:244); - subscribing:
macula:subscribe/5(src/mcl_om_pubsub_subscriptions.erl:418); - org membership:
macula:org_member/4(src/mcl_om_org_member.erl:78).
- advertising a capability:
1.2 Which module goes where
| part | modules (mcl-om src/) | change |
|---|---|---|
| Contract (core) | mcl_om (boot, the facade), mcl_om_app, mcl_om_sup (without the pool), mcl_om_service, mcl_om_health, mcl_om_health_handler, mcl_om_describe, mcl_om_info, mcl_om_guard, mcl_om_guard_control, mcl_om_guard_limits, mcl_om_guard_pipeline, mcl_om_guard_rate, mcl_om_guard_size, mcl_om_guard_stage, mcl_om_simple_handler, mcl_om_singleton, mcl_om_wire, mcl_om_ownership_proof, mcl_om_ownership_proof_replay, the identity key load in mcl_om_identity (:333-364), and the mcl_service template (priv/templates/) | mcl_om:call_capability/4,5 and mcl_om_pubsub:publish/2,3 become dispatchers: LAN first, then the bridge (§2.4). mcl_om_info reads claim labels (src/mcl_om_info.erl:77), which become optional. mcl_om_guard publishes its alerts through pubsub (src/mcl_om_guard.erl:247), so they reach the LAN as well. |
| LAN transport (new, default) | new: cluster start (gossip, cookie and secret), capability registry on pg, call, pubsub on pg, the HTTP entry point (§4) | new code, small (§2) |
| Mesh bridge (optional) | mcl_om_capabilities (advertise, DHT, call_station), mcl_om_claim, the pool start in mcl_om_identity (:244), mcl_om_pubsub and mcl_om_pubsub_subscriptions and mcl_om_pubsub_sup (the macula side), mcl_om_org_member, mcl_om_advertise_liveness, mcl_om_provider_grant, mcl_om_wire_test (the station codec) | runs only on a node with seeds and bridge => true (§3). Health counts its verdicts only there (src/mcl_om_health.erl:126-137). |
The library still depends on macula, even on a LAN without a station. It uses macula's node keys, signing and CBOR (e.g. mcl-kanban/.../realm_signature.ex:55), and macula's gossip. It does not start a pool, which 1.9.0 already allows (§1.1). The spike (mcl-martha/docs/spikes/lan-cluster.md:99-110) found the same: macula is loaded, but only gossip is started.
2. LAN transport on distributed Erlang
2.1 Discovery and trust
Proven in the spike (mcl-martha#2; mcl-martha/docs/spikes/lan-cluster.md:12-33):
- Distribution: plain
inet_tcp_dist. - Discovery:
macula_cluster:start_cluster(#{strategy => gossip, secret => S})(macula/src/macula_cluster_system/macula_cluster.erl:196-217, 241).- Gossip packets carry an HMAC over the node name, and a packet with a bad tag is dropped (
macula_cluster_gossip.erl:43-45, 407, 431). - A found peer is dialled with
net_kernel:connect_node(:540), and the Erlang cookie gates that dial.
- Gossip packets carry an HMAC over the node name, and a packet with a bad tag is dropped (
- Trust: under "Shared cookie + secret", the first node generates the cookie and the gossip secret into its data volume. The factory copies them to each further node at install. No approval step, no LAN TLS.
- The harm to name: a device that learns the cookie and the secret owns the cluster. Distributed Erlang runs any code on any node. The guard is the secret, not the LAN.
- Failover: two nodes give copies only. Losing either one blocks writes on both. Three nodes are needed to survive one going down (DECIDED "Three for failover";
reckon-db/guides/cluster_consistency.md:227-244).
The library takes over the spike's release settings:
- a LAN node name;
- distribution on the LAN interface with a fixed port range;
- epmd on the LAN;
- gossip started at boot.
The standalone per-service releases keep loopback (mcl-rag#32).
2.2 Capabilities and calls
- Register:
bootalready hands each capability's{Mod, Args}tomcl_om_capabilities:register/3(src/mcl_om.erl:81-85). On the LAN, the library starts one small host process per capability. That process runs the samemcl_om_guard_pipeline:wrapper/3as the mesh path does. It joins thepggroup{Org, Name}in one library scope. - Call:
mcl_om:call_capability(Org, Name, Payload, Timeout)keeps its signature (src/mcl_om.erl:304-306).- It reads
pg:get_members(Scope, {Org, Name}). - It prefers a local member, otherwise it picks one at random.
- It sends the payload with
gen_server:calland the timeout. - On
noprocornodedownit tries the next member once.erpcis not needed: the target is a process, not a function. With no member, the call goes to the bridge, if this node has one (§3). Otherwise it fails with{error, no_provider}.
- It reads
- Who may call: each capability names a caller policy (
src/mcl_om_service.erl:61-73).openand{callers, members}: every cluster node passes (trust on sight).{callers, {nodes, Ids}}: checked against the caller's node id (§2.4).{callers, role}: a realm role, which a LAN does not have. It is refused on the LAN and served only through the bridge.
- Payload shape: the mesh delivers a CBOR-decoded map, and
mcl_om_wiretolerates both its key shapes (src/mcl_om_wire.erldoc, lines 1-12). On the LAN the map travels as an Erlang term, so no codec runs. Services that read fields throughmcl_om_wire:fieldsee no difference. A handler that matches{text, Bin}keys directly would. Unconfirmed: the service count of such handlers. The LAN package's test runs each bundled service's own capability tests over the LAN transport, to find them.
2.3 Pubsub
- Publish:
mcl_om_pubsub:publish(Topic, Payload[, Opts])(exportssrc/mcl_om_pubsub.erl:26-29) sends to every member of thepggroup{topic, Topic}. - Subscribe: a service's declared
subscriptions/0(src/mcl_om_service.erl:130-135, 207) joins that group for each subscriber. - Source filters:
{org, Org}, as whiteboard uses (mcl-whiteboard/apps/.../whiteboard_topic.ex:31), andmembers: any cluster node passes.{nodes, Ids}: checked against the publisher's node id, carried with the event.
- Delivery: at most once, like
async_logon the mesh. Unconfirmed: whether any subscriber relies on the mesh's replay, so the LAN package must name it if it finds one. - Existing local fan-out stays: Phoenix.PubSub in kanban and whiteboard remains as it is, local on each node (e.g.
mcl-kanban/apps/project_boards/.../application.ex:65).
2.4 Caller identity
- Today: every service decides who is calling from the
calleratom key: 32 bytes, the node id of the key that signed the call, written by macula over anycallerthe payload sent.- mail:
mailbox_citizen.erl:30-33 - kanban:
actor.ex:90-98 - rag:
rag_operators.erl:49-52 - scribe:
record_lesson_responder.erl:15 - graph:
learn_link.erl:58-69 mcl_om_wire:caller/1:src/mcl_om_wire.erl:136-138
- mail:
- On the LAN, the transport writes
caller:- Node to node: the calling node's own mcl_om node id. Each node keeps its own identity key (
src/mcl_om_identity.erl:333-364), and two nodes must never share one. This value is self-asserted by a cluster member. That is no weaker than distributed Erlang itself, since any member can already run code on the callee. - Through the entry point: the member's node id, proven by its key (§4.2).
- Node to node: the calling node's own mcl_om node id. Each node keeps its own identity key (
- No service changes its identity code. The value means what it means today: the node id of a key whose holder is acting.
3. The mesh as an optional bridge
What still needs the mesh, by call site:
| need | where |
|---|---|
| the realm's crew standing (kanban) | mcl-kanban/apps/guide_card_lifecycle/lib/guide_card_lifecycle/crew_facts/crew_standing_reconciler.ex:103-108; crew facts subscribed from a pinned realm publisher (crew_facts.ex:82-90) |
| rag federation across sites | mcl-rag/apps/mcl_rag/src/serve_federated_query/join_federation.erl:78-86 |
| the station directory | mcl-stations/apps/mcl_stations/src/ingest_node_records/ingest_node_records.erl:107-137 (DHT records) |
| a provider that is not on the LAN, e.g. mcl-embedder | mcl-rag/apps/rag/src/rag_embed_mcl_embedder.erl:50 |
| D25 admission, org membership, realm roles | src/mcl_om_claim.erl:190, src/mcl_om_org_member.erl:78 |
| members off the LAN | macula-mcp today (§4) |
Who runs it. One node per cluster, named by a per-node setting (bridge => true plus station seeds). It is not moved by a singleton:
- The bridge holds a mesh identity. A station keeps one link per node id (
macula-station/.../macula_station_listener.erl:1191-1206, from the addendum), so the identity must stay on one box. - If the bridge node is down, the LAN keeps working and only the outside is cut off.
- A second bridge node, with its own key and admission, is the way to get failover, if that is ever wanted.
What it does:
- Outbound:
call_capabilityandpublishfall through to today's mesh code when no LAN member serves the name (§2.2). - Inbound:
- It advertises on the mesh only the capabilities a service marks
export => mesh, under today's org/procedure names. - It forwards each mesh call into the LAN transport, with
callerset to the mesh caller's node id as macula verified it. - The guard pipeline runs at the bridge, the one place strangers come in.
- It advertises on the mesh only the capabilities a service marks
- D25: only the bridge node is admitted, once per exported org. Today every node needs a claim per org (
src/mcl_om_claim.erl:1-22). The other nodes need none.
Beyond one LAN (IDEA, the Supervisor's note): a remote node can join over WireGuard and be on the LAN, so no bridge is needed. That is a deployment choice, not code in this design.
4. The LAN entry point for non-BEAM clients
4.1 Who needs it, and what they use today
| client | today |
|---|---|
| Martha (TS) | crew mail and memory go through macula-mcp's mesh_call as the member (martha/src/claude_code_relay/hooks/call_the_mesh_as_the_member.ts:1-27; src/exchange_crew_mail/exchange_crew_mail.ts:1-41; src/keep_crew_memory/keep_crew_memory.ts:1-30, martha#45) |
| macula-mcp (TS) | stdio MCP server, one mesh pool under one member key, dialling stations (src/index.ts:24, 292; src/connect_to_mesh.ts:1-40; src/mesh_config.ts:146-157) |
| lazymartha (Go) | no network code (go.mod:1-24); it will need the crew room (lazymartha#6 design) |
| browsers | kanban and whiteboard LiveView on loopback, with no login ("acts as the owner", mcl-kanban/config/runtime.exs:102-111; mcl-whiteboard/config/runtime.exs:92-111) |
| scripts | rag's HTTP API on loopback, no auth, and HTTP deposits carry no caller (mcl-rag/apps/mcl_rag/src/serve_http_api/mcl_rag_http_guard.erl:5, 23; add_knowledge_api.erl:1-27) |
4.2 The entry point
- Where it runs: every node serves one HTTP listener, from the library. cowboy is already a dependency (
src/mcl_om.app.src;src/mcl_om_sup.erl:130). - What it binds to:
- The same LAN address that distribution uses (§2.1), on one fixed port.
- Never
0.0.0.0or::. - At start, the library checks that this address is private: 10/8, 172.16/12, 192.168/16, fc00::/7 or link-local. If it is not, as on a VPS or hosted node whose only address is public, neither distribution nor the entry point starts on it. The node runs standalone, with services on loopback and the mesh as today. Its health says why, by name.
- A VPS node joins a LAN cluster through a WireGuard address, which is private (§3, "Beyond one LAN").
- Calls:
POST /lan/v1/callwith{org, procedure, args}. The body goes throughmcl_om:call_capability/4(§2.2), so the guard pipeline and the capability's caller policy apply as on any other path. - Events:
GET /lan/v1/events?topic=...streams pubsub events (server-sent events). The crew room and mail notices need this. - Who may mint a token: only a key on the cluster's member list.
- The list: a file
lan_membersin each node's data volume, holding one member node id per line, each with a role (ownerormember). - How it is written: by the same install step that copies the cookie and the gossip secret (§2.1, DECIDED "Shared cookie + secret"). The owner's key-making step for a member (
martha/src/read_a_members_mesh_key/read_a_members_mesh_key.ts:1-23) adds a line, and the factory copies the file to every node. - Removing a member is the same step in reverse. A token already issued to it stops working at its next call, because every call checks the list (below).
- What this changes:
martha joinstays as it is for the realm path, but a crew on the LAN gets one new step in the owner's key-making: recording the member's node id inlan_members. That step belongs to P7.
- The list: a file
- How a member gets a token:
- The member already has an ML-DSA key: macula-mcp's per-member key file (
macula-mcp/src/mesh_config.ts:146-157). POST /lan/v1/challengewith its node id. A node id that is not on the list is refused here. The node answers with 32 random bytes, kept in that node's memory for 60 seconds and deleted on first use, so a signed challenge can be redeemed only once, and only at the node that issued it.POST /lan/v1/tokenwith the challenge signed by the member's key. The node checks the signature against the public key (its SHA-256 is the node id), checks the list again, and issues the token.
- The member already has an ML-DSA key: macula-mcp's per-member key file (
- The token:
- It holds the node id, the role, the time it was issued and its expiry.
- It is sealed with HMAC-SHA256 under a cluster-wide token key derived from the gossip secret by HKDF (label
mcl-lan token v1). Any node can verify a token another node issued, and no new secret has to be handed out. - Lifetime: 15 minutes. After that the client asks for a new challenge.
- Every node also checks the list on each call, so a member removed from the list loses access at the next call, not at expiry.
- What the caller policies mean for an entry-point call:
- Every call through the entry point carries a token. A request without one is refused, whatever the capability's policy,
openincluded. calleris the token's node id.{callers, members}: a node id onlan_members. That is the LAN's counterpart of "a realm member" (src/mcl_om_service.erl:61-73).{callers, {nodes, Ids}}: that node id is inIds.{callers, role}: refused on the LAN, as in §2.2.- Node-to-node calls (§2.2) are not entry-point calls. They hold the cookie, so they pass
members.
- Every call through the entry point carries a token. A request without one is refused, whatever the capability's policy,
- Who may do what beyond that stays where it is today: the kanban roster, mail's mailbox owner, rag's operator list.
- The harms to name (beside §2.1's cookie and secret):
- A guest device on the LAN that is not on
lan_memberscannot get a challenge, so it cannot get a token and reaches no procedure. - Under trust on sight there is no TLS. A device that sniffs the LAN can replay a member's token for up to 15 minutes, or until that member is removed from the list. It cannot reuse a signed challenge, because each challenge is single-use. That is the same class of harm as the cookie, and it is bounded by the token's lifetime.
- Whoever holds the gossip secret can forge tokens, because the token key derives from it. That device already owns the cluster through the cookie (§2.1), so no new harm.
- A guest device on the LAN that is not on
4.3 Each client
- macula-mcp gets a LAN backend:
MACULA_LAN_ENTRY=http://<node>:<port>instead of stations.mesh_call, the memory tools and the watch tools go to the entry point, signed with the same key.- Martha's hook calls
mesh_callthrough macula-mcp (call_the_mesh_as_the_member.ts:67), so Martha changes only its mesh declaration (martha/src/declare_crew/the_crews_workspace.ts:60-85): an entry address instead of stations. - The rule "one process, one link, one key" (
call_the_mesh_as_the_member.ts:4-9) does not bind on HTTP. It still holds for macula-mcp's mesh mode.
- Martha's hook calls
- lazymartha: plain HTTP from Go to the same endpoint, with the owner's key. This folds into the lazymartha#6 package list that Raf ruled on 2026-12-02.
- Browsers: the Phoenix UIs stay on loopback.
- The harm, if they moved: kanban and whiteboard have no login and act as the node's owner (
mcl-kanban/config/runtime.exs:102-104;mcl-whiteboard/config/runtime.exs:96). On the LAN, any device would hold owner powers over both. The host and origin allow-list (mcl-whiteboard/config/runtime.exs:97-108) does not stop a device that sends the right Host header. - So nothing changes for browsers. The owner reaches the UIs through their own tunnel, as today (
mcl-kanban/config/runtime.exs:102-104), or through lazymartha over the entry point. - Opening the UIs to the LAN waits for a browser sign-in. That could be the entry point's challenge and token carried in a cookie, or a realm's sign-in (§6.2). It is not in this design or its packages.
- The harm, if they moved: kanban and whiteboard have no login and act as the node's owner (
- rag's own HTTP API stays on loopback for operators. LAN clients use the entry point, which carries a caller.
- MCP over HTTP (an agent with no macula-mcp) can come later, on the same listener. The one Erlang candidate seen is
beam-campus/barrelapps/barrel_server/src/barrel_server_mcp.erl:1-18(Streamable HTTP, bearer auth). Its licence and packaging are unconfirmed. It is not in the package list.
5. What each service changes
Counted call sites, non-test code. "Through the library" means the call already goes through mcl_om* and moves with the transport, with no change at the call site. "Direct macula" means the service calls macula itself and must change.
| service | through the library (no change) | direct macula, transport-bound (changes) | other macula use (libraries, no change) |
|---|---|---|---|
| mcl-kanban | boot 1 (apps/mcl_kanban/lib/mcl_kanban/application.ex:15); wire 1 wrapper, about 59 uses (apps/mcl_kanban/lib/mcl_kanban/wire.ex:20); declared subscriptions (service.ex:191) | 1: :macula.call to the realm's crew_standing (crew_standing_reconciler.ex:107-108) → mcl_om:call_capability with a realm target, served by the bridge | topic builders, CBOR, node keys, signed objects: 9 (crew_fact.ex:80, 109; realm_signature.ex:55, 77, 80; crew_approval.ex:56, 69, 72, 80, 147) |
| mcl-whiteboard | boot 1; 15 publishes via mcl_om_pubsub:publish (e.g. board_lifecycle_v1_to_mesh.ex:72); declared subscriptions (service.ex:74-90) | 2: request and reply through ad-hoc :macula_subscriber.start_link plus mesh_handles (get_board_snapshot_by_id_over_mesh.ex:34, 47; list_boards_over_mesh.ex:23, 36) → mcl_om_pubsub reply subscriptions, or a capability call. 1 env read: Application.fetch_env!(:mcl_om, :org) (whiteboard_topic.ex:33), already C6 in the consolidation plan | macula_topic.app_fact 1 |
| mcl-rag | boot 1; wire 44 (e.g. mcl_rag_mesh_rpc.erl:167); embedder call 1 (rag_embed_mcl_embedder.erl:50); capabilities by callback (mcl_rag_service.erl:68-93) | federation (5 lines): macula_rag configure, register_responder, advertise, status, and mcl_om:macula_client (join_federation.erl:37, 78-86) → started only on the bridge node | macula_rag:sign_corpus and corpus_hash (describe_corpus.erl:46, 74); node keys (:37-39) |
| mcl-mail | boot 1 (mcl_mail_app.erl:30); wire 15; caller 1, used by 7 responders (mailbox_citizen.erl:30) | 0 | 0 |
| mcl-graph | boot 1; publish 1 (mcl_graph_facts.erl:47); wire 14; caller and ownership proof 5 (learn_link.erl:59-74) | 1: macula:subscribe(..., #{sources => members}) after mesh_handles (learn_truths_from_mesh.erl:65, 102) → a declared subscription. mcl_om:realm() 2 (learn_link.erl:64, mcl_graph_facts.erl:83): the ownership proof needs a realm. On the LAN it is checked only for calls that came through the bridge. | macula_topic 1 |
| mcl-scribe | boot 1; call to rag 1 (lesson_knowledge.erl:29); wire 2; caller 1 | 0 | 0 |
| mcl-stations | boot 1; wire 7 | 5: subscribe_records ×3, find_records_by_type, macula_client:status (ingest_node_records.erl:107-137): the DHT itself | record codec 12 |
| mcl-ledger | none (empty repo) | – | – |
Totals:
- Transport-bound direct macula calls:
- kanban 1, whiteboard 2, graph 1, rag 5 lines of federation (bridge only), stations 5 (which leave, below).
- Without stations, the bundle changes 9 call sites in 4 services.
- Small config reads: whiteboard's
:mcl_om, :orgread, and graph's realm-scoped ownership proof. - Test lines that touch mcl_om or macula (counted, not classified): kanban 25, whiteboard 10, rag 25, mail 19, graph 25, scribe 12, stations 35.
pg already in rag: rag_app.erl:17-20 starts a pg scope that nothing joins outside tests. The LAN transport uses its own scope, so the two do not meet.
mcl-stations:
- It is a "live, filterable directory of macula stations" built from DHT records (
mcl-stations/README.md:18, 29-38), with one open procedure,list_stations(mcl_stations_service.erl:20, 89). - Its readers are mesh clients:
- the macula SDK's pool bootstrap (
macula/src/client/macula_client.erl:174, 391, 413, 625-631); - macula-mcp
mesh_list_stations(src/mesh_stations.ts:32); - martha's room gate (
martha/src/read_a_room_through_its_gate/read_a_room_through_its_gate.ts:105).
- the macula SDK's pool bootstrap (
- On a LAN it has nothing to list. It leaves the mcl-martha bundle and stays on the public fleet beside the stations, unchanged.
6. Effect on other work
6.1 The clustered-release run (A3 and §2.5 of mcl-martha#1)
| step | state | effect of this design |
|---|---|---|
| A3 1: LAN spike | done (mcl-martha#2, main 386c497) | its release settings move into the library (§2.1) |
| A3 1b: reckon-db must not wipe a store on join | open (Neptunus) | none: still before store mode |
A3 2: store mode from config | waits on 1b | none |
| A3 3: singleton helper | done (mcl_om_singleton, 1.9.0) | none |
| A3 4: side effects as singletons | open | none. The bridge-only work (rag federation, kanban's realm reconciler) runs on the bridge node instead of under a singleton. |
| A3 5: evoq routes one aggregate id to one node | open | none |
| A3 6: rag and graph on one node, reached "over the mesh, through a station" | held for this design | replaced. rag and graph register on the LAN only on the node that holds their volume, and callers reach them through pg (§2.2). No station. |
| §2.5 step 2: multi-service boot | done (1.9.0, src/mcl_om.erl:45-57) | none |
| §2.5 step 3: per-service changes | open | adds the §5 changes to each service's package |
| §2.5 step 4: the clustered release (mcl-martha#6) | parked | builds on the LAN transport (P2 below), with no station in its compose file. Self-hosting gets simpler: one image, ollama, and no station unless a bridge is wanted. |
| per-node, per-org D25 admission | needed today | only the bridge node, once per exported org (§3) |
6.2 Hosted realms (no decision proposed)
- What a realm provides today (
macula-realm/README.md:3-9):- realm lifecycle and key rotation;
- member admission and revocation, with invites;
- D25 provider authorization;
- station links;
- sign-in to sites through the realm (a UCAN token over Hanko).
- What changes in a LAN-first Macula:
- Inside a LAN no node needs the realm. Members are proven by their keys at the entry point (§4.2), and nodes by the cookie.
- The realm is needed for:
- the bridge's admission;
- members who work off the LAN through the mesh;
- cross-site sign-in for people and devices;
- the crew standing that kanban reads (§3).
- Seats: the handover logs count every admitted member and device as a seat (unconfirmed in the realm README). Under this design, members on a LAN are never admitted, so a seat would count only what crosses the bridge.
- What a team buys would shift towards the bridge and cross-site identity. Paid go-live already waits on the benefits transition, so nothing here blocks or changes a date.
7. Packages
In order. Each lands on review PASS and green. Repo names are today's; the rename (§8) changes only the library's repo and name.
| # | repo | what | size |
|---|---|---|---|
| P1 | macula-services/mcl-om | Split behind a transport boundary: contract, LAN, bridge (§1.2). The mesh code stays as it is, behind the bridge side. No behaviour change: every existing test passes. | M |
| P2 | macula-services/mcl-om | LAN transport: cluster start (gossip, LAN distribution, cookie and secret generated into the data volume), pg capabilities and calls with caller written (§2.2, §2.4), pg pubsub (§2.3). call_capability and publish try the LAN first. Two-node tests with peer nodes and a TTL of 0, as in the spike. This is the major release that carries the rename, if Raf picks one (§8). | L |
| P3 | macula-services/mcl-om | Bridge: bridge => true, export => mesh, inbound forwarding with the mesh caller, outbound fall-through, D25 only on the bridge (§3). | M |
| P4 | macula-services/mcl-om | LAN entry point: a private-address bind check, lan_members, a single-use challenge, an HMAC token (15 min) under a key derived from the secret, POST /lan/v1/call and the event stream (§4.2). Tests: a key that is not on the list gets no challenge; a challenge is redeemed only once; a removed member is refused at the next call; a public address starts no listener. | M |
| P5 | mcl-kanban, mcl-whiteboard, mcl-graph, mcl-rag | The §5 changes, folded into each service's §2.3 package: kanban 1, whiteboard 2 + 1, graph 1 + 2, rag federation on the bridge. | S each |
| P6 | macula-io/macula-mcp | LAN backend: MACULA_LAN_ENTRY, token signing, events (§4.3). | M |
| P7 | martha-ai/martha | The mesh declaration accepts an entry address (§4.3), and the owner's key-making step records the member in lan_members for the factory to copy (§4.2). | S |
| P8 | martha-ai/lazymartha | The crew room and calls through the entry point, folded into the lazymartha#6 packages. | S (inside lazymartha#6) |
| P9 | martha-ai/mcl-martha | The clustered release (mcl-martha#6) on P2-P5: no station in compose, mcl-stations out of the bundle. | as #6 |
- P1 and P2 come before A3 packages 4 and 6 build on them.
- P3 and P4 can run in parallel after P2.
- P6 and P7 follow P4.
- The C4 model of this design is in
assets/mcl-lan-context.svgandassets/mcl-lan-container.svg, shown inREADME.md.
8. The rename (IDEA, Raf picks)
Raf asked, 2026-12-02: "should we rename mcl-om to mcl-comms and fold both "-om" and "-lan" into it?" This design already folds them: one library, LAN by default, mesh as bridge (§1). What is left is the name.
8.1 What a rename costs (counted 2026-12-02)
| what | count | source |
|---|---|---|
repos that depend on mcl_om | 32, all in macula-services (agora ... whiteboard) | grep for {mcl_om, / :mcl_om, in each rebar.config and mix.exs |
mcl_om* references in those repos (source, config and tests) | 3,995; most per repo: rag 266, echo 242, mail 198, graph 185, tube 183, tenders 182 | the same grep over *.erl, *.ex, *.exs, *.src, *.hrl, *.config, *.eex, without _build and deps |
mcl_om* references in mcl-om itself (src, test, priv) | 1,616 | same |
| mcl-om Markdown files that name it | 133 | grep -l |
| other repos naming it in prose (macula, macula-mcp, martha, lazymartha) | 21 files | grep -l |
| mcl-corpus files naming it | 28 | grep -l, mcl-corpus 5787ff0 |
| hex package | {hex, [{name, mcl_om}, ...]} (rebar.config:148-149). A new name is a new hex package; mcl_om stays published for whoever pins it | rebar.config |
| rebar template | mcl_service (priv/templates/, scripts/install-templates.sh) generates mcl_om deps and calls | README.md:54, 307, 337 |
| module prefix | 30 modules mcl_om* (29, plus the test helper mcl_om_wire_test) | src/ |
- The work is mechanical: dependency name, module prefix and app env key, by sed. But it touches every one of the 32 repos and their tests.
- Every reference is a line that an older test or doc may still read. The CHANGELOG keeps old names as written (
rebar.config:167).
8.2 When, so services move once
- Only in P2's major release, or not at all. P2 already makes every bundled service take a new major (the LAN transport). Renaming then means one dependency change per service, not two.
- The seven bundled services move with the clustered-release run (§6.1), which touches each of them anyway.
- The other 25 repos move when someone next touches them.
mcl_om1.x stays on hex and keeps working mesh-only, so nothing breaks while they wait. - A rename after P2 would make the bundled services move a second time. That is the outcome to avoid.
8.3 The repos
- Rename the mcl-om repo itself, so its 334 commits of history stay (
git logcount). A forgejo rename keeps issues and PRs. Whether it redirects the old URL is unconfirmed, so a pinnedgitdependency on the old URL must be checked before the rename. - mcl-lan: this design lands here first, as Raf asked. After P1, the design moves into the renamed library's
docs/and mcl-lan is archived, so there are not two homes.
8.4 Naming note
The library holds the service contract (boot, health, info, describe, the scaffold template) as well as the comms (LAN transport, bridge), so a comms-only name undersells half of it. Three names to put to Raf:
| name | says | against |
|---|---|---|
mcl-comms (Raf's) | the transport, which is the change | not the contract, health or scaffold |
mcl-node | what it makes: a macula service node, with its contract, identity and transports | close to macula's own "node" vocabulary (node id, node keys) |
mcl-service | the contract every service implements (mcl_om_service already) | close to macula-services, the org's name |
mcl-core, mcl-node and mcl-comms are free in macula-services and macula-io (directory listing). Hex availability is unconfirmed, since nothing was asked of hex.pm.
9. Since this design landed (appended 2026-12-02)
This design was written and reviewed in macula-services/mcl-lan (#1, landed at 4020832) and moved here unchanged above this section.
- The library is mcl-core. DECIDED 2026-12-02 (Raf): "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". The Supervisor ruled the names (Raf may overrule): app and hex package
mcl_core, module prefixmcl_core_*, a fresh 1.0 line. - §8 is answered and its repo plan is void. mcl-core carries mcl-om's history (merged with
--allow-unrelated-histories), so the mcl-om repo is not renamed. After the firstmcl_corerelease, mcl-om and mcl-lan are archived with a README pointer here. - Where §7 says
macula-services/mcl-om, readmacula-services/mcl-core. P1 is macula-services/mcl-core#1. P2, the LAN transport, is the firstmcl_corehex release. - A3 package 6 is closed as replaced. rag and graph go over the LAN in P5.
- What P1 left for later. P1 moved the pool start with the rest of
mcl_core_identityintosrc/contract/; it moves to the bridge with P3 (bridge => true). Services' directmcl_core_pubsub:publish/2,3calls point atmcl_core_transport:publish/3in P2, once there is a LAN publish to try first. - P2 as built (mcl-core#3). The LAN transport is off until a release sets the
lanapp env, so a node that does not cluster behaves as mcl_om 1.9.0 did. Beyond §2:- The cookie is set from the data dir by mcl_core (
erlang:set_cookie/1), not read from$HOME, so the release only has to be distributed. - A node refuses to start on the LAN without a stable identity key: its node id is the
callerit writes. handler_authorizesjoins{callers, role}as mesh only: the token it checks is the realm's.- LAN events carry
publisher_verified => true. Services that take only verified publishers (mcl-graphlearn_truths_from_mesh.erl:137, mcl-agoraon_agora_post_published_from_mesh_maybe_record_agora_post.erl:73) would drop every LAN event otherwise; the flag means whatcallermeans on the LAN (§2.4). - Each LAN call runs the handler's
init/1andhandle_request/2in a process of its own, asmacula_responsedoes on the mesh.
- The cookie is set from the data dir by mcl_core (
- P3 as built (mcl-core#7). The bridge is the node with the app env
bridgeset totrue, beside itslanmap. With the LAN off, a node is its own bridge, as in 1.9.0. Beyond §3:- A non-bridge LAN node (
member) runs no pool, no claim and no advertisement whatever its seeds, and{mesh, required}asks nothing of it. Its mesh calls and publishes are relayed to the bridge node over distribution (mcl_core_bridge:bridge_node/0, apgscope of its own on every LAN node). - Each served
export => meshcapability joins apggroup carrying the capability without its handler. On its republish tick (70 s), the bridge advertises every one withmcl_core_bridge_inbound, which forwards the mesh call throughmcl_core_lan:call_as/6with the mesh caller. - The guard runs at the serving member, not at the bridge. It counts the mesh caller there, so a forwarded call is counted once. Guarding at the bridge as well would count a call served on the bridge node twice, and halve its limits.
- An exported capability the LAN does not serve (realm-bound
auth, streamer, record only) is advertised with its own handler, and only from the bridge node's own services. - The bridge claims each org it advertises an exported capability for, and no other org. Grant and liveness rows of a capability whose node left are dropped on the next run, so they do not degrade /health.
- Not in P3: mesh events are not republished onto the LAN.
- A non-bridge LAN node (
- P4 as built (mcl-core#4). The entry point is off unless the
lanmap namesentry => #{address, port}; the guide's "The entry point" has the wire. Beyond §4.2:- The node id. A node id is not a bare SHA-256 of the key:
macula_node_keys:node_id/2hashes a label, the profile and the key. The token request names itsprofile, and the node id is recomputed under that profile. This is how Jupiter's advisory (the key must hash to the claimed node id) is met. - The signed message is
"mcl-lan token request v1", a zero byte, the node id and the challenge. It is never the bare challenge, so a signature means nothing to another protocol. The challenge is taken only after the signature verifies, so a forged request cannot spend a member's challenge. A node holds at most four live challenges per node id. - Loopback is accepted beside the private ranges: it exposes nothing beyond the box.
- The bind check guards the entry point only. Distribution is started by vm.args before mcl_core runs.
- A call goes to the LAN only. §4.2 says it goes through
call_capability/4. With no LAN provider, the entry point answersno_lan_providerand does not relay to the bridge, because on the mesh the call would carry the bridge's identity, not the member's. - A
"caller"in the JSONargsis dropped. The serving member writescalleras an atom key, and a client's binary"caller"would otherwise sit beside it. - Replies are JSON. A binary that is not UTF-8 travels as
{"$bytes": base64url}, and a tuple as an array. - A removed member is refused at its next call, token request or stream event. A stream also reads the list on a 25 s tick, and ends when its token expires.
- The node id. A node id is not a bare SHA-256 of the key: