# 🤖 The smart door: remember how you last signed in

Status: **APPROVED by Paul, 2026-11-19 (r2, with option (a))**. Build in the order below.
Author: Claude (Opus 5.5), for Paul. Reviewed: Fable (claude-fable-5-2), r1:
READY AFTER FIXES. r2 applies every finding. Paul ruled the §4 question (a).

## The ask and the rulings

Paul, 2026-11-19: "Can we level up our ID flow? Inspired by e.g. Tito and
Eleven, there should be a smart sign in screen that remembers the last
signin method used."

Paul's three rulings, picked the same day:

1. **Remember the address too, sealed.** It lives in a cookie on the person's
   own device, sealed so only that host can read it. It is never kept at rest
   on any server. The door shows it back only to that browser. This amends
   Home's one rule (see "Home's one rule" below).
2. **Methods are the ones we have:** passkey, emailed link or Keymail, and
   Oficina ID. No Apple or Google sign-in, which would need its own spec.
3. **Slice 1 is the web:** id.oficina.works plus estilo's door, the sign-in
   page every app shares. Native sign-in sheets come later.

## What already exists (most of it)

- **rastrillo has shipped a remembering sign-in screen since v0.27**
  (2026-09-28, plan `rastrillo/docs/superpowers/plans/2026-09-27-signin-screen.md`,
  copy approved in copy review). `auth.Config.SigninScreen` turns it on.
  `lastsignin` keeps the way in (keymail, magic link or passkey) plus the
  address, in a sealed, host-only, HttpOnly cookie that lasts 400 days. The
  cookie is bound to its origin, renewed on every sign-in, and kept on sign-out.
  `auth.Forget` is the "Use a different email" button. The `ui` partial
  `signin` draws these doors: *ask*, *link* ("Continue as {address}"),
  *keymail*, *passkey* ("Sign in with your passkey" first), *sent*, *confirm*
  and *continue*. The cookie is never evidence of anything: a one-tap posts the
  address to `Begin`, which checks it from scratch, and the screen consults no
  store, so it can't reveal whether an address is known.
- **Of the suite, only Equipo has it turned on.** Every other app draws estilo's
  door (`chrome.SignIn`), which is a bare email form. Docs, Sheets, Slides,
  Calendar, Calls and Memoria pin rastrillo v0.27.1 to v0.29.2; Fichas and Mapa
  pin v0.35. All of them are new enough.
- **Home (id.oficina.works) has its own sign-in**, not rastrillo `auth`,
  because Home is blind. It shows a passkey button once script runs, then the
  email form. It remembers nothing.
- **Docs with Home configured** sends `/signin` straight to Oficina ID. The
  email form is at `/signin/local`.

So most of the level-up is **adoption**. Two pieces are new: Oficina ID as a
remembered method, and Home remembering for itself.

## What each door shows

**One way in per screen** (Paul, 2026-11-19: "We shouldn't offer two options
on the same screen. One option, and below it 'other ways to sign in'"). The
door shows the method used last on this browser as its single primary
action. Below it is a quiet link, **Other ways to sign in**. Nothing labels
the remembered method as last used: being the one on offer is the cue (Paul,
same day: it "can easily be inferred"). Unless marked *new*, all copy is
rastrillo's approved copy.

**Other ways to sign in** is a page of its own, not a disclosure, so it needs
no script. It is a chooser: a short list of rows, each opening a one-option
screen for that method, plus **Back**. **Use a different email** moves there
as the last row. It forgets this browser's record (`Forget`) and opens the
email field.

**An app's door** (Docs shown; any app with Oficina ID configured):

| Last used here | The one option | Other ways lists |
|---|---|---|
| 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) | **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
place of the Other ways link.

**id.oficina.works** (the brand is "Oficina ID"):

