Design team provisioning, the Home operator endpoint and the Team page (design only, no code). Three implementation documents: team-provisioning-amendment.md (a narrow, signed /operator/v1 on each Home role reusing the operator engine, opened only by Paul's fresh confirmation on Home's own pages, a provenance fence, consumer registration derived from the directory's signed record, and a consumer registry beyond HOME_CONSUMERS' 16 entries); team-provisioning-app.md (Alta, the Paul-only provisioning app, holding only CARLOS team-scoped credentials and no platform secret); team-members.md (the Team page: all members read, owners write behind step-up, add-by-email resolved on the credential origin, sealed owner-chosen names, and the roster port order). Reviewed by Claude Fable 5.1 (claude-fable-5-1) across three rounds in discussion 92, APPROVED (design, round 3). Implements Paul's 2026-10-27 rulings: new people get their own team; ruling 8 re-ruled for Alta on condition of CARLOS team-scoped credentials; every run confirmed with a fresh sign-in; owners must already exist; labels and retired hostnames never reused. Not approved by this verdict: the handoff StartPath change, the CARLOS credential and its floor release, each implementation slice, and Paul's pre-flight confirmation.
Squashed from team-provisioning-design into main.
3 files changed,
+1,261
−0
implementation/team-members.md+343 −0implementation/team-provisioning-amendment.md+551 −0implementation/team-provisioning-app.md+367 −0
CI cancelled — superseded by a newer push — run details
landed from team-provisioning-design
diff --git a/implementation/team-members.md b/implementation/team-members.md| new file mode 100644 |
| index 0000000..240f4dd |
| --- /dev/null |
| +++ b/implementation/team-members.md |
| @@ -0,0 +1,343 @@ |
| +# 🤖 Team members: the Team page, and roster mode in every 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). Not approved by that verdict and gated separately: |
| +the shared `handoff` change (`ConsumerConfig.StartPath`) before the Team |
| +page; each slice (Team page, resolve, each app's roster port) — whole-code |
| +review, CI green, verified canary (amendment status, items 1 and 3). |
| +Base: Home origin/main `e2ec1ab`; Docs `d867db1`, Sheets `af8deeb`, Slides |
| +`ebbb08f`, Calendar `00d8e3d`, Calls (repo `oficina/meet`, `cmd/calls`) |
| +`47afcb9`, Memoria `521ae24`. |
| +**Paul's rulings, 2026-10-27, applied here:** owner-chosen member names, |
| +sealed, refusing `@`; unnamed members show role plus a short ref; **every |
| +member of a team sees its member list, only owners write**; no "you've been |
| +added" mail from Home (owners tell people); port order Sheets, Slides, |
| +Memoria, Calendar, Calls. |
| +**Implements** spec ruling 23, §10 (`memberships` "written only at the |
| +directory origin, by a team owner, behind a fresh-assertion step-up"), §14's |
| +step-up row, and gate 21. Companions: `team-provisioning-amendment.md` |
| +(seeds the first owner) and `team-provisioning-app.md`. |
| + |
| +--- |
| + |
| +## 1. Scope |
| + |
| +Part A: a **Team page** on `https://oficina.works` that shows a team's |
| +members to every member of that team and lets an owner add, remove, promote, |
| +demote and name them. |
| +Part B: the follow-on — **roster team mode** in Sheets, Slides, Calendar, |
| +Calls and Memoria, which only Docs has today. Until Part B lands for an app, |
| +that app ignores the Team page and keeps admitting by its own allowlist. |
| + |
| +## 2. The page |
| + |
| +- **Route:** `GET /team?team=<sqid>` (ruling 22: team views carry `?team=`). |
| + Linked from the springboard's account menu as "Team" when the signed-in |
| + person is on the selected team. |
| +- **Signed out:** an anonymous `GET /team?team=<sqid>` follows the chooser |
| + (`docs_chooser.go:142-154`): 303 to `/auth/start?return_to=…` with the |
| + query preserved (spec §5.6), so a shared team link survives sign-in. |
| +- **Who sees it:** a directory session whose subject has a `memberships` |
| + row (owner or member) for that team. **Everyone else signed in — a guest, |
| + a member of another team, a stranger, an unknown or malformed sqid — gets |
| + the same 404** as an unknown route (gate 4's pattern). **The page's own |
| + answers are never 403**; `csrf.Protect` and the host check, which run |
| + before the handler, keep their own codes. |
| +- **Who writes:** owners only. A member sees no write controls, and a |
| + member's POST to any write route gets the same 404 (gate 21). |
| +- **Reading needs a session; writing needs a fresh one (round 1, blocker |
| + 4; round 2, blocker 2).** The directory gains a **second |
| + `handoff.Consumer`** on the same `Store`, same `ConsumerID` (`directory`), |
| + with `RequireFreshAuth: true`, at its own start path |
| + **`/auth/fresh/start`**; `Callback` and `Finish` stay shared because they |
| + are store-level and the fresh requirement rides the pending row's path |
| + prefix. The existing consumer at `/auth/start` stays ordinary |
| + (`RequireFreshAuth` is per consumer, `handoff/http.go:139-141`). **This |
| + cannot be mounted on today's `handoff`:** `Start` calls `c.guard(w, r, |
| + http.MethodGet, StartPath)` and `guard` 404s when `r.URL.Path != path` |
| + (`handoff/http.go:70-80`, `:107`), with `StartPath` a package constant and |
| + no path field in `ConsumerConfig`. So it needs a **reviewed change to the |
| + shared `handoff` module**: `ConsumerConfig.StartPath`, defaulting to the |
| + constant, used by `Start`'s guard. **Sequencing:** that change, its tests |
| + and its review land first; the Team page and the directory operator |
| + confirm page (amendment §4) both depend on it and come after. The fresh |
| + consumer asks the issuer for `max_age=300` and enforces the five-minute |
| + window itself on finish. Every Team-page POST checks the directory session's |
| + `auth_time` is within 300 s and not in the future; if not, it renders the |
| + existing continuation page to |
| + `/auth/fresh/start?return_to=%2Fteam%3Fteam%3D<sqid>`, and the person |
| + repeats the action on return. The submitted change is **not** retained |
| + across the step-up (the chooser's expired-session rule). The same fresh |
| + consumer fronts the operator confirm page (amendment §4). |
| + `noscript_test.go`'s route list gains `/team`, `/team/add`, |
| + `/team/resolved`, `/team/confirm`, the role/name/remove POSTs and |
| + `/auth/fresh/start`. |
| +- **Inherited gap, stated:** `fresh-assertion.md`'s open rastrillo item |
| + applies. The fresh consumer's `max_age=300` makes the issuer refuse a |
| + Keymail session with no reported gesture; but a directory session minted by |
| + ordinary SSO from such a session inside the last 300 s carries |
| + `auth_time = At` and passes a directory-side freshness check. The page |
| + inherits that gap until rastrillo lets an assertion carry an absent |
| + `auth_time`, exactly as Docs linking does. Writes that arrive through |
| + `/auth/fresh/start` are not affected. **Recovery codes:** a recovery-code |
| + sign-in mints `AuthTime: now` (`passkey.go:28-39`) and no method claim |
| + rides the assertion, so a fresh exchange from such a session passes here. |
| + For the Team page that is accepted — recovery is a current credential. |
| + The directory operator confirm page inherits the same two gaps; the |
| + credential confirm page is where Paul's method is visible and refused |
| + (amendment §4 step 3). |
| +- **Scriptless.** Every action is a plain form POST with CSRF; estilo's |
| + `busy.js` is the only script, already on Home's closed list. |
| +- **Shape (estilo, Calma door rules — sky only on the team header):** |
| + |
| +``` |
| + Owner's view |
| + Oficina â–¾ Lagged [account â–¾] |
| + ─────────────────────────────────────────────────────────────────── |
| + Team [Add person] |
| + Till Owner added 27 Oct [Make member] [Remove] [Name] |
| + You Owner added 27 Oct [Make member] [Name] |
| + Member …k7q Member added 28 Oct [Make owner] [Remove] [Name] |
| + Changes reach every app in this team within a minute. |
| + |
| + Member's view: the same list, no buttons, and |
| + "Only owners can change who is on this team." |
| +``` |
| + |
| +## 3. Rules every write keeps |
| + |
| +1. **Owner only, re-checked inside the write transaction** (the page render |
| + is not authority). |
| +2. **Never zero owners.** Removing or demoting the last owner refuses with |
| + fixed copy. Without this a team's roster becomes unwritable and the only |
| + exit is the operator seed (§5.2's "operator reset in all but name"). |
| +3. **One membership row per (team, person).** Adding an existing member |
| + refuses with "already on this team"; role changes use their own button. |
| +4. **Epoch bumps** come from the existing `memberships_epoch_*` triggers; no |
| + second increment. Instances see a change within the roster lease |
| + (refresh due 30 s, hard expiry 60 s — `roster-contract.md`). |
| +5. **`added_at`** (round 1, blocker 5): `memberships` gains a **nullable** |
| + `added_at` (integer day, coarsened per §3.3), written by |
| + `directory.seed-team` for the first owner — its `INSERT INTO |
| + memberships(team_id,person_ref,role)` (`directory.go:254`) changes to |
| + write it, part of "verbs wrapped" — and by `/team/confirm`; pre-migration |
| + rows hold NULL and show no date. Additive migration |
| + `directorydata/migrations/0002_membership_added_at.sql`; gate 2's static |
| + half reads it. |
| +6. **Bounds:** 500 members per team (well inside the roster's 10,000 and |
| + 100-per-page limits; a number with a reason: a team page, not a |
| + directory). 30 writes per owner per hour. |
| +7. **Call 2 still cannot write `memberships`**, and nothing here changes |
| + that. |
| + |
| +## 4. Adding someone by email |
| + |
| +**The problem.** The owner knows an address. The roster keys on a person |
| +ref. Turning one into the other needs the pepper, which only the credential |
| +role holds (ruling 4), and `home-operator-seed.md` rules that *"the |
| +directory cannot request address resolution over HTTP."* The directory must |
| +also never see the address at all — it is the origin that renders |
| +account-authored strings and holds the roster. |
| + |
| +**The design: the browser carries the owner to the credential origin, which |
| +resolves and signs.** The address is typed on `id.oficina.works`, never on |
| +`oficina.works`. |
| + |
| +1. **Directory, `POST /team/add` (owner, fresh).** Stores an add-intent row: |
| + hash of a random 32-byte intent id, team id, requester person ref, chosen |
| + role, sealed optional display name (§5), expiry 10 minutes. 303s (via |
| + the continuation page) to |
| + `https://id.oficina.works/resolve?consumer=directory&intent=<id>`. |
| +2. **Credential, `GET /resolve`.** Requires a complete credential session. |
| + Renders fixed copy only — "Enter the email address of the person to |
| + add" — **no team name, label or sqid on the page** (origin separation, |
| + gate 5). The intent id rides a sealed `__Host-` cookie, as `/authorize` |
| + does. |
| +3. **Credential, `POST /resolve`.** Normalizes and blind-indexes with the |
| + sign-in helper; finds the person, or mints a person stub as spec §6 |
| + describes for a never-signed-in guest, using the helper that exists, |
| + `findOrMintPersonOn` (`links.go:156`) — call 2, which §6 names, is not |
| + implemented. Rate limited: 20 per subject per |
| + hour, plus the existing per-IP budget. Signs a **member-resolution |
| + receipt**: `{v, purpose:"member-resolve", iss, aud:<directory>, |
| + requester:<session sub>, intent, person_ref, iat, exp ≤ 120 s, jti}` with |
| + a new dedicated P-256 key (private half `HOME_RESOLVE_KEY` on the |
| + credential role only) under context `oficina/home/member-resolve/v1`. The |
| + directory pins the public half as **`HOME_RESOLVE_PUBLIC_KEY`** — a fourth |
| + pinned key beside `HOME_ASSERTION_KEYS`, the operator key and the roster |
| + keys — and it joins `NewDirectory`'s key-inequality set. Auto-POSTs it to the directory with the |
| + existing handoff page (static script, Continue button with script off). |
| + The address is dropped. **The response never says whether the person |
| + already existed.** |
| +4. **Directory, `POST /team/resolved`.** Verifies the receipt (key, context, |
| + `aud`, expiry, single-use `jti` in its own store), loads the intent by |
| + hash, and requires `requester` = intent requester = current directory |
| + session subject. Like the assertion callback it does **not** write here: |
| + it stores the verified result in the sealed inbox and 303s to |
| + `GET /team/confirm`. |
| +5. **Directory, `POST /team/confirm`** (same-origin, CSRF, still fresh): |
| + re-checks owner, writes `(team, person_ref, role)` and the sealed name in |
| + one transaction, deletes the intent. Done. |
| + |
| +**Telling the person: Home sends nothing** (Paul, 2026-10-27). The owner |
| +tells them; the confirm page says so: "Let them know — they sign in at |
| +oficina.works." Rejected: a fixed "you've been added" mail from the |
| +credential role. |
| + |
| +**What this costs the one rule.** Nothing new at rest: the address is |
| +transient on the credential role, as on every sign-in; the directory holds a |
| +person ref, as it does for every member. Gate 2 gains a fifth path (resolve) |
| +that receives an address and must leave none readable, WAL included. |
| + |
| +## 5. What the page shows — RULED 2026-10-27 by Paul |
| + |
| +**Owner-chosen display names, sealed at rest; a member without one shows |
| +role plus a short ref** ("Member …k7q"). Rejected, recorded so they are not |
| +re-proposed: refs only (unusable past a few people); a name each person sets |
| +for themselves suite-wide (a new per-person preference, §8 keeps that set |
| +small); addresses pulled from the team's instances and rendered in RAM |
| +(grows Home, and Home-only members have no address in any instance); an |
| +address kept by Home (forbidden by the one rule). |
| + |
| +**Storage.** `membership_names(team_id, person_ref, sealed_name, |
| +updated_at day)` in the directory DB, FK to `memberships` with |
| +`ON DELETE CASCADE`, sealed with the existing ID-bound helper under a new |
| +purpose (`directory.member-name/v1/<team id>/<person ref>`). 1–64 UTF-8 |
| +bytes; **any value containing `@` is refused** with a field hint saying why, |
| +so a name is not quietly an address. A determined owner can still type |
| +"till at lagged dot biz"; it is sealed, so it is not *readable at rest* — |
| +the rule's test. Set when adding (optional) or later via [Name]; owners |
| +only; deleted with the membership row. Names never ride an assertion, call |
| +8, a log or an error string. |
| + |
| +**Spec text this changes:** §3.2's "Sealed" list gains "member display |
| +names"; §10's data-model list gains `membership_names` and |
| +`memberships.added_at`; the README's published list says owners can name |
| +members. Gate 2's static half reads the `membership_names` migration |
| +(`directorydata/migrations/0003_membership_names.sql`) and asserts the name |
| +column is a sealed BLOB. |
| + |
| +## 5a. Every member sees the list — RULED 2026-10-27 by Paul |
| + |
| +**Checked against the rules:** |
| + |
| +- **The one rule** (no readable address at rest, retains nothing from an |
| + instance): untouched. The list is rendered from the roster and the sealed |
| + names — Home's own records, not instance content — and nothing is added at |
| + rest beyond §5's sealed column. |
| +- **§2.2's "only to that person" / "no operator view"** governs content an |
| + *instance* hands Home; the roster is not that. The closest honest analogue |
| + is applied anyway: the list is rendered **per request, only to a person |
| + who is on that team**, and never to anyone else — no operator view, no |
| + cross-team view, no export, no API. A guest, a member of another team or |
| + Paul as operator gets 404 like any stranger. |
| +- **Never cross a team:** the query is keyed on the requested team and the |
| + viewer's own membership in it; gate 4 tests the cross-team case. |
| +- **Never a support console:** no path renders another team's list. |
| + |
| +**The privacy cost, stated plainly:** every member learns **who else is on |
| +the team, who the owners are, when each was added, and the name an owner |
| +chose for each person** — including names the named person never saw or |
| +agreed to. An owner's private note used as a name ("Till – contractor, leaving March") |
| +is published to the whole team. The field hint says so: "Everyone on this |
| +team sees this name." Before this ruling only owners learned the roster |
| +from Home; members could already infer much of it from shared items in the |
| +instances, but not owner status or names. |
| + |
| +## 6. Gates |
| + |
| +- **Gate 21** — every write requires a fresh assertion (`auth_time` 301 s |
| + refuses; future refuses); call 2 cannot write `memberships` or names; a |
| + write naming a team the caller does not own answers the same 404 as an |
| + unknown team; a member (non-owner) can GET the list but gets 404 on every |
| + POST, and the page renders no write control for them. |
| +- **Gate 4** — a member of Acme opening `/team?team=<beta>` gets 404; a |
| + guest of `acme.docs` (no roster row) gets 404 on Acme's list. |
| +- **Gate 2** — resolve path extended; names containing `@` are refused, and |
| + canary names appear only as ciphertext in the file, WAL and SHM. |
| +- **Gate 5** — `/resolve` renders no account-authored string (scan with a |
| + canary team name and member name present in the directory). |
| +- **Gate 9** — no address, member name, team name or person ref fragment in logs. |
| +- **Step-up route** — a stale-session POST renders the continuation to |
| + `/auth/fresh/start`; an assertion through it with `auth_time` 301 s old is |
| + refused at finish; the ordinary `/auth/start` consumer is unchanged. |
| + Anonymous `GET /team?team=<sqid>` 303s to `/auth/start` with the query |
| + preserved. |
| +- **`added_at`** — seed and confirm write a day value; pre-migration rows |
| + render no date; gate 2's static half covers both new migrations. |
| +- **Last-owner** — remove/demote the sole owner refuses; with two owners, |
| + either may leave. |
| +- **Cross-origin** — receipt replay, wrong `aud`, wrong requester (another |
| + owner's session), expired intent, a receipt for team A confirmed into team |
| + B, and a directory-only attacker (no credential session) all fail. |
| + |
| +## 7. Part B — roster mode in the other five apps |
| + |
| +**What Docs already does** (`internal/docs/team_config.go`, |
| +`team_access.go`, `teamstate`): `DOCS_TEAM_ID`, `_DIRECTORY_ORIGIN`, |
| +`_PROVISIONING_BASE64`, `_OPERATOR_KEYS_BASE64`, `_ROSTER_TOKEN` (all or |
| +none, and only with `DOCS_HOME_*`); a verified provisioning record; the |
| +`home/roster` cache; tri-state admission (Member / NotMember / Unknown); |
| +grant-only query mode when not a member; lease re-check before every commit |
| +and stream event; a fingerprint marker that refuses to boot back into |
| +allowlist mode. Each port copies that shape with `<APP>_TEAM_*` names and |
| +the same five variables. Shared code to extract first: a small |
| +`home/teammode` helper (config parse, record verification, admission |
| +middleware, fingerprint marker) so five apps do not re-implement Docs' |
| +`team_config.go`. Then per app: |
| + |
| +| App | Admission today | Port work beyond the shared helper | Hard part | |
| +|---|---|---|---| |
| +| Sheets | `SHEETS_OWNERS` (everyone is co-owner) | Member = the team rung; grant-only mode for any per-sheet sharing; close live edit channels at lease expiry | None special | |
| +| Slides | `SLIDES_ALLOWED_ADDRESSES` | As Sheets. Team instances ship **without uploads** (no object storage on the account); when storage arrives, cap presigned GETs at the lease ceiling (60 s) | Asset URLs outliving removal, later | |
| +| Calendar | `CALENDAR_ALLOWED_ADDRESSES` | Published `.ics` feed tokens stay capability links (like Docs public links) and need an owner revoke; reminders need an address | Home-only members have no address in the instance — reminders need an in-app "email for reminders" the instance stores (ruling 5 allows instances to) | |
| +| Calls | `CALLS_ALLOWED_ADDRESSES` | Check standing at room join and on every signaling reconnect; close the signaling socket at lease expiry | Native Mac/iOS clients assume one host; they need a team-host picker and Home sign-in | |
| +| Memoria | `MEMORIA_OWNERS` | Grant-only mode applies to search results and the AI answer's sources; sibling calls already bind to `MEMORIA_TEAM` hosts | AI stays off unless the team owner asks and Paul agrees (see `team-provisioning-app.md` §5) | |
| + |
| +**Order — RULED 2026-10-27 by Paul:** Sheets, Slides, Memoria, Calendar, |
| +Calls. Calls last because of native clients and live media. |
| + |
| +**Until an app is ported**, its `lagged` instance runs Home sign-in plus its |
| +own allowlist holding only the owner's address (Track 1). Alta registers it |
| +as a credential consumer so Home sign-in works, but leaves its directory |
| +`team_instances` row **pending**: `roster-contract.md` forbids marking an |
| +instance live in the chooser before TeamMode passes its gates. Adding someone |
| +on the Team page therefore does nothing in that app until it is ported; |
| +Alta's per-instance allowlist edit (Paul only, retyping the address — Alta |
| +keeps none after a team is live) is the stopgap. |
| + |
| +**Acceptance per port:** Docs' existing roster test list (two teams, removal |
| +within 60 s under failing refresh, grant-only vs owner shortcut, stream |
| +closure, fingerprint lock-in), plus a readiness probe `GET /api/team` |
| +returning only `{team_mode, consumer, roster:"ok"|"stale"|"unknown"}` for |
| +Alta's activation evidence. Full app CI, top-model review, verified canary. |
| + |
| +## 8. Not in this design |
| + |
| +Guests (unchanged: instance grants, `kind = guest`); per-team 2FA floor |
| +(§14); ownership transfer as its own verb (promote + leave covers it); |
| +invitations that wait for acceptance (membership is immediate; standing |
| +does nothing until the person signs in); suite-wide sign-out. |
| + |
| +## 9. Still open |
| + |
| +Nothing for Paul in this file; all four questions were ruled on 2026-10-27 |
| +(names, no mail, members read, port order). Round-2 review is owed on §2 and |
| +§5. |
| + |
| +## 10. Round-1 findings: disposition |
| + |
| +Blocker 4 (no route to start a step-up; "no 403 anywhere") → §2: a second |
| +`handoff.Consumer` with `RequireFreshAuth` at `/auth/fresh/start`, named in |
| +the noscript route list; anonymous GET follows the chooser; 403 claim |
| +narrowed to the page's own answers. Blocker 5 (no `added_at`) → §3 rule 5, |
| +§5 spec-text list. Notes: `findOrMintPersonOn` cited (§4 step 3); freshness |
| +gap inherited and stated (§2); `HOME_RESOLVE_PUBLIC_KEY` pinned and in the |
| +inequality set (§4 step 3); `membership_names` in §10 and gate 2 (§5); |
| +Calls repo named (status). **Round 2:** blocker 2 (fresh consumer not |
| +mountable) → §2: reviewed `handoff` change (`ConsumerConfig.StartPath`), |
| +guard cited, sequenced first; recovery-code acceptance stated and |
| +cross-referenced; `added_at` nullable and the seed INSERT change (§3); the |
| +stopgap allowlist edit retypes the address (§7). None declined. |
diff --git a/implementation/team-provisioning-amendment.md b/implementation/team-provisioning-amendment.md| new file mode 100644 |
| index 0000000..938c6b6 |
| --- /dev/null |
| +++ b/implementation/team-provisioning-amendment.md |
| @@ -0,0 +1,551 @@ |
| +# 🤖 Amendment: the operator endpoint (teams without the maintenance worker) |
| + |
| +**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 round 1 |
| +(CHANGES REQUIRED, 5 blockers) and round 2 (CHANGES REQUIRED, narrow, 3 |
| +blockers); round 3's six non-blocking notes are applied (§13). |
| +**Not approved by this verdict, and needing its own review before the code |
| +it gates** (Fable, round 3, verbatim): |
| +1. The shared `handoff` change (`ConsumerConfig.StartPath`) — before the |
| + Team page and both confirm pages. |
| +2. `carlos/platform` `team-scoped-credentials` (discussion 449) and its |
| + floor release — before Alta reaches production (Paul's condition on |
| + ruling 8). |
| +3. Each implementation slice (operator HTTP transport, ceremony pages, |
| + consumer registry and CSP, new verbs, Team page, resolve, each app's |
| + roster port, Alta) — whole-code review, CI green, verified canary, per |
| + AGENTS.md "Shipping cadence". |
| +4. Paul's §12 pre-flight confirmation before the first production |
| + `initialize`. Direction approved in principle by Paul, |
| +2026-10-27: "the provisioning app creates teams, owners and consumer |
| +registrations through a narrow, authenticated Home endpoint, instead of the |
| +blocked platform-117 maintenance worker." |
| +**Paul's rulings, 2026-10-27, applied here:** two-key approval on every run; |
| +ruling 8 re-ruled for Alta, conditional on CARLOS team-scoped credentials; |
| +the owner must already exist (`existing_only`); team labels are never reused. |
| +**Base:** origin/main `e2ec1ab`. Companions: `team-provisioning-app.md` (the |
| +caller, **Alta**) and `team-members.md` (the Team page). |
| + |
| +--- |
| + |
| +## 1. What changes |
| + |
| +Every operator verb in `internal/operator` runs today only inside a platform |
| +maintenance worker that does not exist (platform discussion 117). This |
| +mounts **the same engine** behind one HTTP route per Home role, callable only |
| +by one pinned external signer (Alta), and only inside an approval window that |
| +**Paul opens on Home itself**, after a fresh sign-in, against Home's own copy |
| +of the plan. The engine is unchanged; **the verbs are wrapped** (a window |
| +check, and on the directory a provenance fence, inside each mutation). It |
| +adds consumer registration and retirement verbs and a stream read, and moves |
| +the credential consumer list out of the 16-entry `HOME_CONSUMERS` env var |
| +into the credential database. **Home still holds no platform credential** |
| +(spec §7's load-bearing fact): Alta creates instances; Home records facts |
| +about its own resources. |
| + |
| +## 2. Approved text this supersedes (quoted) |
| + |
| +Each quoted file gains a one-line pointer here when this lands. |
| + |
| +1. `home-provisioner.md`: *"Implement a separate local Go command, |
| + `oficina provision`, callable directly by a human. … Every maintenance |
| + mutation still requires its actual browser session, CSRF, current |
| + account-owner lookup and `requireFreshAuth`."* — Replaced by §4. |
| +2. `home-provisioner.md`: *"The fixed operator entry point is enabled only |
| + for maintenance execution of the immutable configured release. Normal |
| + HTTP startup does not expose it. Tests must prove direct app requests |
| + cannot invoke it."* — Replaced: HTTP startup exposes `/operator/v1` |
| + **only when** `HOME_OPERATOR_HTTP` is configured (§3). |
| +3. `home-provisioner.md`, "Registry custody and persistence": *"Init creates |
| + random device and registry IDs plus signing/encryption keys, and stores |
| + the keys only in an age scrypt-encrypted credential file … The |
| + independent floor backend writes signed immutable sequence/head files"* |
| + and its two-phase floor CAS. — Replaced by Alta's sealed SQLite plus |
| + **Home's per-role stream head as the rollback arbiter**: Home refuses any |
| + sequence that is not previous + 1, so a rolled-back Alta is refused and |
| + resynchronises through `<role>.inspect` (§5). |
| +4. `home-operator-seed.md`: *"Platform discussion 117 owns stopping traffic |
| + and all background work, holding the database lease … The command never |
| + starts an HTTP server, sends mail or makes network calls."* — Replaced |
| + for this path; the engine serializes with `BEGIN IMMEDIATE` on the |
| + serving process's own writer, so `home-operator-open.md`'s |
| + fenced-identity proof is moot here. |
| +5. `home-operator-seed.md`: *"The invocation must be authorized outside the |
| + request. … The platform must provide an authenticated invocation context |
| + or equivalent private launch configuration before command wiring is |
| + approved; an environment boolean supplied by the caller is |
| + insufficient."* — Replaced by §4: Alta's pinned signature **and** a |
| + window Paul opened on Home, with the pins in reviewed |
| + `HOME_OPERATOR_HTTP` configuration. |
| +6. `home-operator-seed.md`: *"The verified operator context must attest |
| + successful exact-host/body/header build verification, assertion |
| + registration, isolated instance database/config, and the reviewed |
| + TeamMode acceptance gates. A string supplied by the request is not that |
| + attestation."* — **Weakened, said so:** on this path |
| + `ActivationEvidence` is Alta's signed observation through the CARLOS |
| + console plus the credential role's registry digest |
| + (`team-provisioning-app.md` §7), not a platform attestation. |
| +7. `roster-contract.md`: *"This module … adds no public bootstrap route and |
| + no runtime operator mutation transport. Live provisioning/restore remains |
| + gated on supported fenced maintenance (platform discussion117) or a |
| + separately reviewed genuinely fresh first-boot path."* — This file is |
| + that transport, **for provisioning only; restore stays gated**. |
| +8. `home-provisioner.md` step 6: *"Register the exact consumer with |
| + credential Home by updating its bounded immutable HOME_CONSUMERS manifest |
| + … stop at the bound. Scalable registration is separate work."* — |
| + Replaced by §7. |
| +9. `team-entry.md`: *"No request can register or alter a consumer."* and |
| + *"pilot bootstrap is not a web administration endpoint."* — Narrowed: one |
| + signed, Paul-approved request type registers or retires a consumer; no |
| + browser request can. |
| +10. `directory-runtime.md`: *"There is currently no exported network writer |
| + that can mark an instance live."* — Now there is exactly one (§5). |
| +11. Spec §10: the first owner is *"seeded by the drain with the person the |
| + sealed queue payload §7 already carries."* — Widened: the owner may also |
| + come from an **operator-authored plan**. The signup queue is untouched |
| + and still drained by a human. |
| + |
| +**Rulings this touches:** |
| + |
| +- **Ruling 8 — RE-RULED for Alta by Paul, 2026-10-27.** Its Rejected column |
| + read *"A standing console token in a web-facing app."* Its reason (§7) — |
| + an RCE on Home's sign-in surface must never reach instance creation — |
| + still holds: Home holds no CARLOS credential. Re-ruling, to be added to |
| + spec §1 as its own row: **a web-facing app other than Home (Alta) may hold |
| + CARLOS credentials, on condition that CARLOS gains team-scoped |
| + credentials** that act **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 reach. CARLOS design: `carlos/platform` branch |
| + `team-scoped-credentials` (role `team`). |
| +- **Ruling 7** is unaffected: Alta is the human gate and never auto-drains |
| + the signup queue. |
| + |
| +**Not superseded:** §0; §2.2's four never-dos; ruling 4 (pepper on the |
| +credential role only); ruling 19; ruling 23; `home-operator-seed.md`'s |
| +*"The directory cannot request address resolution over HTTP."* |
| + |
| +## 3. Where it lives and how it is switched on |
| + |
| +- **Routes, per role, each on its own origin** (`id.oficina.works` for |
| + credential verbs, `oficina.works` for directory verbs): |
| + `POST /operator/v1` (signed operation or signed inspect challenge), |
| + `POST /operator/v1/plan` (Alta submits a signed plan, §4), |
| + `GET` + `POST /operator/confirm` (Paul's browser, §4; no query — one |
| + pending plan per role). |
| +- **Off unless configured.** `HOME_OPERATOR_HTTP` (JSON ≤ 8 KiB, closed |
| + fields) per role: `version`, `role`, `origin`, `installation`, `registry`, |
| + `device`, `public_key`, `key_id`, `actions` (≤ 8), `operator_subject` |
| + (Paul's person ref), `prefilter_token_sha256`; **credential role also** |
| + `directory_provisioning_public_key` (the directory's |
| + `oficina/roster/provisioning/v1` key, which the credential role pins for |
| + the first time — §5). Absent → no route mounted (404 like any unknown |
| + path). Malformed → boot refuses. |
| +- **Separate keys.** Alta's key differs from the assertion, owner-seed, |
| + directory-provisioning, roster and resolve keys (`NewDirectory` / |
| + `NewCredential` already refuse equality; the HTTP loader extends it). |
| +- **`allowedAction`** (`protocol.go:130-141`) is a closed switch and grows: |
| + `credential.register-consumer`, `credential.retire-consumer`, |
| + `credential.inspect`, `directory.disable-consumer`. |
| + |
| +## 4. Authentication: Alta's key and Paul's confirmation on Home |
| + |
| +An operation is accepted only if **all** hold, in order, before any write: |
| + |
| +1. **Not a browser.** Refuse `Cookie`, `Origin`, `Sec-Fetch-*`. No CORS. |
| + `application/json`, ≤ 64 KiB, read with a hard limit before parsing. |
| +2. **Prefilter bearer** (32 bytes, SHA-256 constant-time compare) — a DoS |
| + filter, **not authority**. |
| +3. **Alta's signature** — `Verifier.Verify`, unchanged: pinned P-256 key, |
| + context `oficina/home/operator-input/v1`, ≤ 300 s, exact |
| + role/origin/installation/registry/device, sequence = previous + 1. |
| +4. **An open window on this role admitting the verb and its input** (below). |
| + |
| +**The ceremony (round 1, blocker 1 — option (b); round 2, blockers 1 and |
| +3).** |
| + |
| +**Sequencing prerequisite.** Step 2 needs the directory's fresh-only |
| +consumer, which needs a **reviewed change to the shared `handoff` module** |
| +(`team-members.md` §2: today `guard` 404s any start path but the |
| +`StartPath` constant, `handoff/http.go:70-80`, `:107`). That change and its |
| +review land **before** the directory confirm page and the Team page. |
| + |
| +1. **Alta submits a plan to each role**, `POST /operator/v1/plan` (same |
| + transport checks 1–2), signed by Alta's key under context |
| + `oficina/home/operator-plan/v1`. **Both roles' plans carry the same |
| + `plan_id`** (32 random bytes), plus `role`, `kind` (`initialize` | |
| + `create-team` | `add-apps` | `retire-apps`), `apps` (registry slugs), |
| + `issued_at`, `expires_at` (≤ 900 s). The **directory** plan adds `label` |
| + and `display_name` (round 2: so a compromised Alta cannot choose the |
| + team's name after Paul confirms); the **credential** plan adds `owner`. |
| + **Home verifies the signature, extracts the closed fields, and never |
| + persists the signed plan bytes or the address.** Directory writes |
| + `plan_id`, `kind`, `label`, `apps`, `expires_at`, the display name |
| + **sealed** (the team-name helper). No digest of the name is kept (round |
| + 3): `seed-team` opens the seal inside its transaction and compares bytes. Credential blind-indexes `owner` with `findOrMintPersonOn`'s |
| + normalisation (`links.go:156`, existing-only lookup) and writes |
| + `plan_id`, `kind`, `apps`, `owner_index`, `expires_at`. One pending and |
| + one open plan per role; a further submit refuses until the pending one is |
| + confirmed or expires (**up to 15 minutes; no cancel verb** — a convenience |
| + we skip). **Expired and refused plan rows are deleted** (`secure_delete` |
| + is on), so a blind index for a never-confirmed plan does not linger. |
| +2. **Paul's browser confirms on the directory**: |
| + `https://oficina.works/operator/confirm` — **no query**; the page shows |
| + the role's one pending plan. It sits behind the directory's fresh-only |
| + consumer (`/auth/fresh/start`, `team-members.md` §2): a session whose |
| + `auth_time` is older than 300 s or in the future goes through the fresh |
| + exchange first and returns to `/operator/confirm`. Subject ≠|
| + `operator_subject` → 404. The page renders **Home's copy**: the first 8 |
| + hex of `plan_id`, kind, label, display name, each app as |
| + `<label>.<app>.oficina.works`, expiry. [Open window] POST — inside the |
| + directory's CSRF group — re-checks subject, freshness and plan expiry |
| + **inside the write**, then opens the directory window for 15 minutes. |
| + **Inherited gap:** the directory session carries no sign-in method, so a |
| + recovery-code session and the Keymail no-gesture case of |
| + `team-members.md` §2 pass here exactly as they pass the Team page; the |
| + credential page below is where the method is visible and refused. |
| +3. **Then on the credential origin**: `https://id.oficina.works/operator/confirm` |
| + — **no query**, the role's one pending plan. `/operator/confirm` joins |
| + `credentialReturn`'s closed list (`signin_return.go:12-17`, exact paths, |
| + no query). On **GET and POST** it requires: subject = `operator_subject` |
| + (else 404); `sessions.Fresh(300)`; no future `auth_time`; not |
| + `keymailWithoutGesture`; and **`Method` not containing `recovery`** (Paul, |
| + round 2: recovery codes mint `AuthTime: now`, `passkey.go:28-39`, so they |
| + would satisfy any freshness window; this page refuses them). **A stale |
| + session** gets a sealed **fresh intent** written before the redirect to |
| + `/signin` — `assertionIntent{MaxAge: 300, Subject: operator_subject}` with |
| + a reserved consumer value and a **random nonce** (`readAssertionIntent` |
| + requires `handoff.ValidNonce`, `assertion_intent.go:34`, and does not |
| + validate `Consumer`) — which `handleSigninBegin` and the Keymail callback |
| + already honour (`signin.go:245-247`, `:356-358`), so the sign-in forces a |
| + real gesture (magic link, or Keymail `prompt=login`) instead of looping. |
| + `/operator/confirm` consumes the intent on return, **clears the cookie** |
| + (today only `handleAssertion` does, `exchange.go:110`), and re-checks |
| + everything above. The reserved consumer value can never reach an |
| + assertion: `handleAssertion`'s consumer lookup refuses it. **The page renders no account-authored string** (gate |
| + 5): the first 8 hex of `plan_id` (the same plan Paul just opened on the |
| + directory), kind, app registry names (compiled constants), expiry, the |
| + first 8 hex of `owner_index`, and "Type the owner's email to confirm". |
| + The POST — inside the credential CSRF group (`app.go:199`) — re-checks |
| + subject, freshness, method and expiry **inside the write**, and opens the |
| + window only if the typed address blind-indexes to `owner_index`. |
| + |
| +**Order is advice, not enforced.** Paul is told directory first, then |
| +credential; nothing breaks if he reverses it. An `initialize` plan is |
| +directory-only. |
| + |
| +**Mounting.** `/operator/v1` and `/operator/v1/plan` are mounted outside |
| +`csrf.Protect` and before `sessions.Middleware` on both routers, as |
| +`handoff.CallbackPath` is (`directory.go:77`); the no-`Cookie` refusal makes |
| +session middleware a no-op there anyway. `/operator/confirm` is the |
| +opposite: inside each role's session and CSRF groups. |
| + |
| +**Nonce and `BindStart`.** Round 0's raw-assertion forwarding is removed: |
| +Home never receives an assertion from Alta, so nothing binds a plan to an |
| +assertion nonce (round 1 found it unbuildable: `handoff.Store.Finish` hands |
| +`Complete` parsed claims and deletes the token, `handoff/http.go:206-230`). |
| +Alta's own Home sign-in is an ordinary consumer. |
| + |
| +**Window semantics.** A window admits **any number** of operations whose |
| +verb is allowed for its `kind` (§5) and whose input is inside it, until it |
| +expires; it never widens or extends. Directory: label matches, app ∈ `apps`, |
| +and `seed-team`'s `display_name` equals, byte for byte, the plan's sealed |
| +display name (opened inside the transaction). |
| +Credential: `owner-seed`'s address blind-indexes to `owner_index`; |
| +`register-consumer`'s record app ∈ `apps`. **An expired owner receipt needs a |
| +new `owner-seed` operation** under a live window — replay returns the same |
| +expired receipt by design (`credential.go:66`, `home-operator-seed.md` |
| +"never renews authority"). No `Oficina-Plan` header: one open window per role |
| +makes it redundant. |
| + |
| +**The owner must already exist** (Paul, 2026-10-27): over this endpoint |
| +`owner-seed` accepts only `existing_only: true`; an unknown address refuses |
| +and mints no stub. |
| + |
| +**Why this shape.** Alta's key alone cannot act without Paul confirming on |
| +Home; Paul's confirmation is of **Home's copy** of the plan, so a compromised |
| +Alta cannot show him one plan and execute another. What remains: Paul |
| +approves the plan Alta submitted — a compromised Alta can submit a plausible |
| +one and hope he confirms it. §8 bounds that. |
| + |
| +**Not an operator view.** The confirm pages show the operator's own plan, |
| +not anyone's data; they render only to `operator_subject`. They do grow Home |
| +by two pages; that is the cost of not trusting Alta's rendering. |
| + |
| +## 5. Verbs, windows and fences |
| + |
| +| Role | Verb | Kinds | Status | |
| +|---|---|---|---| |
| +| credential | `credential.owner-seed` (existing-only) | create-team | wrapped | |
| +| credential | `credential.register-consumer` | create-team, add-apps | **new** | |
| +| credential | `credential.retire-consumer` | retire-apps | **new** | |
| +| credential | `credential.inspect` | any (no window) | **new** | |
| +| directory | `directory.initialize` | initialize | wrapped | |
| +| directory | `directory.inspect` (+ stream) | any (no window) | **extended** | |
| +| directory | `directory.seed-team` | create-team | wrapped | |
| +| directory | `directory.provision-consumer` | create-team, add-apps | wrapped | |
| +| directory | `directory.verify-consumer` | create-team, add-apps | wrapped | |
| +| directory | `directory.activate-consumer` | create-team, add-apps | wrapped | |
| +| directory | `directory.disable-consumer` | retire-apps | **new** | |
| + |
| +- **`credential.register-consumer` is derivative of a fenced directory |
| + write (round 1, blocker 2).** Its input is the directory's **signed |
| + provisioning record** from `directory.provision-consumer` |
| + (`directory.go:307-314`, context `oficina/roster/provisioning/v1`). The |
| + credential role verifies it with the pinned |
| + `directory_provisioning_public_key`, checks `issuer` = itself and |
| + `directory` = the configured directory, requires the record's app ∈ the |
| + window's `apps`, and registers **exactly** the record's consumer ID and |
| + audience. Mechanics: `roster.VerifyProvisioning(record, keys, binding)` |
| + takes the *expected* bindings, so the verb first parses the record's |
| + claimed consumer, app, team and audience, fixes `issuer` and `directory` |
| + to the pinned values, verifies with those, and registers only what |
| + verified. The audience was produced by the directory's `ValidateRoute` |
| + against the team's own stored label, under the provenance fence. Collision |
| + is checked against **`HOME_CONSUMERS` ∪ table**, on ID and origin. Returns |
| + the registry digest (§7). So Alta's order is provision first, register |
| + second. |
| +- **What the credential role sees.** It never sees labels in its plans any |
| + more; it sees hostnames only inside verified directory records. What it |
| + cannot know is whether a label is taken — that is the directory's fence, |
| + and the record is the only path in. |
| +- `credential.retire-consumer` — marks a table consumer `retired`; |
| + `/authorize` and sign-out refuse it. `origin` stays UNIQUE, so **a retired |
| + app hostname is dead at Home for good** — the same rule as labels never |
| + being reused (Paul, 2026-10-27). Re-adding a retired app to a team is not |
| + supported. Env-manifest entries are out of reach. |
| +- `directory.disable-consumer` — `team_instances.state = disabled`, |
| + `roster_consumers.enabled = 0`, receipt with the existing `disable` value. |
| +- `<role>.inspect` — **new code** on the credential role (it has no |
| + `Inspect` today) and an extension on the directory (today it returns no |
| + stream and refuses when stored pins differ, `inspect.go:105-110`): returns |
| + generation (directory), next team id/sqid (directory), the role's |
| + `(sequence, head)`, and its pending/open plan id and expiry (no plan |
| + contents). It does **not** report label freedom; `seed-team` |
| + refusing a taken label is the check. |
| +- **Provenance fence (directory).** Every directory verb except `inspect` |
| + and `initialize` may touch only a team whose `seed-team` committed through |
| + this HTTP stream (`operator_http_teams(team_id, operation_id)`, written in |
| + the seed's transaction). Production has **no teams today** (§12), so the |
| + fence protects an empty set now and every future team not created here. |
| +- **`directory.initialize`** keeps its precondition (no generation, no |
| + consumer, no tokens, no bootstrap receipt — `directory.go:160-168`) and its |
| + `baseline_attestation`, which is Paul's typed confirmation in Alta (§12), |
| + signed in the plan. It must be the directory stream's **first operation**: |
| + the engine requires `initial_authority = true` at sequence 1 |
| + (`engine.go:160-163`), and every other directory verb refuses `Initial`. |
| +- **One stream per role.** The engine stores one operator identity per role |
| + and refuses any other once one has acted. Alta will own both streams. |
| + **Restore therefore needs Alta's key material** (or a separately reviewed |
| + re-enrolment) until such a design exists — the native Linux command can act |
| + only with Alta's pins and key. |
| + |
| +**Refused, permanently or until their own design:** any membership write but |
| +the seed's first owner (Team page — spec §10, `team-members.md`); rename; |
| +relabel; label release; retired-consumer reactivation; restore or generation |
| +change; token rotation; ownership transfer; team deletion; any read of |
| +memberships, names or people. |
| + |
| +## 6. What the endpoint may not do |
| + |
| +Return anything readable beyond the engine's result JSON (ids, outcome, |
| +epoch, signed record, bearer, owner receipt); log anything but a fixed verb |
| +label, outcome code and operation-id prefix (gate 9); restore, rotate keys |
| +or re-initialize; act for a browser (no cookie read, no session minted on |
| +`/operator/v1`). |
| + |
| +## 7. Consumers beyond the 16-entry limit |
| + |
| +The cap exists because the credential origin's CSP names every manifest |
| +origin in `form-action` (`security.go`, `runtime.go:102`). |
| + |
| +1. **Per-response `form-action`.** The handoff page **and the |
| + `signoutConfirm` page** (a same-origin POST that redirects to a preview |
| + consumer) set `form-action 'self' <directory> <that one consumer's |
| + origin>`. Every other credential page keeps `'self' <directory>`. |
| +2. **A credential `consumers` table** — `consumer_id` (PK), `origin` |
| + (UNIQUE), `state` (`active` | `retired`), `created_at` (day), |
| + `operation_id`; written only by §5's two credential verbs; cap 4,096 |
| + (a trigger with its reason: a runaway Alta, not a scale target). |
| +3. **Readers see the union through one atomic pointer.** The effective |
| + registry is an immutable map (`HOME_CONSUMERS` ∪ active table rows) held |
| + in an `atomic.Pointer`, swapped after each committed write. Every reader |
| + uses it: `exchange.go:41,78`, `security.go:13`, `signout.go:173`, |
| + `dashboard_config.go:72`. |
| +4. **Collision refuses boot** (an ID or origin in both). That takes the |
| + credential origin — and suite sign-in — down, which is correct and goes |
| + in the runbook: remove the env entry, redeploy. |
| + |
| +Production `HOME_CONSUMERS` holds 7 entries today (§12); **Alta becomes the |
| +8th env entry** before the table lands. The directory needs nothing new |
| +here: `team_instances` and `roster_consumers` are rows already. |
| + |
| +**New tables (additive):** credential `consumers`, `operator_plans` |
| +(plan_id, pending/open, kind, apps, owner_index, expiry); directory |
| +`operator_plans` (plan_id, pending/open, kind, label, apps, sealed display |
| +name, expiry), `operator_http_teams`; both keep |
| +`<role>_operator_state` / `_results` unchanged. No table ever holds signed |
| +plan bytes or an address. |
| + |
| +## 8. Threat model: a compromised provisioner |
| + |
| +An attacker holds Alta's operator key, prefilter token and CARLOS |
| +credentials. |
| + |
| +- **Without Paul confirming on Home:** nothing at Home. On CARLOS, the |
| + team-scoped credential reaches only Alta's own environments and instances |
| + (ruling 8's condition); Home cannot bound that, CARLOS does. |
| +- **If Paul confirms a plausible attacker plan:** for 15 minutes, the label |
| + and apps **Paul saw on Home**, and the owner whose address **Paul typed**: |
| + a new team, consumers at `<that label>.<app>.oficina.works`, activated. |
| + Costs: a label and hostnames squatted for good (never reused). **Cannot:** |
| + create a consumer for any existing team's hostnames (the credential role |
| + registers only from a directory record, and the directory fence admits |
| + only teams this stream seeded); add a member anywhere; read any |
| + membership, name, address or content; mint a session; touch |
| + `HOME_CONSUMERS`; rename. |
| +- **Victim class, named:** the owner Paul typed — possibly Paul himself — |
| + sees an attacker-run team in their chooser for those apps and may sign in |
| + to it, handing that instance their `sub` and whatever they then type |
| + there. Phishing, recorded, bounded by Paul having confirmed that label. |
| +- **Replay:** single-sequence requests; plans single-use and expiring. |
| + **Existence oracle:** the existing-only lookup at plan submit tells |
| + Alta's key holder whether an address has a person — `owner-seed` already |
| + does, so nothing new. |
| +- **Compromised Home origins** are as in §13a of the spec. **Three signers |
| + move into serving processes** (before, they lived only in the operator |
| + command): the directory's provisioning signer; the credential role's |
| + owner-seed signer; and the credential role's resolve key |
| + (`team-members.md` §4). A directory compromise could sign provisioning |
| + records and a credential compromise could sign owner receipts or member |
| + resolutions — but each origin's compromise already concedes more (§13a), |
| + and registration or seeding still needs Alta's key and a window Paul |
| + opened. |
| + |
| +## 9. The one rule and gates |
| + |
| +- **No readable address at rest.** The address reaches the credential role |
| + three times (plan, confirm, owner-seed), is blind-indexed and dropped. |
| + Plans hold the blind index; result rows hold `HMAC(idempotency key, |
| + input)` and a sealed, address-free result. The directory sees person refs |
| + only. |
| +- **Spec §3.2's plaintext list gains:** consumer origins in the credential |
| + DB (hostnames, which contain labels — never secret, and `HOME_CONSUMERS` |
| + already held them); plan labels and app slugs in the directory DB; plan |
| + kinds, apps and blind indexes in the credential DB; `memberships.added_at` |
| + (day) from `team-members.md`. |
| +- **Gate 1** drives the whole sequence (plan, both confirms, every verb) |
| + with canary addresses and names; scans both databases, WAL and SHM. |
| + **Gate 2** gains plan-submit, confirm and owner-seed-over-HTTP as address |
| + paths — *extended, not replaced*; on the plan-submit path it asserts the |
| + **signed plan bytes and the canary address are absent** from the file, WAL |
| + and SHM, and that an expired plan's row is gone. **Gate 5** scans the credential confirm |
| + page with canary labels present. **Gate 9** captures every log line, |
| + hostile refusals included. **Gate 10** covers every new route. |
| + |
| +## 10. Tests required before merge |
| + |
| +1. **Mounting:** no routes without `HOME_OPERATOR_HTTP`; role separation; |
| + Host spoofing refused. |
| +2. **Transport:** browser markers, size, content type, prefilter (fixed 401). |
| +3. **Signature:** wrong key/context, expired, sequence gap, changed input |
| + under a used sequence; exact replay after expiry returns the stored |
| + result and mutates nothing. |
| +4. **Ceremony:** plan signed by another key; a second pending plan |
| + refused; differing `plan_id`s across roles refused at confirm; confirm by |
| + a non-operator subject → 404; directory confirm with stale or future |
| + `auth_time`; credential confirm with a stale session (a fresh intent is |
| + written and the forced sign-in returns to `/operator/confirm` — no loop |
| + for a Keymail identity), a Keymail session with no gesture, a |
| + **recovery-code session** (refused), a mistyped owner address; confirm |
| + after plan expiry; `seed-team` with a display name not matching the |
| + plan's sealed name byte for byte; expired plan rows deleted; a fresh |
| + intent with a missing or invalid nonce is ignored (no loop — plain |
| + sign-in); the fresh-intent cookie is cleared after a successful confirm; |
| + the reserved consumer value in a fresh intent is refused by |
| + `handleAssertion`'s consumer lookup (it can never mint an assertion). |
| +5. **Scope:** other label, app outside `apps`, verb outside `kind`, window |
| + expiring mid-run, expired owner receipt then a fresh `owner-seed`. |
| +6. **Blocker 2:** `register-consumer` without a record, with a record signed |
| + by another key, for an app outside the window, for an origin in |
| + `HOME_CONSUMERS`; a record for a pre-existing team is unobtainable |
| + (fence). |
| +7. **Registry:** 17th and 4,097th consumer; env/table collision refuses |
| + boot; retired consumer refused at `/authorize` and sign-out; the handoff |
| + and `signoutConfirm` CSPs name exactly one consumer; concurrent reads |
| + during a swap (race detector). |
| +8. **Mutation:** removing the window check, the fence, the record |
| + verification or the typed-owner comparison each fails a named test. |
| +9. **Privacy and survival:** gates per §9; existing sessions, keys and team |
| + ciphertexts survive the additive migrations (reopen with the old binary). |
| +10. **Canary** on deployed previews: Alta creates `alpha` and `beta`; each |
| + owner sees only their team; the seven existing consumers keep working. |
| + |
| +## 11. Alternatives rejected |
| + |
| +- **Forwarding Paul's assertion from Alta to Home** (round 0) — unbuildable |
| + with the shared consumer, and Paul would approve Alta's rendering, not |
| + Home's copy. |
| +- **`carlos run` against Home's database** — no fence, no launch context; a |
| + database edit from outside in all but name. |
| +- **Alta writing Home's database or holding a Home signing key** — a third |
| + Home origin. |
| +- **Signature only** — rejected by Paul: Alta's key would be a standing |
| + ability to mint teams. |
| +- **Waiting for platform 117** — still blocked at platform `57aec0a`. |
| + |
| +## 12. Pre-flight facts and the confirmation Paul gives |
| + |
| +**Evidence, 2026-10-27, 21:06 UTC** — read-only `carlos db query --app |
| +oficina` on a restored replica copy, transaction 3140: production directory |
| +has `teams` = 0, `memberships` = 0, `team_instances` = 0, |
| +`roster_generation` = 0, `roster_consumers` = 0, `roster_tokens` = 0, |
| +`directory_operator_state` = 0, `directory_operator_results` = 0. So |
| +`directory.initialize`'s four-empty-tables precondition holds, and **Alta's |
| +first production run is an `initialize` plan**. |
| + |
| +**Required pre-flight confirmation:** Paul confirms, against that evidence, |
| +that this directory database has **never** issued a roster generation or |
| +consumer record (Home cannot prove historical absence after a possible |
| +restore; `home-provisioner.md`). Alta signs that confirmation as |
| +`baseline_attestation`. |
| + |
| +**If a generation were ever present,** `initialize` refuses and no other |
| +directory verb can open the stream (blocker 3). That needs a separately |
| +reviewed `directory.enrol` first operation; it is **not designed here**. |
| + |
| +**Production `HOME_CONSUMERS`** (credential role, `oficina-id`, as |
| +`HOME_CONSUMERS_BASE64`) holds **7** entries: calendar, calls, directory, |
| +docs, memoria, sheets, slides. Alta is added as the 8th env consumer before |
| +§7's table lands; the 16 cap applies until then. |
| + |
| +## 13. Review findings: disposition |
| + |
| +**Round 1.** Blocker 1 → §4 (option b). Blocker 2 → §3, §5, §8. Blocker 3 → |
| +§5, §12. Blocker 4 → `team-members.md` §2. Blocker 5 → `team-members.md` §3, |
| +§5; §9. Non-blocking: supersessions §2 items 3, 5, 6; "verbs wrapped" §1, |
| +§5; `allowedAction` §3; header dropped §4; window semantics and receipt |
| +renewal §4; inspect is new code and reports no label freedom §5; retired |
| +hostnames dead for good §5; atomic swap, union readers, `signoutConfirm`, |
| +runbook §7; victim class §8; §3.2 list §9; stream ownership and restore §5; |
| +`HOME_CONSUMERS` count §12. |
| + |
| +**Round 2.** Blocker 1 (plan bytes) → §4 step 1, §9 gate 2, §10.4. Blocker |
| +2 (fresh consumer not mountable) → §4 sequencing prerequisite, |
| +`team-members.md` §2. Blocker 3 (credential confirm loop, lost target) → §4 |
| +step 3 (no query, `credentialReturn`, sealed fresh intent, GET and POST |
| +re-checks). Recovery-code sessions refused on the credential page; the |
| +directory's inherited gap stated (§4 step 2). Same `plan_id` on both roles, |
| +shown on both pages (§4). Display name bound by the directory plan (§4, |
| +window semantics). Order advisory; 15-minute block, no cancel (§4). Three signers |
| +in serving processes (§8). Mounting outside CSRF and sessions (§4). |
| +`VerifyProvisioning` mechanics (§5). Existence oracle (§8). Alta and Team |
| +page notes applied in those files. None declined. |
| + |
| +**Round 3 (APPROVED, design).** Non-blocking notes applied: `name_digest` |
| +dropped, byte comparison in `seed-team` (§4, §7); fresh intent with random |
| +nonce, cleared on consumption, reserved consumer refused by |
| +`handleAssertion` (§4 step 3, §10.4); §10.4 additions (invalid nonce |
| +ignored, cookie cleared). The `lagged-team` blank keys, PLATFORM timing and |
| +Docs prefix preflight are applied in `team-provisioning-app.md` §6. |
diff --git a/implementation/team-provisioning-app.md b/implementation/team-provisioning-app.md| new file mode 100644 |
| index 0000000..3b97244 |
| --- /dev/null |
| +++ b/implementation/team-provisioning-app.md |
| @@ -0,0 +1,367 @@ |
| +# 🤖 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 40-hex commit in `/api/version`'s body; an app |
| + reporting anything else cannot be activated until it does. |
| +- `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). |