oficina / home Public

Spec rev 5: Fable's fourth review applied (not re-reviewed)

Human

Prompt

Revision 5 of spec/oficina-id-native, same branch; push, update discussion 112 + task 110, report tip + changelog. Don't merge. Status: "revision 5: Fable's fourth READY AFTER FIXES applied; not re-reviewed". No new rulings needed โ€” these are fixes within Paul's rulings. [Fable fourth pass @1b74278: items 1-6 plus the choose page's request-forgery protection.]

From this commit's own message. The prompt ledger has no entries for it — which is what a squashed, rebased or amended commit looks like, and what every commit looks like in a repo without a ledger.

Summary

Unavailable roster stays 503 on both paths, and byte-for-byte is defined as status, body and header set (1). NativeExchange's real order: verify, read, Admit with no tx and the 409 before any jti write, then one tx, with Unlinked outside it because EnsureHome opens its own writer (2). The no-app-session precondition is restored, the choose POST refuses with a session present, and Connect consumes the proof (3). The choose landing is reached via the Fail hook and lands on the default path (4). Native choice gates are added and Admit joins the set-together invariant (5). Sign-out pre-signs /native/v1/signout before deleting the key (6). The choose page's request-forgery protection is specified.
Agent notes
Doc only. 264 lines.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev b6aea352f657432d25c0ea29613465aed2c7ae87 parent 1b74278
1 file changed, +29 −21
  • docs/superpowers/specs/2026-11-14-oficina-id-native.md +29 −21

CI cancelled โ€” superseded by a newer push — run details

