Repository navigation
fix(gateway): keep sessions.list responsive with many configured agents - #124453
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Land-ready evidence for exact head
The root cause is repeated physical target identity construction on configured-only misses. The fix is the owner-boundary design: one bounded prepared snapshot keyed by config identity, registry Symbol token, and incognito generation; registry/incognito lifecycle fences cover the completed list cache; sharing receives the authoritative prepared targets; the requested alias row is retained; redundant prewarm dedupe is removed; and existing target identity uses realpath before stat. Generic CLI/Doctor discovery remains fresh. Production LOC is +200/-76 (net +124); tests are +383/-2 (net +381). The production growth is the explicit lifecycle token/generation/fence and bounded snapshot. There is no config, schema, protocol, TTL, polling, or fallback surface. Scope is intentionally narrow: this proves the repeated target identity/ |
|
Merged via squash.
|
## What Problem This Solves The configured-only 29-store projection test changes the process state-directory override while its suite retains a live Gateway projection. Both contexts compete for the process-held store registry memo, making filesystem-probe assertions depend on unrelated background work. ## User Impact This is a test-fixture correction with no production behavior change. It preserves all 29 seeded stores, the warm preparation request, filesystem assertions and cleanup. No production checks, SQL, security, schema, service-lifecycle or SDK behavior changes; no numeric T1 or SQL statement/request improvement is claimed. ## Why This Change Was Made Move the case into the existing handler-only projection suite, which exercises the same list handlers without a live Gateway. Preserve the independently landed runtime-config setup from #169714. After setting both multi-store overrides, explicitly publish the completed fixture configuration: `createSessionStoreDir` has already installed an earlier snapshot, so merely reading it does not publish the new store template and agent entries. The two-file diff is +72/−75 and contains the reviewed fixture move plus its snapshot-publication correction. The test originated in #124453; the first commit exposing the retained-projection interaction remains unestablished. Two Codex review rounds completed with no actionable findings, covering the fixture move and snapshot adaptation. ## Evidence Exact head `443698a6a37b0e425c4bf305100140522c5a3843` passed [CI run 38313773328](https://github.com/openclaw/openclaw/actions/runs/38313773328): 20 successful jobs and 29 skipped jobs, including a successful CI gate. Both projection cases passed: 56.56 s Vitest duration and 58.73 s test-runner wall time; the conventional-state-directory case took 4.984 s and the configured-only case 2.919 s. Local runtime was not repeated. The other changed file, `src/gateway/server.sessions.store-paths.test.ts`, was not selected by that PR run. Its six cases passed in [run 38311910220, job 115019808666](https://github.com/openclaw/openclaw/actions/runs/38311910220/job/115019808666) on `0c4b38b77adfcd32fc25a18f5d0ed7fb97c2faae`, using the exact same fixture blob `b3cdb024f1f3affcf1a811d8e341d8002942d97f`. That includes both disposal outcomes and configured-only lineage coverage. Summed case times were 14.531 s; no file wall time is available. This is reused composition evidence, not an exact-PR-head sibling run; the broader job failed in three other files. The exact-head baseline ratchets, source contracts, additional boundaries, selected test types and lint jobs passed. Normal commit hooks and diff checks passed. Build artifacts and the published-driver update cell were not selected for this test-only change. Knip evidence is reused narrowly from [run 38311910220](https://github.com/openclaw/openclaw/actions/runs/38311910220/job/115019807997): both changed test blobs, package/lock/workspace, all-exports configuration and runner match; the primary Knip configuration differs only in a comment. That actual scan reported only three unrelated team-scale exports, all already removed on this branch. This is scoped evidence for this diff, not a claim that the earlier whole-tree scan passed. The same composition's actual Madge check reported zero cycles; this change adds no production import edge. This green PR run does not establish green scheduled CI on main.
…#170284) ## What Problem This Solves The configured-only 29-store projection test changes the process state-directory override while its suite retains a live Gateway projection. Both contexts compete for the process-held store registry memo, making filesystem-probe assertions depend on unrelated background work. ## User Impact This is a test-fixture correction with no production behavior change. It preserves all 29 seeded stores, the warm preparation request, filesystem assertions and cleanup. No production checks, SQL, security, schema, service-lifecycle or SDK behavior changes; no numeric T1 or SQL statement/request improvement is claimed. ## Why This Change Was Made Move the case into the existing handler-only projection suite, which exercises the same list handlers without a live Gateway. Preserve the independently landed runtime-config setup from openclaw#169714. After setting both multi-store overrides, explicitly publish the completed fixture configuration: `createSessionStoreDir` has already installed an earlier snapshot, so merely reading it does not publish the new store template and agent entries. The two-file diff is +72/−75 and contains the reviewed fixture move plus its snapshot-publication correction. The test originated in openclaw#124453; the first commit exposing the retained-projection interaction remains unestablished. Two Codex review rounds completed with no actionable findings, covering the fixture move and snapshot adaptation. ## Evidence Exact head `443698a6a37b0e425c4bf305100140522c5a3843` passed [CI run 38313773328](https://github.com/openclaw/openclaw/actions/runs/38313773328): 20 successful jobs and 29 skipped jobs, including a successful CI gate. Both projection cases passed: 56.56 s Vitest duration and 58.73 s test-runner wall time; the conventional-state-directory case took 4.984 s and the configured-only case 2.919 s. Local runtime was not repeated. The other changed file, `src/gateway/server.sessions.store-paths.test.ts`, was not selected by that PR run. Its six cases passed in [run 38311910220, job 115019808666](https://github.com/openclaw/openclaw/actions/runs/38311910220/job/115019808666) on `0c4b38b77adfcd32fc25a18f5d0ed7fb97c2faae`, using the exact same fixture blob `b3cdb024f1f3affcf1a811d8e341d8002942d97f`. That includes both disposal outcomes and configured-only lineage coverage. Summed case times were 14.531 s; no file wall time is available. This is reused composition evidence, not an exact-PR-head sibling run; the broader job failed in three other files. The exact-head baseline ratchets, source contracts, additional boundaries, selected test types and lint jobs passed. Normal commit hooks and diff checks passed. Build artifacts and the published-driver update cell were not selected for this test-only change. Knip evidence is reused narrowly from [run 38311910220](https://github.com/openclaw/openclaw/actions/runs/38311910220/job/115019807997): both changed test blobs, package/lock/workspace, all-exports configuration and runner match; the primary Knip configuration differs only in a comment. That actual scan reported only three unrelated team-scale exports, all already removed on this branch. This is scoped evidence for this diff, not a claim that the earlier whole-tree scan passed. The same composition's actual Madge check reported zero cycles; this change adds no production import edge. This green PR run does not establish green scheduled CI on main.
Related: #124384
What Problem This Solves
Fixes an issue where operators listing sessions across many configured agents could still see the Gateway saturate CPU and memory and time out, even after #124384 removed broad directory enumeration. On Molty, the exact #124384 merge remained at 149.6% CPU and 2.95 GB RSS, timed out over HTTP, and made 16,023 failed
readlinkcalls in 8 seconds because every configuredsessions.listcache miss rebuilt physical target identities.This PR intentionally excludes #124372. That change addresses a separate path, is not bundled here, and is not a replacement for this cache-ownership repair.
Why This Change Was Made
Configured Gateway listings now reuse one bounded prepared target snapshot keyed by the exact config identity, a durable-registry generation token, and the incognito membership generation. The completed list-cache fence carries both lifecycle generations, so registry or incognito membership changes rebuild the snapshot and invalidate completed results without restoring request-time filesystem discovery.
The prepared physical target set is also the authoritative sharing lookup set. This collapses requested-agent symlink aliases to one row, avoids redundant requested-agent prewarm dedupe when no incognito database is open, and keeps path identity internally consistent by resolving the real path before reading its stat identity. Generic CLI and Doctor dedupe remains fresh per call.
User Impact
Operators with many configured agents should get responsive session listings without repeated matcher, stat, or symlink-resolution work on each distinct list request. Registry and incognito topology changes remain visible immediately through explicit generation fences, while fixed/shared stores, lineage, startup prewarm, and incognito behavior are retained.
Live Molty validation of this exact PR head is still pending and is required before merge.
Evidence
1/29/29; a second distinct request performs0/0/0/0/0matcher/stat/lstat/readlink/realpath work.pnpm check:changedpassed every selectedcoreandcoreTestslane. Crabbox/Blacksmith CLI was unavailable, so the repository-authorized trusted-source fallback ran locally; this is not presented as remote proof.git diff --checkgates are clean. Fresh structured autoreview reported no accepted/actionable findings at 0.97 confidence.pull_requestCI attachment/completion and Molty live validation of this exact head. Do not merge until both are green.