Skip to content

fix(selfhost): backlog-vs-fresh fairness, convergence-cap shadowing, and maintenance admission feedback loop#9233

Merged
JSONbored merged 4 commits into
mainfrom
worktree-agent-ad948fb5137fdddc0
Jul 27, 2026
Merged

fix(selfhost): backlog-vs-fresh fairness, convergence-cap shadowing, and maintenance admission feedback loop#9233
JSONbored merged 4 commits into
mainfrom
worktree-agent-ad948fb5137fdddc0

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Three self-hosted queue fairness/admission bugs, bundled per the ORB backlog convention:

#9153 — backlog-vs-fresh fairness lane inert whenever any unclassified priority-10 webhook is due

claimNextForegroundLane's lane-scoped claim requires beating the best due unclassified foreground
priority with a strict >. githubWebhookPriority returns 10 (equal to fresh's own priority, above
backlog's 9) for nearly every webhook other than a fresh PR open/reopen/synchronize/ready-for-review
event, so on any repo with CI at least one such row is essentially always due — neither lane's priority
can ever satisfy > 10, and both lane claims permanently fall back to plain priority ordering, exactly
the starvation the mechanism exists to prevent.

Added shouldEscapeLanePriorityGate (in queue-fairness.ts): once the oldest due row in the lane being
claimed has waited at least DEFAULT_FOREGROUND_LANE_MAX_STARVE_AGE_MS (10 minutes, mirroring
maintenance-admission's trickle_max_defer_age), the gate is bypassed and the lane's own priority ordering
decides instead of being blocked outright. Wired into both the Postgres and sqlite backends (each computes
the oldest due row's age for the lane being claimed — fresh via a dedicated query, backlog by reusing the
row set already fetched for repo selection).

Judgment call: the issue offered two options (a bounded age escape, or comparing against
claim_sort_key/age directly). Went with the age escape since it's a strictly smaller, more surgical
change that preserves the existing priority-gate semantics in the common case and only changes behavior
once genuine starvation is detected.

#9154 — 5-PR backlog-convergence cap applied before the repair-exhausted filter

selectBacklogConvergenceCandidates sorted oldest-open-first, sliced to 5, and only then did the caller
filter out repair-exhausted PRs — so five old, permanently-unpublishable PRs could occupy every slot
forever, shadowing every other PR needing convergence behind them.

Split the pure ordering into sortedBacklogConvergenceCandidates (unsliced) and had
sweepRepoBacklogConvergence walk that full order, skipping exhausted candidates as it goes and stopping
once max actionable ones are found. selectBacklogConvergenceCandidates becomes a thin
slice-after-sort wrapper for callers that don't need the exhaustion filter (kept for API compatibility).
Also logs + records an audit event (agent.sweep.backlog_convergence, outcome denied) when every
examined candidate is repair-exhausted, so a permanently wedged head of the backlog is visible instead of
the sweep silently returning early every cycle.

Judgment call: didn't add a secondary sort/rotation (the issue's third, optional suggestion) — the
exhaustion filter plus the new audit-visible signal already resolves the "silently stuck forever" failure
mode; a stuck PR now shows up in the audit log every cycle rather than needing a rotation scheme.

#9155live_job_age_high collapses the maintenance lane on normal operation, plus a feedback-loop perf bug

Two compounding defects:

  1. oldestLiveRunnableAgeMs counted a row as active when status='processing' OR due-pending, so a
    normal in-flight job (a routine multi-minute AI review) alone pushed the age past maxLiveJobAgeMs
    for its whole duration, tripping live_job_age_high with no drain escape and collapsing the whole
    maintenance lane — including the watchdog/alerter that would report an actual overload — to the 4-hour
    trickle backstop. Narrowed oldest_runnable's own filter to 'pending' AND due rows only, excluding
    'processing' entirely.
  2. Every claimed maintenance job recomputes maintenancePressureSignals' four aggregate scans, and a
    denial returns true from processOne(), so the pump loop immediately claims the next due maintenance
    row and repeats — a burst of N due maintenance rows means 4N sequential scans in one tight loop (a
    positive feedback loop: more denials → more scans → higher load → more denials). Added a short-TTL
    (default 1.5s, configurable via MAINTENANCE_ADMISSION_PRESSURE_CACHE_TTL_MS) memoized wrapper shared
    by the admission check and the pressureSignals() observability method, in both backends. Also added a
    partial index on (is_maintenance, status) for the maintenance-lane aggregate, which previously had no
    supporting index at all.

Judgment call: chose a fixed drain-escape-free fix (exclude processing from the age signal) rather
than adding a second drain escape to live_job_age_high — the issue offered both options, and excluding
processing is the more precise fix since the underlying problem is that the signal conflates "running"
with "starved," not that the escape mechanism itself is missing.

Test plan

  • npx tsc --noEmit -p tsconfig.json --incremental false — clean
  • npx vitest run test/unit/selfhost-sqlite-queue.test.ts test/unit/selfhost-pg-queue.test.ts test/unit/selfhost-queue-fairness.test.ts test/unit/selfhost-backlog-convergence.test.ts test/unit/selfhost-maintenance-admission.test.ts test/unit/queue-2.test.ts — 552 passed
  • npm run selfhost:env-reference regenerated (new MAINTENANCE_ADMISSION_PRESSURE_CACHE_TTL_MS env var)
  • npm run db:schema-drift:check / npm run db:migrations:check — clean (the new partial indexes are
    self-managed idempotent DDL inside pg-queue.ts/sqlite-queue.ts, not versioned D1 migrations, so no
    new migration file is needed)
  • Rebased on latest main; re-typechecked and re-ran the full relevant test set post-rebase

Closes #9153
Closes #9154
Closes #9155

…riority gate

The lane-scoped foreground claim requires beating the best due unclassified
priority, but githubWebhookPriority returns 10 (equal to fresh's own priority,
above backlog's 9) for nearly every webhook other than a fresh PR open/reopen/
synchronize/ready-for-review event. On any repo with CI at least one such row
is essentially always due, so neither lane's priority can ever satisfy the
strict `>` gate and both lane claims permanently fall back to plain priority
ordering -- the exact starvation the fairness mechanism exists to prevent.

Add shouldEscapeLanePriorityGate: once the oldest due row in the lane being
claimed has waited at least DEFAULT_FOREGROUND_LANE_MAX_STARVE_AGE_MS (10
minutes, mirroring maintenance-admission's trickle_max_defer_age), the gate
is bypassed so an old lane row can win on its own merits.

Closes #9153
Wires shouldEscapeLanePriorityGate into claimNextForegroundLane for both the
Postgres and sqlite queue backends: each computes the oldest due row's age
for the lane being claimed (fresh via a dedicated query, backlog by reusing
the row set already fetched for repo selection) and falls back to the plain
`>=` floor once that age crosses the bounded threshold, instead of staying
permanently gated behind an unclassified priority-10 webhook.

Includes regression tests for both backends covering the escape arm (an aged
backlog row wins preferentially) and the control arm (a fresh backlog row
stays gated this cycle), plus a fix to a pre-existing pg-queue test whose
placeholder created_at (an epoch-adjacent 1000ms) incidentally tripped the
new age escape.

Closes #9153
…ence cap

selectBacklogConvergenceCandidates sorted oldest-open-first, sliced to `max`,
and only then did the caller filter out repair-exhausted PRs -- so five old,
permanently-unpublishable PRs could occupy every slot forever, shadowing the
6th+ PR needing convergence behind them indefinitely.

Split the pure ordering out into sortedBacklogConvergenceCandidates (unsliced)
and have sweepRepoBacklogConvergence walk that full order, skipping exhausted
candidates as it goes and stopping once `max` actionable ones are found --
selectBacklogConvergenceCandidates itself becomes a thin slice-after-sort
wrapper over the new function for callers that don't need the exhaustion
filter. Also logs + records an audit event when every examined candidate is
repair-exhausted, so a permanently wedged head of the backlog is visible
instead of the sweep silently returning early every cycle.

Closes #9154
…e pressure signals

Two compounding defects in maintenance admission:

- oldestLiveRunnableAgeMs was computed over rows that are either 'processing'
  or due-and-pending, so a normal in-flight job (a routine multi-minute AI
  review) alone pushed the age past maxLiveJobAgeMs for its whole duration,
  tripping live_job_age_high with no drain escape and collapsing the entire
  maintenance lane -- including the watchdog/alerter that would report an
  actual overload -- to the 4-hour trickle backstop. Narrow oldest_runnable's
  own FILTER to 'pending AND due' rows only, excluding 'processing' entirely.

- Every claimed maintenance job recomputes maintenancePressureSignals' four
  aggregate scans, and a denial returns `true` from processOne(), so the pump
  loop immediately claims the next due maintenance row and repeats -- a burst
  of N due maintenance rows means 4N sequential scans in one tight loop, a
  positive feedback loop (more denials -> more scans -> higher load -> more
  denials). Add a short-TTL (default 1.5s, configurable via
  MAINTENANCE_ADMISSION_PRESSURE_CACHE_TTL_MS) memoized wrapper shared by the
  admission check and the pressureSignals() observability method, in both
  the Postgres and sqlite backends. Also add a partial index on
  (is_maintenance, status) for the maintenance-lane aggregate, which
  previously had no supporting index.

Closes #9155
@superagent-security

Copy link
Copy Markdown
Contributor

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

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
loopover-ui 45536f7 Commit Preview URL

Branch Preview URL
Jul 27 2026, 08:17 AM

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 92 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
loopover-ui 7.43MB 92 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: loopover-ui

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/add-scalar-classes-C0JV9rmt.js (New) 2.17MB 2.17MB 100.0% 🚀
assets/tanstack-vendor-DxO72oY9.js (New) 804.04kB 804.04kB 100.0% 🚀
assets/docs.fumadocs-spike-api-reference-C0ENZhFG.js (New) 442.88kB 442.88kB 100.0% 🚀
assets/AgentScalarChatInterface.vue-mq-im4N0.js (New) 201.71kB 201.71kB 100.0% 🚀
assets/modal-WSK241Uo.js (New) 184.39kB 184.39kB 100.0% 🚀
assets/client-FfJIHLW2.js (New) 146.06kB 146.06kB 100.0% 🚀
assets/self-hosting-configuration-ClqfkLcC.js (New) 101.69kB 101.69kB 100.0% 🚀
assets/maintainer-panel-CubX_ySD.js (New) 79.0kB 79.0kB 100.0% 🚀
assets/routes-CVyvZunU.js (New) 35.96kB 35.96kB 100.0% 🚀
assets/owner-panel-CpksdiWQ.js (New) 27.52kB 27.52kB 100.0% 🚀
assets/app-eQGS1YB8.js (New) 25.78kB 25.78kB 100.0% 🚀
assets/ui-vendor-D1BegFY0.js (New) 22.28kB 22.28kB 100.0% 🚀
assets/miner-panel-B-PJLFXN.js (New) 20.24kB 20.24kB 100.0% 🚀
assets/app.runs-C3nKiNif.js (New) 20.22kB 20.22kB 100.0% 🚀
assets/api._op-C8YZYk7C.js (New) 17.57kB 17.57kB 100.0% 🚀
assets/self-hosting-docs-audit-cwnlBOdI.js (New) 16.6kB 16.6kB 100.0% 🚀
assets/docs._slug-DesQt1xw.js (New) 15.37kB 15.37kB 100.0% 🚀
assets/playground-panel-BBBkGYHc.js (New) 14.43kB 14.43kB 100.0% 🚀
assets/fairness-DhtCA9eH.js (New) 10.73kB 10.73kB 100.0% 🚀
assets/app.audit-DdgEeRPb.js (New) 10.08kB 10.08kB 100.0% 🚀
assets/app.config-generator-RD5o_uDh.js (New) 10.06kB 10.06kB 100.0% 🚀
assets/maintainers-CWBaikcj.js (New) 8.06kB 8.06kB 100.0% 🚀
assets/miners-C_jjESor.js (New) 7.91kB 7.91kB 100.0% 🚀
assets/agents-BusCuptn.js (New) 7.74kB 7.74kB 100.0% 🚀
assets/commands-panel-CmlZStiF.js (New) 6.65kB 6.65kB 100.0% 🚀
assets/maintainer-workflow-P55v7viC.js (New) 6.52kB 6.52kB 100.0% 🚀
assets/digest-panel-BkXsFKY5.js (New) 6.15kB 6.15kB 100.0% 🚀
assets/repos._owner._repo.quality-B7D1ZjB9.js (New) 6.14kB 6.14kB 100.0% 🚀
assets/docs-nav-G2EsWOpX.js (New) 5.95kB 5.95kB 100.0% 🚀
assets/docs.index-BeHsynZD.js (New) 5.95kB 5.95kB 100.0% 🚀
assets/api.index-CB5_W__c.js (New) 4.7kB 4.7kB 100.0% 🚀
assets/docs-DJigbHrD.js (New) 2.7kB 2.7kB 100.0% 🚀
assets/api-DyKnNoVS.js (New) 2.69kB 2.69kB 100.0% 🚀
assets/docs-page-eEGrbKD6.js (New) 2.1kB 2.1kB 100.0% 🚀
assets/table-BxusdyTV.js (New) 1.75kB 1.75kB 100.0% 🚀
assets/app.workbench-ZFSwaeCC.js (New) 1.58kB 1.58kB 100.0% 🚀
assets/tabs-DEAVeTSn.js (New) 1.39kB 1.39kB 100.0% 🚀
assets/app.repos-BAIUW4aj.js (New) 1.07kB 1.07kB 100.0% 🚀
assets/input-CUv8IIsN.js (New) 796 bytes 796 bytes 100.0% 🚀
assets/file-cog-C8j9fpmB.js (New) 758 bytes 758 bytes 100.0% 🚀
assets/app.maintainer-DFar9tOq.js (New) 502 bytes 502 bytes 100.0% 🚀
assets/app.owner-Cg6Tw-sF.js (New) 474 bytes 474 bytes 100.0% 🚀
assets/app.commands-CoICUyol.js (New) 455 bytes 455 bytes 100.0% 🚀
assets/app.playground-CIp3SexU.js (New) 442 bytes 442 bytes 100.0% 🚀
assets/index-Kas1DX7F.js (New) 438 bytes 438 bytes 100.0% 🚀
assets/app.digest-BuQsT_U3.js (New) 430 bytes 430 bytes 100.0% 🚀
assets/eye-off-L6OVLhz6.js (New) 430 bytes 430 bytes 100.0% 🚀
assets/app.miner-CB-yAbdx.js (New) 422 bytes 422 bytes 100.0% 🚀
assets/key-round-D9oyCsiS.js (New) 355 bytes 355 bytes 100.0% 🚀
assets/bot-BBFEgwB5.js (New) 328 bytes 328 bytes 100.0% 🚀
assets/trash-2-Ztqsn7Bf.js (New) 328 bytes 328 bytes 100.0% 🚀
assets/save-CKbQMCMJ.js (New) 327 bytes 327 bytes 100.0% 🚀
assets/git-pull-request-arrow-BdoSbze2.js (New) 321 bytes 321 bytes 100.0% 🚀
assets/list-checks-C4f7Mxpn.js (New) 279 bytes 279 bytes 100.0% 🚀
assets/compass-BedXqa4H.js (New) 251 bytes 251 bytes 100.0% 🚀
assets/history-CtYoFLe0.js (New) 237 bytes 237 bytes 100.0% 🚀
assets/message-square-C4XWD3En.js (New) 233 bytes 233 bytes 100.0% 🚀
assets/lock-DeFmen9i.js (New) 206 bytes 206 bytes 100.0% 🚀
assets/rotate-cw-4Zl87BJJ.js (New) 201 bytes 201 bytes 100.0% 🚀
assets/play-DPO2TZqX.js (New) 190 bytes 190 bytes 100.0% 🚀
assets/circle-check-DAH9Ftky.js (New) 178 bytes 178 bytes 100.0% 🚀
assets/search-DYjfqM0n.js (New) 174 bytes 174 bytes 100.0% 🚀
assets/add-scalar-classes-C7lyb3Lm.js (Deleted) -2.17MB 0 bytes -100.0% 🗑️
assets/tanstack-vendor-CU40gYNJ.js (Deleted) -804.04kB 0 bytes -100.0% 🗑️
assets/docs.fumadocs-spike-api-reference-rSxjBJgD.js (Deleted) -442.88kB 0 bytes -100.0% 🗑️
assets/AgentScalarChatInterface.vue-BQzDzcQl.js (Deleted) -201.71kB 0 bytes -100.0% 🗑️
assets/modal-CcbYYGKq.js (Deleted) -184.39kB 0 bytes -100.0% 🗑️
assets/client-B6J6msoT.js (Deleted) -146.06kB 0 bytes -100.0% 🗑️
assets/self-hosting-configuration-Befldias.js (Deleted) -101.6kB 0 bytes -100.0% 🗑️
assets/maintainer-panel-C1ixBXGW.js (Deleted) -79.0kB 0 bytes -100.0% 🗑️
assets/routes-Q7O2gpEI.js (Deleted) -35.96kB 0 bytes -100.0% 🗑️
assets/owner-panel-ChXpQI-h.js (Deleted) -27.52kB 0 bytes -100.0% 🗑️
assets/app-DDj7pzTG.js (Deleted) -25.78kB 0 bytes -100.0% 🗑️
assets/ui-vendor-azmdXeTB.js (Deleted) -22.28kB 0 bytes -100.0% 🗑️
assets/miner-panel-CU3d3RIa.js (Deleted) -20.24kB 0 bytes -100.0% 🗑️
assets/app.runs-CVI9vMG0.js (Deleted) -20.22kB 0 bytes -100.0% 🗑️
assets/api._op-CsmVsrdB.js (Deleted) -17.57kB 0 bytes -100.0% 🗑️
assets/self-hosting-docs-audit-CskkxX_i.js (Deleted) -16.6kB 0 bytes -100.0% 🗑️
assets/docs._slug-B5ulGkWb.js (Deleted) -15.37kB 0 bytes -100.0% 🗑️
assets/playground-panel-BREt4XE5.js (Deleted) -14.43kB 0 bytes -100.0% 🗑️
assets/fairness-CcDfl1Sc.js (Deleted) -10.73kB 0 bytes -100.0% 🗑️
assets/app.audit-BKiMJEVB.js (Deleted) -10.08kB 0 bytes -100.0% 🗑️
assets/app.config-generator-D573cG3S.js (Deleted) -10.06kB 0 bytes -100.0% 🗑️
assets/maintainers-41DNlhdm.js (Deleted) -8.06kB 0 bytes -100.0% 🗑️
assets/miners-BBsxtfut.js (Deleted) -7.91kB 0 bytes -100.0% 🗑️
assets/agents-C-CEBvQU.js (Deleted) -7.74kB 0 bytes -100.0% 🗑️
assets/commands-panel-CrmyLCUk.js (Deleted) -6.65kB 0 bytes -100.0% 🗑️
assets/maintainer-workflow-Dns62Sky.js (Deleted) -6.52kB 0 bytes -100.0% 🗑️
assets/digest-panel-BpYRl76k.js (Deleted) -6.15kB 0 bytes -100.0% 🗑️
assets/repos._owner._repo.quality-CsUH3Z9s.js (Deleted) -6.14kB 0 bytes -100.0% 🗑️
assets/docs-nav-CLSqC3NK.js (Deleted) -5.95kB 0 bytes -100.0% 🗑️
assets/docs.index-C6GZnSYw.js (Deleted) -5.95kB 0 bytes -100.0% 🗑️
assets/api.index-9UDI4hEo.js (Deleted) -4.7kB 0 bytes -100.0% 🗑️
assets/docs-Bf8emTRf.js (Deleted) -2.7kB 0 bytes -100.0% 🗑️
assets/api-BijUoLLs.js (Deleted) -2.69kB 0 bytes -100.0% 🗑️
assets/docs-page-DUH_t2T8.js (Deleted) -2.1kB 0 bytes -100.0% 🗑️
assets/table-BeeIcXFZ.js (Deleted) -1.75kB 0 bytes -100.0% 🗑️
assets/app.workbench-DNSrCRg3.js (Deleted) -1.58kB 0 bytes -100.0% 🗑️
assets/tabs-DGQQYHWk.js (Deleted) -1.39kB 0 bytes -100.0% 🗑️
assets/app.repos-CSKBhYgT.js (Deleted) -1.07kB 0 bytes -100.0% 🗑️
assets/input-Av4nSpuF.js (Deleted) -796 bytes 0 bytes -100.0% 🗑️
assets/file-cog-C_obDxP7.js (Deleted) -758 bytes 0 bytes -100.0% 🗑️
assets/app.maintainer-amI3totg.js (Deleted) -502 bytes 0 bytes -100.0% 🗑️
assets/app.owner-BeIL8gMB.js (Deleted) -474 bytes 0 bytes -100.0% 🗑️
assets/app.commands-C9roQDJc.js (Deleted) -455 bytes 0 bytes -100.0% 🗑️
assets/app.playground-DuXF6ZLb.js (Deleted) -442 bytes 0 bytes -100.0% 🗑️
assets/index-xZ8eROcE.js (Deleted) -438 bytes 0 bytes -100.0% 🗑️
assets/app.digest-C0NBhMyF.js (Deleted) -430 bytes 0 bytes -100.0% 🗑️
assets/eye-off-B1Px2r2P.js (Deleted) -430 bytes 0 bytes -100.0% 🗑️
assets/app.miner-BjF0xmUT.js (Deleted) -422 bytes 0 bytes -100.0% 🗑️
assets/key-round-B9xcTrqI.js (Deleted) -355 bytes 0 bytes -100.0% 🗑️
assets/bot-C2CCRb5z.js (Deleted) -328 bytes 0 bytes -100.0% 🗑️
assets/trash-2-DgYL1ub5.js (Deleted) -328 bytes 0 bytes -100.0% 🗑️
assets/save-DsLSESc9.js (Deleted) -327 bytes 0 bytes -100.0% 🗑️
assets/git-pull-request-arrow-MGihYq-8.js (Deleted) -321 bytes 0 bytes -100.0% 🗑️
assets/list-checks-C7FHMEFQ.js (Deleted) -279 bytes 0 bytes -100.0% 🗑️
assets/compass-BB6r6fuI.js (Deleted) -251 bytes 0 bytes -100.0% 🗑️
assets/history-BgyxzvBS.js (Deleted) -237 bytes 0 bytes -100.0% 🗑️
assets/message-square--Y7cspS1.js (Deleted) -233 bytes 0 bytes -100.0% 🗑️
assets/lock-PDAGuBk_.js (Deleted) -206 bytes 0 bytes -100.0% 🗑️
assets/rotate-cw-iG8QjHTE.js (Deleted) -201 bytes 0 bytes -100.0% 🗑️
assets/play-CSGA7_0g.js (Deleted) -190 bytes 0 bytes -100.0% 🗑️
assets/circle-check-Cok123j4.js (Deleted) -178 bytes 0 bytes -100.0% 🗑️
assets/search-C9SRST_o.js (Deleted) -174 bytes 0 bytes -100.0% 🗑️

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.61905% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.74%. Comparing base (194fa65) to head (45536f7).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/queue/processors.ts 92.30% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9233      +/-   ##
==========================================
- Coverage   93.94%   92.74%   -1.21%     
==========================================
  Files         825      825              
  Lines       81835    81866      +31     
  Branches    24849    24856       +7     
==========================================
- Hits        76882    75923     -959     
- Misses       3558     4838    +1280     
+ Partials     1395     1105     -290     
Flag Coverage Δ
backend 93.54% <97.61%> (-1.68%) ⬇️

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

Files with missing lines Coverage Δ
src/selfhost/backlog-convergence.ts 100.00% <100.00%> (ø)
src/selfhost/maintenance-admission.ts 100.00% <100.00%> (ø)
src/selfhost/queue-fairness.ts 100.00% <100.00%> (ø)
src/selfhost/sqlite-queue.ts 99.63% <100.00%> (+0.01%) ⬆️
src/queue/processors.ts 94.96% <92.30%> (-0.02%) ⬇️

... and 3 files with indirect coverage changes

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

loopover-orb Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - fixes required

Review updated: 2026-07-27 09:06:26 UTC

13 files · 1 AI reviewer · no blockers · CI failing · unstable

🛑 Suggested Action - Manual Review

Review summary
This bundles three distinct self-host queue fixes (#9153 lane-priority starvation, #9154 backlog-convergence cap-before-filter ordering, #9155 maintenance pressure signal correctness+memoization+index), each traced to a real reachable bug and each backed by regression tests that assert on the actual SQL/predicate emitted rather than mocked-only outcomes. The #9153 fix correctly bypasses the unsatisfiable `>` gate only once the oldest due lane row crosses a bounded age, preserving the gate in the common case (verified by both an escape-arm and control-arm test on pg and sqlite backends). The #9154 fix correctly moves the repair-exhaustion filter ahead of the 5-PR cap by walking the full oldest-first order and capping only actionable candidates. #9155's oldest_runnable fix (excluding 'processing' rows) and the pressure-signals cache/dedup are both plausible and covered by targeted tests (including a TTL=0 control).

Nits — 6 non-blocking
  • src/queue/processors.ts:1868-1875 — the exhaustion walk now `await`s `isRegateRepairExhausted` one PR at a time instead of the old `Promise.all` batch; if many old PRs are exhausted before an actionable one, this serializes N sequential round-trips where before it was parallel (bounded, but worth batching in chunks if repos with long exhausted streaks are common).
  • src/selfhost/pg-queue.ts:1183 / src/selfhost/sqlite-queue.ts — `oldestDueForegroundLaneAgeMs` issues one extra query on every fresh-lane claim cycle (even when the gate won't need the escape), a minor added round-trip per claim.
  • src/selfhost/queue-fairness.ts's `oldestDueForegroundLaneAgeMs`/`shouldEscapeLanePriorityGate` accept a generic `"fresh"|"backlog"` lane param but the backlog arm is, per the doc comment, never actually invoked with `"backlog"` — effectively dead code path worth simplifying or documenting more explicitly.
  • The three touched queue files (`pg-queue.ts` ~1263 lines, `sqlite-queue.ts` ~1559 lines, `processors.ts` ~1903 lines) continue to grow past typical single-file size — consistent with existing repo convention, but flagging for awareness.
  • Consider chunking `isRegateRepairExhausted` checks (e.g. small batches via `Promise.all`) in `sweepRepoBacklogConvergence`'s walk loop to avoid fully serial latency on repos with long exhausted-PR runs (src/queue/processors.ts:1868).
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.

CI checks failing

  • codecov/patch — 97.61% of diff hit (target 99.00%)

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 #9153, #9154, #9155
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 (3 linked issues).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 13 registered-repo PR(s), 13 merged, 331 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 13 PR(s), 331 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Linked issue satisfaction

Addressed
The PR adds a bounded age escape (shouldEscapeLanePriorityGate, mirroring trickle_max_defer_age) that bypasses the unsatisfiable strict '>' gate in both pg-queue.ts and sqlite-queue.ts once the oldest due lane row exceeds a starve threshold, directly resolving the described starvation, and includes regression tests covering both the escape and control (non-escape) arms as required.

Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, Ruby, Go, MDX, Shell, Solidity, JavaScript
  • Official Gittensor activity: 13 PR(s), 331 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Treat this as maintainer-lane context rather than normal contributor-lane activity.
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.

Decision record
  • action: hold · clause: success
  • config: 03a7f8b529a9 · pack: oss-anti-slop
  • record: 426ee3e7a8e3 (schema v3, head 45536f7)

🟩 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 added the manual-review Gittensor contributor context label Jul 27, 2026
@JSONbored
JSONbored merged commit b4ccfe7 into main Jul 27, 2026
10 of 11 checks passed
@JSONbored
JSONbored deleted the worktree-agent-ad948fb5137fdddc0 branch July 27, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment