Uh oh!
There was an error while loading. Please reload this page.
improvement(db): route additional staleness-tolerant reads to the read replica - #4966
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Workspace execution metrics ( Copilot workspace context ( Copilot @-mentions ( No-activity workspace events ( Reviewed by Cursor Bugbot for commit 293dc79. Configure here. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Greptile SummaryThis PR routes additional staleness-tolerant reads to a read replica across five files. Permission and authz checks are explicitly kept on the primary in every case, and the critical
Confidence Score: 5/5Safe to merge. Every authz gate stays on the primary, the decision-making query in no-activity stays on the primary, and processExecutionLogFromDb is correctly retained on the primary. The routing choices are consistent and conservative: permission checks, authz gates, mutation-adjacent reads (hasRecentActivity, execution log fetch), and cooldown state remain on the primary. Replica reads are limited to prompt-assembly fan-outs, dashboard aggregations, and background cron paginators — all explicitly staleness-tolerant. No files require special attention. The boundary between replica and primary reads is drawn correctly throughout. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Incoming Request / Cron Poll] --> B{Auth / Permission Check}
B -->|db PRIMARY| C[Permission Granted?]
C -->|No| D[Return 401/403]
C -->|Yes| E[Data Reads]
E --> F[workspace-context.ts]
E --> G[metrics/executions/route.ts]
E --> H[no-activity.ts]
E --> I[process-contents.ts KB lookup]
F -->|dbReplica| J[(Read Replica)]
G -->|dbReplica| J
H -->|dbReplica| J
I -->|dbReplica| J
H --> K{hasRecentActivity decision query}
K -->|db PRIMARY| L[(Primary DB)]
M[processExecutionLogFromDb] -->|db PRIMARY| L
Reviews (3): Last reviewed commit: "fix(db): no-activity decision read stays..." | Re-trigger Greptile |
waleedlatif1
commented
Jun 11, 2026
Re the Greptile review: the P1 (workspace-event rules evaluating on the replica) was reviewed at an older commit — |
waleedlatif1
commented
Jun 11, 2026
waleedlatif1
commented
Jun 11, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
Jun 11, 2026
waleedlatif1
commented
Jun 11, 2026
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 293dc79. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Second batch of opt-in
dbReplicareads, each classified against the routing checklist (plain SELECT, no locks/transactions, no read-your-writes in a user-perceivable window, not an authz/enforcement decision, staleness-tolerant consumer):lib/copilot/chat/workspace-context.ts): the multi-table fan-out that builds the WORKSPACE.md prompt context (workflows, folders, KBs, tables + row counts, MCP servers, schedules, connectors) now reads the replica — it's prompt-assembly at turn start, and mid-turn freshness comes from VFS tools which stay on the primary. The workspace-access authz gate and shared permission/file/credential helpers are untouchedqueryChunks, tag definitions/usage): chunk rows are written before a document'sprocessingStatusflips to completed, so any replica state showing a completed document already contains its chunks; tag slot allocation and cleanup decision counts stay on the primaryDeliberately not flipped: log-detail fetch (read directly after execution by id — read-your-writes), v1 list endpoints whose service helpers also serve mutation-refetch UI paths (would need executor threading; deferred), and admin/invite listings (negligible volume).
Type of Change
Testing
Checklist