# 🤖 Alta: the team provisioning app

**Status:** APPROVED (design), 2026-10-27. Drafted by Claude Opus 5.5 for
Paul. **Reviewed by Claude Fable 5.1 (claude-fable-5-1), 2026-10-27,
discussion 92, APPROVED (design, round 3)** at `93f8209`, after rounds 1
and 2 (CHANGES REQUIRED); round 3's notes are applied (§14). Not approved by
that verdict and gated separately: the CARLOS `team-scoped-credentials`
design and its floor release before Alta reaches production; Alta's own
implementation review, CI and canary; Paul's pre-flight confirmation
(amendment status, items 1–4). **Implementation needs its own whole-code review** (AGENTS.md). Facts read at origin/main: Home
`e2ec1ab`, carlos platform `57aec0a`, Docs `d867db1`, Sheets `af8deeb`,
Slides `ebbb08f`, Calendar `00d8e3d`, Calls (repo `oficina/meet`,
`cmd/calls`) `47afcb9`, Memoria `521ae24`. It replaces
`oficina/teams/provision-team.py` (Track 1, 2026-10-27).
**Paul's rulings, 2026-10-27, applied here:** ruling 8 re-ruled for Alta on
condition of CARLOS team-scoped credentials, and **Alta does not ship to
production until they exist** (§3); every run needs Paul's fresh sign-in,
now given on Home's own confirm pages; the owner must have signed in once;
labels — and retired app hostnames — are never reused; Slides ships without
uploads; team instances send mail through the platform relay, but with
**per-team credentials CARLOS mints** (Paul's CARLOS ruling, 2026-10-27,
"enforce in one place" — this replaces "share the mail relay"); team
dashboards stay blank;
Memoria is in the `oficina` account.

---

## 1. What it is

A Paul-only web app that creates a **team**: one CARLOS instance per app,
each bound to its own **standalone** config environment with fresh keys,
attached at `<team>.<app>.oficina.works`, registered with Home, plus a Home
team with its first owner. First run: label `lagged`, owner
`till@lagged.biz`, apps docs, sheets, slides, calendar, calls, memoria.

- **Name:** **Alta** (*dar de alta*, to enrol). Repo
  `/Users/paulcampbell/amadan.net/oficina/alta`, module
  `amadan.net/oficina/alta`, CARLOS app `alta`.
- **Host:** `https://alta.oficina.works` proposed (not ruled; alternative:
  its `alta.bds.oncarlos.com` route only). Never in Home's app registry or
  chooser.
- **Stack:** rastrillo (`amadan.net/rastrillo/rastrillo`), estilo chrome and
  door, Calma rules, attribute spelling, scriptless except estilo's
  `busy.js`. One binary, `CGO_ENABLED=0`, hibernates.
- **Not Home.** It holds CARLOS credentials Home must never hold (spec §7).
  Home holds only Alta's public key.

## 2. Who can use it

- **Sign-in:** Home sign-in only (an ordinary consumer, `ALTA_HOME_*` via
  `home/connect`). No local magic link, no address allowlist.
- **Who:** exactly one person ref, `ALTA_OPERATOR_SUBJECT` (Paul's); any
  other identity gets the same 404 as an unknown page.
- **Every run is confirmed on Home.** Alta submits signed plans; Paul then
  opens each Home role's window on Home's own confirm pages, behind Home's
  fresh sign-in, reading Home's copy of the plan and retyping the owner's
  address on the credential origin (amendment §4). Alta never handles an
  assertion beyond its own sign-in. Status pages need only an Alta session
  (idle 30 min, absolute 12 h).

## 3. Credentials it holds, and their reach

**Ruling 8 re-ruled for Alta — Paul, 2026-10-27.** A web-facing app other
than Home may hold CARLOS credentials **on condition** that CARLOS gains
team-scoped credentials acting **only** on named, non-default environments
and the instances bound to them. **Alta does not ship to production until
that credential exists.** Rejected: a separate CARLOS account; accepting
today's app-wide `instance` + `operate` reach. CARLOS design:
`carlos/platform` branch `team-scoped-credentials` — role **`team`**, scope
= the environments the scope owns, and **owned environments are
standalone**: they never inherit the app's default bundle.

**In production**, one credential per app, minted by Paul:

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

Stored as Alta secrets `ALTA_CARLOS_<APP>`, sent as `Authorization: Bearer`
to `https://console.carloku.com/api/cli/apps/oficina/<app>/…`. Memoria is in
the `oficina` account like the others (its `lagged` instance was provisioned
there on 2026-10-27; its README's `--account bds` is stale).

**Before that credential exists** — development and previews only, against
a throwaway sandbox account. **The sandbox never holds production
`instance`, `operate` or `team` tokens**, and no Alta deployment with
production Home pins runs against it. §8's guards were written for this
period and remain defence in depth; they are not the fence (the fence is
CARLOS's scope and Home's provenance fence).

**Home:** `ALTA_OPERATOR_KEY` (P-256; contexts
`oficina/home/operator-input/v1` and `…/operator-plan/v1`),
`ALTA_OPERATOR_PREFILTER` (32 bytes), `ALTA_OPERATOR_INSTALLATION`,
`_REGISTRY`, `_DEVICE` (random once, pinned on Home). **Its own:**
`ALTA_ORIGIN`, `ALTA_INSTANCE_KEY`, `ALTA_DEK`.

**Alta never holds or copies a platform credential.** It never sees Paul's
SMTP password, `CARLOS_RELAY` or any TURN secret, and never writes one into
a team environment (a team credential *cannot* — CARLOS refuses team writes
of platform-managed keys). Under the CARLOS ruling (`team-scoped-credentials.md`
§3a, Paul 2026-10-27, "enforce in one place"), the platform's mail walk and
relay ops **mint a distinct mail credential and relay identity for each
team-owned environment** and write them there; releasing the environment
reaps them. The scan callback secret and the mail-events key are **not
delivered** to team environments.

## 4. What it stores

SQLite, sealed where marked:

- `teams` — label, sealed display name, team sqid, state; **every label ever
  used** stays (labels are never reused; Alta refuses a plan naming one).
- `owner_inputs` — **sealed** owner address; used for the credential plan,
  owner-seed and the stopgap allowlists (§5).
- `runs` / `steps` — the state machine (§6).
- `operator_requests` — **sealed** exact signed request bytes per Home
  operation, kept so a lost result is recovered by exact replay (and so the
  roster bearer is re-fetched by replay, never stored).
- `operator_streams` — per Home role: sequence and head; re-read through a
  signed `<role>.inspect` if Alta's DB is lost.

**Deleted at step 13** once `seed-team` has committed and every stopgap
allowlist is written: the `owner_inputs` row, the **credential plan** and
the **`owner-seed` request** rows (both contain the address; neither replay
is needed after the seed). After that Alta holds no address; the stopgap
allowlist edit for an unported app (`team-members.md` §7) has Paul retype
it, and Alta deletes it again once written.

**Never stored:** generated app keys (sealed to the console's
`secrets_pubkey` and sent; existence is checked by name), CARLOS tokens (env
only), roster bearers, team content; no log line carries an address, label,
key or platform value.

## 5. Per-app recipes

Each app gets an environment **owned by scope `alta`**, named `<team>` (for
`lagged`, `lagged-team`, §6). Owned environments are standalone, so **the
environment is the instance's entire config**: nothing reaches it from the
default bundle. Each key is one of: **GENERATED** by Alta (fresh keys),
**SET** by Alta (team values and env-kind, non-secret settings), or
**PLATFORM** — minted for this environment alone by a CARLOS walk, never
written by Alta. `audit` checks the environment holds exactly GENERATED ∪ SET
∪ PLATFORM; an extra key is a refusal.

Common to every app (`<P>` = DOCS, SHEETS, SLIDES, CALENDAR, CALLS,
MEMORIA):

| Key | Treatment |
|---|---|
| `<P>_ORIGIN` | SET `https://<team>.<app>.oficina.works` |
| `<P>_INSTANCE_KEY` | GENERATED |
| `<P>_HOME_ISSUER` | SET `https://id.oficina.works` |
| `<P>_HOME_CONSUMER_ID` | SET `<team>-<app>` (the directory record's consumer) |
| `<P>_HOME_KEYS_BASE64` | SET from Alta's pinned copy of Home's public assertion keys |
| `<P>_HOME_DEK_BASE64` | GENERATED |
| `HOME_DIRECTORY_ORIGIN` | SET `https://oficina.works` |
| `OFICINA_DASHBOARD_TEAM` | not set — team dashboards stay blank (Paul) |
| `<PREFIX>_SMTP_HOST/PORT/USER/PASS/FROM` | PLATFORM — the mail walk's per-environment credential, under the prefix the app declared to `carlos email` (`CARLOS` by default) |

Per app (allowlist = the owner's address only, until the app has roster
mode — `team-members.md` §7):

| App | GENERATED | SET | PLATFORM | Notes |
|---|---|---|---|---|
| Docs | `DOCS_CONTENT_KEY`; `DOCS_TEAM_ROSTER_TOKEN` (Home's bearer) | `DOCS_ALLOWED_ADDRESSES=""`; `DOCS_TEAM_ID`, `_DIRECTORY_ORIGIN`, `_PROVISIONING_BASE64` (signed record), `_OPERATOR_KEYS_BASE64` (directory provisioning public key) | `DOCS_SMTP_*` (Docs reads no `CARLOS_SMTP_*`, so its mail declaration must use prefix `DOCS` — a step-0 refusal otherwise); `DOCS_SAMPLE_DOCUMENTS` is SET only if Paul wants it | Team mode writes a fingerprint marker; no way back to allowlist mode |
| Sheets | `SHEETS_DEK` | `SHEETS_OWNERS`=owner | — | |
| Slides | — | `SLIDES_ALLOWED_ADDRESSES`=owner | — | **No uploads** (Paul: object storage not approved on the account); no `CARLOS_STORE_*`, so uploads answer 503 |
| Calendar | `CALENDAR_DEK` | `CALENDAR_ALLOWED_ADDRESSES`=owner | — | `CARLOS_CONTROL_SOCKET`/`ADMIN_TOKEN` are platform-set |
| Calls | `CALLS_DEK` | `CALLS_ALLOWED_ADDRESSES`=owner; `CALLS_ZONE`; `CALLS_QUALITY_REPORTS` | `CARLOS_RELAY` — the relay walk's per-environment identity | APNs vars are not read by `main.go`; not set |
| Memoria | `MEMORIA_DEK` | `MEMORIA_OWNERS`=owner; `MEMORIA_TEAM`=label; `MEMORIA_ORIGIN` | — | **AI off**: `MEMORIA_AI`, `MEMORIA_TENSORX_KEY`, `MEMORIA_SIBLINGS`, `MEMORIA_SIBLING_TOKEN_*`, `MEMORIA_ALLOW_LOGGED_MAIL` simply absent — nothing to blank now. Memoria boots without an origin, so `audit` checks it |

**AI for a team** stays off until that team's owner asks and Paul agrees;
TensorX's ZDR ruling (2026-09-19) covers Paul's data, not another owner's.

**Label regex.** Alta uses `^[a-z][a-z0-9-]{1,30}[a-z0-9]$`, deliberately
tighter than Home's `ValidLabel` (1–63), so every derived host
(`<label>-<app>.bds.oncarlos.com`, `<label>.<app>.oficina.works`) stays
well inside DNS limits.

## 6. The state machine

One **run** per (team, plan). Each step is **probe → act → verify →
record**; a crash resumes by probing; nothing is inferred from a timeout;
nothing is deleted to "clean up".

| # | Step | Probe | Act |
|---|---|---|---|
| 0 | Preflight | label regex; never used before; signed `inspect` on both roles (generation, stream heads); console: environment and instance absent, or already bound to this team's owned environment; **each app's mail is declared under the prefix it reads — `DOCS` for Docs — else refuse the run, naming the app** (a wrong prefix leaves the app silently without mail) | — |
| 1 | Initialize (first production run only) | `inspect` reports a generation? | **directory-only** `initialize` plan with Paul's typed baseline attestation (amendment §12); Paul confirms on `oficina.works/operator/confirm`; `directory.initialize` at directory sequence 1. The credential stream's first operation is later `owner-seed` at credential sequence 1 with `initial_authority`, which `Credential.Execute` admits |
| 2 | Plan | open window on both roles? | sign a plan per role **with one shared `plan_id`** (the directory's carries label and display name, the credential's the owner) and `POST /operator/v1/plan`; show Paul the two Home confirm links (`/operator/confirm`, no query) and the plan id's first 8 hex to match on both pages; poll each role's `inspect` until both windows are open |
| 3 | Owner | sealed receipt stored **and `expires_at` in the future**? | `credential.owner-seed` (`existing_only: true`); expired → a **new** operation |
| 4 | Team | team sqid stored? | `directory.seed-team` with the receipt (a taken label refuses here) |
| per app: | | | |
| 5 | Directory consumer | replay | `directory.provision-consumer` → signed record + bearer (pending) |
| 6 | Credential consumer | replay | `credential.register-consumer` **carrying step 5's record** |
| 7 | Environment | `GET /config?environment=<env>`: owned; GENERATED, SET **and PLATFORM** keys present by name | `PUT /config` with the recipe; **never regenerate** an existing key; for a **forked** environment, `unset` every non-platform key not in the recipe (Track 1's blanked `""` keys — `OFICINA_DASHBOARD_TEAM`, `MEMORIA_AI`, `CARLOS_STORE_*`, `MEMORIA_SIBLINGS`, …) before `audit` |
| 8 | Instance | `GET /instances/<team>-<app>.bds.oncarlos.com`: bound to `<env>` | `POST /instances {host, environment}` (socket-backed kind); 409 → probe; bound elsewhere → stop |
| 9 | Domain | `GET /domains`: `state` (never legacy `status`) | `POST /domains {host:<team>.<app>.oficina.works, route}`; poll to `state=live` (≤ 30 min, then park) |
| 10 | Serving | `/api/version` body on the public origin = the app's release, and `update_report.serving` agrees | `POST /restart/scope {host}` if config changed after start |
| 11 | Verify | roster-mode apps only | `directory.verify-consumer` (600 s); poll `GET /api/team` until `roster:"ok"` |
| 12 | Activate | roster-mode apps only | `directory.activate-consumer` with evidence (§7) |
| 13 | Audit | — | §5's exact-keys rule; delete §4's address-bearing rows |

**PLATFORM keys arrive on the walks' cadence, not at `PUT /config`.** Step 7
waits (parking if need be) until the PLATFORM names are present before step
8 creates the instance; step 10's restart-if-config-changed covers a
delivery that lands after the instance started.

Apps without roster mode stop after step 10 with their directory row
**pending** (not in the chooser — `roster-contract.md`), reachable at their
own URL with Home sign-in and the owner allowlist. When an app gains roster
mode, an **add-apps** run replays step 5 for the bearer and continues.

**Windows last 15 minutes and admit any number of in-scope operations.** A
run that parks (domains, cold starts) resumes under a new plan of kind
`add-apps` for the same label and apps, confirmed again on Home.

**Moving the `lagged` stopgap** (six instances bound to hand-made
environment `lagged`, which a record references and so can never become
owned): per app, Paul runs `carlos env fork --from lagged --to lagged-team
--scope alta` (copies only `lagged`'s own keys, so the DEKs Till's data is
sealed with survive; fork never carries `lagged`'s SMTP or relay keys);
the CARLOS walks mint `lagged-team`'s own mail and relay credentials; Alta's
step 7 sets its Home values; once every box is at the
CARLOS floor release, Paul rebinds each instance with `PATCH {environment:
lagged-team, scope: alta}`. Till's databases stay. Docs switching to team
mode then needs Till to **link** his local Docs account to his Home identity
(the existing account-link flow) or his Track 1 documents stay under the old
principal. Fallback if `env fork` is cut from the CARLOS slice: new hosts and
fresh keys, domains re-pointed, and Till's stopgap content is lost — Paul's
call at that point.

## 7. Activation evidence (step 12)

`ActivationEvidence` fields, with their encodings (`verification.go`):

- `app_version` — the token in `/api/version`'s body, exactly as Alta read
  it: every app stamps `git describe --tags --always`
  (`v0.1.0-63-gd867db1`, or a bare commit). Home admits any opaque,
  bounded, printable-ASCII token, `^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$`,
  and checks nothing more (`verification.go` `version()`). It was a
  40-hex commit until Fable's Alta review (oficina/alta discussion 1,
  mismatch ruling 5) ruled that a leftover of the platform-attestation
  design; stamping 40-hex into the apps instead was rejected, since it
  takes away the human version Paul reads to confirm a deploy.
- `artifact_digest` — base64url (no padding) of SHA-256 over the exact
  serving-build identifier string in the instance record's
  `update_report.serving`. It is a digest of the build's **name**, not of
  its bytes; Alta has no access to the artifact itself.
- `environment_binding` — base64url of SHA-256 over Alta's canonical recipe
  JSON for this instance: sorted key names, each with kind and the SHA-256 of
  its SET value (GENERATED and PLATFORM keys contribute their name and kind
  only; Alta never sees PLATFORM values).
- `credential_manifest_digest` — returned by step 6: base64url of SHA-256
  over Go `encoding/json.Marshal` of `["oficina/home/consumer-manifest/v1",
  [[id, origin], …]]`, entries sorted by unsigned UTF-8 byte order of
  consumer ID (the compatibility checker's definition).
- `alias_host` — step 9's host.

They mean "what Alta observed through the console", not a platform
attestation; the amendment §2 item 6 says so.

## 8. Guards in Alta's own code (defence in depth, not the fence)

- One console client refuses: an empty environment; an environment not
  owned per Alta's records; a host not `<label>-<app>.bds.oncarlos.com` or
  `<label>.<app>.oficina.works` for a label in `teams`; any DELETE outside a
  deprovision run. Mutation-tested.
- Logs carry step keys and fixed codes only.
- One run at a time (a lock row); Home serializes per role anyway.

## 9. Deprovisioning ("retire apps")

Probe-first, in order: `directory.disable-consumer` → 
`credential.retire-consumer` → `DELETE /domains/<team>.<app>.oficina.works`
(CARLOS does not detach a claim when its instance goes) → `DELETE
/instances/<host>`. What survives, stated on the confirm page: the parked
database replica (purged only by a CARLOS operator; the host cannot be
re-created until then), the owned environment (no delete verb exists), and
the Home team row, roster and label. **Labels and retired app hostnames are
never reused** (Paul, 2026-10-27; amendment §5). The confirm page names the
team, lists each app, and requires typing the label.

## 10. One-time setup (Paul, person-only)

1. When CARLOS ships team-scoped credentials and every box is at its floor:
   mint the six `team` credentials; `carlos secrets set --app alta`.
2. Confirm mail (with each app's declared prefix — `DOCS` for Docs) and,
   for Calls, the relay are enabled on the apps, so the CARLOS walks mint
   per-environment credentials. Alta is given no SMTP or relay value.
3. Per app zone: wildcard DNS `*.<app>.oficina.works` → the deployment, and
   per-name or wildcard certificates (check `CARLOS_HOST_CLAIM`; Alta uses
   explicit per-host attach).
4. Till signs in once at `https://oficina.works`.
5. Home: add `alta` as the 8th `HOME_CONSUMERS` entry; set
   `HOME_OPERATOR_HTTP` on both roles (credential role including the
   directory provisioning public key); enable the directory roster endpoint
   with its signing keys.
6. Give the amendment §12 pre-flight confirmation; Alta's first run is the
   `initialize` plan.
7. For `lagged`: `env fork` per app, then the explicit rebinds (§6).

## 11. UI sketch (estilo, scriptless)

```
 Alta                                                     [Paul ▾]
 ──────────────────────────────────────────────────────────────────
 Teams                                                  [New team]
   lagged   Lagged     6 apps   live 1 · pending 5       [Open]

 New team
   Label        [lagged      ]   → lagged.docs.oficina.works …
   Name         [Lagged      ]
   Owner email  [till@lagged.biz]   (must have signed in at oficina.works once)
   Apps         [x] Docs [x] Sheets [x] Slides [x] Calendar [x] Calls [x] Memoria
   [Submit plan to Home]

 Plan · lagged — confirm on Home
   1. Open oficina.works/operator/confirm   (label, apps)        ✓ open
   2. Open id.oficina.works/operator/confirm (retype the owner)  ◷ waiting
   docs   env lagged-team: set 12 · generate 4 · platform 5  [details]

 Run · lagged                                     refresh to update
   docs      ✓ consumer ✓ env ✓ instance ✓ domain ✓ serving ✓ live
   slides    ✓ … ◷ domain issuing-cert (12 min)          [Resume]
   memoria   ✓ … ✓ serving  · pending (no roster mode yet)
   [Audit]  [Retire apps…]
```

No live updates: plain GETs; refresh to see progress.

## 12. Tests before merge

Recipe: for each app, the environment equals the recipe exactly (an extra
key refuses); generated keys never regenerate; Alta's console client
refuses to set or unset any PLATFORM key (CARLOS refuses it too); a
PLATFORM value never appears in Alta's DB, logs or plan displays. State machine: crash injection after every act,
against a fake console and a real Home on a preview — resume reaches the
same end state with no duplicate instance, consumer or team; an expired
owner receipt leads to a new owner-seed, not a stuck step 4. Guards: §8
mutation tests. Privacy: no address after step 13 anywhere in Alta's DB
(scan for the canary owner address). End to end on previews: two synthetic
teams; each owner sees only their team; Paul's instances unchanged (config
digest before and after).

## 13. Still open

1. **Production gate:** CARLOS team-scoped credentials and their floor
   release (`carlos/platform` branch `team-scoped-credentials`), including
   `env fork` for the `lagged` move.
2. Alta's host (not ruled).
3. Paul's pre-flight confirmation (amendment §12).

## 14. Round-1 findings: disposition

Approval moved to Home (§2, §6 step 2). Provision before register, record
carried (§6 steps 5–6). Initialize as the first run (§6 step 1). Receipt
expiry probed (§6 step 3). `inspect` no longer claims label freedom (§6
step 0). Owner-seed request and credential plan rows deleted (§4). Activation
encodings (§7). Label regex tighter on purpose (§5). Sandbox never holds
production tokens (§3). Guards are defence in depth (§8). Calls repo named
(status). CARLOS round 1: standalone environments; `lagged` moves by fork +
explicit rebind (§6). **CARLOS round 2 (Paul's ruling on C):** the walks
mint per-team mail and relay credentials into owned environments; Alta holds
and copies no platform value; recipes mark those keys PLATFORM (§3, §5, §6,
§10).
**Round 2:** (relay exposure was recorded here, then withdrawn by Paul's
CARLOS ruling: Alta holds no platform credential — §3, §5); the stopgap allowlist edit
retypes the address (§4); `initialize` is directory-only and the credential
stream opens with `owner-seed` (§6 step 1); one `plan_id` across roles and
display name in the plan (§6 step 2); `artifact_digest` is a digest of a
name (§7). None declined.
**Round 3 (APPROVED, design):** forked environments unset Track 1's blank
keys before audit (§6 step 7); PLATFORM key timing (§6); Docs prefix is a
step-0 refusal (§5, §6).
