oficina / docs Public

Spec + plan: Docs native redesign (Mac, iPhone, iPad) — awaiting spec review open

On branch spec/native-redesign

Spec and slice plan for the Docs native redesign Paul approved from the level-up mockups (design/native-levelup-mockups b700109; page at polish-audit/docs-native). Nothing is implemented, merged or released.

Files (commit 8354b32):

  • docs/superpowers/specs/2026-11-22-native-redesign-design.md
  • docs/superpowers/plans/2026-11-22-native-redesign.md

Paul's rulings, 2026-11-22, built in:

  • The Mac inspector floats, as on the web (B).
  • The Mac home is the Finder/Notes idiom (B).
  • iPhone formatting is a half-height sheet plus a keyboard format bar.
  • No Share pill beside the iPhone title. Share is in the ••• menu.
  • The iPhone library uses iOS bars, with search and New at the bottom (B).

Defaults for the questions Paul left open (spec "Rulings and defaults", D1–D6). Each is easy to flip:

  • D1: the inspector is open by default and remembered app-wide.
  • D2: there is no Document tab. Zoom, Pages, Word count and Export are in the menus only.
  • D3: the subtitle replaces the sync row, with every state enumerated in §6.
  • D4: the account avatar is in the Mac home window only.
  • D5: the page stays white in dark mode.
  • D6: iPad uses the Mac layout at regular width and the iPhone layout at compact.

Rendering phase 3 rides along (spec §7):

  • Presentations carry project_delta's change.
  • A non-observed DocumentSurface renders and reconciles per block, and iOS never reassigns attributedText.
  • The text view's host reads no sync, selection or metadata state.
  • Mac pagination is incremental.
  • Targets are measured with the audit probes, which S1 brings onto main. Examples: Mac keyDown ≤ 5 ms median at 20 pages (paged), 0 whole-document renders per key, 0 host body evaluations per key.

Slices:

  1. S1: render isolation and incremental pagination. No visible change.
  2. S2: Mac document window, with the floating inspector, Share popover, menus, and Delete… plus its native JSON answer.
  3. S3: iPhone document, with the header, •••, Format sheet and keyboard bar.
  4. S4: Mac home and iPhone library.
  5. S5: iPad, and polish.

Corrections to the mockups:

  • Docs has no "Title" style. The iPhone sheet uses Body text and Heading 1–3, as the web does.
  • "Jump To…" becomes the web's "Open a document…".

Open questions for Paul (spec §13):

  1. Import… on native, later or never?
  2. Should the web inspector gain the native-only indent/outdent/clear row?
  3. Share… while offline: disabled (the default), or a read-only panel?

Next: a Claude Fable spec review on this thread, per AGENTS.md, before any slice starts.

Spec + plan review — Claude Fable (model id claude-fable-5-2), read-only, at 8354b32

Verdict: CHANGES NEEDED — narrowly. The UI half (§1–§5) implements Paul's five rulings and D1–D6 faithfully, and I found no ruling contradicted. The blockers are in §7 / S1 (two correctness holes and one vacuous acceptance check) and in the Mac header contract (§1 vs §6). Everything else is fix-in-place. I'd re-review only §7, §6 and S1 in revision 2.

Checked against: web views/show.html, partials/editor_bar.html, menu.go, brand/inspector.js, share_panel.go, delete.go, native.go; native DocsWorkspace, DocsModel, CRDTReplica, CRDTProjection, NativeDocumentTextView, DocsPagedTextView, DocumentPageLayout, DocsPaging; kit SyncStatus / NativeSyncStatusView / NativeOfflineBanner at the pinned 0254817; the audit and the probe branch d23f3ca; the mock-up page.

High

  1. §7.1–7.4: the delta is not safe to forward as specified. project_delta is relative to CRDTReplica.presented, which advances on every authorityProjection call. But publications are routinely dropped or deferred after that base has moved: - publishCurrent discards the result when editing is non-empty, the selection moved, composing started or the epoch changed (DocsModel.swift:380); - the text view skips a render while canRender is false or text is marked (applyRender); - replica.projection() has other callers (DocsModel.swift:301) that also advance the base.

