LAN backend beside the mesh: MACULA_LAN_ENTRY, LAN-first mesh_call, mesh_watch over both (#11) #12

Manually merged
terra merged 3 commits from neptunus/p6-lan-backend into main 2026-12-02 14:53:03 +00:00
Member

Refs #11 (mcl-lan P6). The LAN backend beside the mesh, never in place of it.

DECIDED 2026-12-02 "we won't loose the mesh! I just don't want to pitch Martha as "mesh-only"" (Raf)

  • src/reach_the_lan/lan_entry.ts: the MACULA_LAN_ENTRY check (plain http, no user info, origin only, every resolved address private, link-local or loopback). Requests are pinned to the checked address, and a redirect is refused.
  • lan_token.ts: challenge, then a signature over "mcl-lan token request v1" 0x00 ‖ node_id ‖ nonce only (a nonce that is not 32 bytes is never signed), then the token. It is held in memory and renewed 60 s before expiry and once on a 401.
  • lan_client.ts: call (POST /lan/v1/call with Bearer; $bytes base64url turned into the tool's standard base64) and hear (SSE).
  • mesh_call: a plain call goes to the LAN first (via: "lan", means: in the clear). On no_lan_provider it goes to the mesh (via: "mesh"). realm, ucan, prove_ownership, confidential "required" and bytes in args stay on the mesh.
  • mesh_watch (no realm): LAN + mesh together, each event with its via. The first copy of (publisher, topic, payload hash) within DEDUP_WINDOW_MS is kept (Supervisor ruling 2026-12-02). If one path cannot be opened, the other is still heard, under not_heard.
  • Unset: no LAN code runs, and the replies are byte-for-byte as on main (a test holds this).
  • Memory tools stay on the mesh (ruling (1); the follow-up is on mcl-core).
  • README ("Two ways in") and guides/HOWTO.md describe both.

Tests: a local stand-in entry point on 127.0.0.1 that verifies with NodeKey.verify. Nothing reaches outside, and the DNS lookup is a seam. Mutants: 24/24 killed on the guards.

Refs #11 (mcl-lan P6). The LAN backend beside the mesh, never in place of it. DECIDED 2026-12-02 "we won't loose the mesh! I just don't want to pitch Martha as "mesh-only"" (Raf) - `src/reach_the_lan/lan_entry.ts`: the `MACULA_LAN_ENTRY` check (plain http, no user info, origin only, every resolved address private, link-local or loopback). Requests are pinned to the checked address, and a redirect is refused. - `lan_token.ts`: challenge, then a signature over `"mcl-lan token request v1" 0x00 ‖ node_id ‖ nonce` only (a nonce that is not 32 bytes is never signed), then the token. It is held in memory and renewed 60 s before expiry and once on a 401. - `lan_client.ts`: `call` (POST /lan/v1/call with Bearer; `$bytes` base64url turned into the tool's standard base64) and `hear` (SSE). - `mesh_call`: a plain call goes to the LAN first (`via: "lan"`, `means`: in the clear). On `no_lan_provider` it goes to the mesh (`via: "mesh"`). realm, ucan, prove_ownership, confidential "required" and bytes in args stay on the mesh. - `mesh_watch` (no realm): LAN + mesh together, each event with its `via`. The first copy of (publisher, topic, payload hash) within `DEDUP_WINDOW_MS` is kept (Supervisor ruling 2026-12-02). If one path cannot be opened, the other is still heard, under `not_heard`. - Unset: no LAN code runs, and the replies are byte-for-byte as on main (a test holds this). - Memory tools stay on the mesh (ruling (1); the follow-up is on mcl-core). - README ("Two ways in") and guides/HOWTO.md describe both. Tests: a local stand-in entry point on 127.0.0.1 that verifies with `NodeKey.verify`. Nothing reaches outside, and the DNS lookup is a seam. Mutants: 24/24 killed on the guards.
LAN backend beside the mesh: MACULA_LAN_ENTRY, member token, LAN-first mesh_call, mesh_watch over both (Refs #11)
Some checks failed
CI / identity hold on Windows (pull_request) Has been skipped
CI / parse-check install.ps1 / uninstall.ps1 (pull_request) Has been skipped
CI / node in . (container) (pull_request) Has been skipped
c4 model / A C4 Context and a C4 Component diagram, in assets/, shown by a README (pull_request) Successful in 3s
CI / structural floor (pull_request) Successful in 10s
CI / typecheck (pull_request) Successful in 8s
CI / build (pull_request) Successful in 8s
CI / test (pull_request) Successful in 20s
CI / shellcheck install.sh / uninstall.sh (pull_request) Successful in 8s
CI / node in . (pull_request) Failing after 9s
CI / Dependency advisories (pull_request) Failing after 0s
3ce2e4f519
With MACULA_LAN_ENTRY unset nothing changes. Set, the entry point (mcl-core#4)
is checked first: plain http to a private, link-local or loopback address,
requests pinned to the checked address, redirects refused. The token is
earned by signing only mcl-core's labelled message over a 32-byte challenge,
held in memory, renewed near expiry and once on a 401.

A plain mesh_call goes to the LAN first (via lan, in the clear) and falls to
the mesh on no_lan_provider; realm, ucan, prove_ownership, confidential
required and bytes stay on the mesh. mesh_watch without a realm hears the LAN
and the mesh together, each event with its via, and keeps only the first copy
of (publisher, topic, payload) within DEDUP_WINDOW_MS (Supervisor ruling).
Memory tools stay on the mesh. README and HOWTO describe both ways in.
1. Dedup drops only a copy that arrives by the OTHER path, one for one; real
   repeats over one path are all delivered (Supervisor yes on Jupiter's fix).
2. A LAN stream the entry point ends (token expiry) is opened again with a
   fresh token; a failed reopen, or a stream that ends within
   LAN_REOPEN_MIN_MS, is reported under not_heard.lan.
3. A stream's connect and headers are bounded by TOKEN_REQUEST_MS; the bound
   is lifted once its 200 arrives.
Notes: (b) a payload_not_encodable event is delivered with its error, outside
the dedup; (c) a refused entry's user info is never echoed.
hear_both: no dedup bypass for an unencodable event: it only comes over the LAN, and same-path copies are all kept (Refs #11)
Some checks failed
CI / identity hold on Windows (pull_request) Has been skipped
CI / parse-check install.ps1 / uninstall.ps1 (pull_request) Has been skipped
CI / node in . (container) (pull_request) Has been skipped
c4 model / A C4 Context and a C4 Component diagram, in assets/, shown by a README (pull_request) Successful in 1s
CI / structural floor (pull_request) Successful in 10s
CI / typecheck (pull_request) Successful in 9s
CI / build (pull_request) Successful in 9s
CI / test (pull_request) Successful in 22s
CI / shellcheck install.sh / uninstall.sh (pull_request) Successful in 5s
CI / node in . (pull_request) Failing after 13s
CI / Dependency advisories (pull_request) Failing after 0s
CI / node in . (container) (push) Has been skipped
CI / identity hold on Windows (push) Has been skipped
CI / parse-check install.ps1 / uninstall.ps1 (push) Has been skipped
c4 model / A C4 Context and a C4 Component diagram, in assets/, shown by a README (push) Successful in 4s
CI / structural floor (push) Successful in 10s
CI / typecheck (push) Successful in 12s
CI / build (push) Successful in 9s
CI / shellcheck install.sh / uninstall.sh (push) Successful in 5s
CI / node in . (push) Failing after 12s
CI / Dependency advisories (push) Failing after 0s
CI / test (push) Successful in 28s
ca964f88d9
terra manually merged commit ca964f88d9 into main 2026-12-02 14:53:03 +00:00
Sign in to join this conversation.
No reviewers
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-io/macula-mcp!12
No description provided.