Commit f282f34
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 f8de661 commit f282f34
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 | |
|---|---|---|---|
| |||
1133 | 1133 | | |
1134 | 1134 | | |
1135 | 1135 | | |
1136 | | - | |
1137 | | - | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
1138 | 1140 | | |
1139 | 1141 | | |
1140 | 1142 | | |
| |||
1150 | 1152 | | |
1151 | 1153 | | |
1152 | 1154 | | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
1153 | 1158 | | |
1154 | 1159 | | |
1155 | 1160 | | |
| |||
1162 | 1167 | | |
1163 | 1168 | | |
1164 | 1169 | | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
1165 | 1173 | | |
1166 | 1174 | | |
1167 | 1175 | | |
| |||
4217 | 4225 | | |
4218 | 4226 | | |
4219 | 4227 | | |
| 4228 | + | |
| 4229 | + | |
| 4230 | + | |
4220 | 4231 | | |
4221 | 4232 | | |
4222 | 4233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
234 | 241 | | |
235 | 242 | | |
236 | 243 | | |
| |||
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 | | |
| |||
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
92 | 98 | | |
93 | 99 | | |
94 | 100 | | |
| |||
613 | 619 | | |
614 | 620 | | |
615 | 621 | | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
616 | 626 | | |
617 | 627 | | |
618 | 628 | | |
619 | | - | |
| 629 | + | |
620 | 630 | | |
621 | 631 | | |
622 | 632 | | |
623 | 633 | | |
624 | 634 | | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
625 | 640 | | |
626 | 641 | | |
627 | 642 | | |
| |||
2154 | 2169 | | |
2155 | 2170 | | |
2156 | 2171 | | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
2157 | 2176 | | |
2158 | 2177 | | |
2159 | 2178 | | |
| |||
4082 | 4101 | | |
4083 | 4102 | | |
4084 | 4103 | | |
| 4104 | + | |
| 4105 | + | |
| 4106 | + | |
| 4107 | + | |
| 4108 | + | |
| 4109 | + | |
| 4110 | + | |
| 4111 | + | |
4085 | 4112 | | |
4086 | 4113 | | |
4087 | 4114 | | |
| |||
4179 | 4206 | | |
4180 | 4207 | | |
4181 | 4208 | | |
| 4209 | + | |
| 4210 | + | |
| 4211 | + | |
| 4212 | + | |
| 4213 | + | |
| 4214 | + | |
| 4215 | + | |
| 4216 | + | |
4182 | 4217 | | |
4183 | 4218 | | |
4184 | 4219 | | |
| |||
5472 | 5507 | | |
5473 | 5508 | | |
5474 | 5509 | | |
5475 | | - | |
| 5510 | + | |
| 5511 | + | |
| 5512 | + | |
5476 | 5513 | | |
5477 | 5514 | | |
5478 | 5515 | | |
| |||
7247 | 7284 | | |
7248 | 7285 | | |
7249 | 7286 | | |
| 7287 | + | |
| 7288 | + | |
7250 | 7289 | | |
7251 | 7290 | | |
7252 | 7291 | | |
| |||
7259 | 7298 | | |
7260 | 7299 | | |
7261 | 7300 | | |
7262 | | - | |
| 7301 | + | |
7263 | 7302 | | |
7264 | 7303 | | |
7265 | 7304 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
867 | 867 | | |
868 | 868 | | |
869 | 869 | | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
870 | 874 | | |
871 | 875 | | |
872 | 876 | | |
| |||
0 commit comments