# Alta

Paul's team-provisioning app for the Oficina suite. A **team** is one
CARLOS instance per app, each bound to its own standalone environment owned
by CARLOS scope `alta`, attached at `<label>.<app>.oficina.works`,
registered with Home as a consumer, plus a Home team with its first owner.

Design: Home `implementation/team-provisioning-app.md` (APPROVED, round 3,
discussion 92). Home side: `team-provisioning-amendment.md`, implemented at
Home `82d9388` (activation's version rule relaxed at `0cee9ba`, which
`homecompat` pins). CARLOS side: `team-scoped-credentials.md`, merged at
platform `9bcbab0f5`, **not released**. Alta replaces
`oficina/teams/provision-team.py`. **Not deployed.**

## How a run goes

1. **Preflight** (Alta): the label is new and well-formed, both Home roles
   answer a signed inspect, the directory is initialized, each app has its
   team credential, nothing already holds the environment or the host.
2. **Plan**: Alta signs one plan per Home role with one shared plan id and
   posts it. The run page shows the two Home confirm links and the plan
   id's first 8 hex.
3. **Paul confirms on Home** — `https://oficina.works/operator/confirm`,
   then `https://id.oficina.works/operator/confirm` (retyping the owner's
   address), each behind a fresh Home sign-in. Home shows its own copy of
   the plan. Each confirm opens a 15-minute window.
4. **Alta runs** the steps: owner-seed and seed-team at Home; per app,
   provision and register the consumer, write the environment, create the
   instance, attach the hostname, wait for it to serve, and — for apps with
   roster mode — verify and activate; then the exact-keys audit, after
   which Alta deletes every row holding the owner's address.
5. A run that outlives its window parks; **Continue under a new plan**
   submits an `add-apps` plan for the same apps, confirmed again on Home.

### Profiles and samples (Paul, 2026-11-12)

Each create-team and add-apps run carries a **profile**, chosen on the run
form, recorded on the run and shown with its plan on Alta's run page
(Home's copy of the plan has no field for it):

- **outside** (the default): the recipes below, unchanged. For anyone
  else's team.
- **own**: Paul's own teams. Differs only in `CALLS_QUALITY_REPORTS=on`,
  `OFICINA_DASHBOARD_TEAM=<label>` on the apps that read it (Docs, Sheets,
  Slides, Calendar), and Memoria's AI: the run leaves it off (memoria
  refuses to boot with `MEMORIA_AI=on` and no key, and Alta never holds
  the TensorX key); Paul sets `MEMORIA_TENSORX_KEY` (secret) and
  `MEMORIA_AI=on` in the environment afterwards, and the audit admits the
  two together and refuses either alone. Own teams may also take
  **Equipo and Base** (below).
- **samples**, a separate box: `DOCS_SAMPLE_DOCUMENTS=1`, for a sample
  team only.

Slides has uploads in both profiles (Paul, 2026-11-12): Slides'
app-wide private-storage policy (`carlos instances enable --app slides
--private-storage`, Paul's to run) gives every instance Alta creates its
environment's own bucket at step 8, and CARLOS's objstore walk delivers
`CARLOS_STORE_BUCKET`, `_REGION`, `_ACCESS_KEY`, `_SECRET_KEY` (and
`_ENDPOINT` where the deployment has one). They are PLATFORM keys: Alta
never writes them (the console guard refuses), and the audit admits the
whole set on Slides only, optionally, since an instance created before
the policy has none. Any other app holding them fails the audit. Step 7 records the choice each
environment was written with (the team page shows it per app), and the
audit checks against that. A written environment is never rewritten, so
a run whose choice differs from an app's written one is refused
(`profile-differs-<app>`). "Continue under a new plan" takes only the
apps with steps still to do. Its form (on the team page) offers the
profile and samples choice, defaulted to those apps' own (written, else
the newest run naming them), so a wrong choice on an app not yet written
— a create-team run's included, whose label is already spent — is
corrected by continuing under the right one. A team whose apps are all
finished, under choices that disagree, has nothing to continue and shows
no Continue form.