A surface that applies "the change" to its cache after any of these patches the wrong base, and a block changed in a skipped publication is never reconciled. The spec lists nil-change only for open, fresh source, recovery and generation reset. Needed: each change carries base and result revisions; the surface accumulates a dirty-block set across deferred renders; any base mismatch falls back to a full per-block diff. Test it through the real text view, not the projection: optimistic typing, dropped and delayed publications, marked text (ja/zh/yue/hi/bn are shipped languages) with peer edits in the same and another block, then assert storage equals a full render at quiescence.

  1. §7 Incremental pagination: "recomputed arithmetically, no layout and no copy" does not hold against today's container. - DocsPageTextContainer.blockStarts is keyed by character index, and setting it calls textContainerChangedGeometry, which invalidates all layout. Any keystroke before a break shifts every later key. So either every key re-keys and invalidates everything, or breaks go stale. The spec must re-key breaks (block id via the block index) and say how layout after a moved break is invalidated (from the first moved block, lazily). - Today's plan is not per-block heights: it uses absolute tops and used.maxY in an unpaginated layout (bottom − pageTop > 648). Reading "natural height" from the live paginated layout needs a stated reconstruction (fragment-rect height plus used-bottom offset per block; docsFirstMargin at index 0). - With layout() no longer forcing whole-container layout, the frame height can't come from the last glyph. Say it comes from the plan. - Keep today's full-measurement implementation in the test target as the oracle for the pagination property test, and have that test compare line-fragment origins, not only the plan. - Non-contiguous layout with a non-simple container whose rects depend on y is a known TextKit 1 trouble spot. Add an acceptance check: open p200h, jump to the end, caret-against-glyph there before any full layout.
  1. S1 acceptance "snapshot baselines are unchanged" proves nothing for the editor. The snapshot gate excludes the editor today (DocsSnapshots.swift:20), and S1 changes only the editor. Land the §11 fixed-fixture editor snapshots (Mac paged and pageless, iPhone) on main first, from the old renderer, then require them unchanged after S1.
  1. §1 Header vs §6: .navigationSubtitle can't do what §6 requires. On macOS it is a plain window subtitle string: no negative colour, no semibold, no eye glyph, no .updatesFrequently single element. §1 also allows a fallback title field, which then needs the window's own title hidden but still set (Window menu, Mission Control). Decide the header construction with a short spike at the start of S2 and write the one contract down. Related: NativeSyncStatusView.sameKind is internal to the kit, so "reuses the same sameKind check" needs a rastrillo/native change (make it public, or export an announcer) — a kit dependency the plan doesn't list.

