pushleft
Deploy your first app
Manual contents
Handbook
HandbookPushleftArchitecture
Operate
Install the control planeYour own serversFleetOperations and alertsAuthenticationAccess gateDomains and DNSUsage and budgetsScheduled jobsAbuse controlsAI provider proxyCustomer mailErrors and performanceLogs and metricsRetentionObject storageContainer registryGit server
Develop
The .pl.yaml manifestOnboard with an AI agentThe pl up demoBuild executorSource ingestionAgent gatewayManaged databasesSecurity findingsTunnels and shellsDev workspacesPrivate hostnamesMesh coordinatorsDesign baseline
Runbooks
Control-plane host failoverControl-plane PostgreSQL failoverControl-plane PostgreSQL restoreCustom domains and certificatesGateway key compromiseIngress host failureNode busyNode disk fullNode drain and replacementNode lostRegistry outageHetzner Robot hostsSecret rotationSecurity incidentStaging fleet on ProxmoxStaging build cacheStuck deploymentVault/OpenBao backup and recovery
More
CI pipelines
Manual · docs/mesh-coordinators.md

Mesh coordinators

Each deployment environment gets its own private network (a tailnet), run by its own Headscale coordinator. This page shows how pushleft-mesh runs those coordinators and enrolls node gateways. It also shows how it approves subnet routes and proves the network is ready.

pushleft-mesh runs only on trusted managed coordinator hosts in the mesh fleet pool. Do not colocate untrusted customer workloads. This process controls Docker, reads platform job state and publishes scoped enrollment credentials. Fleet administration stays private: this is not a public fleet management API.

Coordinator placement

Decided 2026-11-03 (Waseem): there is no mesh host. Each environment’s coordinator runs on one of the environment’s own application or database hosts. To add capacity, add hosts. There is no mesh tier to size. The work is split in two:

  • The controller (pushleft-mesh run) runs on the control plane, as the unprivileged user pushleft-mesh (pushleft-mesh.service). It keeps the database login, the Cloudflare token and the control-plane Caddy. It places coordinators, seals topologies, approves routes and publishes credentials, as before.
  • The host side is the agent. Each agent serves a host API on its management tailnet address, port 8448 (coordinators.rs, remote.rs). The controller calls it to ensure a coordinator, issue or revoke a key, approve routes, list its coordinators and retire one. The host runs Docker and Headscale and keeps the coordinator state under /var/lib/pushleft/headscale.

Placement. A segment gets its coordinator when its first workload is placed (the first network_attachment_requests row). The controller takes the earliest placed host that may run it (mesh_coordinator_eligible, migration 0121). The host must be active and seen in the last 60 seconds, in the application or database pool. It must be shared or dedicated to the segment’s organization, and seen by the agent gateway on the management tailnet. A customer-owned host never runs a coordinator: the customer has root on it. A segment placed only on customer-owned hosts gets the shared platform host that coordinates the fewest segments (decided 2026-11-07). Its gateways reach it at the same public URL. Jobs of a segment without such a host wait in the queue. The coordinator stays on that host while it can run it. When it cannot, the coordinator moves (built 2026-11-03, move_coordinator, migration 0124):

  • When. The coordinator moves when the host has been out of contact for 5 minutes (a reboot comes back well within that). It moves at once when the host is draining, lost or retired, left the application and database pools, or belongs to another organization.
  • Where. The segment’s earliest other placed host that may run it, by the same rule as placement. Without one the segment waits, as before.
  • How. A fresh coordinator starts there: new Headscale state, new Noise key, same URL (the control plane’s Caddy dials the new host). The trigger on coordinator_node_id resets coordinator health and the move clears every attachment’s route evidence, so nothing admits traffic on the old coordinator’s word. Once the new coordinator is ready, every enrollment published before the move is issued again (enqueue_moved_enrollments): a new key and credential revision. That publication also clears the attachment’s provider node, because the new coordinator knows none of the old ones. A rotation on the same coordinator keeps it.
  • Re-join. The agent records the key each gateway enrolled with (.pushleft-enrolled-ref in its state). A newer key in the specification means the coordinator was replaced. The agent then stops the gateway, empties its Tailscale profile and starts it with the new key. A registered profile does not notice a replaced coordinator by itself, and tailscaled stays Running (checked against a real Headscale on 2026-11-03). Routes are then approved again on the new coordinator. Each environment network is down for about a minute on each host.
  • Keys. A fresh coordinator numbers its pre-auth keys from 1 again, so a new key’s Vault path can be one a predecessor already used. The issuer then retires that candidate and takes the next id; it never uses the old secret.
  • The old host. If it comes back, its copy is stale. Retirement removes coordinators of segments that moved to another host, as it does for destroyed ones. It leaves the route and DNS name to the new coordinator.
  • Drained hosts move at once, the same way, by recreating and re-joining. A handover of the state without the minute’s gap is not built. The gateway refuses leases to a draining host, so its own gateways cannot re-join. Move its workloads off first, as node drain and replacement says. Workloads left on it lose the environment network.
  • Lost hosts. The 5 minutes match the scheduler’s lost-node window (PUSHLEFT_NODE_LOST_AFTER_SECONDS, 300). A host silent that long is also declared lost and its work fenced. A host whose agent alone stops keeps its coordinators running and serving, because the control plane’s Caddy dials them directly. Its telemetry heartbeat keeps it fresh, so nothing moves.

While a segment waits for its coordinator, its existing tunnels keep running, but nothing in the environment can enroll or change routes. Backups, backup checks and database removals do not wait for the environment network (decided 2026-11-03). The environment can still be backed up and torn down.

Reaching a coordinator. Gateways reach coordinators only at public addresses (environment firewalls drop private ranges). The control-plane Caddy serves every coordinator as https://hs-<segment>.<mesh domain>:9443/, with the mesh wildcard from the internal CA, and the A record points at the control plane. It proxies to the coordinator’s port on its host’s management tailnet address (18080-19079). The management ACL lets cp@ reach node@:8448,18080-19079 and nothing else on nodes.

Addresses. The controller dials the address the agent gateway saw the agent connect from (fleet_nodes.capabilities.mgmt_address), never one the host reports. The controller refuses anything outside 100.64.0.0/10. So a host cannot point the control-plane Caddy at loopback or at another network.

Relay

