Skip to content

fix(review): stop the re-gate sweep from reordering PRs by repair status - #4411

Merged
JSONbored merged 1 commit into
mainfrom
claude/fix-regate-sweep-fifo-order
Jul 9, 2026
Merged

fix(review): stop the re-gate sweep from reordering PRs by repair status#4411
JSONbored merged 1 commit into
mainfrom
claude/fix-regate-sweep-fifo-order

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • selectRegateCandidates (the scheduled re-gate sweep's candidate picker) sorted a repair-flagged PR (surfaceRepairPriorityPullNumbers -- a PR missing its published public surface or a completed current-head Gate check) ahead of every other candidate, in both staleness and oldest-first order modes, regardless of how stale or how old the ordinary candidates were.
  • With a backlog containing a mix of repaired and ordinary PRs (e.g. after an extended agent pause, where PRs opened during the pause never published anything and need repair, while PRs opened before it are merely stale), this let a newer PR needing repair cut in front of much older PRs that had simply gone stale -- observed live as PRs dispatching out of their creation/staleness order ("spraying") instead of a single, predictable queue order.
  • Repair status now only affects eligibility: it still bypasses the freshness guard (priorityBypassesFreshness) and still keeps a repair candidate in the oldest-first pool even once it already carries a lastRegatedAt stamp (hasRepairPriority). It no longer affects order -- every eligible candidate, repaired or not, is sorted by the same staleness/creation-order key plus the PR-number tiebreak, so a sweep processes its queue in one deterministic order every time, regardless of how many candidates happen to need repair.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves — owner-authored PR fixing a live-observed ordering bug; no separate issue was filed for this follow-up fix.

Validation

  • npm run typecheck
  • npx vitest run test/unit/agent-sweep.test.ts test/unit/queue.test.ts — 783/783 pass, including 3 updated REGRESSION tests (whose expectations flip to reflect the new no-reorder behavior) and one new dedicated regression test (#selfhost-fifo-ordering) added at both the pure-function and full-webhook-integration levels.
  • npm run actionlint / npm run test:workers / npm run build:mcp / npm run test:mcp-pack / npm run ui:openapi:check / npm run ui:lint / npm run ui:typecheck / npm run ui:build / npm audit — not run locally for this focused change; relying on CI (validate) for the full gate.
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries — every affected order-dependent assertion (staleness mode, oldest-first mode, and the full processJob integration test) was re-verified against the new behavior, not just patched to pass.

If any required check was skipped, explain why:

  • This is a narrow, single-concern fix (3 files, no schema/API/UI surface); the full npm run test:ci gate is left to CI per the repo's own established practice for this size of change.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. — N/A, no auth/session surface touched.
  • API/OpenAPI/MCP behavior is updated and tested where needed. — N/A, pure internal sweep-ordering logic, no external surface.
  • UI changes use live API data or real empty/error/loading states. — N/A, no UI changes.
  • Visible UI changes include a UI Evidence section. — N/A, no UI changes.
  • Public docs/changelogs are updated where needed. — N/A, internal scheduling behavior only.

Notes

  • Root-caused live while investigating a report that a repo's re-gate sweep was processing PRs out of order during backlog recovery after an extended agent pause.

selectRegateCandidates sorted a repair-flagged PR (surfaceRepairPriorityPullNumbers --
missing public surface or current Gate check) ahead of every other candidate,
regardless of staleness or creation order. With a mixed backlog of repaired and
ordinary PRs, this let a newer PR needing repair cut ahead of older PRs that had
merely gone stale -- observed live as PRs dispatching out of their creation/
staleness order.

Repair status now only affects eligibility (bypassing the freshness guard, staying
in the oldest-first pool despite already having a regate stamp) -- never final
order. Every eligible PR, repaired or not, is ordered by the same staleness/
creation-order key plus PR-number tiebreak, so a sweep processes its queue in one
deterministic order every time.
@JSONbored JSONbored self-assigned this Jul 9, 2026
@JSONbored JSONbored added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 9, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

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

@JSONbored
JSONbored merged commit 2e7af2b into main Jul 9, 2026
7 checks passed
@JSONbored
JSONbored deleted the claude/fix-regate-sweep-fifo-order branch July 9, 2026 10:49
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.96%. Comparing base (90943c9) to head (fe703c0).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4411      +/-   ##
==========================================
- Coverage   93.96%   93.96%   -0.01%     
==========================================
  Files         401      401              
  Lines       36902    36900       -2     
  Branches    13494    13492       -2     
==========================================
- Hits        34676    34674       -2     
  Misses       1570     1570              
  Partials      656      656              
Files with missing lines Coverage Δ
src/settings/agent-sweep.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Development

Successfully merging this pull request may close these issues.

1 participant