Commit Graph
2 Commits
Author SHA1 Message Date
AlexKucera dde99c8a75 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.
2026-11-13 04:20:15 +01:00
AlexKucera 42bcfce9ba feat(stats): first-draft stats capture (S5.1) (#31)
CI / ci (push) Canceled after 0s
Measure the writer, not the text. Running Pass 1 or Pass 2 on an
unaided draft (origin: writer, First Draft Pass State, post type -
lenient defaults, so bare legacy posts qualify) computes four style
metrics natively in Swift at the invocation - before the engine sees
anything - and stamps stats_captured plus four stats_* values into
the piece's frontmatter in place, so the S5.2 trend view is a plain
scan of Post.frontmatter. Capture re-fires while still First Draft
(latest draft wins); a cancelled pass keeps its capture; ai-origin
and advanced pieces never qualify.

The capture exposed an erasure class: the existingStamp-to-stamped
block rewrite rebuilt frontmatter from three parsed fields, silently
dropping everything else. advancePassState and overwrite now update
their owned keys in place (stampingFrontmatter, widened internal per
its own third-caller trigger; bare posts still normalize through
stamped), so captured stats and foreign YAML survive pass completion
AND mid-pass editor saves. Both fixes are flip-verified by pins.

DraftStats carries the four metrics (burstiness, type-token ratio,
sentence-length variation, trigram repetition) as a pure Foundation
model - full precision out, %.3f at store time. 16 new pins across
DraftStatsTests, PostStoreTests, and PassRunTests; full unit bundle
396/396 (sequential gate; parallel runs flake under external CPU
load per the #30 learning). Finish-audit fanout (ponytail/security/
review) ran on the diff: its MEDIUM (overwrite erasure) and the
converged deletions landed here.

Closes #31
2026-10-22 19:05:42 +02:00