Repository navigation
fix(sessions): bound store lookup to stop gateway CPU wedge without dropping retired stores - #124516
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
This replaces #123988, which was closed after a force-push made it un-reopenable (GitHub blocks reopen when the branch is force-pushed after close). The closing was not a review rejection — it was a self-inflicted packaging error: a bad This head ( @clawsweeper re-review — exact-head proof for the multi-placeholder P1 is in the PR body (pre-fix head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 11:35 PM ET / August 18, 2026, 03:35 UTC. ClawSweeper reviewWhat this changesThe PR filters retired-agent directory discovery before validation and skips unnecessary registry path-identity scans when a unique on-disk owner already determines the session-store selection. Regression provenancePossible regression — probable (reproduction; failure trace). No predecessor PR is attributed. Merge readinessNo blocking correctness findings. This is a focused, net-neutral repair for the linked Gateway availability bug; keep it open while the clean current-base refresh and exact-head required checks complete. Priority: P1 Review scores
Verification
How this fits togetherGateway cron changes refresh bound session rows and broadcast them to connected clients. Resolving each row enters the session-store resolver, which locates persistent agent session databases and selects their durable owner. flowchart LR
Cron["Cron job update"] --> Refresh["Gateway session refresh"]
Refresh --> Lookup["Session-store lookup"]
Lookup --> Discovery["Requested agent discovery"]
Discovery --> Ownership["Store ownership selection"]
Ownership --> Database["Session database"]
Database --> Event["Session change event"]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +110. Total +110 across 5 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the agent-scoped discovery and unique path-owner fast path, then merge only after a clean current-base refresh preserves the focused regressions and exact-head checks pass. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the path: current main scans all discovered agent stores before filtering the requested retired agent, and the PR body supplies exact-head Gateway burst evidence with a populated registry. Is this the best way to solve the issue? Yes. Filtering before target validation and avoiding identity comparison only after a unique path owner is known removes the blocking work while preserving the established ownership and cross-root visibility contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against de41c7de8c6c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (20 earlier review cycles; latest 8 shown)
|
430795c to
2e0b96f
Compare
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
2e0b96f to
3f6deb0
Compare
28c1458 to
970b5d5
Compare
|
🦞🧹 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:
|
…ropping retired stores
Path-derived ownership now avoids irrelevant registry filesystem identity matching while preserving unreadable and ambiguous registry semantics and cross-root retired-store visibility. Co-authored-by: SunnyShu0925 <[email protected]>
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Land-ready at exact head This is the only land-ready comment for this PR. Session proof:
Populated-registry production resolver benchmark, reported as unrelated-path lstat/stat/realpath: N=0 before/after 0/0/0; N=10 before 0/20/20 and after 0/0/0; N=50 before 0/100/100 and after 0/0/0; N=100 before 0/200/200 and after 0/0/0. Exact-head real Gateway proof: a real child-process loopback Gateway over HTTP/WebSocket with an authenticated operator subscriber and production cron RPCs. The registry held 392 unrelated agents plus one retired agent (393 total). Twelve adds plus 48 updates produced 60/60 row-loaded The current-main UI gates were also proven locally: Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/32095422495 — completed successfully; Whole-PR LOC: production +39/-39 (net 0); tests +110/-0. Latest durable ClawSweeper review: #124516 (comment) — exact reviewed head, no actionable findings, proof sufficient, 5/6 readiness. Its requested Gateway proof/rank-up move is applied; the actual conflict was cleanly rebased and exact-head checks are now complete and green. Proof limitation: channels and model providers were disabled. Gateway HTTP, authenticated RPC/WebSocket, the cron service, session loader, SQLite registry, and health endpoint were real. |
|
Merged via squash.
|
Closes #123439
What Problem This Solves
Fixes an issue where cron-bound session refreshes on gateways with many historical agents could peg the main thread and stop HTTP/WebSocket responses. Configured-agent lookups were already bounded, but retired/manual lookup still validated every agent directory and then compared the requested store against every registered database with synchronous filesystem identity calls.
Why This Change Was Made
Filter agent directory names before validation and resolve only the requested retired/manual agent across the configured template roots plus the default root. In physical collision dedupe, a single path-derived owner already has precedence, so registry identity matching is skipped only when it cannot change selection or diagnostics. The registry is still loaded, preserving unreadable-registry failure semantics; ambiguous/multi-owner groups still use full filesystem identity matching. No process-global cache, migration, schema change, or narrowed store-visibility contract.
The branch briefly absorbed a behavior-neutral Control UI formatting/max-lines repair because the corresponding current-main gates made this PR's CI red. During the required conflict rebase, current
main's larger chat-pane refactor had already incorporated both formatter changes and removed the max-lines block, so the redundant UI-only commit was dropped. The final PR contains no Control UI diff.User Impact
Gateways with large historical agent registries no longer perform registry-sized synchronous realpath/stat work for each retired/manual session lookup. Existing cross-root retired stores remain readable, configured-agent behavior is unchanged, and unreadable ownership state still fails indeterminately rather than silently proving absence.
Evidence
Session resolver and Gateway behavior
f2bed042d66d6ec20b77a36775c8c05addff2ec3: a real child-process loopback Gateway over HTTP/WebSocket, with an authenticated operator subscriber and productioncron.add/cron.updateRPCs.sessions.changedevents had reasoncron-bindingand row-loadedsessionId,updatedAt, andmodelfields./healthzprobes, zero failures, zero timeouts; p50 8.00 ms, p95 12.79 ms, max 143.15 ms, below the 250 ms threshold.check-changed, formatting/lint, andgit diff --checkpassed. The session-only structured P1 autoreview was clean.Control UI red-main gate resolution
node scripts/run-vitest.mjs ui/src/pages/chat/chat-task-suggestions.test.ts: 11/11 passed.check-changed, oxlint, oxfmt, andgit diff --check origin/main...HEADpassed for the behavior-neutral repair.mainsubsumed the formatter changes and removed the max-lines block in its chat-pane refactor; the redundant UI commit was dropped during rebase, and the final PR has no UI diff.Scope
AI-assisted.