mcl-lan: macula services on a LAN, the mesh as a bridge

View Source

Uranus, 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:

repocommit
mcl-oma8e35a1 (v1.9.0)
maculaf8a467a0
mcl-kanban506c843
mcl-whiteboard509c6c5
mcl-rag42fb5cd
mcl-mail26ef0a8
mcl-graph0305fd0
mcl-scribeb88e564
mcl-stations12b164d
mcl-ledger5175cf6 (empty: README, LICENSE, .gitignore)
mcl-martha77a0a36
macula-mcp2cb8721 (v0.51.6)
martha15d2b527
lazymartha50c6663
macula-realm4196d68

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

  1. 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, the caller key in each payload). The library picks the transport.
  2. On a LAN:
    • nodes find each other by macula's gossip;
    • a capability is an OTP pg group;
    • a call is a message to a member of that group;
    • pubsub is a pg broadcast;
    • the caller's node id is written into the payload by the transport, as macula writes it today. No station, no realm, no DHT.
  3. 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.
  4. 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.
  5. 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 caller they see today. Browser UIs stay on loopback until there is a sign-in.
  6. mcl-stations leaves the LAN bundle. It is a directory of mesh stations, and it stays where the mesh is.
  7. 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/1 takes 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/0 answers {error, mesh_unavailable} (src/mcl_om.erl:367-372). {mesh, optional} is the default (src/mcl_om.app.src env; 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, then Mod:handle_request(Payload, State) (src/mcl_om_guard_pipeline.erl:64-80). Only its host, a macula_response child, 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) and macula:put_record (:1087);
    • finding and calling one: a DHT lookup (:1328), then macula: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).

1.2 Which module goes where

partmodules (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.
  • 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: boot already hands each capability's {Mod, Args} to mcl_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 same mcl_om_guard_pipeline:wrapper/3 as the mesh path does. It joins the pg group {Org, Name} in one library scope.
  • Call: mcl_om:call_capability(Org, Name, Payload, Timeout) keeps its signature (src/mcl_om.erl:304-306).
    1. It reads pg:get_members(Scope, {Org, Name}).
    2. It prefers a local member, otherwise it picks one at random.
    3. It sends the payload with gen_server:call and the timeout.
    4. On noproc or nodedown it tries the next member once. erpc is 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}.
  • Who may call: each capability names a caller policy (src/mcl_om_service.erl:61-73).
    • open and {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_wire tolerates both its key shapes (src/mcl_om_wire.erl doc, lines 1-12). On the LAN the map travels as an Erlang term, so no codec runs. Services that read fields through mcl_om_wire:field see 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]) (exports src/mcl_om_pubsub.erl:26-29) sends to every member of the pg group {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), and members: any cluster node passes.
    • {nodes, Ids}: checked against the publisher's node id, carried with the event.
  • Delivery: at most once, like async_log on 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 caller atom key: 32 bytes, the node id of the key that signed the call, written by macula over any caller the 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
  • 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).
  • 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:

needwhere
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 sitesmcl-rag/apps/mcl_rag/src/serve_federated_query/join_federation.erl:78-86
the station directorymcl-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-embeddermcl-rag/apps/rag/src/rag_embed_mcl_embedder.erl:50
D25 admission, org membership, realm rolessrc/mcl_om_claim.erl:190, src/mcl_om_org_member.erl:78
members off the LANmacula-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_capability and publish fall 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 caller set to the mesh caller's node id as macula verified it.
    • The guard pipeline runs at the bridge, the one place strangers come in.
  • 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

clienttoday
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)
browserskanban 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)
scriptsrag'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.0 or ::.
    • 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/call with {org, procedure, args}. The body goes through mcl_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_members in each node's data volume, holding one member node id per line, each with a role (owner or member).
    • 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 join stays 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 in lan_members. That step belongs to P7.
  • How a member gets a token:
    1. The member already has an ML-DSA key: macula-mcp's per-member key file (macula-mcp/src/mesh_config.ts:146-157).
    2. POST /lan/v1/challenge with 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.
    3. POST /lan/v1/token with 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 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, open included.
    • caller is the token's node id.
    • {callers, members}: a node id on lan_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 in Ids.
    • {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.
  • 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_members cannot 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.

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_call through 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.
  • 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.
  • 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/barrel apps/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.

servicethrough the library (no change)direct macula, transport-bound (changes)other macula use (libraries, no change)
mcl-kanbanboot 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 bridgetopic 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-whiteboardboot 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 planmacula_topic.app_fact 1
mcl-ragboot 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 nodemacula_rag:sign_corpus and corpus_hash (describe_corpus.erl:46, 74); node keys (:37-39)
mcl-mailboot 1 (mcl_mail_app.erl:30); wire 15; caller 1, used by 7 responders (mailbox_citizen.erl:30)00
mcl-graphboot 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-scribeboot 1; call to rag 1 (lesson_knowledge.erl:29); wire 2; caller 100
mcl-stationsboot 1; wire 75: subscribe_records ×3, find_records_by_type, macula_client:status (ingest_node_records.erl:107-137): the DHT itselfrecord codec 12
mcl-ledgernone (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, :org read, 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).
  • 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)

