SERVE FEDERATION
Note
Preview. Serve federation is a preview feature: no flag turns it on, and its commands and the serve-hub app may change in later releases. Every serve and every CLI that uses it must run Swamp 20261129.160739.0 or later.
A team that runs one swamp serve can see everything about it from that server.
A team that runs ten, one per environment, region or customer, cannot: each
answers only for itself, and finding out which version each runs, how each is
configured, and which are up means asking each in turn. Serve federation gives
those servers one place to report to. One serve becomes the hub, the others
join it as members, and the hub records what each member says about itself.
This page explains why it is built the way it is. To set it up, see Set Up a Federation Hub and Join a Serve to a Hub; for every command and field, see the Serve Federation reference.
A hub only shows
In this preview the hub sees its members and changes nothing on them. It cannot run a workflow on a member, push configuration to it, upgrade it or manage its workers. Rollouts, configuration changes, upgrades and worker management are left for later releases, each with its own design.
Starting with visibility alone keeps the trust a member places in its hub small. A member that joins tells the hub some facts about itself, and that is all joining grants. An operative can join a production serve to a hub without first deciding who on the hub side may change production.
The shape is deliberately flat. A serve is a hub, a member or neither; a member belongs to exactly one hub; there is no hub of hubs. Moving a member to another hub means removing it from the first.
Members pull
Members call the hub; the hub never calls a member. Each member instance sends a check-in over HTTPS every 30 seconds, on the hub's own listener, and the reply sets the next interval. The hub needs no network route to any member, so a member behind a NAT, a firewall or a load balancer that only allows outbound traffic can still join. Polling also passes through proxies and load balancers that a long-lived connection would not, and it leaves room for later releases: a member that pulls its state can also pull work.
The dependency runs one way and stops there. A member checks in from the background, started once serve is ready. Serve's startup, its readiness, its runs, schedules and workers never wait on the hub, and a hub that is down or unreachable never stops a member. The member backs off, up to five minutes between attempts, and carries on with its own work.
What the hub sees
A member reports a fingerprint: a fixed list of facts about itself. Its
swamp version and platform, its serve.yaml version, deployment mode, datastore
kind and format, vault kinds, auth mode, whether TLS, remote-only and
loopback-only are on, its federation role, its extensions, a hash of its
settings, its worker counts, and runtime facts such as its team role and size,
when it started and whether it is ready.
The list is an allowlist. No hostname, IP address, port, file path, username, grant, secret or hash of a secret leaves a member, and nothing a member stores, its data, runs or vault contents, is sent to the hub. A member is known by the name its join token gave it, not by where it runs. Deciding up front what may leave settles data residency before the first member joins: a serve holding data that must stay in one region can join a hub elsewhere, because the fingerprint carries no data.
A list fixed in the code is also one that can be reviewed. Adding a field is an architecture decision, not a side effect of collecting more.
The settings hash covers configuration only: auth mode, limits, timeouts, the policy flags and similar settings, never including admins, users, secrets, paths, hosts or ports. It answers one question, "has this serve's configuration changed?", so a restart, a worker reconnecting or a runtime fact changing never moves it.
History is data
Each member is a record of the built-in type swamp/serve-member on the hub.
Because it is ordinary Swamp data, its history comes from the data layer: every
version of the record is a point in the member's history, and it can be queried
like any other data, or shown as a timeline by the serve-hub app.
A record gets a new version only when something worth remembering changes: the fingerprint hash, the worker counts or the member's status. The time of each check-in is kept apart from the record, in the hub's control-plane store. If check-ins wrote to the record, every member would add a data version every 30 seconds, and the history would be all heartbeat and no change.
The record holds no secret and no hash of one, since anyone with data read on the type can read it. The hub keeps credential and token hashes in its control-plane store instead.
Joining safely
A member joins with a join token, minted on the hub for one member name. A token is single-use, and expires after an hour unless minted for longer, up to 30 days. The hub keeps only its hash. Joining spends the token and returns a member credential, which the member stores in its encrypted control-plane vault and sends with every check-in. The hub keeps only the credential's hash, too. Removing a member deletes its credential, and its next check-in is refused.
A join must survive a lost reply. If the hub spent the token and the answer
never arrived, a plain retry would be refused as a used token, and the member
would be stranded until someone minted another. So each join carries a joinId
the member chose and kept. A retry with the same token and the same joinId
gets the same membership back with a fresh credential, and the old credential
stops working. Without the joinId, a used token is refused like any other.
Further limits keep one member, or one caller, from growing without bound. A
member has at most 64 live instances, and an instance unseen for 24 hours is
dropped. The join and check-in routes are rate limited per address, and failed
attempts count against the caller. Joins, replayed joins and refused check-ins
are written to the hub's audit log, coalesced so that a stopped member calling
with an old credential cannot flood it, and no event carries a token, a
credential or a joinId.
Version 2 first
Serve federation needs serve.yaml version 2 on the hub and on every member,
because version 2 is the version that refuses a key it does not know. A misspelt
federation key in a version 1 file would be ignored, and the serve would run
outside the federation without saying so. See
Configuration Layers
for why version 2 exists, and
Move serve.yaml to Version 2
for moving a file.
Related
- Serve Federation reference — configuration, commands, statuses, limits and the fingerprint fields
- Set Up a Federation Hub
- Join a Serve to a Hub
- Manage Federation Members
- See Several Serves from One Hub — a walkthrough on one machine
- swamp serve — the server each member and hub runs