oficina / docs Public

Spec + plan: four flush triggers, and reset() keeps the text view (S1a, #170)

The coordinator's rulings on Fable's S1a review (#170):

- Finding 6: trigger (e), inputPaused cleared, and didRender's half of
  (d) are dropped from §7 Design 6. canRender reads neither inputPaused
  nor renderedGeneration, so neither can unblock a waiting publication;
  it must not read inputPaused (a reader is paused for good and would
  never see a peer's change); and a writer paused by a refused command
  still holds it as pending input, so the queue-drain trigger draws. The
  no-cost calls stay in the code; no test claims them.
- Finding 2: §7 Design 3 says attaching a different text view draws it
  whole, and that reset() keeps the attached view (a new draft or a
  discard keeps the same host, which nothing rebuilds).

§11 and the plan now count four trigger tests. A table at the end maps
both amendments.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 28bc8c6e8c9ad83c9a4fc196cd4ea8905567a6e2 parent c8f45bd
2 files changed, +15 −5
  • docs/superpowers/plans/2026-11-22-native-redesign.md +2 −2
  • docs/superpowers/specs/2026-11-22-native-redesign-design.md +13 −3
diff --git a/docs/superpowers/plans/2026-11-22-native-redesign.md b/docs/superpowers/plans/2026-11-22-native-redesign.md
index e94f694..2be7ceb 100644
--- a/docs/superpowers/plans/2026-11-22-native-redesign.md
+++ b/docs/superpowers/plans/2026-11-22-native-redesign.md
@@ -62,7 +62,7 @@ Branch `perf/native-render-isolation`. No visible change. Spec §7 Design and Me
- the two-pointer block walk;
- `renderBlock` with neighbour spacing;
- image- and font-scoped re-render;
- - `flushIfDeferred()` wired to triggers (a)–(e).
+ - `flushIfDeferred()` wired to triggers (a)–(d).
4. Per-block reconciliation on both platforms. iOS assigns `attributedText` only at open.
5. Isolate the text view's host:
- the sync row and the toolbar read their own facets;
@@ -79,7 +79,7 @@ Branch `perf/native-render-isolation`. No visible change. Spec §7 Design and Me
- the block render equivalence property test;
- the block-index-under-optimistic-typing test;
- the delta-safety test through the real text view (dropped and delayed publications, extra projections, ja and zh marked text with peer edits, log overflow);
- - the five deferred-flush trigger tests with no later publication.
+ - the four deferred-flush trigger tests with no later publication.
Each was seen to fail with its mechanism broken (a skipped neighbour re-spacing; a flush wired to `didRender` only).
- **No visual change:** S0's editor snapshots, including the after-scripted-edit screens, are unchanged, as are all other baselines.
diff --git a/docs/superpowers/specs/2026-11-22-native-redesign-design.md b/docs/superpowers/specs/2026-11-22-native-redesign-design.md
index cc3e507..66a2aa5 100644
--- a/docs/superpowers/specs/2026-11-22-native-redesign-design.md
+++ b/docs/superpowers/specs/2026-11-22-native-redesign-design.md
@@ -454,6 +454,8 @@ So a delta cannot be forwarded as a patch.
- the pagination caches (Incremental pagination);
- a weak reference to the text view.
+ Attaching a *different* text view (the host rebuilt without the model opening again: an iPad split collapsing, a restructured window) lets the old one go and draws the new one whole. `reset()`, when the replica changes (open, a new draft, a discard), clears what the surface remembers so the next publication is drawn whole, but keeps the attached text view: a new draft or a discard keeps the same host, which nothing rebuilds to attach it again (S1a review, #170 finding 2; coordinator's ruling).
+
It exposes the live text storage as the content that `DocumentCommands`, word counts and `DocumentToolbarSelection` read.
4. **The block index tracks storage, not publications** (finding 1).
- The authority for "which characters belong to which block" is the storage's `.docsTopBlock` attribute (`NativeTextProjection.swift:25`), which optimistically typed text inherits.
@@ -479,10 +481,11 @@ So a delta cannot be forwarded as a patch.
- **(a)** a publication applied (item 5);
- **(b)** the edit queue draining: `drainEdits` ends with `editing` empty and `editingTask` cleared;
- **(c)** composition ending: `compositionChanged(false)`, and the text view's `unmarkText` / marked text committed or cancelled;
- - **(d)** the generation catching up: `projectionGeneration` changes, or `didRender` advances `renderedGeneration` to it;
- - **(e)** `inputPaused` cleared.
+ - **(d)** the generation catching up: `projectionGeneration` changes.
SwiftUI's `updateNSView` / `updateUIView` no longer retries renders, so these hooks are the only triggers. A test covers each, including (b) and (c) with no later publication: storage must converge with nothing else arriving.
+
+ **Two events are not triggers** (revision 3 listed them; S1a review, #170 finding 6, coordinator's ruling). `canRender` reads neither `inputPaused` nor `renderedGeneration`, so neither `inputPaused` being cleared nor `didRender` advancing `renderedGeneration` can be the event that unblocks a waiting publication. `canRender` must not start reading `inputPaused`: a reader's input is paused for good, and it would then never see a peer's change. A writer paused by a refused command still holds it in `editing`, as pending input, so (b) draws when the queue drains after the retry. The implementation still calls `flushIfDeferred()` at both points, because it costs nothing, but no test claims them as triggers.
7. **Per-block rendering:**
- `NativeTextProjection.renderBlock(node, neighbours:)` renders one top-level block, including inline code and the list numbering inside it.
- After a block changes, spacing attributes are recomputed for its neighbours only (`DocumentBlockSpacing` collapses margins between neighbours).
@@ -695,7 +698,7 @@ If a platform's large-document check fails with non-contiguous layout, that plat
- **Library:** shelf of five, the four groups in a fixed time zone, searching ungrouped, `Excerpt` decoded, dates via the locale.
- **Replica dirty log:** revisions advance on every projection call; the dirty set returned with a presentation covers exactly `(since, resultRevision]`; it is nil past the log or across an unknown entry (including `delta.applied` returning nil); a stale publication (`resultRevision ≤ appliedRevision`) is dropped.
- **Block index under optimistic typing:** typing, Return, Backspace at a block's start and a paste go through the real text view with no publication. The index's runs equal the `.docsTopBlock` runs read fresh from storage, including provisional blocks. When the publication then arrives, reconciliation produces a full render's storage.
- - **Deferred flush triggers (finding 2):** one test per trigger (a)–(e) in §7 Design 6. Each has a publication arriving while that condition blocks rendering, and *no later publication*. Storage converges to a full render once the condition clears.
+ - **Deferred flush triggers (finding 2):** one test per trigger (a)–(d) in §7 Design 6. Each has a publication arriving while that condition blocks rendering, and *no later publication*. Storage converges to a full render once the condition clears.
- **Block render equivalence (property test, Low 17):** random edit sequences over fixtures with nested lists, quotes, headings, inline code, images and alignment. The edits include:
- insert and remove at index 0;
- split and merge across blocks;
@@ -811,3 +814,10 @@ If a platform's large-document check fails with non-contiguous layout, that plat
| 12 | Centring mechanism | §1 Page centring: a flipped `DocsDeskView` as the document view, with the text view's frame origin at `leading / m` |
| 13 | S0 coverage | §11: an iPad-width editor screen, and an after-scripted-edit screen on Mac and iPhone |
| 14 | S1 split (coordinator's ruling) | Plan: S1a (probes, log, surface, per-block, isolation, iOS reconciliation) and S1b (pagination, lazy layout, fallbacks) |
+
+## S1a amendments (#170, coordinator's rulings, 2026-11-24)
+
+| # | Finding | Where answered |
+|---|---|---|
+| 2 | A second text view on one surface was never drawn; should `reset()` drop the text view? | §7 Design 3: attaching a different view draws it whole; `reset()` keeps the attached view |
+| 6 | Triggers (e) and `didRender`'s half of (d) cannot unblock anything | §7 Design 6: four triggers, (a)–(d); the two events are no longer triggers, and why |