--- layer: to-be status: in-progress code: - mesh-controller internal/catalogue/filtering.go - mesh-controller examples/route-proxy - mesh-controller internal/identity/authority.go - mesh-host internal/identity/serving.go - mesh-host internal/apply (the service that reflects a rule set) updated: 2026-09-27 decisions: - 02-DECISIONS/0104-a-provision-may-be-answered-by-an-adapter-to-the-predecessor.md - 02-DECISIONS/0106-the-bus-is-nats.md - 02-DECISIONS/0105-the-mesh-adopts-the-predecessors-tunnel-in-place.md - 02-DECISIONS/0119-a-taken-tunnels-predecessor-is-retired.md - 02-DECISIONS/0108-a-route-carries-the-policy-applied-to-a-request.md - 02-DECISIONS/0103-what-an-adopted-node-holds-and-what-its-guard-refuses.md - 02-DECISIONS/0100-a-node-in-use-is-adopted-before-it-is-converged.md - 02-DECISIONS/0099-a-step-that-runs-once-names-what-it-reads.md - 02-DECISIONS/0098-a-fact-a-provider-makes-at-first-start-is-fetched-from-it.md - 02-DECISIONS/0005-the-node-host.md - 02-DECISIONS/0004-a-node-and-how-it-joins.md - 02-DECISIONS/0007-connectivity.md - 02-DECISIONS/0007-connectivity.md - 02-DECISIONS/0004-a-node-and-how-it-joins.md - 02-DECISIONS/0007-connectivity.md - 02-DECISIONS/0006-the-substrate-and-the-control-plane.md - 02-DECISIONS/0066-public-routing-is-name-agnostic.md - 02-DECISIONS/0029-a-network-is-a-shape-because-an-action-cannot-be-undone.md - 02-DECISIONS/0044-a-public-name-is-provisioned-like-any-capability.md - 02-DECISIONS/0045-a-machine-firewall-is-the-sum-of-what-it-listens-on.md --- # Connectivity One of [the controller's](06-the-controller.md) ten contexts, and the one with the most moving parts: **overlay, resolution, exposure, filtering, certificates.** It is written as a whole because the five are one design. They share inputs, they must agree, and every one of them today is computed in a different place by a different module from a different copy of the same facts. ## Why it is controller work Apply [the test](06-the-controller.md) — *everything that needs to know about more than one node* — to each responsibility: | | needs to know | whose | |---|---|---| | **overlay** — who peers with whom, at what address | **every node**, and which of them can be dialled | controller | | **resolution** — which name is which node | **every node** | controller | | **exposure** — which public name reaches which container | **which node is publicly reachable** ([ADR 0007](../../02-DECISIONS/0007-connectivity.md)) | controller | | **filtering** — which port is open, to whom | what is assigned here, and the overlay's shape | controller decides, host applies | | **certificates** — who may present which name | which name belongs to which node | controller | **Not one of the five can be answered by a machine on its own.** That is the whole reason this is a context rather than a set of node-local modules — and it is exactly what the current arrangement gets wrong, by computing all five on the node from a direct database connection. ## The shape: decided centrally, delivered as files Every one of the five resolves the same way, and it is worth stating once rather than five times: > **The connectivity context computes the configuration. It arrives over the link as `file` > resources. The service reads files and knows nothing about the mesh.** This costs **no new host vocabulary**. `file`, `directory`, `service` and `container` already exist; WireGuard, the resolver and the proxy are all *a container or a package, plus files*. It is also what removes the last two upward dependencies. [Research 006](../../01-RESEARCH/006-mesh-from-scratch/host-size.md) counted exactly two modules opening a direct connection to the controller's database — `wireguard` and `traefik` — and they are the reason every node permanently holds a credential to it ([ADR 0004](../../02-DECISIONS/0004-a-node-and-how-it-joins.md)). Both are connectivity modules. **Closing this context closes that set.** ### And they are modules, not a second mechanism beside the module system *Written 2026-08-29, from building it. The first version was code beside the module system doing the module system's job, and the fault it produced is the point of writing this down.* **A machine was on the private network because it had an address.** Every node that had been placed got a peer list, whether or not anybody wanted it there, and there was no way to say a machine should stay off. That is what "special-cased" cost, and it was invisible until somebody wanted the exception. **What made it look unavoidable:** a peer list cannot be written in a manifest. It is derived from every other machine, so it differs on each one and changes when any of them changes. So the manifest says its resources are **computed** — it names something in the controller that works them out per node — and it is a module in every other respect: assigned, resolved, configured by settings, and absent from a machine nobody gave it to. **What that made possible immediately** is the arrangement below, which the code has: | module | provides | requires | claims | |---|---|---|---| | the WireGuard one | a private network, **and the mesh's own addressing** | | *the* private network, one per node | | the names one | name resolution | the mesh's own addressing | | | `networking` | | both of the above | | **Three rather than one, because WireGuard is one VPN of several.** Naming the module after the job — `networking` — and putting WireGuard inside it is the retired *flavor* idea wearing a generic name: the second VPN has nowhere to go. So a module is named for what it *is* and declares what it *does*, and `networking` is the third row — requirements and no files ([ADR 0009](../../02-DECISIONS/0009-modules-and-the-graph.md)). **Names left the WireGuard module for their own.** They had been delivered inside it, on the argument that a machine with peers and no names is half on the network. True, and the wrong place to fix it — names are identical over a *different* private network, so bundling them made one module out of two things. They require the mesh's **addressing** rather than a private network in general, because that is what they are computed from: over a VPN that hands out its own addresses the mesh has nothing to write, and refusing is what stops a machine being given a hosts file that means nothing on it. **And the claim is not decoration.** Choosing a different VPN still installed WireGuard — dragged back in by the names, which needed addresses only WireGuard hands out — and nobody was told. Running two VPNs is not always wrong; being *the* one the mesh runs over is singular. So it is a claim, and the collision is refused by name. **And the proxy's half, which was the other module reaching into the database.** A web application requiring a reverse proxy has to say *which name, which port*, and there was nowhere to put it — `requires` says a thing must exist and never said what to do with it. A module now contributes to a requirement, the controller collects every contribution on a node, and the provider is given them as a file at a path it named. It reloads when that file changes, by the same `restart-on` the private network needed when a peer list changed under a running interface. **The proxy's configuration is not written by the mesh.** It is given the facts and turns them into whatever it runs, which is why swapping Traefik for something else touches nothing that publishes through it. See [ADR 0009](../../02-DECISIONS/0009-modules-and-the-graph.md) for the other direction — handing a credential *back* — which is the larger half and is not built. **What is still not a module, and why that is correct.** The host needs none of this. It has an address and a route before the mesh exists — that is the machine's own networking — and the broker's address is carried in the token rather than resolved ([ADR 0004](../../02-DECISIONS/0004-a-node-and-how-it-joins.md)). **The one connection that carries modules cannot itself be one.** Everything above it can be, and now is. ## The order it comes up in The one thing to get right, because everything else depends on it: ``` 0 the node has an underlay address the machine's own — DHCP, or a provider gave it one 1 the node dials the mesh OVER THE UNDERLAY, at the address in its token 2 it proves itself, and is proved to the link exists (ADR 0004, ADR 0004) 3 the mesh grants it an identity and an overlay address 4 the overlay comes up peer graph delivered as files 5 names resolve resolver config delivered as files 6 filtering is applied derived from what is assigned here 7 routes and certificates once this node has something to expose ``` **Step 1 runs on the underlay and never on the overlay.** This is the circularity that must not be created: the overlay is configured by the mesh, so a link that required the overlay could never be established on a new node. The link stays on the underlay permanently — it is outbound-only and carries its own identity, so it needs nothing the overlay provides. **Nothing before step 3 can resolve a mesh name**, which is why the token carries an *address* ([ADR 0004](../../02-DECISIONS/0004-a-node-and-how-it-joins.md)). Today this is patched with an `/etc/hosts` floor written underneath the resolver; under this design there is nothing to patch. **Step 1 has a precondition this document treated as a fact to record rather than a requirement: the broker's node must be dialable by every node, at a stable address, and so must the hub** ([ADR 0007](../../02-DECISIONS/0007-connectivity.md)). Across the internet that means publicly reachable; on one network it does not. A mesh whose nodes are all behind NAT cannot be raised, and a broker node whose address moves invalidates every token issued for it. **Whether the link should later move onto the overlay, with the underlay as fallback, is [open](../../02-DECISIONS/0007-connectivity.md).** It is a decision rather than a derivation: the gain is which network carries bytes, not what an attacker can reach, since the link is already encrypted against a pinned fingerprint. ## 1 — The overlay **What is decided:** the peer graph. For every node: its overlay address, which peers it holds, which of those it may dial, and which must dial it. **Inputs, all declared:** - **reachability** — an endpoint, or none ([ADR 0007](../../02-DECISIONS/0007-connectivity.md)). Not inferred from the address shape, which is wrong for carrier-grade NAT, wrong for IPv6, and wrong for a routable address behind a closed firewall. - **site** — where the machine physically is, or nothing if it roams. - **role** — hub or not, **declared**. Today it is inferred from an address prefix, which means a renumbering is an outage and nothing can be asked which node is the hub. **Keys.** Each node generates its own keypair. **The private key never leaves the machine**; the public key is published to the mesh. This is already true and it is already right — it is [ADR 0004](../../02-DECISIONS/0004-a-node-and-how-it-joins.md)'s *a node holds its own identity* applied to the overlay, and it means the controller computes a graph it cannot itself impersonate. **Shape: a hub, with direct peering between co-located nodes.** | | | |---|---| | two nodes at the same site | peer **directly**, host-routed, with a keepalive | | everything else | routes through the **hub** | | a node with no site — it roams | **hub only** | **Roaming is hub-only deliberately, and the reason is a property of WireGuard rather than a preference: there is no failover.** A more specific route to a dead endpoint blackholes; it does not fall back to the general one. So a node whose location changes gets exactly one path, because two paths would mean one of them silently swallowing traffic. **What the host receives:** an interface configuration and a peer list, as files. It does not compute them, and after this it holds no credential to the mesh's database. ### Four things the lab found, none of them visible from the mesh's own state *Written 2026-08-29, on the first three machines to actually run this.* Each looked like a working network from every angle the mesh can see: the graph was right, the files were right, the services were up, and every node reported success. - **A running interface does not re-read its configuration.** A node joins, every existing node's peer list changes, each file is replaced — and the service is already running, so nothing reloads it. Every existing node keeps a network that no longer exists. The declaration has to say the service must *reflect* the file, which is declared state; a command to restart would be an action, and the link may not carry one ([ADR 0005](../../02-DECISIONS/0005-the-node-host.md)). - **A hub that shares a site with a spoke was emitted twice** — once as a direct peer and once as the route of last resort. WireGuard takes one entry per public key, so the interface refuses the file. The ordinary shape of a small mesh, and in none of the tests written before it ran. - **Two nodes at one site that neither can be dialled must not peer directly.** Nobody opens the path, and the direct route is more specific than the hub's, so it wins and blackholes. This document's own warning, arriving in its implementation: *a more specific route to a dead endpoint blackholes; it does not fall back to the general one.* - **The container runtime closes the door the overlay needs.** Docker sets the FORWARD policy to DROP, so a hub with `ip_forward` enabled still carries nothing between its spokes. The foundation at tier 1 silently breaks the network at tier 2, and nothing in either tier's state says so. The hub inserts its own rule above those chains and removes it on the way down. **The pattern in all four:** the mesh's picture of the network was correct and the network did not work. That is the argument for the lab in one line — none of these is reachable by reasoning, and each was found within minutes of a real machine trying it. ## 2 — Resolution **Two name spaces, and they do not mix:** | | resolves to | certified by | |---|---|---| | **internal names** | overlay addresses | the **mesh CA** | | **public names** | whatever the outside world must reach | a **public authority** | A node's mesh name is its overlay address. Its public name, if it has one, is a separate fact used by things outside the mesh — and the separation carries two lessons that were learned expensively enough to be worth restating: - **Mesh names are not multicast names.** A name resolved by local multicast discovery introduces a delay and a failure mode that appears on one node and not others — the worst shape a fault can have. - **A node must not pin its own public name locally.** The duplicate record breaks resolution of that name for everything else that needs it. **What the host receives:** the resolver's configuration, as files, listing every peer's internal name and overlay address. **What goes away:** the `/etc/hosts` floor. It exists because a node had to reach the mesh database before its own DNS existed; with [ADR 0004](../../02-DECISIONS/0004-a-node-and-how-it-joins.md) nothing needs a name before the link, and a fallback nothing needs is a path nothing tests. ### Names, and what a container can see *2026-08-31, from a container that could not resolve a name every machine could.* Internal names are `.internal` — the suffix is the one IANA reserved in 2024, so a name that leaks into a public resolver fails rather than reaching a stranger's machine. They are computed centrally, because a name set needs every node at once, and written to each machine's hosts file. **A file rather than a resolver**, and the reasoning holds: it works on every Linux, needs no package, and has no failure mode of its own. The stated trigger for a daemon was *names that are not one-per-node* — service names, wildcards. **But a container does not inherit the machine's names.** It gets its own hosts file holding only its own hostname. So every name the mesh wrote was invisible to the majority of things that need one — and *on the machine it always worked*, which is exactly what made it easy to miss. It was found by a database client on one node failing to resolve another node, on a mesh where both names were correct and present on both machines. **So the mesh gives its names to the containers it declares**, written into each container's own hosts file by the runtime. That extends the file decision rather than overturning it. Given by the mesh and not chosen by a module: a module that listed the machines would go stale the day one joins, and a module that did not would be one whose containers cannot reach anything by name. **The boundary, which is deliberate and worth stating:** *declared* containers. A container somebody starts by hand is not the mesh's to configure, and reaching into every container on a machine — declared or not — is what a nameserver in `resolv.conf` would be for. ### The resolver, built *2026-08-31.* **A service is reached at `..internal`** — the first label is the service, the rest is the node — so what resolves is *anything under a node's name*, going to that node. What routes it once it arrives is a proxy's, and stays separate. **The mesh writes the data and runs no daemon.** One wildcard per machine, from the same set that writes the hosts file. A resolver is third-party software and runs *on* the mesh rather than being *of* it: the mesh has no business shipping one, choosing which one, or knowing its configuration language. Swapping dnsmasq for unbound changes that module and nothing in the controller. **Two roles, two claims, because they are different things.** systemd-resolved cannot answer a wildcard at all — it routes the mesh's suffix to something that can. Treating serving and asking as one role produces a module that cannot work. | | claims | | |---|---|---| | serving | `the-dns-port` | answers the wildcards | | asking | `the-resolver-configuration` | decides what the machine asks | So *which* resolver is not a mesh-wide decision. One machine can use what systemd already owns and another can run dnsmasq, and two of either on one machine is refused rather than fought over. **Two things a resolver must not do**, both found by a machine rather than by reasoning: - **Take an address something else holds.** systemd-resolved holds `127.0.0.53` *and* `127.0.0.54`. - **Read `resolv.conf` for its upstreams.** Whatever points a machine at the mesh writes the resolver's own address there, so it becomes its own upstream and every query it cannot answer loops until its receive queue fills. It needs no upstream: only the mesh's suffix is routed to it. *Checked on two machines, through the path an application takes — nsswitch, files, then DNS — because the module deciding what the machine asks is half of what is being tested and only that path goes through it.* **That is now the second reason to want a resolver**, and it is a different one from the trigger above: | | | |---|---| | names that are not one-per-node | a service named under a machine — `postgres.novox.internal` | | containers the mesh did not declare | anything a person or another tool starts on a node | ### Which resolver is not a question the mesh answers *Written 2026-08-31, after treating it as open when it had been decided two days earlier.* **A resolver takes over `/etc/resolv.conf`, which is a singular resource, so it is a claim** — [ADR 0009](../../02-DECISIONS/0009-modules-and-the-graph.md) lists it in the table beside the seat and pid 1. Choosing between resolved, dnsmasq and unbound is **assigning a module**, per machine, and two of them cannot both be assigned there: > `resolved-config and dnsmasq both claim "/etc/resolv.conf", and only one thing may hold it per node` So there is nothing global to settle and nothing for the mesh to guess. One machine can use what systemd already owns and another can run dnsmasq, and neither has to know about the other. **What the mesh contributes is the part only it can know**: which machines exist and where. That is `mesh-resolver`, which writes one file and holds no claim, because writing a file takes nothing over. A daemon module requires that data and claims the resolver — so swapping the daemon changes that module and nothing else. **This was recorded on 2026-08-29 and reopened as an unanswered question on the 31st.** Which is the argument for the table in ADR 0009 being a table: the pattern is only obvious once seen, and the cost of not seeing it is inventing a mechanism that already exists. ### And the public names a proxy serves must resolve in the mesh too *2026-09-09, found by an internal certificate authority that could not issue.* The mesh writes every `.internal` name into every declared container and treats the public names a proxy serves as a separate matter — *what routes it once it arrives is a proxy's, and stays separate*, above. That holds for a client dialling by internal name. It does not hold for anything **inside** the mesh that must reach a public name, and the first such thing to appear was the internal issuer of §5. **An issuer validates by connecting to the name it is certifying.** Asked for a certificate for a routed public name, the internal authority accepted the order, offered a challenge, and then could not connect: nothing in the mesh resolved that name, so the challenge had no target. A name the mesh can reach from the outside but cannot resolve from the inside is a name it cannot certify with an authority of its own. **So a granted route is published into internal resolution as well** — the routed name to the node that serves it, mesh-wide, by the same mechanism that writes the node names. It is *given by the mesh, not chosen by a module*, for the same reason the node names are: a module listing the routes would go stale the day one changes. The mesh propagates the names it was told to serve and still knows nothing about what they mean ([ADR 0066](../../02-DECISIONS/0066-public-routing-is-name-agnostic.md)). ## 3 — Exposure Settled by [ADR 0007](../../02-DECISIONS/0007-connectivity.md); summarised here because this is where it belongs. **A route is a grant.** A module that must be reachable declares it needs one; the proxy provides it and hands back the public name. Ordinary [ADR 0009](../../02-DECISIONS/0009-modules-and-the-graph.md) vocabulary — the mirror of a database grant, where the consumer supplies a target and receives a name rather than supplying nothing and receiving credentials. **A workload on an unreachable node is proxied by a reachable one, across the overlay.** Which is the case is a mesh-level fact, which is the fourth reason exposure is controller work. ### What was built *2026-08-31.* Nothing new in the vocabulary, which was the claim and is now the fact: a route is a provision, a proxy provides it, and a module that must be reachable requires it. The consumer contributes the name it wants and the port it listens on; the proxy receives every consumer that asked; the consumer is told what the provider serves, which is how it knows its own name. **One field was missing, and it is the one anything reaching back needs.** A contribution now carries **where the mesh says that machine is**. A database is reached *by* its consumer, so the mesh never had to tell a provider where anybody was; a proxy is the other direction — it is told to send traffic to a consumer and has to open a connection. Without it every provider implementing a provision would have to know how the mesh names machines, which is a convention leaking into every module. **Exposure and filtering are different questions and a module answers both.** A workload says what it listens on and who may reach it; separately, it says it wants a route. A module that asked for a route and not for the port is unreachable by the proxy it just asked for — which the lab demonstrates, because the machine is already filtering by the time this runs. **Withdrawal, which was open above.** The file the proxy is given is the whole truth about who has a route, so a proxy replaces its table rather than merging. Merging would keep serving a name whose module was unassigned — and *a stale public name pointing at nothing fails more visibly than a stale grant* is the reason it must not survive, not a reason to tolerate it. **A name a proxy does not serve is refused by saying which it does.** A route that was withdrawn and a name that never existed are different things, and a bare 404 makes an operator go and read the mesh to tell them apart. *Checked in the lab by a request to the name reaching the workload across the private network and returning the workload's own answer, then by unassigning the module and requiring the same request to stop working.* ### The name is a label, not a domain *2026-09-09, from running the whole mesh in the lab.* A route contribution carried its public name in full — the forge as `git.example.tld`, spelt out in the module. Pointing the same catalogue at a different domain — a lab standing in for production, or a second operator's mesh — meant rewriting that name on every routed module. The mesh was holding a **map of names to services**, which is the one thing it must not: a public name is two facts owned by two different places, and neither is the module's manifest. **A module contributes a label; the node contributes its public domain; the mesh composes.** The operator chooses where the forge lives — `git`, or `code` — and that is the module's to say. The domain is the node's, set once. The mesh joins them and grants `