Skip to content

feat(nodes): derive worker capacity from CPU cores and make it configurable - #128352

Merged
steipete merged 1 commit into
mainfrom
steipete/reverent-lichterman-9ad48d
Aug 23, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/reverent-lichterman-9ad48d

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Node session hosting caps every paired node at 2 concurrent worker sessions, hardcoded in src/node-host/node-worker-capacity.ts (DEFAULT_WORKER_CAPACITY = 2). The capacity option was already plumbed through NodeWorkerSupervisorOptions into NodeWorkerCapacity, but the only production construction site (prepareNodeHostRuntime) never passed it, so a 32-core Mac Studio hosts exactly two sessions and there is no knob to change that.

Why This Change Was Made

Operators distributing session load across their own machines need per-node concurrency to reflect the hardware. This change:

  • Defaults worker capacity to os.availableParallelism() (falling back to os.cpus().length, mirroring the existing src/config/agent-limits.ts pattern), clamped to [1, NODE_WORKER_CAPACITY_MAX] (1024).
  • Adds nodeHost.workerRuns.capacity (strict integer, 1..1024) as the explicit override, wired from config through createNodeWorkerSupervisor. Node-local enforcement is unchanged — the Gateway still cannot set this remotely.
  • No compat path: the hardcoded 2 is deleted. The durable slot journal, { total, available } inventory publication, and 10-second admission wait are untouched; only the ceiling changes.

Config baseline note: regenerating docs/.generated/config-baseline.* records +4 core fields — 1 from this PR and 3 pre-existing unrecorded fields already on main (clean main regenerates 2335 → 2338); this PR absorbs that drift.

User Impact

Nodes now host one worker session per available CPU core by default instead of two total, and nodeHost.workerRuns.capacity bounds it explicitly. Existing nodes pick up the new default on update + node restart. Docs updated (docs/nodes/index.md, docs/plan/runners.md).

Evidence

  • Regression (fails pre-fix): src/node-host/runner.test.ts — config nodeHost.workerRuns.capacity: 5 must publish workerHost.capacity {total: 5, available: 5} in the atomic runner inventory; pre-fix the runtime ignored the option and published {total: 2}.
  • Default derivation: src/node-host/node-worker-supervisor.test.ts — mocked os.availableParallelism of 0 / 7 / 1025 publishes 1 / 7 / 1024; explicit capacity never consults the CPU count.
  • Schema: src/config/config.node-agent-runs.test.ts — accepts 1/5/1024, rejects 0/-1/1.5/1025 with the exact issue path.
  • pnpm test src/node-host src/config: 3,846 passed, 2 skipped (289 files).
  • pnpm check:changed, pnpm check:import-cycles, pnpm config:docs:gen && pnpm config:docs:check, pnpm config:schema:check, pnpm docs:check-mdx (777 files), git diff --check: all green.
  • Production LOC delta: +14 (new config surface + default resolution); tests +55.
  • Codex autoreview (uncommitted diff): clean, no accepted/actionable findings (gpt-5.6-sol, high)

…urable

Node session hosting was capped at a hardcoded 2 concurrent worker sessions.
The default is now one worker slot per available CPU core (clamped to 1..1024),
and nodeHost.workerRuns.capacity overrides it explicitly. The capacity option
was already plumbed through the supervisor; this wires it from config and
deletes the hardcoded constant. Docs and config baselines regenerated.
@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation plugin: file-transfer size: S maintainer Maintainer-authored PR labels Aug 23, 2026
@steipete
steipete marked this pull request as ready for review August 23, 2026 20:23
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 23, 2026, 4:32 PM ET / 20:32 UTC.

ClawSweeper review

What this changes

This PR adds nodeHost.workerRuns.capacity and changes node worker-session capacity from a fixed two slots to a CPU-derived, bounded default.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for maintainer product review. The wiring is coherent, but it replaces the documented two-worker upgrade default for every existing enabled node without a capacity setting; an update and restart can instead advertise one slot per available CPU core.

Priority: P1
Reviewed head: 556f79d55be01b77a6deb4b7181d6710f7f2f95c
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation is focused, but the unresolved upgrade-default decision is a merge blocker.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the reported automated coverage is supplemental evidence.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the reported automated coverage is supplemental evidence.
Evidence reviewed 6 items Current documented contract: Current main documents that each enabled node runs at most two worker processes by default, so absent capacity is an established upgrade behavior.
Changed default: The PR replaces the current-main constant of two with an availableParallelism()-derived default; no existing config is distinguished from a fresh configuration.
Config-to-dispatch path: The strict schema accepts the new field, runtime passes it to the sole worker-supervisor construction site, and the runner publishes that capacity to the Gateway inventory.
Findings 1 actionable finding [P1] Preserve the documented two-slot upgrade default
Security None None.

