| 1 | # Release slice: preview deploys |
| 2 | |
| 3 | Status: 2026-11-11, revision 2. Drafted by Claude (Opus 5.5) on |
| 4 | `release-preview` from main 2096af3. This slice of |
| 5 | `2026-11-11-equipo-release.md` runs ahead of the others, at Paul's |
| 6 | request: "Can we unblock it from being able to get me mockups and deploy |
| 7 | them / the app?" |
| 8 | |
| 9 | Revision 1 (3bc1909) drew NOT READY from Astra in its one round. The |
| 10 | findings are in `CODEX-FINDINGS-RELEASE-PREVIEW.md`; revision 2 takes |
| 11 | every one, marked **(astra N)**, mostly by cutting scope. |
| 12 | |
| 13 | The main cut is that v1 builds nothing. A preview is the committed files |
| 14 | of one output directory, read from git objects. Running a build command |
| 15 | moves to v2, with the release plan's prefetch. |
| 16 | |
| 17 | ## 0. Why, and the finish line |
| 18 | |
| 19 | Engineering can build clickable mockups on a task branch, but Paul has |
| 20 | no way to see them. A preview is a Carloku **temporary static site**: a |
| 21 | public `tmp-<name>.<region>.oncarlos.com` that moves to the Trash after 7 |
| 22 | days. It gets the platform host only, and an account holds at most 20 |
| 23 | (carlos/platform `docs/superpowers/specs/2026-09-25-temporary-static-sites-design.md`). |
| 24 | |
| 25 | **Finish line:** |
| 26 | - An approved candidate whose `release/preview.json` names an output |
| 27 | directory is published to `tmp-<task id>`. |
| 28 | - The task card says "Preview: <link> (expires in 7 days)". |
| 29 | - A newer approved candidate replaces the preview in place. |
| 30 | - Demo: the barber mockups task (`tk5fen4uajpn`, paulca/threatmin) once |
| 31 | Paul retries it. |
| 32 | |
| 33 | A preview is never called shipped, deployed or live. |
| 34 | |
| 35 | ## 1. Rules |
| 36 | |
| 37 | 1. **Approved candidates only.** Equipo schedules a preview once per |
| 38 | candidate, only after Review approves it, and only when Review's |
| 39 | report says the candidate has `release/preview.json` |
| 40 | (`has_preview`). |
| 41 | - `has_preview` is scheduling evidence, not authority **(astra 3)**: |
| 42 | the preview step reads the config again from the candidate. |
| 43 | - **Why approval, not "Paul asked":** a preview is published to the |
| 44 | open internet under Paul's account. Approval means a second model |
| 45 | has read the change and its config first. |
| 46 | - The coordinator cannot trigger a preview. |
| 47 | - A person's Preview button for an unapproved candidate is v2 (§6). |
| 48 | 2. **Config.** `release/preview.json` holds `{"output": "<dir>"}`. It is |
| 49 | read from git objects, at most 4 KiB, decoded strictly. |
| 50 | - `output` is a clean relative path that is not `.git`, and none of |
| 51 | its parts start with `.`. |
| 52 | - Any other field, `build` included, refuses the preview in v1 |
| 53 | **(astra 4, cut)**. |
| 54 | 3. **Export from git objects, never the working tree (astra 4).** |
| 55 | - The runner fetches the candidate into a private git directory, as |
| 56 | checks do, and lists `git ls-tree -r -l <candidate> -- <output>`. |
| 57 | - Only regular blobs (modes 100644 and 100755) are taken. A symlink |
| 58 | (120000), a submodule, any path with a part starting with `.` |
| 59 | (`.carlos/` included) and the reserved `equipo-preview.json` all |
| 60 | refuse the preview. |
| 61 | - Caps: at most 2,000 files, 10 MiB each and 50 MiB in total, all |
| 62 | checked against the listing before any read. |
| 63 | - Each blob is written with `git cat-file blob`, its size checked |
| 64 | while copying, to a fresh file in a new 0700 staging directory |
| 65 | under the runner's state, outside every workspace and namespace. |
| 66 | No repository code runs. |
| 67 | - The digest is the SHA-256 of the sorted lines `<path> <sha256>`. |
| 68 | The marker `equipo-preview.json` (task, full candidate, step, |
| 69 | attempt, digest) is written after it and is not part of it. |
| 70 | - Every `carlos` command runs with its working directory in a fresh, |
| 71 | empty directory. |
| 72 | 4. **Steps and authority (astra 3, 8).** The preview step runs on the |
| 73 | primary. |
| 74 | - **Start:** the start authorization (`LeaseCheck`) for a preview step |
| 75 | holds only for the current attempt, not withdrawn, of a task not |
| 76 | cancelled, whose newest candidate is the step's, approved, and |
| 77 | whose creator is still an owner. |
| 78 | - **Built:** after export the runner reports `preview{phase: built, |
| 79 | digest, files, bytes}` and the instance records the digest. This |
| 80 | report must arrive before publishing: the publish check below |
| 81 | requires the recorded digest. |
| 82 | - **Publish:** before each mutation, the runner sends a `LeaseCheck` |
| 83 | with purpose `preview_publish` and the digest (a new field). The |
| 84 | instance's `authorizePreview` repeats the start conditions, and |
| 85 | requires the digest to equal the recorded one. It writes an audit |
| 86 | row. |
| 87 | - Below protocol 9 the runner never sends a preview check, so it is |
| 88 | never downgraded into an ordinary lease. The instance places |
| 89 | previews only on a primary at 9. |
| 90 | - **The commitment point is the promote.** A refusal before it ends |
| 91 | the step `cancelled`, and nothing of this candidate is served. A |
| 92 | refusal after it cannot unpublish, and the step says so. |
| 93 | 5. **Mutations: one at a time, fixed templates (astra 1, 2, 6).** Every |
| 94 | command runs with `CARLOS_SERVICE_TOKEN` in the environment and the |
| 95 | account and console from the credential file. Each mutation is |
| 96 | preceded by its own publish check, and its intent is written to the |
| 97 | runner's step state first. |
| 98 | |
| 99 | | Phase | Command | |
| 100 | |---|---| |
| 101 | | read state | `carlos apps list`: the `tmp-<task>` line is missing, live with an expiry, live with no expiry (kept), or trashed. Anything unparseable is unknown and ends the step | |
| 102 | | create (missing) | `carlos deploy --temporary --ttl 7d --app <task> --kind static --version p0-<step7> --no-prompt <placeholder dir>`. It creates the app, mints its host and serves a runner-written placeholder page, never repository content. Its watch probes only that page, which has no `_redirects` | |
| 103 | | renew (live) | `carlos apps ttl --app tmp-<task> 7d`, before any content changes. The platform's printed expiry is recorded | |
| 104 | | ship | `carlos ship --app tmp-<task> --kind static --version p-<step7>-<attempt> --no-prompt <staging dir>`. Serves nothing | |
| 105 | | promote | `carlos promote --app tmp-<task> --no-prompt p-<step7>-<attempt> <channel>`. The channel is read from `carlos channels` | |
| 106 | |
| 107 | - **Refused states:** kept, trashed or unknown. Trashed ends |
| 108 | `preview_expired`, and the step does not invent another name. |
| 109 | - **Refusals and their reasons:** a create refused at the cap is |
| 110 | `preview_cap`. Carloku's create budget is 50 attempts per principal, |
| 111 | counted in memory **(astra 9)**. A refused create is reported, never |
| 112 | retried. |
| 113 | - **Never run:** delete, keep, domains, gate, assets, env and secrets. |
| 114 | - **Never on another app:** no command touches any app but |
| 115 | `tmp-<task>`. |
| 116 | - **Versions:** each includes the preview step's id, and the record |
| 117 | keeps the full candidate **(astra 7)**. |
| 118 | 6. **Verified, without following anything (astra 2).** After the promote, |
| 119 | the runner fetches `https://tmp-<task>.<domain>/equipo-preview.json`. |
| 120 | - The request refuses redirects, sends no credential, is capped at |
| 121 | 64 KiB and retries for at most 2 minutes. |
| 122 | - It needs HTTP 200, the task, the full candidate, the step, the |
| 123 | attempt and the digest. |
| 124 | - Then the step is done (`deployed`), with the URL and the platform's |
| 125 | expiry. |
| 126 | - Otherwise it is done with the outcome `unconfirmed` **(astra 5)**, |
| 127 | and it is never retried. |
| 128 | 7. **Restarts (astra 5).** |
| 129 | - A preview step that stopped before its first mutation fails |
| 130 | `runner_restarted`, as today. |
| 131 | - One stopped after a mutation intent was written runs again in a |
| 132 | reconcile phase. That phase rebuilds nothing and sends nothing: it |
| 133 | fetches the marker (rule 6), and ends `deployed` or |
| 134 | `unconfirmed`. |
| 135 | - **Rolling a runner back below 8:** the instance stops placing |
| 136 | previews, every preview step settles, and the outbox drains first. |
| 137 | 8. **Ancillary (astra 7).** Preview steps never drive a task: the |
| 138 | progress Equipo computes skips them. A failed preview leaves the task |
| 139 | where it was, with no Needs you. |
| 140 | 9. **Audit and spend.** |
| 141 | - Audit rows for every check (`preview.authorize`, allowed or |
| 142 | refused) and outcome (`preview.deployed`, `preview.unconfirmed`, |
| 143 | `preview.failed`), with the task, step, candidate, app and digest, |
| 144 | and no credential. |
| 145 | - A preview runs no model, so it spends no tokens. The step records |
| 146 | its wall time and bytes. A first preview uses one of the |
| 147 | principal's temporary create attempts. |
| 148 | |
| 149 | 10. **Round 2 fixes** (Astra round 2 on 5885855, findings in |
| 150 | `CODEX-FINDINGS-RELEASE-PREVIEW-R2.md`). |
| 151 | - **No replacement after a start.** A preview attempt that started is |
| 152 | never replaced. Withdrawn, or its runner removed, it ends done and |
| 153 | "could not be confirmed" once its export was recorded as built |
| 154 | (it may have published), and cancelled before that. |
| 155 | - **A withdrawn attempt keeps its report.** A withdrawn attempt's |
| 156 | own done report is kept as it says. |
| 157 | - **Cancelled previews reconcile.** After a restart, a preview that |
| 158 | may have published reconciles from the marker even when cancelled. |
| 159 | - **The credential file is refused unless all of these hold:** |
| 160 | - it is a regular file, not a link (lstat, then `O_NOFOLLOW`); |
| 161 | - its mode is exactly 0600 and the runner's user owns it; |
| 162 | - it is outside every directory a sandbox mounts (the workspace, |
| 163 | scratch, step git directories, the Go root and the module |
| 164 | cache); |
| 165 | - its JSON decodes as expected. |
| 166 | |
| 167 | Every error is a fixed sentence, never content or keys. The path |
| 168 | is one of the protected paths. |
| 169 | - **An empty account is a listing.** `carlos apps list` printing "no |
| 170 | apps in this account" counts as an empty list. |
| 171 | |
| 172 | ## 2. States and the card |
| 173 | |
| 174 | - **The timeline:** "Prepared 12 files (340 KiB)." once built, then |
| 175 | "Preview ready" with the link. An unconfirmed outcome reads "Preview |
| 176 | could not be confirmed". A failure reads as any stopped step does, with its reason. |
| 177 | - **The task card:** the newest `deployed` preview whose expiry is still |
| 178 | ahead gives "Preview: <link> (expires in 7 days)". |
| 179 | |
| 180 | ## 3. Wire |
| 181 | |
| 182 | **Protocol 9,** `wire.ProtocolPreview`, adds (8 went to the empty-repository merge, `wire.ProtocolEmptyMerge`, on main first): |
| 183 | - `StepReport.has_preview` (Review); |
| 184 | - `StepReport.preview` (`{phase, app, url, version, digest, files, |
| 185 | bytes, expires_at, outcome}`); |
| 186 | - `LeaseCheck.digest`; |
| 187 | - the `preview` specialist and the `preview_publish` purpose. |
| 188 | |
| 189 | **Downgrade:** |
| 190 | - `Encode` drops the fields below 8. |
| 191 | - A preview dispatch is never encoded below 8: `Encode` refuses it with |
| 192 | `ErrProtocol`. |
| 193 | - **The fence (astra 8):** when a primary connects below 8, its queued |
| 194 | and running preview steps settle `cancelled` with `runner_outdated` |
| 195 | (`fenceOldRunner`'s pattern), and their pending dispatch commands are |
| 196 | retired. |
| 197 | |
| 198 | ## 4. Permissions |
| 199 | |
| 200 | | What | Who holds it | Paul's action | |
| 201 | |---|---|---| |
| 202 | | A Carloku credential that can create, update and ttl temporary apps | the primary runner, from a 0600 file (`EQUIPO_PREVIEW_CREDENTIAL_PATH`) never mounted into a namespace | **C6, carlos/platform#935**, asks for a `temporary` role. Until then, see below | |
| 203 | | The runner setting | Paul | one `EQUIPO_PREVIEW_CREDENTIAL_PATH` line in the staging runner's `service.env` | |
| 204 | |
| 205 | **Until C6:** |
| 206 | - **The account:** a Carloku account used only for previews. |
| 207 | - **The credential:** `carlos services create --role publish --account |
| 208 | <previews account> equipo-previews`. |
| 209 | - **The file:** the token, console, account and the account's platform |
| 210 | domain (for example `bds.oncarlos.com`). |
| 211 | |
| 212 | This credential is broad: it could also create permanent apps or keep |
| 213 | one **(astra 1)**. The executor's templates are the only limit, and the |
| 214 | dedicated account bounds what it can reach. A `deploy` credential cannot |
| 215 | create apps (`authcli.go:598`), so it cannot serve here. |
| 216 | |
| 217 | ## 5. Tests, failing first |
| 218 | |
| 219 | - **wire:** the downgrade below 8, strict at 7, and a preview dispatch |
| 220 | refused below 8. |
| 221 | - **runner:** |
| 222 | - **config:** strict decoding, unknown fields, bad paths; |
| 223 | - **export:** symlink, submodule and dot paths, the reserved name, the |
| 224 | caps, the digest, and the marker kept out of it; |
| 225 | - **executor:** the exact argv of each phase, the token only in the |
| 226 | environment, the working directory, each state of `apps list`, a |
| 227 | publish check refused before each mutation; |
| 228 | - **verification:** a match, a mismatch, and a redirect refused; |
| 229 | - **reconcile:** after a restart. |
| 230 | - **thintest:** |
| 231 | - an approval with `has_preview` schedules one preview, and only one |
| 232 | per candidate; without either, none; |
| 233 | - a newer approved candidate schedules another; |
| 234 | - each start and publish condition, one at a time; |
| 235 | - the digest is bound; |
| 236 | - a preview never sets Needs you or moves the stage; |
| 237 | - the card line and the timeline; |
| 238 | - the audit rows; |
| 239 | - the fence for a protocol 7 primary. |
| 240 | - **Mutations:** each authority condition, each export guard, the |
| 241 | allowlist, the verification checks and the ancillary rule are broken |
| 242 | once, and each test is seen to fail. |
| 243 | |
| 244 | ## 6. Out of scope, v2 |
| 245 | |
| 246 | - Build commands, which need the release plan's prefetch and contained |
| 247 | build. |
| 248 | - A person's Preview button. |
| 249 | - A second name after an expired preview. |
| 250 | - Deleting a preview when its task ends; it expires on its own. |
| 251 | |
| 252 | ## 7. Copy (Astra's delegated verdicts applied, two passes) |
| 253 | |
| 254 | | Key | Text | |
| 255 | |---|---| |
| 256 | | `work.specialist.preview` | Preview | |
| 257 | | `work.tl.preview_built` | Prepared %d files (%s). | |
| 258 | | `work.tl.preview_ready` | Preview ready | |
| 259 | | `work.tl.preview_unconfirmed` | Preview could not be confirmed | |
| 260 | | `work.card.preview` | Preview: %s (expires in %s) | |
| 261 | | `work.reason.preview_cap` | the account already has 20 previews | |
| 262 | | `work.reason.preview_expired` | this task's preview expired and its name is still taken | |
| 263 | | `work.reason.preview_config` | this version cannot use release/preview.json | |
| 264 | | `work.reason.preview_too_large` | the preview exceeds 2,000 files, 10 MiB per file or 50 MiB in total | |
| 265 | | `work.reason.preview_state` | Equipo could not read the preview's state | |
| 266 | | `work.reason.runner_outdated` | the runner needs an update for previews | |
| 267 | | `work.card.preview_open` | Preview: %s | |
| 268 | | `work.preview.in_days` / `in_day` / `today` | %d days / 1 day / less than a day | |
| 269 | | `work.reason.preview_failed` | a Carloku command for the preview failed | |
| 270 | |