test(folds): pin the typing budget at N/2N
CI / ci (push) Canceled after 0s

The #142 in-place re-key had correctness coverage but no typing-cost
guard — a quiet fallback to the full pass keeps every correctness
pin green while restoring O(buffer) work per keystroke. Add an
operation-count instrument (never wall-time): ProseList.parents
gains an observeLines reporter, refreshFolds/refreshFoldRendering
thread a per-call observer, and a per-instance onLineScan hook
windows the paths that call refreshFolds() bare (the PostEditorView
coordinator tail). No shared state — the hosted suite is parallel.

Three pins: zero scanned lines for typing beside a fold at N=204
and 2N=404 lines; an exact-count control (206/406) proving the
instrument is live and scaling; and a through-seam pin driving real
insertText through a real ProseTextView.Coordinator into
refreshFolds() — zero scans, fold survives, self-controlling with
its own 206 liveness assert. Mutation-checked: severing the single
observer firing fails the control and the through-seam pin.
This commit is contained in:
AlexKucera committed 2026-11-13 17:21:16 +01:00
1 parent 7ed304124e
commit c460545c59
3 files changed
+126 -5

No files matched your search

+6 -1
View File
@@ -121,8 +121,13 @@ nonisolated enum ProseList {
let hiddenLineCount: Int
}
static func parents(in text: String) -> [ParentHint] {
/// `observeLines` (brief-24): reports how many lines the scan visited —
/// the typing-budget instrument. Nil in production; tests inject it to
/// pin that single-line typing edits scan ZERO lines (the #142 in-place
/// re-key) while full passes scan O(lines). Per-call, no shared state.
static func parents(in text: String, observeLines: ((Int) -> Void)? = nil) -> [ParentHint] {
let scanned = lines(in: text)
observeLines?(scanned.count)
var out: [ParentHint] = []
for (idx, line) in scanned.enumerated() where line.isList {
let bounds = blockBounds(scanned, from: idx, indent: line.indent)