feat(stats): trend view — the writer's arc (#32)
CI / ci (push) Canceled after 0s

A Trends pane (rail destination after Learnings — measurement beside
memory): one line chart per style metric (burstiness, type-token ratio,
sentence variation, trigram repetition) across unaided-first-draft
CAPTURES over time. Points are capture moments, never draft grades —
the pane answers "am I getting better," not "is this draft good." Each
card carries a first-to-last read (improving/steady/slipping at ±0.01,
direction inverted for trigram repetition — the one falling-is-better
metric; one capture shows its value with no verdict), an up/down-better
hint, and a one-line plain-language gloss of the term.

The edited-text leak is closed by construction: Post.scan reads the
five stats_* frontmatter keys into firstDraftStats only when every key
parses to a finite double AND the piece carries the capture gate's
immutable pair (origin writer, type post — not pass_state, which
legitimately advances after the capture). Import carries external YAML
verbatim, so imported ai pieces or outlines with hand-stamped keys
never render, while a migrated writer piece keeps its real arc. The
finite gate also kills a deterministic crash: Double("nan") parses, and
a non-finite peak traps the chart's y-domain construction.

The pane rides PostsModel's watched scan — no scan of its own — so it
refreshes with the library. Fixed y-domains keep single captures
visible (sentence variation scales to its peak); offset-keyed chart
identity and a title tie-break make same-second capture twins
deterministic; the empty state names how the data arrives.

Finish-audit (3 reviewers) fixed the nan/inf crash, the import leak,
same-second ordering, and cut the injectable tolerance parameter and a
label-switch enum down to raw values. Suite 508; the non-finite and
read-back-gate pins are flip-verified.

Closes #32
This commit is contained in:
AlexKucera committed 2026-10-31 15:12:45 +01:00
1 parent 97e86cf62d
commit 3ee6756467
11 files changed
+679 -8

No files matched your search

+10
View File
@@ -22,6 +22,10 @@ struct WorkspaceView: View {
case posts
case sessions
case learnings
/// #32 (S5.2): the trend view — the writer's arc across unaided
/// first-draft captures, sibling of Learnings (measurement beside
/// memory).
case trends
/// #108: the archive rail destination — archive/ as a first-class
/// pane (prototype variant B/C verdict: a destination, not a
/// library disclosure).
@@ -211,6 +215,10 @@ struct WorkspaceView: View {
// #26: list-only pane over <home>/learnings/ — read side;
// promoting a fix card (the fix-card rail) writes the files.
LearningsPaneView(home: gate.museionHome)
case .trends:
// #32 (S5.2): the arc — rides PostsModel's watched scan, so
// the pane refreshes with the library, no scan of its own.
TrendsPaneView(model: gate.posts)
case .archive:
// #108: list-only pane — clicking a row selects the piece and
// hops to Posts where its editor lives.
@@ -249,6 +257,8 @@ struct WorkspaceView: View {
RailButton(pane: .posts, selection: $selection, label: "Posts", systemImage: "doc.text")
RailButton(pane: .sessions, selection: $selection, label: "Sessions", systemImage: "bubble.left")
RailButton(pane: .learnings, selection: $selection, label: "Learnings", systemImage: "cube")
// #32: Trends after Learnings — measurement beside memory.
RailButton(pane: .trends, selection: $selection, label: "Trends", systemImage: "chart.xyaxis.line")
Spacer()
// #108: Archive at the rail bottom, above Settings (prototype's
// box icon).