Known limit (left as ruled): Continue defaults to nothing when two
unfinished apps' choices differ, and says `profile-differs-<app>`.
Choosing one profile on the form continues both when at most one of
them is written (the unwritten one takes the choice); two unfinished
apps *written* under different choices cannot be continued from any
form. A later run takes back out only a key
exactly as Alta wrote it (`OFICINA_DASHBOARD_TEAM=<label>`,
`DOCS_SAMPLE_DOCUMENTS=1`); the console guard refuses any set of
`MEMORIA_AI` or `MEMORIA_TENSORX_KEY`.

Labels: Alta's pattern, never `--` (`xn--` punycode), and never a reserved
name (`ReservedLabels`: `oficina`, every app's name, and the suite's and
platform's own names).

### Equipo and Base (own teams only; team-bundle spec, 2026-11-30)

Design: `docs/superpowers/specs/2026-11-29-team-bundle-design.md` and its
plan, on branch `design/team-bundle`.

- **Seeded, not roster.** Neither app has Home roster mode. Their owner
  comes from `EQUIPO_OWNERS` and `BASE_OWNER`, so their recipes write the
  owner's address, and Alta keeps it (sealed) until both environments
  are written. Each serves a seeded `GET /api/team`. Step 11 activates
  it only when the probe names this consumer and reports an owner
  (`roster-owner-pending` parks until then).
- **Removing someone at Home removes them from neither.** That is
  accepted for own teams (Paul, 2026-11-30). Remove them in Equipo and
  Base too.
- **Own profile only.** Step 0 refuses either under `outside`
  (`app-own-only`). The team page offers them only to a team whose apps
  are all own, and never on the adoption label.
- **Base comes last.** Step 0 refuses Base (`base-needs-team-apps`)
  until the team has, or the run includes, every other app, Equipo
  included. Its tile list (`BASE_OFICINA_APPS`, every other app) and
  `BASE_EQUIPO_ORIGIN` then never depend on the run. A label over 19
  characters cannot take Base (`label-too-long-for-base`). A team that
  leaves out any app (Calls, say) cannot have Base, and a later
  `retire-apps` leaves that app's tile in Base's list. `BASE_NAME` is the
  label, because Alta keeps no display name in a recipe's inputs. Base has no
  Store: no `BASE_PLATFORM_*`, `BASE_APPS_DOMAIN` or
  `BASE_ASSERTION_KEY`.
- **Created with the team, in practice.** Add-apps refuses Equipo or Base
  once Alta has forgotten the owner (`owner-forgotten-seeded`): a retyped
  address would become their owner on a shape check alone. It also
  refuses them on a team with any app written under `outside`.
- **No agent keys** (`<P>_AGENT_*`) on fresh instances, as for the six.
  Agent access for fresh teams is a follow-up.
- **Execution is Paul's post-run pair**, like Memoria's AI. Set both:
  - `EQUIPO_EXECUTION_ENABLED=1`;
  - `EQUIPO_EXECUTION_MARKER_PATH=/data/instances/<label>-equipo.<account>.oncarlos.com/execution/witness`,
    the instance's own CARLOS directory.

  The audit admits the exact pair together, and refuses half of it or a
  path naming another instance. Alta's console guard refuses writing
  either. App `equipo` is already under `--swap hold`, which is
  app-wide.
- **Closing a team** with these apps (spec §5.1 rule 4):
  - `retire-apps` leaves the environment and the parked replica;
  - before `carlos env release`, unset each Equipo and Base secret and
    key (`carlos secrets unset`, `carlos env unset`);
  - revoke the team's GitHub connections at GitHub;
  - revoke Memoria's TensorX key at TensorX.

### Retiring

Retiring apps (`retire-apps`) disables the directory consumer, retires the
credential consumer, detaches the hostname and deletes the instance. The
parked database replica, the owned environment, and the team's label stay;
labels and retired hostnames are never reused.

## Configuration

| Variable | Kind | What |
|---|---|---|
| `ALTA_ORIGIN` | env | Alta's own origin. The host is not ruled; the default is the unlisted platform address `https://alta.bds.oncarlos.com`. Change it here and in Home's `HOME_CONSUMERS` together. |
| `ALTA_DEK` | secret | 32 bytes, standard base64: seals Alta's database columns. |
| `ALTA_OPERATOR_SUBJECT` | env | Paul's Home person ref: the only identity that sees a page. |
| `ALTA_HOME_ISSUER` | env | `https://id.oficina.works` |
| `ALTA_HOME_CONSUMER_ID` | env | `alta` |
| `ALTA_HOME_KEYS_BASE64` | env | Home's assertion public keys (the manifest every app has). Also written into each team app's `<P>_HOME_KEYS_BASE64`. |
| `ALTA_HOME_DEK_BASE64` | secret | 32 bytes for the sign-in hand-off. |
| `HOME_DIRECTORY_ORIGIN` | env | `https://oficina.works` |
| `ALTA_OPERATOR_KEY` | secret | Alta's P-256 operator key (`alta keygen`). |
| `ALTA_OPERATOR_PREFILTER` | secret | 32 bytes, base64url: Home's prefilter bearer. |
| `ALTA_OPERATOR_INSTALLATION`, `_REGISTRY`, `_DEVICE` | env | Random once (`alta keygen`), pinned on Home. |
| `ALTA_DIRECTORY_PROVISIONING_PUBLIC_KEY` | env | The directory's provisioning public key (base64url): Alta verifies every record with it and writes it into Docs' `DOCS_TEAM_OPERATOR_KEYS_BASE64`. |
| `ALTA_CARLOS_DOCS`, `_SHEETS`, `_SLIDES`, `_CALENDAR`, `_CALLS`, `_MEMORIA` | secret | One CARLOS `team` credential per app, scope `alta`. Never an operate or instance token. |
| `ALTA_CARLOS_ACCOUNT` | env | The account's **sqid**, default `bds` (the team doors 404 the account's name). |
| `ALTA_CARLOS_CONSOLE` | env | Default `https://console.carloku.com`. |
| `ALTA_CALLS_ZONE` | env | `CALLS_ZONE` for team Calls instances; default `UTC`. |

`alta keygen` prints fresh operator material, the pins, and both roles'
`HOME_OPERATOR_HTTP` with every verb Alta uses.

## Deploying (checklist; nothing here has been done)

1. **Hub repo**: create `oficina/alta` on amadan.net, then push `main`.
2. **Production gate**: CARLOS `team-scoped-credentials` released, and every
   box at its floor (`release.TeamEnvironmentFloor`, v0.30.0).
3. **Team credentials** (Paul, person-only), one per app:

       carlos services create --account oficina --role team --app docs --scope alta alta-docs
       … sheets, slides, calendar, calls, memoria

   then `carlos secrets set --app alta ALTA_CARLOS_<APP>=…`.
4. **The CARLOS app** `alta` in account `oficina` (`bds`), served at its
   platform address; `carlos apps build-probe --app alta --account oficina
   /api/version`; Alta's own config from the table above.
5. **Mail and relay**: each app's mail declared under the prefix its binary
   reads — `DOCS_SMTP` for Docs — and the relay enabled for Calls, so the
   CARLOS walks mint per-environment credentials. An app switched to
   CARLOS mail submission (`carlos email submission on --app <a>`, Paul)
   gets no credential at all: each team environment receives only
   `<stem>_MAIL_FROM` (`CARLOS_MAIL_FROM`, or `DOCS_MAIL_FROM` for Docs),
   and step 7 takes that as the app's mail. The switched binaries read
   only that one From, so a switched app must be declared under
   `CARLOS_SMTP` (Docs: `DOCS_SMTP`), even one whose SMTP also reads its
   own prefix (Slides, Calendar, Calls); a From under any other stem fails
   step 7 with `mail-prefix-<app>`; after redeclaring, wait for the walk
   to take the stray From out before re-running. Alta is given no SMTP, From or
   relay value. Slides' private-storage policy on (`carlos instances
   enable --app slides --private-storage`, Paul), so each team Slides gets
   its own bucket; Alta is given no store value either.
6. **Versions**: ship team apps with `carlos ship --version` equal to the
   app Makefile's `VERSION` (`git describe --tags --always`) if you want
   the box's serving name and `/api/version` to match. Step 10 does not
   require it: it records both, uses `/api/version` as the activation's
   `app_version` and the box's name for `artifact_digest`, and notes a
   difference in the audit.
7. **DNS and certificates**: `*.<app>.oficina.works` → the deployment, per
   app zone; Alta attaches explicit hosts.
8. **Home**: add `"alta": "<ALTA_ORIGIN>"` as the 8th `HOME_CONSUMERS`
   entry (credential role); set `HOME_OPERATOR_HTTP` on both roles (from
   `alta keygen`, with `operator_subject` and, on the credential role,
   `directory_provisioning_public_key` filled in) beside each role's
   `HOME_OPERATOR_MATERIAL`; enable the directory's roster endpoint.
9. **The owner** (Till) signs in once at `https://oficina.works`.
10. **Amendment §12 pre-flight**: Paul confirms the production directory has
   never issued a roster generation or consumer record, by typing it on
   Alta's Initialize page. Alta's first production run is `initialize`.
11. **`lagged`**: per app, `carlos env fork --from lagged --to lagged-team
    --scope alta`, then rebind each instance with `--scope alta`; create the
    team in Alta with "Moving a stopgap" ticked.

## Where Alta follows the merged code, not the design text

Home's `team-provisioning-app.md` is a separate repository; these are
recorded here instead (Fable's rulings on oficina/alta #1):

- **§5, Slides uploads**: the design says Slides ships with "No uploads
  … no `CARLOS_STORE_*`". Paul ruled on 2026-11-12 that Slides uploads are
  switched on app-wide (`carlos instances enable --app slides
  --private-storage`, his step). Every Slides instance then gets its own
  bucket at creation, and the audit admits CARLOS's five store keys on
  Slides only, whole and by kind. Alta never writes them. Amend the
  design's Slides row when Home's document is next touched.
- **§3, the console path**: a team credential's doors take the account's
  sqid, so the path is `/api/cli/apps/bds/<app>/…`, not
  `/api/cli/apps/oficina/<app>/…` (`teamInScope` compares the path to the
  credential's own account sqid).
- **§6 step 10 and §7, the serving build**: there is no
  `update_report.serving`. The box's report is `status.HostRollout`; the
  team role reads it as `rollout` on the `GET /instances` list door
  (`?q=<host>`), and `GET /instances/{host}` carries neither. Step 10
  requires the instance awake, not transient, `config_pending` false, and
  both `rollout.serving` and `/api/version` present; it does not require
  them to be equal.
- **§6 step 0, the mail prefix**: a team credential cannot read an app's
  mail declaration. Alta checks a forked environment that already exists
  at step 0, and every environment when the walk delivers (step 7, and
  the audit), refusing a prefix the app does not read. Deploying step 5 is
  the human check.
- **§7, `app_version`**: Home now admits an observed printable token
  (`^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$`, Home `0cee9ba`), so a
  git-describe stamp activates. Alta mirrors that rule at step 10
  (`activationVersion` in `provision/steps.go`): a version Home would
  refuse parks there as `version-unacceptable` instead of failing
  activation.
- **§6 step 11, `/api/team`**: every app has roster mode — Docs, Sheets,
  Slides, Calendar, Calls and Memoria (team mode on each app's main or
  team-mode branch: Docs `e58a22f`, Sheets #52, Slides #33, Calendar #35,
  Calls oficina/meet #31, Memoria #32). Each serves the readiness probe
  once that build is deployed; until then it parks at
  `no-readiness-probe` and its directory row stays pending.
- **§4–§5, the owner's address**: no recipe writes it any more (no
  stopgap allowlists), so the seed is its last use and Alta deletes it in
  the pass that seeds the team. The rule still waits for any app whose
  recipe holds the owner, should one return.
- **Calls has no push**: `cmd/calls` does not read `CALLS_APNS_*` (on
  main or team-mode), so a team's Calls sends no Apple notifications.
  `CARLOS_RELAY` stays PLATFORM, minted per environment.
- Memoria's AI is never turned on by Alta: no `MEMORIA_AI`, TensorX key,
  siblings or logged mail in any recipe. An own team's audit admits the
  pair Paul sets by hand (see Profiles).
- **§11, Help**: the account menu has no Help items yet (no Colophon page).

## Adopting the existing apps (`alta-adopt`)

`alta-adopt` is a second binary, run on Paul's machine and never deployed.
It joins the eight canonical apps (docs, sheets, slides, calendar, calls,
memoria, equipo, base at `https://<app>.oficina.works`) to a Home directory team
labelled `oficina`, named "Oficina", so oficina-connect can route an
assistant's calls to them. On CARLOS it writes two keys per app,
`<P>_AGENT_ISSUER = https://connect.oficina.works` and
`<P>_AGENT_TEAM = <the team's SQID>`, and proves nothing else changed. It
creates no instance and changes no Home key or `HOME_CONSUMERS`.

The design is Home `implementation/existing-team-adoption.md`; the plan
is `docs/superpowers/plans/2026-11-16-adoption-runner.md`. Every command
is a dry run unless given `--apply`. Build it with `make adopt`.

For adding Equipo to the already adopted `oficina` team, use
[the Equipo rollout](docs/equipo-adoption.md). Equipo is adoption-only;
Alta does not yet offer a recipe for new Equipo instances. Its app-side
adoption contract must be deployed before `configure`.

Base joins the same way, adoption-only, by
[the Base rollout](docs/base-adoption.md). Its operations door already
answers agent-access's challenge before adoption, so its delivery check
holds that door instead of watching it move (Paul approved the rule
2026-11-23).

### Before the first run

The shared production keyset comes first, before the CARLOS credential
and the Home counts (critical path step 5; home 101 §5, with its
corrections). Adoption and Alta share one operator signer, installation,
registry and device on both Home roles, so this one keyset is what the
config file carries.

- **Paul approves one `alta keygen`** (Alta's operator key, the
  prefilter and the pins) **and one `home team-keygen -subject
  pr_tsoeky4xus2habsdlun2jvzmku`** (Home's side, for Paul's person ref).
  One of each: the pins and key Home holds must be the ones in the
  config file.
- **The team configuration is applied to `oficina-id`, then to
  `oficina`**, in that canaried order: the credential role first, checked,
  then the directory. Follow home 101 §5 as corrected there, not an
  earlier copy.
- **Paul names the machine that holds the operator key.** `alta-adopt`
  runs only there, and the config file and the state database stay there.

- **The config file** (`--config`, mode 0600, Paul's own) holds Alta's
  operator key, prefilter and pins, `ALTA_DEK`, the directory's
  provisioning key, the console and account, the state database's path,
  and `artifacts`.
- **`home_issuer` must be `https://id.oficina.works`**, the runner's
  `adopt.HomeIssuerOrigin`. Any other value is refused when the config is
  loaded. The CARLOS preflight checks each app's `<P>_HOME_ISSUER`
  against the same constant (`home-issuer-mismatch`).
- **`artifacts`** maps each app to the SHA-256 of the release name Paul
  reviewed, as 64 lowercase hex: the value `X-Carlos-Version` serves, for
  example `printf %s v1.4.0 | sha256sum`. Activation is refused for an
  app whose served release hashes to anything else.
- **The CARLOS credential** is an Admin service token
  (`carlos services create --account oficina --role admin
  oficina-adoption`). It is passed on a file descriptor only
  (`--carlos-token-fd 3 3<token-file`), held in memory and zeroed on exit.
  It is never in the environment, the config or the state database.
- **The state database** is the run's journal and Alta's operator stream.
  Back it up after each session. Never edit, replace or delete it by hand.
- Gated on CARLOS 522 Plan 1 (conditional writes and
  `restart/scope`) being on the production console.

### Phases

Phases may fall in separate sessions on separate days. Home's plan windows
last 15 minutes and are never extended, so each plan is its own short
session. A delivery check has no age limit: it stays valid until the
instance, the served version or the config it observed changes.

| Phase | Command | What happens |
|---|---|---|
| 0a | `home-preflight --phase pre-initialize` | Both Home roles inspected, plus Paul's pasted table counts. |
| 0b | `preflight` | Per app, read-only: the config's layers, any other instance that would inherit the keys (`inherits-<host>` stops the run), team-mode keys, identity, delivery. |
| 1 | `initialize` | Directory `initialize`, after Paul types the §12 attestation. |
| 2 | `home-preflight --phase pre-plan-a`, then `plan-a` | Owner-seed, seed-team, then provision and register (verify only) for all six. |
| 3 | `configure --app <a>` | Per app: one conditional `PUT /config`, one restart of the canonical host only, the after snapshot, and the runner's delivery check. |
| 4 | `activate --apps calendar` | Plan B: calendar, the canary, is re-observed and activated. |
| 5 | `activate --apps docs,sheets,slides,calls,memoria` | Plan C. Refused until Plan B has activated calendar. |

`initialize`, `plan-a` and `activate` open a plan. After Paul confirms it
on Home, `advance --run <id> --apply` takes the run as far as it can go;
run it again if it stops (`status` shows where every run is).

### Paul's steps, in order

1. **The shared production keyset** (see the prerequisite above). Approve
   the one `alta keygen` and the `home team-keygen -subject
   pr_tsoeky4xus2habsdlun2jvzmku`, apply the team configuration to
   `oficina-id` and then `oficina`, and name the machine that holds the
   operator key.
2. **CARLOS credential.** Run `carlos services create --account oficina
   --role admin oficina-adoption`, and pass the result to `alta-adopt`
   only on a file descriptor.
3. **Home counts, before initialize.** Run
   `alta-adopt home-preflight --phase pre-initialize`. It prints eight
   read-only queries; run each with `carlos db query` against Home's
   directory and paste the counts. Rerun with `--apply` to record them.
4. **CARLOS preflight.** Run `alta-adopt preflight`. Any code stops the
   run; `inherits-<host>` means another instance shares the layer the keys
   would go to. `artifact-mismatch` means the app is not serving the
   release reviewed in `artifacts`. `operations-<shape>` means its
   `/api/v1/operations` does not answer as it should before adoption: a
   404, for Slides, Calls and Equipo their own 401, or for Base its own
   agent-shaped 401.
5. **Initialize.** Run `alta-adopt initialize --apply` and type the
   attestation. Confirm on
   [https://oficina.works/operator/confirm](https://oficina.works/operator/confirm)
   with a fresh passkey in the system browser, then
   `advance --run <id> --apply`.
6. **Wait out the initialize window: 15 minutes from the confirmation.**
   The pre-plan-a preflight refuses (`plan-open`) while it is open.
7. **Home counts, before Plan A.** Run
   `home-preflight --phase pre-plan-a --apply` with fresh counts. After
   initialize, `roster_generation` and `roster_operator_receipts` hold one
   row each; every other table is empty.
8. **Plan A.** Run `plan-a --apply` and type the owner (Paul's own
   address). Confirm on
   [https://oficina.works/operator/confirm](https://oficina.works/operator/confirm),
   then on
   [https://id.oficina.works/operator/confirm](https://id.oficina.works/operator/confirm),
   retyping the owner. Both pages should show the SQID, the six canonical
   hosts, "Oficina" and the same 8-hex prefix. Then `advance`.
9. **Configure.** For each app, `configure --app <a>` (dry run) and then
   with `--apply`: one config write and one restart, of that host only.
   Before writing, `configure` refuses as preflight does, so nothing is
   written for an app that is not serving its reviewed release. It then
   waits until the app serves agent-access's challenge, records the after
   snapshot, then checks the delivery itself and records the check. The
   app must serve the same release as before, the reviewed one, in both
   the `/api/version` body and `X-Carlos-Version`, with no redirect;
   `/healthz` must answer 200; and `/api/v1/operations` must now give
   agent-access's answer where it gave a 404, and agent-access's challenge
   where Slides and Calls gave their own 401. There is nothing to sign in
   to and nothing to type.
10. **Plan B.** Run `activate --apps calendar --apply`, confirm on both
    pages, then `advance`.
11. **Plan C.** Once Plan B's run is done, run `activate --apps
    docs,sheets,slides,calls,memoria --apply`, confirm on both pages, then
    `advance`.
12. **Clean up.** `carlos services delete oficina-adoption`, and back up
    the state database.

### When a step stops

- **Plan A fails before the team is seeded.** Stop. Home then holds no
  team, and the runner has no way to restart a failed Plan A. Nothing at
  Home needs undoing: an owner-seed receipt expires after 300 s and an
  unconfirmed plan after 15 minutes. Leave the state database as it is,
  and get a recovery procedure reviewed before doing anything else.
- **Plan A's window closes after the seed.** Run `plan-a --apply` again:
  it opens a continuation (`add-apps` for the seeded SQID) that provisions
  and registers only the apps still missing. Confirm it on both pages and
  `advance`.
- **A plan lapses before confirmation.** `plan-a --apply` signs it again;
  for Plans B and C, run `activate` again.
- **A process dies mid-configure** (closed laptop, lost network). Run the
  same `configure --app <a> --apply` again. It rereads the console and
  continues from the journal: a write that landed is found, never sent
  twice; the baseline is never retaken. A restart may be repeated. If
  the process died after the restart, the delivery check is made again
  with no second write or restart.
- **The delivery check is refused** (`check-<code>`). Nothing is
  recorded, and activation stays refused for that app. The code names
  what is wrong: `check-not-delivered` (version, header, redirect, health
  or the operations answer), `check-artifact-mismatch` or
  `check-artifact-unreviewed` (the served release is not the reviewed
  one in `artifacts`; checked before the write too, so this means it
  changed since), `check-identity-<field>` or `check-config-<key>`
  (the instance or its config moved since the after snapshot). Find out
  why before going on. Once it is put right, the same `configure --app
  <a> --apply` checks again.
- **A stop** (`preserved-changed`, `identity-changed`,
  `agent-keys-conflict`, `agent-keys-foreign`, `receipt-mismatch`,
  `receipt-malformed`) is final for that app: every resume refuses again,
  and the runner never unsets a value it did not write. Look at the
  console first.
- **Failed and stopped states stay closed.** A failed run and a stopped
  write or rollback are never cleared by the runner. Going past one needs
  a reviewed procedure first.
- **Plan C is refused with `canary-not-active`.** Plan B has not yet
  activated calendar, or calendar has since been rolled back or
  disabled. Finish Plan B first. After a calendar rollback or disable,
  Plan C stays refused: going past that needs a reviewed procedure.
- **Activation parks with `observe-<codes>`.** The re-observation just
  before activation no longer matches the journal; the codes name what
  moved (`delivery-check-superseded`, `config-<key>`, `identity-<field>`,
  `artifact-mismatch`, …). Nothing was activated. Find out what changed
  before going on.

### Every production write, and its rollback

| # | Write | Where | Rollback |
|---|---|---|---|
| 1 | `directory.initialize` | Home directory | **None**, by design. Gated on the Home preflight and the §12 attestation. |
| 2 | Plan submissions for initialize, A, B and C, both roles | Home `operator_plans` | An unconfirmed plan expires after 15 minutes and is swept. |
| 3 | `credential.owner-seed` | Home credential | None needed: the receipt expires after 300 s. |
| 4 | `directory.seed-team` `oficina` / "Oficina", Paul as owner | Home directory | None (nothing is deleted). The team is inert without a live instance, and the label is reserved. |
| 5 | `directory.provision-consumer` ×6 | Home directory | `alta-adopt disable --app <a> --apply`: a retire-apps plan, then `directory.disable-consumer`. |
| 6 | `credential.register-consumer` ×6 (verify only, nothing inserted) | Home credential | None needed. |
| 7 | Conditional `PUT /config` of `<P>_AGENT_ISSUER` and `<P>_AGENT_TEAM`, one per app | CARLOS `oficina`, the canonical host's layer | `rollback-config --app <a> --apply`: a journalled conditional unset that refuses foreign values, **then the scoped restart (dry run first)**. Before the unset and before the restart it rereads the host, and stops if the instance or any preserved key has changed since the baseline. Complete only when the probe shows the old operations shape again. |
| 8 | `POST …/restart/scope {"host"}` after its dry run, one per app | CARLOS, that host only | Restart again after the rollback. |
| 9 | `directory.verify-consumer` per app | Home directory | Expires after 600 s. |
| 10 | `directory.activate-consumer` per app | Home directory | Immediately: row 7's rollback, which stops delegated access at the app. Then `disable`. A revoke at connect also works. |

From row 4 onward, keep Home on an adoption-capable build: **never
downgrade it, restore an older snapshot, or delete rows.**

### Rehearsal

`adopt/rehearsal_test.go` runs the whole adoption against the fakes, in
the order above, then again killed at every Home act and at every CARLOS
act (before and after the PUT, after the restart, mid-rollback), resuming
each time from the journal. `homecompat/adopt_flow_test.go` runs the Home
half, with the preflight's own queries, against Home's real operator
code.

## Developing

    make ci        # vet, gofmt, tests, and the Home compatibility module
    make release   # linux/arm64, stamped with git describe
    make adopt     # the local adoption runner, releases/alta-adopt

Tests run the state machine against `homeop/fakehome` and
`console/fakeconsole` (including a crash after every act, a lost answer
after every Home commit, and §8's guards), and against Home's real
operator engine in `homecompat/`.
