Skip to content

fix(worker-bus): make priority scheduler authoritative - #307

Merged
qnbs merged 6 commits into
mainfrom
fix/workerbus-authoritative-scheduler
Aug 1, 2026
Merged

fix(worker-bus): make priority scheduler authoritative#307
qnbs merged 6 commits into
mainfrom
fix/workerbus-authoritative-scheduler

Conversation

@qnbs

@qnbsqnbs commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • dispatch WorkerBus tasks exclusively through the bounded priority scheduler
  • replace animation-frame pool polling with event-driven availability
  • cover queue wait and execution with the progress-rearmed inactivity watchdog
  • bound critical work with an eight-task reserve and centralize settlement cleanup

Verification

  • WorkerBus: 37 tests passed
  • WorkerPool: 14 tests passed
  • PriorityTaskQueue: 7 tests passed
  • DuckDB client: 23 tests passed
  • local embedding service: 18 tests passed
  • focused Biome and strict tsgo checks passed

Local environment note

The npm exec lint-staged wrapper hung on the constrained workstation. Its underlying Biome command was run directly and passed before the commit; the commit therefore used --no-verify.

CopilotAI review requested due to automatic review settings August 1, 2026 13:13
@vercel

vercelBot commented Aug 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
worldscript-studioReadyReadyPreviewAug 1, 2026 3:23pm

@coderabbitai

coderabbitaiBot commented Aug 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in:26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d104f140-c051-42b3-93f5-8c1675878ae8

📥 Commits

Reviewing files that changed from the base of the PR and between 76d8cfa and 25df3d0.

📒 Files selected for processing (16)
  • AGENTS.md
  • AUDIT.md
  • CLAUDE.md
  • README.md
  • TODO.md
  • docs/adr/0015-worker-generation-consolidation.md
  • packages/worker-bus/src/progressEmitter.ts
  • packages/worker-bus/src/taskQueue.ts
  • packages/worker-bus/src/types.ts
  • packages/worker-bus/src/workerBus.ts
  • packages/worker-bus/src/workerPool.ts
  • packages/worker-bus/tests/progressEmitter.test.ts
  • packages/worker-bus/tests/taskQueue.test.ts
  • packages/worker-bus/tests/workerBus.test.ts
  • packages/worker-bus/tests/workerPool.test.ts
  • tests/e2e/helpers.ts

Comment @coderabbitai help to get the list of available commands.

@codeant-ai

codeant-aiBot commented Aug 1, 2026

Copy link
Copy Markdown

🏁 CodeAnt Quality Gate Results

Commit:ddbdef83
Scan Time: 2026-08-01 13:13:37 UTC

✅ Overall Status: PASSED

Quality Gate Details

Quality GateStatusDetails
Secrets✅ PASSED0 secrets found
Duplicate Code✅ PASSED0.0% duplicated
SAST✅ PASSEDNo security issues
Bugs✅ PASSEDRating S: No bugs
IAC✅ PASSEDNo IAC issues

View Full Results

@deepsource-io

deepsource-ioBot commented Aug 1, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 76d8cfa...25df3d0 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall GradeSecurity

Reliability

Complexity

Hygiene

Code Review Summary

AnalyzerStatusUpdated (UTC)Details
DockerAug 1, 2026 3:22p.m.Review ↗
JavaScriptAug 1, 2026 3:22p.m.Review ↗
PythonAug 1, 2026 3:22p.m.Review ↗
RustAug 1, 2026 3:22p.m.Review ↗
ShellAug 1, 2026 3:22p.m.Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Comment threadpackages/worker-bus/src/workerBus.ts
Comment threadpackages/worker-bus/src/workerBus.ts
Comment threadpackages/worker-bus/src/workerBus.ts
Comment threadpackages/worker-bus/src/workerBus.ts Outdated
Comment threadpackages/worker-bus/src/workerBus.ts Outdated
Comment threadpackages/worker-bus/src/workerBus.ts Outdated
Comment threadpackages/worker-bus/src/workerBus.ts
Comment threadpackages/worker-bus/src/workerPool.ts Outdated
Comment threadpackages/worker-bus/tests/taskQueue.test.ts Outdated
Comment threadpackages/worker-bus/tests/taskQueue.test.ts Outdated

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Makes WorkerBus’s bounded priority scheduler authoritative and replaces pool polling with event-driven dispatch.

