# Preview hosts: Equipo pairs with a CARLOS preview host

Status: 2026-11-12, fast lane, built on `release-preview-devbox` from main
a0d22a0, with a self-review instead of an Astra round. It builds on the
preview slice (`2026-11-11-equipo-release-preview.md`) and reuses its
export: committed static files read from git objects, never a build.

## What it is

Equipo is designed to pair with a CARLOS preview host. A preview host is
an adapter behind one interface (`previewHost` in
`internal/runner/thin/preview_devbox.go`): where an approved candidate's
export is published, under which name, and where its marker is fetched.
Two adapters exist, and others can be added:

| Host | Name | Reach | Ends |
|---|---|---|---|
| CARLOS devbox | `eq-<task>` | the tailnet only | `carlos devbox unshare` when the task ends |
| Carloku temporary sites | `tmp-<task>` | public | expires after 7 days |

Devbox wins when a runner has both.

## Pairing is explicit, and visible

- **Opting in:** a runner pairs with devbox only when its configuration
  says `EQUIPO_PREVIEW_HOST=devbox` and its carlos (`EQUIPO_CARLOS_PATH`,
  else `PATH`, else `~/.local/bin`) answers `carlos devbox list`.
  - `scripts/staging-thin.py` sets this for the owner's staging runner
    (not the suite's), so the barber task needs nothing from Paul.
  - Carloku temporary sites pair as before, through the credential file.
- **The hello:** the runner reports the host in its hello
  (`Capabilities.PreviewHost {kind, domain}`, protocol 11; below it only
  the previews flag stays, and the first hello carries neither). The
  devbox domain is learnt from the first share's link, saved, and sent in
  the next hello.
- **Settings → Machines:** the page gains a Previews section. It names the
  machine that hosts previews ("Previews: docs-t1 (on your tailnet)"),
  online first, devbox first. With none paired, it explains how to pair
  one.
- **An exploration's card with nothing paired:** it says "Pair a preview
  host to open previews in your browser." It links to that section and
  still to the branch.

## A devbox preview

1. **Prepare:** export and report built, as before.
2. **Authorize:** one publish check for this export's digest, right before
   the command.
3. **Record:** the phase (publishing) and the intent are recorded.
4. **Share:** `carlos devbox share --dir <the export> eq-<task>`, the one
   share template. Sharing again under the same name replaces the copy in
   place for a newer approved candidate.
5. **Confirm:** the link devbox prints (exactly `https://eq-<task>.<domain>`)
   is confirmed by fetching the marker, with no redirect followed and the
   exact task, candidate, step, attempt and digest.
6. **Clean up:** devbox serves its own copy, so the export goes, except
   the marker that a restart's reconcile reads.
7. **The card:** it says "Preview: <link> (on your tailnet)", with no
   expiry, and the line leaves once the task ends.
8. **The task ends:** done, dropped or cancelled, the instance's
   ForgetTask runs `carlos devbox unshare eq-<task>`, but only for a link
   this runner recorded sharing.
   - A link that is already gone counts as gone.
   - Any other failure keeps the record for the next end.

**Access:** tailnet-wide, with no `--allow`. Equipo does not know a task
creator's tailnet login, and this is what Paul's own shares do.

**Commands** run from the runner process, outside every namespace: devbox
needs AF_UNIX to reach its registrar. They come from fixed templates
only: `list`, `share --dir <absolute export> eq-<task>` and
`unshare eq-<task>`. Each runs from an empty private directory, with a
private HOME and no credential. Repository content is never run.

## Self-review

- **Authority:** a share is preceded by the instance's publish check,
  bound to the digest. Unshare has no separate check: it only removes
  exposure, and it runs on the instance's own ForgetTask for that task,
  for a link this runner recorded.
- **What the instance accepts:**
  - a devbox result only as `eq-<task>`, at `https://eq-<task>.<domain>/`;
  - a hello's preview host only with previews on, a known kind and a
    clean domain.
- **Wire:**
  - protocol 11 adds one optional, validated capability field;
  - below 11, `Encode` drops it and the flag stays;
  - the first hello drops both;
  - mixed versions: an old instance sees only the flag, and an old runner
    sends no host, so Machines shows none.
- **Known limits:**
  - only the primary runs previews;
  - a folded task is no ending (Undo restores it), so its devbox link
    stays up, though its card line goes;
  - a runner that lost its state can't unshare an old link, which then
    stays until someone unshares it by hand;
  - the devbox domain is unknown until the first share, so the first
    hello says the host without its domain.
- **Copy:** Astra's delegated pass. Its replacements were taken, except
  the Previews lede, which keeps "Equipo is designed to pair with a CARLOS
  preview host", as Paul asked.
- **Tests and mutations:**
  - a fake `carlos devbox` covers share, replace in place, the marker,
    the learnt domain, unshare (gone, failed, repeated), the allowlist,
    explicit pairing and the fallback;
  - contracts cover the Machines line, the tailnet card that goes when the
    task ends, and the pairing link;
  - each guard was broken once and its test seen to fail.
