0068. Coach read models: scope, exemplars, sufficiency and the catalogue
Source:
docs/decisions/0068-coach-read-models.md. Generated at build time; edit the source file.
Date: 2026-11-22. Status: accepted (M5b Task 1). Builds on ADR 0046 (the games read model,
readOnly, scopedAccountIds), ADR 0059 (R3 tables and the web hand-off), ADR 0064 §9 and
§19 (the chat’s input snapshot and account scope) and ADR-R2-7 / ADR-R2-13 (KPIs, Maia-only
difficulty).
Context
Section titled “Context”M5b’s coach pages (report, weaknesses, areas, progress, chat) read the R2 profile tables:
weakness_estimates, weakness_state_history, weakness_series_point, kpi_snapshot,
game_metrics, game_openings, move_features, and report_runs.input. Each of them is keyed
by (account, time class), labels and minimum evidence live in Rust, and the web must not invent
numbers the backend did not compute. apps/web/src/server/profile is that read model.
Decision
Section titled “Decision”- R1, the coach scope is one (account, time class). The options are the user’s linked
accounts (
scopedAccountIds, verified or not) with at least onegame_metricsrow, best first: most rows, then lichess before chesscom, then bullet, blitz, rapid, classical, daily. The URL paramsaccountandtcnarrow the options when they name one of them; a foreign, malformed or empty param is ignored, and a choice that matches no option falls back to the first option. With no option,resolveCoachScopereturns null (the “building” state). - Every read is scoped and read-only. Each exported read runs in
readOnlyand first checks that the scope’s account is one of the user’s (ownsScope), so a scope built for one user reads nothing for another: empty lists, null details and zero counts of rows, never another user’s data. Every query filters by the scope’s account and time class. - R2, exemplars come from the newest report input. A weakness’s example positions are the
exemplarsof the matchingweaknesses[]entry (contractidandvariant, e.g.W3+shallow) of the newestreport_runsrow of the scope whoseinputis not null, the snapshot the coach chat also reads. The page names that run’s date. No such run givesnull; a run that cites no position for the weakness gives an empty list. Onlyinputandcreated_atare read fromreport_runs. - R3, the headline number is the stored posterior. A weakness shows
meanwith its storedci_low–ci_high(80%), next tok_unweightedofn_unweightedchances. It is sufficient whenn_unweighted ≥ min_evidence(key)(Rust); below thatneedMoreis the shortfall. A series without a Rust minimum (only binomial weakness keys have one) is never sufficient. The lead finding is the top weakness withpriority > 0, stateactive,emergingorrelapsed, and sufficient evidence. - Intervals are stored or Wilson. Stored intervals are passed through unchanged. The only
interval the web computes is the weekly weakness rate:
wilson(events, chances, 0.8)over a week’sweakness_series_pointrows (ISO weeks in UTC, the newest 26 with a point), and a week with no chance hasrate: null. KPI and area values that are null stay null; a missing area score is{ value: null, n: 0 }. - Catalogue parity.
catalogue.tsholds the weakness, motif and KPI tables as TS literals.profile-core’scatalogue_snapshottest writes them from the public Rust items tobackend/fixtures/profile/catalogue.json(UPDATE_SNAPSHOTS=1) and fails on drift; the web’scatalogue.test.tsfails when the TS tables differ from that file. The seven areas are kept in@ci/ui’sareaLabelsorder by a test, becausearea-scoreis a client module. - Labels.
W*keys use the Rust label.motif.missed:<tag>uses the KPI label ofmotif_miss_rate:<tag>(“Missed forks”) andmotif.allowed:<tag>the same words with “Allowed” (“Allowed forks”).opening:<colour>:<slug>uses the line’sgame_openings.line_name, else the slug in words, plus “(as White)” or “(as Black)”.endgame:<type>reads “Rook endgames”, “Minor-piece endgames” and so on. An unknown key is shown as itself. - Areas of non-
Wseries.motif.*series belong to tactics,opening:*to openings andendgame:*to endgame; an unknownWvariant takes its family’s area. - Difficulty is counted, never estimated.
difficultyStatuscounts the scope’s positions bymove_features.difficulty_status(ok,pending_maia,not_applicable); positions without a status are not counted.
Consequences
Section titled “Consequences”- A new Rust weakness, motif or KPI fails the Rust snapshot until the fixture is regenerated,
then the web parity test until
catalogue.tsis updated, so labels and thresholds never drift. - Pages get honest gaps (null,
needMore,rate: null) and must render them as stated gaps. - Exemplars lag the profile until the next report is built; the page says which report they come from.