Commit bbfcd04
committed
feat(github): cache bare PR reads and reviews, mirroring the head-SHA sync-state pattern
Closes #2537.
GET /pulls/{n} (PR state/mergeable_state) and GET /pulls/{n}/reviews were the
largest and third-largest GitHub REST contributors observed in a live
rate-limit trough, and neither was covered by the earlier PR-files cache
(#audit-rate-headroom / #2527). The bare-PR-state read was implemented as
four near-identical helpers with no caching or coalescing, called from
readiness checks, the maintenance planner, duplicate-sibling reconciliation,
and a gate-override command; reviews were explicitly left uncached ("more
volatile than files" -- true at a fixed head, but reviews only actually
change on a pull_request_review webhook).
Extends the existing pull_request_detail_sync_state table (migration 0093)
with prMergeableState/prState/prStateFetchedAt, and reuses the already-present
reviewsSyncedAt column as the review cache's freshness marker. PR-state is
event-invalidated on pull_request synchronize/closed/reopened (with a 5-minute
safety-net TTL so a missed webhook self-heals within one sweep tick); reviews
are invalidated on pull_request_review submitted/edited/dismissed rather than
on head-SHA change, since reviews are independent of the head.
The pre-merge verdict thread and its unified-comment mirror (the #4220
act-boundary) are deliberately left routed through the raw, uncached fetch --
they must always force-refetch live, since the stored/cached mergeable_state
lagging GitHub's async recompute is exactly what caused #4220. This is
verified by two dedicated regression tests plus direct mutation testing
(temporarily rerouting the act-boundary through the cache and confirming both
tests -- and no others in the suite -- catch it).1 parent 84b9a50 commit bbfcd04
9 files changed
Lines changed: 1182 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1138 | 1138 | | |
1139 | 1139 | | |
1140 | 1140 | | |
1141 | | - | |
1142 | | - | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
1143 | 1145 | | |
1144 | 1146 | | |
1145 | 1147 | | |
| |||
1155 | 1157 | | |
1156 | 1158 | | |
1157 | 1159 | | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
1158 | 1163 | | |
1159 | 1164 | | |
1160 | 1165 | | |
| |||
1167 | 1172 | | |
1168 | 1173 | | |
1169 | 1174 | | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
1170 | 1178 | | |
1171 | 1179 | | |
1172 | 1180 | | |
| |||
4229 | 4237 | | |
4230 | 4238 | | |
4231 | 4239 | | |
| 4240 | + | |
| 4241 | + | |
| 4242 | + | |
4232 | 4243 | | |
4233 | 4244 | | |
4234 | 4245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
237 | 244 | | |
238 | 245 | | |
239 | 246 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
| |||
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
| |||
614 | 620 | | |
615 | 621 | | |
616 | 622 | | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
617 | 627 | | |
618 | 628 | | |
619 | 629 | | |
620 | | - | |
| 630 | + | |
621 | 631 | | |
622 | 632 | | |
623 | 633 | | |
624 | 634 | | |
625 | 635 | | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
626 | 641 | | |
627 | 642 | | |
628 | 643 | | |
| |||
2188 | 2203 | | |
2189 | 2204 | | |
2190 | 2205 | | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
2191 | 2210 | | |
2192 | 2211 | | |
2193 | 2212 | | |
| |||
4225 | 4244 | | |
4226 | 4245 | | |
4227 | 4246 | | |
| 4247 | + | |
| 4248 | + | |
| 4249 | + | |
| 4250 | + | |
| 4251 | + | |
| 4252 | + | |
| 4253 | + | |
| 4254 | + | |
4228 | 4255 | | |
4229 | 4256 | | |
4230 | 4257 | | |
| |||
4322 | 4349 | | |
4323 | 4350 | | |
4324 | 4351 | | |
| 4352 | + | |
| 4353 | + | |
| 4354 | + | |
| 4355 | + | |
| 4356 | + | |
| 4357 | + | |
| 4358 | + | |
| 4359 | + | |
4325 | 4360 | | |
4326 | 4361 | | |
4327 | 4362 | | |
| |||
5615 | 5650 | | |
5616 | 5651 | | |
5617 | 5652 | | |
5618 | | - | |
| 5653 | + | |
| 5654 | + | |
| 5655 | + | |
5619 | 5656 | | |
5620 | 5657 | | |
5621 | 5658 | | |
| |||
7390 | 7427 | | |
7391 | 7428 | | |
7392 | 7429 | | |
| 7430 | + | |
| 7431 | + | |
7393 | 7432 | | |
7394 | 7433 | | |
7395 | 7434 | | |
| |||
7402 | 7441 | | |
7403 | 7442 | | |
7404 | 7443 | | |
7405 | | - | |
| 7444 | + | |
7406 | 7445 | | |
7407 | 7446 | | |
7408 | 7447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
874 | 874 | | |
875 | 875 | | |
876 | 876 | | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
877 | 881 | | |
878 | 882 | | |
879 | 883 | | |
| |||
0 commit comments