Skip to content

fix: reserve long-poll capacity for worker startup - #26751

Open
1aifanatic wants to merge 3 commits into
stablyai:mainfrom
1aifanatic:fix/check-poll-capacity-reservation
Open

1aifanatic wants to merge 3 commits into
stablyai:mainfrom
1aifanatic:fix/check-poll-capacity-reservation

Conversation

@1aifanatic

@1aifanatic 1aifanatic commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Repeated waiting checks can no longer fill every request slot and block worker startup. Capacity errors now say how many slots are occupied, and server operators can configure the total limit.

What Changed

Waiting orchestration checks have a separate limit of half the long-poll pool. Checks, questions and browser hosts together may use three quarters, preserving space for worker startup and other waits. Socket and WebSocket requests share these counters and release them on completion or disconnect.

The server reads ORCA_RPC_LONG_POLL_CAP at construction, accepting positive safe integers and otherwise retaining the default of 16. An explicit server option takes precedence. Existing runtime_busy errors include total and per-class occupancy; the remote-server guide documents the setting.

Why

Increasing the global limit alone would let persistent checks fill the larger pool again. Extending the existing admission limits reserves launch capacity while preserving the current retry error code and transport behavior.

Linked Issue

Fixes #19342

Visual Proof

N/A - server request admission and diagnostic text only; no rendered UI change.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Windows, Node 24.21.0, ORCA_BACKGROUND_LAUNCH=1: all 33 tests pass across runtime-rpc-check-admission, runtime-rpc-browser-host-admission, runtime-rpc-websocket-long-poll-caps and runtime-rpc-long-poll-transport suites. Coverage includes mixed check/question/browser occupancy with launch capacity remaining, invalid configuration, explicit-option precedence, overflow diagnostics, and socket disconnect cleanup.

Formatting, git diff --check and check:code-quality:changed pass. Full lint/typecheck/build and live macOS/Linux/SSH testing remain unverified locally due to native toolchain and resource limitations.

AI Disclosure

GPT-6 was used to investigate, implement, test and review this change.

Review

Limits remain owned by the execution host and shared across transports. No request schema, stream opcode, dependency, shell command or path changes. Older clients receive the existing runtime_busy error code with more detailed text.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Limits round down with a minimum of one slot; a total cap of one cannot reserve separate capacity. Raising the total limit increases permitted concurrent waits and should reflect the server workload. This adds occupancy diagnostics to errors, not a new metrics endpoint.

Author

X: @1aifanatic

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Review follow-up: both environment and explicit pool limits now normalize to 2-128. Local transport capacity grows to max(32, twice the pool), bounded at 256 connections. All 42 tests across six suites pass, including 40 separate Windows named-pipe clients at cap 64 with startup/settings/nonblocking admission and cleanup. Dispatch handlers are inert; no complete agent launch is claimed. Changed-code quality gate passes.

Merged main 099afc8 in 920b127, preserving both Node-runtime test-list additions and the newer launch classification. All 46 tests across six suites and the changed-code quality gate pass on the merged branch.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0a173ead-1dde-4b0c-9fa3-baaf352fb227
📥 Commits

Reviewing files that changed from the base of the PR and between e5902bb and 49364a5.

📒 Files selected for processing: 8
  • config/scripts/vitest-node-runtime-files.mjs
  • docs/site/content/docs/remote-servers.mdx
  • src/main/runtime/rpc/unix-socket-transport.ts
  • src/main/runtime/runtime-rpc-check-admission.test.ts
  • src/main/runtime/runtime-rpc-check-socket-capacity.test.ts
  • src/main/runtime/runtime-rpc/runtime-rpc-lifecycle.ts
  • src/main/runtime/runtime-rpc/runtime-rpc-long-poll.ts
  • src/main/runtime/runtime-rpc/runtime-rpc-state.ts

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

📝 Walkthrough

The runtime now reads the total long-poll cap from ORCA_RPC_LONG_POLL_CAP when it is a positive safe integer. Waiting orchestration.check requests use a separate sub-cap and active-poll counter. Capacity errors include total and per-class occupancy. Unix-socket connection capacity is set from the long-poll cap. Tests cover configuration, admission, release, and disconnect accounting. The remote-server documentation describes the cap and its startup behavior.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 49364

