Skip to content

fix(orb): invalidate durable CI cache on coalesced fork-PR completions - #8737

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
bitfathers94:fix/issue-8684
Jul 26, 2026
Merged

fix(orb): invalidate durable CI cache on coalesced fork-PR completions#8737
JSONbored merged 2 commits into
JSONbored:mainfrom
bitfathers94:fix/issue-8684

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

fix(orb): invalidate durable CI cache on coalesced fork-PR completions

maybeReReviewOnCiCompletion returns early for fork PRs (empty
pull_requests[]) once a completion event in a burst is head-SHA
coalesced, before ever reaching the invalidation loop whose own comment
promises it runs "for EVERY resolved PR, regardless of whether the
re-review below actually fires". Only the first completion per 60s
window invalidated the durable CI-state cache, so a reader could observe
a stale pre-completion aggregate for up to the cache TTL — for fork PRs
only (same-repo PRs invalidate before their coalesce check).

Invalidate the durable cache in the coalesced branch too, resolving via
the fast stored-DB head-SHA lookup only (no live fork fallback — the
round-trip the coalesce exists to avoid; an untracked fork the DB misses
has no cache entry to clear, mirroring maybeInvalidateCiCacheOnLegacyCiEvent).
The coalescing itself is unchanged: it still suppresses the duplicate
re-review dispatch.

Closes #8684

maybeReReviewOnCiCompletion returns early for fork PRs (empty
pull_requests[]) once a completion event in a burst is head-SHA
coalesced, before ever reaching the invalidation loop whose own comment
promises it runs "for EVERY resolved PR, regardless of whether the
re-review below actually fires". Only the first completion per 60s
window invalidated the durable CI-state cache, so a reader could observe
a stale pre-completion aggregate for up to the cache TTL — for fork PRs
only (same-repo PRs invalidate before their coalesce check).

Invalidate the durable cache in the coalesced branch too, resolving via
the fast stored-DB head-SHA lookup only (no live fork fallback — the
round-trip the coalesce exists to avoid; an untracked fork the DB misses
has no cache entry to clear, mirroring maybeInvalidateCiCacheOnLegacyCiEvent).
The coalescing itself is unchanged: it still suppresses the duplicate
re-review dispatch.

Closes JSONbored#8684
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 26, 2026 01:34
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.19%. Comparing base (6735ef1) to head (cbbfe50).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8737      +/-   ##
==========================================
+ Coverage   90.56%   91.19%   +0.63%     
==========================================
  Files          96       97       +1     
  Lines       22490    25677    +3187     
  Branches     3884     5016    +1132     
==========================================
+ Hits        20367    23417    +3050     
- Misses       1945     1993      +48     
- Partials      178      267      +89     
Flag Coverage Δ
backend 95.70% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/queue/processors.ts 95.70% <100.00%> (ø)

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 26, 2026
@loopover-orb

loopover-orb Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-26 05:32:27 UTC

2 files · 1 AI reviewer · no blockers · readiness 90/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR closes a real gap: the coalesced-completion early-return for fork PRs (empty pull_requests[]) skipped the durable CI-state cache invalidation that the non-coalesced path in the invalidation loop below always runs, so a reader could see a stale CI aggregate for the cache TTL on fork PRs specifically. The fix resolves the coalesced PR via the fast stored-DB lookup (listOpenPullRequests filtered by headSha) rather than the live commits/pulls round-trip the coalescing exists to avoid, mirroring the stated maybeInvalidateCiCacheOnLegacyCiEvent pattern, and both catch()-wraps keep the resolve/invalidate best-effort so a DB or cache hiccup doesn't fail the webhook. The two added tests are well-targeted: one drives two real check_suite events through processJob and asserts the durable sync-state row is actually nulled on both the non-coalesced and coalesced event (with a throwing fetch stub proving no live round-trip occurred), and the other confirms the coalesced second event still suppresses the duplicate re-review audit — this is a genuine reachable-path fix, not a can't-occur guard.

Nits — 3 non-blocking
  • src/queue/processors.ts: the new invalidation branch calls listOpenPullRequests(env, repoFullName) and filters in-memory by headSha rather than a headSha-scoped DB query — fine at typical open-PR counts but worth confirming this matches the existing invalidation loop's approach rather than adding a second, differently-shaped query path.
  • The PR description states the invalidation loop's own comment already promises it runs 'for EVERY resolved PR, regardless of whether the re-review actually fires' — worth double-checking that comment is still accurate post-fix or updating it to reference the new coalesced branch as well.
  • Consider whether invalidateCiStateCache could be batched/parallelized (e.g. Promise.all) instead of sequential awaits in the for-loop if a repo can have many open fork PRs sharing edge-case head SHAs, though this is a minor perf nit not a blocker.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #8684
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ⚠️ 20/25 Preflight is ready, but the PR body does not name the validation run.
Contributor workload ✅ 10/10 Author activity: 44 registered-repo PR(s), 29 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bitfathers94; Gittensor profile; 44 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Linked issue satisfaction

Addressed
The diff moves cache invalidation into the coalesced fork-PR branch (resolving via the stored DB head-SHA lookup before the early return) so it now runs unconditionally, and adds both a test proving invalidation happens on both coalesced events and a regression test proving the re-review dispatch is still deduplicated.

Review context
  • Author: bitfathers94
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: TypeScript
  • Official Gittensor activity: 44 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Add validation command/output.
  • Then work through the remaining 1 step in the Signals table above.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(orb): fork-PR CI-completion coalescing skips the durable cache invalidation it's supposed to guarantee unconditionally

2 participants