fix(review): reuse the live mergeable_state/CI read across a single pass - #4537
Conversation
reReviewStoredPullRequest / the direct pull_request webhook handler both thread ONE shared LiveGithubFacts object through readiness, maybePublishPrPublicSurface, and runAgentMaintenancePlanAndExecute -- but the latter two independently force-refetched the same PR's mergeable_state and CI aggregate live from GitHub, back to back, with no mutation between the two reads. Adds reuseOrRefreshLiveMergeState/reuseOrRefreshLiveCiAggregate, which reuse a value already populated by a FORCED write earlier in the same pass instead of re-fetching. Deliberately not the existing cachedLiveMergeState/ cachedLiveCiAggregate variants: those fall through to the durable cross-webhook cache on a request-local miss, which can replay an older webhook's snapshot -- exactly what the disposition input's #4220 invariant prohibits. Tracks which keys were populated by a forced (genuinely-live- this-pass) write via new forcedMergeStateKeys/forcedCiAggregateKeys sets on LiveGithubFacts, so a value written by the READINESS path's own cache-preferring reader is never mistaken for a fresh one. Closes #4498.
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4537 +/- ##
=======================================
Coverage 94.04% 94.04%
=======================================
Files 422 422
Lines 37579 37589 +10
Branches 13729 13733 +4
=======================================
+ Hits 35340 35350 +10
Misses 1583 1583
Partials 656 656
🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-09 23:40:02 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 7 non-blocking
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Closes #4498.
Summary
reReviewStoredPullRequestand the directpull_requestwebhook handler both thread ONE sharedLiveGithubFactsobject through readiness,maybePublishPrPublicSurface, andrunAgentMaintenancePlanAndExecute— but the latter two independently force-refetched the same PR'smergeable_stateand CI aggregate live from GitHub, back to back, with no GitHub-side mutation between the two reads (only a comment/labels get posted in between).reuseOrRefreshLiveMergeState/reuseOrRefreshLiveCiAggregate, which reuse a value already populated by a FORCED write earlier in the same pass instead of re-fetching.cachedLiveMergeState/cachedLiveCiAggregatevariants (the audit's original suggestion) — those fall through to the durable cross-webhook cache on a request-local miss, which can replay an older webhook's snapshot. That's exactly what the disposition input's#4220invariant (see the doc comment onrefreshLiveMergeState) prohibits: the act-boundary disposition must never see a stale value. Verified this distinction matters empirically — an existing test ("a second agent-regate-pr pass for the SAME still-settled head_sha serves the readiness check from the durable cache...") broke against a naivecachedLiveMergeState-based fix and only passed once the fix correctly distinguished a genuinely-fresh forced write from a possibly-stale cached one.LiveGithubFactsgainsforcedMergeStateKeys/forcedCiAggregateKeys(Set<string>), populated only by the FORCED writers (refreshLiveMergeState/refreshLiveCiAggregate). The reuse helpers only trust a memoized value when its key is in these sets — never when it was populated by the READINESS path's own cache-preferring reader.Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
npm run typechecknpx vitest run test/unit/queue.test.ts(759 passed) and the full unsharded suitenpx vitest run(12,906 passed, 12 skipped) — run in full given this touches a widely-shared interface (LiveGithubFacts).Safety