Changes:

  • Adds priority/FIFO scheduling with bounded critical-task reserve.
  • Adds enqueue-to-completion inactivity watchdogs and centralized cleanup.
  • Expands regression tests and updates architecture documentation.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
packages/worker-bus/src/workerBus.tsImplements scheduler-driven dispatch and watchdog lifecycle.
packages/worker-bus/src/workerPool.tsAdds non-blocking acquisition and availability notifications.
packages/worker-bus/src/taskQueue.tsAdds runnable-task selection and critical reserve.
packages/worker-bus/src/progressEmitter.tsAdds task progress cleanup.
packages/worker-bus/src/types.tsDocuments timeout semantics and adds saturation event.
packages/worker-bus/tests/workerBus.test.tsTests scheduling, saturation, cleanup, and timeouts.
packages/worker-bus/tests/workerPool.test.tsTests event-driven worker availability.
packages/worker-bus/tests/taskQueue.test.tsTests reserve limits and runnable selection.
docs/adr/0015-worker-generation-consolidation.mdRecords scheduler follow-up resolution.
README.mdUpdates WorkerBus feature description.
TODO.mdRecords completed scheduler hotfix.
AUDIT.mdUpdates release and audit status.
AGENTS.mdUpdates agent architecture guidance.
CLAUDE.mdUpdates WorkerBus guidance and removes resolved debt.

Comment threadpackages/worker-bus/src/workerBus.ts Outdated
Comment threadpackages/worker-bus/src/progressEmitter.ts

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:ddbdef834b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadpackages/worker-bus/src/workerBus.ts Outdated
Comment threadpackages/worker-bus/src/workerBus.ts Outdated
Comment threadpackages/worker-bus/src/workerBus.ts Outdated
Comment threadpackages/worker-bus/src/workerBus.ts Outdated
Comment threadpackages/worker-bus/src/workerBus.ts Outdated
@codecov

codecovBot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.85047% with 39 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
packages/worker-bus/src/workerBus.ts87.75%6 Missing and 24 partials ⚠️
packages/worker-bus/src/workerPool.ts84.21%2 Missing and 4 partials ⚠️
packages/worker-bus/src/progressEmitter.ts89.28%0 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@qnbs

qnbs commented Aug 1, 2026

Copy link
Copy Markdown
OwnerAuthor

@CodeAnt-AI review\n@coderabbitai review

@coderabbitai

coderabbitaiBot commented Aug 1, 2026

Copy link
Copy Markdown

@qnbs I will review pull request #307.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codeant-ai

codeant-aiBot commented Aug 1, 2026

Copy link
Copy Markdown

Question: review\n@coderabbitai review

Answer:

Review findings

[P1] Completed progress streams can remain pending forever

ProgressEmitter.complete() only deletes the listener set:

complete(taskId: string): void{this.listeners.delete(taskId);}

However, iterable(taskId) creates its own iterator state (done, resolveNext) and registers a listener. Deleting the listeners does not mark that iterator as complete or resolve a pending next() call. Consequently, consumers awaiting progress can hang indefinitely after the task settles:

constnext=handle.progress[Symbol.asyncIterator]().next();// task completesawaitnext;// remains pending

This is especially problematic because finalize() now explicitly calls this.progress.complete(...), so the new centralized cleanup path can strand progress consumers.

complete() should notify the per-task async iterable state and resolve any pending next() with { done: true, value: undefined }, while ensuring subsequent next() calls also return done. A regression test should cover both an iterator already waiting on next() and an iterator created after task completion.

Comment threadpackages/worker-bus/src/workerBus.ts
Comment threadpackages/worker-bus/src/workerBus.ts Outdated
@qnbs

qnbs commented Aug 1, 2026

Copy link
Copy Markdown
OwnerAuthor

@CodeAnt-AI review

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:31dffbf143

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadpackages/worker-bus/src/workerBus.ts Outdated
@qnbs

qnbs commented Aug 1, 2026

Copy link
Copy Markdown
OwnerAuthor

@CodeAnt-AI review

@qnbs

qnbs commented Aug 1, 2026

Copy link
Copy Markdown
OwnerAuthor

@CodeAnt-AI review

@qnbs
qnbs merged commit b4bfd7a into mainAug 1, 2026
27 checks passed
@qnbs
qnbs deleted the fix/workerbus-authoritative-scheduler branch August 1, 2026 15:47
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@qnbs