Gateways reach each other directly when they can. When they cannot, Tailscale relays their WireGuard packets through a DERP server. Pushleft runs its own: tailscale’s derper on the control plane (pushleft-derper.service, pinned as PUSHLEFT_DERPER_VERSION in images.lock.env). Decided 2026-11-04 (Waseem) after a measurement. Every cross-host environment flow went through Tailscale’s public relays in Frankfurt and Nuremberg, at about 16 ms per round trip against 0.5 ms direct. An application on one box paid about 1.2 s per page for 87 queries to its database on another.

  • Map. Each coordinator’s DERP map has one region, 900 (pl), with one node: derp.<mesh domain>. It is dialled at the control plane’s public IPv4, with DERP on tcp 9443 and STUN on udp 61478. Tailscale’s public regions are not in it. install-control-plane.sh writes it to https://releases.<base>/derpmap.json and sets PUSHLEFT_DERP_MAP_URL to it. The URL has a public certificate, so Headscale’s own trust store accepts it. Headscale fetches the map at start and every 3 hours, and pushes a changed map to every gateway.
  • DERP. The control-plane Caddy’s mesh server (:9443) terminates TLS for derp.<mesh domain> with the mesh wildcard, which gateways trust already (SSL_CERT_FILE). It proxies the DERP upgrade to derper on loopback :3340 (the private firewall drops 3340 off loopback). stream_close_delay is 24 hours: without it, every Caddy config change (the mesh controller makes about 36 a day) cuts every relayed connection.
  • STUN. udp 61478, public. The Robot firewall admits it through the udp 32768-65535 rule, so box 1 needs no new Robot rule. The port is above the host’s ephemeral range (32768-60999).
  • Privacy. DERP forwards packets that are already WireGuard-encrypted between the two gateways. The control plane sees node public keys and packet sizes, nothing in clear.
  • Not admitted per client. Anyone who can reach :9443 can relay through it (bandwidth only; they reach no tailnet). Add --verify-client-url when that matters.
  • One relay. If the control plane is down, relayed paths stop. Direct paths between gateways do not need the relay once they are up. Tailscale’s public regions as a fallback were dropped by decision. To add one back, change the map’s content and keep the URL.

