Skip to content

fix(queue): guard terminal PR resync races - #2460

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-stale-closed-pr-upsert-issue
Jul 2, 2026
Merged

fix(queue): guard terminal PR resync races#2460
JSONbored merged 1 commit into
mainfrom
codex/fix-stale-closed-pr-upsert-issue

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • The per-PR regate path could unconditionally upsert a fetched live non-open PR payload and return, allowing a stale closed response to overwrite a concurrently-reopened stored row and cause a live-open PR to be skipped by future sweeps.

Description

  • Add a freshness guard in reReviewStoredPullRequest that re-reads the stored PR and only calls upsertPullRequestFromGitHub for a live non-open payload if the stored row is still open and its updatedAt matches the job's snapshot.
  • This prevents a stale terminal upsert from winning a race against a concurrent reopen webhook while preserving the early-exit semantics for genuinely terminal PRs.
  • Add a regression unit test that simulates a concurrent reopen webhook while the regate fetch returns a stale closed payload and asserts the stored PR remains open with the reopened head.
  • Files changed: src/queue/processors.ts, test/unit/queue.test.ts.

Testing

  • Ran npx vitest run test/unit/queue.test.ts -t "regate-terminal-exit" and the targeted unit tests passed.
  • Ran npm run typecheck and git diff --check, both succeeded.
  • Ran npm run test:coverage with coverage enabled and the global coverage thresholds for the whole repo failed (expected given the focused unit change and repo-wide thresholds), so full coverage gate remains unsharded and must be green before pushing.
  • Attempted npm run test:ci and npm audit --audit-level=moderate but both were blocked by environmental/network issues (actionlint runner-label resolution and npm audit 403), not by the change itself.

Codex Task

@loopover-orb

loopover-orb Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-02 04:51:22 UTC

2 files · no blockers · readiness 68/100 · CI pending · blocked

⏸️ Suggested Action - Manual Review

  • The AI review could not be completed for this change, so the gate is held for a human reviewer rather than passed automatically. It re-evaluates on the next update.

Review summary
AI review is already running for this PR head in another Gittensory pass. Gittensory is holding this PR for manual review until that pass completes.

Nits — 2 non-blocking
  • AI review already in progress for this PR head — The gate is held for a human reviewer rather than passed automatically; it re-evaluates once the in-flight review completes or on the next update.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.
Signal Result Evidence
Code review ✅ No blockers No AI review summary
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ⚠️ 1 scoped overlap Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (size label size:XS; no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 65 registered-repo PR(s), 55 merged, 554 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 65 PR(s), 554 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 65 PR(s), 554 issue(s).
  • Related work: Titles/paths share 7 meaningful terms. (PR #2461, PR #2459)
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Review top overlaps.
  • Add a concise scope and risk note.
  • Triage stale or unlinked PRs.
  • No action.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
  • Check active issues and PRs before submitting.
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.

🟩 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.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added gittensor gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 2, 2026
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.80%. Comparing base (d4957ed) to head (b071278).
⚠️ Report is 47 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2460   +/-   ##
=======================================
  Coverage   95.80%   95.80%           
=======================================
  Files         224      224           
  Lines       24970    24972    +2     
  Branches     9075     9076    +1     
=======================================
+ Hits        23922    23924    +2     
  Misses        428      428           
  Partials      620      620           
Files with missing lines Coverage Δ
src/queue/processors.ts 91.08% <100.00%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored JSONbored self-assigned this Jul 2, 2026
@JSONbored
JSONbored merged commit a9fb639 into main Jul 2, 2026
12 checks passed
@JSONbored
JSONbored deleted the codex/fix-stale-closed-pr-upsert-issue branch July 2, 2026 05:29
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jul 2, 2026
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

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant