Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): turns no longer re-read merged PRs from GitHub #19344

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/19344/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Every finished turn re-read every merged PR in that project from GitHub, once for each client that showed it. refreshAfterTurn moves the project epoch, and that epoch is part of every PR's cache key. So the 10-minute merged cache from #16280 was dropped after each turn, and detail and activity (about 15 GraphQL points per activity read) went back to the host. With several agents working in one project, this happens every few seconds.

Now, when a detail read sees a PR as merged, the server keeps the project epoch that the PR had at that time. Turns no longer change its key. The refresh button and PR mutations still move it, because they bump the PR's own epoch. The 10-minute merged TTL still expires. Closed PRs still follow turns, because they can reopen. The fix is on the server, so web, desktop, and mobile all get it.

Proof

New test re-reads an open pull request after a turn, but not a merged one. It reads an open PR and a merged PR, then runs 3 turns and one explicit refresh:

Host reads (detail + activity)BeforeAfter
Open PR, initial read + 3 turns4 + 44 + 4
Merged PR, initial read + 3 turns4 + 41 + 1
Merged PR, explicit refresh1 + 11 + 1

The test fails on main and passes with this change. All 245 tests in apps/server/src/pullRequest pass. apps/server typecheck passes. Lint and format are clean.

Refs #13496

Reviewed with sol-loop: 1 round with GPT-6.1 Sol.

Model and harness: Claude Opus 5.5 in Claude Code via T3 Code.

🤖 Generated with Claude Code

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — The server now suppresses repeated GitHub detail and activity reads for merged pull requests across turn refreshes, while explicit refreshes and mutations still invalidate them. This is a small, well-tested change, but it alters production cache freshness and autonomously gates substantial external work, so human review is appropriate.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire4.9 KiB5.0 KiB+30 B (+0.6%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB+30 B (+2.5%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.8 KiB20.9 KiB+41 B (+0.2%)29.3 KiB✅
      CodexLive turn messages12+1 (+100.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages220 (0.0%)8✅

      Baseline: 9a01524 · PR result: 20a5966 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    5. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: 84901919-2c35-4421-aee6-f8a83c30445e
      📥 Commits

      Reviewing files that changed from the base of the PR and between 9a01524f3faca628699cdf65b43ad020b40b86d8 and 20a596680a78787c45a9ce1c97dd48b4c6100bc1.

      📒 Files selected for processing: 2
      • apps/server/src/pullRequest/PullRequestService.test.ts
      • apps/server/src/pullRequest/PullRequestService.ts

      Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.

      📝 Walkthrough

      PullRequestService records the project epoch when a pull request is first read as merged. Later project-epoch changes do not move that reference’s cache key, while reference-specific epoch changes still apply. A test checks refresh and explicit invalidation behavior.

      Changes: Merged pull request caching

      Layer / File(s)Summary
      Record merged reference epochs
      apps/server/src/pullRequest/PullRequestService.ts, apps/server/src/pullRequest/PullRequestService.test.ts
      Detail reads record the current project epoch for merged references. Their cache keys remain stable across later project-epoch changes, subject to reference-specific epoch changes. The map evicts its oldest entry at capacity. Tests verify that refreshes reread open requests but leave merged requests cached until explicit invalidation.

      Priority: ⬆️ High

      Estimated code review effort: 2 (Simple) | ~15 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to 20a59

      Merged pull requests remain cached across turns, while explicit invalidation still permits a fresh read. No merge-blocking issue is established.

      Pre-merge checks: Passed 2 · Failed 2
      Failed Failed checks: 2 warnings
      Check nameStatusExplanationResolution
      Linked Issues checkWarningIssue [#13496] requires cached, shared detail and activity reads that do not re-fetch merged or closed PRs on each refresh signal. It also requests refresh backoff before quota exhaustion. This PR add…Implement and test the remaining [#13496] requirements for closed PR caching and refresh backoff, or provide an issue-level scope change that removes those requirements before treating this PR as complete.
      Description checkWarningThe description explains the problem, implementation, affected clients, linked issue, and focused verification results. However, it does not include the required Scope and approval information or expl…Add a Scope and approval section that links issue #13496 or the relevant discussion and includes explicit maintainer approval, or explains why this focused fix qualifies for an exemption. Rename or align the Proof section with Verification …
      Passed Passed checks: 2 passed
      Check nameStatusExplanation
      Out of Scope Changes checkPassedThe diff changes only PullRequestService cache-epoch handling and its regression test. The changes directly reduce repeated server reads for merged PRs, which is within issue [#13496]. No unrelated pr…
      Title checkPassedThe title clearly and concisely describes the main change: merged pull requests are no longer reread from GitHub on turns.
      Full details: Linked Issues check

      Explanation

      Issue [#13496] requires cached, shared detail and activity reads that do not re-fetch merged or closed PRs on each refresh signal. It also requests refresh backoff before quota exhaustion. This PR adds project-epoch pinning only for PRs observed as merged. The new test confirms that closed PRs still follow turns, and the diff contains no refresh-backoff change or test. The PR therefore satisfies the merged-PR subset but not all linked coding requirements.

      Full details: Description check

      Explanation

      The description explains the problem, implementation, affected clients, linked issue, and focused verification results. However, it does not include the required Scope and approval information or explicit maintainer approval, and it uses a Proof heading instead of the required Verification heading.

      Resolution

      Add a Scope and approval section that links issue #13496 or the relevant discussion and includes explicit maintainer approval, or explains why this focused fix qualifies for an exemption. Rename or align the Proof section with Verification if required by repository conventions.

      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.

Sign in to join this conversation.