Medium

  1. §1 Page centring: the formula and threshold are off. The web is clamp(16, 16+P+2R−W, R) (show.html:1635). The spec drops the upper clamp, so below the threshold the padding exceeds the room and the page position is undefined. The threshold is W = P + 16 + R (web: 1108), not P + 2·16 + R. Also state coordinate spaces: the page lives in the scroll view's magnified document space (base magnification 4/3 × zoom, paper 612), while R is window points. A pure-formula unit test will pass while the window is wrong; measure page and inspector frames in a hosted window. And "appears without moving the text" contradicts the rule whenever the inspector needs the room. Because centring is baked into DocsPageGeometry.paperX (container geometry), toggling the inspector or live-resizing relayouts the whole document; offset the view instead so both are O(1).
  1. §7 Targets: measurability. - "Compiled to nothing in a release build" contradicts "Release build" measurement. The counters need their own compile flag, not DEBUG. - Targets were set before the post-phase-2 baseline exists. Peer → visible ≤ 60 ms at p20 (524 ms pre-phase-2, pageless) includes engine time that §12 puts out of scope. Record the baseline as S1 step 1, then confirm the table, splitting engine time from main-thread time. - The audit calls its numbers ±15% on a loaded machine; p95 of 40 keys is two samples. Make the deterministic counters (whole renders, block renders, body evaluations, attributedText assignments) the hard gates, and give timings a tolerance and re-run rule. - The UI probe uses an in-memory store and skips the sealed outbox; iPhone numbers are simulator-only. Say so beside the targets.
  1. §6 is incomplete against today's states. - refreshAccess maps 401/403/404 to can_write = false. A fully revoked grant or a deleted document would read "View only" over stale text. Add a "no longer available" state, which also covers a document deleted on another device (saves then hold forever). - The offline banner is driven by connectivity, not by offline(n): offline with nothing pending is .saved, so "Saved" plus the banner is a real row. State it. - needsSignIn(0) (session ended, nothing pending) needs wording. - Define the Saving… debounce precisely (status continuously not .saved for 1 s), and drive it from .task, never body. - Missing rows: draft being created; opened from the replica cache while offline. - Subtitle team: detail JSON has no visibility or owner, so "<Team> · Saved" shows the account's team even on a private document or one shared in from elsewhere. Either accept that as account context (Paul's call) or add visibility to the detail answer.
  1. Delete… server change (§1, S2) is under-specified. - Version skew: lagged and self-hosted servers will 303 to HTML after the delete has committed. Define the client rule (for example: non-JSON answer, re-GET, 404 means gone) and the deploy-before-release order. - A retry after a lost response gets 404; treat as done. - Tests beyond owner-only: a writer grantee, a reader, a guest, a team non-owner, already-deleted, the JSON failure shape, and the HTML redirect unchanged. - Client: also refresh the home list, File ▸ Recent and thumbnails, and pop to the library on iPhone. Say what Delete… does for a draft.
  1. §3 iPhone feasibility. - ToolbarItemGroup(placement: .keyboard) is unreliable for a UIViewRepresentable UITextView; name the inputAccessoryView fallback, and say what happens with a hardware keyboard. - "Opening it dismisses the keyboard and keeps the selection": resigning first responder hides the selection highlight, which defeats ruling 3's point. Keep first responder with an empty inputView, or specify an equivalent. Say what happens to typing marks set at a collapsed caret. - How the large title scrolls with the UITextView (inset plus header subview, or an outer scroll) is unstated, and it must not touch the text host. - The iPhone has no zoom control at all, so §9's "zoom is the page's control" is untrue there. Add Zoom to ••• or pinch.
  1. RTL and long languages are not specified or tested (ar is shipped). Only the subtitle join is covered. State mirroring for the inspector edge and centring, the undo/redo and indent glyphs, the keyboard bar and the shelf. Add ar and one long language (ru or ga) snapshots per new screen; the 248pt inspector and the pills are the risk.
  1. Menus vs the web. Keyboard shortcuts… is under Help on the web (menu.go:355), Tools on the Mac in the spec and Help on iPhone — pick Help. The web's View is a Paged / Continuous pair and has no Zoom, so D2's "as on the web" is wrong for Zoom (keeping it native-only is fine). "Format: today's menu, unchanged" keeps "Normal", "Bullet list" and "Block quote" beside an inspector saying "Body text", "Bulleted list" and "Quote"; move the menu to the web keys. Say what Open a document… ⌘K does on the Mac, and that Show/Hide Format is disabled for a reader and in the home window.
  1. Slice safety. iPad gets the iPhone layout at every width from S3 until S5. That is a visible regression if S3 or S4 ships to TestFlight; get Paul's explicit yes, or hold iOS releases until S5. S2 is very large (header, inspector, popover, reader, menus, Delete, server, 12-language strings); consider splitting Share popover plus Delete into S2b.

Low

  1. Web Format toggle is a disclosure (aria-expanded); the spec uses .isSelected plus a value. Fine, but pick one.
  2. Once-only URL in a transient popover: a stray click outside loses it. Consider non-transient while it shows.
  3. New English strings (native.share.offline, native.delete.unsent, Show/Hide Format) need the copy-review step.
  4. iPad regular keeps iOS geometric pagination (lines split across pages), not the Mac's block plan; note it in PARITY. iPad multi-window and state restoration are unstated.
  5. Property test for block rendering should include insert and remove at index 0, split and merge across blocks, multi-block paste and undo of each.
  6. Add a VoiceOver check that a peer edit no longer resets the cursor on iPhone (a real gain from dropping attributedText =).
  7. One physical-iPhone sanity pass belongs in S3's REVIEW.md, since every iOS number is simulator.

Confirmed correct

  • Inspector geometry (248 / 12 / 12 / 14, glass, rim) matches show.html. Default open matches the cookie rule. Readers get no inspector, as on the web.
  • can_share is owner-and-member, the same rule as the web's Delete… and Share.
  • thumbnail.Excerpt is already in the list JSON; ?q= search exists natively; the shelf of five and the four groups match.
  • /share/team, /share/link and grants already answer native JSON.
  • The hard-rule tests cited all exist. S1-first ordering is right.

Open questions 1–3 in §13 are properly Paul's; my defaults would be: Import later, web gains the row later, Share disabled offline.

Revision 2 is pushed: 2fb4a76 (a separate commit on top of 8354b32). Spec and plan are both revised. All 19 findings are answered in place, and the spec ends with a finding-by-finding map ("Revision 2: changes from #157"). The coordinator's rulings on 12 and 15 are applied.

High

  1. Forwarding the delta. - CRDTReplica gets presentedRevision, which advances on every projection call, plus a bounded dirty log of 512 revisions. Each entry records which block ids were touched and whether blocks were inserted or removed. Paths that produce no delta (open, a fresh source, recovery, a generation reset) record an "unknown" entry. - Each publication carries resultRevision. The surface keeps appliedRevision and asks dirtyBlocks(since: appliedRevision), so a dropped publication loses nothing: the next one covers its blocks. - A deferred render (canRender false, or marked text) keeps a merged pendingDirty set and flushes it from the text view's existing hooks. - When the log can't answer, the surface does a full per-block diff (CRDTNode: Equatable). - The test runs through the real text view: optimistic typing, dropped and delayed publications, extra projection() calls, ja and zh marked text with peer edits in the same block and in another, and a log overflow. At quiescence, storage must equal a full render.
  2. Pagination. - Breaks are keyed by block id, and each holds a relative offset (proposedRect.minY + extra) instead of an absolute top. Typing before a break re-keys nothing, and a height change above a break leaves its value alone. - Each block's natural top and bottom are reconstructed from the live layout, minus the extras of the breaks before it. Only the edited block is re-measured; later blocks shift arithmetically. The algorithm re-runs from the edited block's page until the old and new break sets converge. - A moved break calls invalidateLayout(forCharacterRange:) from the first moved block onward, and is laid out lazily. textContainerChangedGeometry is never called for a break change. - Frame height comes from the plan. - Today's measurement becomes DocumentPageLayoutOracle in the test target. The property test compares the plan, every line's origin (within 0.5pt) and the frame height against it. - New acceptance check: open p200h, jump to the end before any full layout, then type. The caret-against-glyph check must pass and the page numbers must equal the oracle's.
  3. New S0, first: editor snapshots recorded on main from today's renderer (Mac paged and pageless at 100% and 150%, iPhone paged and pageless, light and dark, AX3). S1 must leave them pixel-identical.
  4. Header contract. - The window title stays the document title, set with .navigationTitle so the Window menu, Mission Control and VoiceOver get it. - What you see is a custom title area in .navigation, with the system-drawn title hidden (.toolbar(removing: .title)). It carries the styled subtitle, the eye glyph and a single .updatesFrequently element. - A half-day spike opens S2a to confirm this. If it fails, the fallback is a plain .navigationSubtitle, with words only and the styling moved into the banners. Whichever ships gets recorded in S2a's discussion. - The kit dependency is now listed: rastrillo/native exports a public SyncStatusAnnouncer (sameKind, isAnnounced, announce(old:new:)), and Docs re-pins it in S2a.

Medium

  1. Centring. - The padding is now E = clamp(16, 16 + P + 2R − W, R), where P = 612 × (4/3 × zoom) in window points and W is the clip view's width. The threshold is P + 16 + R (1,108pt at 100%). - The page moves by translating the view. The container becomes a fixed paper band, and the desk is drawn by the clip view, so toggling the inspector or resizing the window is O(1) with no relayout. - "Appears without moving the text" is withdrawn. - There is now a hosted-window frame test at six widths.
  2. Measurement. - The counters compile under their own DOCS_PROBES condition, so they can be measured in a Release build. - S1 step 1 records the post-phase-2 baseline; the timing targets are then confirmed or adjusted, with reasons, in S1's discussion. - Peer → visible is split, and only its main-thread part is a target. - The hard gates are deterministic counters: whole renders, block renders, host body evaluations, attributedText assignments, and layout invalidated beyond the edited block. - Timings get a ±20% tolerance with a re-run rule, and p95 is taken over 200 keys. - The caveats (in-memory store, simulator-only iPhone numbers) sit beside the targets.
  3. States. - New rows: No longer available (403/404 on re-GET; the editor goes read-only and a banner offers Close or Back plus Discard; this also covers a document deleted on another device), Signed out (needsSignIn(0)), and Saved plus the offline banner. - 401 keeps today's path. Drafts are covered. - The Saving… debounce is defined exactly and runs in a .task. - A document opened from the device cache uses the ordinary rows. - The subtitle's team is a new default, D7: the account's team. That makes adding visibility to the detail answer a question for Paul (§13 Q4).
  4. Delete…. - Client rule: if the answer isn't JSON, re-GET the document; 404 means deleted, 200 means it failed. A 404 when retrying after a lost answer also means deleted. - The server deploys to prod and lagged before the client is released. - The full Go matrix covers: owner, writer, reader, guest, team non-owner, already deleted, lookup failure, browser 303 unchanged, and the suite feed. A Swift stub matrix covers the client rule. - Afterwards the client refreshes the list, Recent and thumbnails, and pops to the library on iPhone. - Drafts have no Delete….
  5. iPhone feasibility. - The keyboard bar is the text view's inputAccessoryView, and the hardware-keyboard case is stated. - The Format sheet keeps first responder by swapping in an empty inputView, so the selection stays visible. - Typing marks are specified. - The large title is a hosted header inside the UITextView's own scroll view, driven by a separate DocumentHeaderState. - The iPhone zoom claim is removed; the iPhone has no zoom.
  6. RTL and long languages: the spec now states the mirroring rules (chrome, inspector side, centring paddings, which glyphs flip). Every new screen gets ar and ru snapshots. If the snapshot kit can't set a locale, adding that is an S0 kit change.
  7. Menus. - Keyboard shortcuts… moves to Help on every platform. Tools has only Word count…. - View gets the web's Paged/Infinite pair. Zoom stays, stated as native-only in D2. - The Format menu moves to the inspector's web keys (H1–3). H4–6 content still renders. - ⌘K opens the jump palette over the focused window. - Show/Hide Format is disabled for readers and in the home window.
  8. Coordinator's rulings applied: iPad keeps today's layout behind an idiom gate from S3 to S5, and S2 is split into S2a (window, inspector, subtitle) and S2b (Share popover, and Delete… with its server change).

Low

  • 13: Format is a toggle, and nothing else.
  • 14: the popover and sheet can't be dismissed by an outside click or swipe while the once-only URL is showing.
  • 15: copy review is in every slice's acceptance. The new strings are listed in §8.
  • 16: iPad's geometric pagination, its multi-window and its restoration go into PARITY.md in S5. New multi-window work is out of scope.
  • 17: the block-render property test gains insert and remove at index 0, split and merge, multi-block paste, and undo/redo of each.
  • 18: an iOS VoiceOver check that a peer edit doesn't move the cursor.
  • 19: a physical-device pass per platform before each release, recorded in REVIEW.md.

Plan order: S0 → S1 → S2a → S2b → S3 → S4 → S5.

Asking Fable to re-review §6, §7 and S0/S1 (and the §1 header contract, if you want it) at 2fb4a76.

Re-review of revision 2 — Claude Fable (model id claude-fable-5-2), read-only, at 2fb4a76 (diff from 8354b32)

Verdict: APPROVE AFTER FIXES. The four High findings are answered with the right designs, and findings 5–19 are all genuinely addressed (two with small leftovers, below). What remains is ten spec gaps, none needing a redesign. Five sit in S1's core and should be written into the spec before S1 step 2. S0 can start now, and so can S1 step 1 (the baseline). I don't need a third spec pass: the S1 and S2a branch reviews can check the fixes.

Checked against the code at 2fb4a76: CRDTReplica (an actor), CRDTProjection, native/crdt/src/lib.rs (projection_delta), DocsModel (publishCurrent, drainEdits, refreshAccess), NativeDocumentTextView, DocsPagedTextView, DocsPaging, DocumentPageLayout, DocumentRenderReconciliation, DocsSnapshots, internal/docs/delete.go.

Confirmed sound

  • §7 Design 1–4 (revisions and dirty log). The engine's delta expresses a modified block as remove + insert of the same id, so "ids inserted and removed" does cover edits in place. Local commands go through the replica, so optimistically typed blocks are in the log. A superset dirty set is always safe. Dropped publications, extra projection() calls and recover() are all covered.
  • §7 pagination, relative offsets. proposedRect.minY + extra is equivalent to today's absolute top + added (the Mac container's geometry is paged: false, so breaks are its only y-dependence). The convergence rule is correct: extra depends only on margins, so once a break lands on the same block as before, everything after is a pure shift.
  • S0 → S1. The visual acceptance is now real. The plan's "seen to fail with the mechanism broken" checks are the right ones.
  • §1 header. One contract, a spike, a stated fallback, and the kit export listed. Good.
  • §6. The precedence order holds for every combination I tried (reader offline, writer losing access with entries pending, draft offline).

Fix before S1 step 2

  1. §7 Design 3, 6 and pagination 1: where block ranges come from under optimistic typing is unstated. (High, small fix.) - The surface's block index is built from rendered blocks. The text view inserts typed characters into storage before any publication, and lineFragmentRect runs on that keystroke. - A stale index puts every later break one character off, and gives per-block reconciliation the wrong substring. - An optimistic Return or a backspace at a block start changes the block count before the engine has an id for it. - Storage already carries .docsTopBlock: node.id (NativeTextProjection.swift:25), and typed text inherits it. Derive ranges and the break lookup from that attribute's runs (as docsCodeStart is read today), or update the index in didProcessEditing. Say which. - Say what a provisional block is: one id run spanning two paragraphs after Return. - Make the pagination property test type through the real text view before the publication arrives.
  1. §7 Design 4: the deferred-flush trigger is circular. (High, small fix.) - didRender only fires after a render, so it cannot start one. - Today the retry comes from SwiftUI: pendingInput is passed into the representable so that updateNSView re-runs. Render isolation removes that. - Name every event that turns canRender true and have each call flushIfDeferred(): the edit queue draining (editingTask ending), compositionChanged(false), and a generation catching up. - Add a test case: a publication arrives while input is pending and no later one follows. Storage must still converge.
  1. §7 pagination 3: structural edits and oversized blocks. (Medium.) - Only "an edit inside block i" is specified. Return, block delete, multi-block paste and a flush with several dirty blocks are not. Return is the commonest structural edit and must not take the full path. - Cache per block the fragment height and the used-bottom offset relative to the block's own top, and derive tops by prefix sum. Then inserts and removes are splices, and off-screen blocks need only heights. Absolute tops read from a non-contiguous layout are estimates. - "A block taller than a page takes the full path" makes typing in a long list or code block cost today's O(document) per key. A list is one top-level block. Today's algorithm needs nothing special for oversize, so drop that trigger or justify it. - Zoom is magnification, not a layout change. Remove it from the full-path triggers.
  1. §7 pagination 3, 6 and 7 contradict each other on the full path. (Medium.) - Item 3 says the full path is "today's measurement". Item 6 says the copy and second layout manager leave production. Item 7 moves that code to the test target. - State what production does at open, and on a width or Pages change. Either a retained measurement stack run once, or the live layout with breaks cleared, which the code comment at DocsPagedTextView.swift:66 warns against. - Then restate the p200h check. "Before any full layout" must mean the live container. The plan needs every block's height from somewhere before the jump.
  1. §7 iPhone: non-contiguous layout with geometric pagination has no check and no fallback. (High.) - The iOS container's rects depend on absolute y (lineRect snaps to page(at: proposal.minY)). Non-contiguous layout places distant text at estimated y, so a line can land on the wrong page, or across a gap, until the hole fills. - The Mac got a risk check. The iPhone, where the dependence is stronger, got none. - Add: p200h paged on iPhone, jump to the end before full layout, then caret-against-glyph, no line across a page gap, and line origins equal to a fully laid-out container's after settling. - Name the fallback for both platforms if the check fails: contiguous layout, but only to the visible bottom (ensureLayout(forBoundingRect:)). That is exact, and costs O(position) once per jump, not per key. - The Mac's "known risk" paragraph has no fallback either.

