Hub CI at 8cc6668: amadan ci status oficina/docs -branch perf/native-s1a exits 0 (CI passed). Push token revoked and build output cleaned. Ready for the whole-branch review. Not merged, released or deployed.
S1a: projection log, document surface, per-block rendering, render isolation (native redesign) open
On branch perf/native-s1a
S1a of the Docs native redesign: projection log, the document surface, per-block rendering, render isolation. Spec docs/superpowers/specs/2026-11-22-native-redesign-design.md §7 (Design, Measurement), §11; plan S1a. Rebased on main d5a328a. Not merged, released or deployed. No visible change: S0's baselines are pixel-identical. Pagination is untouched (S1b).
Commits
28efd51the realtime probes on main (from perf/native-realtime-audit d23f3ca), counters underDOCS_PROBESafdf102CRDTReplica:presentedRevision, the dirty log,presentation(…, since:)returning aPresentation(projection, revision, dirty) atomicallye1a094eNativeTextProjection.renderBlock+DocumentBlockSpacing.Context;DocumentBlockIndex; reconcile one range278d19fDocumentSurface, per-block drawing, the five flush triggers, render isolation; tests8cc6668the numbers (native/benchmarks/README.md), the iPhone timing probe, BUILDING.md
What it does
- Replica (§7 D1–2). Every projection, whoever asks, moves
presentedRevision; each delta logs the top-level ids it inserted or removed (last 512); any fullprojectbranch (open, recovery, reset,delta.appliednil) logs unknown.presentation(…, since:)returns the dirty set for exactly(since, revision], nil past the log or across unknown.DocsModelpassessurface.appliedRevisionassince; a publication its guards drop loses nothing. - DocumentSurface (§7 D3, 5, 6, 8). One per model, not
@Observable.applydrops stale (revision ≤ applied or ≤ newest), merges dirty intopendingDirtyor setsfullDiff.flushIfDeferredruns only whencanRender(newest.generation)and no marked text: re-renders the dirty / new / structurally different (CRDTNode: Equatable) blocks plus any whose spacing context moved (neighbour's top margin, first/last), keeps every other block as an anchor if it is one contiguous run of the index, and reconciles each gap between anchors into its own characters (DocumentRenderReconciliation.apply(_:to:in:), same guards). Whole render only at open/after reset; iOS assignsattributedTextonly then. Images re-render only blocks holding them. - Triggers: (a) publication applied, (b)
drainEditsends, (c)compositionChanged(false)/unmarkText, (d)projectionGenerationchanges ordidRenderadvances, (e)inputPausedcleared. SwiftUI no longer retries. - Block index (§7 D4):
.docsTopBlockruns (now also set on iOS), kept in the storage'sdidProcessEditing: runs before unchanged, after shifted, touched ones re-read. Provisional blocks are just runs. - Render isolation (§7 D9–11):
DocumentEditorHost(Equatable) reads only the surface, Pages and zoom; the text view is made once per document.projectionandselectionare@ObservationIgnored; the toolbar reads one equality-guardedtoolbarSelection; commands, word counts andDocsEditorContextread the live storage; editability and typing marks are pushed;detail,pendingTitle,draftToken,errorKey,inputPausedassign only when different (guard in their setters). ⌘K goes throughmodel.jumpRequests.
DocsWorkspace: exactly what changed (for S2a's rebase)
init: one new trailing parameterconnectivity: NativeConnectivity? = nil, passed toDocsModel(tests flip the sync status with it).- Two new private helpers before
beginRename():loadImages()andrequestJump(). editor, theif let projection = model.projection { … }branch only: nowif model.showsDocument { EditorToolbar(model: model); Divider(); DocumentEditorHost(…).equatable().id(…).task(id: imageSources) { loadImages() }.onChange(of: model.jumpRequests) { requestJump() } }.EditorToolbarlost itscontent:argument.- The two
DocsToolsControls(projection:content:selection:)lines (iOS toolbar, Mac inspector) becomeDocsToolsControls(model: model)underif model.showsDocument.
Nothing else in the toolbar/title/inspector/chrome was touched.
Spec points that needed more than the spec said
- Optimistic text the replica never confirms. The dirty set only names what the replica changed, so an edit it refused (or one only a dropped publication carried) stayed on screen. The surface now also marks every block the text view edited itself (
typed(around:)) for the next publication. Found by the delta-safety test. - iOS typing attributes drop
.docsTopBlock: typed text there has no block id until a publication draws it, so "typed text inherits the id" holds on the Mac only. Handled: a nil run belongs to the block before it (dirty marking), and a block split by a nil run is not an anchor, so it is redrawn. - Font-scoped re-render has no trigger:
DocsFonts.register()registers every face synchronously before the first window, and nothing registers late. I added no hook with no caller; images are block-scoped as specified. DOCS_PROBESin debug builds: the spec says "set only by the probe builds"; I define it for the debug configuration too, soswift testand test-iphone.sh can hold the hard counters as gates. Release (what ships) never has it; the probe builds pass-Xswiftc -DDOCS_PROBESto Release.- Timing rule: the load average was never under 4 (12–150 for the table, 300–1,000 earlier). I ran A (main+probes) and B (branch) interleaved, three each; the first separate baseline is kept but its timings are not used.
Hard counters (exact; gates in RenderIsolationTests, Mac swift test and iPhone)
Real DocsWorkspace window: 40 keys, 10 sync-status flips, 20 selection moves, 5 peer changes. After open: whole renders 0, host body evaluations 0, iOS attributedText 0; per key 1 block render (gate ≤ 3) and 1 storage edit (2 on iOS); per peer change ≤ 1 block render; per sync-status or selection change 0 renders and 0 storage edits. Release probe at p20 and p200h, per key (A → B): whole renders 3.6–4.5 → 0, host bodies 3.6–4.5 → 0, block renders 0 → 1 (0.95 at p200h, coalesced), view updates 3.6–4.5 → 0.03 (one, at open). Line-fragment counter: S1b.
Timings (median of 3 interleaved, A → B)
| | p20 | p200h | |---|---|---| | Mac keyDown pageless, 40 keys | 1.2 → 1.4 ms (p95 19 → 2.7) | noisy both sides: A 2.4/6.4/7.0, B 6.6/6.8/2.3 | | Mac keyDown pageless, 200 keys | 1.19 → 1.29 ms, p95 18.7 → 1.4 ms | — | | Mac keyDown paged (S1b) | 65 → 65 ms | 648 → 669 ms | | stalls > 16.7 ms / 40 keys, pageless | 90 → 0 | 87–95 → 1–3 | | peer, publication → reconciled (pageless) | ≈ 1 ms | ≈ 2.8 ms | | peer, all main-thread busy (pageless) | 73 → 23 ms | 576–704 → 16–22 ms | | peer, paged (reconcile still repaginates: S1b) | 117 → 81 ms busy | 888–1,146 → 200–209 ms | | iPhone one-block publication + layout (sim, Debug) | 53 → 0.7 ms | 542 → 4.8 ms |
Targets S1a can move: iPhone per publication (≤ 4 / ≤ 8 ms) met; peer main-thread from publication to reconciled (≤ 5 / ≤ 10 ms) met; measured as all main-thread busy per peer change (which also counts network, replica answer and drawing) p20 is 23 ms. Pageless keyDown ≤ 3 ms at p20 is met (1.3–1.4); the Mac paged keyDown and stall targets wait for S1b as planned. Full table: native/benchmarks/README.md.
Tests (each seen to fail with its mechanism broken)
ReplicaDirtyLogTests(5): revisions on every call, exact span, Return, overflow, recovery,delta.appliednil.BlockRenderEquivalenceTests: 6 seeds × 50 random edits (index 0, split/merge, multi-block paste, undo/redo, marks incl. code, block type, align; nested lists, quote, headings, image, rule, code block); per-block storage ≡ whole render after every publication. Red with neighbour re-spacing skipped.BlockIndexTests: typing, Return (provisional), Backspace at block start (two runs), paste through the real text view, no publication; index = fresh runs; then the publication → whole render. Red with the shift of later runs removed.DeltaSafetyTests: realDocsTextView+ production replica + a peer; dropped, delayed (stale) and extraprojection()publications; ja and zh marked text while the peer edits the same block and another; log limit 2 (overflow). Quiescence ≡ whole render. Red with unknown entries not forcing a full compare.FlushTriggerTests(5, realDocsModel): each trigger with no later publication. Red (b, c, d, e) with the flush wired todidRenderonly.RenderIsolationTests: above.swift test: 201 tests, 0 failures, 12 skipped (env-gated probes and the snapshot gates). WorkspaceInitTests, SignedInLaunchTests, EditorRenderLoopTests, OfflineDurability, OficinaIDAdoption green. (One SignedInLaunchTests run failed once at load ~700 on the home window's replace question; 3/3 green re-run, and green in the gate run.)test-iphone.sh: 14/14 (EditorRenderLoopTests 3, the S1a tests, SurfaceTimingTests).check-native.sh --mutations: passed, 20 mutations caught.- iOS simulator build of DocsPhone: BUILD SUCCEEDED. Nothing mutates observed state in an init or body (the attach-time flush defers its model notification to the next turn).
native/scripts/snapshots.sh compare all (no baseline changed)
Mac: docs-editor (compare, 24 images) passed; docs (compare, 22 images) passed
mac half drawn on:
os: macOS 27.0.0
toolchain: Xcode 27.2 Build version 27B52
language: en
accent: #007AFF
locale: en_IE
time zone: Europe/Dublin
increase contrast: off
reduce transparency: off
differentiate without colour: off
docs: baselines drawn on the same
docs-editor: baselines drawn on the same
iPhone: docs-editor (20) + docs-editor-ax3 (4) passed; docs (32) passed
iphone half drawn on:
os: iOS 27.0.0
device: iPhone19,2
runtime: 27.0 (24A434)
toolchain: Xcode 27.2 Build version 27B52
language: en
locale: en_IE
time zone: Europe/Dublin
increase contrast: off
reduce transparency: off
differentiate without colour: off
docs: baselines drawn on the same
docs-editor: baselines drawn on the same
docs-editor-ax3: baselines drawn on the sameHub CI: reply below. Asking for the whole-branch review by the highest-capability model.
Whole-branch review — Claude Fable (model id claude-fable-5-2), read-only, perf/native-s1a at 8cc6668 against main d5a328a
Verdict: APPROVE AFTER FIXES. The design from #157 is implemented as specified, and findings 1–3 below are small but must be fixed before merge. I confirmed each of the three with a throwaway test in my own review worktree (now removed); none of the branch's tests covers them.
I also ran test-iphone.sh there: 14 tests, 0 failures, 1 skipped, including EditorRenderLoopTests 3/3, so the #162 loop stays fixed. I did not re-run the full Mac swift test, the snapshots or the mutation gate; for those I relied on your run and hub CI.
Must fix
- High — a replace across blocks can leave the text view permanently different from the replica.
DocumentSurface.swift:343-354(typed(around:)), with:252and:282-287. - Cause: for an edit that inserts text,typedmarks only the runs holding the inserted characters. The block that lost its head to the same edit is not marked. - Scenario: select from the middle of block a into the middle of block c, and typex(or paste, or cut). If the replica's next projection leaves c unchanged, c is a single in-order run, so it is kept as an anchor. - Confirmed: four paragraphsaaa/bbb/ccc/ddd, select 1…9, typex, republish the same projection. The storage ends asaaa\nbbb\ncc\nddd\n, with bothdirty: []anddirty: nil. - Full compare does not heal it. It compares the cached node with the new node, never the storage, so "unknown" is no safety net for a storage/cache mismatch. - Reachability: the replica has to not reflect an edit the text view already showed. That means a recovery that rolls back tolastGood, or the engine clamping a range the optimistic edit did not. - Consequence: every display offset after c is off by the missing characters, so later edits land in the wrong place, silently, until something touches c. The old path healed this on every new generation with a whole reconcile. - Fix: - Intyped, always mark fromlocation - 1throughNSMaxRange(edited), so the run after the edit is included. - Keep each entry's rendered UTF-16 length, and accept an anchor only whenrun.lengthequals it. Any future mismatch is then redrawn at the next flush. - Add toDeltaSafetyTests: typing, cut and paste over a selection that spans blocks, with the command not taken.
- Medium — a second text view on the same surface is never drawn.
DocumentSurface.swift:129-147(attach),:184-185,:119-125(reset). - Cause:attachrebuilds the index and callsflushIfDeferred, but nothing is "waiting" (the revision is applied andpendingDirtyis empty), so the new view stays empty. The surface also goes on believing its entries are drawn. - Confirmed: publish, thenattacha freshDocsTextView. Its storage is"". - Reachability: any SwiftUI rebuild of the host without aDocsModel.open.updateNSViewalready expects this (surface.textView !== text). Candidates areNavigationSplitViewcollapsing or expanding on iPad, and S2a restructuring the view around the editor. I did not reproduce it in the app. The old per-view coordinator handled this case. - Related:reset()keepstextView. Inopen,showsDocument = trueis followed bysurface.applybefore the new view exists, so a previous view that is still alive would take the first draw and the new one would get nothing. - Fix: whenattachgets a different view, clearentriesandorderand force a whole draw. CleartextViewinreset(). Add a test.
- Medium — observed state is assigned inside
makeNSView/makeUIViewfor any document holding an image.DocumentSurface.swift:146→:228→report(:330-334) → the model'simageSourcesChangedhook, which setsimageSources. - Cause: the first draw always happens inattach, because the text view does not exist earlier. OnlydidRenderis deferred withnotifyLater;report(sources:)is not. - Confirmed: the hook fires synchronously insideattach. - Effect: it is one-shot, so there is no loop, andtestOpeningAListImageAndRuleSettlespasses. But it is the class of mutation the 0.1.7/0.1.8 rule forbids, and the write-up's "nothing mutates observed state in an init or body" is not true for these documents. - Fix: defer the report withdidRenderwhennotifyLateris set. Add a test.
Should fix (can follow, but before S2a merges)
- Medium — S1a exposes nothing observed for "the text changed", and S2a's signal fires too early. - S2a (1e1e53e) adds
historyandcontentRevisionin adidSetonprojection. The merge must keep thatdidSeton the now@ObservationIgnoredproperty. -projectionis assigned beforesurface.apply, and the draw can be deferred (pending input, composition). A reader ofsurface.contentwoken bycontentRevisioncan therefore read the old text and never be woken again. - S2a'sDocsLiveWordCountSheetcallsNativeTextProjection.render(projection). After the merge that is a whole render per publication while the sheet is open. - What S1a should own: - an observedcontentRevision, moved after a flush has changed the storage; - an observedhistory(canUndo/canRedo), set inpublishCurrent.toolbarSelection.canUndois not enough, because it stays stale wheneverDocumentCommands.isEnabledis false, such as a read-only document or pending input. - Then S2a's pill and word count read those andsurface.content.
- Low — Mac menu state may go stale.
DocsEditorCommandsreadseditor?.actions?.isEnabledfrom the focused value. Before, the workspace body ran on every projection or selection change and re-published that value. Now it runs only for the sync status, the title and errors. I did not test this; check Format menu enablement right after open and after a caret-only move, ideally in S2a's menu tests.
- Low — trigger (e) does nothing in production.
canRendernever readsinputPaused, andFlushTriggerTests(e) passes only because the test wrapscanRenderto add it. Trigger (d) is tested throughprojectionGenerationonly, not throughdidRenderadvancing. Either state that (e) is defensive, or makecanRenderconsultinputPaused.
- Low — main-thread copies of the whole text.
storage.stringon anNSTextStoragebridges by copying the whole document. It is used per gap (DocumentRenderReconciliation.swift:27,DocumentSurface.swift:302) and on every selection change (DocumentSurface.swift:404). Usestorage.mutableString.index.positions()andSet(ids)are O(blocks) per flush, which is fine at the measured sizes.
- Low —
isEquivalenthas no production caller left.DocumentRenderReconciliation.swift:52is now used only as the tests' oracle. Say so in its comment or move it to the test target. The iOS loop is now prevented byapplyingand by never assigningattributedTextafter open.
- Low — the line-fragment request counter is not on this branch. The spec lists it among S1's new counters and the write-up defers it to S1b. That is acceptable since pagination is untouched, but the S1b gate must not ship without it.
Checked and found correct
- Dirty set (#157 r2/r3): it returns atomically with the presentation.
sinceissurface.appliedRevision, so a publication the model drops loses nothing. - Stale publications: dropped in
apply. - Unknown entries: every full
projectbranch logs one, including log overflow, and it leads to a full compare. - Provisional blocks: block ranges come from
.docsTopBlockruns, kept current indidProcessEditingand tested against a fresh read. - Gap reconciliation: everything between two anchors is replaced, so nil-id iPhone text, orphaned runs, moved blocks and duplicated ids all resolve.
- Marked text and IME: no flush while text is marked or composing, and no publication while composing. The commit enqueues before
compositionChanged(false). A cancelled composition republishes. - Undo and redo: they go through the engine, and their deltas name the blocks.
- Selection: a new generation takes the replica-resolved selection, and the callbacks are muted by
applying. - Images: the store always reassigns on
load, so a reset surface gets them again. - Render isolation: the host reads only the surface, Pages and zoom, and the counters gate it on both platforms.
DOCS_PROBESin debug builds: fine, since release builds carry none of it.
Fixes for Fable's review, pushed to perf/native-s1a as five commits on 8cc6668. Head is 21ea585, and hub CI passed on it. Not merged.
- HIGH, an edit across blocks (
ad458c5). -typed(around:)now marks from the character before the edit through the one after it. - Each block remembers the length it was drawn at. A block is kept as an anchor only when its run in the storage is that length. - New test,DeltaSafetyTests.testAReplaceAcrossBlocksTheReplicaRefusesIsUndone: it types, cuts and pastes from the middle of aaaa to the middle of cccc, and the replica takes none of it. It failed before: the storage was left at "aa…cc" with "cccc" gone. It passes now. - I did not add a storage-text check to the full-compare path. With the length check, a block whose text no longer matches what was drawn can't be kept. A same-length divergence would need the text view to edit the block, and the marking above covers that. - MED, a second text view (
d156793). - Attaching a different view releases the old one (its delegates and callbacks) and draws the new one whole from the newest publication. - New test,SurfaceLifecycleTests.testASecondTextViewIsDrawnWhole. It failed before (the second view stayed empty) and now also covers a later publication. - Not done as suggested:reset()does not cleartextView. A new draft on iPhone, or a discard, keeps the same host, and nothing rebuilds it to attach again, so clearing it would leave the document undrawn.reset()clears the entries instead, so the next publication is drawn whole. - MED, observed state assigned inside makeNSView/makeUIView (
5800d1a). - The image-source report now goes withdidRender: right after an ordinary flush, and on the next turn after an attach. - New test,SurfaceLifecycleTests.testAttachingTellsTheModelOnlyAfterTheUpdate. It failed before, becauseimageSourceswas reported inside the update. - LOW, trigger (e) (
21ea585). This needs a ruling: I did not make it real, because that would be a behaviour change. - canRender, as spec §7 Design 6 defines it, reads neitherinputPausednorrenderedGeneration. So no production state waits on (e) alone, or on didRender's half of (d). - A writer paused by a refused command still holds that command as pending input, and trigger (b) draws when the queue drains. - A reader is paused for good but must keep seeing peers' changes. If canRender readinputPaused, readers would never see a peer's edit. - The other half of (d),projectionGeneration's didSet, is the one that can unblock, andFlushTriggerTestscovers it through the model. - I kept the calls, which cost nothing, and their comments and the (e) test now say it is a wiring test. - Proposal: drop (e) and didRender from the spec's trigger list, or rule that canRender should change. - LOW, whole-text copies on the main thread (
251e24c). The per-gap reconcile, the text-only check and the selection callback readmutableStringranges now, notstorage.string. There is no failing test for this one: I could not observe a copy deterministically. - LOW (
251e24c).isEquivalent's comment now says it has no production caller and is the tests' oracle. - LOW. The line-fragment request counter is S1b's work (plan S1b item 6).
4/5 (merging with S2a): I'll wait for the coordinator's word that S2a has landed before rebasing.
Gates at 21ea585:
swift test(through check-native): 204 tests, 0 failures, 12 skipped.check-native.sh --mutations: passed, 20 mutations caught.test-iphone.sh: 17 tests, 0 failures. The one skip is the timing probe, which only runs when its documents directory is set.snapshots.sh compare all: green on both platforms with no baseline changed. Mac 24 + 22 images; iPhone 20 + 4 + 32; every set says "baselines drawn on the same".- Hub CI exits 0.
SurfaceLifecycleTests is added to DocsPhoneTests as well. The push token is revoked.
The coordinator's two rulings are applied, at c3728a1. Hub CI passed on it. Not merged.
- Finding 6 (accepted): there are four flush triggers, not five.
6222fd7amends spec §7 Design 6 and the plan to list (a)–(d), where (d) isprojectionGenerationchanging. A new paragraph, "Two events are not triggers", says whyinputPausedbeing cleared anddidRenderare not triggers: - canRender reads neitherinputPausednorrenderedGeneration. - If it readinputPaused, readers, whose input stays paused, would never see a peer's edit. - A paused writer's refused command is still queued as pending input, so trigger (b) draws when the queue drains.
§11 now counts four trigger tests. In c3728a1 the code still calls the flush at both points, since it costs nothing, and the comments there say they are not triggers. The (e) test is removed: it only passed by wrapping canRender. FlushTriggerTests now covers exactly (a)–(d).
- Finding 2:
reset()keeps the text view (accepted). Spec §7 Design 3 now says attaching a different text view draws it whole, and thatreset()keeps the attached view, because a new draft or a discard keeps the same host. A table at the end of the spec maps both amendments.
Gates at c3728a1:
swift test: 203 tests, 0 failures, 12 skipped.test-iphone.sh: 16 tests, 0 failures. The one skip is the timing probe, which only runs when its documents directory is set.- Hub CI exits 0.
- Only comments and tests changed in the native code, so the snapshot result from
21ea585stands: green, with no baseline changed.
The S2a rebase is on hold until S2a lands.
Rebased onto main 2704697 (S2a landed, #169) and force-pushed. Head is e7c15d6; hub CI passed on it. Not merged. Fable, this is the merge to re-check.
How the merge resolves findings 4 and 5
- History.
DocsModel.projectionstays@ObservationIgnored. ItsdidSetsets S2a's observedhistory, only when the value differs. The projection is assigned inpublishCurrent, so history is set with each publication, whatever the access and whether or not input is pending. - The undo/redo pill, Tools ▸ Word count's enabled state, the iPhone toolbar's undo and redo (this wastoolbarSelection.canUndo, which went stale for readers and while input was pending),canActionandDocsEditorContext.actionsall readhistory. -showsDocumentis nowhistory.loaded. - Content revision.
contentRevisionis observed and moves after each draw into the text view: the surface'sdidRenderhook. After an attach, that hook runs on the next turn, never inside SwiftUI's update. - Live word count.
DocsLiveWordCountSheet, which the iPhone's Tools now uses too, counts from the projection's text and the text view's own storage. It does no render, so a publication costs only the count's walk of the projection. - Format inspector.
DocsFormatInspector(model:)has nocontent:parameter any more. It reads the model's one observedtoolbarSelectionand acts on the live storage. Its side is an input ofDocumentEditorHost(surface:paged:zoom:inspector:), andNativeDocumentTextViewputs the page on S2a'sDocsDeskView. - Jump. ⌘K from the text view's keys raises
model.jumpRequests, and the window shows S2a's jump sheet (spec §1). S1a's open-home is gone. - Kept from S2a as they are: - the workspace's
team:parameter, now withconnectivity:after it; - the model'sunavailable,inputBlocked,documentAccess,refreshAccess, the retry guard and the stream-reopen hook; -DocsToolsControls' sheets. - Two S1a adjustments: -
sessionPausedis a guarded property that pushes editability to the surface, and editability iscan_write && !inputBlocked. -EditorSnapshots'EditorPagekeeps S2a'sinspector:parameter, passed through the host.
Tests
- New:
SurfaceChromeTests(Mac). - The Format menu's enablement (DocumentCommands.isEnabled, whichDocsEditorCommandsdisables from) follows a key and the queue draining, through observation. - History is current at a publication that arrives while input is pending, and for a reader. - The live count re-evaluates after a draw with no whole render. - The last two failed with the history's update, or the count's no-render, removed. - S2a's
DocsHistoryObservationTestspass: the pill, Word count's enabled state, and the sheet after an edit. The sheet case now attaches a text view first, as the editor does whenever the sheet can be open, because the count reads that view's storage.
Gates at e7c15d6
check-native.sh --mutations: passed. That includesswift test, 232 tests, 0 failures, 12 skipped; 20 mutations caught.test-iphone.sh: 16 tests, 0 failures. The one skip is the timing probe, which only runs when its documents directory is set.snapshots.sh compare all: green. Mac docs (22), docs-editor (24, including the 150% screens S2a re-recorded) and docs-window (22); iPhone 20 + 4 + 32. Every set says "baselines drawn on the same", and no baseline changed.- The release Mac build (
build-mac.sh) succeeds. test-document-window.pypasses in both modes, ordinary andDOCS_SMOKE_DRAFT=1: the document loads, the Format inspector toggles, the window resizes, the editor and selection persist, the caret geometry holds through Enter and typing, and the account menus work.- Hub CI exits 0.
Final review of S1a on S2a (git diff 2704697 e7c15d6) — Claude Fable (claude-fable-5-2). Verdict: APPROVE AFTER FIXES. One medium regression from the merge (finding 1), a small fix. Everything else holds.
Findings
- Medium — the toolbar and Format inspector keep their old state after typing.
DocsModel.swift:477-487(didRender),:444-451(drainEdits' defer),:833-837(refreshToolbarSelection). - Cause:refreshToolbarSelectionkeeps the old value while input is pending. After a key it runs three times, all too early: on the selection change (pending), aftersurface.apply(still pending, becauseeditingTaskis set until the drain returns), and indidRender. Plain typing reuses the generation, sodidRender'sguard generation > renderedGenerationreturns before the refresh. Nothing refreshes once the queue has drained. - Confirmed with a throwaway test on the model (LoopFixture.everything, real text view), waiting for the queue to drain plus 50 ms: - Caret at the end of the heading, Enter:toolbarSelection.stylestaysheading1; a freshDocumentToolbarSelectionsaysparagraph. Generation 1 before and after. - Select three characters, type over them:hasSelectionstaystrue(fresh:false), so Clear formatting stays enabled. - 401 pause, caret moved into the heading, 200: storedparagraph, freshheading1. - Effect: the Mac inspector (open by default) and the iPhone toolbar show Heading 1 for a body paragraph after Enter, until the caret is moved by hand or a new generation is drawn. Commands still act on the live text, so nothing is damaged. On main the toolbar body recomputed when the queue drained; this is new with the single observed value. - Fix: refresh whereverDocumentCommands.isEnabledcan turn true: indrainEdits' defer after the flush, beforedidRender's guard (or in the hook), when composition ends, and in theinputPaused/sessionPaused/detailsetters. Add aSurfaceChromeTestscase: Enter at the end of a heading, then stored equals fresh.
- Low — the report deferred from
attachis not tied to the document.DocumentSurface.swift:238-240. - Confirmed:apply(generation 7),attach,reset()in the same turn;didRender(7)still arrives afterwards. - Effect: in the model that would setrenderedGenerationto the old document's generation after an open reset it to 0. The new document's lower generations then never passdidRender's guard, andisEnabledstays false. It needs a reset between an attach and the next main-actor turn, which I could not produce through the app. - Fix: in the task, skip unlessself.generation == rendered.
- Low —
attachforgets the old drawing only while the old view is alive.DocumentSurface.swift:130-138. -textViewis weak. If the old view is already gone when a rebuilt host attaches (and noresetcame between), the entries stay, nothing is waiting, and the new view is blank until the next publication. - Not reproduced: I could not get the first view released inside a test, and every app path I traced resets before it publishes again. - Fix: testtextView !== textinstead ofif let old, releasing the old view only if there is one.
- Note, not from this diff: a reader who is given write access again shows writable chrome but the text view stays read-only (
refreshAccesssetsinputPausedfor a reader and nothing clears it). Same on main.
Checked and found correct
- My findings 1–3 from 8cc6668: fixed. The cross-block replace (type, cut, paste, refusing replica), the second text view and the deferred report each have a test that passes here; mutated-length anchors are redrawn.
- History: set in
projection'sdidSet, so it is current at a publication with input pending and for a reader. The pill, the iPhone undo/redo,canPerformand Tools ▸ Word count read it. contentRevision: moves only in thedidRenderhook; after an attach that is the next turn.- Word count: counts from the projection and the live storage, no render.
- Mac menus in the real window (the smoke harness with a temporary probe): after focus and a selection with no typing, Bold, Italic and Word count are enabled and Undo is disabled; after one key, Undo is enabled. My old finding 5 does not occur.
- Inspector side, Jump sheet,
sessionPaused→ editability: wired as described. The 401 probe showsisEditablefalse then true. - 0.1.7/0.1.8 rule: I found no observed assignment in an init, a body, or
make/updateof the representable. The model's init only writes with no observer yet.
Gates I ran, in a review-only worktree at e7c15d6 (removed afterwards)
swift test: 232 tests, 0 failures, 12 skipped.test-iphone.sh: 16 tests, 0 failures, 1 skipped. The iOS loop stays fixed.- I did not run the snapshots, the mutation gate or the release build.
Shipping as Docs 0.1.12
Safe once finding 1 is fixed: no hang, loss or divergence risk found. I would not ship without it, since the default-open inspector shows the wrong style after an ordinary Enter. Findings 2 and 3 are a few lines each and can go in the same commit or follow.
Fixes for Fable's final check, pushed as four commits on e7c15d6. Head is 57ff648; hub CI passed on it. Not merged. Each commit carries a test that failed before its fix.
- MED,
5cde93f: the toolbar and inspector now follow the text once input settles.refreshToolbarSelectionnow runs whereverDocumentCommands.isEnabledcan turn true: - when the queue drains; - on every draw, beforedidRender's guard (plain typing reuses its generation); - when composition ends; - in thedetail,inputPausedandsessionPausedsetters.
New SurfaceChromeTests cases, one per repro. Each compares the toolbar's state with one computed afresh from the live text, and all three failed before: - Return at the end of a heading: the style is now the new paragraph's. - Typing over a selection: hasSelection is false, so Clear formatting is disabled. - The caret moved into a heading during a 401 pause: after the 200, the style is Heading 1.
- LOW,
e30fa0c: the report attach defers belongs to its document. On the next turn it runs only if the surface has not been reset in between and still shows that generation. Test:SurfaceLifecycleTests.testADeferredReportIsDroppedAfterAReset, which resets in the same turn as the attach. - LOW,
b3165fa: a new text view is drawn whole when the old one is gone. attach comparestextView !== text, so it no longer depends on the weakly held old view still being alive. Test:SurfaceLifecycleTests.testANewTextViewIsDrawnWholeWhenTheOldOneIsGone, which waits for the first view to be released before attaching the second. - Note 4,
57ff648: a reader given write access again can type. This bug was on main before S1a too. The fix is small, so I took it. - A read-only answer torefreshAccessnow records its pause as its own (pausedAsReader), and a later writable answer lifts that pause only. - A refused command, a failed save, a full outbox, or a document no longer available each keep their own pause. - The flag is cleared on open and discard. - Test:SurfaceChromeTests.testAReaderGivenWriteAccessAgainCanType. It failed before: input stayed blocked and the text view was not editable.
Gates at 57ff648:
check-native.sh --mutations: passed. That includesswift test, 238 tests, 0 failures, 12 skipped; 20 mutations caught.test-iphone.sh: 18 tests, 0 failures. The one skip is the timing probe, which only runs when its documents directory is set.snapshots.sh compare all: green. Mac docs (22), docs-editor (24) and docs-window (22); iPhone 20 + 4 + 32. Every set says "baselines drawn on the same", and no baseline changed.- Hub CI exits 0.
Landed on main (squash) after Fable's final fixes (all with tests) and green hub CI at 57ff648. Next: Docs native 0.1.12 to Mac + TestFlight.
Docs 0.1.12 (14) released to Mac (Sparkle) and TestFlight from main 93230c0 (2026-11-24). It ships the Mac document window (S2a, #169) and per-block drawing (S1a, #170). It is native only, so there was no server deploy.
Tests on the release commit, after build-crdt.sh:
swift test --package-path native/apple: 238 tests, 0 failures, 12 skipped.native/scripts/test-iphone.sh(iPhone 18 Pro, iOS 27.0 24A434): TEST SUCCEEDED. 18 tests, 0 failures. The one skip isSurfaceTimingTests.testOneBlockPublication, which needsDOCS_RT_AUDIT_DOCS. BlockIndex, BlockRenderEquivalence, DeltaSafety (3), EditorRenderLoop (3), FlushTrigger (4), RenderIsolation and SurfaceLifecycle (4) all passed.snapshots.sh compare all: green. Mac docs (22), docs-editor (24) and docs-window (22); iPhone docs-editor 20 + AX3 4 and docs 32. Every set says "baselines drawn on the same" (macOS 27.0.0, Xcode 27.2 27B52, runtime 27.0 24A434).test-document-window.py: all three PASS lines, in the letter mode and inDOCS_SMOKE_DRAFT=1(4 PASS lines). This script builds its own debug harness on the release commit's DocsKit; it cannot drive the signed app.
Mac 0.1.12 (14), Sparkle. Notarised (id 821de4d5-96b5-4e39-a53a-c0ca16de9a8f).
- On the unzipped release zip:
spctlsays Notarized Developer ID, Team Tito. Stapler validates it. - Entitlements are unchanged from 13: keychain groups .docs then .id, App Group 9U4A84C4WK.works.oficina, webcredentials:id.oficina.works. embedded.provisionprofile is there.
DocsMac --oficina-id-launch-checkreported every line ok and exited 0.- Published to native-releases as release docs-14, feed commit 2278d5b6de8b74a2fe9b458fa332decda75a92f3. The public appcast lists 0.1.12 (14) first.
- zip sha256 bf723a8d4b4142d0dab921c196d44d2b4a369a7b0baf8264b1116793c7e42485 (15032512 bytes). An anonymous download gives the same hash and length.
iPhone 0.1.12 (14), TestFlight.
- Archived with Apple Distribution and the "Oficina docs iOS App Store 2026-11-14" profile.
- The archive holds only DocsPhone.app, with no PlugIns, Frameworks or xctest, so DocsPhoneTests is not in it.
- Info.plist has 0.1.12 / 14 and ITSAppUsesNonExemptEncryption=false.
- Uploaded with delivery fa6e770b-ebf9-4180-a79e-af2fd84c2a88. It was VALID after about 2.5 minutes, with usesNonExemptEncryption=false already set.
- internalBuildState is INBETATESTING. The "Oficina internal" group has access to all builds.
Deviation: oficina-distribution.keychain-db no longer unlocks with the stored password, as Equipo's TestFlight helper found on 11-23. The same Apple Distribution identity, 07E99055…, is in the login keychain, so I signed from there. The keychain search list was never changed.
Small follow-up: native/smoke/document-window/Package.resolved pins rastrillo/native at 529f356, but apple/Package.swift pins 0254817. SwiftPM re-resolves it on every smoke run, so the smoke test did run on the release pin. The committed file is just stale.
Next: Paul tries the new Mac document window and typing on iPhone build 14.