Build S7: mixed-content outline guard — no silent prose loss #111

Closed
opened 2026-10-15 14:08:51 +02:00 by AlexKucera · 2 comments
Owner

Part of #110

Question

Build S7: mixed-content outline guard — no silent prose loss. External outlines with paragraph lines between bullets currently drop those lines on the next in-app save (parse drops non-item lines after the first bullet; serialize never writes them back). Ruling: on open, when a type: outline piece parses with dropped non-item lines, warn and offer opening the piece in prose mode instead — outlines still render in prose mode (nested lists, apex pipeline), just not as well; no data loss. Accepting outline mode anyway = the save normalizes (drops) as today, but only after the explicit choice. Flush discipline: the choice happens before any edit; a piece already being edited in-session when the drop is detected can't silently normalize on ⌘S either — the guard fires at load/route time (draft staging + session open), where the type decision lives.

[Generated by AI]

Part of #110 ## Question **Build S7: mixed-content outline guard — no silent prose loss.** External outlines with paragraph lines between bullets currently drop those lines on the next in-app save (parse drops non-item lines after the first bullet; serialize never writes them back). Ruling: on open, when a `type: outline` piece parses with dropped non-item lines, warn and offer opening the piece in prose mode instead — outlines still render in prose mode (nested lists, apex pipeline), just not as well; no data loss. Accepting outline mode anyway = the save normalizes (drops) as today, but only after the explicit choice. Flush discipline: the choice happens before any edit; a piece already being edited in-session when the drop is detected can't silently normalize on ⌘S either — the guard fires at load/route time (draft staging + session open), where the type decision lives. [Generated by AI]
AlexKucera added the wayfinder:task label 2026-10-15 14:08:51 +02:00
AlexKucera self-assigned this 2026-10-15 14:34:30 +02:00
Author
Owner

Resolved — S7 landed.

What shipped (302 insertions across 6 files, 176/176 tests green, build + swiftformat/swiftlint clean):

  • OutlineTree.parsesWithLoss(_:) — the detector: any non-blank non-item line after the first item (shares parseItem, so detector and parser can never disagree; blanks/preamble don't count).
  • PostsModel.select guard branch — a type: outline piece that parses with loss ends the old session (flush-first, prose-mode flush can't drop), nils the new one, and holds the open (outlineGuardPieceID). The ask presents over an EMPTY editor — nothing can edit, so nothing can normalize on ⌘S before the choice (the ticket's flush discipline).
  • Answers: Open in Prose (default; sets proseOverridePostID, a routing override with lastDraftWasOutline's exact lifecycle) · Open as Outline (explicit consent — saves drop as today) · Cancel/Esc (no session; still guarded on next open).
  • OutlineGuardSheet in WorkspaceView — the third house ask (OriginAsk/NewProject binding pattern).
  • 6 tests: parsesWithLoss pin + guard lifecycle (fires/holds/file untouched, prose edit-flush cycle drops nothing, outline answer consented drop, cancel re-guards, clean pieces open untouched).

Record: docs/devlog/20261015-issue111-outline-guard_log.md

Uncommitted on main — awaiting explicit authorization per repo policy.

[Generated by AI]

Resolved — S7 landed. **What shipped** (302 insertions across 6 files, 176/176 tests green, build + swiftformat/swiftlint clean): - `OutlineTree.parsesWithLoss(_:)` — the detector: any non-blank non-item line after the first item (shares `parseItem`, so detector and parser can never disagree; blanks/preamble don't count). - `PostsModel.select` guard branch — a `type: outline` piece that parses with loss ends the old session (flush-first, prose-mode flush can't drop), nils the new one, and holds the open (`outlineGuardPieceID`). The ask presents over an EMPTY editor — nothing can edit, so nothing can normalize on ⌘S before the choice (the ticket's flush discipline). - Answers: **Open in Prose** (default; sets `proseOverridePostID`, a routing override with `lastDraftWasOutline`'s exact lifecycle) · **Open as Outline** (explicit consent — saves drop as today) · **Cancel/Esc** (no session; still guarded on next open). - `OutlineGuardSheet` in WorkspaceView — the third house ask (OriginAsk/NewProject binding pattern). - 6 tests: `parsesWithLoss` pin + guard lifecycle (fires/holds/file untouched, prose edit-flush cycle drops nothing, outline answer consented drop, cancel re-guards, clean pieces open untouched). Record: docs/devlog/20261015-issue111-outline-guard_log.md Uncommitted on main — awaiting explicit authorization per repo policy. [Generated by AI]
Author
Owner

Audit round (finish-audit, 3 parallel fresh-context reviewers) — findings fixed, pins verified to bite:

  • HIGH (security + general): same-id reselect re-fired the guard over an already-open piece, nil'ing its session without teardown — the armed debounce could flush prose-dropped text while the ask was up (the exact loss the guard prevents). Fix: reselect of the open piece is an early-return no-op, as it was pre-guard.
  • MEDIUM: ⌘N / drag-drop during the ask left the hold live; answering destroyed the new draft/guest. Fix: outlineGuardPieceID dies in newPost/newOutline/openExternal + openUnguarded (select's tail now routes through it — one open body).
  • LOW: Cancel left the row selected over the empty editor → selection cleared.
  • ponytail: ~45 lines deleted (openUnguarded dedup, one-read isGuardedOutline via splitFrontmatter, writeNew-based test helper, always-true condition).

3 pinning tests added; both lifecycle pins verified to FAIL with the fixes reverted. 179/179 green, build + swiftformat/swiftlint clean. Deferred: remembered per-piece prose preference (per-open consent is the ruled direction); main-actor guard reads (existing house posture).

[Generated by AI]

Audit round (finish-audit, 3 parallel fresh-context reviewers) — findings fixed, pins verified to bite: - **HIGH (security + general):** same-id reselect re-fired the guard over an already-open piece, nil'ing its session without teardown — the armed debounce could flush prose-dropped text while the ask was up (the exact loss the guard prevents). Fix: reselect of the open piece is an early-return no-op, as it was pre-guard. - **MEDIUM:** ⌘N / drag-drop during the ask left the hold live; answering destroyed the new draft/guest. Fix: `outlineGuardPieceID` dies in newPost/newOutline/openExternal + `openUnguarded` (select's tail now routes through it — one open body). - **LOW:** Cancel left the row selected over the empty editor → selection cleared. - **ponytail:** ~45 lines deleted (openUnguarded dedup, one-read isGuardedOutline via splitFrontmatter, writeNew-based test helper, always-true condition). 3 pinning tests added; both lifecycle pins verified to FAIL with the fixes reverted. 179/179 green, build + swiftformat/swiftlint clean. Deferred: remembered per-piece prose preference (per-open consent is the ruled direction); main-actor guard reads (existing house posture). [Generated by AI]
Sign in to join this conversation.