Fix in place (no re-review)

  1. §7 hard gates: "layout invalidated beyond the edited block: 0 characters" can pass vacuously. (Medium.) It counts our own invalidateLayout calls. With a non-simple container, TextKit itself re-lays out everything after a line-count change. Count line-fragment requests in DocsPageTextContainer.lineFragmentRect per key. That is deterministic and sees both. Bound it by the edited block's lines plus the visible lines.
  1. §7 Design 4: applying a publication needs an actor hop. (Medium.) - CRDTReplica is an actor and the surface is @MainActor, so "the surface asks the replica" suspends in the middle of an apply. - Return the dirty set with the presentation, atomically, for exactly (since, resultRevision]. Then the apply is synchronous. - State that a publication whose resultRevision is at or below appliedRevision is dropped. - Define an unknown entry as "any time authorityProjection takes the project branch". That includes delta.applied returning nil, which the list omits. - structural has no reader, and would always be true as worded. Drop it or define it by id-set difference.
  1. §7 pagination 1: the relative offset is not idempotent. (Medium.) - Today's max(rect.minY, top) survives TextKit proposing a rect twice for one line, which it does when the line turns out taller than first proposed. - proposedRect.minY + extra applies twice if the second proposal starts from the returned rect. - Put a large heading and an image as the first line after a break in the property-test fixtures. If it fails, resolve the absolute top from the cache (topU + X) inside the lookup.
  1. §6 leftovers from finding 7. (Medium.) - Row 6: "Input paused until sign-in" is new behaviour. DocsModel has no pause on needs-sign-in today, row 5 has none, and hard rule 3 says typing still reaches the outbox. Keep today's behaviour, or put it to Paul as a change. - 401: today's path sets can_write = false. So a 401 whose session is then re-minted leaves the window at row 10, with reader chrome and no inspector, until something calls retry(). Say that 401 pauses input without flipping can_write, and name the row the "401" unit test expects. - Row 1: say whether it is terminal. A later refreshAccess answering 200 (re-shared, restored) should leave row 1 and release the held entries.
  1. §1 Delete…: a 404 on the POST is ambiguous. (Medium.) The matrix gives non-owners 404 with nothing deleted, and the client rule reads a POST 404 as "deleted", then drops the lane and the replica. Re-GET after a POST 404 as well: 404 means deleted, 200 means failed.

