Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(github): revalidate pull request stack reads with ETags #22078

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/22078/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Problem

The pull request sync refetches a linked pull request's stack over REST (repos/{owner}/{repo}/stacks?pull_request=N) whenever its summary changes, and every read spent core quota even when the stack hadn't changed. Telemetry from 44 servers sharing one GitHub account showed getPullRequestStack at about 710 REST requests/hr, with no conditional requests.

Fix

getPullRequestStack keeps the last body and ETag per credential and sends If-None-Match, so an unchanged stack comes back as a 304, which GitHub doesn't charge for. Each request is pinned to the credential its validator is keyed by, so a 304 never returns another account's body. A 401 still invalidates the credential the same way it does unpinned.

Bottom of a 2-PR stack; #22073 builds on it.

Verification

  • New test: a polled stack is revalidated with its ETag, the cached body is returned on a 304, and a different credential doesn't reuse the first one's validator.
  • vp test run packages/source-control-github/src/server/GitHubPullRequestApi.test.ts, plus lint and typecheck for packages/source-control-github.

Done by Claude Opus 5.5 in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

    1. juliusmarminge changed the title

    2. juliusmarminge added labelsmacroscope-review

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — This PR adds credential-scoped in-memory caching and credential-pinned conditional requests for existing GitHub stack reads, including reuse of cached private response bodies on 304 responses. The change is contained and tested, but its authentication and sensitive-data isolation implications warrant human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Review in Change Stack →
      ✨ 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.
    5. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB−7 B (−0.1%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB−7 B (−0.6%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB−7 B (−0.1%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB−7 B (−0.6%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages220 (0.0%)8✅

      Baseline: 4883320 · PR result: 1154190 · 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.

    6. juliusmarminge merged this0ea5e5a

    7. juliusmarminge closed this

Sign in to join this conversation.