| index dff34f3b3..fd03dae9b 100644 |
| --- a/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md |
| +++ b/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md |
| @@ -1,6 +1,6 @@ |
| # Fleet public routes: an app on a fleet serves at its URL with no hand row |
| |
| -Status: DRAFT rev 2, 2026-10-30. Discussion: amadan carlos/platform #457 |
| +Status: DRAFT rev 3, 2026-10-30. 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. |
| @@ -12,8 +12,20 @@ Revisions: |
| rulings (platform-39) on P1-1, P1-2, P1-3, P1-4, P1-5, P1-6, P1-7, P1-8 and |
| P2-9 to P2-13. Changes are marked **(R1-n)**. Also found while checking |
| R1-9: the retention pass would have started pruning fleet apps' releases |
| - from the hub (§4.15, marked **(rev 2)**). Round 1 of 3 is spent; this |
| - is the text for round 2. |
| + from the hub (§4.15, marked **(rev 2)**). |
| +- Rev 3: Astra round 2 (`CODEX-FINDINGS-fleet-public-routes-R2.md`, NOT |
| + READY, 3 P1 and 4 P2; R1-2, 4, 6, 7, 8, 10, 12 resolved), every finding |
| + taken with the controller's rulings (platform-39). Changes are marked |
| + **(R2-n)**: the hub does no gate work at all for a forward host, form |
| + parsing included (R2-1); the floor judges a first publication and the |
| + barrier's two orders are closed under one mutex (R2-2); bindings are |
| + applied by one conditional write, `SetFleetBoxIf` (R2-3); canary-status |
| + reads skip forward rows and the trash prefetch for forward apps reads |
| + only the marker (R2-4); the domains trash loop skips forward rows |
| + (R2-5); one exhaustive persisted shape, enforced by the registry's |
| + writers and checked by `InertForward` (R2-6); the census list per unit, |
| + release publication included (R2-7). Rounds 1 and 2 are spent; this is |
| + the text for round 3, the last. |
| |
| ## 1. Intent |
| |
| @@ -195,7 +207,13 @@ throttle only on `Kind == "instance"` (`ratelimit.go:124`, |
| |
| The password gate runs at the edge that holds the row's `Gate` |
| (`edge.go:1966-1972`). A login POST (`gate.LoginPath`, `/.carlos/gate`) |
| -on a row with no gate is answered 404 and never proxied. |
| +on a row with no gate is answered 404 and never proxied. Before that, as |
| +soon as the host is known to be served here, `ServeHTTP` reads the login |
| +POST's body (`r.ParseForm()`, `edge.go:1798-1803`) and re-resolves the |
| +upstream by the form's `next` path (`edge.go:1819-1827`); its own comment |
| +says a body drained there cannot be proxied on (`edge.go:1785-1790`). |
| +The gate's handler reads the password with `ParseForm` |
| +(`internal/gate/gate.go:129-136`), which parses urlencoded bodies only. |
| |
| `X-Carlos-Version` is stamped by the edge holding the row's version |
| (`versionHeader`, `edge.go:2748`; `genproxy.go:312`). The hub's response |
| @@ -221,47 +239,67 @@ path to it, uncached. Bindings are honoured only from their own key and a |
| registered box. A release floor stops a channel moving below the first |
| release that writes forward rows while fleets exist. |
| |
| -### 4.2 The forward row **(R1-7, R1-10, R1-2, R1-3)** |
| +### 4.2 The forward row: one exhaustive persisted shape **(R1-7, R1-10, R1-2, R1-3, R2-6)** |
| |
| -Columns: |
| +Every persisted column of `registry.Route` (`internal/registry/registry.go:43-450`, |
| +and the embedded `ClaimOwnership`, `claimrows.go:16-19`) is in exactly |
| +one of four classes. A column added to `Route` later fails a test until |
| +it is classed (§8 test 1). |
| |
| -| column | value | |
| -|---|---| |
| -| `Host` | the record's host | |
| -| `Kind` | `forward` (`registry.KindForward`, `Route.IsForward()`) | |
| -| `Slug` | the record's, converged (R1-10: instance catch-alls derive from it, `internal/domains/aliases.go:170`) | |
| -| `App`, `Account` | the record's | |
| -| `Region` | the record's `fleet/<f>` | |
| -| `Channel` | the record's, display only | |
| -| `RateLimit` | `rec.RateLimitColumn()`, as `RouteFor` renders it (R1-2) | |
| -| `Status` | `ready` | |
| -| `Provisioned` | true | |
| -| `FleetBox` | written only by the bindings pass; kept while `Region` is unchanged, cleared when it changes | |
| - |
| -Every other column is empty, deliberately including `Gate` (the fleet |
| -edge owns the gate, §4.8), `Version` (the box stamps it), `Steering`, |
| -`Socket`, `Addr`, `Addrs`, `DBPath`, `Runtime`, `Unit`, `Backing`, `Caps`, |
| -`Tunnel`, `Hibernate`, `Seed`, `Health`, `Replicas`, `EgressAllow`. |
| - |
| -`Route.InertForward()` is the shape predicate: `IsForward()` and every |
| -column in the last sentence empty. Every reader below that admits a |
| -forward row admits only an inert one. |
| - |
| -Writes go through two new registry calls, never `Upsert` (R1-7: `Upsert` |
| -keeps a non-empty existing `Tunnel`, `Caps`, `Unit`, `Seed` and others, |
| -`internal/registry/registry.go:1512`): |
| +| class | columns | who writes them on a forward row | |
| +|---|---|---| |
| +| declared | `Host`; `Kind` = `forward` (`registry.KindForward`, `Route.IsForward()`); `Slug` (R1-10: catch-alls derive from it, `internal/domains/aliases.go:170`); `App`; `Account`; `Region` = `fleet/<f>`; `Channel` (display only); `RateLimit` = `rec.RateLimitColumn()` (R1-2); `Status` = `ready`; `Provisioned` = true; `CreatedAt` (kept from the existing row, else now) | `PutForward` only | |
| +| binding | `FleetBox` | `SetFleetBoxIf` only (§4.5); `PutForward` keeps it while `Region` is unchanged and clears it when `Region` changes | |
| +| observational | `DNSStatus`, `DNSCheckedAt`, `CertExpiresAt` | the domains health pass (`SetDNSStatus`, `SetCertExpiresAt`, `internal/domains/reconcile.go:488`, `:511`); `PutForward` preserves them. No dispatch, publication or eligibility decision reads them for a forward row | |
| +| forbidden, must be zero | `Socket`, `Addr`, `Addrs`, `Health`, `HoldOp`, `Incarnation`, `ServingSeq`, `SeedSource`, `ImportGate`, `AssetsOff`, `AssetGen`, `LastError`, `DBPath`, `Version`, `PrevVersion`, `GoodVersion`, `GoodDigest`, `GoodDemand`, `ServingVersion`, `Pool`, `Environment`, `Tunnel`, `Caps`, `Hibernate`, `HA`, `Runtime`, `Gate`, `Canary`, `Replication`, `NextDue`, `StatusNamed`, `Backing`, `Unit`, `Platform`, `Seed`, `Args`, `IdleSeconds`, `MaxRunSeconds`, `Steering`, `UpdateSettings`, `EgressAllow`, `Size`, `PolicyExpiresAt`, `BuildState`, `Replicas`, `Replica`, `ClaimIncarnation`, `ClaimStamp`, `ClaimOwner`, `ClaimRowID` | nobody | |
| |
| -- `PutForward(rt)`: one transaction. If a row exists at the host and is |
| - not a forward row, it returns `ErrHostHeld` and writes nothing. Otherwise |
| - it writes every column, the forward set above and zero for the rest, so |
| - an operator column that reached a forward row is cleared on the next |
| - pass. `FleetBox` is carried from the existing row only when `Region` is |
| - unchanged. |
| -- `DeleteForward(host)`: deletes the row only if it is still a forward row, |
| - in the same statement. |
| +`Gate` is forbidden on purpose: the fleet edge owns the gate (§4.8). |
| +`Version` too: the box stamps the header. `WakeIncarnation` is not |
| +persisted (`json:"-"`) and is not a column. |
| |
| -`carlos route` and `carlos add` refuse a forward row's host, naming the |
| -record, as `carlos route` already refuses a provisioned row's channel. |
| +`Route.InertForward()` is `IsForward()` and every forbidden column zero, |
| +each compared one by one. Every reader that admits a forward row admits |
| +only an inert one; a forward row that is not inert is served by nobody, |
| +published by nobody and skipped by nothing that would skip an inert one |
| +(§4.4, §4.15). |
| + |
| +The registry enforces the shape where rows are written, so a stray value |
| +cannot get there in the first place (R1-7, R2-6): |
| + |
| +- `PutForward(rt)`: one transaction. If a row exists at the host and is |
| + not a forward row, it returns `ErrHostHeld` and writes nothing. |
| + Otherwise it writes the declared columns from `rt`, keeps the |
| + observational ones and (by the rule above) `FleetBox`, and writes zero |
| + to every forbidden column. Never `Upsert`, which keeps non-empty |
| + existing values (`registry.go:1512`). |
| +- `DeleteForward(host)`: deletes the row only if it is still a forward |
| + row, in the same statement. |
| +- `SetFleetBoxIf(host, fleet, label)` (§4.5). |
| +- Every other writer of the `routes` table in `internal/registry` carries |
| + `kind <> 'forward'` in its statement (an `INSERT` or `Upsert` over a |
| + forward host returns `ErrForwardRow`, an `UPDATE` or `DELETE` matches |
| + nothing), except |
| + `SetDNSStatus` and `SetCertExpiresAt`. Today those writers are `Upsert`, |
| + `UpsertUnlessRootfs`, `Delete`, `DeleteIfUnchanged` and the setters |
| + `SetSeedSource`, `SetHold`, `SetHoldIf`, `SetHoldIfSeq`, `SetClaimHold`, |
| + `SetAccount`, `SetChannel`, `SetStatus`, `SetCaps`, `SetDBPath`, |
| + `SetInstancePaths`, `SetBacking`, `SetUnit`, `SetReplication`, |
| + `SetUpstreams`, `SetSteering`, `SetAssets`, `SetUpdateSettings`, |
| + `SetPolicy`, `SetBuildState`, `SetReplicas`, `SetReplica`, `SetHA`, |
| + `SetGate`, `SetRateLimit`, `SetChannels`, `SetEnvironment`, `SetTunnel`, |
| + `SetPlacement`, `SetEnvironments`, `SetChannelsAndEnvironments`, |
| + `SetVersions`, `SetGoodBuild`, `SetServingVersion`, `SetHibernate`, |
| + `SetNextDue`, `SetSeed`, `SetArgs`, `SetWorkerLimits`, |
| + `SetProvisioned`, `SetStatusNamed`. `SetFleetBox` is removed: its only |
| + caller moves to `SetFleetBoxIf`. The registry's remote mode |
| + (`internal/registry/remote_dispatch.go`) carries the three new calls in |
| + place of `SetFleetBox`. The plan re-derives this list from the |
| + `routes` statements in the package, and a test runs each exported writer |
| + against a forward row (§8 test 1). |
| + |
| +So `carlos route`, `carlos add` and `carlos remove` on a forward host fail |
| +in the registry; the CLI names the record and says to change that |
| +instead (copy review). |
| |
| Why a new kind (Q1, fixed): `instance` is what root adopt, capability, |
| config sync and the fast sweep select (`adopt.go:1302`); `Platform` |
| @@ -277,9 +315,13 @@ The cost is the audit of every reader (§4.15). |
| the records it skips only because they are fleet-placed and this box is |
| not on that fleet. Same judge, validation, `protect`, `unread` and |
| `readFailed` bookkeeping as an in-scope record. Their bodies are already |
| - read. Their apps join the trash prefetch (`reconcile.go:1281-1298`), so |
| - the marker read happens once per app per pass, in the existing parallel |
| - prefetch (budgeted in §6). |
| + read. Their apps do NOT join the existing prefetch, which reads each |
| + live app's manifest right after its marker (`reconcile.go:1281-1298`, |
| + the manifest at `:1293` onward). A second, trash-only prefetch over the |
| + kept records' apps reads the marker alone (`release.ReadAppTombstone`), |
| + with the same `forEach` parallelism, into the same `tombs` map |
| + `trashFor` answers from; a forward app's manifest, seed and policy are |
| + never read **(R2-4)**. Budgeted in §6. |
| 2. **Owners.** `ReconcileConfig.FleetOwners func() (map[string]string, error)` |
| is set by the agent when `CARLOS_TUNNEL_HOST` is set and `CARLOS_FLEET` |
| is not, reading `reg.ListFleets()` once per pass (local SQLite). A read |
| @@ -287,9 +329,12 @@ The cost is the audit of every reader (§4.15). |
| 3. **Decide, per kept record.** Using the instance pass's own trash lookup |
| (`trashFor`): |
| - **mint**: `FleetOwners` names the record's fleet, the fleet's account |
| - equals the record's raw `Account`, the record is not `role: replica`, |
| - its host is not also an in-scope record's (a collision: logged, given |
| - neither), and `declineMint` is false; |
| + equals the record's raw `Account`, the record is not `role: replica` |
| + and names no `Pool` (a pool is the platform boxes' tenancy boundary |
| + and has no meaning on a fleet; such a record is refused up front and |
| + logged, and the forward row's `Pool` is forbidden, §4.2), its host is |
| + not also an in-scope record's (a collision: logged, given neither), |
| + and `declineMint` is false; |
| - **keep**: `declineMint` is true but `removable` is false (an |
| unreadable marker, or a trashed production app): an existing forward |
| row is kept as it is, nothing is minted; |
| @@ -318,8 +363,16 @@ The cost is the audit of every reader (§4.15). |
| |
| Ownership is disjoint by kind: the forward phase writes and deletes only |
| `IsForward()` rows; the instance pass's `retirable` excludes them (the |
| -sidecar rule, `reconcile.go:2044`); the domains pass removes only |
| -`Platform` rows, which a forward row never is **(R1-11)**. |
| +sidecar rule, `reconcile.go:2044`). The domains pass removes rows on two |
| +grounds: its inferred removal touches only `Platform` rows, which a |
| +forward row never is **(R1-11)**; its whole-app trash loop |
| +(`internal/domains/reconcile.go:217-245`) selects every row of a trashed |
| +app with no kind test and calls `DeleteIfUnchanged`, so it gains |
| +`if rt.IsForward() { keptLive = append(keptLive, rt); continue }` ahead |
| +of the delete **(R2-5)**, and `DeleteIfUnchanged` itself matches no |
| +forward row (§4.2). A trashed fleet app's forward row is retired by the |
| +forward phase alone, under its whole-scan, fresh-store and production |
| +rules. |
| |
| On a box that is not a hub, `FleetOwners` is nil and every forward row is |
| retired on its next whole pass. With claims on (`ClaimEnabled`, shelved), |
| @@ -355,7 +408,11 @@ Callers: |
| rows serves an eligible one through `fleetProxy` and gives an ineligible |
| one no map entry: it never falls through to the `Tunnel` or socket arms. |
| The existing fleet case asks the same predicate. No map entry means |
| - `Allowed` is false. |
| + `Allowed` is false. A forward host has no path map at the hub: path rows |
| + (`route_paths`) whose host is a forward row's are not folded into the |
| + map, so every path of a forward host resolves to the forward row, and |
| + the fleet edge, which holds the app's own paths, routes inside it |
| + (§4.8 relies on this; path maps for fleet apps are a non-goal). |
| - The edges-file writer (`internal/host/edgesfile.go:543-598`) reads the |
| local fleets table once per write and the hub predicate from the same |
| env test, and leaves out every row the predicate refuses, a forward row |
| @@ -370,21 +427,44 @@ the console and already the authority for tunnel credentials and the store |
| door's scope. Records themselves are console-written; a door-backed fleet |
| box cannot write one (`aclWrite`, `storedoor.go:644`). |
| |
| -### 4.5 Bindings and box choice **(R1-1)** |
| +### 4.5 Bindings and box choice **(R1-1, R2-3)** |
| |
| -`ReconcileFleetBindings` changes in three ways: |
| +`ReconcileFleetBindings` changes in four ways: |
| |
| 1. A binding is applied only when the object's key equals |
| `fleetBindingKey(b.Fleet, b.Host)`. A body naming another fleet or host |
| than its key is skipped and logged. |
| -2. `b.Box` must be a registered, active box of `b.Fleet` in the local |
| - `fleet_boxes` table (`ListFleetBoxes`). |
| -3. It runs on the hub only (the same predicate as §4.3 step 2). Only the |
| +2. It is applied by one conditional registry write, never by a check |
| + followed by a separate write (R2-3: today's check at `fleetbind.go:255` |
| + and the hostname-only `SetFleetBox` at `registry.go:2761` can straddle a |
| + `PutForward` that moves the row to another fleet): |
| + |
| + ```sql |
| + -- SetFleetBoxIf(host, fleet, label) |
| + UPDATE routes SET fleet_box = ?label |
| + WHERE host = ?host |
| + AND region = 'fleet/' || ?fleet |
| + AND kind <> 'sidecar' |
| + AND EXISTS (SELECT 1 FROM fleet_boxes |
| + WHERE fleet = ?fleet AND label = ?label AND status = 'active') |
| + ``` |
| + |
| + One statement in the one registry file (`fleets` and `fleet_boxes` |
| + live in the same `registry.db`, `fleets.go:190`), so SQLite evaluates |
| + placement, kind and membership in the same write. No row affected is |
| + not an error: the binding no longer applies, and it is logged once. |
| + It applies to forward rows and to fleet-placed hand rows alike, as the |
| + bindings pass does today. |
| +3. The pass's own pre-checks (route exists, not a sidecar, placed on the |
| + binding's fleet, `FleetBox` differs) stay as a cheap filter, and decide |
| + nothing: the write decides. |
| +4. It runs on the hub only (the same predicate as §4.3 step 2). Only the |
| hub holds rows the fleet arm serves. |
| |
| -With the existing check that the row is placed on the binding's fleet |
| -(`fleetbind.go:255`), a box can steer only its own fleet's hosts, and only |
| -to a box of that fleet. |
| +So a box can steer only its own fleet's hosts, to an active box of that |
| +fleet, as of the instant of the write. A binding validated for fleet A |
| +whose host moves to fleet B before the write changes nothing; a later |
| +binding from B's own box stamps it. |
| |
| Box choice: the forward row starts with no `FleetBox`, so the hub takes |
| the first connected box. Single-box fleet (the witness): fully correct. |
| @@ -442,17 +522,38 @@ row too, with the app's own settings: |
| The gate. The hub never interprets a gate on a forward row: the row's |
| `Gate` is empty and the hub forwards every path to the fleet edge, which |
| holds the record's gate on its own row, renders the form, checks the |
| -password, sets and strips the cookie (`internal/gate/gate.go`). The one |
| -code change is the login-POST refusal: |
| +password, sets and strips the cookie (`internal/gate/gate.go`). |
| + |
| +For a forward host the hub does no gate work at all **(R2-1)**. The |
| +branch point is where `ServeHTTP` decides a request is a login POST, |
| +after the host lookup and before the body is read (`edge.go:1798`): |
| |
| ```go |
| -// edge.go:1966, today: if loginPost && up.route.Gate == "" { |
| -if loginPost && up.route.Gate == "" && !up.route.IsForward() { |
| - http.NotFound(w, r) |
| - return |
| -} |
| +// edge.go:1798, today: |
| +// loginPost := r.Method == http.MethodPost && r.URL.Path == gate.LoginPath |
| +loginPost := r.Method == http.MethodPost && r.URL.Path == gate.LoginPath && |
| + !up.route.IsForward() |
| ``` |
| |
| +`loginPost` has exactly two readers (`edge.go:1799` and `:1966`), so this |
| +one change does three things for a forward host: the body is not bounded, |
| +not parsed and not drained (`:1799-1803`); the upstream is not |
| +re-resolved by `next` (`:1819-1827`), which is also unnecessary because a |
| +forward host has no path map at the hub (§4.4) and so `up` is already the |
| +forward row for every path; and the ungated-route 404 (`:1966`) does not |
| +fire. With `Gate` empty, `Admit` (`:1970`) is not called. The request, |
| +its body untouched and its `Content-Length` true, goes through `fleetProxy` |
| +to the fleet edge, where the same code runs on the box's own row (which |
| +carries the gate) and `gate.login` parses the form. |
| + |
| +The gate parses with `ParseForm` (`gate.go:129-136`), which reads |
| +`application/x-www-form-urlencoded` bodies only; the gate's form posts |
| +that encoding. A multipart POST is judged as carrying no password on the |
| +fleet edge, exactly as it is on a platform edge today. The witness (§8) |
| +posts an ordinary urlencoded browser form with a right and a wrong |
| +password through both edges, and a multipart form, which must get the |
| +same wrong-password page it gets from a platform-hosted gated route. |
| + |
| The gate's same-origin check reads `Origin` against `r.Host`, which |
| `fleetProxy` preserves (`edge.go:3110-3116`). The cookie is host-only and |
| `Secure`; the browser holds it for the public name and the hub passes it |
| @@ -552,7 +653,32 @@ Must ignore it, and why that holds: |
| are not in those reports, so the hub could have pruned the build box-1 |
| runs. Its selection skips `IsForward()` rows: fleet apps keep today's |
| rule, pruned by no platform box (and never by a fleet box, spec F6). |
| -- The instance pass's removal (§4.3). |
| +- The instance pass's removal (§4.3), and the domains pass's whole-app |
| + trash loop (§4.3, R2-5). |
| +- **Canary status (R2-4).** `countExpiredCanaries` |
| + (`internal/host/agent.go:3356`), called on every 5-minute status tick |
| + (`agent.go:4333`), resolves the channel pointer of every non-`Platform` |
| + canary route. A forward row keeps `Channel` for display, so it would |
| + have cost one pointer GET per (account, app, channel) per tick for a |
| + canary the hub does not run. It skips `IsForward()` rows; the fleet box |
| + counts its own. |
| + |
| +Reads it, safe with no change (checked for rev 3): |
| + |
| +- `layoutReversalIncomplete` (`internal/host/systemapply.go:1335`, root): |
| + classifies every row; an inert forward row has no socket and no |
| + journal, so it is neither fenced nor in conflict (`activator.Classify`, |
| + `internal/activator/layout.go:95-115`, conflicts only with |
| + `ActivatorManaged` peers). A planted journal could make it read fenced, |
| + which blocks a layout reversal: the safe direction. |
| +- The staged-version sweep (`internal/host/versionsweep.go:64-79`) pins |
| + `Version`, `PrevVersion`, `GoodVersion`, all forbidden on a forward row. |
| +- The egress nudger (`internal/host/egress_nudge.go:107-125`): a row with |
| + no `EgressAllow` and no expiry sends nothing. |
| +- Restart, proof asks, socket advice, alias sockets, sidecar wake |
| + (`restart.go:71`, `proofask.go:134`, `proofroot.go:111`, |
| + `socket_advice.go:35`, `aliassocket.go:54`, `sidecarwake.go:51`): select |
| + `Adoptable`, `instance`, `Platform` with a socket, or sidecars. |
| |
| Must treat it correctly, with a change: |
| |
| @@ -595,8 +721,10 @@ under `fleets/`, `B` = binding objects. |
| | reader | before | after | |
| |---|---|---| |
| | instance pass, record bodies | read on every platform box | same (no new record read) | |
| -| instance pass, trash markers (hub) | in-scope apps | + `A` GETs per pass in the prefetch: `A x P` | |
| -| trash removal confirmation | on a removal only | same, for forward retirements | |
| +| instance pass, trash markers (hub) | in-scope apps: marker, then manifest | + `A` marker GETs per pass in the trash-only prefetch, no manifest, seed or policy read (R2-4): `A x P` | |
| +| trash removal confirmation, production flag | on a removal only | same, for forward retirements | |
| +| canary status, `countExpiredCanaries` (every 5-minute status tick) | 1 pointer GET per canary (account, app, channel) on the box | unchanged: forward rows skipped (R2-4); a canary forward row would have cost 288 GETs a day | |
| +| domains pass (housekeeper, apps domain set) | per its own selectors | unchanged: trash loop skips forward rows (R2-5), sources never pick one (R1-11); DNS and TLS stamps read no bucket | |
| | telemetry (hub; index armed) | per hosted (account, app) | + up to 2 GETs per new pair per scope change and per 30-minute backstop: `<= 2 x 48 x A` (account key shared when the account already has rows) | |
| | telemetry (index off) | 2 GETs per pair per pass | + `2 x A x` telemetry passes | |
| | plans pass (plans on) | 1 limits GET per represented account per pass | + `C` per pass | |
| @@ -604,6 +732,7 @@ under `fleets/`, `B` = binding objects. |
| | build states, alias pass, edges-file assets | per their selectors | unchanged: forward rows excluded or read nothing | |
| | bindings pass | `1 + F + B` per pass on every platform box | on the hub only: saves `(N - 1) x 262 x (1 + F + B)` | |
| | edges file | written on change | one more PUT when a forward row appears or goes; readers' existing 30 s mirror | |
| +| console floor and barrier (§9) | none | none in steady state; one system-pointer GET per followed channel on each fleet create, and on a channel move that crosses the floor (as the regional floor) | |
| | fleet boxes | unchanged | unchanged | |
| |
| So 1a is not free: each fleet app costs the hub about what a platform app |
| @@ -614,55 +743,102 @@ fleet app per day. No reader polls on its own timer: every one is an |
| existing pass gated as it is today. |
| |
| The test: the production pass set (instance pass, telemetry, plans, |
| -retention, bindings, edges file) run over identical records and registry |
| -twice, once without and once with a fleet-placed app and its forward row, |
| -with a counting store; the difference must equal the table's `A = 1, C = 1` |
| -row by row. |
| - |
| -## 7. Census **(R1-13, R1-4)** |
| - |
| -Root-read census (`TestPlan14RootReadCensus`) fails: `internal/provision`, |
| -`internal/registry`, `internal/edge`, `internal/host`, `internal/release` |
| -and the root package are in the root binary. Input sources are unchanged |
| -(the agent-writable `registry.db`, including its console-written |
| -`fleets` and `fleet_boxes` tables, and the bucket through the existing |
| -passes). Added read sites and changed units, claimed one by one with |
| -`make census-card` and `make census-propose`: |
| - |
| -- `internal/registry`: `KindForward`, `Route.IsForward` (reads `Kind`), |
| - `Route.InertForward` (reads the columns of §4.2), `PutForward` and |
| - `DeleteForward` (new writers, conditional on `Kind`). |
| -- `internal/host/egress_source.go` `boxWhollyNested`: **runs as root**. A |
| - new case reads `Kind` and the inert columns of an agent-written row to |
| - SKIP it; every other refusal and the root evidence are unchanged. The |
| - reviewer checks that an agent-written row can only skip itself, never |
| - another row, and that a non-inert forward row is still refused. |
| -- `internal/provision/reconcile.go` `Reconcile` (forward phase, trash |
| - prefetch scope, `retirable` guard) and `ReconcileConfig.FleetOwners` |
| - (reads `Fleet.Name`, `Fleet.Account`). |
| -- `internal/host`: `boxProvisionConfig` (hub predicate, owner map), |
| - `ReconcileFleetBindings` (key check; reads `FleetBox.Label`, `Status`), |
| - `instancesLoop` (hub-only bindings), the edges-file writer (eligibility, |
| - fleets read), `retentionPass` selection, `planThrottleFor`. |
| -- `internal/edge`: `Reload` (forward case, eligibility, fleets read moved |
| - earlier), `FleetServeEligible`, `rateAdmit`, `planThrottleOf`, |
| - `trackUpgrade`, the login-POST rule, `cacheable`, `localAssetCatch`. |
| -- `internal/release`: `FleetForwardFloor`, `FleetForwardFloorAllows`, |
| - `FleetForwardFloorOverrideFlag`, `SystemPointer.AllowBelowFleetForwardFloor` |
| - (an additive, signed field root parses and does not act on, as the two |
| - floors' flags). |
| -- Root package: the `carlos system update` and `rollback` flag; the |
| - `carlos route` and `carlos add` refusal. |
| +retention, build states, bindings, edges file, the status tick's |
| +`countExpiredCanaries`, and the domains pass) run over identical records |
| +and registry twice, once without and once with a fleet-placed app on a |
| +`canary/*` channel and its forward row, with a counting store keyed by |
| +object prefix; the difference must equal the table's `A = 1, C = 1` row by |
| +row, with zero manifest, policy, seed and channel-pointer reads for the |
| +forward app. |
| + |
| +## 7. Census **(R1-13, R1-4, R2-7)** |
| + |
| +How the card is built, read from `internal/provision/plan14_root_reads_test.go`: |
| +every top-level declaration in scope whose body has a read site (a |
| +selection of a field of an `internal/registry` struct, a whole registry |
| +struct, a file or env primitive, `:192-207`) is a unit, pinned by the |
| +sha256 of its source; and every directory in scope has a source |
| +envelope, the hash of all its files (`:397-405`). So a changed |
| +declaration with sites shows as `body` or `sites`, a new one with sites as |
| +`new`, a removed one as `removed`, and every directory touched re-pins its |
| +envelope whether or not a unit changed. |
| + |
| +Input sources are unchanged: the agent-writable `registry.db` (its |
| +console-written `fleets` and `fleet_boxes` tables included) and the bucket |
| +through the existing passes. What is added is read sites, listed here. |
| +This is the list the card should show for rev 3; the builder runs |
| +`make census-card` after each task and reconciles any difference here |
| +before `make census-propose`. |
| + |
| +Envelopes re-pinned (seven): the root package `.`, `internal/registry`, |
| +`internal/provision`, `internal/host`, `internal/edge`, `internal/release`, |
| +`internal/domains`. |
| + |
| +Units, by file (N = new, R = removed, otherwise a changed body or sites): |
| + |
| +- `internal/registry/registry.go`: `Route.IsForward` (N, reads `Kind`); |
| + `Route.InertForward` (N, reads every forbidden column of §4.2); |
| + `Registry.PutForward` (N); `Registry.DeleteForward` (N); |
| + `Registry.SetFleetBoxIf` (N); `Registry.SetFleetBox` (R); and every |
| + writer that gains `kind <> 'forward'` and reads a `Route` field in its |
| + body: `Upsert`, `UpsertUnlessRootfs`, `DeleteIfUnchanged`, and those of |
| + the §4.2 setter list whose bodies select a `Route` field. A setter whose |
| + body has no read site changes only the envelope. `KindForward` (a |
| + constant) is envelope-only. |
| +- `internal/registry/remote_dispatch.go`: `Registry.dispatchRemote` (the |
| + three new cases, `SetFleetBox` gone). |
| +- `internal/provision/reconcile.go`: `Reconcile` (forward phase, trash-only |
| + prefetch, `retirable` guard); the forward phase's own helpers (N), named |
| + by the plan; `ReconcileConfig` (the `FleetOwners` field; envelope unless |
| + a site). |
| +- `internal/domains/reconcile.go`: `Reconcile` (trash-loop skip). |
| +- `internal/host/agent.go`: `boxProvisionConfig` (hub predicate, owner map, |
| + reads `Fleet.Name`, `Fleet.Account`); `instancesLoop` (hub-only |
| + bindings); `countExpiredCanaries` (skip); the hub predicate helper (N). |
| +- `internal/host/fleetbind.go`: `ReconcileFleetBindings` (key check, |
| + `SetFleetBoxIf`). |
| +- `internal/host/edgesfile.go`: `edgesFileWriteClaims` (eligibility, |
| + fleets read, no `assets` for forward rows). |
| +- `internal/host/egress_source.go`: `boxWhollyNested`, **runs as root**. |
| + The new case reads `Kind` and the forbidden columns of an |
| + agent-written row only to SKIP that row; every other refusal and the |
| + root evidence (`railEvidence`) are unchanged. The reviewer checks that a |
| + row can only skip itself, never another row, and that a non-inert |
| + forward row is still refused. |
| +- `internal/host/retention.go`: `retentionPass` (skip). |
| +- `internal/host/plans_pass.go`: `planThrottleFor` (admit). |
| +- `internal/edge/edge.go`: `Edge.Reload` (forward case, eligibility, fleets |
| + read moved before the routes loop, path rows of forward hosts not |
| + folded); `Edge.ServeHTTP` (`loginPost`, `cacheable`); `FleetServeEligible` |
| + (N). |
| +- `internal/edge/ratelimit.go`: `Edge.rateAdmit`. |
| +- `internal/edge/planthrottle.go`: `Edge.planThrottleOf`, `Edge.trackUpgrade`. |
| +- `internal/edge/assetcatch.go`: `Edge.localAssetCatch`. |
| +- `internal/release/layoutintent.go`: `FleetForwardFloor`, |
| + `FleetForwardFloorAllows`, `FleetForwardFloorOverrideFlag`, |
| + `FleetForwardFloorOverrideUsage` (N; envelope-only unless a site). |
| +- `internal/release/systempointer.go`: `SystemPointer` (the additive |
| + signed field `AllowBelowFleetForwardFloor`; root parses it and does not |
| + act on it, as on the two other floors' fields); `SystemPromoteOptions` |
| + (the field `AllowBelowFleetForwardFloor`); `PrepareSystemPromotion` and |
| + `PrepareSystemRollback` (copy the option onto the pointer, as they copy |
| + the rootfs and regional ones, `systempointer.go:318`, `:375`). The |
| + `internal/release` envelope re-pins. |
| +- Root package: `runSystemUpdate` (`system.go:289`) and |
| + `runSystemRollback` (`system.go:578`) (the flag); `runAdd`, |
| + `runRemove`, `runRoute` (`cli.go:197`, `:471`, `:709`) (the refusal |
| + wording on `ErrForwardRow`). |
| |
| Root's own row readers (adopt, capability, named units, restart, stage, |
| -rootfs) change no code and select by `Kind == "instance"`, `IsSidecar()`, |
| -`Unit`, `Runtime`, `Backing`, `Caps`; the reviewer checks none admits an |
| -inert forward row. |
| +rootfs, `layoutReversalIncomplete`) change no code and select by |
| +`Kind == "instance"`, `IsSidecar()`, `Unit`, `Runtime`, `Backing`, |
| +`Caps`, or classify a row they cannot run as neither fenced nor in |
| +conflict (§4.15); the reviewer checks none admits an inert forward row. |
| |
| Record-write census (9B8): no new bucket writer. `Reconcile`'s inventory |
| digest changes and is re-reviewed with the card. The console changes |
| -(`placeAppTarget`, the floor judge, the fleet-create barrier) are outside |
| -the root scope. |
| +(`placeAppTarget`, instance health, the floor judge, `fleetFloorMu`, the |
| +fleet-create barrier) are outside the root scope. |
| |
| Reviewer: Astra, verdict on #280. |
| |
| @@ -671,22 +847,34 @@ Reviewer: Astra, verdict on #280. |
| Unit (`internal/registry`, `internal/provision`, `internal/edge`, |
| `internal/host`): |
| |
| -1. `PutForward` over an existing non-forward row writes nothing and |
| - returns `ErrHostHeld`; over a forward row carrying stray `Tunnel`, |
| - `Caps`, `Unit`, `Seed`, the stored row read back has exactly §4.2's |
| - columns; `FleetBox` survives an unchanged `Region` and is cleared by a |
| - changed one. `DeleteForward` leaves a hand row alone. |
| +1. Shape **(R2-6)**. A reflection test over `registry.Route` fails on any |
| + field not named in one of §4.2's four classes. For each forbidden |
| + column, one at a time: a forward row with only that column set is not |
| + `InertForward()`, is not served, not published and not skipped by |
| + egress; `PutForward` over it writes zero there. `PutForward` over an |
| + existing non-forward row writes nothing and returns `ErrHostHeld`; it |
| + keeps `DNSStatus`, `DNSCheckedAt`, `CertExpiresAt` and (with `Region` |
| + unchanged) `FleetBox`, and clears `FleetBox` on a `Region` change. |
| + Every other exported `routes` writer, run against a forward row, |
| + changes nothing (an `UPDATE` matches no row; `Upsert` and |
| + `UpsertUnlessRootfs` return `ErrForwardRow`); `SetDNSStatus` and |
| + `SetCertExpiresAt` stamp it. `DeleteForward` leaves a hand row alone. |
| 2. Forward phase: every decision of §4.3 step 3 and every row of §4.6, |
| including trash read and not production (retired), production |
| (kept), unreadable marker (kept, not minted), snapshot removal |
| re-confirmed against the bucket; no removal on a failed read or partial |
| - scan; held host reported once per pass. |
| -3. Ownership both ways: the instance pass never retires a forward row; the |
| - forward phase never touches an instance, sidecar, hand or `Platform` |
| - row; the domains pass mints nothing from a forward source. |
| + scan; held host reported once per pass; a record with a `Pool` refused; |
| + a forward app's manifest never read (the trash-only prefetch). |
| +3. Ownership: the instance pass never retires a forward row; the forward |
| + phase never touches an instance, sidecar, hand or `Platform` row; the |
| + domains pass mints nothing from a forward source, and its trash loop, |
| + given a trashed fleet app with a forward row and a trashed platform app |
| + with an instance row, deletes the instance row and keeps the forward |
| + row (R2-5), which the forward phase then retires under its own rules. |
| 4. Readers table: every §4.15 "must ignore" selector answers false for an |
| - inert forward row, retention included (a forward row pins and prunes |
| - nothing for its app). |
| + inert forward row, retention (a forward row pins and prunes nothing for |
| + its app) and `countExpiredCanaries` (a `canary/*` forward row reads no |
| + pointer) included. |
| 5. `FleetServeEligible`: accountless hand row eligible and logged; |
| explicit mismatch refused; invalid account refused (not `OpsAccount`'d |
| into a pass); forward row with empty account, unknown fleet, or a stray |
| @@ -705,12 +893,37 @@ Unit (`internal/registry`, `internal/provision`, `internal/edge`, |
| 9. Bindings through the authenticated store door: a box of fleet A writes |
| `fleets/A/bindings/<B's host>.json` naming fleet B and a B label, and a |
| binding naming an unregistered label under its own fleet; the bindings |
| - pass applies neither. |
| + pass applies neither. Placement change **(R2-3)**, deterministic: A's |
| + box writes a correctly keyed binding for A's host through the door; a |
| + test hook stops the bindings pass after its pre-checks; `PutForward` |
| + moves the row to fleet B (same account) and clears `FleetBox`; the pass |
| + resumes and its `SetFleetBoxIf(host, "A", label)` affects no row; the |
| + stored row has an empty `FleetBox`, and a request goes to B's box. Also: |
| + a binding naming a detached box of the right fleet affects no row. |
| 10. Egress: a box with one nested local instance and an inert forward row |
| is wholly nested; with a non-inert forward row or an unknown kind it is |
| not. |
| -11. Floor: §9's refusals, override, signed flag and fleet-create barrier. |
| -12. Counting store: §6. |
| +11. Floor **(R2-2)**: §9's refusals, override and signed flag, on update, |
| + promote and rollback. A first publication (no pointer) below the floor |
| + is refused while a fleet exists, both in the up-front gate and under |
| + `fleetFloorMu`, and allowed with the override or with no fleet; at or |
| + above the floor it is allowed. The two interleavings, with hooks as |
| + `regionalFloorHooks` has: (a) no pointer; a below-floor update passes |
| + the up-front gate with no fleet; a fleet is created (the barrier passes: |
| + no pointer is on its way); the publication re-judges under |
| + `fleetFloorMu`, sees the fleet and is refused, and no pointer is |
| + written; (b) the below-floor publication goes first under the mutex |
| + with no fleet; the fleet create then reads that pointer and is refused. |
| +12. Login body **(R2-1)**: through both edges, an ordinary |
| + `application/x-www-form-urlencoded` POST to `/.carlos/gate` with the |
| + right password gets the cookie and a redirect to `next`; with a wrong |
| + one, the wrong-password page and no cookie; the fleet edge receives |
| + the body byte for byte with a matching `Content-Length` (asserted at |
| + the box). A `multipart/form-data` POST gets the same answer it gets |
| + from a platform-hosted gated route (no password read). A login POST to |
| + a forward host with a path row at the hub reaches the fleet edge (path |
| + rows are not folded for forward hosts). |
| +13. Counting store: §6. |
| |
| Production-wired witness, the gate ahead of review rounds (memory |
| `production-wired-witnesses`). In the root package, which can import the |
| @@ -728,8 +941,9 @@ loop; no hand-built rows, no fabricated records: |
| with `CARLOS_FLEET=f`, serving over `tunnelclient.Loop` with that token, |
| and a real process at the derived socket answering `/up` with its build. |
| - Through the hub's TLS listener (test certificate): `GET /up` gets the |
| - fleet edge's login form; `POST /.carlos/gate` with the password gets the |
| - cookie; `GET /up` with it is 200 with one `X-Carlos-Version: v1`; the |
| + fleet edge's login form; the form posted back as a browser sends it |
| + (urlencoded, with `next`) with a wrong password gets the wrong-password |
| + page; with the right one, the cookie; `GET /up` with it is 200 with one `X-Carlos-Version: v1`; the |
| same GET without the cookie is the form again (nothing cached at the |
| hub); requests past the limit get 429 from the hub. Then: an instance |
| catch-all under an attached custom parent serves; detach the box, 503 |
| @@ -768,11 +982,24 @@ the old fleet indefinitely. The RegionalDomainsFloor pattern |
| the floor may move anywhere; one at or above it may not move below it or |
| to a version that does not parse. |
| - Condition: while a fleet exists in the console's registry |
| - (`ListFleets` non-empty, local, no bucket read). This is a superset of |
| - "a fleet-placed record exists" (no fleet-placed record can be made, or |
| - forwarded, without a fleet) chosen because the record form needs a walk |
| - of every record and the table form is exact about what matters: no |
| - fleet, no forward row. |
| + (`ListFleets` non-empty, local, no bucket read). A superset of "a |
| + fleet-placed record exists" (no fleet-placed record can be made, or |
| + forwarded, without a fleet), accepted in round 2. |
| +- The judge, `fleetForwardFloorJudge(channel, cur, target, allow)`, has |
| + three cases **(R2-2)**: |
| + - a pointer exists: `FleetForwardFloorAllows(cur.Current.Version, target)` |
| + decides, and a crossing is refused while a fleet exists; |
| + - no pointer (a first publication; supported, `systempointer.go:296`): |
| + a target that parses at or above the floor passes; any other target |
| + is refused while a fleet exists. Absence is not a pass, unlike the |
| + rootfs and regional floors, whose early return |
| + (`rootfsfloor.go:61-63`) and `cur != nil` guard |
| + (`regionalfloor.go:119`) this judge does not share; |
| + - `allow`: passes, logged. |
| + |
| + A rollback always has a pointer (`PrepareSystemRollback` fails without |
| + one, `systempointer.go:362`), so only update and promote can be first |
| + publications. |
| - Override: `--allow-below-fleet-forward-floor` |
| (`release.FleetForwardFloorOverrideFlag`) on `carlos system update` and |
| `carlos system rollback`, signed on the pointer as |
| @@ -780,19 +1007,31 @@ the old fleet indefinitely. The RegionalDomainsFloor pattern |
| identity, as the other two overrides; boxes do not read it. Its log line |
| and the CLI's warning say what it costs: the hub keeps serving fleet |
| apps it can no longer retire, so remove their rows first. |
| -- Checked where the other floors are: `systemFloorGate` / |
| - `systemFloorSnapshot` (`internal/console/rootfsfloor.go`) on the update |
| - door's preflight (`apisystemupdate.go:428`), `promoteHostUpdate`, and |
| - `rollbackHostUpdate`, judged on the same pointer read; and again under a |
| - console mutex (`fleetFloorMu`) immediately before the pointer is |
| - published, as `regionalFloorPublish` does. |
| +- Checked where the other floors are: `systemFloorSnapshot` |
| + (`internal/console/rootfsfloor.go:60`) on the update door's preflight |
| + (`apisystemupdate.go:428`), `promoteHostUpdate`, and |
| + `rollbackHostUpdate`. In `systemFloorSnapshot` the fleet judge runs in |
| + the not-found branch too (with `cur` nil), before that branch returns. |
| + And again, binding, under a console mutex `fleetFloorMu` held from the |
| + judgment through the pointer's publication: `fleetFloorPublish`, the |
| + `regionalFloorPublish` shape, except that it judges when `current()` |
| + returns no pointer instead of skipping. Lock order: `fleetFloorMu` is |
| + taken before `regionalMu`, and nothing under either takes the other |
| + first. |
| - The barrier for the other order: the fleet-create doors |
| (`handleAPIFleetNew`, `fleets.go:176`, and the page form) hold |
| - `fleetFloorMu` from their check to their write and refuse while any |
| - system channel's current pointer names a release below the floor. So a |
| - fleet cannot appear between a downgrade's judgment and its publication, |
| - nor while a downgraded hub could still be running the newer binary. |
| - Existing fleets are unaffected. |
| + `fleetFloorMu` from their check to their registry write, and refuse |
| + while any channel the fresh heartbeats follow (stable for a box that |
| + names none, as `regionalChannelRefusal` reads them, |
| + `apiplacements.go:935-978`) has a pointer naming a release below the |
| + floor or one that does not parse; a pointer that cannot be read refuses |
| + (503). An absent pointer passes. That is the simpler correct choice: |
| + nothing is on its way to the boxes, and any later publication on that |
| + channel, first included, is judged under the same mutex with this fleet |
| + visible, so a below-floor one is refused (interleaving (a) in §8 test |
| + 11). Refusing on an absent pointer would block fleets on deployments |
| + that never publish a channel pointer, for no safety it adds. Existing |
| + fleets are unaffected. |
| |
| Refusal, override and barrier strings go to copy review. |
| |
| @@ -816,11 +1055,14 @@ winning. The release notes say so, and name the floor. |
| inert forward shape (R1-4); a release floor (R1-5); one eligibility |
| predicate (R1-6); no conversion (R1-7); explicit trash decisions |
| (R1-8); Slug kept (R1-10); no platform names in 1a (R1-11). |
| - |
| -One call left for the controller: the floor's condition is "a fleet |
| -exists" rather than the ruling's "a fleet-placed record exists" (§9), for |
| -the reason given there. A deployment with an empty fleet gets a floor it |
| -does not strictly need, and the override covers it. |
| +7. R2 rulings: the hub does no gate work for a forward host, form parsing |
| + included (R2-1); a below-floor first publication is refused while |
| + fleets exist, and the barrier passes an absent pointer for the reason |
| + in §9 (R2-2); `SetFleetBoxIf` (R2-3); canary reads skip forward rows |
| + and the trash prefetch for them is marker-only (R2-4); the domains |
| + trash loop skips forward rows (R2-5); one exhaustive shape (R2-6); the |
| + census list per unit (R2-7). The floor's "a fleet exists" condition was |
| + accepted in round 2. |
| |
| ## 11. Notes against the #457 draft |
| |