| index b76976e..a2b2bbe 100644 |
| --- a/implementation/team-provisioning-amendment.md |
| +++ b/implementation/team-provisioning-amendment.md |
| @@ -1,33 +1,37 @@ |
| # 🤖 Amendment: the operator endpoint (teams without the maintenance worker) |
| |
| -**Status:** PROPOSED, 2026-10-27. Drafted by Claude Opus 5.5 for Paul. Not |
| -reviewed. **No code until a top-model review approves this file** (AGENTS.md |
| -"Review") and Paul answers the pre-flight question in §12. 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." |
| -**Base:** origin/main `e2ec1ab`. Companion files: |
| -`team-provisioning-app.md` (the caller, called **Alta** below) and |
| -`team-members.md` (the Team page). |
| -**Paul's rulings, 2026-10-27, applied here:** two-key approval (Alta's |
| -signature **and** his fresh Home sign-in 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. One |
| -pre-flight question remains open (§12). |
| +**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 |
| +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 |
| +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, in one paragraph |
| +## 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 and verbs** behind one HTTP route per Home role, |
| -callable only by one pinned external signer (Alta) **and** only inside a |
| -short approval window opened by Paul's fresh Home sign-in. It adds consumer |
| -registration and retirement verbs, 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. |
| +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) |
| |
| @@ -36,360 +40,414 @@ 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: Alta's |
| - signature plus Paul's fresh Home assertion. |
| -2. `home-provisioner.md`, "Signed private operation contract": *"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: normal HTTP |
| - startup exposes `POST /operator/v1` **only when** `HOME_OPERATOR_HTTP` is |
| - configured (§3); tests prove it is absent otherwise. |
| -3. `home-operator-seed.md`, "Transport and command boundary": *"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. |
| -4. `roster-contract.md`: *"This module … adds no public bootstrap route and |
| + 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 |
| - separately reviewed transport, for provisioning only. **Restore stays |
| - gated** (§6). |
| -5. `home-provisioner.md` step 6: *"Register the exact consumer with credential |
| - Home by updating its bounded immutable HOME_CONSUMERS manifest … Current |
| - source allows16 entries/8192bytes … stop at the bound. Scalable |
| - registration is separate work."* — Replaced by §7. |
| -6. `team-entry.md`: *"No request can register or alter a consumer."* and |
| + 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, approved request type can register or retire a consumer; no |
| + signed, Paul-approved request type registers or retires a consumer; no |
| browser request can. |
| -7. `directory-runtime.md`: *"There is currently no exported network writer |
| - that can mark an instance live."* — Now there is exactly one, §5. |
| -8. 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** (Paul types it into Alta), as |
| - `home-provisioner.md` already allowed for synthetic pilots. The queue |
| - (call 4) is untouched and still drained by a human. |
| -9. `operator/verification.go` `ActivationEvidence.EnvironmentBinding` and |
| - `ManifestDigest` were specified as maintenance-environment facts. On this |
| - path they are Alta's observations through the CARLOS console and the |
| - credential role's consumer-registry digest |
| - (`team-provisioning-app.md` §7). Same fields, weaker provenance, said so. |
| +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. The re-ruling, to be added |
| - to spec §1 as its own row when this lands: **a web-facing app other than |
| - Home (Alta) may hold CARLOS credentials, on condition that CARLOS gains |
| - team-scoped credentials** — able to create, configure, restart and delete |
| - instances, set env and secrets, and attach and detach domains **only** for |
| - named, non-default environments and the instances bound to them, never |
| - the app's default bundle or instances on it. **Alta does not ship to |
| - production until that credential exists.** Rejected: a separate CARLOS |
| - account for team instances; accepting today's app-wide reach. CARLOS |
| - design: `carlos/platform` branch `team-scoped-credentials`, |
| - `implementation/team-scoped-credentials.md`. |
| + 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 (§14's three conditions are unmet). |
| + the signup queue. |
| |
| -**Not superseded:** §0 the one rule; §2.2's four never-dos; ruling 4 (the |
| -pepper stays on the credential role); ruling 19 (labels reserved suite-wide); |
| -ruling 23 (roster written only by an owner behind step-up, **or seeded with |
| -the first owner**); `home-operator-seed.md`'s *"The directory cannot request |
| -address resolution over HTTP"* — nothing here lets the directory ask the |
| -credential role anything. |
| +**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 |
| |
| -- **Route:** `POST /operator/v1` and `POST /operator/v1/approve` on each |
| - role's own origin — `id.oficina.works` (credential verbs only) and |
| - `oficina.works` (directory verbs only); `allowedAction` already splits |
| - verbs by role. |
| -- **Off unless configured.** `HOME_OPERATOR_HTTP` (JSON, ≤ 8 KiB, closed |
| +- **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?plan=<id>` (Paul's browser, §4). |
| +- **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, subset of §5's allowlist), |
| - `operator_subject` (Paul's person ref), `approver_origin` (Alta's exact |
| - origin), `prefilter_token_sha256`. Absent → the route is not mounted (404, |
| - indistinguishable from any unknown path). Malformed → boot refuses. |
| -- **Separate key from every other key.** Alta's operator public key must |
| - differ from the assertion key, owner-seed signer, directory provisioning |
| - signer and roster keys (`NewDirectory`/`NewCredential` already refuse |
| - equality; extend to the HTTP loader). |
| - |
| -## 4. Authentication: two keys, neither sufficient alone |
| - |
| -A request is accepted only if **all** of these hold, checked in this order, |
| -before any database write: |
| - |
| -1. **Not a browser.** Refuse if the request carries `Cookie`, `Origin`, |
| - `Sec-Fetch-Site` or `Sec-Fetch-Mode`. No CORS. `Content-Type: |
| - application/json`, body ≤ 64 KiB (existing `BodyLimit`), read with a hard |
| - limit before parsing. |
| -2. **Prefilter bearer** (`Authorization: Bearer`, 32 random bytes, compared by |
| - SHA-256 in constant time). This is a cheap DoS filter so unauthenticated |
| - bodies never reach the verifier. **It is not authority** and is documented |
| - as such. |
| -3. **Alta's signature** — the existing `Verifier.Verify` wrapper, unchanged: |
| - pinned P-256 key, context `oficina/home/operator-input/v1`, ≤ 300 s |
| - validity, exact role/origin/installation/registry/device, per-role |
| - sequence = previous + 1 against the role's stored head. |
| -4. **An open approval window covering this operation** (new; replaces "fresh |
| - console approval"). See below. |
| - |
| -**The approval window.** `POST /operator/v1/approve` takes |
| -`{plan, assertion}`: |
| - |
| -- `plan` is a closed JSON object signed by Alta's same key under a new |
| - context `oficina/home/operator-plan/v1`: `plan_id` (32 random bytes), |
| - `role`, `kind` (`create-team` | `add-apps` | `retire-apps` | |
| - `initialize`), `label`, `apps` (subset of the compiled registry), `owner` |
| - (**credential plan only** — the address, transported privately; never |
| - stored, see below), `nonce`, `issued_at`, `expires_at` (≤ 900 s). Alta |
| - signs one plan per role with the same `nonce`; the directory's plan has no |
| - `owner` field, so the address never reaches the directory. |
| -- `assertion` is a normal Home browser assertion (wire v1) that Paul's |
| - browser carried to Alta after a **step-up** (`max_age=300`, |
| - `fresh-assertion.md`). Home verifies it with its own pinned keys: |
| - `iss` = credential origin, `aud` = the configured `approver_origin`, |
| - `sub` = the configured `operator_subject`, `auth_time` within 300 s and not |
| - in the future, `nonce` = `plan.nonce`, `jti` unused in **this role's own** |
| - `operator_approval_jti` table (self-pruning, like every verifier's). |
| -- On success the role stores one `operator_approvals` row: `plan_id`, `kind`, |
| - `label`, `apps`, `expires_at`, and on the credential role |
| - `owner_index` = the **blind index** of the address (the value `people` |
| - already stores; no new column class). The address itself is dropped after |
| - hashing. One open window per role at a time; a second refuses. |
| + `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)).** |
| + |
| +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. |
| + |
| +**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`. |
| +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 |
| -`credential.owner-seed` accepts only `existing_only: true`, so a typo or a |
| -never-signed-in address refuses and mints no person stub. The native |
| -command's other mode is not reachable here. |
| - |
| -Each `/operator/v1` request then names `plan_id` in a header |
| -(`Oficina-Plan`), and the role checks — inside the engine's transaction — that |
| -the window is open and the verb's decoded input is inside it: the label |
| -matches; the app is in `apps`; for `credential.owner-seed`, the input |
| -address's blind index equals `owner_index`. A window never widens and is never |
| -extended; expiry or `kind` mismatch refuses. |
| - |
| -**Why this shape.** Alta's key alone does nothing without Paul freshly |
| -signing in; Paul's assertion alone does nothing without Alta's key and is |
| -bound to one plan. It is "operator key + fresh console approval" with Home's |
| -own step-up as the console. **Said plainly rather than counted as a fix:** a |
| -compromised Alta *plus* Paul signing in to it opens a window for the |
| -attacker's plan. §8 bounds that window. |
| - |
| -## 5. Verbs: reused, new, and refused |
| - |
| -Existing verbs are **reused unchanged** — engine, idempotency by |
| -`operation_id`, sealed results, per-role stream, receipts, 10,000-operation |
| -cap, exactly as in `engine.go`. Each verb and the window kinds admitting it: |
| - |
| -| Role | Verb | Window kinds | |
| -|---|---|---| |
| -| credential | `credential.owner-seed` | create-team | |
| -| directory | `directory.inspect` (signed challenge, read-only) | any | |
| -| directory | `directory.seed-team` | create-team | |
| -| directory | `directory.provision-consumer` | create-team, add-apps | |
| -| directory | `directory.verify-consumer` | create-team, add-apps | |
| -| directory | `directory.activate-consumer` | create-team, add-apps | |
| -| directory | `directory.initialize` | initialize (once per installation) | |
| -| credential | `credential.register-consumer` **(new)** | create-team, add-apps | |
| -| credential | `credential.retire-consumer` **(new)** | retire-apps | |
| -| directory | `directory.disable-consumer` **(new)** | retire-apps | |
| -| both | `<role>.inspect` stream read **(new / extended)** | any | |
| - |
| -`directory.initialize` keeps its own precondition (no generation, no |
| -consumer, no tokens, no bootstrap receipt) and its `baseline_attestation`, |
| -which becomes Paul's explicit typed attestation in Alta, signed in the plan. |
| -It is reachable only under an `initialize` window, as the directory stream's |
| -first operation. |
| - |
| -**One stream per role.** The engine stores a single operator identity per |
| -role (`<role>_operator_state`: installation, registry, device, key) and |
| -refuses any other once one has acted. Whichever signer acts first — Alta |
| -here, or the native Linux command — owns that role's stream. Production has |
| -neither today. Re-enrolment is out of scope, so choosing Alta is choosing it |
| -for restore-time operations too, until a reviewed re-enrolment exists. |
| - |
| -**New verbs** (each with its own review and tests): |
| - |
| -- `credential.register-consumer {consumer_id, origin}` — inserts into the |
| - credential `consumers` table (§7); origin must be |
| - `https://<window label>.<window app>.oficina.works`; ID or origin |
| - collision refuses; returns the registry digest |
| - (`oficina/home/consumer-manifest/v1`) for activation evidence. |
| +`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. 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. Env-manifest entries are out of reach. |
| + `/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` — the signed read-only challenge, plus the role's stream |
| - `(sequence, head)`, so an Alta that lost its database can resume. |
| - |
| -The credential role cannot see labels, so a window naming a taken label |
| -could register a credential consumer for a sibling host of an existing team. |
| -It receives only assertions addressed to itself, and the directory fence |
| -below keeps it out of the chooser and roster. Alta seeds the team (which |
| -fails on a taken label) before registering any consumer. |
| - |
| -**Provenance fence (new, load-bearing).** Every directory verb except |
| -`inspect` and `initialize` may touch only a team whose `seed-team` committed |
| -through this HTTP stream, recorded in a new `operator_http_teams(team_id, |
| -operation_id)` table in the same transaction as the seed. **Paul's existing |
| -teams, and any team that existed before this migration, are unreachable |
| -from this endpoint.** That is the code form of Paul's 2026-10-27 ruling that new |
| -people never touch his existing apps. |
| - |
| -**Refused here, permanently or until their own design:** any membership |
| -write other than the seed's first owner (that is the Team page behind |
| -step-up — spec §10, `team-members.md`); rename; relabel; restore or generation change; |
| -token rotation; ownership transfer; team deletion; any read of memberships, |
| -names or people; any verb on a team outside the provenance fence. |
| +- `<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:** only the engine's existing result JSON |
| - (ids, outcome, epoch, signed record, bearer, owner receipt) — no address, |
| - name or member list. Replay returns the same sealed result. |
| -- **Log content:** a fixed verb label, outcome code and operation-id prefix |
| - only (gate 9). |
| -- **Restore, rotate keys or re-initialize:** restore stays gated on 117. |
| -- **Act for a browser:** no cookie read, no session minted; the approval |
| - assertion is consumed, never exchanged for a session. |
| +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 16-entry/8 KiB cap exists because the credential origin's CSP names every |
| -manifest origin in `form-action` (`security.go`, `runtime.go:102`). Two |
| -changes remove the cap without widening the CSP: |
| - |
| -1. **Per-response `form-action`.** The handoff page (the only credential page |
| - that posts cross-origin) sets `form-action 'self' <directory> |
| - <that consumer's origin>` for that one response. Every other credential |
| - page keeps `form-action 'self' <directory>`. Sign-out's allowlist reads the |
| - same registry. No wildcard, ever. |
| -2. **A credential-role `consumers` table** — `consumer_id` (PK, existing |
| - `consumerName` rule), `origin` (UNIQUE, exact canonical HTTPS), |
| - `state` (`active` | `retired`), `created_at` (day-coarsened), |
| - `operation_id`. Written only by §5's two credential verbs. Loaded at boot |
| - and reloaded in-process after each committed write; the effective registry |
| - is `HOME_CONSUMERS` ∪ table, and an ID or origin present in both refuses |
| - boot. Hard cap 4,096 rows, written in the migration as a CHECK-backed |
| - trigger with its reason (a typo-loop in Alta, not a scale target). |
| - |
| -`HOME_CONSUMERS` keeps the directory and Paul's existing consumers, unchanged. |
| -The directory needs nothing new here: `team_instances` and `roster_consumers` |
| -are already rows with no count cap. **All new tables, both roles, are |
| -additive:** credential `consumers`, `operator_approvals`, |
| -`operator_approval_jti`; directory `operator_approvals`, |
| -`operator_approval_jti`, `operator_http_teams`. |
| +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` |
| +(pending/open, kind, apps, owner_index, expiry); directory `operator_plans` |
| +(kind, label, apps, expiry), `operator_http_teams`; both keep |
| +`<role>_operator_state` / `_results` unchanged. |
| |
| ## 8. Threat model: a compromised provisioner |
| |
| -Assume an attacker holds Alta's operator key, its prefilter token and its |
| -CARLOS service credentials. |
| - |
| -- **Without Paul's fresh sign-in:** nothing at Home. No window opens. On |
| - the CARLOS side, today's `operate`/`instance` pair would let an attacker |
| - rewrite the default bundle Paul's own instances run on and delete them — |
| - **which is why ruling 8's re-ruling is conditional**: in production Alta |
| - holds only team-scoped credentials, which reach Alta's own environments |
| - and instances and nothing of Paul's. Home cannot bound that risk; CARLOS |
| - does. |
| -- **With one window (Paul signs in to a compromised Alta):** for 15 |
| - minutes, one label, the plan's apps: one new team owned by an existing |
| - person of the attacker's choosing, consumers at |
| - `<that label>.<app>.oficina.works`, activated. Costs: a label squatted for |
| - good (labels are never released) and audiences valid only at themselves; |
| - no person stubs, since owner-seed is existing-only here. **Cannot:** touch any existing |
| - team, instance or consumer (provenance fence); add a member anywhere; read |
| - any membership, name, address or content; mint a session; retire |
| - `HOME_CONSUMERS` entries; rename. |
| -- **Phishing, recorded:** a new team's consumer can be an attacker-run |
| - instance; it receives an unreversible `sub` and nothing else Home holds — |
| - the exposure every instance already has. **Replay:** single-sequence |
| - requests, single-use approval `jti`, nonce-bound plans. |
| -- **Compromised Home origins** are unchanged from §13a: the credential |
| - origin can sign in as anyone (including as Paul to approve a window — no |
| - worse than its existing power); the directory can already add members. |
| - |
| -## 9. The one rule and gates 1, 2, 9 |
| +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. |
| +- **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. |
| + |
| +## 9. The one rule and gates |
| |
| - **No readable address at rest.** The address reaches the credential role |
| - twice (approve, owner-seed), is blind-indexed with the sign-in helper and |
| - dropped. Approval rows hold the blind index; result rows hold |
| - `HMAC(idempotency key, input)` and a sealed, address-free result. The |
| - directory sees only person refs. The falsifiable form gains nothing: |
| - consumers are hostnames, approvals are labels and blind indexes. |
| -- **Gate 1** drives the whole HTTP sequence with canary addresses and names |
| - and scans both databases, WAL and SHM. **Gate 2** gains owner-seed-over- |
| - HTTP and approve as two more address paths — *extended, not replaced*. |
| - **Gate 9** captures every log line and error across the same drive, |
| - hostile refusals included. **Gate 10** covers both routes' responses. |
| + 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*. **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:** route absent without `HOME_OPERATOR_HTTP`; each role |
| - refuses the other's verbs; Host-header spoofing refused. |
| -2. **Transport:** browser markers refuse; > 64 KiB refuses before parse; |
| - wrong content type refuses; bad prefilter → identical fixed 401. |
| -3. **Signature:** wrong key or context, expired, sequence gap, changed input |
| +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. **Approval:** wrong `aud` or `sub`, `auth_time` 301 s old or in the |
| - future, nonce mismatch, reused `jti`, expired plan, a second window while |
| - one is open, a plan signed by another key. |
| -5. **Scope:** other label, app outside `apps`, owner whose blind index |
| - differs, verb outside `kind`, window expiring mid-run; provenance fence |
| - refuses every directory verb on a pre-existing team with the unknown-team |
| - code. |
| -6. **Registry:** 17th and 4,097th consumer; env/table collision refuses |
| +4. **Ceremony:** plan signed by another key; third plan refused; 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. |
| +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 |
| - page's CSP names exactly one consumer origin. |
| -7. **Mutation:** removing the approval check, the provenance check or the |
| - blind-index comparison each fails a named test. |
| -8. **Privacy and survival:** gates 1, 2, 9, 10 per §9; existing sessions, |
| - assertion keys and team ciphertexts survive the additive migrations |
| - (reopen with the old binary). |
| -9. **Canary:** on deployed previews, Alta creates `alpha` and `beta` with |
| - synthetic owners; each owner sees only their team; Paul's existing |
| - consumers keep working throughout. |
| + 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 |
| |
| -- **`carlos run` against Home's database** (a `run`-role credential with a |
| - fixed command list). It exists today, but it runs beside the serving |
| - process with no fence and no launch context, `operatorlaunch` would refuse |
| - it, and it is a database edit from outside the app in all but name. |
| -- **Alta writing Home's database directly**, or holding any Home key that |
| - signs assertions, receipts or roster pages. That makes Alta a third Home |
| - origin. |
| -- **Signature only, no approval window** — rejected by Paul, 2026-10-27: |
| - it turns Alta's stored key into a standing ability to mint teams and |
| - owners. |
| -- **Waiting for platform 117.** Still blocked at platform `57aec0a` |
| - (`maintenance-exec.md`: final design approval pending; no command, no |
| - route). The native Linux command stays for restore, which this does not |
| - cover. |
| - |
| -## 12. Ruled, and the one pre-flight question |
| - |
| -**Ruled by Paul, 2026-10-27:** two-key approval on every run (§4); owner |
| -must already exist (§4); **team labels are never reused** — no label |
| -release verb will be built, and a retired team keeps its label for good |
| -(ruling 19 already reserves it; this makes the reservation permanent); |
| -ruling 8 re-ruled for Alta, conditional (§2). |
| - |
| -**Still open — a pre-flight question for Paul before the first production |
| -run:** has production's directory ever been initialized with a roster |
| -generation? Alta's first act is a signed `directory.inspect`. If it reports |
| -no generation, the first run is an `initialize` plan carrying Paul's typed |
| -attestation that this directory database has **never** issued a roster |
| -generation or consumer record (the attestation `home-provisioner.md` |
| -requires; Home cannot prove historical absence after a possible restore). |
| -If Paul cannot attest that, initialization stays unavailable and the |
| -restore procedure — still gated on platform 117 — is the only path. |
| +- **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. 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. |