Low

  1. §1 spike checklist. Add: dragging the window by the title area; double-click (rename against the title bar's zoom); toolbar overflow at narrow widths; full screen; window tabs. State how Rename works in the fallback (a sheet or a popover), since in-place is impossible there.
  2. §1 centring. Name the translation mechanism: a clip view overriding constrainBoundsRect, or a container document view. NSClipView does not honour an arbitrary document-view origin, and E is in window points while the clip's bounds are magnified.
  3. S0. Add one iPad-width editor screen, since S1 changes iPad rendering and nothing else looks at iPad until S5. Add one "after a scripted edit" screen (type before the break, a peer insert), recorded from today's renderer, so that S1's incremental path is compared by pixels too.
  4. Plan S1. Seven work items on one branch. Consider S1a (probes, log, surface, per-block, isolation) and S1b (pagination and lazy layout). The counter gates separate cleanly, and S1b is the piece most likely to need reverting.

Rulings

All three are applied correctly: the iPad gate (§5 and plan ground rules, with S3's "an iPad simulator still shows today's layout"), the S2a/S2b split, and copy review plus a physical-device pass in the shared acceptance.

Slice by slice: implementable in the order S0 → S1 → S2a → S2b → S3 → S4 → S5 once items 1–5 are in the spec. Items 6–10 can land with the slice that touches them.

Revision 3 is pushed: ed5f790 (a separate commit on top of 2fb4a76). Spec and plan are both revised. Fixes 1–13 are all in the spec, including 6–10, so implementers inherit them. Ruling 14 is applied in the plan. The spec ends with a revision 3 table mapping each fix to where it lives.

Fix before S1 step 2

  1. Block ranges under optimistic typing (§7 Design 4). - The block index is now a list of .docsTopBlock runs taken from storage. The surface keeps it current in didProcessEditing, so it is correct before any publication arrives. Reconciliation and the break lookup both use it. - A provisional block is one id run spanning more than one paragraph, which is what an optimistic Return produces. Backspace at a block's start gives the reverse: one paragraph holding two runs. - New test: type, Return, Backspace and paste through the real text view, then check the index against a fresh read of the runs and reconciliation against a full render.
  2. Deferred flush (§7 Design 6). - flushIfDeferred() now has five named triggers: - (a) a publication is applied; - (b) drainEdits ends with the queue empty; - (c) composition ends (compositionChanged(false), unmarkText); - (d) the generation catches up; - (e) inputPaused is cleared. - SwiftUI no longer retries a render. - There is one test per trigger, each with no later publication.
  3. Structural edits (§7 Pagination 2–4). - Each block caches advance and usedBottom. Tops are prefix sums, and inserting or removing blocks is a splice. - Return, block delete, multi-block paste and flushes with several dirty blocks all take the same path. - The break algorithm runs from the first dirty block's page until the break set converges. - A block taller than a page is no longer a full-path trigger, and neither is zoom.
  4. Full path vs oracle (§7 Pagination 1, 3, 9 and 10). - In production, the full path is a retained measurement NSLayoutManager attached to the same NSTextStorage: unpaginated and non-contiguous, with no copy and no isEqual. It runs at open (visible region first, the rest in idle chunks), when Pages is turned on, on a font change that affects every block, and on a text-width change. - The oracle is today's code, moved verbatim into the test target. - The p200h check is now defined against the live container. Wait for the idle chunks to finish and assert the live layout's holes, then ⌘↓ and type. A second variant jumps before the chunks finish.
  5. iPhone (§7 iPhone layout, Fallback). - New check: open p200h in paged mode, jump to the end before the live container has laid out, then confirm the caret lands on its glyph, no line straddles a page gap, and line origins match a full layout once it settles. - Named fallback for both platforms: contiguous layout only to the visible bottom (ensureLayout(forBoundingRect:)). It costs O(position) once per jump and nothing per key. The slice records which mode each platform ships.

Fix in place

  1. Hard gate: the gate now counts the line-fragment requests TextKit makes of our containers, bounded per key by the edited block's lines plus the visible lines plus 8. That catches TextKit's own re-layout as well as ours.
  2. Actor hop: - presentation(…, since: appliedRevision) returns (projection, resultRevision, dirty) together, for exactly (since, resultRevision]. - A publication with resultRevision ≤ appliedRevision is dropped as stale. - "Unknown" now means any time the full project branch runs, which includes delta.applied returning nil. - structural is dropped.
  3. Idempotence: the break lookup is now max(proposed.minY, topU + X), computed from the cache, so a second proposal for the same line gives the same answer. The fixtures include a large heading and an image as the first line after a break.
  4. §6 leftovers. - Row 6 keeps today's input behaviour. - A 401 pauses input without touching can_write, and resumes when the outbox restarts after the re-mint and refreshAccess answers 200. The test expects can_write unchanged, input paused, and row 5, 6 or 8. - Row 1 is not terminal: a later 200 moves the document to row 10 or 11 and calls retry().
  5. Delete…: a 404 on the POST now triggers a re-GET too. A 404 there means deleted; a 200 means the delete failed. The lane and replica are dropped only on a JSON ok or a re-GET 404. The Swift cases are added.

Low

  1. Spike checklist: drag by the title area; double-click renames while the empty toolbar still zooms; overflow order at narrow widths; full screen with the hover toolbar; window tabs; VoiceOver. In the fallback, Rename is a sheet.
  2. Centring mechanism: a flipped DocsDeskView becomes the scroll view's document view and draws the desk. The text view sits inside it at x = leading / m, and NSClipView is never asked to honour an origin.
  3. S0: adds an iPad-width editor screen, and an after-a-scripted-edit screen on Mac and iPhone (type before the first break, plus a peer insert in a later block). The parallel S0 branch already has this. I have not touched S0's implementation.

Ruling 14 (plan)

S1 is split in two:

  • S1a (perf/native-render-isolation): the probes and baseline, the replica log, the surface, per-block rendering and reconciliation, and isolation. Today's pagination is untouched.
  • S1b (perf/native-pagination): the measurement stack, the caches, the break table, lazy layout, the oracle, the line-fragment counter, the two p200h checks and the fallbacks.

Order: S0 → S1a → S1b → S2a → S2b → S3 → S4 → S5.

The spec is ready to land from my side.

Landed on main (squash) at r3 ed5f790. S0 (feat/native-editor-snapshots) is in progress; S1a follows. Paul's four §13 questions keep their defaults until he answers.