Moving coordinators to the map. The DERP map URL is part of a coordinator’s specification. A coordinator still on Tailscale’s public map (https://controlplane.tailscale.com/derpmap/default, exactly) moves to the configured URL on its next ensure. The marker and config.yaml are rewritten from their exact legacy bytes. The container is checked as ours and created again on its own port, so the Caddy route stays. Any other URL change is still drift. Change the map’s content instead; a docker restart pushleft-headscale-<segment> applies it at once, one environment at a time.

Check. In a gateway, tailscale netcheck shows pl as the only region. tailscale status shows relay "pl" for a relayed peer. tailscale ping <peer> reports via DERP(pl) at about 1 ms between Hetzner boxes.

Direct paths

With the relay alone, every cross-host packet still takes two hops through the control plane. Tailscale goes direct between two gateways when each can reach the endpoint the other advertises. That failed on every host (measured 2026-11-04). A gateway sent from, say, 10.128.5.2:57842, and Docker’s masquerade rewrote the port (10232, 22903, 49598 were seen). So the endpoint a gateway learnt by STUN was not the one its peer saw. Also, the Robot firewall drops ports below 32768. Built 2026-11-04 (Waseem):

  • A fixed port per environment. The gateway’s tailscaled listens on 32768 + n, where n is the index of the environment’s /24 in 10.128.0.0/9 (10.128.37.0/24 → 32805). Subnets are globally unique, so the ports are unique on every host with no allocation. They lie in the range the Robot firewall admits (udp 32768-65535). Port 41641 belongs to the host’s own tailscaled and is skipped, so that environment keeps no direct port. The agent passes it as TS_TAILSCALED_EXTRA_ARGS=--port=<port>. The port is not part of the gateway’s specification hash.
  • The port kept both ways. Per gateway, the agent applies its own table inet pld_<segment>. Outbound, the gateway’s packets from its port leave the public interface with the same port (masquerade to :<port>, before Docker’s masquerade). Inbound, udp to that port on the public interface goes to the gateway. The environment firewall already admits DNAT’d flows from the public interface into its bridge. The DOCKER-USER rule of the published ports lets them past Docker. Checked on Linux nftables: without the table, a send from 32805 left as port 16815, and an unsolicited packet to 32805 was dropped. With the table, the peer saw 32805 and the unsolicited packet reached the gateway.
  • The ephemeral range. The host’s ephemeral ports are 32768-60999, so a host socket could hold a gateway’s port. The agent adds each gateway port to net.ipv4.ip_local_reserved_ports and keeps the existing entries. The reservation only keeps the port out of automatic allocation. Explicit binds still work, and existing sockets are untouched. The agent’s unit has ProtectKernelTunables, so the write runs as a one-off systemd-run sysctl job. Neither the table nor the reservation survives a reboot. The gateway’s health check (every 30 s) applies both again, so a rebooted host runs relayed for up to 30 s.
  • Requires the public interface. Only agents with PUSHLEFT_PUBLIC_INTERFACE give gateways a port. Others keep the old behaviour.
  • Not checked: published ports. A published udp port on the same host can equal a gateway’s port, and then one of the two takes it. An example is a TURN range in 49152-49200 against an environment whose subnet index is 16384 or more. Current subnet indexes are far below that.

Rollout. A gateway from before direct ports stays healthy: the recurring check accepts it. The next ensure of its attachment recreates it with the port, on the same state, name and address. If the new one does not become healthy, the ensure puts the old one back. An ensure runs when the attachment has no fresh gateway check, so one environment at a time:

UPDATE network_attachments a SET gateway_checked_at=NULL, updated_at=now()
FROM network_segments s
WHERE s.id=a.segment_id AND s.org_id=a.org_id AND s.environment_id='<environment>' AND a.gateway_status='ready';

Each gateway of that environment restarts once (about 10 to 30 s without cross-host traffic for it).

Check. In the gateway, ps or the container’s environment shows --port=<port>. On the host, run nft list table inet pld_<segment>. tailscale netcheck reports IPv4: yes, <host IP>:<port>. tailscale ping <peer> ends with via <peer host IP>:<peer port> at about 0.5 ms. tailscale status shows direct where it showed relay "pl".

Trust tier

The controller is tier 0, with the other control-plane services (topology). It holds the BYPASSRLS database login and the mesh zone’s Cloudflare token. It holds no Vault token.

A coordinator host is not tier 0. What it holds reaches only environments it already runs:

  • The placement rule. A host coordinates only environments that have a workload on it. Root on that host already reaches those environments’ containers, volumes and database credentials, so their coordinators give it nothing more. Root on a host never reaches another environment’s coordinator.
  • No Vault token, no database login. The keys a host’s coordinators mint go to Vault through the agent gateway (POST /v1/agent/mesh/secret). The gateway accepts a key only under organizations/<org>/environments/<env>/mesh/, and only for an environment whose segment that node coordinates. Its policy (pushleft-agent-gateway.hcl) gained create on the mesh paths for this.
  • Answers are scoped. A host answers the controller only for its own segments, and the controller checks each answer’s identity, URL and port range. A lying host can corrupt only its own environments’ networks.

The coordinator containers run as 65532:65532 (the distroless nonroot user), not as the image’s root. They also run with --userns host, like BuildKit, so that on hosts with userns-remap (H3) the host uid is also 65532 and the agent can give the state to it. The agent gives the root-owned config files to that uid on every pass. It gives the data tree to it only when no container mounts it, before it creates the container. A coordinator that still runs as root is verified as Pushleft’s and created again on its own port. The containers drop every capability, run read-only with no new privileges, and run only the pinned Headscale image. The management Headscale on the control plane (pushleft-mgmt-headscale.service) runs the same way.

Platform containers run non-root (decided 2026-11-07, Waseem: all three now). Headscale and cloudflared run as 65532. The Tailscale environment gateways stay container root. They are kernel-mode subnet routers: app containers send packets for peer /24s through tailscale0, which needs /dev/net/tun, NET_ADMIN and nftables in the gateway’s network namespace. Docker gives a non-root --user no effective capabilities from --cap-add, and no-new-privileges blocks file capabilities. Userspace networking has no tun device, so it cannot forward those packets. On hosts with userns-remap, the gateway’s container root is already an unprivileged host uid.

pushleft-mesh run needs no Docker and no root. The local diagnostic commands (ensure, publish, issue-key, approve-routes) still drive a coordinator on the host they run on, with a Vault token, for fixtures (npm run test:mesh).

Nodes hold no Vault token at all. The agent gateway leases an ensure_environment_gateway job with a single-use, response-wrapped copy of its pre-auth key. It does so only when the key’s path is under that node’s own mesh/<node>/ prefix, so no node can get another node’s key (node secrets).

Until 2026-11-03, a dedicated mesh host (pool mesh, tier 0) ran every coordinator. It held every environment’s state, the BYPASSRLS login and a Vault token that wrote enrollment keys for every organization. Root there reached every tenant’s mesh. That pool, its installer and its Vault policy are gone.

t policy

The tailnet policy decides which gateways can reach each other. Each environment’s tailnet contains only that environment’s gateways. Its Headscale policy has one grant: from the environment’s approved gateway subnets to the same subnets, all ports. With no approvals, it has no grants at all.

The worker renders the policy from its own route fences (routes-<node>.json). It does this whenever a coordinator is ensured, and after every route approval or withdrawal:

  1. Replace config/policy.json.
  2. Validate it with headscale policy check.
  3. Send SIGHUP.

A policy-reload.pending marker in the segment directory keeps the reload armed across a crash or a failed check. Coordinators created with the earlier allow-all policy migrate by the same path on their next ensure.

Sources are subnets, not node addresses. WireGuard drops a packet whose source lies outside the sending peer’s approved routes. A node counts only as the router of the /24 that the worker approved for it under the receipt checks below.

  • A node with no approved route matches no grant. It sees no peers and reaches nothing. An example is a node registered with a stolen or racing pre-authentication key.
  • A gateway that forwards to anything outside the environment’s subnets is refused by the receiving gateway’s filter. Examples are another environment’s bridge on the same host, or the host itself.

Gateways run tailscale up with --snat-subnet-routes=true --stateful-filtering=false.

  • Stateful filtering drops every new flow forwarded into tailscale0. An application container that opens a connection to its database on another host makes exactly such a flow. With it on, no cross-host connection was possible (G4, found by test:fleet-vms on 2026-10-20).
  • The bridge behind a gateway holds only that environment’s containers. The host’s pl_env_* table already confines what they reach.
  • The receiving gateway masquerades forwarded flows to its own bridge address, so the destination host’s firewall sees a local source.

Containerboot passes these flags to tailscale up only, never to the tailscale set it runs for an enrolled profile. The agent therefore recreates an older gateway and runs tailscale set --stateful-filtering=false until the effective preferences match.

Tags are not used. In the pinned Headscale (v0.29.5), a node registered with a tagged key belongs to tagged-devices. It leaves its per-node node-<id> user. Enrollment recovery and route approval are bound to that user.

  • Pre-authentication keys stay untagged, single-use, non-ephemeral and valid for ten minutes.
  • Node expiry is disabled (node.expiry: "0"). Gateways never re-authenticate, so coordinator ensure clears any expiry still set (nodes expire --disable).
  • mesh_node_expiring pages when an expiry cannot be cleared within 7 days.

Limits.

  • A racing node could register first with another node’s key and advertise that node’s subnet. It still passes route approval, because it controls the hostname, key and subnet. It then is that environment’s gateway on that host, and the policy cannot tell.
  • No other node can get the key. Nodes hold no Vault token, and the gateway wraps a pre-auth key only into a lease of the node named in its path.
  • A node that registers with its own key under another hostname, user or subnet is refused at route approval (owned_node and validate_advertisement in crates/pushleft-mesh/src/routes.rs).
  • Accepted limit (2026-11-10): another process on the same host could register with that host’s key before its gateway does. Approval does not compare the gateway’s WireGuard key. That process needs host root, which already defeats every other control on the host.
  • The SIGHUP reload has no readback in Headscale’s file mode. headscale policy check proves only that the server accepts the file. It does not prove that the server has applied it.

Coordinator runtime

Each environment has its own digest-pinned Headscale container, private Docker bridge, Noise key, policy and SQLite database. Runtime inspection refuses foreign ownership, changed specifications, extra ports, mounts or networks, and weakened container restrictions.

Ports. The only published Headscale socket is an HTTP port on the host’s management tailnet address (loopback for the local diagnostic commands). Each coordinator gets a pinned port from 18080-19079. Pushleft takes the first port that no coordinator holds (running or stopped) and that nothing listens on.

  • The port is pinned because Docker reallocates an ephemeral binding when the host restarts. After a mesh-host reboot, two coordinators raced for one port and one stayed down.
  • The worker serializes creation. A container whose docker run failed before it ever started is removed and created again (test:fleet-vms, 2026-10-20).
  • A coordinator created before ports were pinned still has an ephemeral port. On its next ensure, the worker checks that the container is ours, removes it and creates it again on a pinned port. It then republishes the Caddy route to that port. A provider recovery keeps the verified port and skips this step. The state is in the bind mounts, so only the process restarts.

Caddy terminates public HTTPS for the exact environment hostname. It denies the administrative API, metrics, debug and Swagger paths.

The coordinator uses a private Caddy admin Unix socket where available.

  • Provision Caddy’s managed route bucket with ID pushleft-mesh-router. Its first handler is a subroute that contains a routes array.
  • The worker keeps other routes in that array, with ETag/If-Match compare-and-swap.
  • Operators must provision valid TLS certificates and restrict the Caddy admin endpoint. The worker does not bootstrap certificates.
  • Headscale DNS records are DNS-only A records. Application ingress proxy settings are separate.

Durable reconciliation

Reconciliation turns reserved capacity into a sealed, verified network, step by step, and survives restarts.

Reservations. Migration 0018 separates capacity reservation from workload admission. The scheduler can reserve a database node while its segment is still provisioning. This creates a durable network_attachment_requests membership and an immutable, globally unique /24 from 10.128.0.0/9.

  • Both database capacity and gateway overhead stay reserved until execution is ready. The overhead was 500m CPU and 256 MiB RAM per selected host and environment. New gateways reserve 1 CPU (tenant gateway CPU).
  • reserved + active count against capacity and share the unique live-resource index.
  • Repeated polling reuses membership without consuming another subnet slot.
  • Slots never cycle or expire. Pool exhaustion fails closed, so Pushleft never reuses a prefix that stale remote work might still reach.

The database job stays untargeted, and its instance has no active node, until the independent network admission predicate passes. Only then are its allocations activated and its typed execution job targeted.

  • Existing reservations recheck node ownership, region, pool, schedulability, capabilities and heartbeat freshness.
  • These requests are desired membership, not proof of applied topology.
  • Do not release capacity or CIDR reservations on a timeout alone.

Sealing. Migration 0019 adds immutable initial topology sealing and prepared host tasks. With PUSHLEFT_TAILSCALE_IMAGE/--gateway-image configured, the mesh worker:

  1. Waits for all active initial database intents to have reservations.
  2. Seals at most 65 members, with exact request, node and prefix bindings, the configured image and state root, and the host interface.
  • Membership insert and delete take the segment lock. After sealing, only an application host can be inserted (it joins through a topology revision). A delete is always refused.
  • A database host, or a role bound to a volume or a box-bound address, still fails with a fenced-rollout requirement.

The online Linux agent advertises its configured --public-interface/PUSHLEFT_PUBLIC_INTERFACE.

  • The setting must name an existing non-loopback Linux interface. An absent interface prevents initial sealing.
  • Managed VM bootstrap must configure it. Application manifests cannot choose host interfaces.
  • --gateway-state-root defaults to the agent’s /var/lib/pushleft/mesh root and must match the host agents.

Sealing creates blank attachment skeletons and receipt-bound enrollment jobs. No fake Vault reference or partial desired hash is persisted. After actual issuance, one transaction initializes the gateway, firewall, host-route and provider specifications and the exact task payloads.

The ordered host queue prepares, in this order:

  1. An empty owned bridge plus nftables.
  2. The gateway.
  3. Host routes.
  • Firewall checks never create a bridge.
  • A gateway lease requires current firewall evidence.
  • Prepared jobs must exactly match persisted payloads.
  • Destroying or destroyed segments refuse new host work.
  • Provider checks enqueue only after fresh host evidence.
  • Database hosts publish no ports. Ingress targets need a separate placement and mapping workflow.

Each stage is checked again when its evidence is 30 s old. On a node that advertises network_local_checks, the agent reports its own checks every 30 s (admission evidence). A check job is then due only after 90 s without evidence. When local reports stop, the job has 30 s of the 120 s window. Ensure conditions are the same on every node: a generation behind, no evidence, or evidence from the future.

Deduplication is per operation family. A queued downstream gateway or route job cannot suppress the prerequisite refresh that makes it leaseable. Saved topologies keep eligible healthy peers even when another member is offline.

Topology reconciliation runs in a separate bounded worker, with a 150 ms database lock timeout and a 3 s statement timeout. A busy segment cannot block global coordinator and provider health scheduling.

Segment activation (migration 0059). The scheduler calls activate_network_segments() every tick. In one statement under the segment row lock, it moves a provisioning segment to ready only when all of these are true:

  • Its topology is sealed.
  • Its coordinator is ready, checked within 120 s and still valid.
  • Every sealed member host has an unreleased attachment. Its gateway, firewall, host-route and provider-route evidence match the desired generation and were checked within 120 s.
  • No unreleased attachment lacks that evidence.

Activation is one-way. Admission stays per attachment (ready_network_attachments), so a host whose evidence goes stale drops out by itself. The teardown fence keeps a destroying segment from matching.

  • Tests: segment_activation_tests in scripts/application-placement-e2e.sh. End to end on the staging fleet (scripts/staging/staging.sh smoke), where nothing writes the status by hand.
  • Host-wide and provider firewall prerequisites beyond the per-attachment evidence are still not modelled.
  • Migration 0020 adds receipt-bound credential revisions without relaxing runtime task and generation fences. A consumed key’s expiry must not invalidate an enrolled gateway’s identity.
  • The agent has independent serial execution lanes (execution lanes). A test blocks a database command while a mesh health attempt reports its result.
  • Fleet-scale health latency and saturation are unverified.
  • Release blockers still include combined reservation-to-workload transport and fault tests.

Topology revisions

A sealed network can add an application host (decided 2026-11-05, migration 0136), and an idle member can leave it (member removal, decided 2026-11-06, migration 0147). Before this, the member set stayed fixed from the first deploy. An environment could not restart on another box when its box was lost, and a drain could not move it.

What changes. A revision is the only way to change a sealed member set. Each revision is one transaction in the mesh worker (topology::revise):

  1. The scheduler places a stateless role (web, private, worker, or a one-shot role) of a sealed environment on an application host that is not a member. It writes the membership request and the gateway capacity, as for a first deploy. Placement prefers members, because each new host costs every member a gateway rollout.
  2. The mesh worker sees requests that the sealed topology does not have. It seals the next topology: the same version, config and sources, generation + 1, every old member unchanged, and the new requests.
  3. In the same transaction, every prepared member attachment moves to the new generation. Only its peer list (the other members’ subnets) and its generation change, in the gateway, firewall and provider-route tasks together. An attachment that was never prepared moves only its generation.
  4. The new host gets a skeleton attachment at the new generation and its own enrollment, the same as a first member.

Then the normal host queue rolls each member: firewall, gateway, host routes, provider route. Every stage is due because its recorded generation is older than the desired one.

Why it is safe.

  • Generations fence every step. A job of the old generation can no longer lease or report (the agent gateway compares desired_generation). The agent refuses an older generation for the firewall, the routes and the gateway state, and the coordinator does the same for provider routes.
  • The gateway keeps its identity. Its name, state directory, address, key and enrollment stay the same, so it does not enroll again. The agent recreates the container the way it replaces a legacy gateway. It stops and renames the old container and starts the new one on the same state. If the start fails, the old one comes back. The state marker moves to the new generation only after the new container runs. A crash between these steps repeats the replacement or finds it done.
  • An enrollment keeps generation 1. The enrollment is the host’s identity on the coordinator. Credential publication and route approval accept an enrollment at or below the attachment’s generation.
  • The database checks every revision (network_topology_revision_valid, network_attachment_revision_valid). The generation goes up by exactly 1. No member is changed, and a member is removed only when its request is leaving and it is not on the coordinator’s host. The members are exactly the segment’s live requests that are not leaving. Each attachment’s peer list is exactly the other members’ subnets in topology order. Nothing else in the attachment row changes.

How it is fenced.

  • Agents first. A revision waits until every maintained member and the new host advertise environment_mesh_topology_revision. Placement on a non-member also requires it.
  • One at a time. A revision waits until every maintained member runs the current generation completely. The gateway must be ready, with all four stages at the desired generation. A third host waits for the second revision to finish.
  • Old and new never mixed. In a revised network, network_ready admits a workload only when no maintained member is still on an older generation. A role on the new host therefore starts only after every member can route to it. During the rollout, a member is out of ready_network_attachments until it reports the new generation, as after a coordinator move.

Lost and idle members. A member that is offline, lost or has no workload of the environment does not block a revision. Its attachment moves to the new generation with the others and catches up when it is maintained again. A lost member can come back, and the scheduler can place a role on it again. The scheduler then takes its released gateway capacity again, at the size of its prepared gateway. A member that stays idle on a live host leaves the topology (member removal).

Rollout order. Apply the migration, then the agents on all application and database hosts, then the control plane (scheduler and mesh). The order matters only for liveness. Without the agent capability, nothing is placed on a new host and no revision starts. No gateway is recreated by the release itself. A gateway is recreated only in an environment that gets a new host.

A database host joins the same way when the environment places a database on a host that is not a member yet. This happens, for example, when an environment adds its first database after its network was sealed (decided 2026-11-17, gliph). Not covered. A database that is already placed, and roles bound to a volume or a box-bound address, stay on their member hosts. A host that was a member and left joins again through a revision. The 65-member bound still holds. During a revision, every member’s gateway restarts once, and the private network is briefly down on that host. New job admission for the environment waits until each member has rolled. Tested against migrated PostgreSQL (a_sealed_network_adds_an_application_host_through_one_fenced_revision, a_sealed_network_reaches_a_new_application_host_only_through_a_revision, a_member_whose_gateway_capacity_was_released_takes_it_again) and in agent unit tests. The staging fleet has not proven it yet. The proof is a drain of app2 that moves a preview to app.

Member removal

An idle member leaves a sealed network (decided 2026-11-06, migrations 0147 and 0148). Until then a member stayed for good. Each idle host kept its gateway (1000m CPU and 256 MiB), and every peer kept a route to a subnet where nothing answered. A released membership was terminal history (one request per host and segment), so a host that left could never host the environment again. Migration 0148 makes one live request per host and segment unique. A released request stays history, and a host that comes back gets a new request, a new subnet slot and a new enrollment.

When a member leaves. The scheduler checks every tick (network_members.rs). A member is removable when all of these are true:

  • The segment is provisioning, ready or degraded, and its topology is sealed.
  • The environment has an active deployment or a database holding capacity. Without either, the mesh never revises the segment, and a member marked leaving would stay stuck.
  • The host is not the coordinator’s host, and at least one other member stays.
  • Nothing of the environment holds capacity on the host (reserved_environment_workload, and no role, database or volume allocation at all). No volume of the environment lives on the host or moves to it. No job of the environment is queued or leased for the host (except network and name sync work). No database operation moves to or from it. No route or port forward points at it.
  • The last role or database allocation of the environment on the host was released a day ago. When none ever ran, the attachment (or request) is a day old. PUSHLEFT_NETWORK_MEMBER_IDLE_SECONDS sets this (default 86400, minimum 1800).
  • No other member of the segment started leaving within the same time. Each removal or return is a revision that restarts every other member’s gateway. Each return also takes a subnet slot for good (network_subnet_slots, 32768 in all, never reused; alert network_subnet_slots_low at 80%). So a segment loses at most one member a day.
  • Migration 0148 has run, so the host can come back.
  • The host, the coordinator’s host and every remaining member advertise the agent capabilities (below).

How it is fenced.

  1. Leaving. Under the node lock that placement and relocation take (fleet_nodes ... FOR UPDATE), the scheduler checks again and sets network_attachment_requests.leaving_at. A role placed first holds capacity, and the check finds it. A role placed after finds the request leaving. Placement and relocation skip the host, and a role that must go there waits. The request is never reused. After the release, placement joins the host again with a new request, through the next revision. The request fence (fence_network_attachment_request) checks the same conditions again under the segment lock. So two members cannot leave at once and take the last one with them. Leaving is one-way.
  2. Revision. The mesh worker seals the next generation without the leaving member (topology::revise). The remaining members roll the smaller peer list through the normal host queue. The order is firewall, gateway, host routes and provider route. For host routes, the agent flushes the environment table and adds exactly the new peers. The leaving attachment keeps its old generation and gets no more host or route work. The agent gateway also leases, heartbeats and completes no more setup or check job for it, and drops its agent-local evidence reports.
  3. Coordinator. A remove_mesh_member controller job asks the coordinator’s host to remove it (CoordinatorManager::remove_member). The host records the removal first (member-removed-<request>.json, never deleted). Then it deletes every Headscale node and key of the host’s provider user and moves its route fence out of the tailnet policy (kept as removed-routes-<node>-<request>.json). The issuer and route approval refuse that request from then on. A later request of the same host passes the initial-issuance check, because no provider node or key of the host is left. The host refuses a removal once the host enrolled again under another request. The controller then sets mesh_removed_at.
  4. Host. The scheduler fails the member’s queued network jobs and queues the existing remove_environment_gateway task for its one attachment. The gateway leases, heartbeats and completes it only under network_member_removal_authorized. That check needs the request to be leaving and gone from the coordinator, and the sealed topology must not have the host. The host must not be the coordinator’s host, and the task must be exactly network_teardown_task. No other network attempt for the attachment can be in flight. The agent’s teardown removes only this environment’s objects on this one host. They are the gateway container, routes and their fence, the nftables table, the bridge, state and key material. Other members are on other hosts.
  5. Release. The receipt sets the attachment removed with released_at. finish_network_member_removal releases the request and its gateway capacity in the same transaction, with a network_member_removed fleet event (network_member_leaving was recorded at step 1). A member that never had an attachment is released at once in step 4. A failed teardown is queued again every hour.

Rollout order. Use two deploys, because 0148 breaks the mesh that came before it. That mesh inserts attachments with ON CONFLICT (segment_id, node_id), which PostgreSQL cannot match to the partial index (42P10). Topology reconciliation would then fail for every sealed network.

  1. Migrate to 0147. It only adds columns, functions and fences, which the running binaries ignore. pushleft-api migrate applies every migration embedded in its binary, so this step needs an API built from a commit without 0148 (2c17f0d3, the commit that added 0147). An API built from f139d062 or later would apply both at once.
  2. Deploy the control plane: mesh, scheduler and agent gateway. They need 0147 and work with or without 0148 (the mesh inserts with a plain ON CONFLICT DO NOTHING). Two scheduler versions must never run at once: an old scheduler would reuse a leaving request. The systemd restart stops the old process before it starts the new one.
  3. Migrate to 0148 with an API built from f139d062 or later. It must never ship together with 0147 while an earlier mesh runs. A fresh installation has no earlier mesh, so it can apply both at once.
  4. Deploy the agents on all application and database hosts. They advertise environment_mesh_member_removal and answer the coordinator’s remove_member call.

Production ran this rollout on 2026-11-06: 0147 with the mesh, scheduler and gateway from 2c17f0d3, then 0148 with the API from f139d062, then agent 0.1.0-f139d06 on all five hosts. Nothing is removed before 0148 exists and before the host, the coordinator’s host and every remaining member run the new agent. No member leaves before its idle day is up.

Not covered. A lost host is not removed while it is lost. It leaves a day after it comes back idle. A segment in provisioning waits for a leaving member’s release before it activates. Tested against migrated PostgreSQL (an_idle_member_leaves_through_one_fenced_revision, network_members_tests, a_leaving_member_teardown_is_fenced_and_its_receipt_releases_it, a_leaving_member_gets_no_more_setup_or_checks, a_leaving_member_reports_no_evidence). The coordinator removal is tested against a real Headscale (scripts/mesh-e2e.sh: keys go, the old request is refused, a new request enrolls, the old removal then refuses). A removal of a registered gateway and a full removal on the staging fleet are not yet proven.

Credential renewal

Automatic deployment credential renewal is not production-ready (gap).

  • The private issuer implements its provider-side renewal barrier in enrollment.rs.
  • Database publication and host-job and result revision fencing are implemented.
  • Automatic scheduling, agent-side credential restaging and remote-operation quiescence still need implementation and verification.
  • An unused-key inventory observation alone is never used as a registration barrier.

The pinned upstream implementation separates key expiration and consumption CAS from registration persistence. Expiry readback alone therefore does not prove that earlier registration work has stopped.

Renewal journal. The issuer persists enrollment-write.pending.json before a renewal mutation. The journal is bound to the previous receipt and the immutable coordinator ID, specification and verified loopback port.

Its bounded state machine is expire → quiesce → issue → publish:

  1. Retire an uncertain runtime before retrying expiry.
  2. Verify the committed expiry.
  3. Remove the immutable runtime again.
  4. Read the provider node and key provenance.
  • Runtime recreation keeps the SQLite and Noise data and the exact proxy port.
  • Exact consumption keeps its matching receipt. Only a conclusively absent registration plus an expired or absent old key permits a successor.
  • A pre-create inventory finds unpublished keys that a lost response created within the per-node provider user, which only Pushleft manages. Recovery quiesces before it expires those keys. It quiesces and reads back again before it retries creation.
  • Out-of-band changes to these private provider users are unsupported. Unknown consumed or unsafe keys fail closed.

Successor metadata is journaled before the unique-path Vault CAS and readback.

  • The active receipt changes only from the recorded predecessor or the retained intermediate chain. Historical receipts are immutable.
  • Candidates stay in the chain through retirement. A registration during publication fallback is then resolved against the correct receipt after quiescence.
  • A pending journal blocks coordinator publication, routes, revocation and other enrollment intents until the exact intent recovers.

First key. First-key issuance also uses this journal, before user creation or key creation.

  • Initial journals bind initial_identity without inventing a predecessor receipt. Existing renewal journals keep their previous-receipt format.
  • A fresh request for a node with any issued-key or registered-node provenance is rejected before journaling. A new request is not an identity-rotation operation.
  • The initial prepare_user stage retires an uncertain immutable runtime, rechecks empty provenance and reconciles the unique per-node user.
  • Conflicting provenance found at this pre-key stage releases only that empty initial journal after quiescence. It does not adopt the other request or leave a global dead fence.
  • The shared issue and publish stages expire newly created unpublished keys, quiesce and read back expiry, and journal candidate metadata before the Vault CAS.
  • A lost user-create response is recovered by exact user-name inventory after runtime retirement. Creation is not blindly repeated.
  • Missing initial active receipts are allowed. An existing unrelated receipt cannot be overwritten.
  • A registered key without durable matching receipt provenance fails closed.

The recovery above covers the provider side only. The tests do not prove agent restaging, live topology expansion or aggregate admission.

File publication. Immutable metadata and history publication writes and fsyncs private staging bytes. Then it installs a hard link without replacement and fsyncs the containing directory.

  • Retries acknowledge only identical regular files. Foreign content and symlinks are refused.
  • First identity-marker staging lives in the private state root, outside the segment directory that is not marked yet. A crash cannot make its own temporary file look like foreign segment data.
  • Unmarked segment data is never adopted.
  • Old partial final files from earlier implementations are not overwritten automatically. Investigate their provenance privately before you attempt recovery.

Upgrade direction matters. The new worker can read prior renewal journals, but older binaries cannot recover the new initial stage. Complete pending journals with the compatible worker before a binary rollback. Never delete a journal to make a downgrade proceed.

The real provider fixture covers committed initial user and key creation with lost responses, unpublished-key expiry and exact-request recovery. It also covers rejection and release of a conflicting initial request. Seeded conflict boundaries do not prove every concurrent transport interleaving.

The real fixture also checks:

  • Recovery from committed expire and create with lost responses.
  • Orphan expiry, and recreation with a fixed port and immutable ID.
  • A seeded crash after the active rename, followed by successor expiry.
  • A retained consumed candidate during a Vault outage.

It also pauses the actual expiry command after an unused-key observation and registers a real Tailscale gateway with that key. It checks that recovery keeps its receipt and provider identity, with no extra keys or Vault writes, and removes the paused immutable runtime. This proves that a registration which commits before expiry is released is kept. It does not cover a registration paused inside the provider that commits after expiry.

Credential publication

Database publication keeps the enrollment identity, provider node ID and runtime generation and specification hashes. It tracks a separate monotonic credential revision.

  • Explicit renewal jobs bind credential_revision, expected_secret_ref and expected_provider_key_id to the old receipt.
  • Preflight acknowledges exact committed history before it contacts the provider.
  • publish_mesh_credential checks authorization and the live lease again after resource-lock waits. It compare-and-swaps the expected receipt and records append-only history. It atomically replaces only the auth references in all three prepared intents.
  • Replacement clears all independent health evidence. Readiness never transfers to a new credential.
  • A same-receipt acknowledgment does not advance the revision.
  • Superseded host and provider jobs cannot publish or invalidate newer evidence. Queued superseded work is terminalized without suppressing the current repair.
  • Cleanup never revokes a shared candidate while another eligible publisher could commit it. Terminal revocation requires a committed eligibility fence.

publish_mesh_credential is invoker-security and has no PUBLIC execute permission.

  • Provisioning must grant its exact function signature to the private mesh worker role, with its required table permissions. Never grant it to the browser role.
  • Missing revision fields keep legacy revision 1. Explicit malformed or null revision values are rejected.
  • Migrated-database tests cover publication and replay, strict parsing, prepared-task immutability, health reset, blocked-lock lease expiry, shared-candidate cleanup and rejection of stale gateway heartbeats and completions.

These database fences do not prove that a remote Docker operation dispatched earlier has stopped.

Route retries. A failed route check converts to ensure only for the exact current task, revision and assigned coordinator.

  • Queued superseded route jobs are retired with a bounded, job-only SKIP LOCKED selection. Locked, leased, current and other-coordinator jobs are kept.
  • Completion holds the job lock before resource locks. It does its final live-lease CAS against clock_timestamp() after resource waits.
  • Expiry rolls back status changes, retry conversion and health invalidation together.
  • Real two-connection regressions prove that publication waits for the current retry conversion. They also prove that an expired completion cannot erase health after it waits on an attachment lock.

Production still needs proof for:

  • A registration paused inside provider validation across expiry.
  • Every journal crash and cancellation boundary.
  • A delayed Create that survives a Docker-client timeout.
  • Combined provider and database publication loss.
  • Stale host execution and fleet-wide recovery latency.

Seeded crash-boundary tests do not replace concurrent registration transport tests. None of this work opens aggregate admission.

Teardown and authorization

Teardown. Reservation publication holds a shared source-deployment lock and accepts only active lifecycle states. Teardown, failed or unknown states stop only that deployment’s queued job. They do not mark a shared database instance as in error.

  • Agent leasing repeats the lifecycle check under a shared deployment lock for deployment-owned database work.
  • Service and catalog operations without a deployment stay independent.
  • Work that is already running when teardown is requested still needs the explicit cancellation and fencing workflow. Pushleft does not forcibly stop it or recycle its capacity.

Coordinator readiness. Migration 0015 adds coordinator health and tenant-scoped enrollment intents. Migration 0017 adds independently fenced provider-route evidence.

The run command:

  1. Leases provision_tailnet, issue_mesh_enrollment and reconcile_mesh_routes jobs.
  2. Binds each segment to its coordinator node.
  3. Checks actual HTTPS health before it records coordinator readiness.

This readiness is not environment network readiness. Attachment, host routing, provider firewall and periodic host enforcement gates must still pass before deployment admission opens.

Fleet guards. Fleet authorization uses private, shared guard rows, acquired in UUID order before segment and attachment locks.

  • Status, pool and ownership changes and deletion take exclusive guards through database triggers. Heartbeat and capability updates do not.
  • Eligibility is read again after guard acquisition, in a separate statement.
  • This permits concurrent environments and heartbeats, and serializes revocation with publication.
  • Enrollment identity is immutable. Rotation requires a new intent.
  • Revocation clears the affected coordinator and attachment evidence. Changing coordinator identity clears its health and does not transfer readiness.
  • Provisioning also checks current managed, mesh, active and fresh authorization before it publishes health.

Coordinator evidence expires no later than its observed fleet heartbeat plus 60 seconds. Admission also requires its HTTPS check within 120 seconds. The tenant-invoker admission view reads only tenant-scoped segment and attachment evidence. It does not read global fleet inventory. The migration backfills no readiness or provider proof.

The runner schedules due health every two seconds, even when jobs are queued. Up to eight workers drain available work without a fixed per-job sleep, with a 16-connection database pool. These bounds are not a demonstrated capacity or SLO. A realistic 100-attachment provider and HTTPS sweep is still a release test requirement.

Enrollment keys

Enrollment keys are non-reusable, non-ephemeral, and expire after ten minutes.

  • Raw keys go only to Vault KV v2, with create-only CAS writes. Job payloads, database rows, receipts and command output contain references and metadata, never raw keys.
  • Each provider key has a distinct Vault path.
  • Durable receipts bind the request and the secret fingerprint. Retries check provider ownership, expiry, usage and Vault integrity.
  • An ambiguous write is read back before success is reported.
  • Missing or expired keys are revoked or rotated. Unknown credentials are never adopted.
  • Final publication repeats authorization under row locks. Revoked nodes, changed ownership, stale attachments and destroying segments cannot be certified as issued.

Workload nodes hold no Vault token. The gateway (deploy/vault/pushleft-agent-gateway.hcl, read-only on mesh paths) wraps a node’s own enrollment key into that node’s lease. Do not expose the coordinator token or the full organization mount to agents. Receipt metadata and database backups need private access as operational security data, even though they contain no raw credentials (Vault recovery).

Subnet route approval

Route approval tells Headscale which /24 each gateway may route. Without an approved route, a gateway reaches nothing.

The private approve-routes operator command and CoordinatorManager::reconcile_routes implement explicit provider-side route approval. The durable worker:

  1. Consumes exact persisted attachment intents.
  2. Rechecks the job lease, enrollment provenance, node ownership, coordinator identity and generation and hash before provider operations.
  3. Publishes approval evidence only after fresh independent host evidence and real HTTPS checks.

A JSON intent contains node_id, enrollment_id, a typed gateway_spec and enabled. The command takes the same organization, environment and segment identity arguments as ensure, plus --task-file. --check verifies without changing route approvals, and cannot certify an unapplied generation.

The complete controller that prepares every attachment and host intent from a deployment is unfinished (gap). This wiring does not give zero-touch deployment readiness.

Recurring route checks are scheduled for persisted intents after 60 seconds. Admission takes provider-route evidence up to 120 s old, so a check has about a minute to finish.

  • Failed checks invalidate current approval evidence and retry as repair or ensure operations.
  • Exhausted expired leases are terminalized, so they cannot suppress health scheduling for good.
  • Withdrawal can run for revoked or offline workload nodes and destroying segments. It still requires current enrollment provenance, the exact desired intent and an authorized live coordinator.
  • Gateway, firewall, host-route and provider-route evidence must each match the same desired generation and be fresh before admission opens.

Approval requires:

  • The canonical environment coordinator URL.
  • A secret reference scoped to the organization and environment that matches the persisted enrollment receipt.
  • Exactly one provider node for the issued fleet-node user. The node must match that receipt’s pre-authentication key, advertised hostname and auth-key registration method. Hostname or provider ID alone does not prove ownership.

Enabled routes require a live, unexpired node that advertises exactly its assigned local /24.

  • Extra prefixes and exit or default routes are refused.
  • An overlapping approved route on another node also blocks approval.
  • The command replaces approvals with the exact assigned prefix and verifies fresh provider readback. It never appends whatever a node advertises.

Route fences. A private per-node fence of provider ID, generation and hash is persisted before mutation, under the environment coordinator lock. It prevents rollback, same-generation policy changes and silent node replacement, including after route withdrawal.

  • Check-only verification requires exactly the generation and hash already persisted. A higher generation does not prove application.
  • A changed provider node requires an explicit rotation workflow. Do not remove fence files to adopt it.
  • enabled: false with a newer generation withdraws all of that node’s approvals, even when it is offline, then verifies the empty set.
  • Keep enrollment provenance and fences for withdrawal and recovery.

Issuer retries never replace a consumed intent’s receipt. They acknowledge the identical receipt only when exactly one provider node and one consumed, single-use, non-ephemeral key match it. The match covers its node, user and key provenance and its auth-key registration method. A consumed bootstrap key’s expiry is not node expiry, so this acknowledgment neither reads Vault nor issues a new key.

  • Missing, ambiguous, unsafe or mismatched provenance fails closed.
  • Explicit re-enrollment still requires a new intent and the rotation workflow.
  • A check-only failure does not repair drift. An ensure operation is required.

Pending writes. Provider mutations use the verified immutable coordinator container ID.

  1. The worker creates a fsynced, environment-wide pending-write marker before each mutation.
  2. It removes the marker only after exact provider readback.

Errors, cancellation and lost responses leave the marker in place. While it exists, coordinator readiness, key issuance and revocation, and route checks fail closed.

An explicit route ensure recovers:

  1. Verify ownership and remove the old immutable coordinator runtime.
  2. Confirm that it is absent.
  3. Recreate it from the preserved SQLite, Noise and config state.

These steps quiesce even delayed Docker exec requests. Killing the Docker client or accepting a newer generation is not enough. Never delete the pending marker by hand. Recovery does not remove workload containers or coordinator data.

The pending marker keeps the verified loopback proxy port. Recovery binds exactly that port, so existing HTTPS handlers can reconnect without a blocked publication operation.

  • Port conflicts fail closed. The worker never allocates a different upstream silently.
  • An enabled retry may need to wait or retry while the gateway reconnects. The marker stays until its exact route policy converges.
  • The route operation alone does not attest public DNS or ACME, or every proxy path.
  • Offline withdrawal works without a gateway connection.
  • A crash after runtime removal is recovered from the same durable marker on retry.

The tests above are provider-approval evidence only. The real provider fixture and the database authorization and concurrency regressions are separate tests. They do not prove a complete distributed controller deployment. Combined fault-injected orchestration and actual multi-host transport still need end-to-end proof. Do not treat an ambiguous provider write as successful only because a local fence exists.

Configuration and verification

Use pushleft-mesh --help and pushleft-mesh run --help for the runtime arguments. install-control-plane.sh writes the controller’s settings (mesh.env.example):

  • The pinned PUSHLEFT_HEADSCALE_IMAGE from deploy/images.lock.env, sent to each host with every call.
  • PUSHLEFT_MESH_DOMAIN, PUSHLEFT_MESH_HTTPS_PORT (9443) and PUSHLEFT_DERP_MAP_URL (relay).
  • DATABASE_URL, with credentials scoped to what this trusted worker needs.
  • A scoped Cloudflare token file, the zone, and the control plane’s public IPv4.

Hosts need no mesh settings: the agent serves the host API once tailscaled has a management address. Secret token files must not be group or world accessible. Coordinator state (SQLite data and Noise keys) is not backed up (decided 2026-11-03): a lost host loses its coordinators.

npm run test:mesh needs local Docker, OpenSSL and a local Caddy binary (PUSHLEFT_CADDY_BINARY can select it). It starts real pinned Headscale instances, a real HTTPS proxy with temporary certificates, and an emulated Vault KV v2 endpoint. It checks:

  • Instance and network separation, and replay.
  • HTTPS route readback and admin denial.
  • Short-lived issuance, and failures before and after the Vault commit.
  • Provider revocation recovery, secret substitution refusal and tenant ownership rejection.

The real agent then tests untrusted-CA rejection, expired-first-key failure, same-container enrollment with a replacement key, secret cleanup, and enrolled restart while Vault GETs return 503.

  • Enrollment uses the production-generated route handlers with a fixture-only reachable hostname or IP alias. No host DNS or daemon configuration changes.
  • Linux binds the existing Docker host-bridge IP. Docker Desktop uses its host alias.
  • All fixture resources are named and cleaned up.
  • The suite is part of test:all. CI installs checksum-pinned Caddy and runs it on native Linux when the workflow runs.

It does not prove a live Cloudflare account, public DNS or ACME, multi-host workload packet routing, hostname-mismatch rejection or a complete fleet rollout.

npm run test:mesh-controller is part of test:all. It creates a uniquely named disposable PostgreSQL database and applies all migrations.

  • Lease-reaper and enrollment regressions use transaction-local fixture tables. Route and admission, topology and two-connection guard regressions use the actual migrated tables and triggers.
  • Tests cover changed authorization sources, expired jobs, invalid evidence, offline withdrawal, immutable identities, concurrent heartbeats and shared readers.
  • Tests also cover a revoker that already holds the fleet tuple and job and segment lock ordering.
  • Tests also cover blocking until provider publication releases its guard, and immediate readiness invalidation after revocation.
  • Bootstrap tests cover blank skeletons, receipt-bound atomic preparation, ordered host jobs and waiting for all initial reservations.
  • They also cover frozen multi-node peers, offline-peer maintenance, bounded contention and prerequisite-repair starvation.
  • The same command runs agent-gateway authorization races against real PostgreSQL.

API E2E separately checks tenant access to the invoker view, positive and negative, without SELECT on fleet inventory or guards. These regressions do not simulate every distributed crash or interleaving across Docker, Vault and PostgreSQL.

On native Linux, the real mesh runtime fixture must own its private bind state as root, as the production coordinator does: only root-owned state is given to the coordinator’s uid 65532. A container with all capabilities dropped cannot traverse another user’s mode-0700 directories. The test refuses this mismatch. It does not weaken directory permissions or add DAC capabilities.

  • CI opts into PUSHLEFT_MESH_E2E_SUDO=1. This runs only the disposable Python runtime fixture with noninteractive sudo. Cargo compilation stays unprivileged.
  • Local Linux operators can run the fixture as root.
  • Docker Desktop’s file-sharing permissions do not prove this native-Linux ownership property. Remote CI execution is a separate verification requirement.

The mesh fixture also runs receipt-bound subnet approval, exact readback and replay, and refusal of future-generation checks and broader advertisements. It also runs approval-drift repair, consumed-receipt preservation and offline withdrawal.

A temporary Go helper (standard library only, built with the pinned toolchain) runs inside the disposable coordinator’s executable data bind. It stays alive past a real Docker-client timeout and attempts a delayed write. The test requires:

  • Immutable-ID quiescence.
  • Recovery of the same enabled intent through the preserved proxy port.
  • No stale re-enable after withdrawal.
  • Recovery from a committed write with a lost response, and from a crash after the marker.
  • SQLite node-identity retention and real HTTPS verification.

The production noexec tmpfs restrictions are not weakened. Occupied-port and foreign-runtime regressions, and concurrent recovery and cancellation regressions, are still release proof gaps.

Production release still needs complete attachment orchestration, firewall enforcement and reverification, and managed service operations. It also needs restore and HA exercises and passing runtime image vulnerability scans.

Tenant gateway CPU

New application and database environment gateways reserve 1 CPU and 256MiB per host and environment (decided 2026-11-04; 2 CPUs from 2026-10-29, 500m before that). The gateway container’s --cpus equals the reservation.

  • Existing 500m and 2000m reservations stay valid until you resize them. The allowed sizes are 500, 1000 and 2000.
  • Management Headscale coordinators keep their own 0.5-CPU limit.
  • Gateway CPU is a typed runtime budget, separate from network identity. A resize updates the verified owned container in place, and keeps its enrollment, IP and routes.
  • The agent checks the exact declared budget during later health checks.

To resize an existing gateway:

  1. Upgrade the agent, mesh, scheduler and gateway binaries, and apply migration 0127 (0094 for 500 and 2000 only).
  2. Quiesce mesh reconciliation and placement. Wait for the environment’s network leases to finish.
  3. Run scripts/resize-environment-gateway-cpu.sql as the database owner, with explicit org_id, environment_id and cpu_millis=1000 psql variables. It resizes every gateway of that one environment. The script locks the nodes and checks headroom when the size grows (a shrink is never refused). It replaces the allocation at a billing boundary and changes only CPU in all three prepared task copies. Then it queues the in-place update.
  4. Resume services. Verify the runtime limits, and both gateway and route admission readiness.

To find the environments that still have 2000m gateways:

SELECT DISTINCT a.org_id, s.environment_id FROM network_attachments a
JOIN network_segments s ON s.id=a.segment_id AND s.org_id=a.org_id
JOIN fleet_allocations f ON f.resource_kind='network_attachment' AND f.resource_id=a.id AND f.status IN ('reserved','active')
WHERE a.gateway_status<>'removed' AND f.cpu_millis=2000;

Replays are idempotent. The same script with 2000 or 500 restores an earlier budget if needed. Do not leave docker update overrides: they disagree with accounting and admission (meters).

Rendered from the repository at build time. Edit docs/mesh-coordinators.md to change it.