| 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 ({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
accent. Its icon is the Oficina mark's glyph alone, the two fanned cards, drawn in
`currentColor`. It is never the full-colour app icon, whose gradient tile fought the
button's fill. estilo ships the glyph (an inline SVG in the door template, so no
request and no flash). The pill shape is the door's, not yet the suite's: a
suite-wide switch is a separate estilo decision.

**The smaller controls** (Paul's review of the mockups, 2026-11-19):
- **Other ways to sign in, Back, Use a different email and Forget me on this
  device** are text buttons, not thin underlined links, and a clear step below
  the primary. They are medium weight, in the muted text colour that darkens on
  hover, slightly smaller than body text, with a chevron where they move you on
  or back and a soft pill on hover and focus. Semibold in full-strength text was
  tried and was too bold.
- **The chooser's rows are compact**: 48px for a single line, with the
  remembered address as a small second line. Every icon in them is a
  one-colour glyph, the Oficina one included.
- **One focus ring, not two.** rastrillo draws a field's grey edge, then a 2px
  accent outline 2px outside it, which reads as a double border. On the door,
  the edge itself turns accent with a soft halo flush against it. The same
  double ring is on every rastrillo field in the suite, so fix it in
  rastrillo's tokens rather than only on the door, as part of step 1.

**Nothing else on the card.** The door carries no footer links. Docs, Slides,
Calls, Memoria and Mapa put a Colophon link there on 2026-10-26 through estilo's
`SignIn.OpenSource` slot. Nobody ruled that, and Paul, 2026-11-19: "That makes
no sense at all." The Colophon stays under Help. The slot is removed from
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 **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. connect's signed-out `PageData` and estilo's `estilo-signed-out`
each gain that second POST form. Each host forgets separately, so a
Home-derived app chains to id.* after its own Forget: the app's signed-out
page links to `https://id.oficina.works/forget?return=<its own signed-out
URL>`, which shows one button, *new* **Forget me on Oficina ID too** (a
same-origin POST), and a quiet *new* **Not now** link back. After
forgetting, id.* returns **only** to a URL whose origin is a registered
consumer (`HOME_CONSUMERS`) and whose path is exactly `/signed-out`;
anything else lands on id.*'s own signed-out page, which offers its own
Forget. (Sign-out itself never passes through id.*'s signed-out page: the
consumer hop lands on the app's own, so the chain starts there.) Apps add
the link in step 6. 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;
back in the app. If an id.* session is still alive, there is no door at all:
straight back in the app (Paul's ruling 2026-11-20, which retired the
Continue page; slice 1 spec, Assertion and browser exchange, step 2).

## The cookie

It is lastsignin's cookie, unchanged in format. Every host keeps its own,
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.

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` 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

Rastrillo's blind mode turns off address-remembering cookies on purpose,
because Home's rule is "never stores a readable address". Paul's ruling 1
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 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.

**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 amended by ruling 26** (Paul chose option (a), below).
The credential origin may render exactly one person-supplied string: the
address Home sealed itself, under the limits in (a).

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.
"Use a different email" and "Forget me on this device" are the answer. Rotating
`HOME_DEK` forgets everyone, which is harmless: the cookie reads as Invalid
and is cleared.

## Script, flashes and layout

- Every door works with script off, except passkeys, which need their ceremony
  script (ruling 25).
- **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 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`, 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), **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.

## Ruled: the address on id.oficina.works, option (a)

Paul, 2026-11-19, picked **(a)**. Ruling 26 includes this §4 and gate 5
carve-out. Both are amended in the same commit that lands ruling 26.

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."

1. **Docs shows the door.** `/signin` stops hopping straight to id.oficina.works.
   It shows the door with Continue with Oficina ID as the one option.
2. **Forget me on this device** goes on the signed-out page.
3. **The Colophon link comes off the live doors now**, ahead of this work, in
   Docs, Slides, Calls, Memoria and Mapa. estilo's `OpenSource` slot is removed
   later, with the rest of step 2.
