Skip to content

fix(queue): drain contributor PR reviews oldest first - #2865

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-regate-fifo
Jul 4, 2026
Merged

fix(queue): drain contributor PR reviews oldest first#2865
JSONbored merged 1 commit into
mainfrom
codex/fix-regate-fifo

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • Make durable self-host queue claims drain per-PR re-gate work by original GitHub PR creation time.
  • Preserve FIFO order through sweep fan-out, rate-limit requeues, coalesced jobs, and legacy queued rows.
  • Prevent duplicate per-PR re-gate rows from being claimed while the same job key is already processing.

What changed

  • Added a persisted claim sort key to SQLite and Postgres self-host queues.
  • Threaded prCreatedAt through scheduled and issue-linked re-review jobs.
  • Updated claim SQL to order foreground PR review work by PR age before enqueue timing.
  • Added regression coverage for FIFO drain order, duplicate in-flight claim suppression, Postgres claim SQL, and sweep fan-out metadata.

Why

Contributor PRs need to be reviewed and acted on oldest-first so newer work does not jump ahead and increase merge-conflict churn.

Validation

  • npx vitest run test/unit/selfhost-queue-common.test.ts test/unit/selfhost-sqlite-queue.test.ts test/unit/selfhost-pg-queue.test.ts test/unit/queue.test.ts
  • npx vitest run test/unit/selfhost-pg-queue.test.ts
  • npm run typecheck
  • git diff --check

@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2865   +/-   ##
=======================================
  Coverage   96.02%   96.02%           
=======================================
  Files         259      259           
  Lines       28349    28382   +33     
  Branches    10305    10319   +14     
=======================================
+ Hits        27222    27255   +33     
  Misses        491      491           
  Partials      636      636           
Files with missing lines Coverage Δ
src/queue/processors.ts 92.69% <100.00%> (+0.01%) ⬆️
src/selfhost/queue-common.ts 94.84% <100.00%> (+0.19%) ⬆️
src/selfhost/sqlite-queue.ts 99.54% <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.

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

loopover-orb Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Warning

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

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-04 03:17:19 UTC

9 files · 1 AI reviewer · no blockers · readiness 93/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • Touches a guarded path — held for manual review

Review summary
The change consistently threads PR creation time into self-host queue payloads and uses a persisted claim sort key so foreground per-PR re-gate work drains by PR age rather than enqueue time. The SQLite path is covered with behavioral tests, and the Postgres SQL includes the intended duplicate in-flight suppression. The notable remaining risk is coverage/maintainability around the Postgres advisory-lock expression, but I do not see a diff-proven correctness break in the provided hunks.

Nits — 6 non-blocking
  • nit: src/selfhost/pg-queue.ts:899 uses pg_try_advisory_xact_lock directly inside the candidate WHERE clause, so Postgres may evaluate and acquire locks for more candidate rows than the single row ultimately claimed; add a comment or test that documents this intentional tradeoff, or isolate the lock after ordering if you need tighter concurrency semantics.
  • nit: src/selfhost/queue-common.ts:699 hard-codes the legacy fallback base date without explaining why 2000-01-01 sorts correctly relative to real PR creation timestamps; add a short comment because this value now controls durable queue ordering for legacy rows.
  • nit: test/unit/selfhost-pg-queue.test.ts:1008 validates Postgres ordering mostly by asserting SQL text; add a small mocked multi-row claim scenario if the test harness can support it so the ordering behavior is covered, not just the generated query string.
  • In src/selfhost/pg-queue.ts:899, prefer structuring the claim as an ordered candidate CTE followed by the advisory-lock/job-key exclusion on that chosen candidate, or explicitly document why broad advisory-lock evaluation is acceptable for this queue.
  • In src/selfhost/queue-common.ts:699, document the legacy sort base invariant and why PR-number fallback is only for rows without prCreatedAt.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
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 (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 60 registered-repo PR(s), 51 merged, 436 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 60 PR(s), 436 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: 60 PR(s), 436 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • No action.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
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

@JSONbored JSONbored self-assigned this Jul 4, 2026
@JSONbored
JSONbored force-pushed the codex/fix-regate-fifo branch from 8051f43 to c15e2b6 Compare July 4, 2026 03:12
@JSONbored
JSONbored merged commit b01810c into main Jul 4, 2026
13 checks passed
@JSONbored
JSONbored deleted the codex/fix-regate-fifo branch July 4, 2026 03:26
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.

1 participant