Repository navigation
perf(gateway): wait for resume before retrying identity reads - #158779
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 5:25 AM ET / 09:25 UTC. ClawSweeper reviewWhat this changesThe branch makes the shared Gateway client wait and retry identity reads during suspension, and updates the protocol documentation, test configuration, and regression tests. Merge readiness✅ Ready for maintainer review Keep open. Current main and the latest release still settle suspended identity reads as errors, while this focused PR addresses the resulting request churn. Source review found no concrete introduced correctness or security defect. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway accepts authenticated requests over WebSocket and broadcasts suspension phases. A shared browser and Node client correlates those requests and supplies identity results to the Control UI and CLI. flowchart LR
A[Control UI or CLI identity read] --> B[Shared Gateway client]
B --> C{Gateway suspended?}
C -- Yes --> D[Pending read]
G[Gateway resume event or retry timer] --> D
D --> E[Gateway identity request]
C -- No --> E
E --> F[Identity result or original deadline]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +89, Tests +220, Docs +8, Config +3. Total +320 across 9 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep suspension retry ownership in the shared client, with one pending identity read per caller, the original deadline, and unchanged dispatch for other methods. Do we have a high-confidence way to reproduce the issue? Yes. Current-main response settlement and UI cache eviction explain repeated requests, and the PR reports a baseline 40-client run with 1,200 refusals; I did not execute it in this read-only review. Is this the best way to solve the issue? Yes. The shared pending-request client is the narrow owner for browser and Node behavior, and the change preserves deadlines, cancellation, and direct dispatch for other requests. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 75733458a9b7. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
What Problem This Solves
Fixes repeated
agent.identity.getrequests while the Gateway is suspended. Control UI renders retry missing identities after each rejected request is evicted from the shared identity cache, even though the socket remains connected.User Impact
Control UI and CLI identity reads wait for resume instead of repeatedly hitting the suspension fence. Existing request deadlines and cancellation remain in force; a CLI invocation with its default 30-second budget can still time out during a longer suspension. Other RPCs keep their current behavior.
Why This Change Was Made
The shared browser/Node pending-request owner now consumes the existing suspension event and hello snapshot. An explicit retryable suspension refusal also parks the identity read, with a 60-second retry hint as fallback when the resume event is missed. Resume wakes the pending read immediately. Disconnects retain normal request settlement and reconnect backoff.
Only identity reads can wait or replay. Writes retain their synchronous authority/send boundary. This adds 89 net runtime lines, reuses the existing pending-request map, and adds no configuration option, cache, or server queue. The existing structured
details.reason: "gateway-suspending"contract is retained.Caller inspection found render-driven UI retries, not a dedicated identity polling timer. The generic gateway CLI makes one request per invocation; re-running it creates a new connection.
Evidence
Actual shared protocol clients against a synthetic Gateway transport, with a fake clock: 40 connected clients poll identity once per second through a 30-second suspension.
All 40 pending reads complete on the resume turn with zero simulated-time advance. The two regressions fail on the original client at the refusal-count assertion. Additional coverage protects hello snapshot admission, the bounded fallback, original deadlines, abort/disconnect retirement, and immediate write/control dispatch.
Validation uses provider
blacksmith-testbox, profileopenclaw-check:tbx_01m3ebww6hp2znaexnfyz75xqv,node scripts/run-vitest.mjs packages/gateway-client/src/protocol-client.request.test.ts --maxWorkers=1: both new storm cases fail with 1,200 refusals; 18 existing cases pass.tbx_01m3ecferg94de7knbreax6v64(lease workflow), focused request, pending-request, handshake, and Node request-timeout files: 46 tests pass, 3.02 seconds wrapper wall time. The server suspension-admission file passes all 28 tests.tbx_01m3eff5msmdw0w04vzmyh7wfe,pnpm test packages/gateway-client/src/protocol-client.request.test.ts --maxWorkers=1: 25 pass, 2.28 seconds wall.pnpm test src/gateway/server-methods.suspension-admission.test.ts --maxWorkers=1: 28 pass, 25.70 seconds wall (23.57 seconds Vitest, predominantly cold transformation).tbx_01m3ed5h23vt87gv0pkxv52qnn(lease workflow),node scripts/check-changed.mjs --base fd3914e0af3f76ae7545acd75f17d19408e7cd24 -- <nine changed paths>: core/UI/test-root types, all 25 test-type shards, source ratchets, formatting, dependency/boundary guards, and dead-export scans pass. The full lint lane reports the pre-existingui/src/components/app-sidebar-session-navigation.tsmaximum-line error (701 versus 700). That file is byte-unchanged from both the task base and current main. No baseline or suppression was changed.tbx_01m3eff5msmdw0w04vzmyh7wfe(lease workflow). The serialized continuation completed successfully in 258.89 seconds. Previously passing type checks and guards were reused.git diff --checkpasses.b7a83010f6b4769091d632c0cc21486c74d86c67: run 36232386837 passes. Workflow elapsed time is 1,895 seconds (31m35s, including native/platform jobs); the PR has 211 passing checks, none failed or pending, and 57 skipped. Per-file CI timings were not separately collected; the single-worker file costs are recorded above. ClawSweeper reports no actionable findings and sufficient boundary proof.The missing protocol source alias exposed by tests and type checking was added to the shared Vitest and TypeScript resolvers. Reused Testbox checksum syncs timed out before execution and those leases were replaced. The default changed check compared against moving main and included unrelated changes; final validation pins the actual source base
fd3914e0af3f76ae7545acd75f17d19408e7cd24and the nine changed paths.This is fixture and source-boundary evidence, not a live deployment result. No production Gateway was changed or restarted.