| index a2b2bbe..435047a 100644 |
| --- a/implementation/team-provisioning-amendment.md |
| +++ b/implementation/team-provisioning-amendment.md |
| @@ -1,10 +1,11 @@ |
| # 🤖 Amendment: the operator endpoint (teams without the maintenance worker) |
| |
| **Status:** PROPOSED, 2026-10-27. Drafted by Claude Opus 5.5 for Paul. |
| -**Round 1: reviewed by Claude Fable 5.1 (claude-fable-5-1), 2026-10-27, |
| -discussion 92 — CHANGES REQUIRED (5 blockers, non-blocking notes).** Round-1 |
| -fixes are applied below (§13 maps each finding); **round 2 is pending** on |
| -§4 and §5 here and §2/§5 of `team-members.md`. **No code until a top-model |
| +**Round 1: Claude Fable 5.1 (claude-fable-5-1), 2026-10-27, discussion 92 — |
| +CHANGES REQUIRED (5 blockers).** **Round 2: Claude Fable 5.1 |
| +(claude-fable-5-1), 2026-10-27, discussion 92 — CHANGES REQUIRED (narrow, |
| +3 blockers).** Fixes for both rounds are applied (§13); **round 3 is |
| +pending, scoped to §4 steps 1–3 here and `team-members.md` §2.** **No code until a top-model |
| review approves this file** (AGENTS.md "Review") and Paul gives the |
| pre-flight confirmation in §12. Direction approved in principle by Paul, |
| 2026-10-27: "the provisioning app creates teams, owners and consumer |
| @@ -121,7 +122,8 @@ credential role only); ruling 19; ruling 23; `home-operator-seed.md`'s |
| 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?plan=<id>` (Paul's browser, §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` |
| @@ -150,52 +152,91 @@ An operation is accepted only if **all** hold, in order, before any write: |
| 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)).** |
| +**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`: `plan_id` (32 random bytes), `role`, |
| - `kind` (`initialize` | `create-team` | `add-apps` | `retire-apps`), |
| - `apps` (registry slugs), `issued_at`, `expires_at` (≤ 900 s); the |
| - **directory** plan adds `label`; the **credential** plan adds `owner` |
| - (the address, private, never stored). Home stores it **unopened**: |
| - directory keeps `label`, `apps`, `kind`; credential keeps `kind`, `apps` |
| - and `owner_index` = the blind index (`findOrMintPersonOn`'s normalisation |
| - and index, `links.go:156`; existing-only lookup), dropping the address. |
| - One pending and one open plan per role; a third refuses. |
| -2. **Paul's browser confirms on the directory first**: |
| - `https://oficina.works/operator/confirm?plan=<id>`. It sits behind the |
| - directory's **fresh consumer** (the second `handoff.Consumer` with |
| - `RequireFreshAuth: true`, `team-members.md` §2): a session whose |
| - `auth_time` is older than 300 s or in the future is sent through the |
| - fresh exchange first. Subject ≠ `operator_subject` → 404. The page renders |
| - **Home's copy**: kind, label, each app as `<label>.<app>.oficina.works`, |
| - expiry. [Open window] POST (CSRF, freshness re-checked) opens the |
| - directory window for 15 minutes. The page then links on. |
| -3. **Then on the credential origin**: |
| - `https://id.oficina.works/operator/confirm?plan=<id>`, behind the |
| - credential session's own freshness — `sessions.Fresh(300)` plus the |
| - `fresh-assertion.md` rules (no future `auth_time`; a Keymail session with |
| - no reported gesture never counts); stale sends Paul through sign-in with |
| - `/operator/confirm` added to `credentialReturn`'s closed list. Subject ≠ |
| - `operator_subject` → 404. **The page renders no account-authored |
| - string** (gate 5): kind, app registry names (compiled constants), expiry, |
| - the first 8 hex of `owner_index`, and a field "Type the owner's email to |
| - confirm". The POST opens the window only if the typed address |
| - blind-indexes to `owner_index` — so a compromised Alta cannot swap the |
| - owner under Paul's nose. |
| - |
| -**Nonce and `BindStart`.** The raw-assertion forwarding of round 0 is |
| -removed: Home never receives an assertion from Alta, so nothing binds a plan |
| -to an assertion nonce. (Recorded because round 1 found it unbuildable: |
| -`handoff.Store.Finish` hands `Complete` parsed claims and deletes the token, |
| -`handoff/http.go:206-230`; `RequireFreshAuth` is per consumer, not per |
| -request, `http.go:139-141`.) Alta's own Home sign-in is an ordinary |
| -consumer. |
| + `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) and `name_digest` = SHA-256 of its exact |
| + 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 — 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 and re-checks |
| + everything above. **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`. |
| +expires; it never widens or extends. Directory: label matches, app ∈ `apps`, |
| +and `seed-team`'s `display_name` hashes to the plan's `name_digest`. |
| 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 |
| @@ -241,7 +282,11 @@ by two pages; that is the cost of not trusting Alta's rendering. |
| `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. The audience was produced by the directory's `ValidateRoute` |
| + 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 |
| @@ -322,9 +367,11 @@ Production `HOME_CONSUMERS` holds 7 entries today (§12); **Alta becomes the |
| here: `team_instances` and `roster_consumers` are rows already. |
| |
| **New tables (additive):** credential `consumers`, `operator_plans` |
| -(pending/open, kind, apps, owner_index, expiry); directory `operator_plans` |
| -(kind, label, apps, expiry), `operator_http_teams`; both keep |
| -`<role>_operator_state` / `_results` unchanged. |
| +(plan_id, pending/open, kind, apps, owner_index, expiry); directory |
| +`operator_plans` (plan_id, pending/open, kind, label, apps, sealed display |
| +name, name_digest, 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 |
| |
| @@ -348,11 +395,18 @@ credentials. |
| 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. |
| -- **Compromised Home origins** are as in §13a of the spec; the directory |
| - role now holds the provisioning signer in its serving process (before, |
| - only in the operator command) — a directory compromise could sign |
| - provisioning records, but registration still needs Alta's key and a |
| - credential window Paul opened. |
| + **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 |
| |
| @@ -369,7 +423,9 @@ credentials. |
| - **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*. **Gate 5** scans the credential confirm |
| + 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. |
| |
| @@ -381,10 +437,15 @@ credentials. |
| 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; third plan refused; confirm by |
| +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 Keymail session |
| - with no gesture, a mistyped owner address; confirm after plan expiry. |
| + `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 |
| + `name_digest`; expired plan rows deleted. |
| 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 |
| @@ -440,14 +501,25 @@ reviewed `directory.enrol` first operation; it is **not designed here**. |
| docs, memoria, sheets, slides. Alta is added as the 8th env consumer before |
| §7's table lands; the 16 cap applies until then. |
| |
| -## 13. Round-1 findings: disposition |
| - |
| -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. Alta and Team-page notes are applied in those |
| -files. None declined. |
| +## 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 `name_digest` (§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. |