stepstateeffect of this design
A3 1: LAN spikedone (mcl-martha#2, main 386c497)its release settings move into the library (§2.1)
A3 1b: reckon-db must not wipe a store on joinopen (Neptunus)none: still before store mode
A3 2: store mode from configwaits on 1bnone
A3 3: singleton helperdone (mcl_om_singleton, 1.9.0)none
A3 4: side effects as singletonsopennone. 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 nodeopennone
A3 6: rag and graph on one node, reached "over the mesh, through a station"held for this designreplaced. 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 bootdone (1.9.0, src/mcl_om.erl:45-57)none
§2.5 step 3: per-service changesopenadds the §5 changes to each service's package
§2.5 step 4: the clustered release (mcl-martha#6)parkedbuilds 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 admissionneeded todayonly 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.

#repowhatsize
P1macula-services/mcl-omSplit 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
P2macula-services/mcl-omLAN 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
P3macula-services/mcl-omBridge: bridge => true, export => mesh, inbound forwarding with the mesh caller, outbound fall-through, D25 only on the bridge (§3).M
P4macula-services/mcl-omLAN 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
P5mcl-kanban, mcl-whiteboard, mcl-graph, mcl-ragThe §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
P6macula-io/macula-mcpLAN backend: MACULA_LAN_ENTRY, token signing, events (§4.3).M
P7martha-ai/marthaThe 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
P8martha-ai/lazymarthaThe crew room and calls through the entry point, folded into the lazymartha#6 packages.S (inside lazymartha#6)
P9martha-ai/mcl-marthaThe 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.svg and assets/mcl-lan-container.svg, shown in README.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)

whatcountsource
repos that depend on mcl_om32, 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 182the 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,616same
mcl-om Markdown files that name it133grep -l
other repos naming it in prose (macula, macula-mcp, martha, lazymartha)21 filesgrep -l
mcl-corpus files naming it28grep -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 itrebar.config
rebar templatemcl_service (priv/templates/, scripts/install-templates.sh) generates mcl_om deps and callsREADME.md:54, 307, 337
module prefix30 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_om 1.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 log count). A forgejo rename keeps issues and PRs. Whether it redirects the old URL is unconfirmed, so a pinned git dependency 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:

namesaysagainst
mcl-comms (Raf's)the transport, which is the changenot the contract, health or scaffold
mcl-nodewhat it makes: a macula service node, with its contract, identity and transportsclose to macula's own "node" vocabulary (node id, node keys)
mcl-servicethe 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 prefix mcl_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 first mcl_core release, mcl-om and mcl-lan are archived with a README pointer here.
  • Where §7 says macula-services/mcl-om, read macula-services/mcl-core. P1 is macula-services/mcl-core#1. P2, the LAN transport, is the first mcl_core hex 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_identity into src/contract/; it moves to the bridge with P3 (bridge => true). Services' direct mcl_core_pubsub:publish/2,3 calls point at mcl_core_transport:publish/3 in 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 lan app 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 caller it writes.
    • handler_authorizes joins {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-graph learn_truths_from_mesh.erl:137, mcl-agora on_agora_post_published_from_mesh_maybe_record_agora_post.erl:73) would drop every LAN event otherwise; the flag means what caller means on the LAN (§2.4).
    • Each LAN call runs the handler's init/1 and handle_request/2 in a process of its own, as macula_response does on the mesh.
  • P3 as built (mcl-core#7). The bridge is the node with the app env bridge set to true, beside its lan map. 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, a pg scope of its own on every LAN node).
    • Each served export => mesh capability joins a pg group carrying the capability without its handler. On its republish tick (70 s), the bridge advertises every one with mcl_core_bridge_inbound, which forwards the mesh call through mcl_core_lan:call_as/6 with 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.
  • P4 as built (mcl-core#4). The entry point is off unless the lan map names entry => #{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/2 hashes a label, the profile and the key. The token request names its profile, 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 answers no_lan_provider and 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 JSON args is dropped. The serving member writes caller as 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.