| 1 | # 🤖 Amendment: the operator endpoint (teams without the maintenance worker) |
| 2 | |
| 3 | Existing canonical instances: `existing-team-adoption.md` extends §4's |
| 4 | confirmation rendering, §2.6/§5's activation policy and §8's threat model |
| 5 | for explicitly confirmed adoption plans. It preserves existing registrations |
| 6 | and local content authority; ordinary new-team provisioning stays separate. |
| 7 | |
| 8 | **Status:** APPROVED (design), 2026-10-27. Drafted by Claude Opus 5.5 for |
| 9 | Paul. **Reviewed by Claude Fable 5.1 (claude-fable-5-1), 2026-10-27, |
| 10 | discussion 92, APPROVED (design, round 3)** at `93f8209`, after round 1 |
| 11 | (CHANGES REQUIRED, 5 blockers) and round 2 (CHANGES REQUIRED, narrow, 3 |
| 12 | blockers); round 3's six non-blocking notes are applied (§13). |
| 13 | **Implementation slice 1** (operator HTTP transport, confirm ceremony, |
| 14 | consumer registry, new verbs) **reviewed by Claude Fable 5.1 |
| 15 | (claude-fable-5-1), 2026-10-28, discussion 94, APPROVED** at `c880a02` |
| 16 | (round 4, §13). Each superseded file below carries a one-line pointer here. |
| 17 | **Not approved by this verdict, and needing its own review before the code |
| 18 | it gates** (Fable, round 3, verbatim): |
| 19 | 1. The shared `handoff` change (`ConsumerConfig.StartPath`) — before the |
| 20 | Team page and both confirm pages. |
| 21 | 2. `carlos/platform` `team-scoped-credentials` (discussion 449) and its |
| 22 | floor release — before Alta reaches production (Paul's condition on |
| 23 | ruling 8). |
| 24 | 3. Each implementation slice (operator HTTP transport, ceremony pages, |
| 25 | consumer registry and CSP, new verbs, Team page, resolve, each app's |
| 26 | roster port, Alta) — whole-code review, CI green, verified canary, per |
| 27 | AGENTS.md "Shipping cadence". |
| 28 | 4. Paul's §12 pre-flight confirmation before the first production |
| 29 | `initialize`. Direction approved in principle by Paul, |
| 30 | 2026-10-27: "the provisioning app creates teams, owners and consumer |
| 31 | registrations through a narrow, authenticated Home endpoint, instead of the |
| 32 | blocked platform-117 maintenance worker." |
| 33 | **Paul's rulings, 2026-10-27, applied here:** two-key approval on every run; |
| 34 | ruling 8 re-ruled for Alta, conditional on CARLOS team-scoped credentials; |
| 35 | the owner must already exist (`existing_only`); team labels are never reused. |
| 36 | **Base:** origin/main `e2ec1ab`. Companions: `team-provisioning-app.md` (the |
| 37 | caller, **Alta**) and `team-members.md` (the Team page). |
| 38 | |
| 39 | --- |
| 40 | |
| 41 | ## 1. What changes |
| 42 | |
| 43 | Every operator verb in `internal/operator` runs today only inside a platform |
| 44 | maintenance worker that does not exist (platform discussion 117). This |
| 45 | mounts **the same engine** behind one HTTP route per Home role, callable only |
| 46 | by one pinned external signer (Alta), and only inside an approval window that |
| 47 | **Paul opens on Home itself**, after a fresh sign-in, against Home's own copy |
| 48 | of the plan. The engine is unchanged; **the verbs are wrapped** (a window |
| 49 | check, and on the directory a provenance fence, inside each mutation). It |
| 50 | adds consumer registration and retirement verbs and a stream read, and moves |
| 51 | the credential consumer list out of the 16-entry `HOME_CONSUMERS` env var |
| 52 | into the credential database. **Home still holds no platform credential** |
| 53 | (spec §7's load-bearing fact): Alta creates instances; Home records facts |
| 54 | about its own resources. |
| 55 | |
| 56 | ## 2. Approved text this supersedes (quoted) |
| 57 | |
| 58 | Each quoted file carries a one-line pointer here (added when slice 1 landed). |
| 59 | |
| 60 | 1. `home-provisioner.md`: *"Implement a separate local Go command, |
| 61 | `oficina provision`, callable directly by a human. … Every maintenance |
| 62 | mutation still requires its actual browser session, CSRF, current |
| 63 | account-owner lookup and `requireFreshAuth`."* — Replaced by §4. |
| 64 | 2. `home-provisioner.md`: *"The fixed operator entry point is enabled only |
| 65 | for maintenance execution of the immutable configured release. Normal |
| 66 | HTTP startup does not expose it. Tests must prove direct app requests |
| 67 | cannot invoke it."* — Replaced: HTTP startup exposes `/operator/v1` |
| 68 | **only when** `HOME_OPERATOR_HTTP` is configured (§3). |
| 69 | 3. `home-provisioner.md`, "Registry custody and persistence": *"Init creates |
| 70 | random device and registry IDs plus signing/encryption keys, and stores |
| 71 | the keys only in an age scrypt-encrypted credential file … The |
| 72 | independent floor backend writes signed immutable sequence/head files"* |
| 73 | and its two-phase floor CAS. — Replaced by Alta's sealed SQLite plus |
| 74 | **Home's per-role stream head as the rollback arbiter**: Home refuses any |
| 75 | sequence that is not previous + 1, so a rolled-back Alta is refused and |
| 76 | resynchronises through `<role>.inspect` (§5). |
| 77 | 4. `home-operator-seed.md`: *"Platform discussion 117 owns stopping traffic |
| 78 | and all background work, holding the database lease … The command never |
| 79 | starts an HTTP server, sends mail or makes network calls."* — Replaced |
| 80 | for this path; the engine serializes with `BEGIN IMMEDIATE` on the |
| 81 | serving process's own writer, so `home-operator-open.md`'s |
| 82 | fenced-identity proof is moot here. |
| 83 | 5. `home-operator-seed.md`: *"The invocation must be authorized outside the |
| 84 | request. … The platform must provide an authenticated invocation context |
| 85 | or equivalent private launch configuration before command wiring is |
| 86 | approved; an environment boolean supplied by the caller is |
| 87 | insufficient."* — Replaced by §4: Alta's pinned signature **and** a |
| 88 | window Paul opened on Home, with the pins in reviewed |
| 89 | `HOME_OPERATOR_HTTP` configuration. |
| 90 | 6. `home-operator-seed.md`: *"The verified operator context must attest |
| 91 | successful exact-host/body/header build verification, assertion |
| 92 | registration, isolated instance database/config, and the reviewed |
| 93 | TeamMode acceptance gates. A string supplied by the request is not that |
| 94 | attestation."* — **Weakened, said so:** on this path |
| 95 | `ActivationEvidence` is Alta's signed observation through the CARLOS |
| 96 | console plus the credential role's registry digest |
| 97 | (`team-provisioning-app.md` §7), not a platform attestation. Its |
| 98 | `app_version` is therefore the opaque token Alta read on `/api/version` |
| 99 | (bounded printable ASCII, `^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$`), not a |
| 100 | 40-hex commit Home could treat as attested (§13, Alta review). |
| 101 | 7. `roster-contract.md`: *"This module … adds no public bootstrap route and |
| 102 | no runtime operator mutation transport. Live provisioning/restore remains |
| 103 | gated on supported fenced maintenance (platform discussion117) or a |
| 104 | separately reviewed genuinely fresh first-boot path."* — This file is |
| 105 | that transport, **for provisioning only; restore stays gated**. |
| 106 | 8. `home-provisioner.md` step 6: *"Register the exact consumer with |
| 107 | credential Home by updating its bounded immutable HOME_CONSUMERS manifest |
| 108 | … stop at the bound. Scalable registration is separate work."* — |
| 109 | Replaced by §7. |
| 110 | 9. `team-entry.md`: *"No request can register or alter a consumer."* and |
| 111 | *"pilot bootstrap is not a web administration endpoint."* — Narrowed: one |
| 112 | signed, Paul-approved request type registers or retires a consumer; no |
| 113 | browser request can. |
| 114 | 10. `directory-runtime.md`: *"There is currently no exported network writer |
| 115 | that can mark an instance live."* — Now there is exactly one (§5). |
| 116 | 11. Spec §10: the first owner is *"seeded by the drain with the person the |
| 117 | sealed queue payload §7 already carries."* — Widened: the owner may also |
| 118 | come from an **operator-authored plan**. The signup queue is untouched |
| 119 | and still drained by a human. |
| 120 | |
| 121 | **Rulings this touches:** |
| 122 | |
| 123 | - **Ruling 8 — RE-RULED for Alta by Paul, 2026-10-27.** Its Rejected column |
| 124 | read *"A standing console token in a web-facing app."* Its reason (§7) — |
| 125 | an RCE on Home's sign-in surface must never reach instance creation — |
| 126 | still holds: Home holds no CARLOS credential. Re-ruling, to be added to |
| 127 | spec §1 as its own row: **a web-facing app other than Home (Alta) may hold |
| 128 | CARLOS credentials, on condition that CARLOS gains team-scoped |
| 129 | credentials** that act **only** on named, non-default environments and the |
| 130 | instances bound to them. **Alta does not ship to production until that |
| 131 | credential exists.** Rejected: a separate CARLOS account; accepting |
| 132 | today's app-wide reach. CARLOS design: `carlos/platform` branch |
| 133 | `team-scoped-credentials` (role `team`). |
| 134 | - **Ruling 7** is unaffected: Alta is the human gate and never auto-drains |
| 135 | the signup queue. |
| 136 | |
| 137 | **Not superseded:** §0; §2.2's four never-dos; ruling 4 (pepper on the |
| 138 | credential role only); ruling 19; ruling 23; `home-operator-seed.md`'s |
| 139 | *"The directory cannot request address resolution over HTTP."* |
| 140 | |
| 141 | ## 3. Where it lives and how it is switched on |
| 142 | |
| 143 | - **Routes, per role, each on its own origin** (`id.oficina.works` for |
| 144 | credential verbs, `oficina.works` for directory verbs): |
| 145 | `POST /operator/v1` (signed operation or signed inspect challenge), |
| 146 | `POST /operator/v1/plan` (Alta submits a signed plan, §4), |
| 147 | `GET` + `POST /operator/confirm` (Paul's browser, §4; no query — one |
| 148 | pending plan per role). |
| 149 | - **Off unless configured.** `HOME_OPERATOR_HTTP` (JSON ≤ 8 KiB, closed |
| 150 | fields) per role: `version`, `role`, `origin`, `installation`, `registry`, |
| 151 | `device`, `public_key`, `key_id`, `actions` (≤ 8, and **must include |
| 152 | `<role>.inspect`**, which Alta resynchronises from — round 4), |
| 153 | `operator_subject` (Paul's person ref), `prefilter_token_sha256`; **credential role also** |
| 154 | `directory_provisioning_public_key` (the directory's |
| 155 | `oficina/roster/provisioning/v1` key, which the credential role pins for |
| 156 | the first time — §5). Absent → no route mounted (404 like any unknown |
| 157 | path). Malformed → boot refuses. |
| 158 | - **The role's own keys** (the MAC key, the owner-seed signer, the |
| 159 | directory's provisioning signer and its roster keys) come from the |
| 160 | existing reviewed `HOME_OPERATOR_MATERIAL`, the material the native |
| 161 | command reads (round 4). |
| 162 | - **Separate keys.** Alta's key differs from the assertion, owner-seed, |
| 163 | directory-provisioning, roster and resolve keys (`NewDirectory` / |
| 164 | `NewCredential` already refuse equality; the HTTP loader extends it). |
| 165 | - **`allowedAction`** (`protocol.go:130-141`) is a closed switch and grows: |
| 166 | `credential.register-consumer`, `credential.retire-consumer`, |
| 167 | `credential.inspect`, `directory.disable-consumer`. |
| 168 | |
| 169 | ## 4. Authentication: Alta's key and Paul's confirmation on Home |
| 170 | |
| 171 | An operation is accepted only if **all** hold, in order, before any write: |
| 172 | |
| 173 | 1. **Not a browser.** Refuse `Cookie`, `Origin`, `Sec-Fetch-*`. No CORS. |
| 174 | `application/json`, ≤ 64 KiB, read with a hard limit before parsing. |
| 175 | 2. **Prefilter bearer** (32 bytes, SHA-256 constant-time compare) — a DoS |
| 176 | filter, **not authority**. |
| 177 | 3. **Alta's signature** — `Verifier.Verify`, unchanged: pinned P-256 key, |
| 178 | context `oficina/home/operator-input/v1`, ≤ 300 s, exact |
| 179 | role/origin/installation/registry/device, sequence = previous + 1. |
| 180 | 4. **An open window on this role admitting the verb and its input** (below). |
| 181 | |
| 182 | **The ceremony (round 1, blocker 1 — option (b); round 2, blockers 1 and |
| 183 | 3).** |
| 184 | |
| 185 | **Sequencing prerequisite.** Step 2 needs the directory's fresh-only |
| 186 | consumer, which needs a **reviewed change to the shared `handoff` module** |
| 187 | (`team-members.md` §2: today `guard` 404s any start path but the |
| 188 | `StartPath` constant, `handoff/http.go:70-80`, `:107`). That change and its |
| 189 | review land **before** the directory confirm page and the Team page. |
| 190 | |
| 191 | 1. **Alta submits a plan to each role**, `POST /operator/v1/plan` (same |
| 192 | transport checks 1–2), signed by Alta's key under context |
| 193 | `oficina/home/operator-plan/v1`. **Both roles' plans carry the same |
| 194 | `plan_id`** (32 random bytes), plus `role`, `kind` (`initialize` | |
| 195 | `create-team` | `add-apps` | `retire-apps`), `apps` (registry slugs), |
| 196 | `issued_at`, `expires_at` (≤ 900 s). The **directory** plan adds `label` |
| 197 | and `display_name` (round 2: so a compromised Alta cannot choose the |
| 198 | team's name after Paul confirms); the **credential** plan adds `owner`. |
| 199 | **Home verifies the signature, extracts the closed fields, and never |
| 200 | persists the signed plan bytes or the address.** Directory writes |
| 201 | `plan_id`, `kind`, `label`, `apps`, `expires_at`, the display name |
| 202 | **sealed** (the team-name helper). No digest of the name is kept (round |
| 203 | 3): `seed-team` opens the seal inside its transaction and compares bytes. Credential blind-indexes `owner` with `findOrMintPersonOn`'s |
| 204 | normalisation (`links.go:156`, existing-only lookup) and writes |
| 205 | `plan_id`, `kind`, `apps`, `owner_index`, `expires_at`. One pending and |
| 206 | one open plan per role (`UNIQUE(state)`); a further submit refuses until |
| 207 | the pending one is confirmed or expires, and **confirming a pending plan |
| 208 | while a window is open answers 409** until that window expires (round 4) (**up to 15 minutes; no cancel verb** — a convenience |
| 209 | we skip). **Expired and refused plan rows are deleted** (`secure_delete` |
| 210 | is on), so a blind index for a never-confirmed plan does not linger. |
| 211 | 2. **Paul's browser confirms on the directory**: |
| 212 | `https://oficina.works/operator/confirm` — **no query**; the page shows |
| 213 | the role's one pending plan. It sits behind the directory's fresh-only |
| 214 | consumer (`/auth/fresh/start`, `team-members.md` §2): a session whose |
| 215 | `auth_time` is older than 300 s or in the future goes through the fresh |
| 216 | exchange first and returns to `/operator/confirm`. Subject ≠ |
| 217 | `operator_subject` → 404. The page renders **Home's copy**: the first 8 |
| 218 | hex of `plan_id`, kind, label, display name, each app as |
| 219 | `<label>.<app>.oficina.works`, expiry. [Open window] POST — inside the |
| 220 | directory's CSRF group — re-checks subject, freshness and plan expiry |
| 221 | **inside the write**, then opens the directory window for 15 minutes. |
| 222 | **Inherited gap:** the directory session carries no sign-in method, so a |
| 223 | recovery-code session and the Keymail no-gesture case of |
| 224 | `team-members.md` §2 pass here exactly as they pass the Team page; the |
| 225 | credential page below is where the method is visible and refused. |
| 226 | 3. **Then on the credential origin**: `https://id.oficina.works/operator/confirm` |
| 227 | — **no query**, the role's one pending plan. `/operator/confirm` joins |
| 228 | `credentialReturn`'s closed list (`signin_return.go:12-17`, exact paths, |
| 229 | no query). On **GET and POST** it requires: subject = `operator_subject` |
| 230 | (else 404); `sessions.Fresh(300)`; no future `auth_time`; not |
| 231 | `keymailWithoutGesture`; and **`Method` not containing `recovery`** (Paul, |
| 232 | round 2: recovery codes mint `AuthTime: now`, `passkey.go:28-39`, so they |
| 233 | would satisfy any freshness window; this page refuses them). **A stale |
| 234 | session** gets a sealed **fresh intent** written before the redirect to |
| 235 | `/signin` — `assertionIntent{MaxAge: 300, Subject: operator_subject}` with |
| 236 | a reserved consumer value and a **random nonce** (`readAssertionIntent` |
| 237 | requires `handoff.ValidNonce`, `assertion_intent.go:34`, and does not |
| 238 | validate `Consumer`) — which `handleSigninBegin` and the Keymail callback |
| 239 | already honour (`signin.go:245-247`, `:356-358`), so the sign-in forces a |
| 240 | real gesture (magic link, or Keymail `prompt=login`) instead of looping. |
| 241 | `/operator/confirm` consumes the intent on return, **clears the cookie** |
| 242 | (today only `handleAssertion` does, `exchange.go:110`), and re-checks |
| 243 | everything above. The reserved consumer value can never reach an |
| 244 | assertion: `handleAssertion`'s consumer lookup refuses it. **The page renders no account-authored string** (gate |
| 245 | 5): the first 8 hex of `plan_id` (the same plan Paul just opened on the |
| 246 | directory), kind, app registry names (compiled constants), expiry, the |
| 247 | first 8 hex of `owner_index`, and "Type the owner's email to confirm". |
| 248 | The POST — inside the credential CSRF group (`app.go:199`) — re-checks |
| 249 | subject, freshness, method and expiry **inside the write**, and opens the |
| 250 | window only if the typed address blind-indexes to `owner_index`. |
| 251 | |
| 252 | **Order is advice, not enforced.** Paul is told directory first, then |
| 253 | credential; nothing breaks if he reverses it. An `initialize` plan is |
| 254 | directory-only. |
| 255 | |
| 256 | **Mounting.** `/operator/v1` and `/operator/v1/plan` are mounted outside |
| 257 | `csrf.Protect` and before `sessions.Middleware` on both routers, as |
| 258 | `handoff.CallbackPath` is (`directory.go:77`); the no-`Cookie` refusal makes |
| 259 | session middleware a no-op there anyway. `/operator/confirm` is the |
| 260 | opposite: inside each role's session and CSRF groups. |
| 261 | |
| 262 | **Nonce and `BindStart`.** Round 0's raw-assertion forwarding is removed: |
| 263 | Home never receives an assertion from Alta, so nothing binds a plan to an |
| 264 | assertion nonce (round 1 found it unbuildable: `handoff.Store.Finish` hands |
| 265 | `Complete` parsed claims and deletes the token, `handoff/http.go:206-230`). |
| 266 | Alta's own Home sign-in is an ordinary consumer. |
| 267 | |
| 268 | **Window semantics.** A window admits **any number** of operations whose |
| 269 | verb is allowed for its `kind` (§5) and whose input is inside it, until it |
| 270 | expires; it never widens or extends. Directory: label matches, app ∈ `apps`, |
| 271 | and `seed-team`'s `display_name` equals, byte for byte, the plan's sealed |
| 272 | display name (opened inside the transaction). |
| 273 | Credential: `owner-seed`'s address blind-indexes to `owner_index`; |
| 274 | `register-consumer`'s record app ∈ `apps`. **An expired owner receipt needs a |
| 275 | new `owner-seed` operation** under a live window — replay returns the same |
| 276 | expired receipt by design (`credential.go:66`, `home-operator-seed.md` |
| 277 | "never renews authority"). No `Oficina-Plan` header: one open window per role |
| 278 | makes it redundant. |
| 279 | |
| 280 | **The owner must already exist** (Paul, 2026-10-27): over this endpoint |
| 281 | `owner-seed` accepts only `existing_only: true`; an unknown address refuses |
| 282 | and mints no stub. |
| 283 | |
| 284 | **Why this shape.** Alta's key alone cannot act without Paul confirming on |
| 285 | Home; Paul's confirmation is of **Home's copy** of the plan, so a compromised |
| 286 | Alta cannot show him one plan and execute another. What remains: Paul |
| 287 | approves the plan Alta submitted — a compromised Alta can submit a plausible |
| 288 | one and hope he confirms it. §8 bounds that. |
| 289 | |
| 290 | **Not an operator view.** The confirm pages show the operator's own plan, |
| 291 | not anyone's data; they render only to `operator_subject`. They do grow Home |
| 292 | by two pages; that is the cost of not trusting Alta's rendering. |
| 293 | |
| 294 | ## 5. Verbs, windows and fences |
| 295 | |
| 296 | | Role | Verb | Kinds | Status | |
| 297 | |---|---|---|---| |
| 298 | | credential | `credential.owner-seed` (existing-only) | create-team | wrapped | |
| 299 | | credential | `credential.register-consumer` | create-team, add-apps | **new** | |
| 300 | | credential | `credential.retire-consumer` | retire-apps | **new** | |
| 301 | | credential | `credential.inspect` | any (no window) | **new** | |
| 302 | | directory | `directory.initialize` | initialize | wrapped | |
| 303 | | directory | `directory.inspect` (+ stream) | any (no window) | **extended** | |
| 304 | | directory | `directory.seed-team` | create-team | wrapped | |
| 305 | | directory | `directory.provision-consumer` | create-team, add-apps | wrapped | |
| 306 | | directory | `directory.verify-consumer` | create-team, add-apps | wrapped | |
| 307 | | directory | `directory.activate-consumer` | create-team, add-apps | wrapped | |
| 308 | | directory | `directory.disable-consumer` | retire-apps | **new** | |
| 309 | |
| 310 | - **`credential.register-consumer` is derivative of a fenced directory |
| 311 | write (round 1, blocker 2).** Its input is the directory's **signed |
| 312 | provisioning record** from `directory.provision-consumer` |
| 313 | (`directory.go:307-314`, context `oficina/roster/provisioning/v1`). The |
| 314 | credential role verifies it with the pinned |
| 315 | `directory_provisioning_public_key`, checks `issuer` = itself and |
| 316 | `directory` = the configured directory, requires the record's app ∈ the |
| 317 | window's `apps`, and registers **exactly** the record's consumer ID and |
| 318 | audience. Mechanics: `roster.VerifyProvisioning(record, keys, binding)` |
| 319 | takes the *expected* bindings, so the verb first parses the record's |
| 320 | claimed consumer, app, team and audience, fixes `issuer` and `directory` |
| 321 | to the pinned values, verifies with those, and registers only what |
| 322 | verified. The audience was produced by the directory's `ValidateRoute` |
| 323 | against the team's own stored label, under the provenance fence. Collision |
| 324 | is checked against **`HOME_CONSUMERS` ∪ table**, on ID and origin. Returns |
| 325 | the registry digest (§7). So Alta's order is provision first, register |
| 326 | second. |
| 327 | - **What the credential role sees.** It never sees labels in its plans any |
| 328 | more; it sees hostnames only inside verified directory records. What it |
| 329 | cannot know is whether a label is taken — that is the directory's fence, |
| 330 | and the record is the only path in. |
| 331 | - `credential.retire-consumer` — marks a table consumer `retired`; |
| 332 | `/authorize` and sign-out refuse it. `origin` stays UNIQUE, so **a retired |
| 333 | app hostname is dead at Home for good** — the same rule as labels never |
| 334 | being reused (Paul, 2026-10-27). Re-adding a retired app to a team is not |
| 335 | supported. Env-manifest entries are out of reach. |
| 336 | - `directory.disable-consumer` — `team_instances.state = disabled`, |
| 337 | `roster_consumers.enabled = 0`, receipt with the existing `disable` value. |
| 338 | - `<role>.inspect` — **new code** on the credential role (it has no |
| 339 | `Inspect` today) and an extension on the directory (today it returns no |
| 340 | stream and refuses when stored pins differ, `inspect.go:105-110`): returns |
| 341 | generation (directory), next team id/sqid (directory), the role's |
| 342 | `(sequence, head)`, and its pending/open plan id and expiry (no plan |
| 343 | contents). It does **not** report label freedom; `seed-team` |
| 344 | refusing a taken label is the check. |
| 345 | - **Provenance fence (directory).** Every directory verb except `inspect` |
| 346 | and `initialize` may touch only a team whose `seed-team` committed through |
| 347 | this HTTP stream (`operator_http_teams(team_id, operation_id)`, written in |
| 348 | the seed's transaction). Production has **no teams today** (§12), so the |
| 349 | fence protects an empty set now and every future team not created here. |
| 350 | - **`directory.initialize`** keeps its precondition (no generation, no |
| 351 | consumer, no tokens, no bootstrap receipt — `directory.go:160-168`) and its |
| 352 | `baseline_attestation`, which is Paul's typed confirmation in Alta (§12), |
| 353 | carried in the `initialize` operation's input under Alta's signature, as |
| 354 | the existing verb has it — not repeated in the plan, which for |
| 355 | `initialize` carries no label, apps or name (round 4). It must be the directory stream's **first operation**: |
| 356 | the engine requires `initial_authority = true` at sequence 1 |
| 357 | (`engine.go:160-163`), and every other directory verb refuses `Initial`. |
| 358 | - **One stream per role.** The engine stores one operator identity per role |
| 359 | and refuses any other once one has acted. Alta will own both streams. |
| 360 | **Restore therefore needs Alta's key material** (or a separately reviewed |
| 361 | re-enrolment) until such a design exists. Restore through the native |
| 362 | command needs a reviewed profile regeneration first; until then it refuses |
| 363 | a database that has served over HTTP (round 4). |
| 364 | |
| 365 | **Refused, permanently or until their own design:** any membership write but |
| 366 | the seed's first owner (Team page — spec §10, `team-members.md`); rename; |
| 367 | relabel; label release; retired-consumer reactivation; restore or generation |
| 368 | change; token rotation; ownership transfer; team deletion; any read of |
| 369 | memberships, names or people. |
| 370 | |
| 371 | ## 6. What the endpoint may not do |
| 372 | |
| 373 | Return anything readable beyond the engine's result JSON (ids, outcome, |
| 374 | epoch, signed record, bearer, owner receipt); log anything but a fixed verb |
| 375 | label, outcome code and operation-id prefix (gate 9); restore, rotate keys |
| 376 | or re-initialize; act for a browser (no cookie read, no session minted on |
| 377 | `/operator/v1`). |
| 378 | |
| 379 | ## 7. Consumers beyond the 16-entry limit |
| 380 | |
| 381 | The cap exists because the credential origin's CSP names every manifest |
| 382 | origin in `form-action` (`security.go`, `runtime.go:102`). |
| 383 | |
| 384 | 1. **Per-response `form-action`.** The handoff page **and the |
| 385 | `signoutConfirm` page** (a same-origin POST that redirects to a preview |
| 386 | consumer) set `form-action 'self' <directory> <that one consumer's |
| 387 | origin>`. Every other credential page keeps `'self' <directory>`. |
| 388 | 2. **A credential `consumers` table** — `consumer_id` (PK), `origin` |
| 389 | (UNIQUE), `state` (`active` | `retired`), `created_at` (day), |
| 390 | `operation_id`; written only by §5's two credential verbs; cap 4,096 |
| 391 | (a trigger with its reason: a runaway Alta, not a scale target). |
| 392 | 3. **Readers see the union through one atomic pointer.** The effective |
| 393 | registry is an immutable map (`HOME_CONSUMERS` ∪ active table rows) held |
| 394 | in an `atomic.Pointer`, swapped after each committed write. Every reader |
| 395 | uses it: `exchange.go:41,78`, `security.go:13`, `signout.go:173`, |
| 396 | `dashboard_config.go:72`. |
| 397 | 4. **Collision refuses boot** (an ID or origin in both). That takes the |
| 398 | credential origin — and suite sign-in — down, which is correct and goes |
| 399 | in the runbook: remove the env entry, redeploy. |
| 400 | |
| 401 | Production `HOME_CONSUMERS` holds 7 entries today (§12); **Alta becomes the |
| 402 | 8th env entry** before the table lands. The directory needs nothing new |
| 403 | here: `team_instances` and `roster_consumers` are rows already. |
| 404 | |
| 405 | **New tables (additive)**, in their own migration sets |
| 406 | (`oficina_<role>_operator_http`, applied through `Runtime.ServingSchema()`; |
| 407 | round 4): credential `consumers` (with an `app` column, a compiled registry |
| 408 | slug, so `retire-consumer` can check the window's apps), `operator_plans` |
| 409 | (plan_id, pending/open, kind, apps, owner_index, expiry); directory |
| 410 | `operator_plans` (plan_id, pending/open, kind, label, apps, sealed display |
| 411 | name, expiry), `operator_http_teams`; both keep |
| 412 | `<role>_operator_state` / `_results` unchanged. No table ever holds signed |
| 413 | plan bytes or an address. |
| 414 | |
| 415 | ## 8. Threat model: a compromised provisioner |
| 416 | |
| 417 | An attacker holds Alta's operator key, prefilter token and CARLOS |
| 418 | credentials. |
| 419 | |
| 420 | - **Without Paul confirming on Home:** nothing at Home. On CARLOS, the |
| 421 | team-scoped credential reaches only Alta's own environments and instances |
| 422 | (ruling 8's condition); Home cannot bound that, CARLOS does. |
| 423 | - **If Paul confirms a plausible attacker plan:** for 15 minutes, the label |
| 424 | and apps **Paul saw on Home**, and the owner whose address **Paul typed**: |
| 425 | a new team, consumers at `<that label>.<app>.oficina.works`, activated. |
| 426 | Costs: a label and hostnames squatted for good (never reused). **Cannot:** |
| 427 | create a consumer for any existing team's hostnames (the credential role |
| 428 | registers only from a directory record, and the directory fence admits |
| 429 | only teams this stream seeded); add a member anywhere; read any |
| 430 | membership, name, address or content; mint a session; touch |
| 431 | `HOME_CONSUMERS`; rename. |
| 432 | - **Victim class, named:** the owner Paul typed — possibly Paul himself — |
| 433 | sees an attacker-run team in their chooser for those apps and may sign in |
| 434 | to it, handing that instance their `sub` and whatever they then type |
| 435 | there. Phishing, recorded, bounded by Paul having confirmed that label. |
| 436 | - **Replay:** single-sequence requests; plans single-use and expiring. |
| 437 | **Existence oracle:** the existing-only lookup at plan submit tells |
| 438 | Alta's key holder whether an address has a person — `owner-seed` already |
| 439 | does, so nothing new. |
| 440 | - **Compromised Home origins** are as in §13a of the spec. **Three signers |
| 441 | move into serving processes** (before, they lived only in the operator |
| 442 | command): the directory's provisioning signer; the credential role's |
| 443 | owner-seed signer; and the credential role's resolve key |
| 444 | (`team-members.md` §4). A directory compromise could sign provisioning |
| 445 | records and a credential compromise could sign owner receipts or member |
| 446 | resolutions — but each origin's compromise already concedes more (§13a), |
| 447 | and registration or seeding still needs Alta's key and a window Paul |
| 448 | opened. |
| 449 | |
| 450 | ## 9. The one rule and gates |
| 451 | |
| 452 | - **No readable address at rest.** The address reaches the credential role |
| 453 | three times (plan, confirm, owner-seed), is blind-indexed and dropped. |
| 454 | Plans hold the blind index; result rows hold `HMAC(idempotency key, |
| 455 | input)` and a sealed, address-free result. The directory sees person refs |
| 456 | only. |
| 457 | - **Spec §3.2's plaintext list gains:** consumer origins in the credential |
| 458 | DB (hostnames, which contain labels — never secret, and `HOME_CONSUMERS` |
| 459 | already held them); plan labels and app slugs in the directory DB; plan |
| 460 | kinds, apps and blind indexes in the credential DB; `memberships.added_at` |
| 461 | (day) from `team-members.md`. |
| 462 | - **Gate 1** drives the whole sequence (plan, both confirms, every verb) |
| 463 | with canary addresses and names; scans both databases, WAL and SHM. |
| 464 | **Gate 2** gains plan-submit, confirm and owner-seed-over-HTTP as address |
| 465 | paths — *extended, not replaced*; on the plan-submit path it asserts the |
| 466 | **signed plan bytes and the canary address are absent** from the file, WAL |
| 467 | and SHM, and that an expired plan's row is gone. **Gate 5** scans the credential confirm |
| 468 | page with canary labels present. **Gate 9** captures every log line, |
| 469 | hostile refusals included. **Gate 10** covers every new route. |
| 470 | |
| 471 | ## 10. Tests required before merge |
| 472 | |
| 473 | 1. **Mounting:** no routes without `HOME_OPERATOR_HTTP`; role separation; |
| 474 | Host spoofing refused. |
| 475 | 2. **Transport:** browser markers, size, content type, prefilter (fixed 401). |
| 476 | 3. **Signature:** wrong key/context, expired, sequence gap, changed input |
| 477 | under a used sequence; exact replay after expiry returns the stored |
| 478 | result and mutates nothing. |
| 479 | 4. **Ceremony:** plan signed by another key; a second pending plan |
| 480 | refused; differing `plan_id`s across roles refused at confirm (round 4: |
| 481 | unbuildable across two databases; each confirm POST refuses any id but |
| 482 | the one its GET showed, and Paul compares the prefix on both pages); confirm by |
| 483 | a non-operator subject → 404; directory confirm with stale or future |
| 484 | `auth_time`; credential confirm with a stale session (a fresh intent is |
| 485 | written and the forced sign-in returns to `/operator/confirm` — no loop |
| 486 | for a Keymail identity), a Keymail session with no gesture, a |
| 487 | **recovery-code session** (refused), a mistyped owner address; confirm |
| 488 | after plan expiry; `seed-team` with a display name not matching the |
| 489 | plan's sealed name byte for byte; expired plan rows deleted; a fresh |
| 490 | intent with a missing or invalid nonce is ignored (no loop — plain |
| 491 | sign-in); the fresh-intent cookie is cleared after a successful confirm; |
| 492 | the reserved consumer value in a fresh intent is refused by |
| 493 | `handleAssertion`'s consumer lookup (it can never mint an assertion). |
| 494 | 5. **Scope:** other label, app outside `apps`, verb outside `kind`, window |
| 495 | expiring mid-run, expired owner receipt then a fresh `owner-seed`. |
| 496 | 6. **Blocker 2:** `register-consumer` without a record, with a record signed |
| 497 | by another key, for an app outside the window, for an origin in |
| 498 | `HOME_CONSUMERS`; a record for a pre-existing team is unobtainable |
| 499 | (fence). |
| 500 | 7. **Registry:** 17th and 4,097th consumer; env/table collision refuses |
| 501 | boot; retired consumer refused at `/authorize` and sign-out; the handoff |
| 502 | and `signoutConfirm` CSPs name exactly one consumer; concurrent reads |
| 503 | during a swap (race detector). |
| 504 | 8. **Mutation:** removing the window check, the fence, the record |
| 505 | verification or the typed-owner comparison each fails a named test. |
| 506 | 9. **Privacy and survival:** gates per §9; existing sessions, keys and team |
| 507 | ciphertexts survive the additive migrations (reopen with the old binary). |
| 508 | 10. **Canary** on deployed previews: Alta creates `alpha` and `beta`; each |
| 509 | owner sees only their team; the seven existing consumers keep working. |
| 510 | |
| 511 | ## 11. Alternatives rejected |
| 512 | |
| 513 | - **Forwarding Paul's assertion from Alta to Home** (round 0) — unbuildable |
| 514 | with the shared consumer, and Paul would approve Alta's rendering, not |
| 515 | Home's copy. |
| 516 | - **`carlos run` against Home's database** — no fence, no launch context; a |
| 517 | database edit from outside in all but name. |
| 518 | - **Alta writing Home's database or holding a Home signing key** — a third |
| 519 | Home origin. |
| 520 | - **Signature only** — rejected by Paul: Alta's key would be a standing |
| 521 | ability to mint teams. |
| 522 | - **Waiting for platform 117** — still blocked at platform `57aec0a`. |
| 523 | |
| 524 | ## 12. Pre-flight facts and the confirmation Paul gives |
| 525 | |
| 526 | **Evidence, 2026-10-27, 21:06 UTC** — read-only `carlos db query --app |
| 527 | oficina` on a restored replica copy, transaction 3140: production directory |
| 528 | has `teams` = 0, `memberships` = 0, `team_instances` = 0, |
| 529 | `roster_generation` = 0, `roster_consumers` = 0, `roster_tokens` = 0, |
| 530 | `directory_operator_state` = 0, `directory_operator_results` = 0. So |
| 531 | `directory.initialize`'s four-empty-tables precondition holds, and **Alta's |
| 532 | first production run is an `initialize` plan**. |
| 533 | |
| 534 | **Required pre-flight confirmation:** Paul confirms, against that evidence, |
| 535 | that this directory database has **never** issued a roster generation or |
| 536 | consumer record (Home cannot prove historical absence after a possible |
| 537 | restore; `home-provisioner.md`). Alta signs that confirmation as |
| 538 | `baseline_attestation`. |
| 539 | |
| 540 | **If a generation were ever present,** `initialize` refuses and no other |
| 541 | directory verb can open the stream (blocker 3). That needs a separately |
| 542 | reviewed `directory.enrol` first operation; it is **not designed here**. |
| 543 | |
| 544 | **Production `HOME_CONSUMERS`** (credential role, `oficina-id`, as |
| 545 | `HOME_CONSUMERS_BASE64`) holds **7** entries: calendar, calls, directory, |
| 546 | docs, memoria, sheets, slides. Alta is added as the 8th env consumer before |
| 547 | §7's table lands; the 16 cap applies until then. |
| 548 | |
| 549 | ## 13. Review findings: disposition |
| 550 | |
| 551 | **Round 1.** Blocker 1 → §4 (option b). Blocker 2 → §3, §5, §8. Blocker 3 → |
| 552 | §5, §12. Blocker 4 → `team-members.md` §2. Blocker 5 → `team-members.md` §3, |
| 553 | §5; §9. Non-blocking: supersessions §2 items 3, 5, 6; "verbs wrapped" §1, |
| 554 | §5; `allowedAction` §3; header dropped §4; window semantics and receipt |
| 555 | renewal §4; inspect is new code and reports no label freedom §5; retired |
| 556 | hostnames dead for good §5; atomic swap, union readers, `signoutConfirm`, |
| 557 | runbook §7; victim class §8; §3.2 list §9; stream ownership and restore §5; |
| 558 | `HOME_CONSUMERS` count §12. |
| 559 | |
| 560 | **Round 2.** Blocker 1 (plan bytes) → §4 step 1, §9 gate 2, §10.4. Blocker |
| 561 | 2 (fresh consumer not mountable) → §4 sequencing prerequisite, |
| 562 | `team-members.md` §2. Blocker 3 (credential confirm loop, lost target) → §4 |
| 563 | step 3 (no query, `credentialReturn`, sealed fresh intent, GET and POST |
| 564 | re-checks). Recovery-code sessions refused on the credential page; the |
| 565 | directory's inherited gap stated (§4 step 2). Same `plan_id` on both roles, |
| 566 | shown on both pages (§4). Display name bound by the directory plan (§4, |
| 567 | window semantics). Order advisory; 15-minute block, no cancel (§4). Three signers |
| 568 | in serving processes (§8). Mounting outside CSRF and sessions (§4). |
| 569 | `VerifyProvisioning` mechanics (§5). Existence oracle (§8). Alta and Team |
| 570 | page notes applied in those files. None declined. |
| 571 | |
| 572 | **Round 3 (APPROVED, design).** Non-blocking notes applied: `name_digest` |
| 573 | dropped, byte comparison in `seed-team` (§4, §7); fresh intent with random |
| 574 | nonce, cleared on consumption, reserved consumer refused by |
| 575 | `handleAssertion` (§4 step 3, §10.4); §10.4 additions (invalid nonce |
| 576 | ignored, cookie cleared). The `lagged-team` blank keys, PLATFORM timing and |
| 577 | Docs prefix preflight are applied in `team-provisioning-app.md` §6. |
| 578 | |
| 579 | **Round 4 (implementation, discussion 94).** Whole-code review of branch |
| 580 | `operator-http` by Claude Fable 5.1 (claude-fable-5-1) at `2f1cac8`: CHANGES |
| 581 | REQUIRED (narrow); the three blockers — registration admission equal to the |
| 582 | registry reload's, a test of `retire-consumer`'s app scope, and this entry — |
| 583 | are fixed on the same branch. Deviations from the text above, each with the |
| 584 | review's ruling: |
| 585 | |
| 586 | 1. The new tables live in their own migration sets, applied by |
| 587 | `Runtime.ServingSchema()`; `Runtime.Schema()` and the frozen |
| 588 | compatibility, admission and legacy-diagnostic profiles are unchanged, and |
| 589 | the native command refuses a database carrying them (§5's restore |
| 590 | sentence). **Accepted** — restore stays gated and platform 117 does not |
| 591 | exist. The legacy diagnostic skips exactly this set, so a true mismatch is |
| 592 | not hidden behind a standing false one. |
| 593 | 2. `consumers.app`, a compiled slug under a `CHECK`. **Accepted** (§7). |
| 594 | 3. §10.4's cross-role `plan_id` refusal is unbuildable; each confirm POST |
| 595 | carries the id its GET showed and refuses any other. **Accepted** — the |
| 596 | buildable half of round 2's ask, and tested. |
| 597 | 4. `baseline_attestation` stays in `initialize`'s signed input. **Accepted** |
| 598 | (§5). |
| 599 | 5. A stale, future, Keymail-without-gesture or recovery session on the |
| 600 | credential page is redirected to sign-in with the fresh intent rather than |
| 601 | shown a refusal page; no window opens. **Accepted.** |
| 602 | 6. An open window makes a second confirm answer 409 until it expires. |
| 603 | **Accepted** (§4). |
| 604 | 7. The role's own keys from `HOME_OPERATOR_MATERIAL`. **Accepted** (§3). |
| 605 | 8. `<role>.inspect` required in `actions`. **Accepted** (§3). |
| 606 | 9. `TestNoHandlerSetsItsOwnCSP` exempts `security.go`, whose |
| 607 | `setConsumerPolicy` may only add one registered consumer to form-action. |
| 608 | **Accepted.** |
| 609 | |
| 610 | **Alta review (oficina/alta discussion 1, Claude Fable 5.1, mismatch ruling |
| 611 | 5).** `directory.activate-consumer` required `app_version` to be a 40-hex |
| 612 | commit, a leftover of the platform-attestation design that item 6 of §2 |
| 613 | already weakened: every app's `/api/version` answers `git describe --tags |
| 614 | --always`, so no team instance could be activated. `version()` now admits |
| 615 | the observed token, `^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$`; the field's name, |
| 616 | type and canonical encoding, and every other activation check, are |
| 617 | unchanged. Rejected: stamping 40-hex into each app's Makefile, which takes |
| 618 | away the human version Paul reads on `/api/version` to confirm a deploy. |
| 619 | |
| 620 | **For a later amendment (design note, not a deviation):** |
| 621 | `credential.retire-consumer` is app-scoped, not team-scoped — the credential |
| 622 | role sees no labels — so a confirmed `retire-apps` window admits retiring any |
| 623 | table consumer of those apps for any team, and the credential page cannot |
| 624 | show Paul which. The mirror of `register-consumer`'s record derivation would |
| 625 | be a directory-signed `disable` receipt. Weigh it before a second team |
| 626 | exists. |
| 627 | |