feat(cold-turkey): pure goal engine (#161)
CI / ci (push) Canceled after 0s

Wayfinder map #158, Build S1: the pure logic slice the writing
lock consumes — no chrome, no clock of its own.

WritingGoal (words | minutes, one goal per block, fixed at arm)
+ WritingGoalRun: update(text:) takes whole-document text and
netNewWords falls out of the delta (deleting costs — net, not
gross; a big paste counts). now is injected into every call, so
the countdown cannot pause by construction; the minutes deadline
is arm+minutes (inclusive), isMet is live truth, unlatched
(delete below target un-mets — complete on the first true tick),
and progress(now:) is the clamped 0…1 the readout hairline rides.
Word counting goes through the new internal DraftStats.words(in:)
— net-words and first-draft stats share one tokenizer and can
never drift.

Finish-audit fanout: the Int() conversion trap in secondsRemaining
fixed at the seam (isFinite + Double(Int.max).nextDown cap — the
naive cap is itself off-by-one at 2^63; flip-verified pin), two
unpinnable > 0 guards in progress deleted, baselineWords narrowed
to let. Equatable and the ?? armedAt fallback kept deliberately
(S2 consumes the former; removing the latter costs formula
duplication). S2 throttle note landed on #162.

Suite 602/602 (xcresult count), swiftformat + swiftlint clean in
app and test targets. Two traps filed to the swift wiki (bare
@Suite stripped by swiftformat; the Double(Int.max) cap).
This commit is contained in:
AlexKucera committed 2026-11-04 12:50:02 +01:00
1 parent d6c4712aaa
commit e3195d68fd
10 files changed
+389 -5

No files matched your search

+2
View File
@@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file. The format
### Changed
- **cold-turkey:** Pure goal engine (#161, wayfinder map #158 — Build S1 of the Cold Turkey writing lock) — `WritingGoal` (`words(Int)` | `minutes(Int)`, one goal per block, fixed at arm) + `WritingGoalRun`, the armed block: `update(text:)` takes whole-document text and `netNewWords` falls out of the delta (deleting costs — net, not gross; a 2000-word paste counts), and `now` is injected into every call, so the countdown cannot pause by construction. The minutes deadline is arm+minutes (inclusive boundary), `isMet` is live truth, unlatched (deleting below target un-mets; the lock completes on the first true tick), `progress(now:)` is the clamped 0…1 fraction the readout hairline rides, and word counting goes through the new internal `DraftStats.words(in:)` — net-words and first-draft stats share one tokenizer and can never drift ("writer's" is two words, headings are body text, frontmatter never reaches the editor body). Finish-audit fanout (3 reviewers): the `Int()` conversion trap in `secondsRemaining` fixed at the seam (isFinite guard + `Double(Int.max).nextDown` cap — the naive `Double(Int.max)` cap is itself off-by-one at 2^63 and still traps; flip-verified pin), two unpinnable `> 0` guards in `progress` deleted (degenerate zero targets already fall out to 1 through the Double math), `baselineWords` narrowed to `let`; the S2 throttle note landed on #162 (never feed the word count per keystroke). Suite 602 (issue #161)
- **mentor:** Editorial pane chrome (#156, wayfinder map #153 — the #154 contract's build slice 2; the map closes here) — MentorPaneView's chrome now speaks the same two-color editorial voice the transcript gained in #155. The header drops the icon and "Mentor Session" headline for a serif-15/600 "Mentor", and the ready state becomes the semantic green dot (`DesignTokens.readyGreen` — the palette's single sanctioned exception) + lowercase mono `ready`; the base engine version moves to the tooltip (the rare gate/handshake drift note stays visible in orange). The segmented Pass 1 | Pass 2 | Chat picker is gone — the pass bar always carries and owns a compact text-tab selector (mono-10 uppercase tracked, 2pt accent underline on the active tab) above a `PASS N · STATE` status line, the cost line, and the actions as the contract's `MonoButton` (accent solid Run/Restart, surface+border Blind Read, accent-outline Cancel — danger is terracotta, no second hue). The fix-cards row is the ruled plain mono link (no card, no hairline of its own), and the crash / missing-engine / starting states render as quiet state-cards (terracotta tri, serif head, sans-muted body, mini-spinner mono interim). Finish-audit pass: security clean; the orphaned pass-surface MARK, the stale `hermes <base>` doc comment, and a phantom-border comment are fixed; two advisories parked in the devlog (pass-selector state resets on a phase dip — filed as swift-wiki gotcha #28; solid-button contrast ≈ 3.85:1, inherited from #155, to fix pane-wide if flagged). Suite 592 (issue #156)
- **mentor:** Editorial chat voice on the shared transcript (#155, wayfinder map #153 — the #154 contract's build slice 1) — the Mentor and Sessions panes' shared conversation surface now speaks the two-color editorial voice. The model's speaker prefixes map onto three render voices (`speaker(of:)`, pinned): "Mentor:" turns render as full-width serif 15/1.6 prose (markdown parsed at flush, verbatim while streaming — the Vivarium #97 pattern), "You:" turns as right-aligned terracotta-wash capsules (radius 12/12/2/12, capped at 85% of the live column width), and everything else (refusals, pass kick-off labels, Blind Read reveals) as the quiet mono status box on the fg-wash card. ThinkingBlock port: mono-11 toggle over serif-13 muted on the recessed card, open with a spinner while live, collapsed when flushed; research-note cards inherit the wash family. The composer restyles per contract — surface-fill input, ONE accent Send flipping to a terracotta-outlined Stop (plain Return sends, Shift+Return breaks the line — the composer previously sent the draft on Return with no way to type a newline at all), a floating thinMaterial liveness chip above the composer while streaming, and the Debug toggle seated at its trailing edge (the header checkbox is gone; the header keeps title + engine status + session chip). Finish-audit (3 reviewers) hardened it: interpreted markdown opens http(s) ONLY — an `openURL` gate at the sink (engine prose echoes imported content, so a lying label-over-scheme link can never reach a registered handler; pinned via the pure `linkVerdict` seam), Caps Lock no longer turns Shift+Return into a send (pinned), and the two plain-Button toggles speak their state to VoiceOver. Suite 584, flip-verified pins (issue #155)