Skip to content

feat(task): add weighted task slots - #234

Merged
moshloop merged 1 commit into
mainfrom
chore/oipa-sync-20261022
Nov 2, 2026
Merged

moshloop merged 1 commit into
mainfrom
chore/oipa-sync-20261022

Conversation

@moshloop

@moshloop moshloop commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

What

  • Add weighted task slots so a task can reserve more than one unit of capacity via WithSlots.
  • Allow zero-slot tasks to be dispatched through supervisors, so a supervisor can await child tasks without holding an ordinary worker slot.
  • Include active supervisors in foreground waits.

Why

  • Supervisors that wait on child tasks should not consume worker slots that those children need, which could otherwise stall dispatch.
  • Global and group capacity limits still apply.

Notes

  • Touches aliases.go, task/group_admission.go, task/manager.go, task/manager_wait.go, task/slots.go, task/task.go, task/task_wait.go, and task/worker.go.
  • Adds Ginkgo tests in task/slots_ginkgo_test.go.

Summary by CodeRabbit

  • New Features
    • Added task slot configuration to control how much shared and group capacity a task reserves.
    • Added zero-slot supervisor tasks that can run while regular task capacity is occupied. They can wait for child tasks and remain included in completion waits.
    • Tasks continue to hold their reserved capacity until their callbacks finish, and cancellation waits for supervisor callbacks to return.
    • Added the WithSlots option to the package-level API for backward compatibility.

Allow supervisors to await child tasks without consuming ordinary worker slots while still respecting global and group capacity.
Expose WithSlots for weighted reservations, dispatch zero-slot tasks through supervisors, and include active supervisors in foreground waits.
@moshloop
moshloop enabled auto-merge (rebase) November 2, 2026 05:19
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0b75bc14-9138-46ec-bd65-3b89489e4b47
Commits

Reviewing files that changed from the base of the PR and between d234938 and 1bec767.

Files selected for processing: 9
  • aliases.go
  • task/group_admission.go
  • task/manager.go
  • task/manager_wait.go
  • task/slots.go
  • task/slots_ginkgo_test.go
  • task/task.go
  • task/task_wait.go
  • task/worker.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Tasks can reserve weighted global and group capacity through WithSlots. Zero-slot tasks run through supervisor dispatch outside the ordinary worker pool. Worker completion and foreground wait tracking account for the updated task paths.

Changes

Task slot scheduling

Layer / File(s) Summary
Slot contract and capacity admission
task/task.go, task/slots.go, aliases.go, task/manager.go, task/group_admission.go, task/slots_ginkgo_test.go
Tasks now default to one slot. WithSlots sets the reservation and panics for negative values. Manager and group admission use weighted slot counts. Tests cover negative and over-capacity reservations.
Worker reservation and completion
task/worker.go, task/slots_ginkgo_test.go
Workers reserve slots before group admission and retry when capacity is unavailable. Completion releases reserved slots and group permits. A test checks weighted capacity remains reserved until the callback returns.
Supervisor dispatch and wait tracking
task/manager.go, task/slots.go, task/task_wait.go, task/manager_wait.go, task/slots_ginkgo_test.go
Zero-slot tasks use supervisor dispatch and check dependencies before execution. Group semaphore waits skip zero-slot tasks, while foreground wait tracking includes active supervisors. Tests cover nested supervisors, dependency failure, waits, and cancellation drain.

Sequence Diagram(s)

sequenceDiagram
  participant Manager
  participant SupervisorWorker
  participant TaskDependencies
  participant Worker
  Manager->>SupervisorWorker: Dispatch zero-slot task to runSupervisor
  SupervisorWorker->>TaskDependencies: Check task dependencies
  TaskDependencies-->>SupervisorWorker: Report dependencies ready
  SupervisorWorker->>Worker: Call finishTask for the task
Loading

Possibly related PRs

  • flanksource/clicky#231: Changes task scheduling, group admission, worker dispatch, and permit release that this PR extends with weighted slots and zero-slot supervisors.

Suggested reviewers: flanksource

Change: Feature

Merge Risk: Minimal · up to 1bec7

The slot and supervisor paths appear ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description states the purpose and the changed files. It covers the What and Why sections and lists the touched files and test file. It does not follow the repository template. It omits the Descri… Rewrite the description to follow the repository template. Use the Description heading with a brief summary. Check the New feature box under Type of Change. Check the Testing boxes that apply, and state whether the CLI was tested with examp…
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "feat(task): add weighted task slots" matches the main change. The changeset adds WithSlots, a per-task slot reservation, and changes worker, group admission, and supervisor dispatch to use …
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(task): add weighted task slots" matches the main change. The changeset adds WithSlots, a per-task slot reservation, and changes worker, group admission, and supervisor dispatch to use it. The title is specific and concise, and it names the primary feature.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 9 files.

Full details: Description check

Explanation

The description states the purpose and the changed files. It covers the What and Why sections and lists the touched files and test file. It does not follow the repository template. It omits the Description heading and the Type of Change, Testing, Checklist, Breaking Changes, and Additional Notes sections. The author did not mark any type of change or any testing checkbox. The change adds a new exported API (WithSlots) and changes dispatch behavior for zero-slot tasks, so the author should state whether this is a breaking change and fill in the Breaking Changes section. Testing status is also unstated.

Resolution

Rewrite the description to follow the repository template. Use the Description heading with a brief summary. Check the New feature box under Type of Change. Check the Testing boxes that apply, and state whether the CLI was tested with example data. Complete the checklist items that apply, including documentation updates for the new WithSlots API. Fill in the Breaking Changes section. State that the change is non-breaking if it is. Add any notes in the Additional Notes section.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Gavel summary

Source Pass Fail Skip Duration
lint: oxlint 0 1 0 160ms
lint: betterleaks 0 0 1 -
lint: golangci-lint 1 0 0 55.5s
lint: react-doctor 1 0 0 5.6s
lint: tsc 2 0 0 4.9s

Totals: 4 passed · 1 failed · 1 skipped · 1m6s

Failing linters

oxlint — 3 violation(s)

  • /home/runner/work/clicky/clicky/examples/enitity/webapp/src/api.ts:53 — Empty fallbacks in spreads are unnecessary (oxlint)
  • /home/runner/work/clicky/clicky/examples/enitity/webapp/src/api.ts:133 — Empty fallbacks in spreads are unnecessary (oxlint)
  • /home/runner/work/clicky/clicky/examples/enitity/webapp/src/LinkExamplesPage.tsx:217 — Empty fallbacks in spreads are unnecessary (oxlint)

View full results

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Gavel summary

Source Pass Fail Skip Duration
aichat 24 0 0 2ms
api 342 0 0 17ms
cache 28 0 0 122ms
celfilter 14 0 9 16ms
clicky 129 0 0 10.7s
clirender 18 0 0 789.479µs
enitity 1 0 0 5.5s
entity 171 0 0 127ms
entitydemo 1 0 0 1ms
excel 37 0 0 140ms
exec 153 0 1 12.8s
extensions 1 0 0 76.686µs
filter 10 0 3 1ms
flags 41 0 0 1ms
formatters 85 0 0 11ms
github.com/flanksource/clicky 28 0 0 2.9s
github.com/flanksource/clicky/api 258 0 0 160ms
github.com/flanksource/clicky/api/tailwind 434 0 0 -
github.com/flanksource/clicky/api/wasmtest 1 0 0 350ms
github.com/flanksource/clicky/cmd/clicky 4 0 0 10ms
github.com/flanksource/clicky/docs 19 0 0 50ms
github.com/flanksource/clicky/entity 153 0 0 10ms
github.com/flanksource/clicky/examples/enitity/internal/entitydemo 7 0 0 -
github.com/flanksource/clicky/exec 3 0 0 360ms
github.com/flanksource/clicky/flags 53 0 0 -
github.com/flanksource/clicky/formatters 77 0 1 60ms
github.com/flanksource/clicky/formatters/http 38 0 0 -
github.com/flanksource/clicky/formatters/tests 201 0 1 10ms
github.com/flanksource/clicky/internal/gumchoose 2 0 0 -
github.com/flanksource/clicky/lint 13 0 0 -
github.com/flanksource/clicky/markdown 10 0 0 40ms
github.com/flanksource/clicky/mcp 102 0 0 3.1s
github.com/flanksource/clicky/middleware 31 0 0 -
github.com/flanksource/clicky/prompt 15 0 0 -
github.com/flanksource/clicky/route 12 0 0 -
github.com/flanksource/clicky/rpc 378 0 1 -
github.com/flanksource/clicky/rpc/http 8 0 0 10ms
github.com/flanksource/clicky/task 169 0 0 24.1s
github.com/flanksource/clicky/valkey 1 0 0 310ms
gomplatefilter 2 0 0 4ms
http 5 0 0 340.743µs
lint 16 0 0 12.0s
markdown 9 0 0 41ms
mcp 4 0 0 5ms
metrics 17 0 0 3.0s
middleware 38 0 0 2ms
process 46 0 0 1.7s
rpc 59 0 0 1.8s
schemaform 61 0 0 1.7s
sse 74 0 0 1.8s
task 115 0 0 8.0s
tests 11 0 47 2ms
text 78 0 0 304ms
urlfetch 4 0 0 2ms
valkey 46 0 0 308ms

Totals: 3657 passed · 0 failed · 63 skipped · 1m32s

View full results

@moshloop
moshloop merged commit 19fcf2e into main Nov 2, 2026
15 of 16 checks passed
@moshloop
moshloop deleted the chore/oipa-sync-20261022 branch November 2, 2026 05:25
@flankbot

flankbot commented Nov 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.21.92

@coderabbitai coderabbitai Bot mentioned this pull request Nov 4, 2026
15 of 16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants