Skip to content

perf(api): find private PR prefixes from the attachment index - #1398

Merged
Zach Dunn (zachdunn) merged 1 commit into
mainfrom
claude/project-thread-qa9hjs
Nov 7, 2026
Merged

Zach Dunn (zachdunn) merged 1 commit into
mainfrom
claude/project-thread-qa9hjs

Conversation

@zachdunn

Copy link
Copy Markdown
Member

What

listPrefixIdsForTarget (managed comment sync and the CLI private-prefix route) used to range-scan every gh/private/ file_metadata row in the workspace to find which private prefixes hold a PR or issue's files. On the largest workspace that is about 10.5k rows per call.

It now reads the distinct prefix_id values from that target's github_attachments rows. The query is pinned with INDEXED BY github_attachments_target_idx, because without stats SQLite picks github_attachments_prefix_idx and walks every private row in the workspace. In production the biggest target reads 29 rows in about 0.5 ms.

The index row's repo is resolved on the server, so the second query that checked prefix ownership is no longer needed. The sentinel and head-branch lookups are unchanged.

Coverage

Every putObject writes an index row for managed keys. In production, every private attachment key with metadata written since Sep 4 has a row. 168 older keys (Aug 18 to Sep 4, on 48 PRs) have no row; their objects are still in R2. Those rows need a one-off backfill before this deploys, or those old PRs could drop private images on their next comment sync.

Tests

  • New SQLite test: the query plan uses github_attachments_target_idx, and the result covers indexed ids, detached rows, other repos, the sentinel and the head branch.
  • The fakes now handle the new statement, and the unused file_metadata arm is removed.
  • The comment tests seed index rows instead of metadata.
  • api: 3637 tests pass. mcp: 213 tests pass.

Generated by Claude Code

listPrefixIdsForTarget range-scanned every gh/private/ file_metadata row
in the workspace (~10.5k rows per call on the largest workspace, ~15k
calls a week from comment syncs). It now reads the distinct prefix ids
from the target's github_attachments rows, pinned to
github_attachments_target_idx (at most ~30 rows in production). The
index row's repo is server-resolved, so the separate ownership lookup
goes away. Sentinel and head-branch lookups are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeLbkis33mPMcBF5kRguaM
@changeset-bot

changeset-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2c30977

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one): 2

  • coderabbit:review
  • review
🚫 Excluded labels (none allowed): 1

  • wip

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 97a650a2-b1a7-400b-9c28-26e7b2b8f59a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@zachdunn
Zach Dunn (zachdunn) merged commit 06b6d4e into main Nov 7, 2026
4 checks passed
@zachdunn
Zach Dunn (zachdunn) deleted the claude/project-thread-qa9hjs branch November 7, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants