spec: linked deployments rev 2, settle the builder check
A publication is a linked app record; home enforces by published app; link channels cannot pass as fleets; console writes the hub registry; v1 is single-box homes; hub rolls accepted; code references corrected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+118
−53
docs/superpowers/specs/2026-11-10-linked-deployments-design.md+118 −53
CI failed — run details
diff --git a/docs/superpowers/specs/2026-11-10-linked-deployments-design.md b/docs/superpowers/specs/2026-11-10-linked-deployments-design.md| index 6f753af7b..526c1548c 100644 |
| --- a/docs/superpowers/specs/2026-11-10-linked-deployments-design.md |
| +++ b/docs/superpowers/specs/2026-11-10-linked-deployments-design.md |
| @@ -1,6 +1,6 @@ |
| # Linked deployments: publish an app from a home deployment through Carloku |
| -Status: design, 2026-11-10, rev 1. Branch `design-linked-deployments`. |
| +Status: design, 2026-11-10, rev 2 (after a Fable 5.2 builder check). Branch `design-linked-deployments`. |
| Brainstormed with Paul in session on 2026-11-10; his answers are marked |
| as his, and everything else is marked as the designer's call. |
| @@ -71,7 +71,8 @@ names. |
| 1. Link a home deployment to a Carloku account in one command plus one |
| browser approval. |
| 2. Publish and unpublish one app with one command each. Unpublishing stops |
| - the public link at once (within one hub reload, bounded below). |
| + the public link within one hub reload after the serving console records |
| + it, and the home side stops serving it before that (§6.3). |
| 3. A published app looks to a visitor like a Carloku app: hostname, TLS, |
| protection, custom domain, WebSockets. |
| 4. A published static site keeps serving while home is offline. |
| @@ -125,6 +126,8 @@ names. |
| to one account, plus the credential the home deployment holds. |
| - **Publication**: a record on the serving console saying "serve this |
| home app at this hostname for this link". |
| +- **Linked app**: the app record a publication creates in the serving |
| + account (§6.0). It is how every existing app surface sees a publication. |
| ## 5. User flows |
| @@ -159,14 +162,16 @@ then calls the serving console with the link credential. The serving |
| console checks the account's plan caps and that the hostname is free, |
| records the publication, and returns the public URL. The CLI prints it. |
| -Hostname: `<name>.<account>.<platform domain>`, minted exactly as a |
| -Carloku app's platform name is, from the same namespace. Designer's call: |
| +Publishing creates a linked app (§6.0) named `<name>` in the account. |
| +Its hostname is the platform name any Carloku app of that name gets, |
| +minted by the same code from the same namespace. Designer's call: |
| a name already used by a Carloku app in the account (or by another |
| publication) is refused, not shadowed. Paul's demo app already exists on |
| Carloku, so its home copy gets a different name. |
| Custom domains attach with the existing `carlos domains` commands on the |
| -serving side, naming the publication as the app. |
| +serving side, naming the linked app. They work because the linked app is a |
| +real app record. |
| ### 5.3 Unpublish and unlink |
| @@ -203,6 +208,27 @@ views on Carloku. Those live at home. |
| ## 6. How it works |
| +### 6.0 A publication is an app record |
| + |
| +Designer's call, settling the builder check's first question. A |
| +publication creates an ordinary app record in the serving account's |
| +bucket, of a new kind, **linked**, that names its link. The record is |
| +what lets every existing app surface treat it as an app: the app list, |
| +analytics, protection, usage, the app cap, name collisions and |
| +`carlos domains`, with no second source of truth. |
| + |
| +Every path that acts on an app's code or config must refuse a linked app |
| +with a clear message saying the app is managed by its home deployment: |
| +deploy, promote, secrets, env, instances, runs, exec, logs, db, moves, |
| +regions and replicas. Builder to enumerate these from the CLI registry and |
| +the console's app API, and to guard them in one place (a single |
| +"is this app linked?" check consulted by each), with a test that walks |
| +the registry and fails on any app-acting command that does not consult |
| +it. |
| + |
| +Unpublishing or unlinking deletes the linked app record, and with it any |
| +static release and custom-domain attachments. |
| + |
| ### 6.1 The link credential |
| A new credential kind on the serving console, minted only by link |
| @@ -217,59 +243,87 @@ It cannot do anything else: no account APIs, no store door, no replica |
| coordinator, no runs, no fleet APIs. The store door's and the fleet APIs' |
| existing identity checks must refuse it. |
| -The device-code flow today mints only user-scoped tokens |
| -(`ApproveCLIAuth`, `internal/console/authstore.go`). Builder's choice |
| -whether link approval is a new flow kind on the same endpoints or a |
| -separate endpoint pair, provided the approval page names the link and the |
| -account. |
| +The device-code flow today yields only user-scoped tokens: approval |
| +records the user (`ApproveCLIAuth`) and the token is minted when the CLI |
| +polls (`internal/console/authstore.go:505-507`). Builder's choice whether |
| +link approval is a new flow kind on the same endpoints or a separate |
| +endpoint pair, provided the approval page names the link and the account. |
| Rotation and revocation: `carlos link rotate` from home; unlink revokes. |
| -Revocation must cut a connected tunnel, as fleet box detach does today |
| -(`internal/edge/tunnel.go`). |
| +Both cut any connected tunnel at once. Fleet box detach already cuts a |
| +channel; fleet rotation deliberately does not |
| +(`internal/edge/tunnel.go:375-389`), so link rotation must call |
| +`CloseChannel` itself, because a rotation here is the response to a |
| +leaked credential. |
| ### 6.2 Dynamic apps: the tunnel |
| Reuse the fleet tunnel unchanged on the wire: `GET /register` with |
| `Upgrade: carlos-tunnel/1`, inverted HTTP/2, WebSocket upgrades carried |
| -(#471, `internal/tunnelclient`). The channel name space is new, for |
| -example `link/<link id>/<box label>`, so it can never collide with a |
| -fleet's `<fleet>/<label>`. The hub's dynamic auth (`SetDynamicAuth`, |
| -`VerifyDynamic`) gains link channels, loaded from the link table on |
| -reload as fleet boxes are now. |
| - |
| -Routing on the hub: a new route kind (or a forward row with a link |
| -owner instead of a fleet owner; builder's choice) written by the hub's |
| -own pass from the serving console's publication records. Those records |
| -live in the console's database, not the hub's bucket, because a linked |
| -app has no release or app record in the serving bucket. The edge checks, |
| -per request, that the row's account owns the link, as |
| -`FleetServeEligible` does for fleets. One check, used for both kinds. |
| - |
| -Which home box dials: every home box that serves a published dynamic app |
| -dials, with the link credential and its own label. The hub sends a |
| -request to a connected box that serves the app. Designer's call: v1 may |
| -require a home deployment's published apps to be served by its box |
| -that holds the link (one dialling box per link), which covers the Pi. |
| -Multi-box home deployments are the builder's to support or refuse with a |
| -clear message. |
| +(#471, `internal/tunnelclient`). |
| + |
| +**Channel names must not be confusable with fleet channels.** Fleet names |
| +are any `ValidTunnelName` with no reserved words |
| +(`internal/registry/fleets.go:232`), and three places take a channel's |
| +first segment as a fleet: `VerifyDynamic` (`tunnel.go:345`), the store |
| +door (`storedoor.go:181-182`) and `ConnectedOfFleet`'s prefix match |
| +(`tunnel.go:452`). Link channels therefore use a form no fleet name can |
| +take (a prefix outside the fleet name alphabet, or a reserved name that |
| +fleet creation refuses; builder's choice), and each of those three places |
| +must refuse a link channel explicitly. A test proves a link credential is |
| +refused by the store door, the replica coordinator and the fleet APIs. |
| + |
| +**Where the hub learns about links and publications.** As for fleets: |
| +the serving console writes link credential hashes and publication rows |
| +straight into the hub's registry (as `internal/console/fleets.go:259` |
| +does for fleet rows), and the hub's reload picks them up (`edge.go:969`). |
| +No new hub pass reads the console database, and no new bucket polling. |
| + |
| +**Routing.** A forward row with a link owner instead of a fleet owner, or |
| +a new route kind; builder's choice. Eligibility is judged at reload, as |
| +fleet rows are through `FleetArmVerdict` |
| +(`internal/edge/fleetforward.go:31-57`, `edge.go:1043`): the row's account |
| +must own the link. Only the channel choice happens per request. One |
| +verdict function serves both fleet and link rows. |
| + |
| +**Home shapes in scope for v1.** Designer's call: a home deployment whose |
| +console and serving edge run on the same machine and share a registry, |
| +which is the Pi. The link credential and the published set reach the |
| +edge through that registry, so publishing takes effect without a |
| +restart. A box's tunnel today is one loop configured from environment at |
| +agent start (`internal/host/tunnel_client.go:35`); the link adds a second, |
| +registry-driven loop beside it, started and stopped as the link comes |
| +and goes. Linking refuses, with a clear message, a home deployment with |
| +more than one box serving apps, and a box that is itself a fleet box of |
| +another hub. Wider shapes are a follow-up. |
| Client address: the home app sees the visitor's address in the usual |
| forwarded headers, as fleet apps do (see #476). |
| ### 6.3 Home-side enforcement |
| -The home box's tunnel handler serves **only** hosts in its current |
| -published set, which it gets from its own console, not from the hub. Any |
| -other host, including the home deployment's own tailnet names, gets a |
| -refusal without touching an instance. Unpublishing removes the host |
| -from that set before the home console calls the serving console. This |
| -is the guard for anti-goal 1, and it gets its own test that drives the |
| -real tunnel handler with an unpublished host. |
| - |
| -The tunnel handler must not expose the box's other edge surfaces (the |
| -devbox listener, admin or health endpoints beyond what fleet boxes |
| -already expose over the tunnel). Builder to list what the fleet tunnel |
| -handler serves today and cut it down to published hosts. |
| +Home enforces **by published app, not by host**. Designer's call, |
| +because custom domains are attached on the serving side and the home |
| +console never learns them, and having Carloku tell home which hosts to |
| +trust would be trust flowing the wrong way. |
| + |
| +- On every request down a link channel, the hub names the publication it |
| + is serving in a header it sets and always strips from client requests, |
| + as #471 does for its hub marker. |
| +- The home box's link handler maps that publication to a home app using |
| + its own published set, read from its own registry. It serves that app's |
| + instances whatever the Host header says, and refuses anything that |
| + names no currently published app, without touching an instance. |
| +- Unpublishing removes the app from the home set before the home console |
| + calls the serving console. |
| + |
| +The link handler is new and separate from the fleet tunnel handler, |
| +which serves the box's whole edge (`internal/host/agent.go:1257`). It |
| +reaches published apps' instances and nothing else: not the devbox |
| +listener, not admin or health endpoints, not other apps. This is the |
| +guard for anti-goal 1. Its test drives the real handler, through real |
| +wiring, with an unpublished app, an unknown publication, a missing |
| +header, and a client-supplied header. |
| ### 6.4 Offline page |
| @@ -284,9 +338,11 @@ apps keep their current answer unless the copy review rules otherwise. |
| When the home deployment deploys a release of a published static app, |
| the home console uploads the built release to the serving console with |
| -the link credential. The serving console stores it as that publication's |
| -release and serves it as an ordinary static route, with the edge page |
| -cache and asset cache as for any Carloku static site. Publishing a static |
| +the link credential. The serving console stores it as an ordinary static |
| +release of the linked app (§6.0), under the app's own key, and promotes |
| +it. From there it is placed and served exactly as any Carloku static site |
| +is, on any edge box, with the edge page cache and asset cache. It does |
| +not go through the hub. Publishing a static |
| app uploads its current release straight away. |
| The serving side checks the upload as it checks any static release |
| @@ -315,7 +371,16 @@ requests and bytes count as usage, as today's forward rows already do |
| (`usagemeter.go`). A static copy counts against storage like any static |
| release. Plan throttle and lapse apply as for any app. |
| -### 6.8 Versions |
| +### 6.8 The hub, and rolls |
| + |
| +Linked dynamic apps are served on the hub only, as fleet apps are |
| +(fleet public routes spec §4.10); other boxes backhaul to it. A hub |
| +restart drops every link tunnel, and the tunnels redial when it is back. |
| +Designer's call: v1 accepts this, for the same reason fleet apps do, and |
| +visitors see the offline page (§6.4) for those seconds. Fitting links into |
| +region HA is a follow-up. Static copies are unaffected (§6.5). |
| + |
| +### 6.9 Versions |
| The serving console and hub need a release with link support. The home |
| deployment needs one too. A home deployment on an older release cannot |
| @@ -344,13 +409,13 @@ Caching for linked dynamic apps (§6.6) is a separate design after these. |
| - New flow kind or new endpoints for link approval (§6.1). |
| - New route kind or forward row with a link owner (§6.2). |
| -- Channel naming, within the constraint that it cannot collide with |
| - fleet channels. |
| -- Multi-box home deployments: support or refuse clearly (§6.2). |
| +- Channel naming, within the constraints in §6.2. |
| +- The list of app-acting paths a linked app refuses, and the one guard |
| + they all consult (§6.0). |
| - Schema for link and publication records on the serving console. |
| - How the home console stores the link credential (it must not be |
| readable by apps). |
| -- The version floor (§6.8). |
| +- The version floor (§6.9). |
| - CLI flag names beyond those shown, following the CLI registry's |
| conventions. |