| 1 | # Places slice 1: Neary's goes live |
| 2 | |
| 3 | Spec: `docs/superpowers/specs/2026-11-26-places-config.md` (rev 3, Paul's |
| 4 | rulings, the 2026-11-26 carlos correction). Branch `places-slice-1` from |
| 5 | `design-places` 9bca9254 with main 7c113ac8 merged. Nothing here touches |
| 6 | CARLOS, consoles, temporary sites or the Assistant. |
| 7 | |
| 8 | Finish line: Paul, an owner, asks the coordinator to publish Neary's |
| 9 | (`amadan.net/paulca/nearys`, main c069eae7, merged by task tkzmnycab3ml). |
| 10 | `publish_site` raises a place card; he taps "Carloku, account paulca"; the |
| 11 | publish card names the app and place; he taps Publish; docs-t1 deploys with |
| 12 | his login, creates the app, mints its edge-only deploy credential, the |
| 13 | marker answers, and the task shows the confirmed address. |
| 14 | |
| 15 | ## Facts the plan rests on (carlos v0.43.3, read-only) |
| 16 | |
| 17 | - `carlos accounts list --console <o>` prints a `NAME SQID ROLE` table. |
| 18 | - `deploy`, `apps list` and `services create` take `--account-id <sqid>` |
| 19 | (sqid alphabet `abcdefghjkmnpqrstuvwxyz`, 3 to 16) and `--console`. |
| 20 | - With `CARLOS_SERVICE_TOKEN` set, carlos uses only that token and the |
| 21 | console from `--console`/`CARLOS_CONSOLE`; no credentials file is read. |
| 22 | - `services create` has no `--json`: it prints `minted service:<acct>/<name> |
| 23 | (role deploy, app <app>, rungs edge)` and one ` CARLOS_SERVICE_TOKEN=<t>` |
| 24 | line. The runner parses both, never logs the output. |
| 25 | - The credentials file is JSON `{credentials:[{console, expires_at, ...}]}`; |
| 26 | the runner decodes only `console` and `expires_at`. |
| 27 | |
| 28 | ## Protocol 34 (`wire.ProtocolPlaces`; 31 at planning, main took 31 to 33) |
| 29 | |
| 30 | - `Capabilities.Reach`: `Logins` [{console, accounts [{name, sqid}]}] (owner |
| 31 | rows only; at most 8 consoles, 20 accounts each) = "can set up"; |
| 32 | `Keys` [{console, sqid, app}] (deploy credentials held, at most 50) = |
| 33 | "can publish". `ToolHealth.Carlos` (ok, outdated, missing) and |
| 34 | `ToolHealth.CarlosVersion` (`vX.Y.Z`). All validated, no secrets; dropped |
| 35 | from hello below 31 (held and resent, as tool health is). |
| 36 | - `PublishDispatch` gains `Console`, `Account` (sqid), `AccountName`, |
| 37 | `Place`, `PlaceRevision`, `BindingRevision`, `Destination` |
| 38 | (`wire.SiteDestination`: sha256 of a versioned console/sqid/name/app |
| 39 | line). Encode refuses every publish dispatch below 31: an older runner |
| 40 | would deploy to the old constant account. |
| 41 | - `LeaseCheck.Destination` on the publish check; `PublishResult.Created` |
| 42 | and `PublishResult.Key` {name, fingerprint} on the done report. Dropped |
| 43 | below 31. |
| 44 | - Tools `places`, `propose_place`, `publish_site`, `site_status`; Encode |
| 45 | refuses their calls below 31 and the runner answers them locally |
| 46 | (`placesRefused`, as `stuckRefused`). |
| 47 | - Card kind `place` with `Card.Place` {kind, project, candidates [{id, |
| 48 | console, console_label, account}]}; options are candidate ids plus |
| 49 | `not_now`. Native sends unknown kinds to the web (unchanged). |
| 50 | |
| 51 | ## Tasks (each tests first, mutation-checked, own commit) |
| 52 | |
| 53 | 1. **Wire.** Protocol 31 constants and downgrades above; validation bounds; |
| 54 | `SiteDestination`; existing protocol assertions move to 31. Tests: |
| 55 | round trips, refusals below 31, bounds. |
| 56 | 2. **Storage.** Migration 0112: `chat_places` (id, kind, adapter, console, |
| 57 | account_sqid, account_name, state, revision, proposed_by, proposed_at, |
| 58 | confirmed_by, confirmed_at, created/updated; unique live kind+adapter+ |
| 59 | console+sqid) and `chat_project_places` (id, project_id, kind, place_id, |
| 60 | app, revision, app_created_at, key_name, key_fingerprint, key_runner, |
| 61 | key_minted_by, key_minted_at; unique project+kind); `chat_cards.place`. |
| 62 | Models, schema, migration check. Team records, never `scope.Owned`. |
| 63 | 3. **Candidates and the place card (instance).** Candidates come only from |
| 64 | the creator's primary's stored `Reach.Logins`: id `pc_` + 12 hex of |
| 65 | sha256(console, sqid). Fixed rank: flagship (`https://console.carloku.com`) |
| 66 | account named like the repository namespace; else the only owned |
| 67 | account; then the rest, flagship first, then by console and name; at |
| 68 | most six. (`.carlos/config` hints wait for slice 3.) Console labels are |
| 69 | code's (Carloku, Tito, else the host). `propose_place` (owner only; |
| 70 | kind `site`; project; candidate id from `places`) raises the card to the |
| 71 | caller with that candidate first; refused when the project already has a |
| 72 | site binding or an open place card. The answer (card person, owner now, |
| 73 | open, revision; choice one of the stored ids, its stored hash equal to a |
| 74 | recomputed one, still in the primary's current logins) creates or reuses |
| 75 | the confirmed place and binds the project with the app from |
| 76 | `projectSite` (mint once, stored in `site_app` too). Nothing goes to |
| 77 | CARLOS. Audit `place.proposed`, `place.confirmed`, `place.declined`. |
| 78 | If the card names a task still eligible, the publish card follows. |
| 79 | 4. **Publish through the place (instance).** `primarySites` becomes |
| 80 | `siteMode(person, binding)`: primary at 31 with carlos ok; "publish" when |
| 81 | `Reach.Keys` holds console+sqid+app; "setup" when `Reach.Logins` has an |
| 82 | owner login on console+sqid; else a fixed missing reason. `offerPublish` |
| 83 | no longer returns silently: no binding raises the place card (owner) or |
| 84 | says why in the task's lane; no mode says what is missing, once per |
| 85 | merged commit. The publish card question names app, console label and |
| 86 | account; setup adds one line that this first publish creates the app and |
| 87 | its deploy key with the owner's CARLOS login. `answerPublish` stores on |
| 88 | the step place id, both revisions and the destination hash; the dispatch |
| 89 | carries them. `publishRefusal` also refuses when the place is not |
| 90 | confirmed, a revision moved, the hash differs from the step's, or the |
| 91 | check's `Destination` differs. `acceptPublishDone` records `Created` and |
| 92 | the key's name, fingerprint and runner on the binding, audited (no |
| 93 | secret). `publish_site` (task, target `site` only): creator and owner, |
| 94 | task done and merged, Review approved the merged candidate with a site |
| 95 | config, nothing publishing and no open card; proposes a place first when |
| 96 | none; else raises the publish card for an older merged task. |
| 97 | `places` and `site_status` (read-only, quoted data): bindings, places, |
| 98 | app, address and outcome of the newest publish, key holder, the |
| 99 | primary's mode and carlos health, candidates when unbound. |
| 100 | `status` reports `runner.tools.carlos` and its version. |
| 101 | 5. **Runner reach and the carlos guard.** One carlos lookup |
| 102 | (`EQUIPO_CARLOS_PATH`, else PATH, else `~/.local/bin`). The capability |
| 103 | probe runs `carlos version` (5 s), then, when the credentials file passes |
| 104 | the existing file checks, decodes console origins and runs `accounts |
| 105 | list --console <o>` per live console (20 s each, owner rows, validated), |
| 106 | and lists its key files. Preview and publish refuse `carlos_outdated` |
| 107 | before building when the version is unreadable or below v0.43.0. |
| 108 | `EQUIPO_SITE_HOST` and the oficina/Carloku constants go; `Sites` is |
| 109 | never sent. |
| 110 | 6. **Runner publish.** The dispatch's console, sqid, name and app must |
| 111 | validate and hash to its `Destination`. A held key for the app must |
| 112 | match console and sqid (else `publish_key_mismatch`); its deploy runs |
| 113 | `deploy --kind static --account-id <sqid> --console <o> --app <app> |
| 114 | --channel edge ...` with `CARLOS_SERVICE_TOKEN` and `CARLOS_CONSOLE` in |
| 115 | the environment and `CARLOS_CREDENTIALS` naming an absent file. With no |
| 116 | key, setup needs a current owner login there: the taken check (unless |
| 117 | the runner's own record owns it), the same deploy with the login, then |
| 118 | `services create --role deploy --app <app> --rungs edge --account-id |
| 119 | <sqid> --console <o> eq-<slug>-<4>` once the deploy succeeded; the token |
| 120 | goes 0600 to `<state>/site/keys/<app>.json` (dir 0700, outside sandbox |
| 121 | mounts), its fingerprint is sha256's first 16 hex. A failed mint leaves |
| 122 | the site published and reports no key. The trusted scan (`scanPreview`) |
| 123 | runs on the export before the built report: findings refuse |
| 124 | `publish_secrets`, an unavailable scanner `publish_scanner`. The check |
| 125 | sends the destination hash. Published exports carry no Equipo |
| 126 | `_headers`; a project's own `_headers` stays and is scanned with the |
| 127 | rest. |
| 128 | 7. **Coordinator surface.** MCP tool schemas and descriptions, the Claude |
| 129 | allowlist, `provider.ConverseTools`, `MutationKinds`/`WriteTools`/ |
| 130 | `madeCodes` for the two writers, the opening's website sentence (call |
| 131 | `publish_site`; only the person's tap publishes) and `houseRule`. |
| 132 | 8. **Places page.** Settings, read-only, state first: one line per bound |
| 133 | project (app, place, address, checked when), pending proposals, else an |
| 134 | empty line. Owners and members read it; nothing writes. |
| 135 | 9. **End to end.** A thintest contract: protocol 31 primary with a login on |
| 136 | Carloku account paulca, a merged Neary's website task, `publish_site`, |
| 137 | place card, confirm, publish card, Publish, dispatch fields, check with |
| 138 | destination, done with Created and Key, task shows the URL; then a |
| 139 | second publish uses mode publish. Refusals: member tap, stale revision, |
| 140 | place changed after the tap, wrong destination, runner at 30, carlos |
| 141 | outdated, unbound offer says why. Runner tests with a fake carlos: |
| 142 | argv and environment exactly, no token in logs or reports, key file |
| 143 | mode, mismatch refusal, scan refusal. |
| 144 | |
| 145 | ## Astra round 1 fixes (binding; they override the tasks above) |
| 146 | |
| 147 | 1. **The card is the snapshot.** Raising a publish card stores on it |
| 148 | (`chat_cards.place`, publish snapshot JSON) the merged commit, place id |
| 149 | and revision, binding id and revision, console, sqid, name, app, mode |
| 150 | and destination hash. The tap recomputes all of it in its transaction |
| 151 | and refuses (card conflict, card re-raised) when anything moved; the |
| 152 | step copies the snapshot. `publishBuilt`, `acceptPublishDone` and |
| 153 | `settlePublish` carry the snapshot through (`publishRecord` embeds |
| 154 | `wire.PublishResult` plus the snapshot). Tests change place, binding |
| 155 | and login before the tap and after it. |
| 156 | 2. **No weaker check, ever.** Below 31 Encode refuses a `site_publish` |
| 157 | lease check outright (not dropped), and `Link.ConfirmPublish` refuses |
| 158 | locally below 31. `authorizePublish`, `fencePublishes`, `previewHeld`'s |
| 159 | publish side and every `ProtocolPublish` gate on the publish path move |
| 160 | to `ProtocolPlaces`. A queued publish on a runner that reconnects below |
| 161 | 31 is fenced. Tests: reconnect at 30 with a queued step, an instance at |
| 162 | 30 (the runner's check refused locally). |
| 163 | 3. **The owner's login only creates or mints.** Modes: `setup` only while |
| 164 | the binding has no `app_created_at` (the app was never created by a |
| 165 | publish); `publish` only with a held deploy key for exactly that |
| 166 | console, sqid and app; `mint` (new) when the app was created but no |
| 167 | key is held: the runner uses the owner login only for `services create`, |
| 168 | then deploys with the new key. A created app is never deployed with the |
| 169 | login again. The runner's site record becomes destination-bound |
| 170 | (`<state>/site/<console>/<sqid>/<app>.json`): the taken check is skipped |
| 171 | only for an app this runner created at that exact destination. |
| 172 | 4. **Mint durability.** Before `services create` the runner records a mint |
| 173 | intent (name, destination) in the step's phase `site_minting`; the secret |
| 174 | is written to a temp file 0600 and renamed into place; only then is the |
| 175 | key reported. A lost response, a crash before persistence or a refusal |
| 176 | reports `PublishResult.MintLost` (the name) and no key; the instance |
| 177 | records `deploy_lost` on the binding and the Places page says a deploy |
| 178 | key of that name may be live on CARLOS without Equipo holding it. |
| 179 | Restart in `site_minting` never runs the mint again: it reports the |
| 180 | stored key if the file exists, else `MintLost`. A new mint needs a new |
| 181 | tap (mode `mint`, new name). |
| 182 | 5. **Capability is rechecked at dispatch and at the final check.** The |
| 183 | dispatch builder calls `siteMode` and fails the step |
| 184 | (`publish_not_ready`) when the primary, its protocol, carlos health or |
| 185 | the mode's capability changed; `publishRefusal` does the same right |
| 186 | before the deploy. The runner runs the taken check before the final |
| 187 | check, then nothing slow between the check and the deploy. |
| 188 | 6. **Migration copies `site_app`.** 0112 inserts one `chat_project_places` |
| 189 | row (kind site, place '' , app = `site_app`, revision 1, no |
| 190 | `app_created_at`) for every project with a `site_app`; an unplaced |
| 191 | binding confirms nothing and grants nothing. Confirming a place fills |
| 192 | its `place_id` and bumps its revision. Test: rows before 0112 (no app, |
| 193 | an app) migrate as described. |
| 194 | 7. **Strict list parser.** The site path's taken check parses `apps list` |
| 195 | output strictly: a `using ...` line, then either `no apps in this |
| 196 | account` or app lines (with or without the `APP STATE` header, with or |
| 197 | without the region column); anything else, a non-zero exit or a clipped |
| 198 | output counts as taken. Fixtures for each. |
| 199 | 8. **Project headers.** As corrected in task 6. |
| 200 | 9. **`site_status` contract (narrow).** It reports what Equipo recorded: |
| 201 | the binding, place, app, the newest publish's outcome, address and when, |
| 202 | the key's holder and fingerprint (or that it is missing or lost), and the |
| 203 | primary's mode. It does not read the live edge version or domains |
| 204 | (slice 3, P7), and says so in its description. |
| 205 | |
| 206 | ## Astra round 2 fixes (binding; they override everything above) |
| 207 | |
| 208 | 1. **Each use of the login is authorised right before it runs.** The tap |
| 209 | fixes the mode (`setup`, `mint` or `publish`) and, for setup and mint, |
| 210 | the key's name (`eq-<slug>-<4 random>`, minted by code at the tap); |
| 211 | both are in the card snapshot, the step and the dispatch |
| 212 | (`PublishDispatch.Mode`, `DeployName`). The runner never changes mode: |
| 213 | a publish whose key is gone fails `publish_key_missing`. Two final |
| 214 | checks, both destination-bound and refused below 31: `site_publish` |
| 215 | right before every deploy, and `site_mint` (new purpose) right before |
| 216 | `services create`. Each rechecks the creator is an owner, the primary, |
| 217 | the place and binding revisions and the mode. The card says what the |
| 218 | tap does: setup creates the app and a deploy key with the owner's |
| 219 | login; mint creates a deploy key with it. |
| 220 | 2. **Creation is recorded by the authority, pessimistically.** The |
| 221 | instance sets the binding's `app_created_at` when it allows a setup |
| 222 | step's `site_publish` check: from then on the app may exist, so setup |
| 223 | is never offered again, whatever any report says. With no key held the |
| 224 | mode is `mint`. In mint mode the runner first lists the account |
| 225 | (read-only, strict parser); if the app is definitely absent it fails |
| 226 | `publish_app_missing` without minting, and only that reason clears |
| 227 | `app_created_at` (the next card is a setup card again, a new tap). |
| 228 | If the app is listed, it mints, then deploys with the new key. |
| 229 | 3. **The recovery route.** When a setup or mint publish ends with no key |
| 230 | held (seen in the primary's reach), `publishEnded` raises a mint-mode |
| 231 | publish card for the same merged commit. `publishing()` lets exactly |
| 232 | that through: a mint-mode card is allowed after a done publish of the |
| 233 | commit while the binding has no held key. `publish_site` can raise it |
| 234 | too. A mint publish redeploys the same export with the new key, which |
| 235 | is how the key is shown to work. Tested end to end: setup, mint lost, |
| 236 | mint card, tap, key held, then a plain publish. |
| 237 | 4. **Key evidence lives in the runner's hello, not in reports.** |
| 238 | `PublishResult` gains nothing. `ReachDeploy` carries the key's name |
| 239 | and fingerprint and `Lost` (a mint whose answer was lost or |
| 240 | unreadable, or a crash between asking and storing: the runner records |
| 241 | the intent in its state before asking and keeps it until it holds the |
| 242 | key). Every hello repeats them, so an instance rollback loses nothing. |
| 243 | The binding stores the name, the runner, who minted it and when, set |
| 244 | at the allowed `site_mint` check; fingerprint, held and lost are read |
| 245 | from the primary's current reach. Restart in `site_minting` never asks |
| 246 | again: it reports the stored key, or the name as lost. |
| 247 | 5. **Migrated bindings.** A binding with no place (from `site_app`) |
| 248 | accepts a place proposal; confirming fills `place_id`, keeps the app, |
| 249 | bumps the revision and leaves `app_created_at` empty, so its first |
| 250 | publish is a setup at the new destination, behind the strict taken |
| 251 | check. Runner site records are destination-bound; a legacy |
| 252 | app-only record grants nothing, so an app published by the old |
| 253 | oficina path is "taken" if that account is chosen (adoption is out of |
| 254 | v1). Fixtures: no app, minted-unpublished app, previously published |
| 255 | app. |
| 256 | |
| 257 | ## Astra round 3 fixes (made in the build; round limit reached) |
| 258 | |
| 259 | 1. **Attempted is not created.** `app_created_at` (with |
| 260 | `app_created_step`) means "creation was attempted": setup is never |
| 261 | offered again, and nothing is adopted. A mint needs destination-bound |
| 262 | evidence that this runner created the app: its own site record at |
| 263 | `<state>/site/<console>/<sqid>/<app>.json`, written only after its setup |
| 264 | deploy command succeeded. A listing proves existence only. No record and |
| 265 | the app listed: `publish_app_unproven`, nothing minted or deployed. App |
| 266 | definitely absent: `publish_app_missing`, which alone clears the |
| 267 | attempt (the next card is setup, a new tap). Tests: setup authorised then |
| 268 | a crash before deploy; another actor creates the app; the mint refuses. |
| 269 | 2. **Checks are per phase of the approved attempt.** The step's mode never |
| 270 | changes; each check asks what that phase needs. Setup: start and |
| 271 | `site_publish` need no attempt recorded and the login (the allowed |
| 272 | `site_publish` records the attempt with this step's id); `site_mint` |
| 273 | needs the attempt to be this step's and the login. Mint: start and |
| 274 | `site_mint` need an attempt, no held key and the login (the allowed |
| 275 | `site_mint` records `deploy_step` = this step); `site_publish` needs |
| 276 | `deploy_step` to be this step, whatever the reach says by then. |
| 277 | Publish: every check needs the held key. Each check also rechecks the |
| 278 | creator is an owner, the primary at 31 with carlos ok, the place and |
| 279 | binding at their snapped revisions and the destination hash. Tests |
| 280 | include a hello arriving between mint and deploy. |
| 281 | |
| 282 | ## Build notes (deviations, all deliberate) |
| 283 | |
| 284 | - The deploy names the place with explicit flags (`--account-id`, |
| 285 | `--console`) and `CARLOS_CONFIG` names an empty config of the runner's |
| 286 | own, as today, rather than a config holding the destination: no file a |
| 287 | repository or person wrote is read either way. |
| 288 | - The runner writes its destination-bound creation record right after the |
| 289 | setup's final check and before its deploy (the name having just been |
| 290 | found free), so a deploy that failed half way can still get its key by a |
| 291 | mint. The window is the accepted list and deploy race. |
| 292 | - Repository `.carlos/config` hints, team defaults and Change, Undo and |
| 293 | Retire wait for slice 3; candidates rank by namespace and the only owned |
| 294 | account only. `publish_site` takes a task (not a project and commit). |
| 295 | - `EQUIPO_SITE_HOST` and the `Sites` hello flag are gone: a runner at 31 |
| 296 | reports reach instead, and a publish needs 31. The site host now probes |
| 297 | whenever carlos and a state directory exist; without a valid login it |
| 298 | still publishes with held keys and sets up none. |
| 299 | - Approved copy that says Carloku (`chat.publish_unconfirmed`, |
| 300 | `chat.publish_taken`, `work.reason.publish_failed`) is unchanged; it reads |
| 301 | right for Neary's and every Carloku place. |
| 302 | - Native clients show place cards on the web (they route unknown kinds |
| 303 | there already); no Swift change. |
| 304 | |
| 305 | ## Astra branch review |
| 306 | |
| 307 | Round 1 NOT READY (1 blocker, 4 major), fixed in 6a71f098. Round 2 NOT |
| 308 | READY (4 major), fixed in 8fa19e4a. Round 3 NOT READY (1 major: an |
| 309 | interrupted recovery whose key was stored could never be asked again); |
| 310 | the round limit reached, it is fixed after the review (a publish is |
| 311 | blocked only by one that went live) with its contract test, and not |
| 312 | re-reviewed. |
| 313 | |
| 314 | ## Copy |
| 315 | |
| 316 | New strings (card question and setup line, place card, offer reasons, |
| 317 | activity lines, task reasons `carlos_outdated`, `publish_secrets`, |
| 318 | `publish_scanner`, `publish_key_mismatch`, Places page) go to |
| 319 | `/home/paulca/.cache/places-1-copy.json` as copy-review entries and into |
| 320 | `copy.go` marked pending with `scripts/copy-status.py pending`. The |
| 321 | pending-copy gate stays red until Paul reviews them. |
| 322 | |
| 323 | ## Verification and handoff |
| 324 | |
| 325 | Targeted `go test -run` per package while building; then `make ci` once. |
| 326 | Mutation checks recorded in each commit body. Astra reviews this plan and |
| 327 | the whole branch (max three rounds each). Push `places-slice-1`; no merge, |
| 328 | release or deploy. |
| 329 | |
| 330 | ## After release (Paul) |
| 331 | |
| 332 | Upgrade production, then in Equipo: "Publish Neary's". Tap "Carloku, |
| 333 | account paulca", then Publish. The task shows the address. |
| 334 | |