Repository navigation
Conversation
Discovery should find a branch pull request from thread rows alone. On the base, the sweep builds thread shells, which read run and item history, so it fails once those tables are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR discovery built full thread shells, which count tool items, look up run errors and pending work, and walk fork sources. It uses none of that. It needs the thread's project, branch, worktree, saved PR links and settled or archived state. Add a projection read that returns the thread rows and the thread event high-water mark in one transaction, then decodes after it ends. Legacy single-link payloads still read as one link, as they do in shells. The sweep keeps its active and unsettled filters, startup backfill and sequence guard; a one-thread refresh still reads that thread wherever it lives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — This PR changes a high-frequency production discovery path and introduces a new projection-store snapshot implementation, including different transaction and sequence handling. The scope is focused and tested, but the runtime and shared-infrastructure impact warrants human review. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Discovery snapshot contract and reads apps/server/src/orchestration-v2/ProjectionStore.ts, apps/server/src/orchestration-v2/ProjectionSettlement.test.ts |
ProjectionStore adds a snapshot result containing the event sequence and thread rows. SQLite and in-memory implementations apply active-thread, unsettled, and specific-thread selection. Tests cover these scopes and legacy pull-request normalization. |
Service snapshot integration and regression coverage apps/server/src/orchestration-v2/ThreadPullRequestService.ts, apps/server/src/orchestration-v2/ThreadPullRequestService.test.ts, apps/server/src/orchestration-v2/ProviderTurnControlService.test.ts, apps/server/src/server.ts |
ThreadPullRequestServiceV2 reads discovery snapshots from ProjectionStore, and the server provides that layer to the worker. Tests cover snapshot-based discovery, including a case where orchestration projection tables other than the thread table are absent. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Refactor
Possibly related issues
pingdotgg/t3code#24660— The change removes the full shell read from pull-request discovery, but does not add reader concurrency or changeensureTranscriptcaching.pingdotgg/t3code#24895— The service now usesgetPullRequestDiscoverySnapshotto read thread metadata during discovery instead of the prior shell snapshot path.
Suggested reviewers: t3dotgg
Merge Risk: 
Minimal · up to f0f1c
-
PR discovery can use the metadata-only snapshots without an identified sync-sequence regression. No merge-blocking issue remains after normal checks.
Pre-merge checks: 
4
-
Full details: Description check
-
Explanation
The description includes all required sections and provides detailed problem context, implementation scope, verification results, limitations, and related issue information. The Scope and approval section cites issue
#18618and a triage comment, but it also states that maintainer confirmation is still pending.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Problem
Pull request discovery runs at startup, on the one-minute sweep while a client is connected, and after each finished turn. Each run builds full thread shells. A shell read counts tool items, looks up run errors and pending work, and walks fork sources. Discovery uses none of that. It needs the project, branch, worktree, saved PR links, and settled or archived state.
On large installs, discovery is the longest database holder, and this read is the part of it that runs inside a transaction. In #18618, a 31 GB install with about 2,790 threads saw
ThreadPullRequestServiceV2.synchronizerun for a median of 5.5 s and up to 239.7 s. Its longest reader transaction ran 120.7 s, and a reader held that long keeps the WAL pinned (#23482).Change
ProjectionStoreV2.getPullRequestDiscoverySnapshotreads thread rows and the thread event high-water mark in one transaction, then decodes them after the transaction ends. It touches no run, item, message, plan or provider table. The SQL and in-memory stores both implement it.ThreadPullRequestServiceV2uses it for the sweep and one-thread refreshes. Kept as before: active threads only, unsettled only unless a backfill is pending, archived threads still readable by id, startup backfill, and thethread.pull-request.syncsequence guard.linkedPullRequeststill read as one link, asthreadPullRequestsOfdoes for shells. Without that, discovery could replace a legacy link that shells treat as already linked.I passed on a metadata-only mode for
getShellSnapshot: the shell builder joins history in its main query and fork walk, so a separate small read is simpler.Scope and approval
Issue #18618. The triage reply on Julius's behalf (comment) kept it open as an enhancement: "A metadata-only read is a reasonable, cheap follow-up that fits alongside #14703." The large-install numbers came later in that thread.
Maintainers to confirm: whether a performance change of this size fits current intake. This version is server-only, with no contract or client changes.
The backfill window in #21620 applies unchanged, since it reads
settledAtandupdatedAtfrom the same thread rows. Only its test mock would move fromgetShellSnapshotto the new read.Verification
vp test runonThreadPullRequestService.test.ts,ProjectionSettlement.test.ts,ProviderTurnControlService.test.tsandProjectionStore.test.ts: 64 passed.snapshotSequence: 42.vp run typecheckinapps/server: passes.vp fmt --checkandvp linton the changed files: clean.Not checked:
Prior PRs
Generated with Claude Opus 5.5 in T3 Code Nightly