perf(server): turns no longer re-read merged PRs from GitHub #19344
main fromrefs/pull/19344/head·merged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubEvery 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) | Before | After |
|---|---|---|
| Open PR, initial read + 3 turns | 4 + 4 | 4 + 4 |
| Merged PR, initial read + 3 turns | 4 + 4 | 1 + 1 |
| Merged PR, explicit refresh | 1 + 1 | 1 + 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
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
juliusmarminge added labelsmacroscope-review
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 4.9 KiB 5.0 KiB +30 B (+0.6%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB +30 B (+2.5%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 20.8 KiB 20.9 KiB +41 B (+0.2%) 29.3 KiB ✅ Codex Live turn messages 1 2 +1 (+100.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅ Claude Live turn messages 2 2 0 (0.0%) 8 ✅ Baseline:
9a01524· PR result:20a5966· Source CI: successScenario 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.
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.tsapps/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.tsDetail 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:
2 · 2-
Failed checks: 2 warningsCheck name Status Explanation Resolution Linked Issues check 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 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 check 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 expl… Add a Scope and approval section that links issue #13496or 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 checks: 2 passed-
Check name Status Explanation Out of Scope Changes check The 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 check The 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
#13496or 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
-
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
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).