Spec rev 2: Paul's answers and Fable's review applied (not re-reviewed)
Human
Prompt
Revise spec/oficina-id-native (Home) on the same branch, push, update discussion 112/tasks, report the new tip + a changelog. Don't merge. Status line: "revision 2: Paul's answers of 2026-11-14 and Fable's READY AFTER FIXES review applied; not re-reviewed". [Paul's answers: Q1 (a) native passkey sign-in ships in the first slice, email code for people with no passkey yet, slice 1's rule intact; Q2 (a) Keymail approval in an in-app browser sheet with 'Email me a code instead'; Q5 (a) label several web IDs by their teams' names; Q7 Docs is the first app; Q6 stands, Q4 provisionally; Q3 and Q8 re-asked per B1/H1. Fable review @4cc21a8 READY AFTER FIXES: B1-B4, H1-H4, M1-M9, Low items; new questions to add.]
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 answers (Q1a, Q2a, Q5a, Q6a, Q7 Docs, Q4 provisional) and applies every finding of Fable's READY AFTER FIXES review of 4cc21a8: web handle now GET-renders a fixed-text confirm, POST mints only a one-shot consumer session (no Home session) with never-fresh native-web methods (B1, B2); NativeExchange allocates only on team-mode instances with no addressed local accounts, else link_in_browser (B3); Mac spike facts, profiles as hard prerequisite, launch gate before Sparkle, platform-specific App Group, team cache kept in keychain (B4); code-strength numbers, daily cap, per-IP live-start cap and persistent buckets (H1, H2); one-app-compromise residual (H3); guests never assert silently, ask between IDs, invitation consumed in-transaction (H4); M1-M9 and low items; slices re-cut 0a/0b/A/A2/B-E; ten open questions A-J.
Agent notes
Doc only. Length grew to ~390 lines to carry the review fixes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+292
−129
docs/superpowers/specs/2026-11-14-oficina-id-native.md+292 −129
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 b23f6f3..828058c 100644 |
| --- a/docs/superpowers/specs/2026-11-14-oficina-id-native.md |
| +++ b/docs/superpowers/specs/2026-11-14-oficina-id-native.md |
| @@ -1,227 +1,390 @@ |
| # 🤖 Oficina ID: the native slice |
| -Status: draft for Paul; not reviewed. Author: Claude (`claude-opus-5-5`), 2026-11-14, written against Home `e9829fd`. AGENTS.md's Review rule still requires a review by the most capable model available, and §17 needs Paul's answers. There is no implementation, deployment or merge approval. |
| +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. |
| ## 1. Decision and boundary |
| -This spec extends [Oficina ID slice 1](2026-11-13-oficina-id-slice-1.md) and does not replace it. Where this spec says nothing, slice 1 binds. It covers the "native deep-link delivery" that slice 1 left outside its scope. |
| +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 (native level-up BRIEF):** |
| +**Paul, 2026-11-14 (BRIEF):** |
| - Oficina ID is one account across every app and team, named "Oficina ID" on screen. |
| -- Native sign-in is an email and a 6-digit code entered in the app, filled by Mail's one-time-code AutoFill. Passkeys come next. |
| -- Several Oficina IDs can be signed in at once (paul@tito.io, paul@rslw.com), and each one's teams are switchable. |
| -- One sign-in is shared across all five native apps (Calls, Docs, Sheets, Calendar, Memoria) on Mac and iPhone. |
| -- Moving between native and web is seamless: opening the web from an app never asks for a sign-in and lands in the same account and team. |
| +- 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". |
| -**Out of scope:** Contra (slice 2), CallKit/PiP, provisioning, roster writes and per-item grants. |
| +**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). |
| -**Home's one rule holds.** Home gains no readable address, no content and no device name. The one new fact it learns is that a person has N signed-in devices, each tagged with a platform. |
| +**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 |
| -**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). |
| -- Docs, Sheets, Calendar and Memoria use rastrillo/native's browser approval. It keeps pending requests in memory, at most 256 of them for 5 minutes each (`rastrillo-native/server/auth.go:23-37`). |
| -- Calls has its own one-slot store (`calls.md` §C). |
| +**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). |
| **What Home has:** |
| -- P-256 `rastrillo/assertion` v1 minting (`internal/home/exchange.go:72-146`), with an exact consumer registry (`consumer_registry.go`). |
| -- The passkey gate on both email paths (`id_recovery.go:71-92`), and persistent recovery limits (`identity/migrations/0002_recovery.sql`). |
| +- 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`). |
| -- An in-memory email budget of 20 per IP and 5 per blinded address per 15 minutes (`app.go:146-147`; keymaildev/signin v0.1.1 `flow.go:123,137`). |
| -- The directory's `teams`, `team_instances` and `memberships` tables (`directorydata/migrations/0001_directory.sql`). |
| -- `Store.AgentChoices`, which reads a person's live teams and app origins in one snapshot (`directorydata/store.go:129-177`). |
| +- 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`). |
| + |
| +**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`). |
| -**All five apps already consume Home.** Each imports `connect`, `handoff`, `roster` and `teammode`. A completed `connect` sign-in resolves in order: link, then Home-only person, then team-mode `Unlinked` (roster members only). It then mints with `HomeMethod` (`connect/bridge.go:191-247`). |
| +**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. |
| ## 3. The native credential |
| -**On the device**, per identity: a P-256 device key (Secure Enclave where present, else a software key in the data-protection keychain) and a 32-byte random grant token. Both sit in the shared access group `9U4A84C4WK.works.oficina.id` (`kSecUseDataProtectionKeychain` on Mac), `AfterFirstUnlockThisDeviceOnly`, never synchronizable or exported. Slice 0 proves a Secure Enclave key in a shared group works from all five apps. |
| +**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. |
| + |
| +**`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. |
| -**At Home**, a new credential-database table `home_id_grants`: `grant_hash` (SHA-256 of the token, primary key), `person_ref`, `device_key` (65 bytes), `platform` (`mac`/`ios`), `method`, `auth_time`, `created_at`, `last_used_day`, `expires_at`. No address, device name or app list. At most 20 live grants per person; a 21st revokes the least recently used. |
| +**`POST code/resend`**, proved by the start's key, replaces the code: at most 3 sends, 30 s apart. |
| -**Device binding.** Every native call to Home carries `Authorization: OficinaID <token>` and `Oficina-Proof: base64url(payload).base64url(sig)`, where the payload is `{v:1, htm, htu, iat, jti, bh=SHA-256(body)}` signed with rastrillo `crypto` under context `oficina-id/native-proof/v1` (no JWT, no algorithm field). Home requires a live grant, a valid signature by its stored key, `htu` equal to the exact request URL, `|iat−now| ≤ 30 s` and an unseen `jti` (kept 60 s, bounded). A copied token is useless without the key. **No rotation:** five apps share one item and would race, and possession of the key already gives what rotation would. |
| +**`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. |
| -**Lifetime:** 90 days idle, 365 days absolute (Q4). `auth_time` is the sign-in gesture; use never refreshes it, only a new factor ceremony on the same grant ("Confirm it's you"). **Revocation:** device sign-out, the Devices page (§10), expiry, and passkey replacement by recovery code — slice 1's "revoke all Home sessions" **includes every grant**. |
| +**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). |
| -## 4. In-app email code |
| +**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. |
| -New JSON endpoints under `https://id.oficina.works/native/v1/`. They render nothing, answer `no-store`, send no CORS headers and accept only `application/json`. Any request carrying `Origin` or `Sec-Fetch-Site` is refused, so no web page can drive them. |
| +**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. |
| -**`POST code/start {email, device_key, platform}`** → `202 {start, resend_after:30}`. It classifies the address as `/signin` does (Keymail: Q2), stores a `home_id_native_starts` row (`start_hash`, the address sealed under purpose `native.code`, `device_key`, `code_mac`, `sends`, `attempts`, `expires_at`) and mails the code. The answer is identical for known and new addresses: open signup (ruling 7) mints the person at verify, as slice 1 does. **`POST code/resend {start}`**, proved by the start's key, replaces the code: at most 3 sends, 30 s apart. |
| +**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. |
| -**`POST code/verify {start, code}`**, same proof, finds or mints the person as `completeSignIn` does (`signin.go:399`) and runs the same gate as `idGate`. With no passkey enrolled it returns `{grant, auth_time}`. Otherwise it returns `{factor:["passkey","recovery"], pending}`, bound to the start and its key for 5 minutes. |
| +**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. |
| -**Codes and limits.** Six uniformly 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 is live per (blinded address, device key). `start` and `resend` spend the **existing** `/signin` budget, so two doors never double it. `verify` failures take slice 1's persistent, atomic counters (5 per blinded address and 20 per IP per 15 minutes, across all starts), which neither restarts nor parallel requests reset. At most 10,000 live starts, as `id_recovery.go:100` bounds pending factors. |
| +**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. |
| -**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 table and its logs. An SMTP failure never authenticates. |
| +## 5. Native passkeys (first slice, Q1a) |
| -**The mail** uses estilo chrome. Subject "Your Oficina ID code"; first line "Your Oficina ID code is 123456"; then the expiry and an "ignore it if you didn't ask" line. It has **no link**, because a link would sign in a browser, not the app. `.textContentType(.oneTimeCode)` gives Mail AutoFill (iOS 17+, macOS 14+), and a code read on the iPhone can be typed on the Mac. |
| +**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.*`. |
| -## 5. The factor rule: slice 1 against today's ruling |
| +**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. |
| -Slice 1: "After passkey enrollment, email/Keymail sign-in requires a passkey or recovery code." The in-app path keeps the rule as written. A verified code on an enrolled account yields `pending`, never a grant. |
| +**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`. |
| -**`POST recovery {pending, code}`** is the JSON twin of `/passkey/signin/recovery`, with the same limits. It mints an `email+recovery` grant that, as in slice 1, is for sign-in only: |
| -- it cannot enrol or replace a passkey; |
| -- it cannot satisfy step-up; |
| -- replacing a lost last passkey stays on the web. |
| +The challenge is single-use, valid 5 minutes, bound to the device key, and limited by `home_id_ceremonies`. |
| -A passkey completes `pending` instead (§6). |
| +The app calls `ASAuthorizationPlatformPublicKeyCredentialProvider(relyingPartyIdentifier: "id.oficina.works")`. |
| -**The tension (Q1).** Paul ruled "code now, passkeys next". Until native passkeys exist, an enrolled person can finish in the app only by spending a recovery code every time. The options: |
| -- **(a)** native passkey *assertion* in slice A, enrolment in B. Recommended. |
| -- **(b)** a recovery code or a browser fallback until B. |
| -- **(c)** the code alone natively. Not recommended: the passkey then adds nothing against a mailbox holder. |
| +`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`. |
| -## 6. Native passkeys |
| +`LegacyRPID` stays empty. Slice 0 confirms on a real device that `clientDataJSON.origin` is `https://id.oficina.works`. |
| -**Domain association.** All ten builds carry `webcredentials:id.oficina.works`. The credential role serves a static `/.well-known/apple-app-site-association` (`application/json`, no redirect) that lists the ten `9U4A84C4WK.works.oficina.<app>` IDs under `webcredentials`. It holds no account-authored string, and it declares no `applinks`, so §12's handle opens in a browser. |
| +**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). |
| -**Sign-in.** `POST passkey/begin {pending?}` returns WebAuthn options: discoverable without `pending` ("Sign in with a passkey", no email), or restricted to that person with it. The challenge is single-use, lasts 5 minutes, is bound to the device key in place of a browser, and stays within `home_id_ceremonies`' bounds. The app calls `ASAuthorizationPlatformPublicKeyCredentialProvider(relyingPartyIdentifier: "id.oficina.works")`, and the system sheet offers phone-as-key itself. `POST passkey/finish` runs Home's existing verification (exact RP and origin `https://id.oficina.works`, user verification, person binding) and mints a `passkey` or `email+passkey` grant. `LegacyRPID` stays empty. Slice 0 confirms on a real device that a native `clientDataJSON.origin` is exactly `https://id.oficina.works`. |
| +**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. |
| -**Enrolment (slice B).** `passkey/register/{begin,finish}`, with grant and proof, needs `auth_time` within `enrolFreshness` (10 minutes, `passkey.go:30`) on a grant that is not recovery-derived, and uses slice 1's generated names. The first enrolment returns the ten recovery codes **once**: the app offers Copy, Save and Print, and asks for "I've saved them". `e9829fd`'s zero-codes rules apply. "Create a passkey" is offered once, after the first code sign-in. |
| +## 6. Names and labels on the device |
| -## 7. From credential to per-app, per-team session, with no browser |
| +An identity is keyed by its `identity_id`. Signing in with an `identity_id` already present answers "Already signed in". |
| -**1. Home: `POST /native/v1/assert {aud, nonce}`** (grant plus proof) returns `{assertion}`. |
| -- `aud` must be in `consumers()` and must not be the operator's reserved consumer. |
| -- Claims are exactly slice 1's v1: 120 s, a fresh `jti`, `sub` = the person ref, and the grant's `auth_time`. |
| -- `nonce` = `base64url(SHA-256(verifier))`. The verifier is 32 random bytes, new for each exchange. |
| -- No `max_age`: **native never links**. Linking a local account stays slice 1's browser flow, started from the app's web account page. |
| +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. |
| -**2. Instance: `POST <origin>/native/oficina-id {assertion, verifier, target?}`**, a new `connect.Bridge.NativeExchange` that every app mounts. It takes JSON only, sets no cookies and refuses `Origin`. One writer transaction: |
| -- verifies the signature with the pinned keys, the exact issuer and the exact audience; |
| -- requires `SHA-256(verifier) = nonce`; |
| -- reserves `(iss,jti)` in `oficina_handoff_replay`; |
| -- resolves exactly as `complete` does (link → `HomeOnly` → team-mode `Unlinked`); |
| -- rechecks admission, mints, and replies `{session, expires}`. |
| +Home holds no name or avatar, so the app shows initials from the label. |
| -An unknown subject gets `403 {"state":"unknown"}` and is allocated nothing. |
| +## 7. Credential to per-app, per-team session, with no browser |
| -**No pending row: a justified addition.** Slice 1's pending transaction and browser secret exist to stop login CSRF. A native client has no ambient browser to fix an assertion onto. The verifier gives the same guarantee, "only the requester redeems", with no unauthenticated state on the instance. It also retires rastrillo/native's in-memory map, which a restart loses. |
| +**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.** |
| -**No Continue page (Q3).** Slice 1 shows Continue before minting for an existing browser session. Native skips it: the request is the person's own tap, made with a key held on the device. |
| +**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. |
| -**Session lifetime.** A natively minted session lives **7 days**. The app re-mints silently after 24 h of use and on any 401, so a revoked grant stops reaching instances within 7 days. Slice 1's unlink deletes these sessions with every other Home-derived one, since they share `HomeMethod`. |
| +**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. |
| + |
| +**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. |
| + |
| +**No Continue page (Q-A i).** The request is the person's own tap, made with a key held on the device. |
| + |
| +**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. |
| ## 8. Teams |
| -The directory is one more consumer (Home §4: one assertion path). The app posts a directory-audience assertion to the directory's own `POST /native/oficina-id` and gets a 7-day directory session. |
| +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. |
| -**`GET https://oficina.works/api/native/teams`** returns `[{sqid, label, name, role, apps:[{app, origin}]}]`. |
| -- It reads `Store.AgentChoices` in one snapshot, filtered to live instances of the five apps. |
| -- It is `no-store`. Names are opened per request, for that person only. |
| -- The app uses `origin` as given and never builds one, which also covers self-hosted teams (portero ruling 3). Native apps refuse redirects, so they never touch portero (portero §2.2). |
| -- It refreshes at launch, when the menu opens (at most every 5 minutes), and on any 403. |
| +**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). |
| -**Home already knows:** label, name, app origins and their state, role, the roster epoch, and sealed owner-set member names. |
| +**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). |
| -**Missing:** |
| -- A team hue or mark. Clients derive a stable Calma hue from `sqid` (Q6). |
| -- A display name or avatar. Home holds none by design, so the app shows the email typed on this device, with its initials. |
| -- Teams you are invited to but have not joined. Those are instance-side. |
| -- The last-used team. That stays device state (ruling 22). |
| +**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. |
| ## 9. Device store, onboarding, several identities |
| -**Store (RastrilloApple).** The shared keychain group holds one record per identity, `{grant_id, email as typed and lowercased, added_at}`, beside its key and token. The App Group `group.works.oficina` defaults hold only non-secret state: identity order, each identity's team cache, and the last-used (identity, team), suite-wide and per app. Each app's private keychain holds its instance sessions keyed `(grant_id, origin)`, so no app holds another app's cookie. A Darwin notification, `works.oficina.id.changed`, tells the other apps to reread. A device holds at most 5 identities, and adding one already present answers "Already signed in". |
| +**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. |
| -**Onboarding.** Welcome → Email → Code (AutoFill, resend, back) → passkey or recovery code if required → Team (skipped when there is only one). A second app finds the identities already there and offers "Continue as paul@tito.io" or "Use another". It lists only teams that have a live instance of that app. |
| +**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. |
| -**Account menu (PLAN Phase 2).** Identities, each with its teams under it, then Add Oficina ID…, Manage… and Sign Out of <email>. On Mac, ⌃⌘1…9 switch teams and each window carries its own (identity, team). The current identity and team always show. Switching is blocked mid-call, and wherever an app already guards unsaved edits. |
| +A second app offers "Continue as …" or "Use another". |
| + |
| +**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. |
| ## 10. Sign-out per identity, and revocation |
| -**"Sign out of <email>"** is local and immediate. The app deletes that identity's key, token and record from the shared group and posts the notification, so every app drops the identity at once. It then, best effort with 5 s timeouts, revokes the grant with `POST /native/v1/signout`. Each app `POST /signout`s its cached sessions under that `grant_id` and deletes them, and revokes at launch any it later finds under a vanished grant. Completion never waits on Home; slice 1's test with an issuer that **hangs** covers it. |
| +**"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. |
| + |
| +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. |
| + |
| +Nothing waits on Home, and a test proves it against an issuer that **hangs**. |
| -**Devices page.** `https://id.oficina.works/devices` lists grants with fixed labels only ("Mac · signed in 14 Nov · used today"), with Revoke and "Sign out all devices". It sits behind a fresh session and request-forgery protection, and renders no account-authored text. **Disclosed residual:** after a remote revoke, a device that stays offline keeps its instance sessions until their 7-day expiry, in line with slice 1's "no global logout guarantee". There is no per-team sign-out: team standing comes from the roster. |
| +**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. |
| + |
| +**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. |
| + |
| +There is no per-team sign-out. |
| ## 11. Outages |
| -**Credential origin down:** no new identity, and no new or renewed session. Existing sessions run until they expire and cached teams still show. A team with a live session opens; any other shows "Can't reach Oficina ID", with Try again and the app's own sign-in (§14). **Directory down:** the team cache serves, and minting still works, because the credential origin is a separate process. **Instance down:** the existing offline banner. In every case sign-out completes locally, nothing loops, and retrying is the person's choice. |
| +**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). |
| + |
| +**Directory down.** The cache is used, and minting still works. |
| + |
| +**Instance down.** The app shows its offline banner. |
| + |
| +In every case sign-out completes locally, and nothing loops. |
| ## 12. Native → web, and the web changes it needs |
| -**Copy Link and Handoff** carry the plain team URL. A credential never rides a shared URL. |
| +**Copy Link and Handoff** carry the plain team URL. |
| -**"Open on the web":** |
| -1. `POST /native/v1/web {aud, path}` (grant plus proof) returns `https://id.oficina.works/native/web/<handle>`. The handle is 32 bytes, lives 60 s, works once and is never logged. It is sealed and bound to the person, `aud`, a validated local `path` and the grant's `auth_time`. |
| -2. The app opens the link in the default browser. |
| -3. Home consumes the handle and checks the browser's Home session: |
| - - **None:** Home mints one with method `native-web` and the grant's `auth_time`. It is never fresh for step-up or linking. |
| - - **The same person's:** reused. |
| - - **Another person's:** before slice E, a fixed-text page asks "Another Oficina ID is signed in in this browser. Switch to this one?". From slice E, the session joins the set. |
| -4. Home `303`s to the consumer's ordinary slice 1 entry with `path` as the validated return. Pending cookie → `/authorize` → assertion POST → `/auth/finish` then lands on the same team and path. |
| +**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. |
| -Slice 1 would show Continue at step 4. This spec skips it only when this handle minted or chose the session, for this exact consumer, within 60 s (Q3). On any failure the app opens the plain URL, which asks for sign-in as today. |
| +**"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`. |
| -**Web multi-account (slice E)** keeps a handoff, or a second ID, from landing in the wrong account. |
| -- `id.*` holds a **session set**: up to 5 sessions in a sealed `__Host-oficina-ids` cookie, with the existing cookie as "current". |
| -- `/authorize` uses "current". The handle and linking pick the session matching the intent's subject; that check exists today (`exchange.go:107`). |
| -- The directory gets the same set. |
| -- **Instances stay one session per host.** Two IDs in the *same* team stay one at a time in a browser: disclosed, not solved. |
| -- Home holds no address, so no web page can name an ID by email (Q5). |
| +**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. |
| -**Web → app.** Universal links (§13), plus an "Open in the app" button using the custom scheme. Safari ignores universal links on same-host taps. |
| +**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. |
| + |
| +**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. |
| + |
| +**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. |
| ## 13. Universal links and AASA hosting |
| -Each app carries `applinks:<app>.oficina.works` and `applinks:*.<app>.oficina.works`. For a wildcard, the system fetches the file from the bare host, which portero answers. So **portero serves `/.well-known/apple-app-site-association`**, label-free and static, matching its "static on any host" row (portero §2; a portero follow-up). Each app serves the same file on its team hosts, and both answer 200 `application/json` with no redirect. Slice 0 checks the wildcard fetch against Apple's CDN (`app-site-association.cdn-apple.com/a/v1/<host>`). |
| +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. |
| + |
| +**Paths.** Each app lists its item routes (for Calls: `/m/*`, `/j/*`). The file excludes `/auth/*`, `/signin*`, `/signout*`, `/native/*`, `/account/*`, `/api/*` and `/.well-known/*`. |
| -**Paths** list each app's item routes (Calls: `/m/*`, `/j/*`) and exclude `/auth/*`, `/signin*`, `/signout*`, `/native/*`, `/account/*`, `/api/*` and `/.well-known/*`, so no sign-in or handoff URL ever opens an app. **Routing:** `onContinueUserActivity(NSUserActivityTypeBrowsingWeb)` routes by host. If one identity has the origin, the app uses it. If several do, it asks once and remembers per team. If none does, Calls treats the link as a visit (§14), and the other apps offer "Add an Oficina ID" or "Open in browser". Custom schemes stay as the fallback, and items advertise `NSUserActivity` with `webpageURL` for Handoff. |
| +**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". |
| ## 14. Calls guests, the apps' own sign-in, migration |
| -**Calls members** go through §7. |
| +**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. |
| -**Invited guests with an Oficina ID but off the roster** assert to that Calls instance, which is registered like every team instance. They post with `target` from the closed set `/j/{token}`, `/m/{sqid}` (`native_auth.go:56-87`). `Unlinked` refuses non-members, so Calls admits them through its own guest hook, and only by its existing meeting-bound invitation consumption. The visit lives in memory and is dropped on leave (`calls.md` §C). |
| +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). |
| -**Name-only guests** keep the web "Join in the app" offer (`native_auth.go:349-421`), which now also works by universal link. |
| +**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. |
| -**Push** registers per stored (identity, team). |
| +**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. |
| -**The apps' own sign-in (11-13).** The first screen leads with "Sign in with Oficina ID". "Other ways to sign in…" (also in Settings ▸ Advanced) keeps the server address and rastrillo/native's browser approval, for self-hosted servers and local accounts. Those accounts are listed as "Other accounts", by host. `/native/request|start|authorize|exchange` stay for that path. |
| +## 15. Gates |
| -**Migration.** The move to `works.oficina.*` (BRIEF) gives every build new keychain services and defaults domains, so new builds start at Welcome. That *is* the migration: the apps hold no real data, and one reinstall per app is accepted. |
| -- Old `net.amadan.oficina.*` items are orphaned. The release notes say how to delete them. |
| -- Alta's instances are fresh (portero ruling 6), so no server sessions carry over. |
| -- Docs' links keep resolving through `connect.Resolve`. |
| +**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. |
| -## 15. Gates |
| +**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. |
| + |
| +**Assert.** An unregistered `aud` is refused. So is a grant method the consumer's policy refuses. |
| -**Codes and privacy:** no address at rest in the starts table, WAL or backups, and no address or code in logs; code entropy, expiry, single use and the 5-try death; persistent verify limits under concurrency; one `/signin` budget for both doors; identical answers for known and unknown addresses; an enrolled account never gets a grant from a code alone; recovery-derived grants refused for enrolment and step-up. |
| +**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. |
| -**Proof and exchange:** proofs refused for a wrong key, replayed `jti`, skewed `iat`, wrong `htu`, swapped body, or an `Origin`/`Sec-Fetch-Site` header; unregistered `aud` refused; the instance refuses a wrong verifier, replay, swapped audience and unknown subject (allocating nothing); concurrent exchange, unlink and relink. |
| +**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. |
| -**Revocation, handoff, domains:** passkey replacement revokes every grant; native sign-out and Devices revoke both work against a **hanging** issuer; the web handle is single-use, expiring, consumer-bound and refuses a foreign path; AASA content and excluded paths; RP ID exactly `id.oficina.works`, `LegacyRPID` empty. |
| +**Freshness.** Any `native-web` method is refused at enrolment, codes, linking and step-up. |
| + |
| +**Revocation.** Passkey replacement revokes every grant. Native sign-out and Devices revoke both work against a **hanging** issuer. |
| + |
| +**Domains.** The association file's content and excluded paths. The RP ID is exactly `id.oficina.works`, and `LegacyRPID` is empty. |
| + |
| +**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. |
| ## 16. Slices, smallest first |
| | Slice | Contents | |
| |---|---| |
| -| **0** | Client and Paul only. Bundle IDs; entitlements on all ten builds (keychain group, App Group, associated domains); Developer ID profiles. Spikes: a shared Secure Enclave key, native `clientDataJSON.origin`, the wildcard AASA fetch. | |
| -| **A** (first shippable) | **Home:** grants and proof, code start/resend/verify, the recovery factor, passkey assertion if Q1 is (a), `assert`, `signout`, Devices. **connect:** `NativeExchange`. **Directory:** native session and `teams`. **RastrilloApple:** store, onboarding, account menu with N identities and team switching. **One app** (Q7). | |
| -| **B** | Native passkey enrolment, and showing the recovery codes. | |
| -| **C** | The other four apps, and Calls guests. | |
| -| **D** | Universal links, AASA files, `NSUserActivity`, Open on the web. | |
| -| **E** | Web session sets, the switcher, and labels. | |
| +| **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. | |
| ## 17. Questions for Paul |
| -1. **Factor rule (§5).** Choose (a) native passkey assertion in slice A (recommended), (b) a recovery code or the browser until slice B, or (c) the code alone natively (not recommended). |
| -2. **Keymail addresses.** Slice 1 keeps the Keymail upgrade. Choose (a) Keymail approval in an `ASWebAuthenticationSession` sheet, with "Email me a code instead" (recommended), or (b) always mail a code and skip the upgrade. |
| -3. **Silent minting.** Native assertions (§7), and the web handle for its one consumer (§12), skip slice 1's Continue page. Recommended: yes to both. |
| -4. **Lifetimes.** Grants: 90 days idle, 365 days absolute. Native instance sessions: 7 days, which also bounds how long a revocation takes to reach them. Recommended as stated. |
| -5. **Web labels for several IDs.** Home holds no address. Choose (a) label each ID by its teams' names (recommended: nothing new is held), (b) a person-chosen nickname sealed at Home and shown only on the directory, or (c) the address in a sealed browser cookie, rendered by the directory. |
| -6. **Team hue.** Choose (a) derive it on the client from `sqid` for now (recommended), or (b) add an owner-set column of closed Calma hues to `teams`. |
| -7. **First app for slice A.** Docs (recommended: it already has the multi-account `NativeConnection`), or Calls (PLAN's order, but it has to move onto RastrilloApple first). |
| -8. **Code strength.** Is a mailed 6-digit code (10 minutes, 5 tries, rate-limited) equal to a magic link as mailbox proof? Recommended: yes. It proves the same mailbox, and it fixes the cross-device and cross-browser failures. |
| - |
| -**Portal steps for Paul.** None has been taken. |
| -- Register the App Group `group.works.oficina`. |
| -- Enable Associated Domains on the ten `works.oficina.*` App IDs. |
| -- Issue Developer ID provisioning profiles for the Mac Sparkle builds, covering keychain-access-groups, the App Group and associated domains. It is not yet verified that these builds need them (PLAN Phase 0). |
| +**Decided 2026-11-14:** Q1 (a); Q2 (a); Q5 (a); Q6 (a); Q7 Docs. Q4 stands provisionally. |
| + |
| +**Still 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. |
| + |
| +**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. |
| + |
| +**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. |
| + |
| +**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. |
| + |
| +**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. |
| + |
| +**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. |
| + |
| +**G. Code entry on the web door.** In or out? Recommended: out. The web keeps its links, which are stronger against phishing. |
| + |
| +**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. |
| + |
| +**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. |
| + |
| +**J. Migration scope.** Does it cover Till's machines and `lagged`, or only Paul's? Recommended: Paul's only, with Till told separately. |
| + |
| +**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**. |