oficina / docs Public

Docs native: straight in with one Oficina ID (kit 1e36aac), Use another, signed-out 403 re-mint open

On branch feat/oficina-id-straight-in

Branch feat/oficina-id-straight-in @ 2e70647 (on main 0250ef1). Hub CI passed. Not merged; Fable whole-branch review requested.

What. Docs moves to the shared Oficina ID kit's straight-in version (rastrillo/native 1e36aac; Home spec §9 as amended by 2e50b92), mirroring Sheets 03d52db:

  • repin f1c7a14 → 1e36aac everywhere (Package.swift/.resolved, both project.yml, provenance.json, Colophon.json regenerated);
  • straight-in suspension bound to the sign-in route (launch on the Other-ways route suspends; a route flip resumes; signed-in sessions undisturbed; only in .task/.onChange — never view init/body, cf. the 0.1.7/0.1.8 hang, discussion 128);
  • "Use another Oficina ID" (Teams sheet + Mac app menu), only while signed in, refused with an open document window, re-checked (signed in, no windows, no unsent changes) when the confirmation appears; .oficinaReplaceConfirmation(model) on the signed-in screen only; recents/transports of a removed identity dropped on the Mac.
  • Server change (deliberate): Docs' guards never said "Sign in first." — a missing/revoked session gets 403 "signed out\n" (rastrillo), but a native session past 7 days got 403 "Something went wrong.\n", shared with real refusals, so a write after expiry was held as "access lost" and never re-minted. internal/docs/identity.go now answers "signed out" for that one case; native_contract_test.go pins the bytes on every guard and checks other refusals don't use them. The app treats exactly "signed out\n" as an ended session (re-mint, surface 401). Kept by my ruling (the alternative leaves the 7-day case unhandled).

Tests. swift test 132 run, 0 failed, 4 pre-existing skips; new tests for straight in, route binding, Use another guards, the signed-out 403, the signed-in workspace; SignedInLaunchTests hosts the real home window with a saved identity (verified to catch a body mutation). Mac + iOS simulator builds pass. Local Go gate passes apart from three local-environment failures (socket path length under macOS TMPDIR; a pre-move rastrillo file from an in-worktree iOS build) that pass in a clean setup; hub CI green.

Not in scope: Use another on the iPhone library toolbar / Mac Settings (Teams sheet + app menu suffice).

Whole-branch review — Claude Fable 5.2 (claude-fable-5-2), reading git diff 0250ef1 2e70647 as one diff.

Verdict: APPROVE. Nothing blocking. Seven LOW follow-ups and one manual check to do before a release.

How I checked. Review-only worktree at 2e70647 (removed afterwards; docs-straight-in untouched). Read the kit at 1e36aac, spec §9, and Sheets 03d52db for parity. Ran swift test for OficinaIDAdoptionTests, SignedInLaunchTests, WorkspaceInitTests and TransportSupplierTests: 35 passed. I did not run the Go tests myself (no make target here; relied on hub CI) and ran nothing on iOS.

The 0.1.7/0.1.8 hang: not reintroduced.

  • DocsAccountWindow.body, oficinaWorkspace, teamPicker, signedIn, route and DocsDocumentWindow.body only read. Every write (start, suspend/resume, the replace guard, the recents/transports cleanup) is in .task, .onChange, .onAppear or a button.
  • DocsOficinaSession.transport(for:) and client(for:) are pure; mounted/signIns change only from the step publisher.
  • Mutation check: I put windows.entries = windows.entries into oficinaWorkspace. Both SignedInLaunchTests went red for the right reason (the body test's assertion, and the settle test's 60 s watchdog).

Server change: safe.

  • errSessionEnded is returned only at the connect.Expired branch and wraps errIdentityRefused, so every errors.Is caller (linkedSubject, suite, agent store, team_stream) behaves as before.
  • Unlinked or removed identities and requireAdmission keep the generic line. GET/HEAD still 303.
  • No browser script reads the body. An expired-session holder learns nothing they could not already get from sessions.Require.

Re-mint cannot loop. rejected() allows one re-mint per account per 60 s, plus the renewing guard. A server that always answers "signed out" costs one assertion and exchange a minute while requests are being made, and the drainer stops on sessionEnded in between.

Repin: clean. Kit Package.swift and LICENSE are unchanged between f1c7a14 and 1e36aac, so the provenance sha256 holds. Package.resolved, both project.yml files, provenance.json and Colophon.json all carry 1e36aac.

Sheets' leftover LOWs. Docs avoids "picker Use another over outage" (nil unless .signedIn, and the session re-guards). It keeps the confirm-time doc guard gap (finding 2) and the redundant suspend (finding 7).

Findings

  1. LOW — the unsent check runs after the dialog is up. DocsAccountWindow.swift:88-97, 192-196. From the Mac menu the item is gated on open windows and creatingDocument only, so with a non-empty outbox the confirmation is presented, then withdrawn and replaced by the "still sending" alert. I probed this in the hosted window: the alert appears and the identity is kept, so the guard works. Until the async DocsLeaveBlock.check returns, a confirm goes through, and nothing re-checks at confirm. The outbox is left on disk, not deleted, and resumes only if the same identity signs in again. Fix: in useAnother(_:), await DocsLeaveBlock.check first and call oficina.useAnother only when it is clear; keep the onChange as backstop.
  1. LOW — no guard at confirm time (same as Sheets). With the dialog up on the home window, File ▸ Recent or ⌘N (DocsWindowCommands.swift:34-48) can still open a document window of the identity. Confirm then signs it out underneath; :115-120 keeps that window's transport but its session is gone, so edits queue in an outbox nobody is signed in to. Fix: cancel the replace when openDocuments(of:) turns true while confirmingReplace.
  1. LOW — lanes already held as "access lost" do not resume. sessionRestored() only clears sessionEnded (kit OutboxDrainer.swift:135), and Docs never releases a Hold(.accessLost). The branch stops new holds from a 7-day expiry; a lane held by 0.1.8, or by the new app against a server without this change, stays held after a re-mint. Deploy the server before shipping the app.
  1. LOW — the drainer can be left in sessionEnded with a good session. A re-mint set off by another request completes and calls sessionRestored, while the drainer's write sent on the old cookie is still in flight. Its "signed out" then lands, sets sessionEnded, and rejected() drops it under the 60 s limit (DocsOficinaID.swift:214-221). The outbox shows "needs sign-in" until the next foreground or document open. This was unreachable for writes while they were 403. Fix: in rejected(), if the account's session has already been replaced, call DocsOfflineAccount.sessionRestored(account) instead of returning.
  1. LOW — straightInSuspended can drift from the route. The picker's "Other ways" is not blocked by open document windows (:232-236). With home on the server route and an Oficina document window open, a 401 or "signed out" there runs sessionRejected → kit signedIn(), which clears the flag (OficinaIDModel.swift:762) while the route is still .server. A later identity appearing on the device could then go straight in behind Docs' own sign-in (rule 0). No data risk. Fix in Docs (re-suspend after a re-mint on the server route) or in the kit (do not clear on a re-mint).
  1. LOW — tests. - The window-level Use another guard (:88-97: unsent, open document, outage) has no committed test; the session-level tests never reach it. A SignedInLaunchTests case that enqueues one outbox entry and asserts confirmingReplace == false with the identity still present would pin it. - TestNativeContractOtherRefusalsDoNotSaySignedOut calls refuseIdentity(…, false) directly, so it proves the function, not the stack. A real refusal through the router (a live native session whose link or principal was removed, then a POST) is the case that matters. - testBuildingTheSignedInWindowBodyChangesNothingItWatches never asserts the body took the Oficina branch; a server account in the runner's defaults or keychain would let it pass vacuously.
  1. NIT — teamPicker's otherWays calls model.suspendStraightIn() and .onChange(of: route) does it again. Harmless.

Check before release (not verified by me or by any test). Teams sheet → "Use another Oficina ID" sets pickingTeam = false and confirmingReplace = true in the same tick (:236-239), so the confirmation is presented while the sheet is dismissing. My probe called the session directly, not through the sheet. UIKit can drop a presentation made during a dismissal; please tap through it once on an iPhone and once on the Mac.

Landed as main 7de2d40 (squash) after Fable's APPROVE and green hub CI at 2e70647. The seven follow-ups are tasks on this branch. Order: Docs server deploy (with 0250ef1) first — after Paul's alta-adopt Plan C — then a Docs native release carrying fixes for L1/L2/L4 and Paul's Use-another tap-through.

Deployed to production: Docs main 2e21630 (release v0.1.0-88-g2e21630). Alta's Plan C is complete, so the hold on Docs deploys is lifted. This build includes 0250ef1 (a native session can no longer approve the browser sign-in) and 7de2d40 (straight in with one Oficina ID; a signed-out 403 re-mints).

  • Canary. I promoted the release onto canary/overnight-release (overnight-docs.bds.oncarlos.com). - /api/version, /healthz, the one-way door, /signin?ways=1, /signin/local, /signin/oficina (303 to /auth/start) and the colophon (Fiesta, minify, parse) all checked out. - A cross-origin POST to /signin got 403, and a bogus /native/exchange body got 400 "Invalid proof" with no 500. - The only log error was the known "content sealing not activated". - overnight-docs is back on v0.1.0-87-g8de057d.
  • Production. I promoted to edge and restarted docs.bds.oncarlos.com and lagged-docs.bds.oncarlos.com. /api/version serves v0.1.0-88-g2e21630 on docs.oficina.works and lagged.docs.oficina.works, and /healthz is 200 on both. - docs.oficina.works: the door, chooser, /signin/oficina and colophon all check out. - lagged: the door is email-only and /signin/oficina and /signin/local return 404, as expected with no Home.
  • Rollback target: v0.1.0-84-g84d1008. To roll back, run carlos promote --app docs --account oficina --no-prompt v0.1.0-84-g84d1008 edge, then restart both hosts.
  • Mail stays on DOCSSMTP*, because no build was shipped with mail submission.