The one-slot configuration that could block worker startup is no longer supported. No actionable merge-blocking issue remains on the supplied evidence.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 11 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Issue #19342 requires a separate cap for continuously held check polls, configurable total capacity, and occupancy visibility. classifyRuntimeLongPoll classifies orchestration.check with `wait =…
Out of Scope Changes check Passed The changes stay within issue #19342. Runtime changes implement check-poll admission, configuration, occupancy diagnostics, release behavior, and transport headroom needed for the configured pool. Tes…
Title check Passed The title clearly identifies the primary change: reserving long-poll capacity for worker startup. It is concise, specific, and directly related to the pull request.
Description check Passed The description includes all required template sections, explains the change and rationale, links issue #19342, documents testing and limitations, and addresses compatibility and review considerations…
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 11 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch fix/check-poll-capacity-reservation
  • 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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b964685f-8bfc-4361-9bea-2103f05a7e27
📥 Commits

Reviewing files that changed from the base of the PR and between 6a15cd8 and e5902bb.

📒 Files selected for processing (8)
  • docs/site/content/docs/remote-servers.mdx
  • src/main/runtime/runtime-rpc-browser-host-admission.test.ts
  • src/main/runtime/runtime-rpc-check-admission.test.ts
  • src/main/runtime/runtime-rpc-long-poll-transport.test.ts
  • src/main/runtime/runtime-rpc-websocket-long-poll-caps.test.ts
  • src/main/runtime/runtime-rpc/runtime-rpc-long-poll.ts
  • src/main/runtime/runtime-rpc/runtime-rpc-request-admission.ts
  • src/main/runtime/runtime-rpc/runtime-rpc-state.ts

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

@webdevtodayjason

Copy link
Copy Markdown
Contributor

I'm hitting this on Orca 1.4.218 on macOS. We had about 43 concurrent check --wait calls across 30+ agent sessions on one host. Worker-start and check re-arms were refused with runtime_busy. At 20:05, 2 of 3 worker-starts were refused.

I tested this head and its base on a Linux test box. All 33 focused tests passed. The broader relevant suites passed 463 tests on the head and 455 on the base. Both Node server builds passed.

With 40 check attempts at the default cap, the base held 16 and refused worker-start. This branch held 8 and rejected the other 32 checks. Worker-start reached its handler, and a settings mutation succeeded. The startup probe returned consumer_fenced because I did not bind a coordinator Run, so this verifies admission rather than a complete agent launch.

I found a problem with the larger setting. With ORCA_RPC_LONG_POLL_CAP=64 and 40 separate check sockets, 32 waits stayed open and 8 connections closed. New worker-start, settings mutation, and nonblocking check connections also closed. The local transport still has a 32-connection limit, so the extra poll headroom cannot be reached. With the same requests multiplexed on one socket, 32 checks stayed open and startup was admitted.

Could we preserve connection headroom when the configured pool grows and add a test using separate client sockets? Otherwise, raising the cap to fit a host like mine recreates the starvation at the transport limit.

I also confirmed that 0, -1, 1.5, NaN, Infinity, and an unsafe integer fall back to 16. A cap of 1 still lets one check block worker-start. I agree with the existing request to define that minimum. The default class reservation addresses the failure we saw.

@webdevtodayjason

Copy link
Copy Markdown
Contributor

@1aifanatic happy to help with both pieces if it's useful. I can send the separate-client-socket test I used (40 checks on their own sockets, then worker-start and a settings mutation), and a small clamp so ORCA_RPC_LONG_POLL_CAP can't go past what the transport's connection limit can actually hold. Just say if you'd rather I push it here or open a small follow-up.

@1aifanatic

Copy link
Copy Markdown
Contributor Author

Fixed the separate-client transport ceiling in 49364a5. The local connection limit now grows to twice the configured poll pool, bounded at 256 connections; invalid values retain the default and positive limits clamp to 2-128.

The regression uses 40 separate Windows named-pipe clients at cap 64: 32 checks keep waiting, eight receive runtime_busy, and fresh worker-start, settings, and nonblocking-check clients reach dispatch. Closing clients releases all 32 waits. The handlers are inert, so this verifies admission and cleanup rather than a complete agent launch. All 42 focused tests and the changed-code quality gate pass.

This branch has not been deployed

No deployments
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.

longPollCap: continuously-held check polls starve worker-start; cap is 16 and not configurable

2 participants