Live Verification

Command: pnpm openclaw config validate

Result: PASS (completed)

pnpm openclaw config validate
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128352-1Px8ei/target$ pnpm openclaw config validate
scratch=$(mktemp -d); printf '{ nodeHost: { workerRuns: { enabled: true, capacity: 5 } } }\n' › "$scratch/openclaw.json"; OPENCLAW_CONFIG_PATH="$scratch/opencla
w.json" pnpm openclaw config validate
$ node scripts/run-node.mjs config validate
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 100.61 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 14.1s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4167ms (slowest: built plugin control-plane loads 3435ms)
│
◇

OpenClaw 2026.8.1 (556f79d) — Reading the error message remains undefeated. You should try it sometime.

Config file not found: ~/.openclaw/openclaw.json
Create one with openclaw onboard or run openclaw doctor --fix.
[ELIFECYCLE] Command failed with exit code 1.
runner@runnervm
… output truncated …

Assertions:

  • PASS expect_output: Config valid:

How this fits together

A paired node creates a local worker supervisor and publishes its free worker slots to the Gateway. The Gateway uses that inventory to decide whether it can dispatch another supervised session to the node.

flowchart LR
A[Node configuration] --> B[Node-host runtime]
C[Available CPU cores] --> D[Capacity resolver]
B --> E[Worker supervisor]
D --> E
E --> F[Runner inventory]
F --> G[Gateway session dispatch]
Loading

Decision needed

Question Recommendation
Should an existing enabled node with no nodeHost.workerRuns.capacity change from two worker slots to one slot per available CPU core on update? Keep two slots by default: Preserve existing admission behavior and let operators opt into a higher value through the new capacity setting.

Why: This is an intentional default and admission-policy change for existing operators, not a mechanical correctness choice; source and tests establish the behavior but cannot determine the supported rollout policy.

Before merge

  • Preserve the documented two-slot upgrade default (P1) - Existing enabled hosts omit this new field and currently have a documented two-worker ceiling. After update and restart this line instead advertises every available CPU core to the Gateway, so an existing host can accept far more full worker processes without an operator choice; retain two as the default or obtain an explicit rollout decision with upgrade proof.
  • Resolve merge risk (P1) - Existing enabled node hosts with no authored capacity will change from a documented two-slot ceiling to all available CPU cores after update and restart, potentially increasing concurrent worker processes sharply.
  • Complete next step (P2) - A maintainer must decide the existing-node default before any safe repair path can be selected; the protected maintainer label also requires human handling.

Findings

  • [P1] Preserve the documented two-slot upgrade default — src/node-host/node-worker-capacity.ts:61
Agent review details

Security

None.

PR surface

Source +14, Tests +55, Docs +2, Generated 0. Total +71 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 6 16 2 +14
Tests 4 58 3 +55
Docs 2 9 7 +2
Config 0 0 0 0
Generated 2 3 3 0
Other 0 0 0 0
Total 14 86 15 +71

Review metrics

Metric Value Why it matters
Configuration surface 1 field added nodeHost.workerRuns.capacity becomes a new persistent operator control for session admission.
Production versus test LOC production +16/-2 (net +14); tests +58/-3 (net +55); docs/generated +12/-10 The production growth is tied to the new configuration contract and CPU-derived resolution; test growth covers schema and inventory behavior.

Merge-risk options

Maintainer options:

  1. Preserve the two-slot upgrade default (recommended)
    Keep the documented default of two and use the new setting only as an explicit operator scaling control.
  2. Approve the higher default explicitly
    Accept CPU-derived capacity for existing nodes only after recording the rollout decision and proving fresh and upgraded node behavior.
  3. Pause the default change
    Leave the PR open until the node-host owner chooses the supported upgrade policy.

Technical review

Best possible solution:

Retain the two-slot default and offer the new field as the explicit scaling control unless a maintainer deliberately approves the CPU-derived upgrade behavior with fresh-install and upgrade proof.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR changes configuration and default policy rather than reporting a current broken behavior.

Is this the best way to solve the issue?

No: the config wiring is clean, but changing the established two-slot default is not the safest solution until maintainers choose its upgrade policy.

Full review comments:

  • [P1] Preserve the documented two-slot upgrade default — src/node-host/node-worker-capacity.ts:61
    Existing enabled hosts omit this new field and currently have a documented two-worker ceiling. After update and restart this line instead advertises every available CPU core to the Gateway, so an existing host can accept far more full worker processes without an operator choice; retain two as the default or obtain an explicit rollout decision with upgrade proof.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against eb0118b417c4.

