carlos / platform Public

devbox mode design (#474): named HTTPS links on a shared workstation

Live links to loopback dev servers and static folder links, served by the
platform edge on the devbox's tailnet address with a wildcard-only DNS-01
certificate; a registrar socket assigns names by SO_PEERCRED uid.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev e54a6a028b03941738ee27650c69e774c6f74651 parent c24e7a0
1 file changed, +290 −0
  • docs/superpowers/specs/2026-10-30-devbox-mode-design.md +290 −0

CI passed — run details

Intent

Human

<task-notification> <task-id>a4538a1ecd952d618</task-id> <tool-use-id>toolu_01PBRACANfp9neWq9WuFbGXm</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/9b370a04-693c-4bda-b2eb-9a4b08f7626d/tasks/a4538a1ecd952d618.output</output-file> <status>completed</status> <summary>Agent "Map edge features for devbox design" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>All seven questions are answered below from code reading, nothing was run. Paths are relative to the worktree root. ## 1. Wildcard certs (internal/edge/wildcard.go) - **How a cert is obtained:** ACME DNS-01 against Let's Encrypt. The directory can be overridden with `CARLOS_ACME_DIRECTORY` (wildcard.go:57, :122). `obtain()` at :605-673 checks the zone, registers the account, orders `*.&lt;parent&gt;`, solves DNS-01 (:677-740) and stores the PEM. - **DNS provider:** the default is **DNSimple, not Route53**. `dnsProviderFromEnv` (dns.go:66-83) reads `CARLOS_DNS_PROVIDER`: `""`/`"dnsimple"` needs `CARLOS_DNSIMPLE_TOKEN`, and `"route53"` calls `newRoute53DNS`. The provider interface is a single `present(ctx, fqdn, value) (cleanup, err)` (dns.go:35-37). - **Route53 credentials:** `newRoute53DNS` (route53dns.go:84-95) uses `rootaws.LoadDefaultConfig`. For a non-root process that is the plain AWS SDK default chain (rootaws/config.go:37-42: "LoadDefaultConfig preserves the SDK chain for non-root callers"), so env vars, `~/.aws`, or an instance role. The region defaults to us-east-1. The calls it makes are `ListHostedZonesByName`, `ChangeResourceRecordSets` and `GetChange` (route53dns.go:54-62). It finds the zone by walking up the parent names. - **What turns it on:** `newWildcardFromEnv` (:786-924) returns nil unless `CARLOS_WILDCARD_DOMAINS` or `PLATFORM_APPS_DOMAIN` is set, and also nil if no DNS provider is configured (:858-861, logged as "wildcard certs off"). Optional extras: `CARLOS_ACME_DELEGATION_ZONE` (:866) and the steering host (:855-857). - **Which domains:** - Static parents come from `CARLOS_WILDCARD_DOMAINS`, a comma list. - Per-account parents `&lt;sqid&gt;.&lt;PLATFORM_APPS_DOMAIN&gt;` are derived from routes, but only when the label passes `domains.ValidSqid` (`parentsFor`, :203-229). - A wildcard covers exactly one label (`certFor`, :314-334). - For your case, `CARLOS_WILDCARD_DOMAINS=docs-t1.dev.&lt;domain&gt;` covers `x.docs-t1.dev.&lt;domain&gt;`, but not the apex and not deeper names. - **Cert cache:** the shared autocert cache. `--acme-cache` defaults to `$CARLOS_DATA_DIR/acme` (edge.go:3846). With `CARLOS_CERT_CACHE` unset or `dir` it is an `autocert.DirCache` (certcache.go:33-36). Keys are `wildcard-&lt;parent&gt;.pem` (:421-423) and `wildcard-account.key` (:744). - **Wildcard with no HTTP-01 fallback: not possible today.** - `wrapGetCertificate` (:929-942) always falls through to autocert's per-host path for names the wildcard does not cover, and also before the wildcard has been obtained ("nil sends the handshake to the per-host autocert path", :310-313). - Run always builds `autocert.Manager{HostPolicy: e.issuerHostPolicy()}` and always binds `:80` with `m.HTTPHandler` (edge.go:4019-4027, :4111, :4119-4140). There is no flag to turn either off. - The HostPolicy only allows hosts that are in the registry (certsync.go:204-215). On a private box, any routed host not yet covered by the wildcard (the window before first issuance, the apex, deeper names) would trigger HTTP-01/TLS-ALPN-01 orders that fail and use up Let's Encrypt's failed-validation allowance. ## 2. Static serving - **Source of files:** only a release store, through signed channel pointers. `staticSite.currentDir` (static.go:252-284) calls `release.Channel(ctx, store, pub, acct, app, channel)`, then `ensureExtracted` of `site.tar.gz` (:351+, the kind must be "static", :362), extracting into `&lt;cacheDir&gt;/&lt;acct&gt;/&lt;app&gt;/&lt;version&gt;@&lt;digest&gt;`. - **No arbitrary local folder:** there is no "serve this local directory" route kind. `staticHandlerFor` returns a 404 stub unless `staticStore` and `staticPub` are set and `rt.App != ""` (edge.go:700-712). - **Local-disk option:** `CARLOS_DEPLOYMENT_DIR` gives a `release.DirStore` (a store laid out like the bucket) instead of S3 (edge.go:4169-4199). The content must still be signed: you need `CARLOS_RELEASE_PUBKEY` on the edge, and the pointer must be signed with `CARLOS_RELEASE_KEY` (cli.go:2356). - **Minimum env:** `CARLOS_RELEASE_PUBKEY` plus either `CARLOS_DEPLOYMENT_BUCKET` or `CARLOS_DEPLOYMENT_DIR`. A missing one is silent, with no error (edge.go:4173-4175). The cache directory is `$CARLOS_DATA_DIR/static`. The `pointer-digests` ratchets live under `$CARLOS_DATA_DIR` and under `CARLOS_OPT_DIR`, which defaults to `/opt/carlos` (edge.go:4195; release/versions.go:37-42). - **Side effects of setting a store:** `e.staticStore != nil` switches on more than static serving: the geo mirror (edge.go:3895-3897), cert-issuance publishing and gating, the cert mirror, the home map, the door (:3978-4017), and cert warm (:4069). The store door is armed as well (`EnableStatic`, :524). - **"Temporary" sites exist, but they are a console/app lifecycle, not a local feature.** - Usage: `carlos deploy --temporary [--ttl]` (deploy.go:156-157). The TTL is 1h–30d with a default of 7d (temporary.go:47-54). - The app is created through `POST /api/cli/apps/{account}/new-temporary` (console/authcli.go:551-555). It is gated by `CARLOS_TEMPORARY_APPS=1` on the console (cmd/console/main.go:517). - Names use the reserved `tmp-` namespace (release/temporary.go:12-23). `carlos add` refuses such names (cli.go:1641-1646). - The console's expiry pass moves the app to the Trash, and it is purged 3 days later (`TemporaryCooloff`, release/temporary.go:27). - It is still a store-backed static release. The spec is docs/superpowers/specs/2026-09-25-temporary-static-sites-design.md. ## 3. Registry routes - **`Route` struct** (registry/registry.go:43+). Fields relevant here: - `Host`, `Slug`, `Kind` ("instance | service | static | sidecar", plus "status"), `Status` (must be ready-like to be served). - `Socket` ("unix socket upstream; wins over Addr when both set"), `Addr` ("TCP upstream host:port"), `Addrs` (comma-joined multi-upstream list), `Health`. - `App`, `Account` (via `ClaimOwnership`), `Channel`, `Region` (also "fleet/&lt;name&gt;"), `Tunnel`, `FleetBox`. - `Gate` (bcrypt hash, :226-235), `RateLimit`, `Platform`, `Provisioned`, `Hibernate`, `Backing`/`Unit`, `Caps`, `HoldOp`, `ImportGate`. - **Writers:** - `carlos add [--kind] [--addr host:port | --socket path] [--app] &lt;host&gt;` (cli.go:268-546). It builds the row with `Status: "ready"` (:465-470) and writes through `addWrite` → `r.UpsertUnlessRootfs` (cli.go:95-101; registry.go:1433, :1451). - `carlos remove` (cli.go:548) → `Delete` (registry.go:1211). - `carlos route --host … -tunnel/-hibernate/-grant/...` (cli.go:793+) uses narrow setters such as `SetTunnel` (:2775). - `SetGate` (:2637) has no CLI. It is called only from the provision reconcile pass (provision/reconcile.go:1963) and remote dispatch. - **Reload:** `Edge.Watch` (edge.go:2819+) polls `reg.Fingerprint()` every 2s. Fingerprint opens a fresh sqlite connection on `r.path` (registry.go:3815+), and any change triggers `Reload()` (edge.go:729). SIGHUP also reloads (:3911-3922). - **TCP 127.0.0.1:port works today.** - `DispatchArm` returns `ArmAddrs` when `len(rt.AddrList()) &gt; 0` and there is no tunnel, fleet or socket (fleetforward.go:144-165). - Reload builds `tcpProxy(addrs[0], e.hold)`, or `multiProxy` when there is a `Health` config (edge.go:961-990). - Validation (`provision.validAddr`, provision.go:757+) explicitly keeps loopback and RFC1918 allowed and refuses only link-local. - So `carlos add --addr 127.0.0.1:5173 --app x host` produces a served route. Pass `--kind service`: with the default `instance`, `carlos add` also fills in a default DB path, though the socket default is skipped when `--addr` is given. - **Who may write registry.db:** - `registry.Open` has **no ownership or permission checks**. It is just sqlite with WAL (registry.go:607-625), so file permissions are the only guard. - internal/host/registryowner.go only matters for root callers. When euid is 0, `openRegistryConverging` chowns the db, `-wal` and `-shm` to the `carlos` service user and opens the registry in a child process running as that user (:23-46, :59-92). When euid is not 0 it is a plain `registry.Open` (:24-26). - `registryOpenHintFor` (:142-195) only words the "readonly database" error. The service user is hard-coded as `carlos` (host/bootstrap.go:42). ## 4. Edge startup (`carlos edge` → `edge.Run`, main.go:69; edge.go:3842+) - **Flags:** - `--registry` (default `$CARLOS_DATA_DIR/registry.db`), `--acme-cache` (default `$CARLOS_DATA_DIR/acme`). - `--https` (default `:443`), `--http` (default `:80`, "ACME HTTP-01 challenge + redirect to https; in --dev mode, the only listener"). - `--fallback`, and `--dev`, which means plain HTTP on `--http`, no TLS and no ACME (:3933-3961). - **`CARLOS_DATA_DIR`** defaults to `/data` (:3843). - **`platformDomainsFromEnv`** (pending.go:161-171) is the union of `CARLOS_WILDCARD_DOMAINS` and `PLATFORM_APPS_DOMAIN`. It only arms the "pending" 503 page for unknown hosts under those domains (:3869). - **`:80` and ACME when only a wildcard is wanted:** outside `--dev`, both listeners are always bound (:4125-4133) and autocert is always the inner GetCertificate. - An empty flag means `:http`/`:https` (listeners.go:11-16), so there is no "off". - The only workaround is pointing `--http` at something harmless, such as `127.0.0.1:0` (`:0` is supported; listeners.go:29-37 prints the allocated port). - **What a non-root user cannot provide:** - **Binding :443 (and :80).** The production unit runs as `User=carlos` with `AmbientCapabilities=CAP_NET_BIND_SERVICE` (host/units/carlos-edge.service:28-33). Otherwise use a port of 1024 or above, or a sysctl / setcap workaround. - **Default paths:** `/data`, and `/opt/carlos/pointer-digests` when static is enabled. Both can be overridden with `CARLOS_DATA_DIR` and `CARLOS_OPT_DIR`. - Nothing else in `edge.Run` checks euid. Root-only pieces such as the instance-control socket and mounts belong to `carlos agent`, not `carlos edge`. ## 5. Peer-credential pattern - **instancectl** (internal/instancectl/peer_linux.go:22-40): - `peerCred` casts the conn to `*net.UnixConn`, calls `SyscallConn().Control`, then `unix.GetsockoptUcred(fd, SOL_SOCKET, SO_PEERCRED)`. - `productionPeerOK` (:47-68) looks up the `carlos` uid once at startup (fatal if missing) and returns a closure that runs `edgePeer.check(uid, pid)`. The rule is uid == carlos AND pid == the systemd MainPID of carlos-edge.service, with a cached and force-refreshed systemctl read (peer_edge.go). - The check runs inside a wrapping listener: `vettedListener.Accept` calls `ok(c)` and closes refused conns before net/http reads anything, with refusal logs rate-limited to one per second (server.go:315-394). The server disables keep-alives (one request per connection). - A hand-run fallback, `bindControlSocket`, binds the socket path, chowns it to carlos and sets mode 0600 (peer_linux.go). - **A simpler uid-only variant:** `dbreads.StdinConn` (internal/dbreads/worker_linux.go:54-80) checks SO_TYPE, the unix sockname, and SO_PEERCRED with `Pid != 0 &amp;&amp; Uid == want`. - **unixdial deliberately does not check credentials** (unixdial.go:25-27: "a listener systemd created and passed to a DynamicUser service reports root in SO_PEERCRED"). It checks the control-dir path and getpeername instead. - **To reuse it:** copy `peerCred`, the `vettedListener` and `PeerOK func(net.Conn) error`. The decision itself would be a per-uid allowlist, or "the uid owns the route being registered". ## 6. Per-route features for Addr routes (edge.go `ServeHTTP` from :1711) - **Password gate:** applies to any route whose `Gate` is set, Addr routes included, and before the upgrade branch (:2095-2101). There is no local CLI to set `Gate`, though: only provision reconcile and remote dispatch call `SetGate` (registry.go:2637). - **`_headers` (and `_redirects`):** static only. They are parsed from the extracted tree in `staticSite.loadHeaders` (static.go:313) and the format is described in headers.go:1-25. They do not apply to Addr routes. - **Compression:** applies to every non-upgrade response when `e.gzipOn` is on (`CARLOS_EDGE_GZIP` is the kill switch), including Addr routes (:2157-2172). HEAD requests and clients without gzip in Accept-Encoding are skipped (compress.go:196-201). - **WebSocket:** handled for every route kind. The `isUpgradeRequest` branch (:2103-2140) skips the cache and compression and goes to `up.proxy.ServeHTTP`. `tcpProxy` is an `httputil.ReverseProxy` (:2931-2960), which handles 101 upgrades. It sets the forwarding headers and keeps the original Host. - **Also on Addr routes:** - `p.ModifyResponse = e.responseModifier(t)` (:988). - The shared response cache for GET/HEAD (:2216). - Rate limiting. - Edgeguard: Addr routes get the full check, while static routes get only the hard tier at this point (:2058-2062). ## 7. Reverse tunnel (internal/edge/tunnel.go, internal/host/tunnel_client.go) The tunnel lets a box that accepts no inbound connections be served through a public edge. The remote host dials out to the edge's existing :443 on a reserved hostname (`CARLOS_TUNNEL_HOST`) and sends `GET /register` with `Authorization: Bearer &lt;token&gt;`, `Carlos-Tunnel-Name: &lt;name&gt;`, `Connection: Upgrade`, `Upgrade: carlos-tunnel/1`. It must pin ALPN to http/1.1 (tunnel.go:29-45). After a 101 the connection flips: the edge becomes an HTTP/2 client and the host an HTTP/2 server. Pings run every 15s, or every 5s for fleet channels (:46-68). Auth is a constant-time compare against static `CARLOS_TUNNEL_CLIENTS` entries of the form `name=token`; names must pass `ValidTunnelName` `[a-z0-9-]{1,32}` (edge.go:4226-4258). If that misses, it checks registry-backed fleet channels named `&lt;fleet&gt;/&lt;label&gt;` against sha256 token hashes (`VerifyDynamic`, tunnel.go:266-280). A token is bound to exactly one name. Routes use the channel through `Route.Tunnel` (`carlos route -tunnel &lt;name&gt;`), which wins over Socket/Addr. On the client side, `carlos agent` runs `tunnelLoop(e)` (host/agent.go:1026), and it only runs when all of `CARLOS_TUNNEL_URL`, `CARLOS_TUNNEL_TOKEN` and `CARLOS_TUNNEL_NAME` are set (tunnel_client.go:35-58). It serves the agent's own edge over the inverted connection, with backoff handled by internal/tunnelclient.</result> <usage><subagent_tokens>150141</subagent_tokens><tool_uses>48</tool_uses><duration_ms>278302</duration_ms></usage> </task-notification>

Attributed to this commit: 31.0 g CO₂e (3,483,589 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-devbox-mode, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/docs/superpowers/specs/2026-10-30-devbox-mode-design.md b/docs/superpowers/specs/2026-10-30-devbox-mode-design.md
new file mode 100644
index 000000000..3a6c86392
--- /dev/null
+++ b/docs/superpowers/specs/2026-10-30-devbox-mode-design.md
@@ -0,0 +1,290 @@
+# Devbox mode: named HTTPS links on a shared workstation
+
+Status: design, 2026-10-30. Discussion: amadan #474 (the first devbox's host
+and domain are recorded there; this document uses neutral names).
+
+## 1. Why
+
+Several people and their agents build features on one shared Linux
+workstation on the tailnet (the "devbox"). Each feature lives in its own git
+worktree and runs a live dev server on a loopback port. Before pushing, the
+author opens it in a browser over HTTPS to check the work, and sometimes
+sends the link to a colleague on the tailnet.
+
+Today the only way to get an HTTPS link is `tailscale serve`. That breaks down
+in four ways:
+
+- Tailscale allows one operator user per machine. Nobody else can publish a
+ link without `sudo`, and the machine rules forbid agents from using `sudo`.
+- Every link is the machine's one `ts.net` name on a different port, so every
+ link shares one cookie jar. Signing in to one app's admin on one link signs
+ you out of the others.
+- A port number says nothing about which feature is behind it.
+- There is no way to share a static mockup without creating a site in
+ production.
+
+## 2. What it is
+
+The devbox runs the platform edge as a service. Anyone with an account on the
+machine can publish a link at `https://<name>.devbox.example.com` (no port),
+reachable only from the tailnet, in one of two forms:
+
+1. **A live link**: `<name>` proxies to the publisher's dev server on
+ `127.0.0.1:<port>`. Live reload works, because the edge already passes
+ WebSocket upgrades through.
+2. **A folder link**: `<name>` serves a static folder (mockups, decks,
+ prototypes), with no app and nothing in production.
+
+## 3. Goals, non-goals, anti-goals
+
+Goals:
+
+- One command publishes a link, run by the user or their agent, with no
+ `sudo` and no help from anyone.
+- Each link is its own hostname, so cookies and sign-ins don't collide.
+- A link is owned by the account that published it. Nobody else can take
+ over, repoint or remove it.
+- Links last until their owner removes them.
+- A list shows every link, its owner, its age and whether it's answering.
+
+Non-goals:
+
+- Public sharing. Anything wider is deployed to the hosted platform as
+ usual, or uses an app's own tunnel.
+- Running deployed apps, instances, hibernation or anything else from the
+ box layer (`carlos agent`, instance-control, system apply).
+- Password gates. Being on the tailnet is the gate.
+- Automatic expiry (not in the first cut).
+
+Anti-goals (a failure even if it works):
+
+- Anything running as root after the one-time install, or any step that
+ needs `sudo` for day-to-day use.
+- Listening on anything but the devbox's private (tailnet) address. Never
+ `0.0.0.0`, never the office LAN.
+- Failed certificate orders against Let's Encrypt for names the box can
+ never validate (the box isn't publicly reachable).
+- One user able to repoint or remove another user's link.
+- A live link serving stale content from the edge's response cache.
+
+## 4. Decided
+
+Paul's rulings in conversation, 2026-10-30. They are fixed for this design:
+
+- **URLs carry no port.** The edge listens on 443 on the devbox's tailnet
+ address. A one-time root install that grants the bind capability is
+ acceptable; nothing runs as root after it.
+- **Names come from a wildcard DNS name we own**, `*.<devbox>.dev.<platform
+ domain>`, pointing at the devbox's tailnet address. Not Tailscale Services
+ (each service needs admin approval, publishing still goes through the one
+ Tailscale operator, and every service name lands in public certificate
+ transparency logs). Discussion #474 has the reasoning.
+- **Audience is the tailnet only**: mostly authors checking their own work,
+ sometimes a colleague.
+- **Both live dev servers and static folders are in scope.**
+- **This is a platform feature**, built on the existing edge, not a script on
+ one box.
+
+## 5. Shape
+
+### 5.1 The devbox service
+
+One systemd system unit runs `carlos devbox serve` as a dedicated
+unprivileged service user, with `AmbientCapabilities=CAP_NET_BIND_SERVICE`
+(the same pattern as `internal/host/units/carlos-edge.service:28-33`). The
+process holds two things:
+
+- **The edge**, from `edge.Run`'s building blocks, listening on
+ `<tailnet-ip>:443` only. Its data directory is the service user's, not
+ `/data` (`CARLOS_DATA_DIR`, and `CARLOS_OPT_DIR` if static serving needs
+ it).
+- **The registrar** (§5.3), which owns the route registry. The registry file
+ is private to the service user.
+
+Installing the unit, creating the service user and placing the DNS
+credential are the only root steps. A person with root does them once, from
+a runbook. Agents never run them.
+
+### 5.2 Certificates: wildcard only
+
+The edge already obtains wildcard certificates by DNS-01
+(`internal/edge/wildcard.go`, enabled by `CARLOS_WILDCARD_DOMAINS`, Route53
+via `CARLOS_DNS_PROVIDER=route53`, `internal/edge/route53dns.go`). What it
+can't do today is run with **only** the wildcard. Outside `--dev`, `edge.Run`
+always binds `:80` and always falls through to autocert's per-host issuance
+for any name the wildcard doesn't cover, including every name before the
+wildcard first arrives (`wildcard.go:929-942`, `edge.go:4019-4140`).
+
+Devbox mode needs a wildcard-only setting:
+
+- no `:80` listener;
+- no per-host autocert path. A name the wildcard doesn't cover, or a
+ handshake before the wildcard exists, fails the TLS handshake instead of
+ placing an order.
+
+The DNS credential covers only the devbox's challenge record. An IAM policy
+allows `route53:ChangeResourceRecordSets` on the one hosted zone, limited by
+`route53:ChangeResourceRecordSetsNormalizedRecordNames` to
+`_acme-challenge.<devbox>.dev.<platform domain>` and by record type to TXT. It
+also allows the read calls `wildcard.go` makes: `ListHostedZonesByName` and
+`GetChange`. The devbox isn't a cloud instance, so the credential is a static
+key in the unit's environment file, readable only by the service user.
+
+DNS is one record, made once by hand: `*.<devbox>.dev.<platform domain>`, an
+A record to the devbox's tailnet IPv4 address.
+
+### 5.3 The registrar: who may publish what
+
+The registrar listens on a Unix socket that any local account can connect
+to. It identifies each caller by `SO_PEERCRED` uid, reusing the pattern in
+`internal/instancectl/peer_linux.go` (`peerCred` plus a vetting listener),
+and acts on that uid alone. Nothing the client sends can claim another
+identity.
+
+- **Ownership.** The registrar keeps an owner record for each name, holding
+ the uid and username, kept beside the registry rather than in it. Only the
+ owner can repoint or remove a name. A name that is free goes to whoever
+ publishes it first.
+- **Names** are one DNS label (`[a-z0-9-]`, 1-63 characters, no leading or
+ trailing hyphen), because the wildcard covers exactly one label.
+- **Routes** are written into the edge's registry with the existing writers
+ (the path `carlos add` takes to `UpsertUnlessRootfs`). The edge's
+ two-second fingerprint watcher picks them up, so there's no new reload
+ path.
+- **Agent accounts** (separate Unix users that run agents) are users like any
+ other. Their links belong to them.
+
+### 5.4 Live links
+
+A live link is an `Addr` route to `127.0.0.1:<port>`. The registrar refuses
+any address that isn't loopback. This already works in the edge today:
+`carlos add --kind service --addr 127.0.0.1:<port> <host>` gives a served
+route (`fleetforward.go:144-165`, `edge.go:961-990`), and WebSocket upgrades
+and `Host` pass through (`edge.go:2103-2140`).
+
+What must change for devbox routes:
+
+- **No shared response cache.** Live content must never be cached
+ (`edge.go:2216`).
+- **No rate limiting or edgeguard blocking** that a single developer
+ reloading hard could trip.
+
+The `Host` header reaching the dev server is the link's own name. Dev
+servers with a host allowlist (Vite's `server.allowedHosts`, Rails'
+`config.hosts`) need the devbox domain added once per project. Live reload
+clients must connect on 443 (Vite: `hmr.clientPort`). This goes in the user
+docs.
+
+Loopback ports are shared by every account on the machine, so a name's owner
+controls where the name points but not who is listening on that port. That's
+acceptable on a machine whose users trust each other. The docs say so.
+
+### 5.5 Folder links
+
+The service user can't read users' home directories, which are mode 0700 on
+the devbox. So the client reads the folder, as the user, and streams it to
+the registrar as an archive. The registrar stores a snapshot in the service
+user's own space and serves it. Re-running the command replaces the
+snapshot. **My call:** a snapshot, not a live view of the folder. An optional
+watch mode that re-sends on change is the builder's call, and can be cut.
+
+There are two ways to serve the snapshot. The builder picks after reading
+the code:
+
+- **(a) Reuse the release pipeline.** Write the snapshot as a static release
+ into a `release.DirStore` (`CARLOS_DEPLOYMENT_DIR`), signed by a key only
+ the service holds, and serve it through `staticSite`. This gets
+ `_headers`, `_redirects` and the existing file serving unchanged. The
+ catch: setting a static store also turns on the geo mirror, cert mirror,
+ home map, the door and cert warm (`edge.go:3895-4069`). Each must be
+ provably inert or off in devbox mode.
+- **(b) A local-directory static source**: a route that serves a directory
+ the registrar owns, reusing `staticSite`'s file serving and `_headers`
+ parsing but not its store, signing or extraction.
+
+Prefer (a) if turning off the side effects is one clean switch, and (b)
+otherwise. Either way, folder links keep `_headers` behaviour, so a mockup
+behaves as it would once deployed.
+
+A size cap per snapshot (my call: 200 MB) and a total cap for the spool
+protect the machine's disk.
+
+### 5.6 The command
+
+`carlos devbox` gets these verbs. The names are provisional and the copy
+goes through copy review in the plan.
+
+- `share <name> --port <n>` publishes a live link.
+- `share <name> --dir <path>` publishes a folder link.
+- `unshare <name>` removes the caller's own link.
+- `list` shows every link: name, owner, kind, target, age, and whether a
+ live link's port is answering (a TCP connect at list time; nothing polls
+ in the background).
+- `serve` is what the unit runs. Nobody types it by hand.
+
+`<name>` defaults to the current git branch, folded into a valid label
+(**my call**). Output is the full `https://` URL on its own line, so an
+agent can hand it over as is.
+
+### 5.7 Agent sandboxes
+
+On the first devbox, Claude Code's command sandbox runs each command in its
+own network namespace and refuses to create Unix sockets. Checked on
+2026-10-30: from inside the sandbox, a connection to a host loopback port
+failed, and creating an `AF_UNIX` socket returned EPERM. So:
+
+- a dev server started inside the sandbox listens on the sandbox's own
+ loopback, which the edge can't see;
+- `carlos devbox share` can't reach the registrar socket from inside the
+ sandbox.
+
+That's already true of today's `tailscale serve` flow. Agents start dev
+servers and publish links as unsandboxed commands. The design keeps that and
+doesn't try to tunnel through the sandbox. The user docs and the
+`share` error say so: on a connection refused from inside a sandbox, name the
+sandbox as the likely cause.
+
+## 6. Boundaries and budgets
+
+- **Provider boundary.** Nothing here is Tailscale-specific in code: the edge
+ binds a configured private address. DNS-01 uses the existing provider
+ interface (`internal/edge/dns.go`). AWS appears only as the Route53 DNS
+ provider for the first devbox.
+- **Request budget.** No S3 requests. Folder snapshots are local
+ (`DirStore` or a directory). Route53 calls happen only at certificate
+ issuance and renewal: a few calls every 60 or so days.
+- **Census.** The devbox unit runs no root code after install, and adds no
+ readers of production storage.
+
+## 7. Outside this repo
+
+- After the first devbox is live, the app repos that document
+ `tailscale serve` review links switch their docs and review-link skills to
+ `carlos devbox share`. Their per-person shared admin token workaround
+ becomes optional, since each link has its own cookies.
+- The stopgap port block on the first devbox (#474) is removed once devbox
+ links work.
+
+## 8. Left to the builder
+
+- Option (a) or (b) in §5.5, by the rule given there.
+- How the registrar and edge share a process, and the owner store's format.
+- The wire protocol on the registrar socket (HTTP over the Unix socket, like
+ instance-control, is the obvious fit).
+- How `list` shows a link whose owner's account is gone.
+- The runbook for the one-time install, written alongside the unit.
+
+## 9. Done when
+
+On the first devbox, an unprivileged user, and separately an agent account,
+can each:
+
+1. run a dev server on `127.0.0.1:<port>`, publish it, open
+ `https://<name>.<devbox>…` from another tailnet device, and see an edit
+ appear through live reload;
+2. publish a folder and see it with its `_headers` applied;
+3. fail to repoint or remove the other's link;
+
+and `list` shows both links with their owners. No order is ever placed for a
+name the wildcard doesn't cover, and nothing listens on any address but the
+tailnet one.