Repository navigation
perf(server): limit history reads before starting queued messages - #47544
juliusmarminge merged 4 commits into
Conversation
Explicitly starting or resuming a queue loads every historical run before the start planner reads it again. Validate against the live queue and the latest executed run, then read failure details only when they can hold the selected provider. Prepared with gpt-6.2-sol through Codex in T3 Code.
ApprovabilityVerdict: Would Approve Macroscope's review found this PR approvable — This reduces history reads when starting or resuming queued messages while retaining usage-limit, active-run, provider, and worktree safeguards. The change does not introduce new queue actions or alter product defaults. Needs human approval because:
Notes:
You can add or adjust custom eligibility rules. Learn more. |
Queue validation can skip a failed setup when a newer run finishes. Check failed and interrupted runs while the thread lacks a worktree. Prepared with gpt-6.2-sol through Codex in T3 Code.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Dismissing prior approval to re-evaluate b410dfb
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Active runs never count as a failed setup, and a failed latest run is already among the failed and interrupted runs read here. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Dismissing prior approval to re-evaluate c9f2872
EvidenceMeasured sequentially on the same Linux x64 VM with Node v26.13.1 and fresh in-memory SQLite. The real production server runs the identical driver before starting its effect worker; no provider process or provider stand-in is involved. Timing is wall-clock around Steps: create synthetic threads/provider threads; seed completed runs with a user message, assistant reply and assistant-message turn item; put a new user run into held-queue state; time Send now, queue resume and ordinary send in interleaved order. Five rounds × 24 measured samples per command, with four warmups per round. Every short-control sample has exactly four completed runs in a fresh thread. Long history starts at 5,000 and grows to 5,420 identically on both sides. Every timed action entered Values below are median of five round medians; parentheses show the range of round medians.
Send now improves by 113.9 ms, exceeding the larger round-median spread (18.2 ms). Resume improves by 115.5 ms, exceeding the larger round-median spread (18.6 ms). The ordinary-send and short-control ranges overlap; no improvement is claimed for those controls. All 27 persisted-state behavior outcomes match identically on both commits. Both commands preserve usage-limit refusals, session-error overrides, stale-limit handling, different-provider handling, non-root/completed-error handling, failed/interrupted worktree refusals, an older failed setup followed by completion, and acceptance after a worktree is bound. Explicit start also preserves refusals for nonqueued selections, missing messages, active runs, notifications and delegated completions. Each refusal leaves the selected run status and hold state unchanged. These are real T3 validation decisions over synthetic persisted states; external quota reporting and worktree subprocess execution are not represented as verified. Driver · Complete reproduction scripts · Method and instructions · Before raw samples and refusal messages · After raw samples and refusal messages · Summary. Both PNGs were captured twice 500 ms apart with zero differing pixels; both recordings and PNGs were visually inspected. Not shown:
|
main's #47544 bounds queue.resume and queued-run.start itself, so its version of that handler and of its read-failure test is kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ngdotgg#47544) Co-authored-by: Julius Marminge <[email protected]> (cherry picked from commit ab091df)
Merges upstream `pingdotgg/t3code` `3067c49847` (301 commits since `fc5ddf3d3c`). > **Merge this PR with "Create a merge commit". Do not squash it.** > pingdotgg#323 was squash-merged, so `fc5ddf3d3c` stopped being an ancestor of `main` and this merge's base fell back to `c16ad0ce17`: 1013 commits and 180 forecast conflicts. The first commit here, `git merge -s ours fc5ddf3` with the tree unchanged, puts the ancestry back. A squash would throw that repair away along with this merge's own parent. ## Commits (read in order) 1. `chore: record upstream fc5ddf3 as merged`: the ancestry repair, with no content change (`git diff f455503 HEAD^` is empty). 2. `chore: merge upstream t3code to 3067c49`: the merge itself, the `threads.moveWorkspace` union entry, and the docs/fork updates. ## Numbers - Landed 817 files against 819 in the upstream range. The two missing files are `apps/server/src/cli/pair.ts` and its test, which the fork deletes on purpose. - Fork delta: 802 files. ## Conflicts (5, each resolved by its verdict) - `cli/pair.ts` and `cli/pair.test.ts`: upstream modified them and the fork deletes them, so they stay deleted. - `ui/textarea.tsx`: upstream's class string, plus the fork's `font` prop. - `agentContextBudget.json`: upstream's values, with `mcpToolListJsonBytes` set to upstream + 108 (63684). `AgentContextBudget.test.ts` passes. - `pnpm-lock.yaml`: re-derived from upstream's copy. `duplicate-adds` and `resolution-check` are clean. The owned-concern sweep matched 6 new files: four vendored libghostty headers and two e2e scenarios, all false positives. ## Feature classification **Usable as-is** - Effect 4.2.0 (pingdotgg#47767) and libghostty-vt 1.0.2 (pingdotgg#47842). - Several hundred web, mobile and shared fixes: footnotes, previews, the workflow panel, PR UI and more. **Unsupported in Moatless / needs implementation** - `threads.moveWorkspace` (pingdotgg#47234: "Move to project…", the palette folder pick, and recovery from a missing workspace). The union entry is added. Every entry point checks the `threadWorkspaceMoves` capability, which Moatless does not report, so the surface is hidden with no fork gate. Recorded in gaps.md under the methods and capabilities entries. - Blume docs site at t3.codes/docs (pingdotgg#44630): upstream publishing, not relevant to the fork. **Backend behavior to consider reproducing in Moatless** (added to gaps.md under runtime fixes) - Worktree recovery and setup reruns after a stopped turn, a retry, or a failed hook (pingdotgg#47694, pingdotgg#47681, pingdotgg#47679, pingdotgg#47685). - Commits stop when the checkout moves under them (pingdotgg#47617, pingdotgg#47526, pingdotgg#47438), and reused PR worktrees stay on the recorded head (pingdotgg#47596, pingdotgg#47528, pingdotgg#47799). - Scheduled runs resume watching their turn after a restart (pingdotgg#47732) and don't fire twice for one slot (pingdotgg#47722). - Codex resumes and forks keep the selected reasoning effort (pingdotgg#47811). - Perf: shell snapshot queries (pingdotgg#47780), workflow questions answered in one query (pingdotgg#47734), bounded history reads (pingdotgg#47544), event-log pruning (pingdotgg#47862). ## Verification - `verify.mjs`: the parallel pass got the pod evicted, so it was re-run with `--sequential`. Everything except tests is green: duplicate-adds, tripwires, resolution-check, unsupported-methods (after the ADD), lockfile, fmt, lint, typecheck and build. - Tests: 39 of 40 completed packages pass. `@t3tools/shared` fails only `AgentScope`, a known OOM-score sandbox gap. - **Not fully verified: `t3` (apps/server) did not finish.** The container stopped after about 3 hours, 84 files in. Every failure up to that point is a known sandbox gap: - git `insteadOf`, Chromium, and the Codex `/tmp` sticky bit. - `ProjectionStore` and `Orchestrator.control-reads`, which call Node 26's `StatementSync.stat` while the sandbox runs Node 24. - The `t3` tests beside the fork's server delta were run separately: 12 files, 366 tests, all passing. CI should run the rest. - The commit skipped the known knip pre-commit failure. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- Moatless task: https://moatless.soaplabstest.com/tasks/bc02b1b2-62c6-4ed0-9429-49bb17da1c4c


Problem
Explicit queue start and resume decode historical runs, user messages, and errors before the start planner reads the thread again.
Change
Validate against live and queued runs and the latest executed run. Load the queue's messages by ID and fetch the latest run's failure details when they can hold the selected provider. If the thread has no worktree, check failed and interrupted runs for an unresolved setup.
Scope
Server-only follow-up to #47115. The send and start planners use older runs for model attribution, context boundaries, and provider handoffs.
Related to #47538. This PR covers validation for explicit queued start and queue resume.
Verification
On one InstaBox, I alternated upstream and the patch over two pairs. Each run had 36 measured samples per case with in-memory SQLite and no provider process. I repeated the benchmark after restoring the worktree guard. The table compares the mean of the two upstream medians with the revised head's median.
ProjectionStore.commandTurnItemstook about 1 ms at 5,000 runs. The regression case fails on upstream when queue resume loads an unrelated historical user message and passes with this change. All 315 initial focused tests passed on InstaBox. With the worktree guard restored, all 226 runtime-layer tests passed, including the CI regression, andcheck:changedpassed on the revised head. Verification used Node 26.Prepared with gpt-6.2-sol through Codex in T3 Code.