test(goal): pin zero word-rail trips for minutes updates (RED)
CI / ci (push) Canceled after 0s

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.
This commit is contained in:
AlexKucera committed 2026-11-13 04:20:15 +01:00
1 parent 5915178ce8
commit dde99c8a75
3 files changed
+77 -2

No files matched your search

+5 -2
View File
@@ -48,8 +48,11 @@ nonisolated struct WritingGoalRun: Equatable {
/// Record the live editor text. The caller passes the whole
/// document every time; the net falls out of the delta.
mutating func update(text: String) {
currentWords = DraftStats.words(in: text)
/// `countWords` is the injectable word rail — the pins count
/// rail trips through this seam (a global counter would race
/// the hosted suite's parallel DraftStats calls).
mutating func update(text: String, countWords: (String) -> Int = DraftStats.words(in:)) {
currentWords = countWords(text)
}
/// Net new words since arm. Deleting costs — net, not gross; a