oficina / docs Public

Docs native 0.1.10 prerelease: #130 follow-ups L1/L2/L4, rastrillo/native 0254817 open

On branch fix/native-prerelease-0.1.10

Branch fix/native-prerelease-0.1.10 (on main c715478), two commits. Not merged, released or deployed.

  • d766437 — repin rastrillo/native a18c32b → 0254817 (rastrillo/native #49, chunked response reader) in Package.swift, Package.resolved, both project.yml, provenance.json; Colophon.json regenerated with go run ./cmd/docs-colophon (pinned go1.26.5).
  • 6a11103 — Fable's follow-ups from #130: L1 (#131), L2 (#132), L4 (#134).

L1 (#131) — Use another checks before it asks. DocsOficinaSession.requestUseAnother(identity:openDocuments:) awaits DocsLeaveBlock.check first (identity-wide outboxes, open document windows), asks openDocuments again after the await, and only then calls useAnother. The window's useAnother(_:) uses it; its .onChange(of: model.confirmingReplace) stays as the backstop. The confirmation is no longer put up, confirmable, while the check runs, then withdrawn. Test: OficinaIDAdoptionTests.testUseAnotherWithUnsentChangesIsRefusedBeforeItAsks (sink on $confirmingReplace: never true with an unsent entry; a window opening during the check refuses; clear asks once).

L2 (#132) — a document window opening withdraws the question. DocsAccountWindow reads replaceUnderOpenDocument (confirmingReplace && a document window of the identity open) and acts in .onChange: cancelReplace() + the "close its windows" alert. Read only in the body, written only in onChange. Test: SignedInLaunchTests.testADocumentWindowOpeningWithdrawsTheReplaceQuestion hosts the real home window, lets the kit ask, then windows.reserve(...) (what File ▸ Recent/⌘N do) and checks the question is gone and the identity still signed in. Also added Fable's finding-6 backstop test testTheReplaceQuestionIsWithdrawnWithChangesUnsent (passes before and after; it pins the existing guard).

L4 (#134) — a refusal of an already-replaced session. The transport now records which session each request was sent with (DocsOficinaSession.watch(_:account:session:)); rejected(_:sentWith:):

  • waits for a re-mint in flight (the renewing Bool became a renewal Task; a refusal landing mid-re-mint used to be dropped);
  • if the account's session is no longer the one sent with, mints nothing and calls DocsOfflineAccount.sessionReplaced, which joins the drain in flight (if phase == .sending) and then sessionRestored(). Why join and not call sessionRestored straight away as #134 suggested: the watch's rejected Task usually runs on the main actor before the drainer sets sessionEnded (the drainer awaits outbox.endSend first), so an immediate restore would be overwritten. Joining the drain (it starts nothing new) restores after the drainer has stopped. Test: OficinaIDAdoptionTests.testARefusalOfAnAlreadyReplacedSessionRestartsTheOutbox (an outbox write on the first session's cookie gets 403 "signed out" after another request's re-mint; the drainer must leave sessionEnded and no second exchange happens).

Each test fails with its fix reverted (checked by mutation: ask-then-check order for L1, the onChange disabled for L2, the replaced-session branch disabled for L4), and passes with it.

Kit bump notes (a18c32b..0254817). Two commits: 382bf73 and its merge, NativeHTTP.responseDetails reading the body through a task delegate (BoundedBody) in URLSession's chunks instead of AsyncBytes byte-by-byte. Same contract: maxBytes still refuses past the limit (now also up front on Content-Length, cancelling the task), same "The server response is too large." message, response observed before a body error. Kit Package.swift and LICENSE unchanged, so the provenance sha256 holds. Nothing in Docs needed to adapt; Docs never read AsyncBytes itself.

Gates. See the follow-up comment for the Go gate, Mac/iOS builds and hub CI. native/scripts/check-native.sh: passed (171 Swift tests, 0 failures, 4 pre-existing skips; WorkspaceInitTests, SignedInLaunchTests, realtime/healing tests green).

Not in this branch: L3 (deploy-order note), L5 (straight-in drift on the server route), L6 parts 2–3, L7, and Paul's Use-another tap-through on iPhone and Mac (still to do before release).

Gates at 6a11103, all green:

  • native/scripts/check-native.sh: passed (Rust crdt/host, the 200-page fuel test, wire checks both ways, Swift: 171 tests, 0 failures, 4 pre-existing skips).
  • check-mutations.py (the --mutations half): every mutation caught; sources restored, tree clean.
  • Go/web gate .amadan/ci.d/10-gate, run locally with GOTOOLCHAIN=go1.26.5, TMPDIR=/tmp, npm ci in fixtures: gate: ok.
  • native/scripts/build-mac.sh: Oficina Docs.app built (ad hoc). build-iphone.sh simulator: BUILD SUCCEEDED. The first attempt hit a hub 429 on rastrillo/native while the Go gate was fetching modules; the retry was clean.
  • Hub CI: amadan ci status -branch fix/native-prerelease-0.1.10 exit 0, CI passed.

Still needed before 0.1.10 ships: a highest-capability review, Paul's Use-another tap-through on iPhone and Mac (#130), and L3's order (the server with the signed-out 403 is already live as v0.1.0-88).

Whole-branch review of fix/native-prerelease-0.1.10, git diff c715478 6a11103, by Claude Fable (model claude-fable-5-2), review-only session.

Verdict: APPROVE

Nothing blocks the merge or the 0.1.10 release. Six LOW/NIT notes, all of which can follow. Paul's Use-another tap-through (#137) is still needed before release.

What I ran

In my own detached worktree at 6a11103 (removed, with its build output; docs-prerelease untouched). The CRDT artifact was built for arm64 Mac only.

  • swift test, whole package: 171 tests, 4 skipped, 0 failures.
  • SignedInLaunchTests about 15 more times: one failure (finding 1).
  • One mutation by hand (finding 2).
  • A temporary probe in the hosted home window for L2: after a document window opens, the sheet on the window is the "Close this account's open documents first." alert with only Cancel. The replace question is gone from the screen, not only from the model.
  • Read the kit at 0254817 (NativeHTTP, OutboxDrainer, OficinaIDModel). I did not run the kit's own tests, the Go gate, or anything on iOS.

The three fixes

L1: correct. After DocsLeaveBlock.check returns there is no suspension before model.useAnother(), so the question cannot go up over an outbox that was non-empty when checked. The window re-check and the .onChange backstop both remain. A double click asks twice; useAnother() is idempotent.

L2: correct. The body only reads replaceUnderOpenDocument; cancelReplace() and leaveRefusal are written in .onChange and fire once per false→true change. No loop (see finding 3 for a runtime warning that is the kit's).

L4: correct. I could not make it stall, double-send or loop.

  • Stall: phase == .sending implies a drain is in flight (every exit of drainOnce sets another phase), so the join in sessionReplaced always waits on an existing drain and is resumed when it ends. If the phase is not .sending, no stale write is in flight and the immediate restore cannot be overwritten.
  • Double-send: drain() joined while draining starts nothing; the worker stays the only sender. The refused batch goes back to sendable and is sent once on the new session.
  • Re-mint loop: the replaced-session branch returns before lastRejection and mints nothing. A stale refusal costs at most one extra drain on the current session. If that session is refused too, the ordinary 60 s limit applies, as before.
  • Stale transports: every caller (transport(for:), windows.transports, DocsModel.client(), the drainer's supplier) asks per request or per batch, so nothing holds an old session's watch and reports "replaced" for ever.
  • renewal Task: set before the task body can run, cleared inside it, never awaited from inside itself. A refusal that waited and finds the session unchanged (the re-mint failed, or was the day-old check) goes on to the usual guards.
  • Phase 1: the 250 ms pace holds the drainer in .sending, so a join only waits longer. pace is still called from one send at a time. sessionRestored resets the backoff and retryDeadline but not the server's Retry-After deadline.

Kit bump (a18c32b → 0254817): safe

  • Only NativeHTTP.responseDetails changed. stream and download are untouched.
  • The whole body is still collected before returning, so reply.data == "signed out\n" compares the same bytes. The 303 is still delivered unfollowed (the task delegate refuses the redirect, as the session delegate does).
  • The limit is the same at the boundary: up to maxBytes allowed, one more refused, same message, response observed first.
  • The continuation is resumed on every completion path, including cancel and an early finish.

Findings

1. LOW, flaky gate test. SignedInLaunchTests.swift:179 (and the same shape at :160).

  • testTheReplaceQuestionIsWithdrawnWithChangesUnsent failed once in about 15 runs: the first run after a cold build, XCTAssertFalse failed - changes are unsent: the question is withdrawn.
  • It pumps a fixed 0.5 s and then asserts. Poll for !confirmingReplace with a deadline of a few seconds instead.

2. LOW, test gap: the wait for a re-mint in flight is unguarded. DocsOficinaID.swift:249.

  • Removing if let renewal { await renewal.value } passes all 30 OficinaIDAdoptionTests.
  • A test that holds the service's exchange open, sends a refusal with the old session, then releases it would cover it.

3. LOW, kit: the replace confirmation's binding publishes during SwiftUI's own dismissal. rastrillo/native OficinaOnboardingView.swift:401.

  • Both new window tests log "Publishing changes from within view updates is not allowed" at OficinaIDModel.swift:326.
  • My probe's stacks show AppKit's dialog bridge setting the binding to false inside render, and the setter calling cancelReplace() again (twice per dismissal).
  • It happens once per programmatic cancel, is the same on main for the existing backstop, and does not loop. Fix in the kit: publish only when confirmingReplace is true.

4. NIT: the "mints nothing" assertion cannot fail. OficinaIDAdoptionTests.swift:652.

  • docs.rejected(account) at :641 sets lastRejection, so the 60 s limit alone would stop a second exchange. The sessionEnded assertion is the one that guards the fix.
  • Injecting now and stepping it past 60 s before the stale refusal would make this one real.

5. NIT: "Use another" now has an unmarked gap between the tap and the question. DocsAccountWindow.swift:203.

  • The check reads every team's outbox from disk before anything shows. On the Teams sheet path the sheet has already closed. This changes the timing #137 asks Paul to tap through, so that check should be done on this build.

6. NIT: a stale refusal resets the drainer's backoff. DocsOfflineAccount.swift:118.

  • Any request refused on a replaced session (a document GET as well as the outbox's write) ends in retryNow(). Bounded by the requests in flight at the re-mint; one early retry each.

Main (c715478): nothing I would hold back

  • The three squashes are byte-identical to the heads I approved: 80d4989 = 1a1b74b (#146), 0819fa1 = b351324 (#147), c715478 = d5e047a (#145). origin/main is c715478.
  • #147 landed on fixes I prescribed but did not re-read as a delta; my #145 final review ran on top of them (29 of 29 pairs, fuzz, crash boundaries), so they were exercised there.
  • The open low notes from #145 (148–152) and #146 cost at most one extra download or a manual retry; none loses data.
  • Server: production is v0.1.0-88-g2e21630, which has the signed-out 403 (L3 satisfied). The only server-side change on main since is the core wasm rebuilt with the yrs patches. From reading the patch list, those touch local inserts, redo and undo-kept GC, none of which the server does when applying remote updates, so 0.1.10 does not need it deployed first. I did not test the new engine against v88. Deploying c715478 with the release would remove the question.

Landed on main (squash) after Fable's APPROVE and green hub CI at 6a11103; low notes are tasks. Next: deploy the Docs server from main (core wasm carries the yrs patches) canary-first, then release native 0.1.10 (12) to Mac + TestFlight; Paul's Use-another tap-through (#137) on that build.

Docs 0.1.10 (12) released, and the server that goes with it is deployed (2026-11-22, release session).

Server. main 1433e2b, hub CI passed. Built with make release and shipped as v0.1.0-93-g1433e2b. It has the realtime phase 2 engine and the yrs CRDT fixes in the core wasm. Shipped without --mail submit because this Mac's carlos doesn't have it, so mail still goes over DOCSSMTP*.

  • I tested it on the overnight-docs canary first, then put that host back on v0.1.0-87-g8de057d. It is serving that again.
  • edge is now 93, and docs.bds and lagged-docs were restarted. docs.oficina.works, lagged.docs.oficina.works and both bds hosts report 93 on /api/version and in X-Carlos-Version.
  • Checks run on the canary, prod and lagged: - /healthz 200. - /signin 200 with the one-way door ("Sign in to Docs", "Continue with Oficina ID", "Other ways to sign in") and no /auth/start link. - ?ways=1 shows the chooser. - /signin/oficina gives 303 to /auth/start. On lagged it gives 404, as does /signin/local, which is expected there (email-only door). - The Colophon lists Fiesta, minify and parse. - A junk proof to /native/exchange gives 400 "Invalid proof". - /d/<x> and /d/<x>/updates redirect to sign-in, and a POST to updates gives 403 "signed out". Nothing returned a 500.
  • Logs: the only errors are the known "content sealing not activated" lines on lagged and overnight.
  • Not checked: an authenticated document page and its updates against real data. The canary has no seeded or dev account, and I don't use Paul's credentials.
  • Rollback: carlos promote --account oficina --app docs --no-prompt v0.1.0-88-g2e21630 edge, then restart docs.bds.oncarlos.com and lagged-docs.bds.oncarlos.com.

Mac 0.1.10 (12), Sparkle. Notarised (id 9a27f6e5-6a88-45c4-aeb5-6596a016c795).

  • On the unzipped release zip: spctl says Notarized Developer ID, Team Tito. The entitlements are right (keychain groups .docs then .id, App Group 9U4A84C4WK.works.oficina, webcredentials:id.oficina.works) and embedded.provisionprofile is there.
  • --oficina-id-launch-check passed every line and exited 0.
  • Published to native-releases as commit 98ec3473d1e623fcd26bda7c2e07e798f5d9d5dc, release docs-12. The public appcast lists 0.1.10 (12) first.
  • zip sha256 795686ce08e4ea7ab9ab4944ac9cbeb1f635ffbe4544c84ca26f694e83f2be03. An anonymous download gives the same hash.

iPhone 0.1.10 (12), TestFlight.

  • Uploaded with delivery 6224abc8-2915-4c59-b086-25baa3c9207b. The build processed to VALID, with usesNonExemptEncryption=false already set.
  • internalBuildState is INBETATESTING. The "Oficina internal" group has access to all builds.