oficina / home Public

Spec r2: apply Fable's r1 review (READY AFTER FIXES)

No address carry-over (the cookie names only who just signed in); routes for
/signin, /signin/local and /signin/oficina; the chooser and override contract;
problems, refusals, reauth, base path and id.* states; one-way as a separate
default-off option; Home's rastrillo bump as its own step; connect free of
lastsignin; passkey failure path and conditional UI details; Home renders the
shared partial; gate 9 driven by a sealed canary. One question for Paul: §4,
the address on the credential origin.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 9853e1c5d14e0ac98a04902a1c3c709a00fd466a parent 2c12842
1 file changed, +177 −52
  • docs/superpowers/specs/2026-11-19-smart-door.md +177 −52

CI passed — run details

CI log
amadan: .amadan/timeout: this job's budget is 20m0s (this runner allows up to 30m0s)
=== vet ===
CGO_ENABLED=0 go vet ./...
CGO_ENABLED=0 go vet -tags browser ./internal/home/
cd handoff && CGO_ENABLED=0 go vet ./...
cd roster && CGO_ENABLED=0 go vet ./...
cd dashboard && CGO_ENABLED=0 go vet ./...
cd connect && CGO_ENABLED=0 go vet ./...
cd teammode && CGO_ENABLED=0 go vet ./...
=== fmt ===
=== build ===
CGO_ENABLED=0 go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ./cmd/home ./cmd/oficina ./internal/operatorlaunch
cd handoff && CGO_ENABLED=0 go build ./...
cd roster && CGO_ENABLED=0 go build ./...
cd dashboard && CGO_ENABLED=0 go build ./...
cd connect && CGO_ENABLED=0 go build ./...
cd teammode && CGO_ENABLED=0 go build ./...
=== go-test ===
CGO_ENABLED=0 go test -count=1 ./...
?   	amadan.net/oficina/home/cmd/home	[no test files]
ok  	amadan.net/oficina/home/cmd/home-placeholder	0.772s
?   	amadan.net/oficina/home/cmd/oficina	[no test files]
ok  	amadan.net/oficina/home/internal/guardstest	0.094s
ok  	amadan.net/oficina/home/internal/home	51.695s
ok  	amadan.net/oficina/home/internal/home/directorydata	1.415s
ok  	amadan.net/oficina/home/internal/home/logtest	0.011s
ok  	amadan.net/oficina/home/internal/home/seal	0.003s
ok  	amadan.net/oficina/home/internal/home/sealtest	0.003s
ok  	amadan.net/oficina/home/internal/home/wisp	0.053s
ok  	amadan.net/oficina/home/internal/operator	6.455s
ok  	amadan.net/oficina/home/internal/operatorlaunch	4.140s
ok  	amadan.net/oficina/home/internal/provisioner	49.296s
cd handoff && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/handoff	0.673s
ok  	amadan.net/oficina/home/handoff/seal	0.002s
cd roster && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/roster	5.123s
cd dashboard && CGO_ENABLED=0 go test ./...
ok  	amadan.net/oficina/home/dashboard	(cached)
cd connect && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/connect	1.367s
ok  	amadan.net/oficina/home/connect/linkstore	0.447s
cd teammode && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/teammode	0.105s
?   	amadan.net/oficina/home/teammode/teammodetest	[no test files]
=== race ===
go test -race -count=1 ./internal/home/ ./internal/operator/ ./internal/operatorlaunch/ ./internal/home/directorydata/
ok  	amadan.net/oficina/home/internal/home	390.180s
ok  	amadan.net/oficina/home/internal/operator	83.010s
ok  	amadan.net/oficina/home/internal/operatorlaunch	22.402s
ok  	amadan.net/oficina/home/internal/home/directorydata	24.012s
ok  	amadan.net/oficina/home/internal/provisioner	421.257s
cd handoff && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/handoff	12.919s
ok  	amadan.net/oficina/home/handoff/seal	1.014s
cd roster && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/roster	6.916s
cd dashboard && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/dashboard	1.065s
cd connect && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/connect	6.006s
ok  	amadan.net/oficina/home/connect/linkstore	6.365s
cd teammode && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/teammode	1.964s
?   	amadan.net/oficina/home/teammode/teammodetest	[no test files]
diff --git a/docs/superpowers/specs/2026-11-19-smart-door.md b/docs/superpowers/specs/2026-11-19-smart-door.md
index bdeef7f..c21f216 100644
--- a/docs/superpowers/specs/2026-11-19-smart-door.md
+++ b/docs/superpowers/specs/2026-11-19-smart-door.md
@@ -1,7 +1,9 @@
# 🤖 The smart door: remember how you last signed in
-Status: **draft for Paul's approval**, 2026-11-19. No code before approval.
-Author: Claude (Opus 5.5), for Paul.
+Status: **draft r2 for Paul's approval**, 2026-11-19. No code before approval.
+Author: Claude (Opus 5.5), for Paul. Reviewed: Fable (claude-fable-5-2), r1:
+READY AFTER FIXES. r2 applies every finding. One of them (§4, the address on
+the credential origin) needs Paul's ruling; see "Open question".
## The ask and the rulings
@@ -67,11 +69,15 @@ email field.
| Last used here | The one option | Other ways lists |
|---|---|---|
-| nothing | *new* **Continue with Oficina ID** | Email me a link |
-| Oficina ID | *new* **Continue with Oficina ID**, "as {address}" under it if one is remembered | Email me a link ({address}) · Use a different email |
+| nothing | *new* **Continue with Oficina ID** | Email |
+| Oficina ID | *new* **Continue with Oficina ID**. Never captioned with an address | Email ({address}, if this app resolved one) · Use a different email |
| emailed link | **Continue as {address}** | Oficina ID · Use a different email |
| Keymail | **Continue to Keymail**, as {address} | Oficina ID · Use a different email |
-| (email chosen) | Email field · **Continue** | Oficina ID |
+| (Email chosen) | **Continue as {address}** if one is remembered, else the field · **Continue** | Oficina ID |
+
+The chooser's email row is **Email**, with the remembered address as its
+second line. It opens the email screen, where `Begin` classifies the address
+as it does today (Keymail or a link). The row doesn't promise either one.
An app without Oficina ID configured has only email. It shows "Continue as
{address}" or the field, and under it **Use a different email** takes the
@@ -82,9 +88,14 @@ place of the Other ways link.
| Last used here | The one option | Other ways lists |
|---|---|---|
| nothing | Email field · **Continue**. The field offers saved passkeys as autofill (WebAuthn conditional UI, `autocomplete="username webauthn"`), so a passkey holder never needs the list | Sign in with a passkey |
-| passkey | **Sign in with your passkey** | Email me a link ({address}) · Use a different email |
+| passkey | **Sign in with your passkey** | Email ({address}, if kept; see "The cookie") · Use a different email |
| emailed link / Keymail | **Continue as {address}** | Sign in with a passkey · Use a different email |
+For someone who has enrolled a passkey, email on id.* still ends at the passkey
+or a recovery code (slice 1: email alone isn't enough after enrolment). The door
+can't know who has enrolled without consulting a store, which it must not do.
+So the Email row stays neutral, and the gate explains itself when it is reached.
+
**How the buttons look** (Paul, 2026-11-19, option A of four). Every button on
the door is a pill, as in Fichas' level-up: lit from above, with the primary's
shadow tinted by its own accent. **Continue with Oficina ID** uses the app's own
@@ -119,14 +130,57 @@ estilo, and each app drops it as it moves to the new door.
**What changes in rastrillo's screen.** Today its passkey door and ask door
show the passkey button and the email form together, separated by "or", and
its remembered doors end with a ghost "Use a different email" button.
-One-way-in becomes a `SigninScreen` option (`OneWay`, or a better name in
-review). It draws the single option plus the link, and adds the chooser as a
-new `Step`. rastrillo's other users keep today's screen unless they opt in.
-Oficina turns it on everywhere.
+One-way-in becomes a **separate config field, default off** (`SigninOneWay`,
+or a better name in review), so Equipo and rastrillo's other users keep
+today's screen. It draws the single option plus Other ways, and the chooser is
+a new `Step`. The **federated slot** is page-supplied, like `Passkey`: an
+href and a label (`Federated{Href, Label}`). Equipo, which today appends its
+own Home button under the partial, moves into that slot when it opts in.
+`Door()` keeps "a passkey is never the only way in" by construction: the
+email way is always one tap away in the chooser.
**Signed out** (every app): "You're signed out", **Sign in again**, and a
quiet *new* **Forget me on this device**, which posts to `Forget` for a shared
-computer.
+computer. connect's signed-out `PageData` and estilo's `estilo-signed-out`
+each gain that second POST form. A Home-derived sign-out chains to id.*'s
+signed-out page, which offers its own Forget, because each host forgets
+separately. Forget's request-forgery protection is unchanged:
+`csrf.SameOrigin` in apps and `csrf.Protect` on Home. The worst a forged
+request can do is forget.
+
+**Routes, and every state the door must answer** (r1 finding 3, 5, 6, 7, 11,
+14, 18):
+
+- **`/signin` always renders the door.** The query dispatch that sent a bare
+ `/signin` to Home (connect's `Routes.Signin`, Docs' `homeRoutes.signin`) is
+ deleted. **`/signin/local`**, where connect sends unknown, failed,
+ link-resume and choose-declined people, renders the door with **email as the
+ one option**: never Oficina ID, which would loop. **Continue with Oficina ID**
+ is `GET /signin/oficina?return_to=…`. It does today's `rememberReturn` plus
+ `handoff.StartPath`.
+- **Chooser and override:** `?ways=1` renders the chooser. `?way=email|passkey|oficina`
+ renders that method's one-option screen. The override picks a **method,
+ never an address**: the address only ever comes from the sealed cookie or
+ the field. Every chooser link, Back, and the Forget form carry `return_to`.
+- **Problems win.** Any `err` (including Keymail's), a rate limit, or `force=1`
+ renders the email door with the field, keeps `force`, and shows the problem.
+ `sent`, `confirm` and `continue` render as today: no chooser, and **Sent keeps
+ "Use a different email"**.
+- **App refusals** (Docs' in-response "refused", via `Config.Refused`) get a
+ slot: an app-supplied problem (text, plus "force the ask door") in the
+ partial's keys. Without it, a refused person would see "Continue as {old
+ address}" and no message.
+- **Reauth** (`?reauth=1`, or a fresh-auth step-up) offers a **local** method
+ only: email in apps, and passkey or email on id.*. A live id.* session would
+ hand back an old `auth_time`, and connect's link flow needs `FreshLocal`.
+- **Base path:** with `SigninState.Unavailable`, `estilo-signin-screen` draws
+ nothing, and the app answers as it does today.
+- **id.* specifics:** a `Begin` failure after "Continue as" re-renders the
+ field door, prefilled from the cookie. **Sent stays address-free**, as Home's
+ is by design. `?force=1` after a failed Keymail return is the field door with
+ force kept. The chooser, Back and Forget are served on routes that **don't
+ call `rememberReturn`**, or carry `return_to` explicitly. A test walks app →
+ id.* → Other ways → passkey → back in the app.
**The returning path for an Oficina ID user** on an app: tap Continue with
Oficina ID; id.oficina.works opens on Sign in with your passkey; one touch;
@@ -141,20 +195,37 @@ because a parent-domain cookie is ruled out. Docs on `paulca.docs.oficina.works`
and id.oficina.works each remember for themselves. That is what we want: each
door reflects how *that* door was last used.
-Two changes to lastsignin:
-
-- **A federated method:** `MethodFederated` plus a closed, app-set `Provider`
- label (`"oficina"`). rastrillo stays generic, and the label names nothing
- about the person. Home's `connect` writes it when it mints a Home-derived
- session (`Bridge.Finish`), using a jar the app hands it (`auth.RememberJar`).
-- **The address carries over.** A passkey or federated sign-in keeps any
- address the record already held, instead of blanking it. An Oficina ID
- assertion carries no email (slice 1 spec), so this is the only way an app
- can still offer "Continue as {address}" as the second option.
+Changes to lastsignin:
+
+- **A federated method:** `MethodFederated`, with a closed, app-set `Provider`
+ label (`"oficina"`) that `validRecord` checks against a closed set. rastrillo
+ stays generic, and the label names nothing about the person.
+- **No address carry-over** (r1 finding 2; rastrillo's `passkey.go` already
+ refuses it, because "keeping the old address would label one person's
+ passkey sign-in with another's name"). A record only ever holds the address
+ of **the person who just signed in**, or none:
+ - **Apps:** the federated record is written in the app's own
+ `MintHomeSession` hook, never in `connect`. The app calls
+ `RememberJar().Remember` with the address of the local account it just
+ resolved, or with none. It is written only on the session-minting path
+ (`Bridge.complete` → `mintSession`), never on link, choose, unknown or
+ failed. `connect` stays free of `lastsignin`, so its consumers aren't
+ forced onto a new rastrillo minor.
+ - **id.*:** a passkey sign-in keeps the remembered address only if that
+ address's blind index resolves to **the same person ref** as the
+ passkey's subject, checked at sign-in time. Otherwise the address is
+ blanked. A finished passkey gate (`idFinish("signin")`) records
+ *passkey*, so an enrolled person who used email and then their passkey is
+ offered the passkey next time.
+- **API:** `Remember` needs the address supplied by the caller, as above.
+ `AttemptCookie` becomes optional, because Home has no attempt cookie.
+ Old binaries read new records as Invalid and clear them, so a rollback is
+ safe.
The jar on id.oficina.works is built with `lastsignin.New` directly. Its
-instance key is derived from `HOME_DEK` with its own HKDF label
-(`home/lastsignin/v1`), and the origin is `https://id.oficina.works`.
+instance key is derived from `HOME_DEK` under its own label
+(`home/lastsignin/v1`). `seal.Sealer` gains a small domain-separated derive
+method for that. The origin is `https://id.oficina.works`.
## Home's one rule
@@ -164,16 +235,27 @@ allows the following, and nothing wider. It becomes **Home ruling 26**,
recorded in the design spec's §1 table and in AGENTS.md's gloss when this
lands:
-> Home may seal the address a person typed into a cookie on **that person's
-> own device**, and render it back **only to the browser that presents it**.
-> It is never written at rest by Home: not to the database, a log, an error,
-> a metric or a queue. It is not evidence of identity, and the page that
-> shows it consults no store.
+> Home may seal **the address this browser last proved** (an opened link, a
+> Keymail callback) into a cookie on **that person's own device**, and render
+> it back **only to the browser that presents it**, on a `no-store` page. It
+> is never written at rest by Home: not to the database, a log, an error, a
+> metric or a queue. It is not evidence of identity, and the page that shows
+> it consults no store.
The falsifiable form is unchanged. Publish Home's database in full, and
-nothing in it is a readable address. Gates 1 and 2 stay as they are. Gate 9
-gains the cookie's name and value as a canary, so neither may appear in a log
-line.
+nothing in it is a readable address.
+
+**The gates** (r1 finding 12). Gate 9 is driven with a **validly sealed cookie
+whose address is a canary**, across every route, and asserts the address
+appears in no log line. The cookie's name isn't secret, and its ciphertext
+differs on every seal, so neither is a useful canary. The sign-in half of
+gates 1 and 2 also loads the door afterwards and re-scans the DB, WAL and store
+objects. **Before shipping, confirm the carlos edge logs neither Cookie
+headers nor response bodies.**
+
+**§4 and gate 5 are the open question below.** Ruling 26 as written would
+render a person-supplied string on the credential origin, which §4 forbids
+("No account-authored string, ever") and gate 5 enforces.
What this costs, stated plainly: anyone using that browser sees the
address, and so does anyone holding the cookie, who can load the door with it.
@@ -188,39 +270,82 @@ and is cleared.
- **No pop-in on a remembered passkey.** Today rastrillo writes the passkey
button `hidden` and the module reveals it. On the passkey door, where the
button is the primary, that moves the page after load. On that door alone,
- the button is drawn visible and disabled, with its space reserved; the
- module enables it. Without script, the button stays disabled with a single
- line saying passkeys need JavaScript, and Other ways to sign in sits right
- below it.
+ the button is drawn visible and disabled before enhancement, with its space
+ reserved; the module enables it. **If enhancement fails** (no
+ `PublicKeyCredential`, the import fails, or `available()` is false), the
+ module doesn't return silently: it writes the status line and moves to the
+ email screen. With script off, a `<noscript>` line says passkeys need
+ JavaScript, and Other ways sits right below it. `disabled` is used only
+ before enhancement, never as the busy state (it drops focus). Home's
+ script-stripped gate (§12 gate 6) and `noscript_test.go` allow-list the
+ visible button.
+- **Conditional UI on id.*** (passkeys offered in the email field's autofill).
+ It runs only when `isConditionalMediationAvailable()` is true, and never where
+ `LegacyRPID` is set (Home's is empty). An `AbortController` aborts it when the
+ form submits. The conditional `get()` can outlive the five-minute
+ `__Host-oficina-ceremony` challenge, or another tab can replace it, so a
+ refused finish re-begins and retries once. Any failure falls silently back to
+ the field. This needs a `mediation`/`signal` parameter in rastrillo's
+ `webauthn.mjs` `authenticate`.
+- **Home renders the shared partial.** id.* fills an `auth.SigninState` itself
+ and renders rastrillo's `signin` partial, instead of hand-rolling templates
+ that would drift. Its passkey finish answers in rastrillo's shape
+ (`{"ok": true, "to": …}`), so one passkey glue serves both.
- No new font and no icon font (never FOUT).
## The work, in order
-1. **rastrillo:** `MethodFederated` + `Provider`, address carry-over, a
- federated slot in the `signin` partial, the one-way-in option and its
- Other ways chooser, the
- passkey-door no-shift fix and the new strings. Browser drives and axe run
+1. **rastrillo:** `MethodFederated` + `Provider`, the `Remember` API change
+ (no carry-over), the one-way option and its chooser `Step`, the
+ `Federated` slot, the app-problem slot, the passkey-door no-shift and
+ failure path, `webauthn.mjs` conditional mediation, the single focus ring
+ in tokens, `seal` derive, and the new strings. Browser drives and axe run
on every new state, as for the existing ones. Release as a minor version.
2. **estilo:** `estilo-signin-screen`, rastrillo's `signin` partial inside the
- door chrome (sky, card, app mark), taking `SigninState`, `Brand`, `Sky` and
- an optional Oficina ID action. `estilo-signin` stays for apps that haven't
- moved. The signed-out page gains Forget me on this device.
-3. **Home `connect`:** `Bridge.Finish` remembers the federated method through
- the jar the app passes in.
-4. **Home id.oficina.works:** the jar, the three doors above, conditional UI
- in `passkey.js`, ruling 26 and the gate 9 canary.
-5. **The apps,** Docs first, then Sheets, Slides, Calendar, Calls, Memoria and
- Fichas. Each one turns `SigninScreen` on, renders `estilo-signin-screen`,
- bumps estilo and rastrillo, and keeps its own error strings only where
- rastrillo's don't cover them. Equipo moves its existing screen into the
- door chrome. Docs stops redirecting `/signin` to Oficina ID and shows the
- door, with Oficina ID first (see question 1).
+ door chrome (sky, card, app mark), **template-only and duck-typed**. estilo's
+ go.mod stays on the old rastrillo path, so its tests render a fixture. It
+ draws nothing when Unavailable. The Oficina glyph is inline. The signed-out
+ page gains Forget. The `OpenSource` slot is removed. `estilo-signin` stays
+ for apps that haven't moved.
+3. **Home to the new rastrillo**, as its own step: v0.26.1 to the step-1
+ release, with AGENTS.md's ritual (`doctor --fix`, delete the shims, the
+ vendored tokens.css gate). `connect` doesn't import `lastsignin`.
+4. **Home connect:** the `/signin`, `/signin/local` and `/signin/oficina`
+ routes above, and the signed-out page's Forget form.
+5. **Home id.oficina.works:** the jar, the doors through the shared partial,
+ the same-person check, conditional UI, the `{ok,to}` passkey finish, ruling
+ 26 (once the open question is answered), and the gates.
+6. **The apps,** Docs first, then Sheets, Slides, Calendar, Calls, Memoria,
+ Fichas and Mapa. Each one turns `SigninScreen` and the one-way option on,
+ renders `estilo-signin-screen`, bumps estilo and rastrillo, remembers the
+ federated record in its own `MintHomeSession` hook, and moves its refusal
+ text into the app-problem slot. **Equipo** moves its screen into the door
+ chrome and its Home button (`oficina_id.go`) into the federated slot.
+7. **Later, native:** the kit's sign-in sheet reads the last-used method from
+ the App Group, which already holds the last-used (identity, team).
6. **Later, native:** the kit's sign-in sheet reads the last-used method from
the App Group, which already holds the last-used (identity, team).
Reviews follow the Amadan workflow, with a Fable (or Astra) review before each
merge. New copy goes through copy review.
+## Open question for Paul: the address on id.oficina.works
+
+Home's design §4 says the credential origin (id.oficina.works) shows **"No
+account-authored string, ever"**, and gate 5 tests it. Today's passkey page
+withholds the address for exactly that reason. "Continue as paul@tito.io" on
+id.* would be the first such string.
+
+- **(a) Allow it, narrowly (recommended).** Amend §4 and gate 5 for exactly one
+ string: an address Home itself sealed. It is shape-checked again on read
+ (`lastsignin.validAddress`), escaped by html/template, and appears only as
+ text and in a hidden `value`. An attacker can't forge the cookie without
+ `HOME_DEK`. Whatever it says is something this browser proved. The `passkey.go`
+ comment changes in the same commit.
+- **(b) Keep §4 absolute.** id.* remembers the **method only**. The email screen
+ shows the field, and the browser's own autofill supplies the address. App
+ doors still show "Continue as {address}"; only id.* doesn't.
+
## Paul's answers (2026-11-19)
Paul: "Happy with recommendations. Remove now."