opt(goal): minutes feeds do no word work; word rail goes count-only
Finding — cold-turkey-full-tokenization
Unticketed digest finding (cold-turkey-full-tokenization, @argus opt pass 2026-11-09, scanned at efbde25c), implemented by @daedalus on opt/cold-turkey-full-tokenization.
The focused editor's per-keystroke feed drove whole-document word counting for every Cold Turkey goal type: PostEditorView.onTextChange → WritingLockState.feed (Museion/WritingLockState.swift:86) → WritingGoalRun.update (Museion/WritingGoal.swift:51 at base 5915178) → DraftStats.words → tokens(in:) (Museion/DraftStats.swift:112 at base) — split(whereSeparator:) + map(lowercased()), the full lowercased token array materialized per keystroke on the main actor. Minutes goals never read that count: isMet, progress, readout, and completionNoteText all ride the clock (consumer audit below). Before-cost, cited from the finding's probe (@argus, not re-measured here): ~0.32 / 3.07 / 16.64 ms per update at 1k / 10k / 50k words — linear in document size, per keystroke.
Fix (RED-first)
dde99c8 — pins first: injectable per-call word-rail seam on update(text:countWords:) (default = the real rail, repo's established seam style alongside spawnsTicker / injectable at:; a global counter would race the hosted parallel suite's DraftStats.compute calls) + the zero-trips pin, RED at base exactly as designed.
9f4d9ef — fix: update guards on .words; a minutes run does zero word work on feed (its accounting freezes at the arm-time baseline — currentWords was dead state for minutes runs). DraftStats.words becomes a count-only Character pass over maximal isLetter/isNumber runs — no array, no lowercasing; equal by construction to the old split (omitting empty subsequences yields exactly the maximal runs).
7de8e2f — devlog + docs. Main (2cfd8b9, post-#187) merged in at 7cd5e69; INDEX.md both-added-row resolved keep-both, newest-first.
Tests (+3, suite 681 → 684)
a minutes update takes zero word-rail trips — the complexity-class pin: O(document) → O(1) per feed.
a words update takes exactly one word-rail trip — the skip boundary, and the count lands.
word rail equals the split tokenizer over a mixed corpus — the old split expression kept alive as the inline reference: empty, whitespace-only, punctuation-only, Latin/diacritics/Cyrillic/CJK/Arabic, emoji-ZWJ, decimal/comma numbers, contiguous alnum runs.
Review verification (@athena, reviewer's own runs, fresh clone in the review seat)
Unit target (-only-testing:MuseionTests, -destination 'platform=macOS') at merge tip 7cd5e69: 689 executed / 689 passed / 0 failed — ** TEST SUCCEEDED **. Count drift vs the branch run (684 → 689) reconciled by test-name inventory diff: +5 are #187's LibrarySearchSnapshotTests from the main side; nothing lost.
Same target at reviewed branch tip 7de8e2f: 684/684 passed; all 3 new pins green.
swiftformat --lint .: 0 dirty (141 files). swiftlint: 279 violations / 60 serious in 141 files — identical counts to pristine base 5915178 (all pre-existing).
Merge structural proof: parents of 7cd5e69 verified = 7de8e2f + 2cfd8b9; git diff 2cfd8b9 7cd5e69 -- Museion/ MuseionTests/ byte-identical (cmp match) to the reviewed git diff 5915178 7de8e2f -- Museion/ MuseionTests/ — the merge contributed zero code bytes; the PR footprint vs main is exactly the branch's 7 files (165 insertions / 10 deletions); zero conflict markers in the tree.
Mergeability: git merge-tree --write-tree clean (exit 0) against trunk 2cfd8b9 — sign-off scoped to that trunk SHA; re-probe if main moves into this seam before merge.
Consumer audit (grep over Museion/ + MuseionTests/, patterns: update(text, currentWords, netNewWords|netWords, DraftStats.words|\.words(in): currentWords is read only by netNewWords; netNewWords is read only inside .words branches (isMet, progress, readout at WritingLockState.swift:158-164) — minutes paths never read word state, so the freeze is observationally identical. Every pre-existing update(text:) pin is a words run or asserts clock-only facts.
Evidence classes: reviewer's own runs above; implementer's devlog runs at 7de8e2f (684/684, lint identical — independently reproduced here); @argus before-probe quoted from the finding.
Unverified / scope
MuseionUITests target not run — neither in the handoff's gate nor in this review (unit target only).
The words-rail constant-factor gain is structural (no array, no lowercasing — by construction), not slope-measured in this review; the minutes-side win is a complexity-class elimination pinned by the zero-trips test.
Deliberately not folded in (correct scope): DraftStats.compute's store-time sentence-length tokenization still allocates per chunk — once per pass at capture, not per keystroke; separate finding if it ever shows hot.
Disjoint case vs #187 (zero code-file overlap; only the INDEX.md row).
Reviewer: @athena — verdict clean (zero findings; round 1 at 7de8e2f full review, round 2 at 7cd5e69 structural merge proof). Alexander merges.
[Generated by AI]
PR Type
Enhancement, Tests, Documentation
Description
Skip per-keystroke word counting for minutes goals.
Count words without allocating lowercased token arrays.
Add counting-boundary and mixed-script equivalence tests.
Document optimization and verification results.
Diagram Walkthrough
flowchart LR
edit["Editor text update"]
goal["WritingGoalRun.update"]
minutes["Minutes goal: skip word counting"]
words["Words goal: count Character runs"]
count["Update live word count"]
edit --> goal
goal -- "minutes" --> minutes
goal -- "words" --> words
words --> count
The argus opt pass (2026-11-09, unticketed digest finding
cold-turkey-full-tokenization): every editor keystroke feeds the whole
document through WritingGoalRun.update, which counted words for ALL
goal types — a minutes verdict ignores the count, so the feed paid
whole-document tokenization (lowercased [String] allocation) per
keystroke on the main actor for nothing (argus probe: ~16.6 ms/update
at 50k words, linear in document size).
Pins, RED-first where constructible:
- WritingGoalTests 'a minutes update takes zero word-rail trips' —
RED at base (base takes one trip per update).
- WritingGoalTests 'a words update takes exactly one word-rail trip' —
the skip boundary: words goals keep live accounting.
- DraftStatsTests 'word rail equals the split tokenizer over a mixed
corpus' — semantic equivalence pin (old split expression as inline
reference over mixed scripts, emoji, punctuation, numbers,
empties); green at base by design — it is the equivalence proof.
Instrument: update(text:countWords:) gains an injectable word-rail
seam (default DraftStats.words) — per-call counting instead of a
global counter, which would race the hosted suite's parallel
DraftStats calls. No behavior change in this commit; update still
counts for every goal.
Root cause (re-derived live at 5915178): WritingLockState.feed ->
WritingGoalRun.update counted words for EVERY goal type, and
DraftStats.words built the complete lowercased token array
(text.split(whereSeparator:).map(lowercased)) just to return .count —
O(document) allocation + lowercasing per keystroke on the main actor
for minutes goals whose verdict/progress/readout never read the count
(argus probe at efbde25c: minutes ~0.32/3.07/16.64 ms per update at
1k/10k/50k words, linear in document size).
Fix, two halves, semantics byte-stable:
- update(text:) guards on .words — a minutes run does no word work
on feed at all; its accounting freezes at the arm-time baseline
(currentWords was dead state for minutes runs: readout, isMet,
progress, and the completion note all ride the clock).
- DraftStats.words becomes a count-only Character pass over maximal
isLetter/isNumber runs — never materializing the lowercased
[String]. Identical count by construction: the tokenizer's split
(which always omits empty subsequences) yields exactly the maximal
runs; equivalence pinned against the split expression over a
mixed-script/emoji/punctuation/number corpus in DraftStatsTests.
WritingGoalRun.init (arm-time baseline) keeps counting once per arm
through the same rail — now also allocation-free. Callers unchanged
(update's countWords defaults to DraftStats.words); the words-goal
net accounting is pinned unchanged ('a words update takes exactly
one word-rail trip' + all existing net-delta pins).
CHANGELOG [Unreleased] > Changed entry + session log + INDEX row for
the unticketed opt pass (minutes feeds skip word counting; word rail
count-only; no token array per keystroke). Suite 684.
Fold origin/main (2cfd8b9, #187 library-search stale-after-mutation)
into opt/cold-turkey-full-tokenization. Only conflict was the
docs/devlog/INDEX.md both-added-row; resolved keep-both in
newest-first order. No code files touched by the resolution:
Museion/ and MuseionTests/ carry #187's hunks verbatim.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
User description
opt(goal): minutes feeds do no word work; word rail goes count-only
Finding —
cold-turkey-full-tokenizationUnticketed digest finding (
cold-turkey-full-tokenization, @argus opt pass 2026-11-09, scanned atefbde25c), implemented by @daedalus onopt/cold-turkey-full-tokenization.The focused editor's per-keystroke feed drove whole-document word counting for every Cold Turkey goal type:
PostEditorView.onTextChange→WritingLockState.feed(Museion/WritingLockState.swift:86) →WritingGoalRun.update(Museion/WritingGoal.swift:51at base5915178) →DraftStats.words→tokens(in:)(Museion/DraftStats.swift:112at base) —split(whereSeparator:)+map(lowercased()), the full lowercased token array materialized per keystroke on the main actor. Minutes goals never read that count:isMet,progress,readout, andcompletionNoteTextall ride the clock (consumer audit below). Before-cost, cited from the finding's probe (@argus, not re-measured here): ~0.32 / 3.07 / 16.64 ms per update at 1k / 10k / 50k words — linear in document size, per keystroke.Fix (RED-first)
dde99c8— pins first: injectable per-call word-rail seam onupdate(text:countWords:)(default = the real rail, repo's established seam style alongsidespawnsTicker/ injectableat:; a global counter would race the hosted parallel suite'sDraftStats.computecalls) + the zero-trips pin, RED at base exactly as designed.9f4d9ef— fix:updateguards on.words; a minutes run does zero word work on feed (its accounting freezes at the arm-time baseline —currentWordswas dead state for minutes runs).DraftStats.wordsbecomes a count-onlyCharacterpass over maximalisLetter/isNumberruns — no array, no lowercasing; equal by construction to the old split (omitting empty subsequences yields exactly the maximal runs).7de8e2f— devlog + docs. Main (2cfd8b9, post-#187) merged in at7cd5e69; INDEX.md both-added-row resolved keep-both, newest-first.Tests (+3, suite 681 → 684)
a minutes update takes zero word-rail trips— the complexity-class pin: O(document) → O(1) per feed.a words update takes exactly one word-rail trip— the skip boundary, and the count lands.word rail equals the split tokenizer over a mixed corpus— the old split expression kept alive as the inline reference: empty, whitespace-only, punctuation-only, Latin/diacritics/Cyrillic/CJK/Arabic, emoji-ZWJ, decimal/comma numbers, contiguous alnum runs.Review verification (@athena, reviewer's own runs, fresh clone in the review seat)
-only-testing:MuseionTests,-destination 'platform=macOS') at merge tip7cd5e69: 689 executed / 689 passed / 0 failed —** TEST SUCCEEDED **. Count drift vs the branch run (684 → 689) reconciled by test-name inventory diff: +5 are #187'sLibrarySearchSnapshotTestsfrom the main side; nothing lost.7de8e2f: 684/684 passed; all 3 new pins green.swiftformat --lint .: 0 dirty (141 files).swiftlint: 279 violations / 60 serious in 141 files — identical counts to pristine base5915178(all pre-existing).7cd5e69verified =7de8e2f+2cfd8b9;git diff 2cfd8b9 7cd5e69 -- Museion/ MuseionTests/byte-identical (cmpmatch) to the reviewedgit diff 5915178 7de8e2f -- Museion/ MuseionTests/— the merge contributed zero code bytes; the PR footprint vs main is exactly the branch's 7 files (165 insertions / 10 deletions); zero conflict markers in the tree.git merge-tree --write-treeclean (exit 0) against trunk2cfd8b9— sign-off scoped to that trunk SHA; re-probe if main moves into this seam before merge.Museion/+MuseionTests/, patterns:update(text,currentWords,netNewWords|netWords,DraftStats.words|\.words(in):currentWordsis read only bynetNewWords;netNewWordsis read only inside.wordsbranches (isMet,progress,readoutatWritingLockState.swift:158-164) — minutes paths never read word state, so the freeze is observationally identical. Every pre-existingupdate(text:)pin is a words run or asserts clock-only facts.Evidence classes: reviewer's own runs above; implementer's devlog runs at
7de8e2f(684/684, lint identical — independently reproduced here); @argus before-probe quoted from the finding.Unverified / scope
MuseionUITeststarget not run — neither in the handoff's gate nor in this review (unit target only).DraftStats.compute's store-time sentence-length tokenization still allocates per chunk — once per pass at capture, not per keystroke; separate finding if it ever shows hot.Devlog:
docs/devlog/20261113-cold-turkey-full-tokenization_log.md· CHANGELOG:[Unreleased] › Changed.Reviewer: @athena — verdict clean (zero findings; round 1 at
7de8e2ffull review, round 2 at7cd5e69structural merge proof). Alexander merges.[Generated by AI]
PR Type
Enhancement, Tests, Documentation
Description
Skip per-keystroke word counting for minutes goals.
Count words without allocating lowercased token arrays.
Add counting-boundary and mixed-script equivalence tests.
Document optimization and verification results.
Diagram Walkthrough
File Walkthrough
2 files
Count word runs without building token arraysSkip minutes counting and inject word counter2 files
Verify count equivalence across mixed text corpusPin minutes skips and single word-count calls3 files
Describe Cold Turkey word counting performance improvementsRecord optimization rationale and regression verification resultsIndex Cold Turkey word counting optimization log🛠️ Relevant configurations:
These are the relevant configurations for this tool:
[config]
[pr_description]
2cfd8b9) into opt branchPR Reviewer Guide 🔍
Here are some key observations to aid the review process:
🛠️ Relevant configurations:
These are the relevant configurations for this tool:
[config]
[pr_reviewer]
PR Code Suggestions ✨
No code suggestions found for the PR.