carlos / platform Public

spec: linked deployments, rev 1 (publish home apps via Carloku)

A self-hosted deployment links to a Carloku account as a peer and
publishes chosen apps: dynamic apps through the fleet tunnel, static
sites as copies served by Carloku. Brainstormed with Paul 2026-11-10.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev d347973f21ff5897b41880adeec22978981ab788 parent 63706d9
1 file changed, +361 −0
  • docs/superpowers/specs/2026-11-10-linked-deployments-design.md +361 −0

CI cancelled — superseded by a newer push — 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
new file mode 100644
index 000000000..6f753af7b
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-10-linked-deployments-design.md
@@ -0,0 +1,361 @@
+# Linked deployments: publish an app from a home deployment through Carloku
+
+Status: design, 2026-11-10, rev 1. 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.
+
+## 1. Why
+
+Some people run their own CARLOS deployment at home, for example on a
+Raspberry Pi on their tailnet. Its apps are reachable only from the
+tailnet. The same person usually also has a Carloku account.
+
+Sometimes one of those home apps needs to be public:
+
+- a personal blog;
+- a small personal app shared with family by link;
+- a demo shown at a conference talk.
+
+Today the options are to move the app to Carloku, to make the Pi a box in
+a Carloku BYO fleet (which takes it away from the home deployment and
+needs an S3 bucket), or to work around the platform with Tailscale Funnel
+or cloudflared, which skips Carloku's edge.
+
+Paul's reasons for keeping these apps at home, all three of which count:
+the Pi is already paid for; the data stays in the house; and "this runs on
+a Pi in my house, behind Carloku" is a CARLOS story worth telling on stage.
+So linking and publishing must be easy enough to demo live: a command or
+two, not a runbook.
+
+## 2. What it is
+
+A self-hosted CARLOS deployment can **link** to a Carloku account. The
+linked deployment is a peer of the account, not a fleet: Carloku knows it
+exists and serves chosen apps for it, and has no other control over it.
+
+The home deployment then **publishes** individual apps. A published app
+gets a public link that works exactly as if the app were hosted on
+Carloku (Paul: "a link anyone could follow ... as if I had hosted the app
+on carloku.com, but actually the app is running in my house"):
+
+- a hostname under the account, as a Carloku app would get;
+- HTTPS, with TLS ending at the Carloku hub;
+- Carloku's edge protection, rate limits and plan throttle;
+- traffic analytics and usage metering, counted against the account's
+ plan like any Carloku app;
+- custom domains, attached as on any Carloku app;
+- WebSockets.
+
+Everything else stays with the home console: deploys, secrets, data,
+logs, instances and boxes.
+
+Two kinds of published app behave differently:
+
+- **Dynamic apps** (anything with instances) are served from the home
+ deployment through a tunnel that the home deployment dials out to the
+ hub. When home is unreachable, visitors get a clear "this app runs at
+ home and home is offline right now" page from Carloku, not a bare error.
+- **Static sites** are copied to Carloku on each deploy, and Carloku serves
+ the copy. They stay up when the Pi is off. The home deployment is still
+ the source of truth: nothing on Carloku changes until home publishes a
+ new release.
+
+The design is provider-neutral and symmetric: any CARLOS deployment can be
+the serving side. Carloku is the common case and the one this document
+names.
+
+## 3. Goals, non-goals, anti-goals
+
+### Goals
+
+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).
+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.
+5. A published dynamic app shows a clear offline page while home is
+ offline.
+6. The Carloku console shows that the linked deployment exists, whether it
+ is reachable right now, and which apps Carloku serves for it (Paul: "I
+ want to see that it exists, and what apps that we're serving on its
+ behalf"). Nothing more is managed there except unlinking.
+
+### Non-goals (v1)
+
+- **Fallback to a standby copy on Carloku.** Paul ruled this out: for a
+ demo he will give the audience a second link to a copy deployed on
+ Carloku proper.
+- **Syncing a dynamic app's data to Carloku.** The data stays at home.
+- **Access control on published apps.** Anyone with the link can use
+ them, as on Carloku today.
+- **Making the home deployment a fleet**, or letting Carloku place,
+ deploy, start or stop anything at home.
+- **#486 internal apps** (a public/internal flag inside one deployment).
+ This design does not need it: a home deployment that is tailnet-only
+ stays tailnet-only, and publishing is a separate, per-app grant to the
+ link.
+- Several home deployments serving one published app, or one home app
+ published to two Carloku accounts.
+
+### Anti-goals (failure even if everything else works)
+
+1. **Carloku reaches anything at home other than published apps.** Not
+ the tailnet, not unpublished apps, not the home console, not the
+ instances' sockets for other apps, not the store. A compromised or
+ misbehaving hub must still be unable to reach an unpublished app; this
+ is enforced at home, not only at the hub (§6.3).
+2. **Carloku gains control over the home deployment.** No deploys,
+ secrets, exec, runs, store access or config delivery flow from Carloku
+ to home.
+3. **A link or publication outlives its revocation.** Unlink and unpublish
+ take effect promptly on both sides.
+4. **New per-box object-store polling** on either deployment. Publication
+ state flows through console APIs, not new bucket polls (see the S3
+ request cost rule in AGENTS.md and the platform's request meter).
+
+## 4. Words
+
+- **Serving deployment**: the deployment that owns the public front door,
+ here Carloku. Its hub is the console's edge box that terminates
+ tunnels (the "hub" in the fleet public routes spec).
+- **Home deployment**: the self-hosted deployment that runs the app.
+- **Link**: a record on the serving console binding one home deployment
+ 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".
+
+## 5. User flows
+
+### 5.1 Link
+
+On the home deployment (Paul's Pi), an operator runs:
+
+ carlos link create --to https://console.carloku.com
+
+The home console starts the serving console's existing device-code flow
+(`/auth/cli/start`, `/auth/cli/poll`, approval at `/auth/cli` with passkey
+step-up; `internal/console/authcli.go`). The CLI prints the approval link.
+In the browser the person signs in to Carloku, chooses the account and
+sees what they are approving: the home deployment's name, and that it will
+be able to publish apps under this account. Approval mints a **link
+credential** (§6.1) and returns it to the home console, which stores it.
+The plaintext credential is shown to nobody.
+
+Designer's call: approval needs an account role that can create apps, the
+same role `carlos deploy` of a new app needs today.
+
+The home deployment's name defaults to its console's `consoleName()`
+and can be set with `--name`. It is shown on both consoles.
+
+### 5.2 Publish
+
+ carlos link publish <app> # platform hostname
+ carlos link publish <app> --name blog # choose the label
+
+The home console checks the app exists and is the operator's to publish,
+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:
+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.
+
+### 5.3 Unpublish and unlink
+
+ carlos link unpublish <app>
+ carlos link remove
+
+Both work from the home side. Carloku's console also offers **Unlink** on
+the linked deployment's card, for the case where the Pi is lost or
+dead. Unlinking deletes every publication of that link, revokes the
+credential, and drops the tunnel. A static copy is deleted with its
+publication.
+
+`carlos link status` on the home side shows the link, the tunnel state and
+each publication with its public URL.
+
+### 5.4 What Carloku shows
+
+The account's Fleet tab gets a **Linked deployments** section beside
+fleets (`assembleAccountFleet`, `internal/console/accountfleet.go`). Each
+linked deployment shows:
+
+- its name, and when it was linked and by whom;
+- reachable now or not, and when it was last seen;
+- its published apps, each with its public URL and kind (static or
+ dynamic);
+- an Unlink action.
+
+Published apps also appear in the account's app list, marked as served
+from the linked deployment, so analytics, protection and usage views work
+for them as for any app. They have no deploy, secrets, instances or logs
+views on Carloku. Those live at home.
+
+`carlos links list --account <acct>` gives the same on the CLI.
+
+## 6. How it works
+
+### 6.1 The link credential
+
+A new credential kind on the serving console, minted only by link
+approval. It is bound to one account and one link record and carries no
+user's authority. It can:
+
+- create, update and delete publications for its own link;
+- upload static releases for its own static publications;
+- dial the tunnel (§6.2) as its own link's channels.
+
+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.
+
+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`).
+
+### 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.
+
+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.
+
+### 6.4 Offline page
+
+When no home box for the publication is connected, the hub answers with a
+Carloku-rendered page saying the app runs at home and home is offline
+right now, with status 503 and `Retry-After`. Today this case gives the
+plain text "fleet unreachable: no connected box" (`errFleetDark`,
+`internal/edge/edge.go`). The page's copy goes through copy review; fleet
+apps keep their current answer unless the copy review rules otherwise.
+
+### 6.5 Static sites: the copy
+
+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
+app uploads its current release straight away.
+
+The serving side checks the upload as it checks any static release
+(size limits, plan caps, `_headers` rules) and refuses anything else. A
+static publication never opens a tunnel.
+
+If the upload fails, the home deploy still succeeds at home and reports
+that the public copy is behind. `carlos link status` shows which release
+each static publication serves.
+
+### 6.6 Caching for dynamic apps
+
+The edge page cache and asset cache skip forward rows today
+(`edge.go`, `!up.route.IsForward()`; `internal/edge/assetcatch.go`).
+For v1, linked dynamic apps keep that behaviour: every request goes home.
+Designer's call, because both caches take inputs (release manifests,
+asset declarations) that a linked app does not have on the serving side,
+and the freshness rules for those caches took several spec rounds to get
+right. Caching for linked dynamic apps, including serving a stale page
+while home is offline, is a follow-up design.
+
+### 6.7 Plans, caps and metering
+
+A publication counts as an app against the account's app cap. Its
+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
+
+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
+link; the serving console refuses an unknown client cleanly. Builder sets
+the floor.
+
+## 7. Delivery order
+
+Designer's call, following "something Paul can see lands first":
+
+1. **Link and dynamic publish.** Link credential, device-code approval,
+ link channels on the hub, publication records and routing, home-side
+ enforcement, offline page, the Linked deployments section, the CLI.
+ Witness: an app on a home box behind NAT is reachable at its public
+ URL from outside the tailnet, an unpublished app on the same box is
+ not, and pulling the box's network gives the offline page.
+2. **Static copies.** Upload on deploy, serving from the copy. Witness:
+ a static site published from home keeps serving with home switched
+ off.
+3. **Custom domains** on publications, if they do not fall out of slice
+ 1 through the existing alias pass.
+
+Caching for linked dynamic apps (§6.6) is a separate design after these.
+
+## 8. Left to the builder
+
+- 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).
+- 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).
+- CLI flag names beyond those shown, following the CLI registry's
+ conventions.
+
+## 9. Copy
+
+User-facing strings (CLI output and refusals, the approval page, the
+Linked deployments section, the offline page) go through copy review
+before they are written, per AGENTS.md. Neutral names only in examples.