test(goal): pin zero word-rail trips for minutes updates (RED)
CI / ci (push) Canceled after 0s
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:
1 parent
5915178ce8
commit
dde99c8a75
3 files changed
+77
-2
No files matched your search
@@ -103,6 +103,41 @@ struct WritingGoalTests {
|
||||
#expect(block.secondsRemaining(now: Self.arm.addingTimeInterval(60)) == 29 * 60)
|
||||
}
|
||||
|
||||
@Test
|
||||
func `a minutes update takes zero word-rail trips`() {
|
||||
// Opt pass 2026-11-09 (unticketed digest finding): a minutes
|
||||
// verdict rides the clock alone, so the per-keystroke feed must
|
||||
// not count — let alone tokenize — the whole document. One long
|
||||
// feed, zero rail trips through the injectable seam.
|
||||
var block = Self.run(.minutes(30))
|
||||
var railTrips = 0
|
||||
block.update(
|
||||
text: String(repeating: "word ", count: 2000),
|
||||
countWords: { _ in
|
||||
railTrips += 1
|
||||
return 0
|
||||
},
|
||||
)
|
||||
#expect(railTrips == 0)
|
||||
}
|
||||
|
||||
@Test
|
||||
func `a words update takes exactly one word-rail trip`() {
|
||||
// The skip boundary: words goals keep live accounting — exactly
|
||||
// one rail trip per update, and the count lands.
|
||||
var block = Self.run(.words(500))
|
||||
var railTrips = 0
|
||||
block.update(
|
||||
text: "one two three four five six seven",
|
||||
countWords: { _ in
|
||||
railTrips += 1
|
||||
return 7
|
||||
},
|
||||
)
|
||||
#expect(railTrips == 1)
|
||||
#expect(block.currentWords == 7)
|
||||
}
|
||||
|
||||
@Test
|
||||
func `an absurd minutes goal never traps the countdown`() {
|
||||
// Int() traps past Int.max — the clamp at the conversion seam is the pin
|
||||
|
||||
Reference in new issue
Block a user