oficina / equipo Public

spec: release preview deploys (rev 1, for Astra)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 3bc1909e06c879d2ed71827849dad8f4002ae1f8 parent 2096af3
1 file changed, +210 −0
  • docs/superpowers/specs/2026-11-11-equipo-release-preview.md +210 −0

CI failed — run details

diff --git a/docs/superpowers/specs/2026-11-11-equipo-release-preview.md b/docs/superpowers/specs/2026-11-11-equipo-release-preview.md
new file mode 100644
index 00000000..dde592ab
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-11-equipo-release-preview.md
@@ -0,0 +1,210 @@
+# Release slice: preview deploys
+
+Status: 2026-11-11, revision 1, for Astra review. Drafted by Claude (Opus
+5.5) on `release-preview` from main 2096af3. This slice of
+`2026-11-11-equipo-release.md` runs ahead of the others, at Paul's
+request: "Can we unblock it from being able to get me mockups and deploy
+them / the app?" Not implemented.
+
+## 0. Why, and the finish line
+
+Engineering can build clickable mockups on a task branch, but Paul has
+no way to see them. A preview is a Carloku **temporary static site**
+(`tmp-*.oncarlos.com`, carlos/platform
+`docs/superpowers/specs/2026-09-25-temporary-static-sites-design.md`):
+public, self-expiring after 7 days, platform host only, at most 20 live
+per account.
+
+**Finish line:**
+- An approved candidate of a task whose branch has `release/preview.json`
+ is built in the checks sandbox and published to `tmp-<task id>`.
+- The task card says "Preview: <link> (expires in 7 days)", and each
+ newer approved candidate replaces it in place.
+- Demo: the barber mockups task (`tk5fen4uajpn`, paulca/threatmin), once
+ Paul retries it.
+
+A preview is never called shipped, deployed or live. It is a preview.
+
+## 1. Rules
+
+1. **What can be previewed: an approved candidate only.** Equipo
+ schedules a preview only after Review approves a candidate, and only
+ when Engineering reported that the candidate has a valid
+ `release/preview.json`.
+ - **Why approval, not "Paul asked":** a preview is published to the
+ open internet under Paul's account. Approval means a second model
+ has read the change, including its preview config, before anything
+ is built or published.
+ - **No coordinator trigger:** the coordinator cannot ask for a
+ preview, because its words are never authority (merge authority's
+ rule).
+ - **v2, "Paul asked":** a person-only Preview button on an unapproved
+ candidate. It needs a control and copy of its own, so it is moved
+ to v2 (§6).
+2. **Config.** `release/preview.json` holds `{"output": "<dir>",
+ "build": ["argv", ...] | null}`.
+ - `output` is a clean relative path inside the repository.
+ - `build` is optional, at most 16 arguments, and absent for plain
+ HTML mockups.
+ - The runner reads the file from the candidate's tree, at most 4 KiB,
+ decoded strictly. A file that is invalid means no preview, and the
+ Engineering report says so.
+3. **Build, contained.** When `build` is set, it runs in the checks
+ containment (`provider.BuildCheckPolicy`): no network, no provider
+ home, no credentials, and the read-only Go root and module cache that
+ checks get. The tree is the candidate's, in a fresh workspace. A
+ build that fails or times out (10 minutes) ends the step `failed`
+ with its output tail. No network means a Node build that downloads
+ packages cannot run here. Plain files and offline builds work.
+4. **What crosses out.** Only the output directory crosses out, read
+ through `os.OpenRoot` (no path leaves the tree):
+ - regular files only; symlinks, devices and other special files are
+ refused;
+ - at most 2,000 files, 10 MiB each and 50 MiB in total;
+ - the files are copied to a runner-owned staging directory outside
+ every namespace.
+
+ The runner adds `equipo-preview.json`, holding the task, candidate,
+ tree digest and attempt. The tree digest is the SHA-256 of the
+ sorted lines `<path> <sha256>`. The digest and counts go in the
+ record.
+5. **Deploy: fixed commands, from the runner, outside the sandbox.** The
+ credential file (`EQUIPO_PREVIEW_CREDENTIAL_PATH`, 0600) holds the
+ Carloku service token, the console, the account and the account's
+ platform domain. No preview is offered without it. The commands are
+ built from these templates only, with `CARLOS_SERVICE_TOKEN` in the
+ environment:
+ - **First preview of the task:** `carlos deploy --temporary --ttl 7d
+ --app <task id> --account <a> --console <c> --kind static
+ --version <cand7>-<attempt> --no-prompt <staging dir>`. This
+ creates `tmp-<task id>`.
+ - **Later previews:** `carlos deploy --app tmp-<task id> --account <a>
+ --console <c> --kind static --version <cand7>-<attempt> --no-prompt
+ <staging dir>`, then `carlos apps ttl --app tmp-<task id> --account
+ <a> --console <c> 7d`.
+
+ Anything else is refused by the executor, before it runs. That
+ includes delete, keep, domains, gate, assets, env, secrets and any
+ app outside `tmp-<task id>`. A temporary app has no gate, so the
+ deploy watch never asks for a gate pass.
+6. **Verified, not assumed.** After the deploy, the runner fetches
+ `https://tmp-<task id>.<domain>/equipo-preview.json` for up to 2
+ minutes and requires its digest and attempt. Only then does the step
+ report `deployed`, with the URL and an expiry 7 days from the ttl
+ call. If the fetch never matches, the step ends `failed`
+ (`preview_unconfirmed`), with no retry.
+7. **One preview per task, replaced in place.** The app name is
+ `tmp-<task id>`.
+ - A newer approved candidate redeploys the same app and resets its
+ expiry, so a task never holds two previews.
+ - If the app has expired and sits in the Trash (3 days), the next
+ preview is refused as name taken, and the step ends `failed`
+ (`preview_expired`). v1 does not invent a second name.
+ - If the account holds 20 live temporary apps, the step ends `failed`
+ (`preview_cap`), and nothing is evicted.
+8. **Authority before each mutation.** Before each `carlos` mutation,
+ the runner sends a `LeaseCheck` with purpose `preview`. The
+ instance's `authorizePreview` decides it in the write transaction and
+ writes one audit row. It holds only when all of these are true:
+ - the step is the current attempt and not withdrawn;
+ - the task is not cancelled;
+ - the candidate is still the task's newest candidate, with Review's
+ `approve` on it;
+ - the task's creator is still an owner on the roster;
+ - this attempt's tree digest is the one the step reported after the
+ build.
+
+ A refusal ends the step `cancelled`, and nothing is published.
+9. **Audit and spend.**
+ - Every authorization, deploy result and refusal is an audit row
+ (`preview.authorize`, `preview.deployed`, `preview.failed`), with
+ the task, step, candidate, app and digest, and no credential.
+ - A preview runs no model, so its spend is no tokens. The step
+ records its wall time and bytes, and each first preview uses one of
+ the account's 50 temporary creates a day.
+
+## 2. States and the card
+
+- **The step:** a new specialist, `preview`, runs on the primary. On the
+ timeline it shows "Built" once the output crossed out, with files,
+ size and digest, then "Preview deployed" with the link once verified.
+ Failures read "Preview not deployed: <reason>".
+- **The task card:** it gains a line from the newest deployed preview,
+ "Preview: [tmp-….oncarlos.com](https://…) (expires in 7 days)", with
+ the days counted down. An expired preview's line is dropped.
+- **Wording:** no line says shipped, deployed to production or live.
+
+## 3. Wire and versions
+
+- **Protocol 8,** `wire.ProtocolPreview`, adds:
+ - `StepReport.has_preview` (Engineering);
+ - `StepReport.preview` (`{app, url, version, digest, files, bytes,
+ expires_at, phase}`, where phase is `built` or `deployed`);
+ - the `preview` specialist and lease purpose.
+- **Downgrade:** `Encode` drops both fields below 8.
+- **Scheduling:** the instance schedules a preview only on a primary at
+ 8, and confirms it at every lease. A primary that reconnects lower
+ while one is queued has it settled `cancelled`, with reason
+ `runner_outdated`, at that connection, so the queue never holds a
+ dispatch it cannot send.
+- **Runner rollback:** a runner rolled back below 8 must first deliver
+ its outbox, the rule from slice 1.
+
+## 4. Permissions
+
+| What | Who holds it | Paul's action |
+|---|---|---|
+| Carloku credential that can create, update, ttl and read temporary apps | the primary runner, a 0600 file, never mounted into a namespace | **C6, carlos/platform#935:** a `temporary` role limited to exactly that. Until then: a dedicated Carloku account for previews, holding no other app, and an account-scoped `publish` service credential in it, used only through the executor's templates |
+| `EQUIPO_PREVIEW_CREDENTIAL_PATH` on the runner unit | Paul | one env line on the staging runner unit |
+
+The `deploy` role cannot create apps (temporary creates need `publish`,
+`authcli.go:598`), so it cannot serve here. The dedicated account is the
+blast-radius limit until C6 lands.
+
+## 5. Tests, failing first
+
+- **wire:** the downgrade below 8, decoded strictly at 7.
+- **runner:**
+ - the config: strict decoding, its bounds, and bad paths;
+ - the export: symlinks, special files, counts and sizes, the digest,
+ no path leaving the tree;
+ - the build in containment, with a fake;
+ - the executor: the exact argv for a first and a later preview, every
+ other verb refused, the token only in the environment;
+ - verification, both match and mismatch;
+ - a lease refusal before each mutation;
+ - cap, expired and failed deploys.
+- **thintest contracts:**
+ - approve with `has_preview` schedules a preview; without it, or
+ without approval, nothing is scheduled;
+ - a newer approved candidate replaces it;
+ - `authorizePreview`, each condition on its own;
+ - the card line and the timeline states;
+ - the audit rows;
+ - a protocol 7 primary gets no preview.
+- **Mutations:** each rule 8 condition, the export bounds, the allowlist
+ and the verification are broken once, and each test is seen to fail.
+
+## 6. Out of scope, and v2
+
+- A person's Preview button for an unapproved candidate.
+- Builds that need the network (Node installs, for example): they need
+ the release plan's prefetch slice.
+- A second name after an expired preview.
+- Deleting a preview when its task ends: it expires on its own.
+- Previews of binary apps.
+
+## 7. Copy (for delegated review)
+
+| Key | Text |
+|---|---|
+| `work.specialist.preview` | Preview |
+| `work.tl.preview_built` | Built %d files (%s). |
+| `work.tl.preview_deployed` | Preview deployed |
+| `work.card.preview` | Preview: %s (expires in %s) |
+| `work.reason.preview_cap` | the account already holds 20 previews |
+| `work.reason.preview_expired` | this task's preview expired and its name is still taken |
+| `work.reason.preview_unconfirmed` | the preview did not answer with this build |
+| `work.reason.preview_build` | the preview build failed |
+| `work.reason.preview_too_large` | the preview is larger than 50 MiB or 2,000 files |
+| `work.reason.runner_outdated` | the runner is too old for previews |