Labels

Label changes:

  • add P1: A routine update can substantially raise concurrent worker processes on already enabled nodes.
  • add merge-risk: 🚨 compatibility: The PR changes the documented default applied to existing configurations that omit the new field.
  • add merge-risk: 🚨 availability: Higher advertised capacity can cause a node to accept many more simultaneous worker processes after restart.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the reported automated coverage is supplemental evidence.

Label justifications:

  • P1: A routine update can substantially raise concurrent worker processes on already enabled nodes.
  • merge-risk: 🚨 compatibility: The PR changes the documented default applied to existing configurations that omit the new field.
  • merge-risk: 🚨 availability: Higher advertised capacity can cause a node to accept many more simultaneous worker processes after restart.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the reported automated coverage is supplemental evidence.

Evidence

What I checked:

  • Current documented contract: Current main documents that each enabled node runs at most two worker processes by default, so absent capacity is an established upgrade behavior. Public docs: docs/nodes/index.md. (docs/nodes/index.md:493, eb0118b417c4)
  • Changed default: The PR replaces the current-main constant of two with an availableParallelism()-derived default; no existing config is distinguished from a fresh configuration. (src/node-host/node-worker-capacity.ts:61, 556f79d55be0)
  • Config-to-dispatch path: The strict schema accepts the new field, runtime passes it to the sole worker-supervisor construction site, and the runner publishes that capacity to the Gateway inventory. (src/node-host/runtime.ts:335, 556f79d55be0)
  • Focused coverage: Tests cover schema bounds, explicit configured publication through the runner, and CPU-value clamping, but not the intended upgrade rollout from an existing enabled configuration with no capacity field. (src/node-host/node-worker-supervisor.test.ts:73, 556f79d55be0)
  • Feature provenance: The two-slot capacity owner was introduced by the node-worker capacity feature and later extended to publish exact runner slots; both commits are by the likely area owner. (src/node-host/node-worker-capacity.ts:17, 38379a9a2ee1)
  • Release position: The latest stable tag predates the worker-capacity feature, so neither the existing two-slot behavior nor this proposed change is in that stable release. (0790d9f593ad)

Likely related people:

  • steipete: Authored the capacity enforcement, inventory-publication follow-up, and the current PR; history is concentrated in the affected node-host and configuration surfaces. (role: node worker capacity feature owner; confidence: high; commits: 38379a9a2ee1, efaa867d934c, 556f79d55be0; files: src/node-host/node-worker-capacity.ts, src/node-host/runtime.ts, src/config/zod-schema.node-host.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record the maintainer decision on whether existing enabled nodes may change from two slots to CPU-derived capacity.
  • Add fresh-install and upgrade coverage for the selected rollout policy.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer decision (recorded, re: the P1 "preserve the two-slot upgrade default"):

The CPU-derived default is intentional and approved. The repository owner explicitly specified this rollout: default = number of available CPU cores, with nodeHost.workerRuns.capacity as the explicit override. This is option 2 from the merge-risk options ("approve the higher default explicitly").

Why the compat concern does not block: per the review's own release-position evidence, the latest stable tag predates the node worker-capacity feature entirely — the two-slot ceiling has never been reachable from a stable release, so under the repo's compatibility doctrine ("shipped" = reachable from a stable release Git tag) it is not a shipped contract. Pre-release node hosts follow main, and node hosting itself is opt-in (nodeHost.workerRuns.enabled defaults to false); operators who enabled it and want a lower bound set capacity explicitly.

Rank-up moves:

  • Record the maintainer decision — done, this comment.
  • Fresh-install and upgrade coverage for the selected rollout policy — the upgrade case (existing config with workerRuns.enabled: true and no capacity field) is exactly the default-derivation path: src/node-host/node-worker-supervisor.test.ts proves a capacity-less supervisor publishes clamped availableParallelism(), and src/node-host/runner.test.ts proves configs with an explicit capacity publish that value through the atomic runner inventory. Fresh install and upgrade share this single code path — there is no migration branch to cover separately.

@steipete
steipete merged commit 259a14b into main Aug 23, 2026
310 checks passed
@steipete
steipete deleted the steipete/reverent-lichterman-9ad48d branch August 23, 2026 21:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
…urable (openclaw#128352)

Node session hosting was capped at a hardcoded 2 concurrent worker sessions.
The default is now one worker slot per available CPU core (clamped to 1..1024),
and nodeHost.workerRuns.capacity overrides it explicitly. The capacity option
was already plumbed through the supervisor; this wires it from config and
deletes the hardcoded constant. Docs and config baselines regenerated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. plugin: file-transfer rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant