Skip to content

feat(worker): gate queued runs through scheduler admission - #59

Closed
dporkka wants to merge 21 commits into
codex-bounded-task-schedulerfrom
codex-scheduler-run-admission
Closed

dporkka wants to merge 21 commits into
codex-bounded-task-schedulerfrom
codex-scheduler-run-admission

Conversation

@dporkka

@dporkka dporkka commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Summary

Stacked on #58. Integrate the bounded scheduler into worker run admission without duplicating scheduling logic in the worker.

Behavior

  • adds a fail-closed RunAdmission seam before ExecuteRun
  • composes budget start admission before scheduler admission
  • adds budget.Engine.CheckRunStart so a queued run is denied when active concurrency is already equal to the configured maximum, while preserving existing CheckRun semantics for already-running agents
  • reads per-task scheduler claims from task.metadata.scheduler:
    • owns
    • cpu
    • memory_mb
  • namespaces ownership by repository
  • missing scheduler metadata conservatively claims the whole repository
  • blocked JetStream messages are NAKed with a configurable delay rather than executed or acknowledged
  • worker defaults capacity from host CPU plus configurable memory/max-parallel environment variables

Verification

  • packages/scheduler: go test -race ./... — pass
  • apps/api: go test ./internal/budget ./internal/agentrunner ./pkg/agentexecutor — pass
  • apps/worker: go test ./internal/handlers ./cmd/worker — pass
  • targeted API + worker go vet — pass
  • make build builds API, CLI, worker, runner and TypeScript SDK successfully; web build then stops because the isolated validation environment does not have the Next.js binary installed
  • make lint-go could not run in the isolated validation environment because golangci-lint is not installed

Follow-up

This PR adds safe admission, not execution parallelism. The current worker event callback invokes long-running ExecuteRun synchronously. The next change should add a bounded execution pool that reserves admission atomically before launching work, rather than spawning unbounded goroutines.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@dporkka
dporkka force-pushed the codex-bounded-task-scheduler branch from 89c4f3f to 11a0f12 Compare September 28, 2026 19:37

dporkka commented Sep 28, 2026

Copy link
Copy Markdown
Owner Author

Superseded by the landed scheduler path. PR #60/#63 established atomic ownership/resource admission and task-spec ownership; PR #65 ported the remaining useful budget-start and deferred-redelivery behavior onto current main, with concurrency accounting based on atomic admitting claims. Closing this competing implementation to avoid maintaining two scheduler admission paths.

@dporkka dporkka closed this Sep 28, 2026
Sign up for free to 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.

1 participant