Spec rev 3: Paul's answers A-J and lifetimes, Fable's second review applied (not re-reviewed)
Human
Prompt
Revision 3 of spec/oficina-id-native, same branch; push, update discussion 112 + tasks 110/111, report new tip + changelog + line count. Don't merge. Status line: "revision 3: Paul's answers A–J and lifetimes (2026-11-14) and Fable's second READY AFTER FIXES applied; not re-reviewed". [Paul's answers A(i), A(ii)a, B a with N3 fix, C (moved to slice B), D a, E a, F accepted, G none, H Alta/help text, I a, J Paul's machines only, Q4 confirmed; NEW: fix the browser fork now. Fable re-review @7acf2a1: N1-N10, lows, slice A additions, cuts to ~250 lines.]
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
Records Paul's 2026-11-14 rulings A-J and confirmed lifetimes (no open questions remain), amends slice 1's browser allocation with the same no-fork rule (AllocatesHomeOnly in the writer transaction, /account/home/connect-first), and applies Fable's re-review of 7acf2a1: receipt-then-GET /native/web/finish (N1), Home-chosen domain-separated native vs web nonces plus a match number (N2), per-(address,key) caps with returning-key exemption and corrected B cost (N3), starts-table numbers and ip_bucket (N4), connect.IsHomeDerived (N5), mintPolicy wording (N7), first-enrolment revocation (N8), jti after verify with per-grant limit (N9), Keymail sheet moved to A2 and ephemeral (N10), lows; recovery moved to slice B; minimal Sign out all devices in A; evidence, later slices and migration moved to appendices; 238 lines.
Agent notes
Doc only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+133
−285
docs/superpowers/specs/2026-11-14-oficina-id-native.md+133 −285
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 828058c..fa453df 100644 |
| --- a/docs/superpowers/specs/2026-11-14-oficina-id-native.md |
| +++ b/docs/superpowers/specs/2026-11-14-oficina-id-native.md |
| @@ -1,390 +1,238 @@ |
| # 🤖 Oficina ID: the native slice |
| -Status: revision 2: Paul's answers of 2026-11-14 and Fable's READY AFTER FIXES review applied; not re-reviewed. Author: Claude (`claude-opus-5-5`), against Home `e9829fd`. Revision 1 (`4cc21a8`) was reviewed by Fable, who returned READY AFTER FIXES. Every finding from that review is applied here. §17 holds Paul's answers so far and the questions still open. There is no implementation, deployment or merge approval. |
| +Status: revision 3: Paul's answers A–J and lifetimes (2026-11-14) and Fable's second READY AFTER FIXES applied; not re-reviewed. Author: Claude (`claude-opus-5-5`) against Home `e9829fd`. Fable reviewed revision 1 (`4cc21a8`) and revision 2 (`7acf2a1`), returning READY AFTER FIXES both times; this revision applies every finding. No implementation, deployment or merge approval. |
| ## 1. Decision and boundary |
| -This spec extends [Oficina ID slice 1](2026-11-13-oficina-id-slice-1.md) and does not replace it. Wherever this spec is silent, slice 1 binds. Slice 1 left "native deep-link delivery" out of scope; this is that native half. |
| - |
| -**Paul, 2026-11-14 (BRIEF):** |
| -- Oficina ID is one account across every app and team, named "Oficina ID" on screen. |
| -- Native sign-in is in-app email plus a 6-digit code, with Mail one-time-code AutoFill, and passkeys. |
| -- Several Oficina IDs can be signed in at once, each with its own switchable teams. |
| -- One sign-in is shared by all five native apps (Calls, Docs, Sheets, Calendar, Memoria) on Mac and iPhone. |
| -- Moving from an app to the web is seamless: the web opens signed in, in the same account and team. |
| - |
| -**Paul, 2026-11-13:** every app keeps its own sign-in **and** offers "Sign in with Oficina ID". |
| - |
| -**Paul, 2026-11-14 (answers to revision 1):** |
| -- **Q1 (a):** native passkey sign-in ships in the first slice. The email code is for people with no passkey yet. Slice 1's rule stays intact. |
| -- **Q2 (a):** Keymail approval in an in-app browser sheet, with "Email me a code instead". |
| -- **Q5 (a):** several web IDs are labelled by their teams' names. |
| -- **Q7:** Docs is the first app. |
| -- **Recommended answers taken unless Paul objects:** Q6 (team colour derived on the device) and Q4 (lifetimes, provisionally). |
| -- **Not decided:** Q3 and Q8 are re-asked in reframed form (§17). |
| +This spec extends [Oficina ID slice 1](2026-11-13-oficina-id-slice-1.md) and binds wherever it differs from it. Elsewhere slice 1 governs. It covers the native half that slice 1 left out, and one amendment to slice 1's browser path (§8). Paul's rulings are in §16. Evidence and line references are in Appendix A. Slices C–E are specified in Appendix B. |
| **Out of scope:** Contra, CallKit/PiP, provisioning, roster writes and per-item grants. |
| -**What Home learns.** Home still gains no readable address, no content and no device name. It does learn three new things: |
| -- that a person has N signed-in devices, each with a self-reported platform and a `last_used_day`; |
| -- each native assert's audience, at least daily per app and team, which tells it what is in use, roughly. It sees that at request time and never stores it: the replay store keeps a hash and an expiry only; |
| -- a sealed address while an email code is live. |
| - |
| -## 2. Evidence |
| +**What Home learns.** Home still gains no readable address, content or device name. It does learn three things: that a person has N signed-in devices, each with a self-reported platform and a `last_used_day`; each native assert's audience, at least daily per app and team (seen per request, stored only as a replay hash); and a sealed address while an email code is live. |
| -**Today, no device holds an identity.** A native "account" is a host plus an instance cookie (`native-levelup/reports/calls.md` §B3, `docs.md` §3). |
| -- The rastrillo/native browser approval keeps pending requests in memory, 256 at most for 5 minutes each (`rastrillo-native/server/auth.go:23-37`). |
| -- Calls has a one-slot store of its own (`calls.md` §C). |
| -- Keychain items are per app, with no access group (`sheets.md` §3). |
| -- On iPhone the code compare is impossible, and a link that opens in another browser hangs (`calls.md` §B3). |
| +## 2. Ground facts |
| -**What Home has:** |
| -- P-256 assertion minting (`internal/home/exchange.go:72-146`) against an exact consumer registry (`consumer_registry.go`). |
| -- The passkey gate on both email paths (`id_recovery.go:71-92`). |
| -- Persistent attempt buckets in `home_id_attempts` (`identity/migrations/0002_recovery.sql`). |
| -- Recovery-method guards on enrolment (`id_passkey.go:128`) and on linking (`exchange.go:115`). |
| -- 30-day browser sessions (`app.go:123`). |
| -- The in-memory email budget, 20 per IP and 5 per address per 15 minutes, which a deploy resets (`app.go:146-147`). |
| -- In the directory, the `teams`, `team_instances` and `memberships` tables, populated today only for Alta- or operator-provisioned teams, and `Store.AgentChoices` (`directorydata/store.go:129-177`). |
| +**Mac.** Slice 0 checked this on macOS 27 with Paul's Developer ID, 2026-11-14. A Developer ID app that claims `keychain-access-groups` or `associated-domains` without an embedded provisioning profile is **killed at launch**. The team-prefixed App Group `9U4A84C4WK.works.oficina` works on Mac without a profile. iOS uses `group.works.oficina`. Profiles are therefore a hard prerequisite. |
| -**All five apps import `connect`.** Its completion resolves a link, then a Home-only person. On a team-mode instance it then *allocates* a Home-only person for any roster member who arrives unlinked (`connect/bridge.go:214-227`; `api.go:47-64`). |
| - |
| -**rastrillo sessions have one TTL per `Sessions`**, so the lifetime cannot vary per mint (`sessions/sessions.go:65-69,235`). |
| - |
| -**The Mac spike, Paul's team Developer ID on macOS 27, run 2026-11-14:** |
| -- A Developer ID app that claims `keychain-access-groups` or `associated-domains` without an embedded provisioning profile is **killed at launch**. |
| -- The team-prefixed App Group `9U4A84C4WK.works.oficina` works on Mac without a profile. |
| -- `group.works.oficina` needs registering, and on macOS 15 and later it prompts. |
| -- iOS uses `group.works.oficina`. |
| -- rastrillo/native's branch `native/levelup-phase0-tools` now embeds and validates profiles. |
| +**connect today** treats only `HomeMethod`, `magiclink` and `keymail` as sessions (`connect/bridge.go:75,251-255`; `routes.go:149`). rastrillo sessions have one TTL per process (`sessions/sessions.go:65-69`). |
| ## 3. The native credential |
| -**On the device.** Each identity has a P-256 device key and a 32-byte random grant token. |
| -- The key lives in the Secure Enclave where there is one, and otherwise is a software key. |
| -- Both sit in the data-protection keychain under the shared access group `9U4A84C4WK.works.oficina.id`, marked `AfterFirstUnlockThisDeviceOnly`. They never sync and are never exported. |
| -- The data-protection keychain is mandatory on Mac, and the access group needs the profile. **There is no profile-free version of this section.** A Mac build without its profile is killed at launch, so §16's launch gate is required. |
| - |
| -**At Home.** A new credential-database table, `home_id_grants`, holds: |
| -- `grant_hash` (the primary key, SHA-256 of the token), `person_ref`, `identity_id`, `device_key`, `platform`, `method`, `auth_time`, `created_at`, `last_used_day` and `expires_at`; |
| -- `identity_id`: an opaque, stable per-person value, HMAC(person ref) under a dedicated Home key, so the global ref never reaches devices; |
| -- `platform`: whatever the client claims (`mac`/`ios`), so Devices labels built from it are self-reported. |
| - |
| -It holds no address, no device name and no app list. A person has at most 20 live grants, and a 21st revokes the one least recently used. |
| - |
| -**Proof of possession.** Every native call carries two headers: `Authorization: OficinaID <token>` and `Oficina-Proof: base64url(payload).base64url(sig)`. |
| -- The payload is `{v:1, htm, htu, iat, jti, bh=SHA-256(body)}`, signed with rastrillo `crypto` under the context `oficina-id/native-proof/v1`. It is not a JWT and has no algorithm field. |
| -- Home requires a live grant, a valid signature, `htu` equal to the exact request URL, and `|iat−now| ≤ 30 s`. |
| -- Home also requires an unseen `jti`. Seen ones go into a **persistent** table with a clock watermark that survives restarts, as `handoff`'s replay table does. The table is capped, and once full every call **fails closed**. |
| -- Every response carries Home's time (`Date` header, and `now` on a 401) so clients can diagnose clock skew. |
| -- **No rotation.** Five apps share one item and would race each other, and possession of the key already gives what rotation would. |
| - |
| -**Lifetime (Q4, provisional).** A grant lasts 90 days idle and 365 days absolute. `auth_time` is the time of the sign-in gesture. Using the grant never refreshes it; only a new factor ceremony on the same grant does. |
| - |
| -**Revocation** comes from: |
| -- device sign-out (§10); |
| -- the Devices page (§10); |
| -- expiry; |
| -- passkey replacement by recovery code. Slice 1's "revoke all Home sessions" **includes every grant**. |
| - |
| -## 4. In-app email code (for people with no passkey yet) |
| - |
| -The endpoints live under `https://id.oficina.works/native/v1/`. They take JSON only, answer `no-store`, have no CORS and render nothing. A request carrying `Origin` or `Sec-Fetch-Site` is refused. |
| +**On the device.** Each identity has two secrets: a P-256 **device key**, in the Secure Enclave where there is one, otherwise a software key; a 32-byte random **grant token**. |
| -**`POST code/start {email, device_key, platform}` → `202 {start, resend_after}`.** |
| -- Classification matches `/signin`. A Keymail address takes Keymail approval in an `ASWebAuthenticationSession` sheet, with "Email me a code instead" (Q2a). The approval returns through a fixed `works.oficina.<app>://id` callback carrying a one-time `start`, never a credential, which the app redeems with its proof. |
| -- Otherwise Home stores a `home_id_native_starts` row: `start_hash`, the address sealed under `native.code`, `device_key`, `ip_bucket`, `code_mac`, `sends`, `attempts` and `expires_at`. Then it mails the code. |
| -- The answer is the same for a known address and a new one. |
| +Both sit in the data-protection keychain, in the shared access group `9U4A84C4WK.works.oficina.id`, with `AfterFirstUnlockThisDeviceOnly`. They are never synced or exported. There is no profile-free variant. |
| -**`POST code/resend`**, proved by the start's key, replaces the code: at most 3 sends, 30 s apart. |
| +**At Home: `home_id_grants`.** Columns: `grant_hash`: SHA-256 of the token, primary key; `person_ref`; `identity_id`: HMAC of the person ref under a dedicated Home key; `device_key`; `platform`: self-reported; `method`; `auth_time`; `created_at`; `last_used_day`; `expires_at`; `revoked_at`. Revoked rows keep `device_key` for 365 days so that §4 can recognise a returning device. |
| -**`POST code/verify`** finds or mints the person, as `completeSignIn` does (`signin.go:399`), and runs `idGate`'s check. |
| -- With no passkey enrolled, it returns `{grant, identity_id, auth_time}`. |
| -- With one enrolled, it returns `{factor:["passkey","recovery"], pending}`: valid 5 minutes, bound to the start and its key. That keeps slice 1's rule as written. |
| +A person holds at most 20 live grants. A 21st revokes the least recently used. Devices store `identity_id`, never the person ref. The ref does reach the app in transit, as the `sub` of the assertions it forwards; the app neither parses nor stores it. |
| -**Codes.** |
| -- Six uniform random digits, stored as HMAC-SHA256 under a Home key and compared in constant time. |
| -- A code lives 10 minutes, is used once, and dies after 5 wrong tries. |
| -- One code is live per (blinded address, device key). |
| +**Proof.** Every call carries `Authorization: OficinaID <token>` and `Oficina-Proof: base64url(payload).base64url(sig)`. The payload is `{v:1, htm, htu, iat, jti, bh=SHA-256(body)}`, signed with rastrillo `crypto` under the context `oficina-id/native-proof/v1`. There is no JWT and no algorithm field. Home checks that the grant is live and the signature verifies, that `htu` is the exact request URL, and that `|iat−now| ≤ 30 s`; each response carries `Date` (and `now` on a 401), from which the client corrects its clock offset. Only **after** those pass does `jti` go into a persistent replay table. That table survives restarts, holds 60 s of entries, is limited to 120 calls per grant per minute, and fails closed when full. |
| -**Limits.** All buckets here are persistent, so a deploy resets nothing. |
| -- Starts spend the web's in-memory budget, so the two sign-in routes never double the allowance, and also persistent per-address and per-IP buckets. |
| -- Verify failures go in their own `native-code:` buckets, never shared with recovery codes: 5 per blinded address and 20 per IP per 15 minutes, plus a **daily per-address cap** (Q8). Neither restarts nor parallel requests reset them. |
| +The calls made before a grant exists are `code/*` and `passkey/begin`/`finish` without a grant. They are proof-only, signed by the start's key, or by the supplied key for a discoverable passkey. They never touch the `jti` table: their single-use start or challenge is their replay protection. Grants never rotate. Five apps share one item, so rotation would race, and holding the key is the possession proof. |
| -**The starts table.** It holds at most 10,000 live rows and **at most 20 live starts per IP**. When either is full, new starts get `503` "Try again shortly" and existing starts still verify. The web's link sign-in is untouched, because it uses a different table. ~750 IPs could still fill the table for 10 minutes: disclosed. |
| +**Lifetime (Paul, confirmed).** A grant lasts 90 days idle and 365 days absolute. `auth_time` is the time of the sign-in gesture. A new factor ceremony on the same grant updates `method` and `auth_time` together. Using a grant never updates them. |
| -**Privacy.** The address is sealed before the write and erased at verify or expiry, under `secure_delete`. Gates 1, 2 and 9 extend to the new table. |
| +**Revocation.** A grant ends in five ways: device sign-out (§10); "Sign out all devices" (§10); expiry; passkey replacement by recovery code, which revokes every grant; a **first passkey enrolment**, which revokes every grant whose `method` has no passkey, except the grant that enrolled. |
| -**Strength, stated plainly (Q8).** |
| -- **Guessing.** With 5 failures per address per 15 minutes, a sustained attacker gets ~480 guesses a day, about 17% a year to take over an account that has no passkey. A daily cap of 20 failures cuts that to under 1% a year. |
| -- **Relaying.** A code can be relayed by a phishing page. A link signs in only the browser that clicks it. |
| -- **Lockout.** An attacker can lock an address out of code sign-in with ~96 mails a day. |
| -- **Mitigations on the table:** the daily cap, falling back to link-only (browser) sign-in for that address until the next day, and prompting every code-only account to make a passkey right after it signs in. |
| +## 4. Email code, for people with no passkey yet |
| -**The mail.** |
| -- Subject "Your Oficina ID code"; first line "Your Oficina ID code is 123456"; then the expiry and "ignore this if you didn't ask". |
| -- **No link.** A link would sign in a browser, not the app. |
| -- `.textContentType(.oneTimeCode)` turns on Mail AutoFill. That AutoFill is on-device Apple Mail only and depends on the wording, and it is least certain in Mac fields, so slice 0 spikes it with the real HTML mail on both platforms. |
| -- Without AutoFill, the field still accepts typing and paste, and resend and back still work. |
| +**Endpoints.** They live under `https://id.oficina.works/native/v1/`. They take JSON only, answer `no-store`, have no CORS and render nothing. Any request carrying `Origin` or `Sec-Fetch-Site` is refused. |
| -## 5. Native passkeys (first slice, Q1a) |
| +**`POST code/start {email, device_key, platform}` → `202 {start, resend_after}`.** Home classifies the address the way `/signin` does. In slice A, Keymail addresses also get a code: that is Q2's own "Email me a code instead" fallback. The Keymail sheet arrives in A2 (§9). Home then stores a `home_id_native_starts` row and mails the code. The row holds: `start_hash`; the address, sealed under `native.code`; `device_key`; `ip_bucket`; `code_mac`; `sends`, `attempts` and `expires_at`. |
| -**The association file.** Every build carries `webcredentials:id.oficina.works`. The credential role serves a static `/.well-known/apple-app-site-association` (`application/json`, no redirect). |
| -- It lists each distinct App ID, `9U4A84C4WK.works.oficina.<app>`: five if Mac and iPhone share a bundle ID, up to ten if not. |
| -- It holds no account-authored string, and no `applinks` for `id.*`. |
| +The answer is identical for known and new addresses. |
| -**Slice A's critical path.** Because of Q1a, three things now sit on it: profiles for all Mac builds, this file, and Apple's CDN fetching it. |
| +**`code/resend`** replaces the code. A start gets at most 3 sends, 30 s apart. |
| -**Sign-in.** `POST passkey/begin {pending?}` returns WebAuthn options: |
| -- discoverable with no `pending`, so "Sign in with a passkey" needs no email; |
| -- restricted to the person with `pending`. |
| +**`code/verify`** finds or mints the person, as `completeSignIn` does, and then runs `idGate`'s check: with no passkey, it returns `{grant, identity_id, auth_time}`; with a passkey, it returns `{factor:["passkey"], pending}`, valid 5 minutes and bound to the start and its key. Recovery is added in slice B. |
| -The challenge is single-use, valid 5 minutes, bound to the device key, and limited by `home_id_ceremonies`. |
| +**Codes.** Six uniform digits. The server keeps only an HMAC-SHA256 under a Home key and compares in constant time. A code lives 10 minutes, is used once, and dies after 5 wrong tries. One code is live per (blinded address, device key). |
| -The app calls `ASAuthorizationPlatformPublicKeyCredentialProvider(relyingPartyIdentifier: "id.oficina.works")`. |
| +**Where the IP comes from.** The IP is the last `X-Forwarded-For` element written by the CARLOS edge, the same as `clientIP` in `signin.go`. `ip_bucket` is the IPv4 /32 or the IPv6 /64. |
| -`POST passkey/finish` runs Home's existing verification: exact RP and origin, user verification, the person binding. It returns `{grant, identity_id, auth_time}` with method `passkey` or `email+passkey`. |
| +**Limits.** All buckets are persistent; none uses the `home_id_attempts` keys that recovery uses. |
| -`LegacyRPID` stays empty. Slice 0 confirms on a real device that `clientDataJSON.origin` is `https://id.oficina.works`. |
| - |
| -**Recovery.** `POST recovery {pending, code}` is the twin of `/passkey/signin/recovery`. It mints an `email+recovery` grant for sign-in only: no enrolment, no step-up, and no linking. Replacing a lost passkey stays on the web. Ten codes exist, and regenerating them needs a passkey session on the web, so routine native sign-in that spends codes is a question (Q-C). |
| - |
| -**Enrolment (slice B).** `passkey/register/{begin,finish}` needs `auth_time` within `enrolFreshness` (`passkey.go:30`), on a method that is neither recovery- nor `native-web`-derived. It uses slice 1's generated names. The first enrolment shows the ten codes **once**, under `e9829fd`'s rules. Slice A prompts code-only accounts to make one on the web. |
| - |
| -## 6. Names and labels on the device |
| - |
| -An identity is keyed by its `identity_id`. Signing in with an `identity_id` already present answers "Already signed in". |
| +| Bucket | Limit | |
| +|---|---| |
| +| Starts per address | 5 per 15 min and 20 per day | |
| +| Starts per IP bucket | 20 per 15 min and 200 per day | |
| +| Wrong codes per (address, device key) | 5 per 15 min | |
| +| Wrong codes per address, from device keys that never held a grant for that person | **20 per day** (B) | |
| +| Live starts | 10,000 in total, at most 20 per IP bucket | |
| -Its label is the email typed on this device. After a passkey-only sign-in, the label is its teams' names ("paulca, tito"), consistent with Q5, until the person types an email to label it. That email is never sent. |
| +**Returning devices.** A device key that has held a grant for that person (a live or revoked grant row) is exempt from the per-address start and daily caps. It keeps only its own 5-per-15-minutes limit. |
| -Home holds no name or avatar, so the app shows initials from the label. |
| +**Full table.** When the starts table is full, new starts get `503` "Try again shortly", and existing starts still verify. Filling it takes 500 IP buckets; that is disclosed. The web's link sign-in is unaffected. |
| -## 7. Credential to per-app, per-team session, with no browser |
| +**Privacy.** The address is sealed before the write and erased at verify or expiry, under `secure_delete`. Gates 1, 2 and 9 extend to this table. |
| -**1. Home: `POST /native/v1/assert {aud, nonce}`** returns `{assertion}`. |
| -- `aud` is an origin. Home maps it to a consumer by exact match in `consumers()` and refuses the operator's reserved consumer. |
| -- Home applies the **same per-consumer minting policy as `/authorize`**, judged on the grant's `method`. For example, Contra's passkey-only rule refuses an email or recovery grant. |
| -- The claims are slice 1's v1: 120 s, a fresh `jti`, `sub` set to the person ref, and the grant's `auth_time`. |
| -- `nonce` = base64url(SHA-256(`"oficina-id/native-nonce/v1\0"` ‖ verifier)), using a fresh 32-byte verifier. That makes it domain-separated from browser nonces. |
| -- There is no `max_age`. **Native never links.** |
| +**What B costs (corrected).** The daily cap holds guessing to 20 a day from new devices, under 1% takeover a year for an account with no passkey. An attacker can spend that cap with about 4 mails a day (4 starts × 5 wrong codes). That blocks **new-device** code sign-in for the address until the next day. Returning devices and passkeys are unaffected. |
| -**2. Instance: `POST <origin>/native/oficina-id {assertion, verifier, target?}`**, a new `connect.Bridge.NativeExchange`. It takes JSON only, sets no cookies and refuses `Origin`. In one writer transaction it: |
| -1. verifies the assertion against the pinned keys, exact issuer and exact audience; |
| -2. checks the nonce; |
| -3. reserves `(iss,jti)` in `oficina_handoff_replay`; |
| -4. resolves link → `HomeOnly`; |
| -5. rechecks admission and mints. |
| +A blocked new device sees: "Too many attempts for this address today. Use a passkey, or a device you've signed in on before." The code is relayable by a phishing page, which a link is not; that is disclosed. |
| -**Allocation (fixes the fork).** NativeExchange may allocate a Home-only person through `Unlinked` **only** if the app declares, through a new hook `NativeAllocates()`, that the instance is in team mode and holds **no local account with an address**. Alta-fresh teams pass. Any other instance answers `403 {"state":"link_in_browser"}` and allocates nothing, and the app offers "Connect this account on the web", which runs slice 1's linking. The browser completion can fork in the same way today. That belongs to slice 1 and is noted here, not changed. |
| +**The nudge.** After every code-only sign-in, the app offers "Make a passkey". Native enrolment arrives in slice B; until then the app offers it on the web. |
| -**No pending row.** This is a justified addition. Slice 1's pending row and browser secret stop login CSRF. A native client has no ambient browser to fix an assertion onto, and the verifier gives the same "only the requester redeems" property, with no unauthenticated state on the instance. |
| +**The mail.** It has no link, because a link would sign in a browser. Subject: "Your Oficina ID code". First line: "Your Oficina ID code is 123456". Then the expiry, and "ignore this if you didn't ask". The field uses `.textContentType(.oneTimeCode)`. Slice 0 checks Mail AutoFill with the real HTML mail on both platforms. Without it, typing and paste still work. |
| -**No Continue page (Q-A i).** The request is the person's own tap, made with a key held on the device. |
| +## 5. Native passkeys (slice A, Q1a) |
| -**Session lifetime.** Natively minted sessions use a new method, `home-assertion-native`. `connect.ResolveSession` refuses one older than 7 days from `At`. That makes the lifetime **absolute and not sliding**, enforced in `connect` because rastrillo has one TTL per `Sessions`. The app re-mints after 24 hours and on any 401. Slice 1's unlink must delete both `HomeMethod` and `home-assertion-native` sessions. |
| +**Associated domain.** Every build carries `webcredentials:id.oficina.works`. The credential role serves a static `/.well-known/apple-app-site-association` (`application/json`, no redirect). It lists each distinct App ID `9U4A84C4WK.works.oficina.<app>`, which is 5 if Mac and iPhone share bundle IDs and up to 10 if not. It holds no account-authored text and no `applinks`. The profiles, this file and Apple's CDN fetch are all on slice A's critical path. |
| -## 8. Teams |
| +**Sign-in.** |
| +1. `passkey/begin {pending?}` returns discoverable WebAuthn options, so "Sign in with a passkey" needs no email. With `pending` it is restricted to that person. The challenge is single-use, lasts 5 minutes, is bound to the device key, and counts within `home_id_ceremonies`. |
| +2. The app runs `ASAuthorizationPlatformPublicKeyCredentialProvider(relyingPartyIdentifier: "id.oficina.works")`. |
| +3. `passkey/finish` runs Home's existing verification: exact RP and origin, user verification, and the person binding. It returns `{grant, identity_id, auth_time}`, with method `passkey` or `email+passkey`. |
| -The directory is a consumer like any instance. The app gets a directory session through the same `NativeExchange`, then calls `GET https://oficina.works/api/native/teams` → `[{sqid, label, name, role, apps:[{app, origin, consumer_id}]}]`. |
| -- It reads `Store.AgentChoices` in one snapshot, filtered to live instances of the five apps, `no-store`. |
| -- The app uses `origin` exactly as returned; native apps never use portero (portero §2.2). |
| -- It refreshes at launch, on opening the menu (at most every 5 minutes), and on any 403. |
| +`LegacyRPID` stays empty. Slice 0 confirms that `clientDataJSON.origin` is `https://id.oficina.works`. |
| -**What is missing.** |
| -- A team hue: derived on the device from `sqid` (Q6). |
| -- Display names and avatars: none, by design. |
| -- Invited-but-unjoined teams: these are instance-side. |
| -- The last-used team: device state (ruling 22). |
| +**Recovery (slice B, Paul's ruling C).** `POST recovery {pending, code}` mints an `email+recovery` grant. That grant is for sign-in only: no enrolment, no step-up, no linking. Routine sign-in may spend recovery codes. The app shows how many remain and prompts when fewer than 3 are left. Replacing a lost passkey stays on the web. |
| -**Zero teams.** After open signup, or before an invitation is accepted, the list is empty. Onboarding shows "You're not in a team yet", with what to do next (Q-H). |
| +**Enrolment (slice B).** `passkey/register` needs `auth_time` within `enrolFreshness`, on a method that contains neither `recovery` nor `native-web`. It shows the ten recovery codes once, under `e9829fd`'s rules, and revokes the passkey-less grants (§3). |
| -**Prerequisite.** Only Alta- or operator-provisioned teams populate the tables this reads, and Alta's team runs are blocked on CARLOS platform mail today. If Paul's teams don't exist when slice A lands, slice A shows nothing. Paul's teams must exist through Alta or the operator path before slice A can be tested. |
| +## 6. Names on the device |
| -## 9. Device store, onboarding, several identities |
| +An identity is keyed by `identity_id`. If a mint returns an `identity_id` already on the device, the app says "Already signed in" and revokes the duplicate grant at once. |
| -**Store (RastrilloApple).** Every record carries `v`, a schema version. An app that meets a newer record never rewrites it. It reads what it understands and asks for an update ("Update Oficina Docs to use this Oficina ID"). |
| -- **Shared keychain group:** one record per identity (`v`, `grant_id`, `identity_id`, label, `added_at`), its key and token, and **its team cache**. Team names stay in the keychain because a Mac App Group container of an unsandboxed app is readable by any process running as the same user. |
| -- **App Group:** `9U4A84C4WK.works.oficina` on Mac and `group.works.oficina` on iOS. It holds only the identity order and the last-used (identity, team). |
| -- **Each app's private keychain:** that app's instance sessions, keyed `(grant_id, origin)`. |
| -- `works.oficina.id.changed` tells the other apps to reread. The store holds at most 5 identities. |
| +The label is the email typed on this device. After a passkey-only sign-in, the label is the identity's team names, until the person types an email to label it; that email is never sent. There is no name or avatar: the app draws initials. |
| -**Onboarding.** |
| -1. Welcome. |
| -2. "Sign in with a passkey", or Email, then Code. |
| -3. A passkey or recovery code, if required. |
| -4. Team: skipped when there is one; "no team yet" when there is none. |
| +## 7. Credential to team session, without a browser |
| -A second app offers "Continue as …" or "Use another". |
| +**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. |
| -**Account menu.** Identities, each with its teams, then Add Oficina ID…, Manage… and Sign Out of <label>. |
| -- On Mac, ⌃⌘1…9 switch teams, and each window keeps its own pair. |
| -- Switching is blocked mid-call and while edits are unsaved. |
| +**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 browser or web nonce never matches; |
| +3. reserves `(iss,jti)` in `oficina_handoff_replay`; |
| +4. resolves the link, then the Home-only person; |
| +5. may allocate only under §8's rule, evaluated in this same transaction; |
| +6. rechecks admission; |
| +7. mints with method `home-assertion-native`. |
| -## 10. Sign-out per identity, and revocation |
| +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)). |
| -**"Sign out of <label>"** acts locally at once. It deletes the identity's key, token, record and team cache, then posts a notification; every app drops the identity. |
| +**One predicate.** `connect.IsHomeDerived(method)` is true for `HomeMethod`, `home-assertion-native` and `home-native-web`. Resolve, `ResolveSession`, `existingPerson`, `signedIn`, the same-person check, unlink and sign-out all use it in place of today's literal checks. |
| -Then, best effort with 5-second timeouts: |
| -- `POST /native/v1/signout` revokes the grant; |
| -- each app `POST /signout`s its cached sessions and deletes them; |
| -- any session found later under a missing grant is revoked at launch. |
| +**Lifetime (Paul, confirmed).** `connect` refuses a `home-assertion-native` or `home-native-web` session more than **7 days** after its `At`: absolute, not sliding. The app re-mints after 24 hours and on any 401. Unlink deletes every `IsHomeDerived` session. |
| -Nothing waits on Home, and a test proves it against an issuer that **hangs**. |
| +## 8. No account forks: native and browser (Paul's new ruling) |
| -**Devices page.** `https://id.oficina.works/devices` lists grants with fixed, self-reported labels and offers Revoke and "Sign out all devices". It needs a fresh session and request-forgery protection. |
| +**The rule.** A new hook, `AllocatesHomeOnly(tx)`, is true only when the instance is in team mode **and** holds no local account with an address. Alta-fresh teams pass. It is evaluated inside the minting writer transaction, for **both** paths: `NativeExchange`; slice 1's browser completion, the `FinishAtomic` callback. **This amends slice 1:** `connect`'s `Unlinked` allocation runs only when `AllocatesHomeOnly` is true. |
| -**Disclosed residuals.** |
| -- An offline device keeps its instance sessions for up to 7 days after a remote revoke. |
| -- Browser sessions opened through §12 outlive app sign-out and Devices revoke unless Paul chooses otherwise (Q-I). Under Q-I (a), app sign-out also asks each instance to end that person's `home-native-web` browser sessions. |
| +**When it is false**, nothing is allocated. **Browser.** `/auth/finish` 303s to `GET /account/home/connect-first`. The link-resuming marker is already set (`bridge.go:229`). The page reads: title: "Connect this account first"; body: "This team has accounts that sign in with email. Sign in with your email once, then we'll connect your Oficina ID — after that, Sign in with Oficina ID works here"; buttons: "Sign in with email" (to `/signin/local`, after which linking begins) and "Cancel". **Native.** The app gets `403 {"state":"connect_first"}` and offers two labelled routes: "Connect on the web", which opens `/account/home/connect-first` explicitly in the default browser (§12); "Sign in with email instead", which is this app's own sign-in (§11). |
| -There is no per-team sign-out. |
| +## 9. Teams, store, onboarding |
| -## 11. Outages |
| +**Teams.** The directory is a consumer. The app gets a directory session through `NativeExchange`, then calls `GET https://oficina.works/api/native/teams` → `[{sqid, label, name, role, apps:[{app, origin, consumer_id}]}]`. The list comes from `Store.AgentChoices`, filtered to live instances of the five apps, and is `no-store`. Apps use the returned origin as given. They never use portero. The app refreshes at launch, on opening the menu (at most every 5 minutes), and on any 403. The team colour is derived on the device from `sqid`. **Zero teams (Paul's ruling H):** once Alta runs, the empty state offers "Create a team" through Alta. While Alta is blocked, slice A shows help text only. Slice A needs Paul's teams to exist first, through Alta or the operator path. |
| -**Credential origin down.** |
| -- No new identities, and no new or renewed sessions. |
| -- Live sessions run until they expire, and cached teams still show. |
| -- A team with no live session shows "Can't reach Oficina ID", with Try again and the app's own sign-in (§14). |
| +**Store (RastrilloApple).** Every record carries `v`. An older app reads what it understands, never rewrites a newer record, and asks for an update. **Shared keychain group:** each identity's record, key, token and **team cache**. Team names stay out of the Mac App Group because an unsandboxed app's group container is readable by any process running as the same user. **App Group** (`9U4A84C4WK.works.oficina` on Mac, `group.works.oficina` on iOS): identity order and the last-used (identity, team) only. **Each app's private keychain:** its sessions, keyed `(grant_id, origin)`. |
| -**Directory down.** The cache is used, and minting still works. |
| +`works.oficina.id.changed` tells the other apps to reread. |
| -**Instance down.** The app shows its offline banner. |
| +**Slice A (Docs):** one identity; onboarding: Welcome, then "Sign in with a passkey" or Email → Code, then a passkey if required, then Team (skipped when there is one; the empty state when there are none); the "Make a passkey" nudge; the zero-teams help text. |
| -In every case sign-out completes locally, and nothing loops. |
| +**Slice A2 adds:** up to 5 identities; the account menu (identities, the teams under each, Add, Manage, "Sign out of <label>"), with ⌃⌘1…9 on Mac and a per-window (identity, team), blocked mid-call or with unsaved edits; the Keymail sheet: ephemeral `ASWebAuthenticationSession` (`prefersEphemeralWebBrowserSession = true`, so no Safari cookies). The approval mints **no Home browser session**, only a one-time `start` returned to a fixed `works.oficina.<app>://id` callback, which the app redeems with its proof; the Devices page. |
| -## 12. Native → web, and the web changes it needs |
| +## 10. Sign-out and revocation |
| -**Copy Link and Handoff** carry the plain team URL. |
| +**"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; |
| +2. each app sends `POST /signout` for its cached sessions; |
| +3. each app sends `POST /native/web/end`, authenticated by its 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. |
| -**Opening any web page from an app** goes through `id.*`, or explicitly in the default browser. On Mac, `NSWorkspace.open` of the app's own universal link can loop back into the app. Teams self-hosted on other domains get no universal links, only the custom scheme. |
| +Sessions found later under a missing grant are revoked at launch. Nothing waits on Home; the tests use a hanging issuer. |
| -**"Open on the web" (slice D):** |
| -1. `POST /native/v1/web {aud, path}`, with a grant and a proof, returns `https://id.oficina.works/native/web/<handle>`. The handle is 32 bytes, single-use, lives 60 s and is never logged. It is sealed and bound to the person, the consumer, a validated local `path`, the grant's `method` and its `auth_time`. |
| -2. **GET only renders** a fixed-text page: "Open Oficina Docs on the web as the Oficina ID from your app? If you didn't just choose Open on the web in an Oficina app, close this page." The page has a **Continue POST** (same-origin, request-forgery protected). Prefetchers, link scanners and an attacker's `302` therefore consume nothing. |
| -3. The POST mints **no Home session and no `id.*` cookie**. It issues a one-shot assertion for that consumer only, with `auth_time` from the grant. It delivers it through slice 1's form POST to a fixed instance entry, `/native/web/finish`, which mints a browser session with method `home-native-web` and lands on `path`. |
| +**Sign out all devices (slice A).** A minimal **"Sign out all devices"** in `id.*`'s account menu, behind a fresh session and request-forgery protection, revokes every grant. The full Devices page, with fixed self-reported labels and per-grant Revoke, comes in A2. |
| -**The method is never fresh.** If any Home session is ever derived from a handle, its method is `native-web+<grant method>` (for example `native-web+email+recovery`). Every freshness check refuses a method containing `native-web`: enrolment, codes, linking `max_age` and step-up, alongside today's `recovery` tests (`id_passkey.go:128`, `exchange.go:115`). A gate proves it. |
| +**Disclosed residual.** An offline device keeps its team sessions for up to 7 days after a remote revoke. |
| -**Why a handle may ride a URL path.** Slice 1 keeps *assertions* out of URLs, because an assertion is redeemable at a consumer. A handle is not: it is redeemable only at `id.*`, only by a POST behind a confirmation, once, within 60 s. A used handle in browser history is dead. The "never rides a shared URL" rule holds, because the handle never enters Copy Link or Handoff. |
| +## 11. Outages, and each app's own sign-in |
| -**The residual login-CSRF risk (Q-A ii).** An attacker can mint a handle from their own grant and lure a victim to it. A victim who presses Continue lands in the attacker's team session. Without the confirmation page, that would happen silently. |
| +| Down | Behaviour | |
| +|---|---| |
| +| Credential origin | No new identities, sessions or renewals. Live sessions run to expiry and cached teams show. A team without a session shows "Can't reach Oficina ID", with Try again and the app's own sign-in. | |
| +| Directory | The team cache is used; minting still works. | |
| +| Instance | The app's offline banner. | |
| -**Web multi-account (slice E).** |
| -- `id.*` holds a session set: up to 5 sessions in a sealed `__Host-oficina-ids` cookie, with "current" picked by the intent's subject (`exchange.go:107`). The directory holds the same set. |
| -- Labels are the teams' names (Q5a). |
| -- An instance keeps one session per host, so two IDs on one team host collide on that host's cookie in a browser. Disclosed. |
| -- Web → app is universal links plus a custom-scheme "Open in the app" button. |
| -- Code entry on the web door is Q-G. |
| +Sign-out always completes locally, and nothing loops. |
| -## 13. Universal links and AASA hosting |
| +**Each app's own sign-in (Paul, 11-13).** "Other ways to sign in…" keeps the server address and rastrillo/native's browser approval (`/native/request|start|authorize|exchange`), for self-hosted servers and local accounts. |
| -Each app claims `applinks:<app>.oficina.works` and `applinks:*.<app>.oficina.works`. For the wildcard, the system fetches the association file from the bare host, which portero answers. So **portero serves `/.well-known/apple-app-site-association`**, a static file with no label in it (a portero follow-up). Team hosts serve the same file. Slice 0 checks the fetch against Apple's CDN. |
| +## 12. Native → web, "Open on the web" (slice D) |
| -**Paths.** Each app lists its item routes (for Calls: `/m/*`, `/j/*`). The file excludes `/auth/*`, `/signin*`, `/signout*`, `/native/*`, `/account/*`, `/api/*` and `/.well-known/*`. |
| +**Opening any page** goes through `id.*` or explicitly in the default browser, never via the app's own universal link, which on Mac can loop back into the app. Copy Link and Handoff carry the plain team URL. |
| -**Routing.** When a link opens, the app checks which identities hold a team on that origin: |
| -- one identity: use it; |
| -- several: **always ask, never default**, and remember per team only if the person asks it to; |
| -- none: Calls offers the guest choice (§14), and the other apps offer "Add an Oficina ID" or "Open in browser". |
| +**Open on the web, step by step (Paul's ruling A(ii)(a)):** |
| +1. **The app asks for a handle.** `POST /native/v1/web {aud, path}`, with grant and proof, returns a URL, `https://id.oficina.works/native/web/<handle>`, and a two-digit **match number** that the app shows ("Check the browser shows 47"). The handle is 32 bytes, single-use, sealed and never logged, and bound to the person, the consumer, a validated local `path`, the grant's `method` and its `auth_time`. |
| +2. **The browser opens the link.** The GET must arrive within 60 s. It renders a fixed-text page: the match number; "Open Oficina Docs on the web as the Oficina ID from your app? If you didn't just choose Open on the web, close this page."; **Continue**. |
| -## 14. Calls guests, the apps' own sign-in, migration |
| + The GET consumes nothing. It sets a sealed `__Host-` confirmation cookie, and the form's request-forgery token is an HMAC of that cookie. |
| +3. **The person presses Continue.** The POST is accepted within 5 minutes of the GET, with an exact same-origin `Origin`. It mints **no Home session and no `id.*` cookie**. It signs a one-shot assertion for that consumer, with nonce `H("oficina-id/native-web/v1\0" ‖ handle id)` and the grant's `auth_time`, and posts it to `/native/web/finish`. |
| +4. **The instance receives it (N1, copying `handoff.Callback`, `handoff/http.go:211-243`).** `POST /native/web/finish` requires the exact issuer `Origin`. It recomputes the web nonce from the handle id in the form, stores a sealed receipt, sets a `__Host-` inbox cookie, and 303s to `GET /native/web/complete`. |
| +5. **The instance finishes.** The GET carries the Lax session cookie. In one writer transaction it consumes the receipt and checks the existing session. If a different person is signed in, it refuses with "Another account is signed in here. Sign out of it first", and nothing is replaced. Otherwise it mints a `home-native-web` session (7 days absolute, §7) and lands on `path`. |
| -**Guests (Q-E).** A link to a Calls instance where none of your teams lives never asserts silently: an assertion would hand that operator, possibly a self-hoster, your stable cross-team subject. Slice 1 deferred pairwise subjects for exactly that reason. The default is **Join as a guest by name**, today's flow. "Use Oficina ID <label>" is offered with the line "This meeting's server will learn your Oficina ID", and with two IDs the person picks one. |
| +**Which assertion goes where.** `/native/web/finish` accepts only web nonces. `NativeExchange` and `/auth/assertion` never match them: they recompute native nonces, or look up their own pending nonces. |
| -An assertion-backed guest is admitted only with a valid, unconsumed invitation, `/j/{token}`, checked and consumed in the same transaction as the mint. `/m/{sqid}` alone proves only that the meeting exists and grants nothing beyond Calls' existing lobby and knock. The visit is held in memory, as today (`native_auth.go:56-87`, `calls.md` §C). Name-only guests keep "Join in the app" (`native_auth.go:349-421`). Push registers per stored (identity, team). |
| +**Never fresh.** Any method containing `native-web` is refused at enrolment, codes, linking and step-up, alongside the `recovery` checks (`id_passkey.go:128`, `exchange.go:115`). |
| -**Each app's own sign-in (11-13).** "Other ways to sign in…" keeps the server address and rastrillo/native's browser approval, for self-hosted servers and local accounts. |
| +**Handles may ride a URL path, assertions may not.** The handle is redeemable only at `id.*`, only through a confirmed POST, once. |
| -**Migration (Q-J).** `works.oficina.*` builds start at Welcome, and that is the migration. |
| -- **Custom schemes.** Old `net.amadan.oficina.*` builds still claim the custom schemes, and whichever launched first wins. The old apps must be deleted. |
| -- **Sparkle.** Each old appcast needs one final release saying "Download the new app". |
| -- **Permissions.** Camera and microphone permissions reset under the new bundle IDs. |
| -- **Till.** Till's `lagged` team is a second user. |
| +**Residual.** A victim lured to an attacker's handle who presses Continue despite a mismatched number lands in the attacker's team session. |
| -## 15. Gates |
| +## 13. Gates (slices 0–A2; later gates are in Appendix B) |
| -**Codes.** |
| -- No address at rest, and no address or code in logs. |
| -- Code entropy, expiry and single use. |
| -- Persistent buckets (separate from recovery's), including the daily cap, that survive restart and parallel requests. |
| -- The per-IP live-start cap, and 503 when the starts table is full. |
| -- The same answer for known and unknown addresses. |
| -- An enrolled account never gets a grant from a code alone. |
| +**Codes:** no address at rest, and no address or code in logs; entropy, expiry and single use; persistent buckets that survive a restart and parallel requests; the per-(address, key) and daily caps, and the returning-key exemption; per-IP-bucket live starts, and 503 when the table is full; identical answers for known and unknown addresses; no grant from a code alone on an enrolled account. |
| -**Proof.** Refused for a wrong key, a replayed `jti` (including across a restart), a full replay table (fails closed), a skewed `iat`, a wrong `htu`, a swapped body, or an `Origin` header. |
| +**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.** An unregistered `aud` is refused. So is a grant method the consumer's policy refuses. |
| +**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; `AllocatesHomeOnly` is false → nothing allocated, on both the native and the browser path, evaluated in the transaction; `IsHomeDerived` everywhere; 7-day refusal; concurrent exchange, unlink and relink. |
| -**Exchange.** Refused for a wrong verifier, a replay or a swapped audience. An unknown subject gets `link_in_browser` and nothing is allocated on an instance with local accounts. Concurrent exchange, unlink and relink are tested. A `home-assertion-native` session is refused after 7 days. |
| +**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. |
| -**Handles.** A GET consumes nothing. A POST without the confirmation is refused. A handle is single-use, expires, is bound to its consumer, and refuses a foreign path. A handle mints no Home session. |
| +**Domains:** the association file's content; RP ID exactly `id.oficina.works`; `LegacyRPID` empty. |
| -**Freshness.** Any `native-web` method is refused at enrolment, codes, linking and step-up. |
| +**Mac launch:** the final signed, notarised artifact of every Mac build **launches and reads the shared group** before any Sparkle publish. A build killed at launch cannot update itself. |
| -**Revocation.** Passkey replacement revokes every grant. Native sign-out and Devices revoke both work against a **hanging** issuer. |
| +## 14. Slices |
| -**Domains.** The association file's content and excluded paths. The RP ID is exactly `id.oficina.works`, and `LegacyRPID` is empty. |
| +| Slice | Contents | |
| +|---|---| |
| +| **0a** | Profiles on every build; the Mac App Group ID; the launch gate; a shared Secure Enclave key read by two apps. | |
| +| **0b** | The association file on `id.*` plus Apple's CDN; spikes for passkey `clientDataJSON.origin` and Mail AutoFill on both platforms. | |
| +| **A** | **Docs**, one identity. **Home:** grant and proof, code (Keymail addresses included), native passkey sign-in, `assert`, `signout`, "Sign out all devices", replacement revoking every grant. **connect:** `NativeExchange`, `IsHomeDerived`, the 7-day limit, the `AllocatesHomeOnly` rule on **both** paths, and the connect-first page. **Directory:** `teams` and the zero-teams help. | |
| +| **A2** | Several identities, the account menu, team switching, the Keymail sheet, the Devices page. | |
| +| **B** | Native recovery (ruling C) and native passkey enrolment with the codes. | |
| +| **C–E** | Appendix B: the other four apps and Calls guests; universal links and Open on the web (§12); web multi-account. | |
| -**The Mac launch gate.** The final signed, notarised artifact of every Mac build **launches and reads the shared group** before any Sparkle publish. A build killed at launch cannot update itself. |
| +## 15. Portal steps and release acknowledgements (Paul's ruling F, accepted) |
| -## 16. Slices, smallest first |
| +**Portal:** register `group.works.oficina` (iOS only); enable Associated Domains and keychain sharing on every `works.oficina.*` App ID; issue a profile for **every** Mac build, Developer ID and App Store. **Releases:** every Mac release depends on those profiles and the launch gate, and the Mac App Group becomes `9U4A84C4WK.works.oficina`. **Migration:** Appendix C. |
| -| Slice | Contents | |
| -|---|---| |
| -| **0a** | Profiles for every build: the Mac App Group ID change and the launch gate. A shared Secure Enclave key read by two apps (Docs plus one more). | |
| -| **0b** | The association file on `id.*` and Apple's CDN fetch; a native passkey `clientDataJSON.origin` spike; a Mail AutoFill spike on both platforms. | |
| -| **A** | **Docs only**, one identity. **Home:** grant and proof; code and Keymail; native passkey sign-in (Q1a); recovery; `assert`; `signout`. **connect:** `NativeExchange` with the allocation rule. **Directory:** `teams`, read-only, to pick a team; the zero-teams screen. Requires Paul's teams to exist (§8). | |
| -| **A2** | Several identities, team switching, the account menu, the Devices page. | |
| -| **B** | Native passkey enrolment and display of the recovery codes. | |
| -| **C** | Sheets, Calendar, Memoria, Calls, and Calls guests. | |
| -| **D** | Universal links, `NSUserActivity`, Open on the web. | |
| -| **E** | Web session sets and labels. | |
| +## 16. Paul's rulings, 2026-11-14 (all decided) |
| -## 17. Questions for Paul |
| +Q1 (a): native passkey sign-in ships first; the email code is for people with no passkey yet, and slice 1's rule is intact. Q2 (a): the Keymail sheet, with "Email me a code instead" (moved to A2, with the code as the fallback until then). Q4: grants last 90 days idle and 365 absolute; team sessions last 7 days absolute (confirmed). Q5 (a): web IDs are labelled by their teams' names. Q6 (a): the team colour is derived on the device. Q7: Docs comes first. |
| -**Decided 2026-11-14:** Q1 (a); Q2 (a); Q5 (a); Q6 (a); Q7 Docs. Q4 stands provisionally. |
| +A(i): native sign-in skips Continue. A(ii)(a): one Continue tap signs that browser in to that one app only, never `id.*`. B (a): a daily cap plus a passkey nudge. Its lockout cost is corrected in §4 (about 4 mails a day blocks new devices only). C: recovery codes may be used for routine sign-in, showing what remains and prompting below 3; this moves to slice B. D (a): the shared-credential risk is accepted for slice A and disclosed. Any process in the keychain group can assert for any audience, so a bug in one app exposes every app's data, Memoria's private items included. Per-app keys need attestation and come later. E (a): Calls guests join by name by default, and use their Oficina ID only by explicit choice. F: accepted (§15). G: there is no code entry on the web door. H: "Create a team" through Alta once Alta runs; help text while it is blocked. I (a): app sign-out ends the browser sessions it opened, best effort, on all that person's devices per instance. J: migration covers Paul's machines only; Till must be told before slices C and D. New: fix the browser fork now (§8). |
| -**Still open:** |
| +No questions remain open. |
| -**A. Confirmation, split in two (B1).** |
| -- **(i) Native assertions without a Continue page (§7).** Recommended: yes. The tap is in the app and the key is on the device. |
| -- **(ii) May the web link sign in a browser without confirmation?** The trade-off: silent sign-in is the seamless experience, but it is a login-CSRF hole. Choose one: |
| - - (a) a fixed-text confirmation plus a one-shot, consumer-only session. Recommended. Residual risk: a victim who presses Continue on a lured link lands in the attacker's team. |
| - - (b) no web sign-in from the app: the plain URL, signed in by the browser's own Home session, if it has one. |
| - - (c) silent sign-in. Not recommended. |
| +## Appendix A. Evidence |
| -**B. Accounts that sign in by code only (H1, replaces Q8).** A code alone means about 17% a year of takeover under sustained guessing, phishing relay, and lockout for ~96 mails a day. Choose one: |
| -- (a) a daily failure cap of 20, falling back to link-only sign-in, plus a prompt to make a passkey. Recommended: under 1% a year. |
| -- (b) require a passkey within N days of the first code sign-in. |
| -- (c) accept the risk as stated. |
| +**Today:** no device holds an identity; "accounts" are host-plus-cookie (`native-levelup/reports/calls.md` §B3, `docs.md` §3). rastrillo/native's browser approval keeps a pending map in memory (5 minutes, 256 entries; `rastrillo-native/server/auth.go:23-37`). Calls has a one-slot store (`calls.md` §C). Keychain items have no access group (`sheets.md` §3). |
| -**C. Spending recovery codes in routine sign-in.** There are only ten, and regenerating them needs a passkey on the web. Choose one: |
| -- (a) allow, showing how many are left, and prompt below 3. Recommended. |
| -- (b) native recovery only as a last resort, once per device. |
| +**Home:** P-256 assertion minting (`internal/home/exchange.go:72-146`); a consumer registry mapping id → origin only (`consumer_registry.go`); the passkey gate (`id_recovery.go:71-92`); `home_id_attempts` (`identity/migrations/0002_recovery.sql`); 30-day browser sessions (`app.go:123`); the in-memory email budget (`app.go:146-147`); directory tables populated only for Alta- or operator-provisioned teams, read by `Store.AgentChoices` (`directorydata/store.go:129-177`). |
| -**D. One compromised app yields everything (H3).** Any process in the keychain group can assert for any audience and open the web. A parsing bug in Calls could therefore expose Memoria private items in every team. Choose one: |
| -- (a) accept and disclose the risk. Recommended for slice A. |
| -- (b) per-app keys bound to app zones. This needs App Attest, which is iOS-only in practice; later work. |
| +**connect:** completion allocates Home-only people through `Unlinked` (`connect/bridge.go:214-227`). The resume-linking marker is set at `bridge.go:229`. |
| -**E. Guest ID disclosure (H4).** Choose one: |
| -- (a) name-only by default, with Oficina ID behind an explicit choice that names the disclosure. Recommended. |
| -- (b) Oficina ID by default for registered instances. |
| +**Mac spike:** see §2. `group.works.oficina` needs registering and prompts on macOS 15 and later. rastrillo/native branch `native/levelup-phase0-tools` embeds and validates profiles. |
| -**F. Mac releases (B4).** Every Mac release depends on provisioning profiles plus the launch gate, and the Mac App Group becomes `9U4A84C4WK.works.oficina` (iOS keeps `group.works.oficina`). Accept? Recommended: yes. |
| +## Appendix B. Later slices (C–E), with their gates |
| -**G. Code entry on the web door.** In or out? Recommended: out. The web keeps its links, which are stronger against phishing. |
| +**C: the other apps, and Calls guests (Paul's ruling E).** A link to a Calls instance outside your teams never asserts silently: an assertion would hand that operator your stable cross-team subject. The default is **Join as a guest by name**. "Use Oficina ID <label>" says "This meeting's server will learn your Oficina ID", and with two identities the person picks one. An Oficina ID guest is admitted only with a valid, unconsumed `/j/{token}`, consumed in the minting transaction. `/m/{sqid}` alone grants only Calls' lobby and knock (`native_auth.go:56-87`). The visit is held in memory. Name-only guests keep "Join in the app" (`native_auth.go:349-421`). Push registers per (identity, team). *Gates:* no silent guest assertion; the invitation consumed atomically; `/m/{sqid}` grants nothing. |
| -**H. Zero teams.** Choose one: |
| -- (a) "Create a team" through Alta, plus "Waiting for an invitation?" help. Recommended once Alta runs. |
| -- (b) the help text only. |
| +**D: universal links and Open on the web (§12).** Each app claims `applinks:<app>.oficina.works` and `applinks:*.<app>.oficina.works`. The wildcard file is fetched from the bare host, so portero serves `/.well-known/apple-app-site-association` (static, label-free); team hosts serve it too. The file lists item routes (Calls: `/m/*`, `/j/*`) and excludes `/auth/*`, `/signin*`, `/signout*`, `/native/*`, `/account/*`, `/api/*` and `/.well-known/*`. Routing: one identity with that origin → use it; several → always ask; none → guest choice (Calls) or "Add an Oficina ID". Self-hosted teams on other domains use the custom scheme only. `NSUserActivity` carries `webpageURL`. *Gates:* the handle GET consumes nothing; Continue POST timing and token binding; the receipt-then-GET finish with no silent replacement of another account; web nonces accepted only at `/native/web/finish`; `native-web` never fresh; `/native/web/end`; excluded paths. |
| -**I. Should app sign-out end the browser sessions it opened (§10)?** Choose one: |
| -- (a) yes, best effort per instance. Recommended. |
| -- (b) no: those sessions end at their normal lifetime, or on the web's Sign out. |
| +**E: web multi-account.** `id.*` and the directory hold a set of up to 5 sessions in a sealed `__Host-oficina-ids` cookie, with "current" picked by the intent's subject (`exchange.go:107`). They are labelled by team names (Q5a). An instance keeps one session per host, so two IDs on one team host collide in a browser; that is disclosed. *Gates:* set size; no address rendered on `id.*`. |
| -**J. Migration scope.** Does it cover Till's machines and `lagged`, or only Paul's? Recommended: Paul's only, with Till told separately. |
| +## Appendix C. Migration and release plan (Paul's ruling J: Paul's machines only) |
| -**Portal steps for Paul.** |
| -- Register the App Group `group.works.oficina` (**iOS only**). |
| -- Enable Associated Domains and keychain sharing on every `works.oficina.*` App ID. |
| -- Issue a provisioning profile for every Mac build, Developer ID and App Store. Slice 0a's spike makes these a **hard prerequisite**. |
| +New `works.oficina.*` builds start at Welcome. Old `net.amadan.oficina.*` builds still claim the custom schemes, so Paul deletes them. Each old appcast gets one final "Download the new app" release. Camera and microphone permissions reset. Alta's instances are fresh, so no server sessions carry over. Docs' existing links keep resolving through `connect.Resolve`. Till (team `lagged`) must be told before slices C and D, because his old apps must be deleted too. |