0082. The colour split: profile rows per side the player had
Source:
docs/decisions/0082-colour-split-profile-rows.md. Generated at build time; edit the source file.
Date: 2026-11-22. Status: accepted (next round, task T1). Builds on ADR-R2-5 (priority and
MIN_GAMES), ADR-R2-6 (timeline states), ADR-R2-11 (band reference aggregation), ADR-R2-23
(per-metric band fallback) and ADR 0080 (the chess.com peer benchmark, in parallel).
Context
Section titled “Context”The owner wants every stat broken down for White and Black. The profile tables held one row per
account × time class (× metric or series), computed over every game. GameContext.player_color
was already loaded for every analysed game, and every weakness series point carries its game id,
so a per-colour profile needs no engine work: only the stored metrics and series points,
filtered by colour.
Decision
Section titled “Decision”- One dimension,
side_scope ('both', 'white', 'black')(migration20261123000000_colour_split.sql).kpi_snapshot,weakness_estimates,band_referenceandaccount_benchmark_statgetside NOT NULL DEFAULT 'both', so every existing row isboth. The side joinskpi_snapshot_lookup_idxand the primary keys ofweakness_estimates(account_id, time_class, side, series_key),band_reference(build_id, band, time_class, side, metric)andaccount_benchmark_stat(account_id, time_class, side, metric). Rust’sprofile_core::types::Sidemirrors it. - build-profile computes three times. Estimates and KPI snapshots (with their
area:*rows) are computed forboth(unchanged), and for the games the player had White, then Black, in: that side’s series points, games-in-window count and weekly windows. Sessions are computed once over every game (a session mixes colours). Every binomial key gets a row per side, a side without games included, so each side’s row set is complete. - The same minimum evidence, counted per side.
MIN_GAMES(30) gates ranking on the side’s own games in the window; a snapshot’snis the side’s own count, so the web’sKPI_MIN_GAMES(10) and per-KPI minimums apply per side unchanged. - The timeline stays
bothonly. Per-colour states would halve the evidence behind every onset and transition.weakness_state_historyhas no side. A colour’s estimate rows carry the account’s (both) state and a nullP_imp(a timeline quantity). Events (profile.updated,weakness.changed) come from the both side only, as before. - A side is benchmarked only by its own rows.
load_band_reference_for(band, tc, side)reads one side; the per-metric fallback moves across bands, never across sides. Abothreference is never applied to one colour: no colour rows means no colour benchmark (NoBenchmark, null band fields). The Lichess aggregation now also writeswhiteandblackrows from the sides that had that colour, with their own player counts andlow_sample. The build’s evidence gate and supersede rule countbothrows only, so a build’s activation is decided as before. - The peer benchmark (ADR 0080) splits the same way. A colour’s peers are the opponents
who had that colour (
peer_sides_of): the player’s Black games give the White peers, so White play is compared with White play. They are aggregated by the same rules (same rating window around the player’s latest rating, the player’s 183-day window, the pooled rate and the excluded mirrored rows of ADR 0081, their ownn_chancesandlow_sample) and stored as that side’saccount_benchmark_statrows (sidejoins its primary key).account_benchmark(the band and its counts) stays one row per account × time class and describes the both benchmark; colour rows are written only when it exists. The coaching input’sload_account_benchmarkreads the both rows. - Existing profiles rebuild once, without the engine. There is no profile version to bump:
PLAYER_GAME_METRICS_VERSIONdescribes the per-game metrics, which did not change, and bumping it would also make every reference observation stale. Instead the worker start runsrequeue_colour_split: every account × time class withbothestimates but noblackone gets a build-profile job (deduped). The build reads the stored rows, so it is idempotent and the pair is never due again. - Readers keep reading
both. The coaching input, the weekly input, the scheduler’s precision check, the timeline’s stored states and the web read models (latestSnapshots, the weakness summaries, the benchmark label andcli profile) filterside = 'both', so every page is unchanged. Per-side UI and the CoachingInputby_colorcome later (T2b, T3, T4).
Consequences
Section titled “Consequences”- About three times the estimate rows and up to three times the snapshot rows per build; the build’s CPU part grows accordingly (still one load, one transaction).
- A colour’s ranking can differ from the account’s: Black may be unranked (fewer than 30 games) while both is ranked. That is the honest reading of the evidence.
- A colour without peers (or Lichess rows) of its own has unbenchmarked estimates and area scores: “not compared”, never the both benchmark. A player who always has White has no White peers at all.