Build S1: Cold Turkey goal engine — net-words delta + countdown #161
Notifications
Due Date
No due date set.
Blocks
#162 Build S2: WritingLock — kiosk, chrome integration, unbroken typing
AlexKucera/museion
Reference: AlexKucera/museion#161
Reference in new issue
Block a user
Question
Build the pure logic slice the lock consumes — no chrome, no UI:
WritingGoalmodel:words(Int) | minutes(Int)— one goal per block, fixed at arm time.DraftStats.swift; word-boundary semantics pinned by tests and consistent with whatever DraftStats counts (cite it — headings are body text, frontmatter is not).AC: pure Swift, no UI, no engine dependency; suite green — count executed tests in the xcresult, never trust the banner (#31, #134).
Part of #158
[Generated by AI]
Resolution — S1 built, suite green (601/601)
Landed (uncommitted working tree per the map's standing rule):
Museion/WritingGoal.swift—WritingGoal(words(Int)|minutes(Int), one goal per block, fixed at arm) +WritingGoalRun: the armed block carrying goal +armedAt+ baseline/current word counts. API S2 consumes:update(text:)(whole-document text),netNewWords(deleting costs; a big paste counts),secondsRemaining(now:),isMet(now:),progress(now:)(0…1 clamped — the readout hairline's number).Museion/DraftStats.swift— internalwords(in:)added: the one word-count rail. Cold Turkey net-words counts through the SAME tokenizer as the first-draft stats, so the two can never drift (the ticket's "cite DraftStats" demand, answered structurally: "writer's" = 2 words, headings are body text, frontmatter never reaches the editor body).MuseionTests/WritingGoalTests.swift— 10 pins: word-delta math (type/delete/paste/undo), timer boundaries (−1 s ≠ met, on-the-second = met), goal-met transitions, tokenizer parity, progress fractions.Key design fact for S2: the engine owns no clock —
nowis injected into every call, so "never pauses" holds by construction (no pause API exists).WritingLockStateowns the ticker and pollsisMet(now:);isMetis live truth, unlatched (deleting below target un-mets — complete on the first true tick). NamedWritingGoalRunper charting decision 7 (writingLockstays S2's state machine name).Verification: definitive full run on the settled tree, counted from the xcresult (not the banner): 601 executed / 601 passed / 0 failed, all 10 WritingGoalTests cases in the executed tree. swiftformat + swiftlint clean on the three touched files; GitNexus impact on
DraftStatsran HIGH-fan-out but the edit is purely additive (new member, zero existing call sites touched).Two facts for the record:
@Suiteattribute but keeps@Suite("Name")— every suite must carry the string argument (now noted in MuseionTests/AGENTS.md).EditorSessionTests/debounce flushes…failure under the added parallel suite (the #147 load-flake class) — isolated run 8/8 green, green in the definitive run; no code change. If it recurs as suites grow, its wait window needs the #147 treatment.Devlog:
docs/devlog/20261104-issue161-cold-turkey-goal-engine_log.md. Fog unchanged — S5.1 tie-in and preset chips stay post-calibration; nothing graduates from this slice.[Generated by AI]