Skip to content

perf(swarm): give collector groups independent execution lanes - #158616

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-swarm-execution-lane-20260919
Sep 26, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-swarm-execution-lane-20260919

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Collector children could receive a swarm scheduler slot and then stall in their parent's ordinary eight-slot subagent execution lane. Raising tools.swarm.maxConcurrent did not raise execution concurrency, and the backlog also delayed ordinary children from the same parent.

User Impact

Each admitted swarm group now executes in subagent:swarm:<schedulerGroupKey> with its scheduler-owned capacity. Ordinary children retain the immediate parent's session lane and its default cap of 8, including ordinary descendants of collectors.

The default tools.swarm.maxConcurrent increases from 8 to 32, explicitly approved by Peter on 2026-09-26. An explicit value of 8 still caps the group at 8. Each running child costs one model stream and one Code Mode worker isolate. maxChildrenPerGroup and maxTotalPerGroup are unchanged; there is no new configuration or storage format.

Why This Change Was Made

After the existing collector authorization, preflight carries the live scheduler group's lane descriptor through command execution. Its cap getter follows the scheduler owner across delayed preparation and retries, including restored launches. The command queue installs that capacity atomically with enqueue, keeps ordinary concurrency publications separate, and retires idle group queues. Diagnostics expose the group key and swarm scope, with at most 32 detailed group rows and overflow aggregated.

Docs, schema help, labels, and the generated config-doc hash describe the new default. The existing auth-selection helper moves unchanged into a sibling module to satisfy the attempt module's line-growth ratchet. Net production growth is 88 lines.

Evidence

The 60-task execution-queue fixture measured these admissions:

Configuration Before After Ordinary spawn from the same parent
Swarm cap 32 8 active, 52 swarm tasks queued 32 active, 28 queued Queued before; immediately admitted after
Swarm cap 8 8 active, 52 swarm tasks queued 8 active, 52 queued Queued before; immediately admitted after

Both regression cases fail on the original implementation. The fixture deliberately isolates execution capacity from child-creation admission; a 60-live-child application must separately allow that admission count. In the full flow, the swarm scheduler normally holds excess children before execution enqueue. This proves capacity and isolation, not live model throughput or production memory savings.

On Blacksmith Testbox (blacksmith-testbox, profile openclaw-check), the lane file took 2.48 s / 619 MiB peak RSS before and 1.68 s / 457 MiB after. These include cold/warm test loading and are not claimed as runtime CPU/RSS improvements.

  • Measurement lease: tbx_01m3dqtfw975dkxc8d5m0wq0zj (run). /usr/bin/time -v node scripts/run-vitest.mjs src/agents/embedded-agent-runner/lanes.test.ts --maxWorkers=1: two expected regression failures before, 14/14 passing after. Dependencies were installed once after the initial missing-dependencies refusal. Two later source-sync attempts timed out before tests; the lease was stopped.
  • Validation lease: tbx_01m3drh11h0yq8aazhbvw9vqwf (run). Changed tests plus command-queue, scheduler, swarm-tool, and diagnostics siblings: 355 tests passed. Each remote command used native sync, with one command active at a time.
  • Final validation lease: tbx_01m3dsfap25waznmyyk3xgsxn2. pnpm openclaw config validate --json accepted an isolated config with tools.swarm.maxConcurrent: 64 (valid: true, no warnings); its normal runtime build completed in 30.5 s. The final attempt/lifecycle rerun passed 180 tests, and the final lane rerun passed 14. All leases are stopped.
  • Independent Codex autoreview: no actionable P0–P2 findings, including the auth-helper extraction.

Single-worker measured file costs (pnpm test <file> --maxWorkers=1):

Test file Tests Wall time
embedded-agent-runner/lanes.test.ts 14 2.64 s
embedded-agent-runner/run/lane-controller.lifecycle.test.ts 10 38.48 s
subagents/swarm/swarm-config.test.ts 18 2.01 s
gateway/agent-turn/agent-request-preflight.test.ts 26 29.87 s
command/attempt-execution.cli.test.ts (existing coverage) 170 47.97 s

The lifecycle file spends 91% of its Vitest duration transforming existing dependencies; its new case uses the existing fixture with no timers or process boots. The unchanged attempt suite covers the behavior-preserving extraction. Queue tests cover nested ordinary admission, config-publication independence, diagnostics, and idle retirement. Preflight coverage uses the real scheduler and checks live cap changes without trusting saved launch settings.

node scripts/check-changed.mjs --base b03cf209ea6b2eb93be6f3c486317fc05422fdf5 passed core typechecking and all 25 selected test typecheck groups (1,254.61 s), formatting, generated config-doc validation, boundary/ratchet/dependency guards, and dead-export scans. Its final lint failure was a test-only string/enum comparison; after replacing that comparison with the literal lane name, the owning node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <21 changed TS files> passed with zero warnings/errors. The remaining native-schema, database, media-download, runtime-loader, import-cycle, webhook, and pairing guards passed separately. The completed typecheck proof was reused.

pnpm docs:check-config-examples validated 1,284 config fences; pnpm docs:check-links checked 14,621 links with zero broken links. Earlier check attempts identified the required config-doc hash refresh and a narrow test-fixture type omission; both were corrected. One attempted lint-only checker option was unsupported, so the checker's actual lint command was used. Source-sync timeouts were infrastructure failures before execution, recovered with stopped/replacement leases and native sync.

Rebased after concurrent queue-diagnostics and documentation changes. git range-diff confirmed only conflict-context changes to the feature patch. Fresh lease tbx_01m3dw8phwfbzp67z0qnwhd0ny passed 131 overlapping queue/controller/preflight/config/diagnostics tests, core typechecking, lint across the 21 changed TypeScript files, and the config-doc check. After a subsequent plugin retirement changed the generated hash, lease tbx_01m3dwnryyvyb6y5tn05ejw9np regenerated and verified the combined config-doc artifact. Both leases are stopped.

Exact-head CI for 1049c6f0c9f6: CI run, passed, including openclaw/ci-gate: 129 successful CI jobs. Across the 55 selected compact test jobs, CI wall times were 86–520 s. Per-file CI timings could not be extracted because the completed-job log request failed with a stream error; the measured per-file Testbox costs are recorded above. No live Gateway was modified or restarted. Live model throughput, resource pressure at 32 running children, and production rollout remain unmeasured.

@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M labels Sep 26, 2026
@steipete
steipete marked this pull request as ready for review September 26, 2026 03:26
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 1049c6f0c9f610011a7b4e1b4797c3853ce69eb8
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/command/attempt-auth-selection.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@steipete
steipete force-pushed the steipete/perf-micro-swarm-execution-lane-20260919 branch from bca893d to b4701f7 Compare September 26, 2026 03:33
@steipete
steipete force-pushed the steipete/perf-micro-swarm-execution-lane-20260919 branch from b4701f7 to 1049c6f Compare September 26, 2026 03:42
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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 Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 25, 2026, 11:52 PM ET / September 26, 2026, 03:52 UTC.

ClawSweeper review

What this changes

Routes Swarm collector children through separate group execution lanes, raises the default group concurrency from 8 to 32, and updates diagnostics and documentation.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open. Current main still has the collector execution bottleneck, so the change is useful, but its new diagnostics expose session identities across configured visibility boundaries.

Priority: P2
Reviewed head: 1049c6f0c9f610011a7b4e1b4797c3853ce69eb8

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The scheduler and queue path has focused before/after validation, but the diagnostic identity disclosure blocks merge.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate. Its recorded before/after fixture exercises the command queue and supporting preflight and lane-controller tests; no live Gateway resource result is claimed. No stored-data contract changes.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate. Its recorded before/after fixture exercises the command queue and supporting preflight and lane-controller tests; no live Gateway resource result is claimed. No stored-data contract changes.
Evidence reviewed 9 items Current-main behavior: Current main resolves subagent execution to the immediate parent's lane and has no Swarm group lane selection.
Released default: The latest supplied release still defaults Swarm group concurrency to 8; this PR's behavior has not shipped there.
Execution handoff: The introduced scheduler lookup supplies the active group's lane and a live capacity getter; preflight obtains it after matching a registered collector request.
Findings 1 actionable finding [P1] Redact foreign session identities in swarm lane diagnostics
Security Needs attention Foreign session identity disclosure: The new per-group diagnostic snapshot exposes a requester session key through an operator.read method that does not check whether the reader can see that session.

How this fits together

Swarm schedules collector children requested by an agent. Gateway preflight passes each admitted group's lane and capacity to the agent execution queue, which starts child runs and reports queue diagnostics.

flowchart LR
 A[Collector request] --> B[Swarm scheduler]
 B --> C[Gateway preflight]
 C --> D[Group execution queue]
 D --> E[Child agent runs]
 D --> F[Lane diagnostics]
 F --> G[Read-only operator]
Loading

Before merge

  • Redact foreign session identities in swarm lane diagnostics (P1) - Each scheduler group key contains the requester session key and caller-selected group ID, and this new snapshot returns both in diagnostics.lanes. That method accepts operator.read without filtering by session visibility, although restricted readers cannot list or resolve foreign sessions. Return a bounded opaque group identifier or filter rows by the viewer, and test the final RPC result with a restricted reader.
  • Resolve security concern: Foreign session identity disclosure - The new per-group diagnostic snapshot exposes a requester session key through an operator.read method that does not check whether the reader can see that session.
  • Resolve merge risk (P1) - A restricted read-only operator can receive foreign requester session keys and caller-selected group names through diagnostics.lanes.
  • Complete next step (P2) - Repair the cross-session disclosure in lane diagnostics and verify the response for a restricted reader before merge.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.

Findings

  • [P1] Redact foreign session identities in swarm lane diagnostics — src/process/command-lane-diagnostics.ts:79-80
  • [high] Foreign session identity disclosure — src/process/command-lane-diagnostics.ts:79
Agent review details

Security

Needs attention: The auth-helper move preserves its logic, but new lane diagnostics disclose requester session identities across configured session-visibility boundaries.

PR surface

Source +88, Tests +130, Docs +46, Generated 0. Total +264 across 26 files.

View PR surface stats
Area Files Added Removed Net
Source 17 192 104 +88
Tests 4 134 4 +130
Docs 4 60 14 +46
Config 0 0 0 0
Generated 1 2 2 0
Other 0 0 0 0
Total 26 388 124 +264

Review metrics

Metric Value Why it matters
Implicit group limit 8 → 32 running children per group Existing setups without an explicit value can admit four times as many collector runs per group.
Code growth production net +88 lines; tests net +130 lines The production growth wires the scheduler through existing Gateway and queue owners and includes a behavior-preserving auth-helper move.

Merge-risk options

Maintainer options:

  1. Hide raw group identities (recommended)
    Use bounded opaque identifiers for group diagnostics and prove a restricted reader cannot recover another session's key from the RPC result.

Technical review

Best possible solution:

Keep the separate group lanes, but publish bounded opaque group identifiers in diagnostics and verify the final RPC response for a reader barred from the requester's session.

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

Yes. Current-main source shows collector execution entering the parent's subagent lane, and the PR records a before/after queue fixture; this reviewer did not execute the fixture.

Is this the best way to solve the issue?

No, not yet. Group-owned execution lanes address the bottleneck at the existing scheduler and queue owners, but the diagnostic response must stop disclosing raw session identities.

Full review comments:

  • [P1] Redact foreign session identities in swarm lane diagnostics — src/process/command-lane-diagnostics.ts:79-80
    Each scheduler group key contains the requester session key and caller-selected group ID, and this new snapshot returns both in diagnostics.lanes. That method accepts operator.read without filtering by session visibility, although restricted readers cannot list or resolve foreign sessions. Return a bounded opaque group identifier or filter rows by the viewer, and test the final RPC result with a restricted reader.
    Confidence: 0.93

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The existing Swarm concurrency setting is constrained by a second queue, affecting a specialized fan-out workflow.
  • add merge-risk: 🚨 security-boundary: New diagnostic rows disclose requester session keys to operator.read clients without session visibility filtering.
  • add merge-risk: 🚨 availability: The maintainer-approved default increases simultaneous model and worker demand from 8 to 32 children per group; live resource pressure remains unmeasured.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit 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 maintainer-authored PR is exempt from the external-contributor proof gate. Its recorded before/after fixture exercises the command queue and supporting preflight and lane-controller tests; no live Gateway resource result is claimed. No stored-data contract changes.

Label justifications:

  • P2: The existing Swarm concurrency setting is constrained by a second queue, affecting a specialized fan-out workflow.
  • merge-risk: 🚨 security-boundary: New diagnostic rows disclose requester session keys to operator.read clients without session visibility filtering.
  • merge-risk: 🚨 availability: The maintainer-approved default increases simultaneous model and worker demand from 8 to 32 children per group; live resource pressure remains unmeasured.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit 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 maintainer-authored PR is exempt from the external-contributor proof gate. Its recorded before/after fixture exercises the command queue and supporting preflight and lane-controller tests; no live Gateway resource result is claimed. No stored-data contract changes.

Evidence

Security concerns:

  • [high] Foreign session identity disclosure — src/process/command-lane-diagnostics.ts:79
    The new per-group diagnostic snapshot exposes a requester session key through an operator.read method that does not check whether the reader can see that session.
    Confidence: 0.93

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Shakker: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Josh Avant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Replace raw diagnostic group keys with bounded opaque identifiers and verify the response as a restricted operator.

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
steipete merged commit c88ac86 into main Sep 26, 2026
221 checks passed
@steipete
steipete deleted the steipete/perf-micro-swarm-execution-lane-20260919 branch September 26, 2026 04:08
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
MarMarLabs added a commit to MarMarLabs/openclaw that referenced this pull request Sep 26, 2026
22 upstream commits, none in extensions/feishu. One conflict,
docs/.generated/config-baseline.sha256, which is generated: upstream's
core schema moved (openclaw#158616) while this branch moves the channel one. It
came from upstream and was regenerated.

build:docker ran in a separate detached checkout of this commit outside the
nested node_modules install. Regenerating there gave upstream's core line,
this branch's channel line, the unchanged plugin line and a new total, as
predicted from the two sides, and the three generated-file checks pass
there. The counts stay at core 2463, channel 3742, plugin 4349. The
lockfile did not move.

Feishu: 105 files and 2161 tests in the extension project, 15 files and 347
tests in the database-workers project. The forwarder test and the routing
guards pass, 2033 tests (one --help probe first hit its 5 second spawn
timeout while the separate build was running, and test-projects then passed
1738 of 1738 twice on its own). oxlint on the 43 changed code files, oxfmt,
tsgo:core, tsgo:extensions, tsgo:extensions:test, tsgo:test:root, and the
line-cap, max-lines and assertion-safety ratchets against upstream/main all
pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: M 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