fix(server): skip item counts during worktree cleanup #38879
OpennateEc(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/38879/headopened View on GitHubnateEc(GitHub profile, opens in a new tab) linked this to fix #38792
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- @@ -8876,5 +8878,6 @@88768878 pendingTurnItemRows,88778879 ] = yield* Effect.all([88788880 readForThreadIds(selectShellRunRows, forkSourceIds),8879- readForThreadIds(selectShellRunItemCounts, forkSourceIds),8880- readForThreadIds(selectShellItemCounts),8881+ readForThreadIds(8882+ selectShellRunItemCounts,8883+ options?.includeItemCounts === false ? [] : forkSourceIds,
Pushed2739504
Sign in to join this conversation.
No actionable comments were generated in the recent review.
Walkthrough
Shell snapshots can omit item-count reads. Storage cleanup uses this option when it reads threads. The default snapshot behavior remains enabled. Tests verify snapshot contents and SQL reads when counts are disabled.
Changes: Shell snapshot item counts
apps/server/src/orchestration-v2/ProjectionStore.ts,apps/server/src/orchestration-v2/ProjectionStore.test.tsShellSnapshotOptionsaddsincludeItemCounts, which defaults totrue. When it isfalse, the snapshot skips item-count queries and returns zero counts. Tests verify shell fields, zero counts, and SQL reads without rollback timestamp and item-count table reads.apps/server/src/storageCleanup.tsStorageCleanup.readThreadsrequests a shell snapshot with item counts disabled. Its read-only SQLite execution remains unchanged.Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Refactor · Severity of issue fixed: Medium
Possibly related issues
Possibly related PRs
Suggested reviewers:
juliusmarminge,t3dotgg,macroscopeappMerge Risk:
Minimal · up to
27395Storage cleanup no longer runs item-count queries when it reads thread shells. Regular client shell reads still return counts. The change is small and tested, and no remaining merge risk was identified.
Pre-merge checks:
4
#38792reports that the hourly cleanup read builds item counts that cleanup never uses. The verified whole-PR diff (merge base 5b265f8 to head 273950) changes StorageCleanup.readThreads in apps/…Full details: Title check
Explanation
The title "fix(server): skip item counts during worktree cleanup" follows conventional commit style and names the main change. The raw summary shows storageCleanup.readThreads now requests the shell snapshot with includeItemCounts: false, and the ProjectionStore option skips item-count queries. The title matches the changeset and the linked issue about unnecessary cleanup reads.
Full details: Description check
Explanation
The description covers the problem (hourly cleanup reads item counts it never uses), the change (cleanup requests skip count queries and historical run-row reads while client requests keep counts), and scope (links issue
#38792and explains that client shell requests are unchanged). The verification section names specific checks: the projection regression showing counts of 4, 0, and 1 on the normal read, and a fork regression that traces SQL to confirm the source-run query is skipped. It also states what was not checked, namely the production database timing. The template's scope guidance about maintainer requests is not addressed, but that is non-critical. The model/harness line at the end is present. The description is mostly complete.Full details: Linked Issues check
Explanation
Issue
#38792reports that the hourly cleanup read builds item counts that cleanup never uses. The verified whole-PR diff (merge base 5b265f8 to head 273950) changes StorageCleanup.readThreads in apps/server/src/storageCleanup.ts to call projections.getShellSnapshot({ includeItemCounts: false }) before it reads active and archived threads. The raw summary states that ProjectionStore.ts adds an optional includeItemCounts flag, default true. When false, shell reads skip fork-source and per-thread item-count queries and return visibleItemCount as 0. The raw summary states that ProjectionStore.test.ts checks this behavior, including traced queries that omit the item-count table and that default reads still return counts. This covers the item-count objective of#38792. The PR does not change the wider sweep strategy (field-limited reads or incremental reads), and the issue lists those only as possible approaches. Production timing was not remeasured, and the PR description says so. Limit: the ProjectionStore.ts diff and test diff could not be read because changed blobs are missing from the checkout, so their behavior rests on the summary.Full details: Out of Scope Changes check
Explanation
The verified change in apps/server/src/storageCleanup.ts is a three-line change. It passes includeItemCounts: false in the cleanup read only. The summary describes the ProjectionStore.ts change as an optional flag that defaults to true, so client shell requests keep counts. It describes the ProjectionStore.test.ts change as tests for that flag. All of these changes serve the item-count objective of
#38792. No unrelated change was identified. Limit: ProjectionStore.ts and its test file could not be read as diffs, so their scope is assessed from the summary only.Finishing Touches
Generate unit tests (beta)
5e8bd644-b799-4eef-80f3-55e2368ac819Reviewing files that changed from the base of the PR and between 05e0f24c4c5c1075f8627ab4be69a55aa02d6cc6 and 273950496da2d5b0d6a312ad09d28303787af326.
apps/server/src/orchestration-v2/ProjectionStore.test.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.