fix(selfhost): stop exempting agent-regate-sweep from installation concurrency admission - #2989
Conversation
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-04 09:02:23 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 6 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 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.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2989 +/- ##
=======================================
Coverage 96.06% 96.06%
=======================================
Files 260 260
Lines 28684 28685 +1
Branches 10437 10437
=======================================
+ Hits 27555 27556 +1
Misses 493 493
Partials 636 636
🚀 New features to boost your workflow:
|
…ncurrency admission installationConcurrencyKeyForJob was gated at the sqlite-queue.ts/pg-queue.ts call sites by isForegroundJobPriority(job.priority), but agent-regate-sweep's own row priority (8, PRIORITY_BY_TYPE) equals FOREGROUND_QUEUE_PRIORITY_FLOOR (also 8), so that guard misclassified it as foreground and silently exempted it from the new per-installation concurrency limiter -- exactly the sweep/backfill fan-out this policy was added to bound. Move the exclusion into installationConcurrencyKeyForJob itself, by job type (agent-regate-pr only) rather than by priority, so it can never collide with another type's tuned priority again. Add regression coverage exercising agent-regate-sweep through the limiter in both queue backends.
The fabricated agent-regate-sweep row carried no priority column, which is indistinguishable from a real background job under the old priority-based exclusion guard (isForegroundJobPriority(NaN) is false either way) -- the test passed against both the buggy and fixed code, proving nothing. Construct the row with the real priority (8, PRIORITY_BY_TYPE) via enqueueResult so the test only passes under the new type-based exclusion. Verified by temporarily reintroducing the old priority-based guard: the test now fails against it as expected. Also lock the type-based split at the pure resolver level: assert agent-regate-sweep gets a key despite the same priority-8/floor-8 collision that excludes agent-regate-pr, in the same test.
63f2610 to
c9f5cf4
Compare
Summary
sqlite-queue.ts/pg-queue.tscall sites viaisForegroundJobPriority(job.priority) ? null : installationConcurrencyKeyForJob(message).agent-regate-sweep's own row priority (8,PRIORITY_BY_TYPEinsrc/selfhost/queue-common.ts) exactly equalsFOREGROUND_QUEUE_PRIORITY_FLOOR(also8), soisForegroundJobPriority(8)returnstrueand the limiter was silently inert foragent-regate-sweep— exactly the sweep/backfill fan-out this policy was added to bound (per the feature's own motivating narrative: "one installation's background sweep/backfill claim every available background slot"). A pre-existing test comment already documented this as a known gap and worked around it with a different fixture instead of fixing it.installationConcurrencyKeyForJobitself, keyed by job type (agent-regate-pronly) instead of by priority-floor comparison at the call sites, so it can never collide with another type's tuned priority again.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run typechecknpm run test:coveragenpm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
test/unit/selfhost-installation-concurrency-admission.test.ts,test/unit/selfhost-sqlite-queue.test.ts,test/unit/selfhost-pg-queue.test.ts— 286/286 passing, confirmed via v8 branch coverage that the new type-based branch is hit both ways) rather than the full suite, per this repo's convention of scoping local verification to the affected area for small fixes and letting CI verify the rest.Safety
UI Evidencesection below with screenshots. (N/A — no visible UI changes.)