# Places slice 1: Neary's goes live

Spec: `docs/superpowers/specs/2026-11-26-places-config.md` (rev 3, Paul's
rulings, the 2026-11-26 carlos correction). Branch `places-slice-1` from
`design-places` 9bca9254 with main 7c113ac8 merged. Nothing here touches
CARLOS, consoles, temporary sites or the Assistant.

Finish line: Paul, an owner, asks the coordinator to publish Neary's
(`amadan.net/paulca/nearys`, main c069eae7, merged by task tkzmnycab3ml).
`publish_site` raises a place card; he taps "Carloku, account paulca"; the
publish card names the app and place; he taps Publish; docs-t1 deploys with
his login, creates the app, mints its edge-only deploy credential, the
marker answers, and the task shows the confirmed address.

## Facts the plan rests on (carlos v0.43.3, read-only)

- `carlos accounts list --console <o>` prints a `NAME SQID ROLE` table.
- `deploy`, `apps list` and `services create` take `--account-id <sqid>`
  (sqid alphabet `abcdefghjkmnpqrstuvwxyz`, 3 to 16) and `--console`.
- With `CARLOS_SERVICE_TOKEN` set, carlos uses only that token and the
  console from `--console`/`CARLOS_CONSOLE`; no credentials file is read.
- `services create` has no `--json`: it prints `minted service:<acct>/<name>
  (role deploy, app <app>, rungs edge)` and one `  CARLOS_SERVICE_TOKEN=<t>`
  line. The runner parses both, never logs the output.
- The credentials file is JSON `{credentials:[{console, expires_at, ...}]}`;
  the runner decodes only `console` and `expires_at`.

## Protocol 34 (`wire.ProtocolPlaces`; 31 at planning, main took 31 to 33)

- `Capabilities.Reach`: `Logins` [{console, accounts [{name, sqid}]}] (owner
  rows only; at most 8 consoles, 20 accounts each) = "can set up";
  `Keys` [{console, sqid, app}] (deploy credentials held, at most 50) =
  "can publish". `ToolHealth.Carlos` (ok, outdated, missing) and
  `ToolHealth.CarlosVersion` (`vX.Y.Z`). All validated, no secrets; dropped
  from hello below 31 (held and resent, as tool health is).
- `PublishDispatch` gains `Console`, `Account` (sqid), `AccountName`,
  `Place`, `PlaceRevision`, `BindingRevision`, `Destination`
  (`wire.SiteDestination`: sha256 of a versioned console/sqid/name/app
  line). Encode refuses every publish dispatch below 31: an older runner
  would deploy to the old constant account.
- `LeaseCheck.Destination` on the publish check; `PublishResult.Created`
  and `PublishResult.Key` {name, fingerprint} on the done report. Dropped
  below 31.
- Tools `places`, `propose_place`, `publish_site`, `site_status`; Encode
  refuses their calls below 31 and the runner answers them locally
  (`placesRefused`, as `stuckRefused`).
- Card kind `place` with `Card.Place` {kind, project, candidates [{id,
  console, console_label, account}]}; options are candidate ids plus
  `not_now`. Native sends unknown kinds to the web (unchanged).

## Tasks (each tests first, mutation-checked, own commit)

1. **Wire.** Protocol 31 constants and downgrades above; validation bounds;
   `SiteDestination`; existing protocol assertions move to 31. Tests:
   round trips, refusals below 31, bounds.
2. **Storage.** Migration 0112: `chat_places` (id, kind, adapter, console,
   account_sqid, account_name, state, revision, proposed_by, proposed_at,
   confirmed_by, confirmed_at, created/updated; unique live kind+adapter+
   console+sqid) and `chat_project_places` (id, project_id, kind, place_id,
   app, revision, app_created_at, key_name, key_fingerprint, key_runner,
   key_minted_by, key_minted_at; unique project+kind); `chat_cards.place`.
   Models, schema, migration check. Team records, never `scope.Owned`.
3. **Candidates and the place card (instance).** Candidates come only from
   the creator's primary's stored `Reach.Logins`: id `pc_` + 12 hex of
   sha256(console, sqid). Fixed rank: flagship (`https://console.carloku.com`)
   account named like the repository namespace; else the only owned
   account; then the rest, flagship first, then by console and name; at
   most six. (`.carlos/config` hints wait for slice 3.) Console labels are
   code's (Carloku, Tito, else the host). `propose_place` (owner only;
   kind `site`; project; candidate id from `places`) raises the card to the
   caller with that candidate first; refused when the project already has a
   site binding or an open place card. The answer (card person, owner now,
   open, revision; choice one of the stored ids, its stored hash equal to a
   recomputed one, still in the primary's current logins) creates or reuses
   the confirmed place and binds the project with the app from
   `projectSite` (mint once, stored in `site_app` too). Nothing goes to
   CARLOS. Audit `place.proposed`, `place.confirmed`, `place.declined`.
   If the card names a task still eligible, the publish card follows.
4. **Publish through the place (instance).** `primarySites` becomes
   `siteMode(person, binding)`: primary at 31 with carlos ok; "publish" when
   `Reach.Keys` holds console+sqid+app; "setup" when `Reach.Logins` has an
   owner login on console+sqid; else a fixed missing reason. `offerPublish`
   no longer returns silently: no binding raises the place card (owner) or
   says why in the task's lane; no mode says what is missing, once per
   merged commit. The publish card question names app, console label and
   account; setup adds one line that this first publish creates the app and
   its deploy key with the owner's CARLOS login. `answerPublish` stores on
   the step place id, both revisions and the destination hash; the dispatch
   carries them. `publishRefusal` also refuses when the place is not
   confirmed, a revision moved, the hash differs from the step's, or the
   check's `Destination` differs. `acceptPublishDone` records `Created` and
   the key's name, fingerprint and runner on the binding, audited (no
   secret). `publish_site` (task, target `site` only): creator and owner,
   task done and merged, Review approved the merged candidate with a site
   config, nothing publishing and no open card; proposes a place first when
   none; else raises the publish card for an older merged task.
   `places` and `site_status` (read-only, quoted data): bindings, places,
   app, address and outcome of the newest publish, key holder, the
   primary's mode and carlos health, candidates when unbound.
   `status` reports `runner.tools.carlos` and its version.
5. **Runner reach and the carlos guard.** One carlos lookup
   (`EQUIPO_CARLOS_PATH`, else PATH, else `~/.local/bin`). The capability
   probe runs `carlos version` (5 s), then, when the credentials file passes
   the existing file checks, decodes console origins and runs `accounts
   list --console <o>` per live console (20 s each, owner rows, validated),
   and lists its key files. Preview and publish refuse `carlos_outdated`
   before building when the version is unreadable or below v0.43.0.
   `EQUIPO_SITE_HOST` and the oficina/Carloku constants go; `Sites` is
   never sent.
6. **Runner publish.** The dispatch's console, sqid, name and app must
   validate and hash to its `Destination`. A held key for the app must
   match console and sqid (else `publish_key_mismatch`); its deploy runs
   `deploy --kind static --account-id <sqid> --console <o> --app <app>
   --channel edge ...` with `CARLOS_SERVICE_TOKEN` and `CARLOS_CONSOLE` in
   the environment and `CARLOS_CREDENTIALS` naming an absent file. With no
   key, setup needs a current owner login there: the taken check (unless
   the runner's own record owns it), the same deploy with the login, then
   `services create --role deploy --app <app> --rungs edge --account-id
   <sqid> --console <o> eq-<slug>-<4>` once the deploy succeeded; the token
   goes 0600 to `<state>/site/keys/<app>.json` (dir 0700, outside sandbox
   mounts), its fingerprint is sha256's first 16 hex. A failed mint leaves
   the site published and reports no key. The trusted scan (`scanPreview`)
   runs on the export before the built report: findings refuse
   `publish_secrets`, an unavailable scanner `publish_scanner`. The check
   sends the destination hash. Published exports carry no Equipo
   `_headers`; a project's own `_headers` stays and is scanned with the
   rest.
7. **Coordinator surface.** MCP tool schemas and descriptions, the Claude
   allowlist, `provider.ConverseTools`, `MutationKinds`/`WriteTools`/
   `madeCodes` for the two writers, the opening's website sentence (call
   `publish_site`; only the person's tap publishes) and `houseRule`.
8. **Places page.** Settings, read-only, state first: one line per bound
   project (app, place, address, checked when), pending proposals, else an
   empty line. Owners and members read it; nothing writes.
9. **End to end.** A thintest contract: protocol 31 primary with a login on
   Carloku account paulca, a merged Neary's website task, `publish_site`,
   place card, confirm, publish card, Publish, dispatch fields, check with
   destination, done with Created and Key, task shows the URL; then a
   second publish uses mode publish. Refusals: member tap, stale revision,
   place changed after the tap, wrong destination, runner at 30, carlos
   outdated, unbound offer says why. Runner tests with a fake carlos:
   argv and environment exactly, no token in logs or reports, key file
   mode, mismatch refusal, scan refusal.

## Astra round 1 fixes (binding; they override the tasks above)

1. **The card is the snapshot.** Raising a publish card stores on it
   (`chat_cards.place`, publish snapshot JSON) the merged commit, place id
   and revision, binding id and revision, console, sqid, name, app, mode
   and destination hash. The tap recomputes all of it in its transaction
   and refuses (card conflict, card re-raised) when anything moved; the
   step copies the snapshot. `publishBuilt`, `acceptPublishDone` and
   `settlePublish` carry the snapshot through (`publishRecord` embeds
   `wire.PublishResult` plus the snapshot). Tests change place, binding
   and login before the tap and after it.
2. **No weaker check, ever.** Below 31 Encode refuses a `site_publish`
   lease check outright (not dropped), and `Link.ConfirmPublish` refuses
   locally below 31. `authorizePublish`, `fencePublishes`, `previewHeld`'s
   publish side and every `ProtocolPublish` gate on the publish path move
   to `ProtocolPlaces`. A queued publish on a runner that reconnects below
   31 is fenced. Tests: reconnect at 30 with a queued step, an instance at
   30 (the runner's check refused locally).
3. **The owner's login only creates or mints.** Modes: `setup` only while
   the binding has no `app_created_at` (the app was never created by a
   publish); `publish` only with a held deploy key for exactly that
   console, sqid and app; `mint` (new) when the app was created but no
   key is held: the runner uses the owner login only for `services create`,
   then deploys with the new key. A created app is never deployed with the
   login again. The runner's site record becomes destination-bound
   (`<state>/site/<console>/<sqid>/<app>.json`): the taken check is skipped
   only for an app this runner created at that exact destination.
4. **Mint durability.** Before `services create` the runner records a mint
   intent (name, destination) in the step's phase `site_minting`; the secret
   is written to a temp file 0600 and renamed into place; only then is the
   key reported. A lost response, a crash before persistence or a refusal
   reports `PublishResult.MintLost` (the name) and no key; the instance
   records `deploy_lost` on the binding and the Places page says a deploy
   key of that name may be live on CARLOS without Equipo holding it.
   Restart in `site_minting` never runs the mint again: it reports the
   stored key if the file exists, else `MintLost`. A new mint needs a new
   tap (mode `mint`, new name).
5. **Capability is rechecked at dispatch and at the final check.** The
   dispatch builder calls `siteMode` and fails the step
   (`publish_not_ready`) when the primary, its protocol, carlos health or
   the mode's capability changed; `publishRefusal` does the same right
   before the deploy. The runner runs the taken check before the final
   check, then nothing slow between the check and the deploy.
6. **Migration copies `site_app`.** 0112 inserts one `chat_project_places`
   row (kind site, place '' , app = `site_app`, revision 1, no
   `app_created_at`) for every project with a `site_app`; an unplaced
   binding confirms nothing and grants nothing. Confirming a place fills
   its `place_id` and bumps its revision. Test: rows before 0112 (no app,
   an app) migrate as described.
7. **Strict list parser.** The site path's taken check parses `apps list`
   output strictly: a `using ...` line, then either `no apps in this
   account` or app lines (with or without the `APP STATE` header, with or
   without the region column); anything else, a non-zero exit or a clipped
   output counts as taken. Fixtures for each.
8. **Project headers.** As corrected in task 6.
9. **`site_status` contract (narrow).** It reports what Equipo recorded:
   the binding, place, app, the newest publish's outcome, address and when,
   the key's holder and fingerprint (or that it is missing or lost), and the
   primary's mode. It does not read the live edge version or domains
   (slice 3, P7), and says so in its description.

## Astra round 2 fixes (binding; they override everything above)

1. **Each use of the login is authorised right before it runs.** The tap
   fixes the mode (`setup`, `mint` or `publish`) and, for setup and mint,
   the key's name (`eq-<slug>-<4 random>`, minted by code at the tap);
   both are in the card snapshot, the step and the dispatch
   (`PublishDispatch.Mode`, `DeployName`). The runner never changes mode:
   a publish whose key is gone fails `publish_key_missing`. Two final
   checks, both destination-bound and refused below 31: `site_publish`
   right before every deploy, and `site_mint` (new purpose) right before
   `services create`. Each rechecks the creator is an owner, the primary,
   the place and binding revisions and the mode. The card says what the
   tap does: setup creates the app and a deploy key with the owner's
   login; mint creates a deploy key with it.
2. **Creation is recorded by the authority, pessimistically.** The
   instance sets the binding's `app_created_at` when it allows a setup
   step's `site_publish` check: from then on the app may exist, so setup
   is never offered again, whatever any report says. With no key held the
   mode is `mint`. In mint mode the runner first lists the account
   (read-only, strict parser); if the app is definitely absent it fails
   `publish_app_missing` without minting, and only that reason clears
   `app_created_at` (the next card is a setup card again, a new tap).
   If the app is listed, it mints, then deploys with the new key.
3. **The recovery route.** When a setup or mint publish ends with no key
   held (seen in the primary's reach), `publishEnded` raises a mint-mode
   publish card for the same merged commit. `publishing()` lets exactly
   that through: a mint-mode card is allowed after a done publish of the
   commit while the binding has no held key. `publish_site` can raise it
   too. A mint publish redeploys the same export with the new key, which
   is how the key is shown to work. Tested end to end: setup, mint lost,
   mint card, tap, key held, then a plain publish.
4. **Key evidence lives in the runner's hello, not in reports.**
   `PublishResult` gains nothing. `ReachDeploy` carries the key's name
   and fingerprint and `Lost` (a mint whose answer was lost or
   unreadable, or a crash between asking and storing: the runner records
   the intent in its state before asking and keeps it until it holds the
   key). Every hello repeats them, so an instance rollback loses nothing.
   The binding stores the name, the runner, who minted it and when, set
   at the allowed `site_mint` check; fingerprint, held and lost are read
   from the primary's current reach. Restart in `site_minting` never asks
   again: it reports the stored key, or the name as lost.
5. **Migrated bindings.** A binding with no place (from `site_app`)
   accepts a place proposal; confirming fills `place_id`, keeps the app,
   bumps the revision and leaves `app_created_at` empty, so its first
   publish is a setup at the new destination, behind the strict taken
   check. Runner site records are destination-bound; a legacy
   app-only record grants nothing, so an app published by the old
   oficina path is "taken" if that account is chosen (adoption is out of
   v1). Fixtures: no app, minted-unpublished app, previously published
   app.

## Astra round 3 fixes (made in the build; round limit reached)

1. **Attempted is not created.** `app_created_at` (with
   `app_created_step`) means "creation was attempted": setup is never
   offered again, and nothing is adopted. A mint needs destination-bound
   evidence that this runner created the app: its own site record at
   `<state>/site/<console>/<sqid>/<app>.json`, written only after its setup
   deploy command succeeded. A listing proves existence only. No record and
   the app listed: `publish_app_unproven`, nothing minted or deployed. App
   definitely absent: `publish_app_missing`, which alone clears the
   attempt (the next card is setup, a new tap). Tests: setup authorised then
   a crash before deploy; another actor creates the app; the mint refuses.
2. **Checks are per phase of the approved attempt.** The step's mode never
   changes; each check asks what that phase needs. Setup: start and
   `site_publish` need no attempt recorded and the login (the allowed
   `site_publish` records the attempt with this step's id); `site_mint`
   needs the attempt to be this step's and the login. Mint: start and
   `site_mint` need an attempt, no held key and the login (the allowed
   `site_mint` records `deploy_step` = this step); `site_publish` needs
   `deploy_step` to be this step, whatever the reach says by then.
   Publish: every check needs the held key. Each check also rechecks the
   creator is an owner, the primary at 31 with carlos ok, the place and
   binding at their snapped revisions and the destination hash. Tests
   include a hello arriving between mint and deploy.

## Build notes (deviations, all deliberate)

- The deploy names the place with explicit flags (`--account-id`,
  `--console`) and `CARLOS_CONFIG` names an empty config of the runner's
  own, as today, rather than a config holding the destination: no file a
  repository or person wrote is read either way.
- The runner writes its destination-bound creation record right after the
  setup's final check and before its deploy (the name having just been
  found free), so a deploy that failed half way can still get its key by a
  mint. The window is the accepted list and deploy race.
- Repository `.carlos/config` hints, team defaults and Change, Undo and
  Retire wait for slice 3; candidates rank by namespace and the only owned
  account only. `publish_site` takes a task (not a project and commit).
- `EQUIPO_SITE_HOST` and the `Sites` hello flag are gone: a runner at 31
  reports reach instead, and a publish needs 31. The site host now probes
  whenever carlos and a state directory exist; without a valid login it
  still publishes with held keys and sets up none.
- Approved copy that says Carloku (`chat.publish_unconfirmed`,
  `chat.publish_taken`, `work.reason.publish_failed`) is unchanged; it reads
  right for Neary's and every Carloku place.
- Native clients show place cards on the web (they route unknown kinds
  there already); no Swift change.

## Astra branch review

Round 1 NOT READY (1 blocker, 4 major), fixed in 6a71f098. Round 2 NOT
READY (4 major), fixed in 8fa19e4a. Round 3 NOT READY (1 major: an
interrupted recovery whose key was stored could never be asked again);
the round limit reached, it is fixed after the review (a publish is
blocked only by one that went live) with its contract test, and not
re-reviewed.

## Copy

New strings (card question and setup line, place card, offer reasons,
activity lines, task reasons `carlos_outdated`, `publish_secrets`,
`publish_scanner`, `publish_key_mismatch`, Places page) go to
`/home/paulca/.cache/places-1-copy.json` as copy-review entries and into
`copy.go` marked pending with `scripts/copy-status.py pending`. The
pending-copy gate stays red until Paul reviews them.

## Verification and handoff

Targeted `go test -run` per package while building; then `make ci` once.
Mutation checks recorded in each commit body. Astra reviews this plan and
the whole branch (max three rounds each). Push `places-slice-1`; no merge,
release or deploy.

## After release (Paul)

Upgrade production, then in Equipo: "Publish Neary's". Tap "Carloku,
account paulca", then Publish. The task shows the address.
