perf(tasks): summary-first /tasks/browse selection with bounded previews - #1191
Merged
Conversation
One summary row per task version (exact card counters, status buckets, model-grouped cost inputs, last_run_at), refreshed inside the same transaction as every trial-population mutation: create/import, start/reset, completion, cancellation, retry/supersede, scoped deletion, experiment deletion, and default-version selection. Refreshes serialize per version with sorted transaction-scoped advisory locks because concurrent trial inserts hold KEY SHARE FK locks on task_versions. No reader change and no historical scan: the browse endpoint still aggregates on demand, and rows exist only for versions written to after deploy. The read cutover and historical population land separately. Split 1/4 of the #1152 re-land.
Data-only migration: reseed a summary row for every task version, zero every counter, then replay the scoped aggregate and cost-breakdown updates from task_browse_summary_001. Needed because the summary table survived the #1156 revert while write-through maintenance did not, so existing rows are frozen at the 2026-08-11 backfill, versions created since have no row at all, and versions whose scoped trials vanished need resetting. The default browse reader (next split) has no fallback scan when a summary row is missing or stale, so it needs this population to return correct ordering and exact counts for historical tasks. Split 2/4 of the #1152 re-land.
Default GET /tasks/browse ordering and exact card counters now come from task_version_browse_summaries: the page query orders current task versions by the summary's last_run_at and applies the 24-task limit before any trial aggregation, instead of grouping the organization's whole trial history first. Selected cards fetch at most 24 recent current-version trials through an indexed lateral query; total_trials stays exact and latest_trials_truncated marks a shortened preview. Advanced aggregate filters, comparisons, and non-default aggregate sorts keep the on-demand aggregation path. The cost rollup uses the corrected billed_cost_usd key (the billed_usd KeyError 500'd /tasks and caused the #1156 revert); billed-trial coverage now pins it. Split 3/4 of the #1152 re-land; requires the summary maintenance hooks and historical population from the previous splits. Local EXPLAIN (600 tasks / 31k trials): page selection 1,552 -> 161 buffers, 21,085 trial rows -> 0 read at selection time.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Aug 12, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 287a14c. Configure here.
Contributor
Oddish previewCommit:
Vercel deployment URL: https://oddish-nd92qid0f.oddish.app Plan:
This comment is updated by the PR Preview workflow. |
kyle-compute
changed the base branch from
perf/tasks-browse-backfill
to
staging
August 12, 2026 01:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Why this PR exists
Split structure and merge order
Exact screen, request, and frequency
Screenshot for area that is targeted
Production evidence
What this PR changes
Local query evidence
Using a local Postgres fixture with 600 tasks and approximately 31,000 trials:
Known behavior change between this PR and #1192
What this PR does not change
Historical-data decision
Validation completed
Rollback
Note
Medium Risk
Hot-path read cutover for the main task browser with no fallback when summary rows are missing, so it depends on prior population being complete. Also expands the browse API response shape used by the frontend.
Overview
Cuts over the default
GET /tasks/browsepath to summary-first selection: page ordering and exact card counters now come fromtask_version_browse_summariesfor the selectedcurrent_version_id, instead of aggregating organization trial history before applying the limit.Visible cards then load at most 24 current-version trial previews via a lateral query. Exact totals stay on the summary row;
latest_trials_truncatedmarks when the preview is shorter thantotal_trials. New status-bucket fields (pass_count,partial_count, etc.) are also returned from the summary.Advanced aggregate filters, comparisons, and non-default aggregate sorts keep their existing on-demand trial aggregation path. Costs on the default path resolve from the persisted summary
cost_breakdown(including billed rollups).Reviewed by Cursor Bugbot for commit ab05e20. Bugbot is set up for automated code reviews on this repo. Configure here.