Repository navigation
feat(scout-for-lol): derive a lane_results table in the report lake - #5305
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
|
Automatic reviews are disabled for this repository. Configure in Code Review Settings. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
5b2c5c5 to
7c94295
Compare
c99c2fd to
546551d
Compare
|
@codex review Automated re-review request for |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Why Lane rates across a friend group (and later the public pages) need "ahead at 15" per laner without reading every timeline frame per request; consumer reads share two DuckDB slots per process. The table must say exactly what the match page says (buildRoleMatchups, aligned to the corrected checkpoint rule in #5205). What - New derived lake table lane_results: one row per laner per tracked match that buildRoleMatchups can pair (laner and same-role opponent PUUID, participant id and champion; team, role, win, queue, game time, has_timeline, the checkpoint timestamp and the gold/CS/XP difference at 15:00). Checkpoint = first frame stamped in [15:00, 16:00); none (shorter game, missing frame, no timeline) means NULL differences. - Derivation reuses buildRoleMatchups over the same checkpoint frames the app reads. A fold re-derives every match its staged match or timeline rows name (fold files); a rebuild derives every match. Reads keep the newest derivation per laner (derived_at), so a timeline folded after its match replaces the timeline-less rows. - Schema epoch 3 (Delivery forward-only configuration scout-beta/3, scout-prod/3) and a declared predecessor fingerprint 0d22d548965ee58c (the lake without lane_results): the next scheduled fold migrates by full rebuild; boot and initial-history folds skip while it is pending. - buildLaneResultsSource (reports/duckdb/lake/lane-results-source.ts) is gated: a build not at the current fingerprint answers "unavailable"; fetchLaneResultsForMatches surfaces that as a typed state. No reader is switched to the table yet. - Build manifests and compaction metrics record laneResultRows. - Wiki explanation and backend README describe the table and migration. Verification - Default-tier parity test (lane-results.test.ts): a five-match test lake (ranked with frames stamped at 900303 ms, a 14:30 game, no timeline, ARAM, a bot laner) agrees with fetchFullMatch + fetchTimelineCheckpointFrames + buildRoleMatchups for all 40 laners; incremental fold derivation with a late timeline reads identically to one full derivation; gate states covered. Reverting the checkpoint window to start at 14:00 fails the parity test. - Extended-tier lane-results.integration.test.ts: real runReportLakeFold (match, then timeline) equals runReportLakeRebuild from S3; a predecessor-schema lake is unavailable, then migrated by the next fold. - bunx turbo run build typecheck test lint --filter=@scout-for-lol/backend - Not run: CI, deployment, live rebuild in beta/prod. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
Why The lane_results writer in report-lake imported buildRoleMatchups from a tRPC router module, so the lake depended on a transport. What - Move consumer-match-role-matchups.ts and standard-rift.ts to src/reports/lanes/ (role-matchups.ts, standard-rift.ts) unchanged; the match and Explore routers, community insights and the lake writer import them from there. Verification - Typecheck and lint of the touched modules are clean. - consumer-profile-details.router.test.ts (role pairing), lane-results.test.ts (parity with buildRoleMatchups), lane-results.integration.test.ts and the architecture-boundary test pass unchanged: 21 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
…he lane pairing
Why
buildRoleMatchups threw when a 15:00 checkpoint frame omitted a participant.
Riot's participantFrames is an open record and nothing between Riot and the
lake guarantees ten entries, so that is boundary data. Reused by the
lane_results writer, one such timeline would have failed every fold and
rebuild in a stage.
What
- buildRoleMatchups returns checkpoint "complete" | "missing" | "incomplete"
on every pairing; an incomplete checkpoint gives no lane result for any lane
of the match (the match page shows no result instead of failing).
- lane_results gains checkpoint_complete (NULL without a checkpoint, FALSE for
a partial frame, which leaves the differences NULL). Schema fingerprint
e767138ef6f2cf23; the predecessor is unchanged (the lake without the table).
- Manifests record laneResultIncompleteCheckpoints and
report_lake_lane_checkpoint_incomplete_total{tier} counts them.
- README and wiki describe the state.
Verification
- Read-only audit of the published builds: beta (1795739716228-0016) 0 of
7,755 matches with a 15:00 checkpoint, prod (1795739708605-0368) 0 of
29,331, have a partial checkpoint frame; 0 partial frames at any timestamp in
either stage.
- lane-results.test.ts adds a match whose 15:00 frame omits a participant;
table and match page agree for all 50 laners (1 incomplete match).
- Role pairing unit test covers the incomplete and missing states.
- Backend and app build/typecheck/test/lint; backend extended tier.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
Why: main gained role-matchup imports from the router module that this stack removes, and the lane_results rows pass readonly arrays. What: repoint those imports to reports/lanes/role-matchups.ts, make the buildRoleMatchups inputs readonly, and share the empty timeline and lane lake fixture tail that the ratchet flagged as duplicated. Verification: backend typecheck clean; bun run jscpd ratchet passes; check-directory-file-counts passes. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
Why: consumer-guild.router.ts and profile-summary.ts came in from main importing the router-module standard-rift.ts that this stack moved. What: import STANDARD_COMMUNITY_QUEUES from reports/lanes/standard-rift.ts. Verification: backend and app typecheck and lint after restacking onto main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
…h detail snapshots Why: roleMatchups now carry checkpoint (complete/missing/incomplete), which main's consumer match story snapshots did not include. What: regenerate the two match-detail snapshots; the only change is one checkpoint line per pairing (complete with a timeline, missing without). Verification: consumer-match-story.router.test.ts 13/13. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
… module after the restack Why: main moved bindParams and runSource into reports/duckdb/lake/statement.ts, so the lane_results derivation and reads no longer resolved them. What: point derive-lane-results and lane-results-reads at the leaf module. Verification: turbo typecheck lint over the changed packages, jscpd, check-directory-file-counts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
546551d to
908a14d
Compare
…ults landed Why: main's Compare router still imported standard-rift from the old router path and the lane readers imported runSource from the profile reads; #5305 moved both, so the backend build failed on main. What: point compare.ts at reports/lanes/standard-rift and the lane readers at the lake statement leaf module. Verification: turbo typecheck lint over the changed packages, scout backend matchup/lane/compare tests, jscpd, check-directory-file-counts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
…mpare reader (#5545) Why #5305 moved standard-rift.ts to reports/lanes/ while #5398 (merged just before it) still imported the old trpc/router/consumer path, so main's backend no longer builds. What Repoint the one remaining import in compare/compare.ts. Verification - bunx turbo run typecheck --filter=@scout-for-lol/backend: 26/26. - bun run test src/trpc/router/consumer/compare (backend): 7/7. - eslint on the changed file: clean. Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ults landed Why: main's Compare router still imported standard-rift from the old router path and the lane readers imported runSource from the profile reads; #5305 moved both, so the backend build failed on main. What: point compare.ts at reports/lanes/standard-rift and the lane readers at the lake statement leaf module. Verification: turbo typecheck lint over the changed packages, scout backend matchup/lane/compare tests, jscpd, check-directory-file-counts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
Why: the lane_results change (#5305) added a required checkpoint to RoleMatchup, so the Match page fixture no longer typechecked against main. What: the fixture's role matchup is a complete checkpoint. Verification: app and design-audit typecheck, lint and test:ci pass; bun run jscpd passes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
Why: the lane_results change (#5305) added a required checkpoint to RoleMatchup, so the Match page fixture no longer typechecked against main. What: the fixture's role matchup is a complete checkpoint. Verification: app and design-audit typecheck, lint and test:ci pass; bun run jscpd passes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
…ults landed Why: main's Compare router still imported standard-rift from the old router path and the lane readers imported runSource from the profile reads; #5305 moved both, so the backend build failed on main. What: point compare.ts at reports/lanes/standard-rift and the lane readers at the lake statement leaf module. Verification: turbo typecheck lint over the changed packages, scout backend matchup/lane/compare tests, jscpd, check-directory-file-counts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
Why: the lane_results change (#5305) added a required checkpoint to RoleMatchup, so the Match page fixture no longer typechecked against main. What: the fixture's role matchup is a complete checkpoint. Verification: app and design-audit typecheck, lint and test:ci pass; bun run jscpd passes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
…ults landed Why: main's Compare router still imported standard-rift from the old router path and the lane readers imported runSource from the profile reads; #5305 moved both, so the backend build failed on main. What: point compare.ts at reports/lanes/standard-rift and the lane readers at the lake statement leaf module. Verification: turbo typecheck lint over the changed packages, scout backend matchup/lane/compare tests, jscpd, check-directory-file-counts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y
…ayer summary from lane_results (#5441) * feat(scout-for-lol): serve the Matchup page and a lane line on the Player summary from lane_results Why The redesigned in-app Matchup page needs the viewer's and friends' record in a champion matchup with ahead at 15 minutes, and the Player page's "Lately" line needs "Ahead at 15 minutes in 11 of 19 lane games". Both must use the one definition of ahead at 15 held by the lane_results table, never recompute from timelines, and say so when the published lake predates the table. What - consumerChampion.matchup({ championId, opponentChampionId, lane, guildIds? }): the viewer's record and friends' record (each with game count and ahead at 15 of the games with a checkpoint) plus the viewer's ten newest games with scoreline, standing at 15 and LP change. One lake slot; logic in trpc/router/consumer/champion-matchup/. - consumerPlayer.profileSummary gains `lane` ({ status, games, ahead }) over the games window the summary already reads, in its existing lake slot. - Both return a typed unavailable result when lane_results is gated or has no derived rows. A game with no 15:00 checkpoint counts in the record but not in the ahead figure; a level lane is not ahead. - Design-audit seed derives lane_results for its fixture lake. Verification - vitest: champion-matchup, profile-lane and consumer-player-lane suites (23 tests) pass, including one-slot, gated, empty, forbidden, multi-account and multi-server cases; src/trpc/router/consumer and lib/player-profile pass apart from two consumer-match-story snapshots owned by the base PR. - backend and app tsc, eslint on touched directories, jscpd and directory file-count checks pass. - Not run: live beta or production lake (lane_results is gated there until the rebuild publishes). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y * fix(scout-for-lol): resolve the lane imports that moved when lane_results landed Why: main's Compare router still imported standard-rift from the old router path and the lane readers imported runSource from the profile reads; #5305 moved both, so the backend build failed on main. What: point compare.ts at reports/lanes/standard-rift and the lane readers at the lake statement leaf module. Verification: turbo typecheck lint over the changed packages, scout backend matchup/lane/compare tests, jscpd, check-directory-file-counts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y * test(scout-for-lol): put the lane router suites in the db CI group Why: the matchup and player-lane router suites reach the PostgreSQL harness, so the CI group guard rejected them in the free groups. What: list both in the db group and drop them from the free groups' excludes and turbo inputs. Verification: scripts/ci-test-groups.test.ts passes; both suites pass locally. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y * fix(scout-for-lol): give a shared account to the viewer in the matchup tally Why: an account tracked by the viewer in one server and by another person in a second was assigned to whichever came last, which could move the viewer's matchup games into friends. What: the viewer's entry owns a shared PUUID regardless of order; a test covers both orders. Verification: champion-matchup suites pass; typecheck and lint run by the pre-commit hook. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Why
Lane rates across a friend group (and later the public pages) need "ahead at 15" per laner without reading every timeline frame on each request: consumer reads share two DuckDB slots per process. The table has to say exactly what the match page says, so it reuses
buildRoleMatchupsand the corrected checkpoint rule from #5205.This builds on #5186, now merged. It retired the previous lake migration, which freed the single predecessor slot this migration uses.
What
lane_resultsderived table (backend/src/report-lake/lane-results/): one row per laner per tracked match thatbuildRoleMatchupscan pair. Columns:match_id,month,derived_at,game_created_at,queue_id,puuid,participant_id,team_id,role,champion_id,opponent_participant_id,opponent_puuid,opponent_champion_id,win,has_timeline,checkpoint_timestamp_ms,checkpoint_complete,gold_diff_at_15,cs_diff_at_15,xp_diff_at_15(laner minus opponent).NULLdifferences andcheckpoint_completeNULL; a match without a timeline still has its rows withhas_timeline = false. "Ahead at 15" isgold_diff_at_15 > 0.checkpoint_complete = falsewithNULLdifferences.buildRoleMatchupsnow returnscheckpoint: "complete" | "missing" | "incomplete"on every pairing, so the match page shows no lane result instead of throwing. Manifests recordlaneResultIncompleteCheckpoints, andreport_lake_lane_checkpoint_incomplete_total{tier}counts these matches. Evidence is under Verification.buildRoleMatchupsandisStandardRiftGamemoved unchanged fromtrpc/router/consumer/toreports/lanes/(role-matchups.ts,standard-rift.ts). The routers, community insights and the lake writer import them from there. The move is its own commit.buildRoleMatchupsand the app's checkpoint frame selection. Reads keep the newest derivation per laner (derived_at), so a timeline folded after its match replaces the timeline-less rows.scout-beta/3,scout-prod/3) andLAKE_PREDECESSOR_SCHEMA_FINGERPRINT = 0d22d548965ee58c, pinned by a test to the current schema minuslane_results. The next scheduled fold migrates by full rebuild; the boot fold and initial-history publishing skip while it is pending (the feat(scout-for-lol): store bot and unresolved participants in the report lake #4512 mechanism, restored).buildLaneResultsSource(reports/duckdb/lake/lane-results-source.ts, next tolake.ts, which is at its line cap) answersunavailablefor any build not at the current fingerprint.fetchLaneResultsForMatches(lake/lane-results-reads.ts) returns{ status: "unavailable" } | { status: "available"; rows }. No reader is switched to the table in this PR.report_lake_compaction_rows_totalrecordlaneResultRows.explanation/scout-report-lake) and backend README describe the table and the migration.Verifying the rebuild in each stage
After this deploys, the next scheduled lake fold in each stage runs the migration rebuild. It is done when:
manifest.jsonhasschemaFingerprint: e767138ef6f2cf23, alaneResultRowscount andlaneResultIncompleteCheckpoints(expected0today, per the audit below).lane_resultsrows match eligible matches: every tracked match that pairs (standard Summoner's Rift queue, 10 participants with ids, each role once per team) has exactly 10 rows. Against the published build:matchesin the first query should equalrift_matchesminus matches that do not pair (end-of-game records, duplicated or missing roles); the gap is small and each such match also hasroleMatchups: nullon its match page. Then readers can switch (follow-up C3 removes the predecessor and the gate together).Demo
There was no lane table before this PR; these tables come from the default-tier fixture lake (
lane-results.test.ts), dumped withduckdb -markdown.lane_resultscolumns (monthis the hive partition):Row counts on the test lake.
rebuild_*is one full derivation.fold_*is two fold derivations where the ranked match's timeline arrives in the second fold: the files hold 20 rows for it, and reads keep the 10 newest.Fold vs rebuild: the same rows either way.
Partial 15:00 frames in the live lakes. A read-only DuckDB audit ran inside each stage's
scout-backendpod over the published build's Parquet (staging excluded). It counted tracked matches whose first frame in [15:00, 16:00) has fewer distinct participants than the match, and the same for every frame at any timestamp.The count is zero today, but no code guarantees it.
RawTimelineFrameSchema.participantFrames(data/src/league/raw-timeline.schema.ts) is an open, nullable record, andflattenTimeline(report-lake/flatten-timeline.ts) writes whatever entries a frame has. The Scout Client converter (scout-client/canonical/lcu-timeline.ts) checks that frame participants are known, not that every participant is present. So the review's rule applies: this is a typed, counted state, not fail-loud.The ranked match, blue side. The checkpoint is the frame stamped at 900303 ms, not the 14:00 frame, where blue led every lane by 100. Level gold is not ahead.
Parity with the match page.
lane-results.test.tsreads the same lake throughfetchFullMatch+fetchTimelineCheckpointFrames+buildRoleMatchupsand compares the checkpoint state, ahead-at-15 and the three differences for every laner. All 50 laners agree, including the partial-frame match. As a mutation check, starting the derivation's checkpoint window at 14:00 instead fails it:Wiki: a new section, "Derived tables: lane results", in
explanation/scout-report-lake. There is no prior state to compare against. Desktop at 1440 and mobile at 390:Verification
bunx turbo run build typecheck test lint --filter=@scout-for-lol/backend --filter=@scout-for-lol/app --continue(after the move and the checkpoint change): backend 642/642 test files, app 92/92. The app is included becauseconsumerMatch.detail'sroleMatchupsgainedcheckpoint. 32/33 tasks passed. The one failure was the dependency build@shepherdjerred/tracker#build(ENOENT @shepherdjerred/console-ui/styles/index.css), which then passed when re-run alone (9/9).The move is behaviour-identical: before the checkpoint change, the role-pairing unit tests, the lane parity tests, the lane integration tests and the architecture-boundary test (21 tests) passed unchanged on the moved module.
lane-results.test.ts(default tier): 4/4. It covers parity withbuildRoleMatchupsfor all 50 laners (frames at about 900303 ms, a 14:30 game, no timeline, ARAM, a bot laner, a 15:00 frame missing participant 7), fold/rebuild parity with a late timeline, and the gate states (no manifest, predecessor fingerprint, current schema with nothing derived). As a mutation check, moving the checkpoint window to start at 14:00 fails 2 of the 4.Role-pairing unit test: a frame that omits a participant now returns
checkpoint: "incomplete"withat15: nullfor every lane, and no frame returns"missing".lane-results.integration.test.ts(extended tier): 2/2.runReportLakeFold(the match first, then its timeline) equalsrunReportLakeRebuildfrom S3, and the gold differences equal the match page'sbuildRoleMatchups.unavailableand reportsreportLakeMigrationPending. The next fold runs astier: "rebuild", the rows come back identical, and the fold after that is an ordinary fold.schema.test.ts: the epoch is 3 and the fingerprint ise767138ef6f2cf23. The predecessor fingerprint equals the current schema minuslane_results, and the retirede086a72a1a8176aais nowunknown.Wiki:
bun run typecheckreported 0 errors andbun run buildcompleted. The new section was rendered and inspected at 1440 and 390 (Demo).bunx lefthook run pre-commit: passed, including service-registration (the immutable configuration revisions are bumped toscout-beta/3andscout-prod/3) and directory-file-counts.Backend extended tier on the final head:
bun run verify:extended -- --filter=@scout-for-lol/backend: 26/26 tasks, 161 test files and 1,479 tests passed,lane-results.integration.test.tsincluded.Earlier full extended run:
bun run verify:extended -- --filter='...[origin/main...HEAD]': 66/66 tasks passed. Test files passed:@scout-for-lol/backend161,@scout-for-lol/temporal20,@shepherdjerred/delivery71,@shepherdjerred/temporal45 + 84, and golink, errors and mc-harness 1 each. This ran on the head while it was stacked on refactor(scout-for-lol): retire the participant-kind lake migration predecessor #5186. The rebase ontomainafter refactor(scout-for-lol): retire the participant-kind lake migration predecessor #5186 merged left the commit unchanged (git range-diffshows it identical).Restacked onto
maind8a526c. Main had added more importers of the moved modules, so three commits integrate them:standard-rift.tsimporters (consumer-guild.router.ts,profile-summary.ts);consumerMatch.detailsnapshots, which only gain acheckpointline per pairing.One catalog conflict was resolved by keeping main's
recipeRevisionId: scout-beta/4alongside this PR'sconfigurationRevisionId: scout-beta/3. Service-registration passes. On the restacked head:build typecheck lintpassed, and app tests passed 95/95 files;consumer-match-story.router.test.ts13/13.testre-run: 663/663 files and 6,189 tests;bun run verify:extended -- --filter=@scout-for-lol/backend): 165 files and 1,503 tests, 26/26 tasks;Not run: Woodpecker CI on this head, image publication, Delivery and ArgoCD rollout, and the live migration rebuild in Beta and Prod (see "Verifying the rebuild in each stage").
The match page renders an
incompletecheckpoint like a missing one (no lane result). The app's scoreboard type ignores the newcheckpointfield, and no UI copy changed.🤖 Generated with Claude Code
https://claude.ai/code/session_011u9pQk6p4o3DxofkiZXg8y