Repository navigation
fix: keep gateway control traffic responsive under concurrent turns - #123608
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 9:41 AM ET / 13:41 UTC. ClawSweeper reviewWhat this changesMoves Gateway turn preparation, plugin metadata, workspace-transfer authorization, and session-title writes onto lifecycle-owned or admitted paths so control clients and health RPCs remain responsive during concurrent turns. Merge readinessKeep open for maintainer review: this maintainer-authored, protected PR addresses a credible Gateway availability problem, and its prior workspace-root concurrency finding appears addressed, but the local partial clone could not retrieve the exact-head source tree for a full final-diff verdict. Priority: P1 Review scores
Verification
How this fits togetherGateway clients send control RPCs and agent turns through the same Node process. This PR moves expensive per-turn discovery and shared-state writes behind lifecycle preparation and admission fences so control traffic remains responsive while preserving worker and session ownership checks. flowchart LR
A[Gateway clients] --> B[Control RPCs and agent turns]
B --> C[Lifecycle-prepared plugin metadata]
B --> D[Session and workspace admission]
C --> E[Agent runtime and tools]
D --> F[Worker transfer and title updates]
E --> G[Responsive control responses]
F --> G
Decision needed
Why: The branch changes concurrency, session admission, plugin loading, and worker-transfer authority while carrying a protected maintainer label; this needs an accountable human merge decision. Before merge
Agent review detailsSecurityNone. PR surfaceSource +291, Tests +295, Other +132. Total +718 across 38 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one lifecycle-owned metadata and admission path, then merge only after the exact head demonstrates bounded control latency and green required checks without weakening workspace or transfer ownership fencing. Do we have a high-confidence way to reproduce the issue? Yes. The PR describes a bounded multi-node workspace-fanout scenario that measures fresh authenticated connections, ready probes, and completed turns; the changed benchmark is the intended reproduction harness. Is this the best way to solve the issue? Unclear. Lifecycle-owned metadata and admission fences match the affected ownership boundaries, but the exact final tree was unavailable locally, so the complete final implementation cannot be confirmed as the best form. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5523f8a334c9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Exact-head CI is green in run 31807558395. The calibrated control-plane load gate passed three consecutive runs at the approved 4s p100 bound; the 2s fresh-handshake bound remains unchanged. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…penclaw#123608) * fix(gateway): preserve control-plane responsiveness under load * fix(plugins): accept prepared readonly manifests * refactor(plugins): prepare workspace ownership before metadata reuse * chore: leave changelog updates to release flow * fix(gateway): finish control-plane load repair * perf(gateway): reuse prepared workspace root facts * perf(gateway): coalesce workspace root preparation * test(gateway): calibrate control-plane load bound
…ion generations (#128980) * fix(sessions): keep gateway responsive while large transcript archives are built (#112424) * fix(sessions): keep gateway responsive during transcript archiving * test(sessions): strengthen archive worker coverage * fix(sessions): bound archive worker concurrency * test(sessions): normalize rollback paths on Windows * fix(sessions): load source archive worker on node 22 * fix(sessions): align archive fencing with session windows * test(sessions): adapt cleanup race to archive worker * fix(sessions): harden archive worker lifecycle * style(sessions): format archive lifecycle tests * fix(sessions): release writer lane during archive work --------- Co-authored-by: Josh Lehman <[email protected]> (cherry picked from commit 9bfe292) * fix(sessions): release writer lane during transcript archival (#119460) (cherry picked from commit 141a16f) * fix(gateway): fence background titles during session archival Backport the session-title admission fix from upstream commit 530b33e (#123608) without its unrelated gateway changes. Keep asynchronous disk-budget scans out of the transcript stat regression fixture. * test(ui): settle custodian mobile layout assertions (#116613) (cherry picked from commit 871abad) --------- Co-authored-by: Heming Zeng <[email protected]> Co-authored-by: Josh Lehman <[email protected]> Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
octopool: pr_view served from shared cache (hit); set OCTOPOOL_FRESH=1 for a live read
What Problem This Solves
Fixes an issue where concurrent node-hosted turns could keep completing while the Gateway control plane stopped accepting new WebSocket clients and delayed health/control RPCs for several seconds.
Why This Change Was Made
Profiling showed that each turn synchronously rediscovered plugin metadata and loaded enabled tool runtimes on the Gateway event loop, then repeated durable workspace-transfer owner reads. This moves stable plugin/tool work to the Gateway lifecycle boundary, carries prepared metadata through run planning, gives accept/control work a turn before serialized workspace generations, combines transfer authorization facts into one authoritative read, and bounds retained workspace snapshots. Workspace plugin overrides still require exact owner provenance; durable environment, credential, epoch, session, generation, and tunnel-instance fencing remain enforced.
User Impact
Operators can open new Gateway clients and use health/control RPCs during node-host fan-out instead of losing observability while data-plane turns continue.
Evidence
Profile attribution
The bounded 2-node/8-turn reproduction initially measured a 9.63s authenticated connection and an 8.01s
/readyzprobe. Main-thread CPU attribution was:A later phase profile isolated 9.9s of synchronous
resolvePluginToolRegistry -> loadOpenClawPlugins -> jiti/Babelwork (34% of active samples), led by the Teams meeting tool runtime. Transfer authorization also spent 12.2% in repeated durable owner validation. Inference JSON serialization and presence fan-out were not leading frames.Heap snapshots attributed only about 34MiB of retained growth to module/code graphs, maps, bytecode, and contexts; transcript and transfer buffers were not the retained owner. The snapshot service now prunes superseded manifests after live tokens retire.
Before/after under load
hello-ok1.868s; worst/readyz1.290s; 12/12 turns completed; zero failed probes; Gateway RSS growth 112MiB./readyzmax 1.282s;sessions.listmax 1.282s; zero failed samples; turn fan-out 6.23-6.59s.CI closeout and SQLite race disposition
Exact head: 4923d34.
Verification
OPENCLAW_BUILD_PRIVATE_QA=1 pnpm buildpassed on the exact final source./readyz/sessions.listmax 1.468s) with no request-time filesystem probe.git diff --checkand changed-file formatting passed.Production LOC: +251/-72 (net +179) | Tests: +269/-13. The production growth adds the CI load gate and explicit lifecycle/authority facts needed to remove request-time discovery without weakening workspace-plugin or worker authority boundaries.