Repository navigation
fix(gateway): reduce control-plane stalls during concurrent turns - #133429
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
26dec89 to
7ace3c0
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 2:44 PM ET / 18:44 UTC. ClawSweeper reviewWhat this changesThe PR yields embedded-agent preparation between stages and reuses lifecycle-owned Gateway, plugin, and provider metadata to reduce control-plane stalls during concurrent turns. Merge readinessNo concrete introduced correctness or security defect was found. Keep this maintainer-owned, protected PR open until the exact-head validation completes; the prior timeout-classification finding is addressed in the current head. Priority: P2 Review scores
Verification
How this fits togetherGateway control requests share Node’s event loop with embedded-agent setup and session projection. The changed code schedules setup stages and resolves plugin/provider/session metadata used by Control UI and Gateway clients. flowchart LR
A[Concurrent agent turns] --> B[Attempt preparation]
B --> C[Event-loop stage scheduling]
C --> D[Gateway control requests]
E[Plugin and provider metadata] --> F[Session list projection]
F --> D
D --> G[Control UI and API clients]
Decision needed
Why: The patch has no supported mechanical repair remaining, but it changes Gateway availability behavior and is protected for explicit maintainer handling. Before merge
Agent review detailsSecurityNone. PR surfaceSource -11, Tests +285, Docs +1. Total +275 across 21 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the lifecycle-owned metadata and elapsed-work scheduling design, then land it after the exact-head Gateway and lifecycle validation confirms the corrected abort behavior under the normal merge gate. Do we have a high-confidence way to reproduce the issue? No: this read-only review did not run the concurrent-load workload. The PR body supplies a detailed isolated Gateway and Control UI scenario, and source inspection confirms the changed owners it exercises. Is this the best way to solve the issue? Yes: the patch removes repeated work at lifecycle and projection owners, preserves live activation policy, and avoids new configuration or persistence surfaces rather than masking stalls with looser limits. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9050011d1e40. 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 (2 earlier review cycles) |
|
Addressed the pre-listener timeout classification finding. The new checkpoint and the external listener now use the same abort classifier, with once-only side effects. The regression failed before the fix because the full embedded-attempt cleanup hook received The refreshed current-main comparison and real isolated Control UI video are now in the PR body. I read the latest Rank-up moves: the timeout regression and current-head proof are addressed by this work; final exact-head CI will be checked after pushing the correction. The review's stored-data warning is not applicable: the bundled-root field is an in-process PluginCache member invalidated by the existing generation owner. No SQLite schema, persistent cache schema, embedding metadata, migration or storage semantics change. |
|
Final head This lands the measured owner-level improvement first, as requested, not total stall remediation. A retained final-head repeat still exceeded the unchanged UI HTTP budget (2576ms) despite all32 turns/128 patches completing and zero operation failures. The current harness misses that UI violation. The separate follow-up will repair the measurement gate and investigate the remaining tail; no host-noise or memory-leak attribution is claimed. |
|
Merged via squash.
|
…enclaw#133429) * fix(gateway): reduce control-plane stalls during concurrent turns * fix(agents): preserve timeout classification before preparation
Related: #133061
What Problem This Solves
Gateway readiness, session lists, history and Control UI HTTP responses can stall during bursts of concurrent agent turns. This extends the session-update repair in #133061. It reduces measured stalls without claiming to eliminate CPU saturation or every latency tail.
Why This Change Was Made
Reuse process-stable plugin lookup facts within their existing lifecycle, resolve normalized CLI backend owners before evaluating live activation policy, and collect provider auth metadata in one owner pass. Attempt preparation shares event-loop start turns while preserving asynchronous overlap, caller context and resource cleanup. Session lists yield according to elapsed projection work instead of repeatedly requeueing cheap rows.
Preparation checkpoints and the external abort listener now share once-only timeout classification. A regression reproduced cleanup receiving
cancelfor a timeout before listener setup; it now receivestimeout, matching the terminal outcome.No enablement policy is cached. No public configuration, protocol, SQLite schema, persistence semantics or command concurrency settings change. Production diff +355/-367 (net -12), tests/support +412/-126, docs +1. Main's selected-parent session index and nested-tool activity ownership remain intact.
User Impact
The refactor substantially reduces measured control-plane stalls, but a later identical repeat still exceeded the two-second UI HTTP budget. CPU-pressure readiness diagnostics still report degraded load. A previously observed timeline-disabled UI HTTP tail remains a separate follow-up; it is not dismissed as host noise.
Evidence
Built current-main baseline
61edeb8a6fe90ade870d11436eb4308469ac436aand final candidatea272f175688041b1437ae7d407ee0fc6739158e9. Same configured workload: 32 turns, 48 seeded sessions, 128 updates across four clients, three history readers with five-request bursts, six subscribers, visible observer, 100 ms cadence and 1000 ms mock stream delay. Fresh isolated HOME/state and random loopback ports; synthetic streaming provider only. No production Gateway stressed or mutated.Baseline failed; the tabulated final-candidate run passed with zero operation failures. A later fresh-cache repeat completed all32 turns and128 patches but failed the unchanged UI latency budget: UI HTTP2576ms, readiness1748ms, list1934ms, history1893ms, all operation failures zero. The harness incorrectly exited0 because UI is omitted from its control gate. This is a retained observed latency failure for the separate follow-up, not a complete-fix claim or attributed host-noise explanation. The preceding integrated head
7ace3c08c008passed three32-turn trials (worst readiness597ms/list339ms/UI769ms/history678ms), an8-turn control and three timeline-disabled32-turn controls (UImax922ms). Final candidate raw requests prove32 streaming Responses requests plus1 embedding request; all32 turns and128 patches completed. Older baseline/candidate mock HTTP record totals65/36 varied; their extra requests cannot be classified without retained raw data. Memory indexing is observed in the later browser captures, so total HTTP record count is not a fixed-turn count.376 integrated tests passed, followed by30 focused timeout/sibling lifecycle tests. The timeout regression failed before its correction. Full local changed-code gates, frozen-source fresh-cache sourcePerformance build, Control UI build and Codex P0 autoreviews passed. An earlier build overlapped native checkout refresh and was explicitly discarded as proof before rebuilding.
The final real-browser-under-load run also passed: real built Control UI, fresh Playwright context, real Gateway WebSocket traffic, visible session-label changes and the selected synthetic reply while load remained active. All32 turns completed; zero page errors/operation failures. Max readiness899ms/list749ms/UI1209ms/history963ms. This adds browser/asset work and is separate from the HTML-only benchmark. Two prior recordings were interrupted by the recorder's own10s reply wait; retained traces show continued control-plane service and19 persisted replies in the inspected failure. The recorder now uses the benchmark's existing120s completion deadline; the2s latency budgets were never raised. Failed captures remain retained locally.
[email protected]
Captures inspected: synthetic fixture state only. The prior timeline-disabled UI HTTP2164ms observation and final-head UI2576ms repeat remain unresolved; passing repeats do not erase them. UI/history latency were checked directly because the existing benchmark control gate omits those samples; fixing that blind spot and profiling remaining history work is a separate follow-up. No memory-leak or general capacity claim.
AI-assisted implementation. Latest ClawSweeper finding and Rank-up moves addressed by timeout regression and refreshed exact-head proof. Hosted exact-head CI/native landing checks remain pending.