diff --git a/docs/superpowers/specs/2026-11-14-oficina-id-native.md b/docs/superpowers/specs/2026-11-14-oficina-id-native.md
index d6a4f45..05f688e 100644
--- a/docs/superpowers/specs/2026-11-14-oficina-id-native.md
+++ b/docs/superpowers/specs/2026-11-14-oficina-id-native.md
@@ -1,6 +1,6 @@
# ๐Ÿค– Oficina ID: the native slice
-Status: revision 4: Paul's fork ruling (2026-11-14) and Fable's third READY AFTER FIXES applied; not re-reviewed. Author: Claude (`claude-opus-5-5`) against Home `e9829fd`. Fable reviewed revisions 1 (`4cc21a8`), 2 (`7acf2a1`) and 3 (`575e824`), each READY AFTER FIXES; every finding is applied. No implementation, deployment or merge approval.
+Status: revision 5: Fable's fourth READY AFTER FIXES applied; not re-reviewed. Author: Claude (`claude-opus-5-5`) against Home `e9829fd`. Fable reviewed revisions 1 (`4cc21a8`), 2 (`7acf2a1`), 3 (`575e824`) and 4 (`1b74278`), each READY AFTER FIXES. Every finding is applied; no new rulings were needed. No implementation, deployment or merge approval.
## 1. Decision and boundary
@@ -99,13 +99,12 @@ The label is the email typed on this device. After a passkey-only sign-in, the l
**1. Home: `POST /native/v1/assert {aud, challenge}` โ†’ `{assertion}`.** `challenge` = SHA-256 of a fresh 32-byte verifier. Home maps `aud` (an origin) to a consumer by exact match in `consumers()`. It refuses the operator consumer. Home calls **`mintPolicy(consumer, method)`**, one shared function that `/authorize` also calls. It is empty in slice A; Contra's passkey-only rule lands there later. Claims are slice 1's v1: 120 s, a fresh `jti`, the person ref as `sub`, and the grant's `auth_time`. **Home sets the nonce itself:** `H("oficina-id/native/v1\0" โ€– challenge)`. A grant holder therefore cannot obtain a web-handle nonce (ยง12) from this call. There is no `max_age`, and native never links.
-**2. Instance: `POST <origin>/native/oficina-id {assertion, verifier, target?}`.** This is `connect.Bridge.NativeExchange`. It takes JSON only, sets no cookies and refuses `Origin`. In one writer transaction it:
-1. verifies the assertion: pinned keys, exact issuer and audience;
-2. recomputes the native nonce from the verifier. A grant holder cannot obtain an assertion with a browser or web nonce from `assert`, and this endpoint accepts only the native one;
-3. reserves `(iss,jti)` in `oficina_handoff_replay`;
-4. resolves the link, then the Home-only person, then ยง8's member choice;
-5. rechecks admission;
-6. mints with method `home-assertion-native`.
+**2. Instance: `POST <origin>/native/oficina-id {assertion, verifier, target?}`.** This is `connect.Bridge.NativeExchange`. It takes JSON only, sets no cookies and refuses `Origin`. It runs in this order:
+1. **Verify** the assertion (pinned keys, exact issuer and audience) and recompute the native nonce from the verifier. A grant holder cannot obtain an assertion with a browser or web nonce from `assert`, and this endpoint accepts only the native one.
+2. **Read** the link, then the Home-only person, with no write.
+3. **Decide.** If there is neither, call `Admit` with **no transaction open**: it is `Runtime.Check` and may wait on a roster fetch, and `runtime.go:89-92` forbids calling it while holding the writer. A non-member gets the unknown answer, an unavailable roster gets 503, and a Member gets 409 `choose`. All three return here, before any `jti` write (ยง8).
+4. **One writer transaction.** Reserve `(iss,jti)` in `oficina_handoff_replay`, re-resolve the link and the Home-only person, recheck admission, and mint with method `home-assertion-native`.
+5. **Allocate, only with `choice:"new"` from a Member.** This happens between step 3 and the mint, outside the transaction. `Unlinked` takes no transaction (`connect/api.go:69`), and Docs' `EnsureHome` opens its own writer transaction (`principalstore/store.go:176-183`), so calling it inside step 4 would deadlock until the busy timeout. It is idempotent and re-checks before it creates, and step 4 re-resolves the person it made.
The verifier gives the "only the requester redeems" property without slice 1's pending row; a native client has no ambient browser for login CSRF to exploit. There is no Continue page (Paul's ruling A(i)).
@@ -115,20 +114,29 @@ The verifier gives the "only the requester redeems" property without slice 1's p
## 8. No account forks: members choose (Paul's ruling, 2026-11-14)
-**The rule, on both paths.** It replaces revision 3's instance-wide rule. When an assertion's subject has no link and no Home-only person, `connect` takes the **roster decision first**, through a new non-allocating hook `Admit(ctx, issuer, subject)`, which is teammode's `AdmitUnlinked` decision. It never asks whether the team has local or email accounts.
-- **Non-members, an unavailable roster, and instances without `Unlinked`** get today's "unknown" answer **byte for byte**: the same status, page, copy and link-resuming marker (`bridge.go:229`). Natively that answer is `403 {"state":"unknown"}`, identical for every such subject.
-- **Only a roster Member with no link** gets the choice, and nothing is allocated until they choose. A guest's local account therefore never blocks a new member's first sign-in.
+**The rule, on both paths.** It replaces revision 3's instance-wide rule. When an assertion's subject has no link and no Home-only person, `connect` takes the **roster decision first**, through a new non-allocating hook `Admit(ctx, issuer, subject)`: teammode's `AdmitUnlinked` decision. It never asks whether the team has local or email accounts. `Admit` is set together with `Unlinked` and `HomeOnly`, or not at all, which extends `bridge.go:53`'s invariant.
-**Browser.** `/auth/finish` stores a sealed, single-use choice proof (subject, `auth_time`, browser-bound with a `__Host-` cookie, 10 minutes). It then 303s to `GET /account/home/choose`, a page with request-forgery protection.
+**What each subject gets:**
+- **A non-member, or any subject on an instance without the hooks:** today's "unknown" answer **byte for byte**, meaning the same status, body and set of headers. The link-resuming marker cookie (`bridge.go:229`) is freshly sealed each time, so only its value differs. Natively the answer is `403 {"state":"unknown"}`, identical for every such subject.
+- **An unavailable roster:** stays today's 503 "try again" on both paths, exactly as now (`teammode/runtime.go:130` โ†’ Docs `errTeamUnavailable`, `oficina/docs internal/docs/home_connect.go:215,225` โ†’ `connect/bridge.go:224-225,234-235`).
+- **A roster Member with no link:** gets the choice. Nothing is allocated until they choose, so a guest's local account never blocks a new member's first sign-in.
+
+**The app-session precondition stays.** Today, allocation is reachable only when no app session is present (`bridge.go:219-223`, `api.go:55-58`). If any app session is present at finish, the answer is today's unknown plus the marker, decided **before** `Admit` and with no proof issued.
+
+**Browser.** `Complete` records the state `choose` together with a sealed, single-use choice proof. The proof holds the subject and `auth_time`, is bound to the browser by a `__Host-` cookie, and lives 10 minutes. The Fail hook (`result.state`, as with "unknown") then 303s to `GET /account/home/choose`. `handoff.Finish` keeps the return path and hands `Complete` only the claims (`handoff/http.go:265-274`), so after a choice the person lands on **the default path**, `/`.
+
+**Request-forgery protection** on the choose page is ยง12's pattern: the form token is an HMAC of the choice-proof cookie, and the POST requires an exact same-origin `Origin`. The page:
- Title: "Welcome to the team".
- Body: "Do you already have an account here that signs in with email? Connect it, and your Oficina ID will open it from now on. If you're new here, continue with Oficina ID."
-- Button **"Connect my existing account"** goes to `/signin/local`, with the link-resuming marker set, and then to slice 1's linking.
-- Button **"I'm new here โ€” continue with Oficina ID"** POSTs. That consumes the proof, rechecks `Admit` and that there is still no link, allocates through `Unlinked`, and mints.
-- Unlink clears pending choice proofs together with the other pending sets.
+- **"Connect my existing account"** consumes the proof, then goes to `/signin/local` with the link-resuming marker set, then to slice 1's linking. Abandoning the link step afterwards therefore leaves no proof to press "I'm new here" with.
+- **"I'm new here โ€” continue with Oficina ID"** POSTs, and the POST **refuses when an app session is present**. Otherwise it consumes the proof, rechecks `Admit` (with no transaction open) and that there is still no link, allocates through `Unlinked`, then mints in one writer transaction that re-resolves the person.
+- Unlink clears pending choice proofs along with the other pending sets.
-**Native.** `NativeExchange` answers a Member with no link `409 {"state":"choose"}`, rolling back so that nothing, not even the `jti`, is kept. The app then offers the same two labelled routes:
+**Native.** With no `choice`, a Member with no link always gets `409 {"state":"choose"}` and nothing is allocated. The app then offers the same two labelled routes:
- **"Connect my existing account"** opens `<origin>/account/home` in the default browser. That is `connect`'s link start, which signs in locally first (`navigation.go:95-110`).
-- **"I'm new here โ€” continue with Oficina ID"** gets a fresh assertion and re-posts with `choice:"new"`, which allocates under the same rechecks.
+- **"I'm new here โ€” continue with Oficina ID"** gets a fresh assertion and re-posts with `choice:"new"`. The client sends `choice` only from this button.
+
+`choice` is ignored for a linked or Home-only subject. A non-member who sends `choice:"new"` gets the identical `403` unknown.
**Scope of the change.** In `connect`:
- `Bridge.complete` calls `Admit` in place of `Unlinked`;
@@ -136,7 +144,7 @@ The verifier gives the "only the requester redeems" property without slice 1's p
- `NativeExchange`;
- `Config.Admit`, which all five apps wire to teammode.
-The browser `Finish` keeps today's shape (`handoff/http.go` `Finish`: `Store.Finish`, then `Complete`), so the browser path is **not** claimed to be one transaction. Allocation happens only in the explicit choice handlers, which recheck before allocating. The apps' `Unlinked` takes `ctx` and re-checks before it creates (their `EnsureHome`; slice A confirms this in Docs before relying on it). The proof is single-use, so a race between two choices yields one person.
+The browser `Finish` keeps today's shape (`handoff/http.go` `Finish`: `Store.Finish`, then `Complete`), so the browser path is **not** claimed to be one transaction. Allocation happens only in the explicit choice handlers, which recheck before allocating. The apps' `Unlinked` takes `ctx`, opens its own writer transaction and re-checks before it creates (Docs' `EnsureHome`, `principalstore/store.go:176-183`), so it is never called with the writer held. The proof is single-use, so a race between two choices yields one person.
## 9. Teams, store, onboarding
@@ -152,8 +160,8 @@ The browser `Finish` keeps today's shape (`handoff/http.go` `Finish`: `Store.Fin
## 10. Sign-out and revocation
-**"Sign out of <label>" (Paul's ruling I).** The app first deletes the identity's key, token, record and cache locally, and notifies the other apps. Then, best effort with 5-second timeouts:
-1. `POST /native/v1/signout` revokes the grant;
+**"Sign out of <label>" (Paul's ruling I).** The app first signs the `POST /native/v1/signout` request with the device key and holds it, along with the token, in memory. Then it deletes the identity's key, token, record and cache locally, and notifies the other apps. Then, best effort with 5-second timeouts:
+1. it sends the pre-signed `POST /native/v1/signout`, which revokes the grant. The proof's `iat` window is 30 s, so a request that cannot be sent in time is dropped; the grant then ends at expiry or through "Sign out all devices";
2. each app sends `POST /native/web/end`, authenticated by its still-valid native session, to every instance it holds a session on. That ends that person's `home-native-web` browser sessions on the instance, **from all their devices**, as disclosed;
3. each app sends `POST /signout` for its cached sessions.
@@ -202,7 +210,7 @@ Sign-out always completes locally, and nothing loops.
**Proof:** refused for a wrong key, a replayed `jti` (also across a restart), a full table (fails closed), a skewed `iat`, a wrong `htu`, a swapped body, or an `Origin` header; no `jti` row before the grant and signature verify; the per-grant rate limit.
-**Assert and exchange:** an unregistered `aud` is refused; `mintPolicy` is shared with `/authorize`; refused for a wrong verifier, a web nonce, a replay, or a swapped audience; the roster decision comes first. Non-members, an unavailable roster and instances without `Unlinked` get byte-identical responses on both paths, whether or not the instance has local accounts. A Member gets the choice and nothing is allocated before it. A guest's local account never blocks a new member's first sign-in. A choice proof is single-use, browser-bound and expiring; `IsHomeDerived` everywhere; 7-day refusal; concurrent exchange, unlink and relink.
+**Assert and exchange:** an unregistered `aud` is refused; `mintPolicy` is shared with `/authorize`; refused for a wrong verifier, a web nonce, a replay, or a swapped audience; the roster decision comes first. **Byte-identical:** non-members and instances without the hooks get the same status, body and header set on both paths, whether or not the instance has local accounts (the marker's value excepted). **Roster unavailable:** 503 on both paths. **Native with no `choice`:** a Member with no link always gets 409, and nothing is allocated. **`choice:"new"`:** ignored for a linked or Home-only subject; a non-member who sends it gets the identical 403. **Hooks:** `Admit`, `Unlinked` and `HomeOnly` are set together or not at all. **App session at finish:** gets unknown plus the marker, with no proof issued. **Choose POST:** refused when an app session is present. **Connect:** consumes the proof. **No `jti` is written** before the 409. `Admit` is never called with the writer held. A guest's local account never blocks a new member's first sign-in. A choice proof is single-use, browser-bound and expiring, and its form token is bound to its cookie; `IsHomeDerived` everywhere; 7-day refusal; concurrent exchange, unlink and relink.
**Revocation:** first passkey enrolment revokes the passkey-less grants; recovery-based replacement and "Sign out all devices" revoke every grant; a duplicate `identity_id` revokes the new grant; sign-out works against a **hanging** issuer.