Fleet public routes design (Phase 1a of #457), draft rev 1
An app placed on a fleet gets a forward row on the hub (the console's box, which holds the fleet tunnels), written by the hub's own instance pass from records it already reads, checked against the hub's local fleets table, and served by the existing fleetProxy. Witness: shop.bab.dev.oncarlos.com on dev fleet r10r. Draft for Paul's read; no review rounds yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+671
−0
docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md+671 −0
diff --git a/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md b/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md| new file mode 100644 |
| index 000000000..6487be64e |
| --- /dev/null |
| +++ b/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md |
| @@ -0,0 +1,671 @@ |
| +# Fleet public routes: an app on a fleet serves at its URL with no hand row |
| + |
| +Status: DRAFT rev 1, 2026-10-29, for Paul's read. No review rounds yet. |
| +Discussion: amadan carlos/platform #457 (this is its Phase 1a, pulled out |
| +on its own because it needs no rented boxes and no billing). Branch |
| +`design-fleet-public-routes`, cut from main `1fa2a99b`. Every file:line |
| +below is on that commit. |
| + |
| +## 1. Intent |
| + |
| +Paul, 2026-10-29: "these apps need to be behind the router... I want to be |
| +able to see the app running at a URL!" |
| + |
| +An app placed on a fleet (BYO today, managed later) must answer at its |
| +public URL through the platform's router, with its certificate and its |
| +custom domains, and nobody writes a route row by hand. Native and rootfs |
| +apps alike. |
| + |
| +The witness is the rootfs sample on dev: fleet `r10r`, box `box-1` |
| +(i-0c966f9d7826ed65d, kass eu-west-1), app `shop` in account `bab`, |
| +instance `shop.bab.dev.oncarlos.com`, serving `v1` on box-1. Acceptance: |
| + |
| + curl -sI https://shop.bab.dev.oncarlos.com/up |
| + |
| +answers `200` with `X-Carlos-Version: v1`, from anywhere, with no hand row |
| +on any box. |
| + |
| +## 2. Goals and non-goals |
| + |
| +Goals: |
| + |
| +- G1. Every record placed on a fleet gets a row on the box that holds that |
| + fleet's tunnels (the hub), within seconds of the record appearing, and |
| + loses it when the record goes, moves or stops qualifying. |
| +- G2. The row forwards over the fleet's tunnel. It runs nothing on the |
| + hub: no release is staged, no process started, no database replicated. |
| +- G3. A fleet's tunnel carries only hostnames of the account that owns the |
| + fleet. Checked where the row is written and again where it is served. |
| +- G4. Certificates, custom domains, backhaul from other platform boxes and |
| + `X-Carlos-Version` work for these hosts through machinery that exists. |
| +- G5. No new steady-state bucket requests on any box. |
| + |
| +Non-goals (other work): |
| + |
| +- Managed provisioning, billing, enrolment (#457 phases 2 and 3). |
| +- 1b, which box in a multi-box fleet runs an instance. §4.5 states what 1a |
| + assumes and what it leaves broken. |
| +- 1c, the reboot lease (#451). |
| +- Fleet boxes not ordering certificates they can never be validated for |
| + (box-1's failing autocert, §3.6). Noise, not a blocker; a follow-up. |
| +- Regional domains (#447) and path maps over fleet hosts. |
| + |
| +## 3. What happens today |
| + |
| +### 3.1 How a platform record becomes a route |
| + |
| +Every platform box runs the instance pass, `provision.Reconcile`, on the |
| +change index (`internal/host/changeindex.go:283`, seconds after a console |
| +write bumps the serial) and on a 5-minute backstop |
| +(`internal/host/agent.go:3878`). The scan reads every instance record in |
| +the bucket, judges it, validates it, and only then asks scope |
| +(`internal/provision/reconcile.go:1217`). A record in scope becomes a row |
| +through `RouteFor`, the one renderer. A row the pass minted or adopted is |
| +`Provisioned`, which is what grants the removal phase authority over it |
| +(`reconcile.go:2044`). |
| + |
| +### 3.2 `inScope` refuses fleet records from both sides |
| + |
| +`inScope` (`reconcile.go:487-499`): region equality is the home-box test, |
| +widened only for the everywhere classes, and never across the fleet |
| +boundary. A record with `Region == "fleet/<f>"` is in scope only on a box |
| +whose own region is `fleet/<f>`, that is, the fleet's own boxes. A |
| +platform box reads the record and skips it. The removal phase asks the |
| +same `inScope` of the row (`reconcile.go:2044`), so a fleet-placed row on |
| +a platform box is never retired by this pass either. |
| + |
| +That boundary is right and stays: a platform box never runs a fleet |
| +record, and a fleet box never runs a platform record. |
| + |
| +### 3.3 The hub and the tunnel |
| + |
| +A fleet box dials out. `tunnelLoop` (`internal/host/tunnel_client.go:35`) |
| +reads `CARLOS_TUNNEL_URL`, `CARLOS_TUNNEL_NAME` (`<fleet>/<label>`) and |
| +`CARLOS_TUNNEL_TOKEN`, dials the hub's ordinary :443 listener, sends |
| +`GET /register` with the bearer token, and the connection inverts: the hub |
| +becomes the HTTP/2 client, and the box serves its WHOLE edge over it |
| +(`go tunnelLoop(e)`, `agent.go:1026`; `internal/tunnelclient`). |
| + |
| +The hub is the box whose edge has `CARLOS_TUNNEL_HOST` set |
| +(`enableTunnelsFromEnv`, `internal/edge/edge.go:4066`). It authenticates a |
| +fleet dial against the `fleet_boxes` table in its own registry |
| +(`FleetChannelAuth`, `internal/registry/fleets.go:625`, active boxes only), |
| +reloaded with the routes (`edge.go:1112-1134`), which also loads each |
| +fleet's owning account for the store door (`fleetAccounts`). That table is |
| +written by the console (`internal/console/fleets.go`), which opens the |
| +same `/data/registry.db` (`cmd/console/main.go:447`). So the hub is, in |
| +practice, the console's box: it is the only registry that has fleets in |
| +it, and `carlos fleets` says boxes "dial this console". |
| + |
| +On dev: |
| + |
| +| name | resolves to | |
| +|---|---| |
| +| `platform.dev.carlosframework.com` (console) | 99.80.78.4 | |
| +| `tunnel.dev.carlosframework.com` (`CARLOS_TUNNEL_URL` in `platform-infrastructure/dev/region-pi.md`) | 99.80.78.4 | |
| +| `shop.bab.dev.oncarlos.com`, any `*.bab.dev.oncarlos.com` | 99.80.78.4 | |
| +| `bab.dev.oncarlos.com` (apex) | 18.135.60.181 (dennis, uk) | |
| + |
| +99.80.78.4 is sophie-knitting (`carlos-dev-ie`, i-05498eada6f0afd23), the |
| +dev console box. So on dev the hub, the console and the box the apps |
| +domain points at are one box. `carlos fleets ls --account bab` (read-only, |
| +2026-10-29): `r10r` bucket `carlos-r10r-fleet-640012953448`, box `box-1` |
| +active, secrets key `c71cc5c26233`; `r10w` box-1 detached. box-1 reaches |
| +the bucket only through the hub's store door (it logs `fleetapi:` errors, |
| +#366), so it is a door-backed box with no bucket credentials. |
| + |
| +### 3.4 What the hub does with a fleet-placed row |
| + |
| +`Edge.Reload` binds any ready row whose `Region` parses as a fleet |
| +placement to `fleetProxy`, on placement alone, ahead of socket and addr |
| +(`edge.go:766`, `:821-825`). `fleetProxy` (`edge.go:3106`) picks the |
| +channel per request with `fleetChannelFor` (`edge.go:3086`): the row's |
| +`FleetBox` if that box is connected, else the first connected box of the |
| +fleet in sorted order, else 503 with `Retry-After: 2` and cause |
| +`fleet_dark` (`errFleetDark`, `edge.go:3071`). The request keeps its Host |
| +and goes over HTTP/2 inside the box's own TLS session to the hub. The |
| +row's process is never the hub's to manage (`viaTunnel`, `edge.go:965`). |
| + |
| +`FleetBox` comes from bindings. A fleet box publishes |
| +`fleets/<f>/bindings/<host>.json` through the door on every wake |
| +(`fleetBindingHook`, `internal/host/fleetbind.go:302`, takeover) and once at |
| +start (`publishResidentFleetBindings`, `:336`, never stealing). |
| +`ReconcileFleetBindings` (`fleetbind.go:210`) runs on EVERY platform box on |
| +the 5-minute loop (`agent.go:3894-3898`) and stamps `FleetBox` on an |
| +EXISTING row placed on the binding's own fleet. It never creates a row. |
| + |
| +So the serving half exists and works. What is missing is the row. |
| + |
| +### 3.5 The only ways a fleet row has ever reached the hub |
| + |
| +- `apps place` (`placeAppTarget`, `internal/console/fleets.go:817-829`) |
| + stamps `Region` on the console box's existing rows of the app |
| + (`reg.SetPlacement`). That was the customer-fleets design's answer |
| + ("placement subsumes" the route ceremony, |
| + `platform-infrastructure/platform-design/superpowers/specs/2026-08-05-customer-fleets-design.md`). |
| + It never adds a row, so an app born placed (`apps create --place`) gets |
| + nothing, and rootfs apps cannot be placed at all (`rootfsPlaceWords`, |
| + `internal/console/seedmove.go:174`). The Pi runbook has recorded the gap |
| + since August (`platform-infrastructure/dev/region-pi.md`: "Placement does |
| + NOT yet produce a route in the platform edge's own registry"). |
| +- A hand row. The recipe in use (`2026-10-24-rootfs-apps-2-verify.md` D7): |
| + `carlos add --account-id bab --app <app> --channel r10-proxy <host>` on |
| + sophie, then `apps place --target fleet/<f>`. The channel is a name that |
| + exists nowhere, so the hub's adopt pass finds no pointer and stages |
| + nothing. That trick is the tell: a fleet row with a real channel and |
| + `Kind = "instance"` is `release.Adoptable` (`internal/release/adopt.go:1302`), |
| + and the hub would stage and run the app's release locally. |
| + `railsdemo.bab.dev.oncarlos.com` serves through such a row today: |
| + `curl -sI .../up` gives 200 with one `x-carlos-version: r3b`. |
| + |
| +A placed row also has no retirement: the removal phase cannot see it |
| +(§3.2), so it outlives its record. |
| + |
| +### 3.6 Certificates and where TLS ends |
| + |
| +TLS for the public name ends at the hub. The box never presents a |
| +certificate for the app's host: tunnel traffic is HTTP/2 inside a TLS |
| +session the box itself dialed to the tunnel host. |
| + |
| +The hub's autocert asks `issuerHostPolicy` (`internal/edge/certsync.go:197`), |
| +which admits exact names of routes in the deployment, and on a box with a |
| +deployment store one elected issuer orders and publishes to |
| +`control/certs/` while the others mirror it (`armCertIssuance`, |
| +`certsync.go:107-150`). With no row anywhere for `shop.bab...`, sophie's |
| +policy refuses the name and the handshake ends in the alert seen today: |
| + |
| + TLSv1.3 (IN), TLS alert, internal error (592) |
| + |
| +box-1 has no deployment store, so it issues for itself (`certsync.go:122`) |
| +and fails, because the name resolves to sophie and validations never reach |
| +box-1. Harmless to serving; noise in its journal. |
| + |
| +### 3.7 DNS |
| + |
| +The apps domain's names are the deployment's own DNS, set in the |
| +deployment roots (dev: `*.dev.oncarlos.com` and the per-account wildcards |
| +point at sophie's address). On a steering deployment the steering |
| +converger writes per-host latency records from the boxes' edges files. No |
| +DNS changes for a fleet app: its platform name already resolves to the |
| +platform's edges. |
| + |
| +### 3.8 Custom domains |
| + |
| +A custom domain is a bucket claim; every box's alias pass |
| +(`aliasPassReporting`, `agent.go:1176`) writes `route_aliases` rows, and |
| +the edge serves an alias only through a local primary row |
| +(`edge.go:1083`). With no hub row, a fleet app's custom domain is not |
| +served anywhere today. |
| + |
| +### 3.9 Headers, cache, analytics |
| + |
| +- `X-Carlos-Version` is stamped by the edge that holds the row's version |
| + (`versionHeader`, `edge.go:2748`; `genproxy.go:312` for generations). The |
| + box sets it; a hub row with an empty `Version` adds nothing, so the |
| + box's header passes through once (railsdemo above). |
| +- Analytics count once: the hub counts, and the box skips requests that |
| + arrived over the tunnel (`fromTunnel`, `internal/edge/analytics.go:117`). |
| + Plan throttle, rate limits, the guard and request records do the same |
| + (`planthrottle.go:58`, `ratelimit.go:128`, `edge.go:1895`, |
| + `reqrecords.go:64`). Edge errors are filed by the box, the hub files only |
| + a failed hop (`emitEdgeError`, `edge.go:581`). |
| +- The hub's response cache stores tunnel responses like any other |
| + (`edge.go:2083`). The app's `Carlos-Purge` is applied and stripped by the |
| + box's edge (`purge_header.go:219`, `:331`), so the hub's copy cannot be |
| + purged. A live gap with hand rows today; §4.11. |
| + |
| +## 4. Design |
| + |
| +### 4.1 In one paragraph |
| + |
| +The hub's own instance pass, which already reads every record, gives each |
| +fleet-placed record whose fleet is in the hub's local fleets table, owned |
| +by the record's account, a forward row: a row of a new kind, `forward`, |
| +that carries the host, the app, the account and the placement and nothing |
| +that makes any pass on the hub run it. The edge already serves such a row |
| +through `fleetProxy`; it now also refuses one whose account is not the |
| +fleet owner's. The same pass retires the row when the record goes, moves |
| +off the fleet, or stops qualifying. Certificates, custom domains, |
| +backhaul and the version header follow from the row through code that |
| +exists. Nothing new is read from the bucket. |
| + |
| +### 4.2 The forward row |
| + |
| +A row with exactly these columns: |
| + |
| +| column | value | |
| +|---|---| |
| +| `Host` | the record's host | |
| +| `Kind` | `forward` (new constant `registry.KindForward`, `Route.IsForward()`) | |
| +| `App`, `Account` | the record's | |
| +| `Region` | the record's `fleet/<f>` | |
| +| `Channel` | the record's, for display only | |
| +| `Status` | `ready` | |
| +| `Provisioned` | true | |
| +| `FleetBox` | left to the bindings pass (§4.5) | |
| + |
| +Everything else is empty: no `Socket`, `Addr(s)`, `DBPath`, `Version`, |
| +`Runtime`, `Unit`, `Backing`, `Caps`, `Tunnel`, `Hibernate`, `Seed`, |
| +`Health`, `Replicas`. `Upsert` preserves a non-empty `FleetBox`, so the |
| +forward pass and the bindings pass do not undo each other. |
| + |
| +Why a new kind rather than the old placed-row shape (`Kind = instance`) |
| +or the domains pass's minted shape (`Platform = true`, |
| +`internal/domains/reconcile.go:875-893`): |
| + |
| +- `instance` is what the hub's root adopt pass, capability pass, fast |
| + sweep and config sync select on (`release.Adoptable`, `CapabilityRoute`, |
| + `adopt.go:1302`). The hand-row recipe dodges that with a channel that |
| + does not exist. A design cannot. |
| +- `Platform` belongs to the domains pass, which removes `Platform` rows on |
| + its own inferences. Sharing the flag shares the removal authority. |
| +- Every selector that names a kind positively (`Kind == "instance"`, |
| + `IsSidecar()`) skips an unknown kind. A pass that does not know about |
| + `forward` fails toward ignoring the row. The edge's fleet arm keys on |
| + placement, not kind (`edge.go:821`), so serving needs no new arm. |
| + |
| +The cost is the sidecar lesson (AGENTS.md): every reader of `reg.List()` |
| +is a consumer of the new kind and has to be audited (§4.14). |
| + |
| +### 4.3 Who writes it, from what, and when |
| + |
| +The writer is `provision.Reconcile` on the hub, in a phase of the same |
| +call, over the same scan: |
| + |
| +1. The scan, at the `inScope` skip (`reconcile.go:1217`), keeps the |
| + records it skips only because they are fleet-placed and this box is |
| + not on that fleet. Same judge, same validation, same `protect`, |
| + `unread` and `readFailed` bookkeeping as an in-scope record. Their |
| + bodies are already read; nothing new is fetched. |
| +2. `ReconcileConfig` gains `FleetOwners func() (map[string]string, error)`, |
| + nil on every box that is not a hub. The agent sets it when |
| + `CARLOS_TUNNEL_HOST` is set and `CARLOS_FLEET` is not, reading |
| + `reg.ListFleets()` from the local registry once per pass. A read error |
| + aborts the forward phase for the pass, mints nothing and retires |
| + nothing. |
| +3. The desired set: a kept record gets a forward row when |
| + - `FleetOwners` is set and names the record's fleet; |
| + - that fleet's account equals the record's `Account`; |
| + - the record is not `role: replica`, and its host is not claimed by an |
| + in-scope record of this same pass (a host in both sets is a |
| + collision, logged and given neither). Instance moves refuse fleet |
| + records (`apiinstancemove.go:91`), so no move is in flight; |
| + - no row other than a forward row already holds the host (§4.7). |
| + Sidecar records never reach this pass (`ReconcileSidecars` owns them). |
| +4. Mint and converge: a missing forward row is written; an existing one |
| + whose `App`, `Account`, `Region` or `Channel` differs is rewritten in |
| + place. `FleetBox` is cleared when `Region` changes (the old binding |
| + names a box of the old fleet). |
| +5. Retire, only on a pass where nothing failed to read and the scan was |
| + whole (the instance pass's rule, `reconcile.go:1968-2044`, including the |
| + re-check against the bucket's own walk over a snapshot): every forward |
| + row not in the desired set is deleted. A host in `protect` is kept. |
| +6. Order: the forward phase runs BEFORE the instance phase's mint. A |
| + record that moved from a fleet to this box's region sees its forward |
| + row gone before the instance phase looks for a row to mint or adopt. |
| + |
| +On a box that is not a hub, `FleetOwners` is nil, the desired set is |
| +empty, and step 5 retires any forward row it holds. That is what makes a |
| +box that stops being the hub clean up after itself, and why only the hub |
| +ever holds one. |
| + |
| +When it appears: the console's create of a fleet-placed record bumps the |
| +serial; the hub's change-index pass runs in seconds; `Edge.Reload` picks |
| +the row up on its 2-second registry watch. Until the fleet box has minted |
| +its own row, a request reaches the box and gets the box's unknown-host |
| +answer. With claims on (`ClaimEnabled`, shelved), the forward phase does |
| +nothing and logs once; claims are off everywhere. |
| + |
| +### 4.4 Tenancy: one rule, checked twice |
| + |
| +The rule: a fleet's tunnel carries only hostnames whose account is the |
| +fleet's owner. |
| + |
| +- The pass checks it before writing (§4.3, step 3). The source of the |
| + owner is the hub's own `fleets` table, written only by the console and |
| + already the authority for the fleet's tunnel credentials and its store |
| + door scope. Not the bucket owner record |
| + (`accounts/<acct>/fleets/<f>.json`, `internal/console/fleetowner.go`): |
| + it costs a read per fleet per pass, and the hub already holds the better |
| + answer locally. |
| +- The edge checks it where traffic is forwarded. `Edge.Reload` reads the |
| + fleets table before building the map (today it reads it after, |
| + `edge.go:1112`), and a fleet-placed row whose `release.RouteAccount` is |
| + set and differs from the fleet's account gets no map entry: no proxy, |
| + and `Allowed` says no, so no certificate order either. Logged, throttled |
| + per host. This covers forward rows, hand rows, legacy placed rows and |
| + aliases (an alias inherits its primary's entry). A fleet-placed row with |
| + no account (a pre-account hand row) is served as today and logged. |
| + |
| +What the record itself is trusted for is unchanged: records are written by |
| +the console, and a door-backed fleet box cannot write one (`aclWrite`, |
| +`internal/edge/storedoor.go:644`). A grandfathered fleet box that still |
| +holds bucket credentials could; that is the customer-fleets v1 trust |
| +statement and 1a does not widen it, because the edge check means such a |
| +record can only point at its own account's fleet. |
| + |
| +Bindings stay as they are: a box can only steer a host to a box of its own |
| +fleet (`fleetbind.go:255`), which the edge check now also confines to the |
| +owner's hosts. |
| + |
| +### 4.5 Naming the box, and multi-box fleets |
| + |
| +The record does not name a box and 1a does not add one. The forward row |
| +starts with `FleetBox` empty, so `fleetChannelFor` takes the first |
| +connected box of the fleet. The bindings pass stamps `FleetBox` when a box |
| +publishes a binding. |
| + |
| +1a makes `ReconcileFleetBindings` hub-only: it only ever stamps rows that |
| +exist, and only the hub holds fleet rows that can be served (a box with no |
| +tunnel hub has no fleet arm). Today it lists `fleets/` on every platform |
| +box every five minutes. |
| + |
| +Single-box fleet (the witness): fully correct. There is one channel, the |
| +fallback finds it, and the binding is cosmetic. |
| + |
| +Multi-box fleet, what happens today and with 1a alike: every box of the |
| +fleet mints the record's row (its region is `fleet/<f>`), the instance |
| +runs on whichever box holds its lease, and the hub routes to the bound box |
| +if connected, otherwise to the first connected box, which wakes the |
| +instance or loses the lease race and answers 503 with `Retry-After`. The |
| +binding lags a move by up to one bindings pass (about 5.5 minutes), and |
| +in that window requests can land on a box that does not hold the lease. |
| +1a does not fix this. 1b owns box choice, and the likely fix (the hub's |
| +store door stamps `FleetBox` the moment a binding PUT passes through it, |
| +since the door runs on the hub) is noted there, not built here. |
| + |
| +### 4.6 Retirement and moves |
| + |
| +| event | forward row | |
| +|---|---| |
| +| record deleted, or app trashed | retired on the next whole pass | |
| +| app placed back on the platform (`apps place --target ""`) | retired; the instance pass on the box in scope (maybe the hub) mints the real row, after, in the same pass | |
| +| app placed on another fleet of the same account | rewritten in place, `FleetBox` cleared | |
| +| fleet's owner changes, or the fleet row goes (no fleet removal exists yet) | edge stops serving on its next reload; the pass retires the row | |
| +| every box of the fleet detached | kept; requests get 503 `fleet unreachable` with `Retry-After` | |
| +| hub stops being the hub (`CARLOS_TUNNEL_HOST` removed) | retired by that box's own pass; the new hub mints | |
| +| a read failed this pass | nothing retired, as for instance rows | |
| + |
| +The instance pass gains the sidecar-style guard in the other direction: |
| +`retirable` excludes `IsForward()` rows, and the forward phase retires |
| +only `IsForward()` rows. Both directions get a test (§8). |
| + |
| +### 4.7 Rows already at the host, and `apps place` |
| + |
| +- A hand row (not `Provisioned`) at the host wins. No forward row is |
| + written, the host is logged once per process, and nothing touches the |
| + hand row. railsdemo keeps serving through its hand row; removing it is |
| + an operator step for later, with Paul's approval. |
| +- A legacy placed row (`Provisioned`, `Kind instance`, `Region` the same |
| + fleet, same account and app as the record) is converted into a forward |
| + row in place. The instance-pass family minted it and the console only |
| + re-stamped its region, so this stays inside one authority. Its local |
| + process, if any, was already not the edge's (`viaTunnel`), and dropping |
| + its `Socket` and `DBPath` takes it out of the activator's and |
| + Litestream's sets. |
| +- Any other row at the host (a different account, app, kind or fleet): |
| + untouched, and the record gets no forward row. Logged. |
| +- `placeAppTarget` stops calling `reg.SetPlacement` on the console box's |
| + rows (`fleets.go:817-829`). Records are the authority in both |
| + directions now; the two passes converge the hub's rows from them. |
| + Keeping the stamp would turn a hub instance row into a fleet row that |
| + nothing can retire. |
| + |
| +### 4.8 Certificates and TLS |
| + |
| +TLS ends at the hub, as for hand rows today. The forward row is an exact |
| +route in the deployment, so the issuer's policy admits it, and the hub's |
| +edges file publishes it (§4.9), so a non-hub issuer admits it too. The |
| +first handshake orders the certificate (or the account's wildcard covers |
| +it, where a deployment issues those); on a multi-box deployment the hub |
| +serves the issuer's copy once its mirror picks it up (seconds). The box |
| +needs no certificate for the name. Custom domains get theirs through cert |
| +warm and the alias rules as any alias does (§4.10). |
| + |
| +### 4.9 Other platform boxes and DNS |
| + |
| +The hub's edges file lists every ready row, the forward row included, as |
| +`role: home` with its account and app (`internal/host/edgesfile.go:592`). |
| +A request for the host that lands on another platform box misses its own |
| +map and backhauls to the hub (`homemap.go`), which forwards over the |
| +tunnel. One hop, as for any home-boxed route. Steering, where on, points |
| +the host at the hub's region. No DNS record is written or changed. |
| + |
| +### 4.10 Custom domains |
| + |
| +They follow from the row with no new code: the hub's alias pass sees a |
| +local primary for the claim and writes the alias, the edge folds it onto |
| +the forward row's proxy, and the edges file publishes it once its DNS is |
| +stamped as pointing. The edge's tenancy check applies to the alias through |
| +its primary. |
| + |
| +### 4.11 Headers, cache, metering |
| + |
| +- `X-Carlos-Version`: the forward row has no `Version`, so the hub stamps |
| + nothing and the box's header (from the generation that served, on a |
| + rootfs or generations box) reaches the client once. The witness asserts |
| + exactly one value. |
| +- Response cache: forward rows bypass the hub's response cache, for the |
| + reason the backhaul path already gives (`edge.go`, backhaul notes: a copy |
| + kept where the app's `Carlos-Purge` cannot reach it can never be |
| + invalidated). The box's edge is the home edge. Open question 2. |
| +- Analytics, plan throttle, rate limit, guard, request records: counted |
| + once at the hub, skipped on the box (§3.9). Unchanged. |
| +- Usage: the hub meters what it forwards (`edge.go:1902`), which is the |
| + platform's egress. Whether the box's own meter also lands somewhere a |
| + bill reads is for the plan to establish; 1a changes neither. |
| + |
| +### 4.12 Hibernation and wake |
| + |
| +The hub never manages a forward row (`viaTunnel`, and the row has no |
| +`Hibernate` or `Runtime`). A sleeping native instance on the box wakes on |
| +the request the tunnel delivers, through the box's own activator. A rootfs |
| +instance is resident and does not sleep. A wake that takes longer than the |
| +client waits is the box's existing behaviour, not the hub's. |
| + |
| +### 4.13 Failure modes |
| + |
| +| what fails | what a visitor sees | why | |
| +|---|---|---| |
| +| fleet box down, or its tunnel down | 503, `Retry-After: 2`, after at most ~10 s of reap | `errFleetDark`; fleet channels ping every 5 s with a 5 s deadline (`tunnel.go:50-59`) | |
| +| tunnel drops mid-request | 502 | `fleetProxy`'s other transport errors | |
| +| box up, its own row not minted yet | the box's unknown-host answer | the box's pass has not run | |
| +| instance failed on the box (held build) | whatever the box answers (its last good build, or its error) | the hub forwards | |
| +| hub down | the host is down | the hub is a single point for its fleets, as now | |
| +| fleet owner mismatch | TLS refusal, as for an unknown host | §4.4 | |
| +| record deleted | TLS refusal after the next whole pass | §4.6 | |
| + |
| +### 4.14 Every other reader must ignore a forward row |
| + |
| +The plan's first task is the audit: every reader of `reg.List()` and |
| +every selector on `Provisioned`, listed with what it does with a |
| +`forward` row. Known so far: |
| + |
| +- Must ignore (positive kind or column filters already do; each gets a |
| + guard test): root adopt (`release.Adoptable`, `SidecarAdoptable`), |
| + `CapabilityRoute`, named-unit config delivery and restart (no `Unit`), |
| + the rootfs and activator paths (no `Runtime`, no `Hibernate`, |
| + `ActivatorOwned` false), Litestream (`ops.FleetDBs`, no `DBPath`), seed |
| + passes (`seedreconcile.go:174`), layout, scheduled work, plans and caps |
| + counting, telemetry, the instance pass's own removal (§4.6). |
| +- Must include: the edge's fleet arm, the edges file, the alias pass, the |
| + issuer policy, analytics' app switch (by account and app). |
| +- Console, which shares the registry: the fleet page's placed-apps list |
| + (`fleets.go:1301-1307`) and the placement readers (`accountfleet.go:144`, |
| + `regionfacts.go:118`) already read fleet-placed rows as "placed", which |
| + is now correct for apps born placed. Instance health |
| + (`apiinstances.go:405-420`) treats a local row as local and must skip a |
| + forward row so a fleet instance keeps its fleet answer. |
| +- The domains pass (flagship, `PLATFORM_APPS_DOMAIN` set) mints platform |
| + addresses from a source row; with a forward row as source, `mintedRoute` |
| + copies its kind and region, giving a second forward-kind row owned by |
| + the domains pass. The plan checks the source selection and the domains |
| + pass's removal against that. |
| + |
| +## 5. Provider boundary |
| + |
| +Nothing here touches a cloud API. The forward pass reads the registry and |
| +records it already read, the edge reads the registry, and DNS is the |
| +deployment's. Works the same on any provider and on a deployment with no |
| +cloud at all. |
| + |
| +## 6. Request budget |
| + |
| +Steady state, nothing changing, per box per day: |
| + |
| +| box | before | after | |
| +|---|---|---| |
| +| hub | instance pass reads (unchanged); bindings pass `1 + F + B` per pass | same | |
| +| every other platform box | instance pass reads; bindings pass `1 + F + B` per pass | instance pass reads; no bindings pass | |
| +| fleet boxes | unchanged | unchanged | |
| + |
| +`F` is the number of directories under `fleets/`, `B` the number of |
| +binding objects; the loop runs about 262 times a day (5 minutes plus up to |
| +a minute of jitter). So 1a saves `(N - 1) x 262 x (1 + F + B)` requests a |
| +day on a deployment with `N` platform boxes, and adds none: the forward |
| +phase uses records the scan already read and a local SQLite table; the |
| +edge check is local. |
| + |
| +On change: one edges-file PUT on the hub when a forward row appears or |
| +goes (the file is written on change only), and the readers' existing |
| +30-second mirror reads it; one certificate order per new host, as for any |
| +route. A test with a counting store asserts the instance pass makes the |
| +same store calls with and without fleet-placed records present. |
| + |
| +## 7. Census |
| + |
| +- Root-read census (`TestPlan14RootReadCensus`): it fails, because |
| + `internal/provision`, `internal/registry`, `internal/edge` and |
| + `internal/host` are in the root binary. Card through `make census-card` |
| + and `make census-propose`. Claims to make: no root read is added; root's |
| + passes read the registry as before and select by `Kind == "instance"`, |
| + `IsSidecar()`, `Unit`, `Runtime`, `Backing`, `Caps`, none of which a |
| + forward row carries; the edge's fleets read moves earlier in `Reload`, |
| + same table, same connection rule. Reviewer from the other family |
| + (Astra), verdict on #280. |
| +- Record-write census (9B8): no new bucket writer. If the forward phase |
| + lives in a declaration the inventory pins (`Reconcile` names record |
| + keys), its digest changes and is re-reviewed with the census card. |
| +- The console change (`placeAppTarget`) is outside the root census scope. |
| + |
| +## 8. Tests |
| + |
| +Unit (`internal/provision`, `internal/edge`, `internal/registry`): |
| + |
| +1. Desired set: owner match mints; owner mismatch, unknown fleet, |
| + non-hub, replica, collision with an in-scope record, existing hand row |
| + or other row: none, and logged once. |
| +2. Converge and retire: each row of §4.6's table; no retirement on a |
| + failed read, a partial scan, or a protected host; the snapshot |
| + re-check. |
| +3. Guards both ways: the instance pass never retires a forward row; the |
| + forward phase never retires an instance or sidecar row. |
| +4. Every selector in §4.14's "must ignore" list answers false for a |
| + forward row (one table test over the selectors, so a new selector that |
| + forgets the kind shows up there). |
| +5. Edge: a fleet-placed row with a mismatched account gets no map entry |
| + and `Allowed` false; a match is served through `fleetProxy`; a |
| + forwarded response carries the box's `X-Carlos-Version` exactly once; |
| + forward rows skip the response cache. |
| +6. Counting store: the request budget of §6. |
| + |
| +Production-wired witness (the gate, ahead of review rounds; memory |
| +`production-wired-witnesses`). In the root package, which can import both |
| +the console and the agent, building on `internal/edge/tunnel_e2e_test.go`'s |
| +real tunnel loop. No hand-built forward rows, no fabricated records: |
| + |
| +- A real console `Server` over a temp registry and a dir-backed |
| + deployment store creates account A's fleet `f`, adds `box-1` (keeping |
| + the printed token), creates app `shop` with `--place fleet/f` and its |
| + instance, and promotes `v1`. |
| +- The hub: a real `Edge` with the tunnel hub armed through |
| + `enableTunnelsFromEnv` (`CARLOS_TUNNEL_HOST` set), the same registry, |
| + and the instance pass run through the function the change-index leg |
| + calls, with the config the agent builds from its env. |
| +- The box: a second real `Edge` on its own registry, its instance pass |
| + run with `CARLOS_FLEET=f`, serving over `tunnelclient.Loop` with the |
| + token from step one, and a real process bound at the derived socket |
| + answering `/up` with the build. |
| +- Assert through the hub's TLS listener (test certificate): `GET /up` is |
| + 200 with one `X-Carlos-Version: v1`. Then: detach the box, 503 with |
| + `Retry-After`; re-add, 200; delete the record, the row goes and the hub |
| + refuses the name; a second account B with its own fleet places an app on |
| + `fleet/f` by writing the record directly (bypassing the console door): |
| + no row, and a hand row for it is refused by the edge. |
| + |
| +Live acceptance on dev, after the roll (read-only checks): |
| + |
| +- `curl -sI https://shop.bab.dev.oncarlos.com/up` from DOCS-T1: 200, |
| + `X-Carlos-Version: v1`. |
| +- The same through leo (`--resolve shop.bab.dev.oncarlos.com:443:18.200.150.210`): |
| + 200 by backhaul. |
| +- `curl -sI https://railsdemo.bab.dev.oncarlos.com/up`: still 200 through |
| + its hand row. |
| +- The r10r fleet page lists `shop`. |
| + |
| +## 9. Rollout |
| + |
| +No switch. A forward row exists only on a hub, and only for a record whose |
| +fleet the hub's own table gives to the record's account; a box with no |
| +hub, which is every box but the console's on today's deployments, holds |
| +none. Stopping rule 5: what a user gets is their fleet app at its URL; who |
| +asks is Paul (2026-10-29); it switches on when the release carrying it |
| +rolls to dev, and on the flagship with its next roll. |
| + |
| +No release floor. Only the hub writes forward rows, and other boxes see |
| +them only through the hub's edges file, in a shape they already read. A |
| +rollback of the hub leaves forward rows that the older binary still serves |
| +(its fleet arm keys on placement) and never retires, and its root passes |
| +ignore (they select `instance`); the next upgrade reconciles them. |
| + |
| +Order: dev first (sophie is the dev hub), the witness check, then the |
| +flagship. On any other deployment with fleets (Tito, for Eleven), the |
| +upgrade gives fleet-placed records public rows where no hand row holds |
| +the host; hand rows keep winning. Say so in the release notes. |
| + |
| +No member-facing strings are added. If the plan adds a REASON for a |
| +withheld forward row to `instances list`, it goes to copy review. |
| + |
| +## 10. Open questions for Paul |
| + |
| +1. A new row kind (`forward`) rather than reusing `instance` or the |
| + domains pass's `Platform` flag. Recommend: the new kind (§4.2). The |
| + other two hand the row to passes that run or remove things. |
| +2. Forwarded responses skip the hub's response cache, because the app's |
| + `Carlos-Purge` stops at the box and the hub's copy could never be |
| + invalidated. Recommend: skip in 1a. The cost is that fleet apps get no |
| + response cache until the purge is carried through the tunnel. |
| +3. Hand rows: leave them winning, or adopt a hand row that matches a |
| + record? Recommend: leave them (adoption is an authority transfer), and |
| + convert only the `Provisioned` legacy placed rows. railsdemo's hand row |
| + goes later, with your approval. |
| +4. The edge refuses any fleet-placed row whose account is not the fleet's |
| + owner, hand rows included. Recommend: yes, mismatches only; a row with |
| + no account is served as today and logged. |
| +5. `apps place` stops stamping the console box's rows. Recommend: yes; |
| + the passes converge from records in both directions. |
| + |
| +## 11. Notes against the #457 draft |
| + |
| +- "The console never writes route rows": it never ADDS one, but |
| + `apps place` re-stamps `Region` on the console box's existing rows |
| + (`fleets.go:817-829`). That was the original route answer for fleets, |
| + and it is why the hub already has a fleet arm. It never helped an app |
| + born placed, or any rootfs app. |
| +- "A forwarding row only when the fleet's owner record names the same |
| + account": the bucket owner record is not needed. The hub holds the |
| + console's `fleets` table locally, the same table its tunnel auth and |
| + store door use. §4.4. |
| +- "The hub edge (the platform box the router reaches)": concretely the |
| + console's box. Boxes dial the console host and the fleets table exists |
| + only in its registry. On dev that is sophie, which is also where the |
| + apps domain resolves. |
| +- "Pointing at the fleet and the box running the instance": the record |
| + names no box. The box comes from the existing bindings |
| + (`fleets/<f>/bindings/<host>.json`, `ReconcileFleetBindings`), with the |
| + first connected box as fallback, which is enough for one box (§4.5). |
| +- Line refs: `fleetProxy` is at `edge.go:3106` on main (3059 in the draft). |
| + `inScope` at `reconcile.go:487-499` is right. |
| +- "Custom domains and certificates follow from the row": yes, plus two |
| + things the draft did not name: the edge-side tenancy check (§4.4) and |
| + the hub cache that the app's purge cannot reach (§4.11). |