0078. Honest coach availability, uncompared weaknesses and R2-backed examples
Source:
docs/decisions/0078-honest-coach-availability-and-benchmarks.md. Generated at build time; edit the source file.
Date: 2026-11-22. Status: accepted (bug hunt on the owner’s real data, batch A). Builds on ADR 0062 (the sidecar), ADR 0068 (the weakness read model), ADR-R2-6 (timeline states) and ADR 0060 (chat tools).
Context
Section titled “Context”The bug hunt ran the app on real data with no rating-band reference built and, at first, no AI. Three things claimed more than the data held:
- With no benchmark, Rust stores every weakness as
not_an_issuewith a nullexcessand band (ADR-R2-6: “no reference claims nothing”). The web showed that as “Under control”, “Not an issue”, “Nothing stands out” and “Now not an issue”. - The web could not tell whether the worker had an AI client, so it offered “Build my report”, “Ask your first question” and “100 of 100 left” while nothing could answer.
- The coach’s
find_examplesread only the report’s exemplars. With nothing ranked there are none, so the coach said it “found none” while R2 had stored the occurrences.
Decision
Section titled “Decision”- Uncompared weaknesses are a read-model state, not a Rust state.
WeaknessSummary.comparedis false when the storedband_medianorexcessis null (Rust writesexcessonly with a benchmark,profile::estimates::estimate_row). The timeline lane carriescompared: false. Every surface then says “Not compared yet: no benchmark for players at your level yet” and still shows the weakness’s own rate, range and n: the weaknesses list (its own group) and detail, the overview’s “What to work on” (LeadFinding.none.compared), the report’s “What’s costing you games” (no ranked weakness and no metric band median) and every timeline. With a benchmark nothing changes. Rust is unchanged: a distinct state would ripple through the detector, the contract and the AI input for no gain, since the nullexcessalready says it. - The estimate’s window is stated. Rust counts only points at most
WINDOW_DAYS(183) older than the build, so its counts read “in the last 6 months”, and the detail’s weekly list covers the same window (fromupdated_atminus 183 days, up to 28 ISO weeks), so the two add up. - The worker records its AI state. A worker with AI runners upserts one
ai_statusrow at start (enabled, itsai: enabled|disabled (...)line, never a credential) and refreshesheartbeat_atevery 30 s; a stopped worker’s row goes stale after 120 s. The web readscoachStatus:available(a fresh enabled row),no_ai(fresh rows, none enabled) oroffline(no fresh row), using the database clock. While notavailable:- the coach list, a new conversation and a thread say “Coach not available right now”, keep past answers readable, disable the composer and show no allowance;
- an empty report offers “Build it from your numbers” with
no_ai(a computed-only report) and nothing withoffline. The breaker opening at runtime is not reflected; the row states the startup choice.
- The AI disclosure sits only beside AI text (each answer and section carries its own), so the coach list and an empty new conversation show none.
find_examplesreads R2’s stored occurrences after the report’s exemplars, scoped to the conversation’s account and time class: a weakness’s per-gameexemplarPlies(game_metrics.metrics.weakness,W3coveringW3.shallowandW3.deep), a motif’s erring player moves whose best or refuting line carries the tag (move_features, the contract’s snake_case mapped to R2’s camelCase), and an opening line’s worst player move in its first 30 plies, one per game (game_openings). A position’s tags now include its stored line tags. An empty result is therefore a real “none found”.- The first question always opens its thread. Once the server returns the thread id the new conversation page links to it and, if the client navigation has not left within 4 s, loads it with a full navigation.
Consequences
Section titled “Consequences”- One small table and migration (
20261122010000_ai_status.sql), regenerated into Drizzle. - The e2e seed writes an enabled
ai_statusrow for the simulated worker. - Building the band reference (bug hunt B1) turns every “Not compared yet” back into a state.