Repository navigation
fix(sessions): reduce cold catalog listing delays - #139146
Conversation
Reuse completed canonical validation metadata for the first listing cache read. Recheck the connection data version before reuse and preserve full-entry reads, Doctor projections, and existing cache invalidation.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 10:49 AM ET / 14:49 UTC. ClawSweeper reviewWhat this changesReuse session metadata already decoded during validation to reduce cold catalog listing delays while preserving existing listing and cache behavior. Merge readiness✅ Ready for maintainer review This remains a useful optimization absent from current main. No introduced correctness or security defect was found, and the protected maintainer-owned PR is not eligible for automated cleanup. Priority: P2 Review scores
Verification
How this fits togetherSession catalogs combine provider listings with metadata from OpenClaw’s per-agent SQLite databases. The shared session reader validates stored entries, builds listing snapshots, and supplies metadata for display and visibility filtering. flowchart TD
A[Catalog request] --> B[Session metadata reader]
C[Per-agent SQLite database] --> B
B --> D[Validate stored session keys]
D --> E{Database version unchanged?}
E -->|Yes| F[Reuse decoded metadata]
E -->|No| G[Read fresh metadata]
F --> H[Project and filter catalog results]
G --> H
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +59, Tests +245, Other 0. Total +304 across 7 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep reuse confined to the synchronous listing read; the added handoff and freshness check preserve validation and Doctor contracts without extending cache lifetime. Do we have a high-confidence way to reproduce the issue? Yes: current source shows a cold validation scan followed by a separate listing decode, and the supplied benchmark measures that path; this read-only review did not rerun it. Is this the best way to solve the issue? Yes: passing completed metadata across the existing owner boundary removes duplicate work without skipping validation or changing database-handle retention. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against bcecb3d1d19a. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* origin/main: (46 commits) fix(gateway): keep chat metadata responsive across auth refresh (openclaw#139192) fix(doctor): keep Workshop relocation lint read-only (openclaw#139193) perf(ui): retain unchanged forwarded avatar publications (openclaw#139181) fix(config): guide exec policy migration repairs (openclaw#139143) test(i18n): refresh representative Watch key (openclaw#139197) fix(agents): preserve recovered scheduled-run outcomes (openclaw#139037) refactor(acp): simplify pending operation accounting (openclaw#139189) fix(plugin-sdk): harden account scope for pairing requests and challenges (openclaw#139142) perf(gateway): avoid redundant PR landing ancestry checks (openclaw#139186) perf(ui): release captured audio cache leases directly (openclaw#139174) fix(skills): validate names in library forms (openclaw#139184) fix(sessions): reduce cold catalog listing delays (openclaw#139146) perf(cron): scan preserved action output once (openclaw#139163) fix(agents): keep fresh tool results readable under context pressure (openclaw#139165) fix(compaction): heartbeat sessions ignore the active transcript byte cap (openclaw#136533) perf(agents): reuse snapshotted web search result rows (openclaw#139162) fix(onboarding): keep Tauri setup recoverable and verify model results (openclaw#139140) fix(memory): rank indexed sessions by source activity (openclaw#139112) perf(terminal): avoid rebuilding sanitized link fallbacks (openclaw#139159) perf(agents): bound retained tool result projection data (openclaw#139157) ...
Reuse completed canonical validation metadata for the first listing cache read. Recheck the connection data version before reuse and preserve full-entry reads, Doctor projections, and existing cache invalidation.
Reuse completed canonical validation metadata for the first listing cache read. Recheck the connection data version before reuse and preserve full-entry reads, Doctor projections, and existing cache invalidation. (cherry picked from commit d1df83e)
What Problem This Solves
Resolves a problem where operators opening or refreshing session catalogs wait unnecessarily for locally stored metadata when database handles are cold. Large inventories amplify that delay.
Why This Change Was Made
Reuse the metadata already parsed by canonical-key validation during the same listing read. The cache checks SQLite’s connection-local data version before consuming those complete facts and uses its existing fresh SELECT if an external commit intervened.
Retained-window keys, timestamp filtering, owner and participant projection, Doctor’s full entries, cache invalidation and fresh delivery privacy keep their existing contracts. No schema, migration, configuration, RPC, cache lifetime or retained-handle policy changes. Production LOC is +87/-28 (net +59); tests are +247/-2. The assertion baseline decreases one existing allowance from 3 to 2.
User Impact
Cold metadata listings, including
sessions.catalog.list, perform less synchronous work. The large-inventory proof showed roughly 31–33% shorter cold handler times. Warm full-page reads showed a modest measured increase, recorded below; this is not a universal speedup claim.Evidence
Linux Node 24.19.0 / SQLite 3.53.3 proof used the actual Gateway request router, synthetic authenticated connect metadata and real SQLite. All 864 final response digests and row, enumeration and progress counts matched between variants in each timing/SQL-diagnostic matrix. The matrix covers small/large inventories, sparse/full pages, temporary/held handles, native/adopted rows and progress/final delivery. A separate privacy control held provider planning fixed while a draft transition removed the progress row and restoration returned the final row. No WebSocket handshake or live provider call is claimed.
For two agents with 5,000 stored entries each and eight adopted hosts, handler elapsed medians were:
Cold cells use three miss/hit pairs. Warm cells use 60 observations per variant across two processes in ABBA order. The final large warm full-page median with fresh enumeration increased 1.6%; an earlier run measured 3.4%. The immediately repeated cached-enumeration request increased from 29.77 to 30.30 ms (1.8%). Both are retained, with no causal explanation inferred. Separate SQL diagnostics showed 11 metadata scans returning 55,000 rows versus 22 scans returning 110,000 rows in the large sparse cold case.
All 159 focused owner/sibling tests, focused typed lint, cycle checks and the complete unchanged changed-file gate passed. The original implementation failed both decode-once regressions. The full gate took 956.1 seconds; all observed process groups closed, source inventories stayed unchanged and the test lease is completed. Earlier assertion bookkeeping, fixture typing and lint failures were corrected and retained with the refused finished-lease reuse attempt.
The source proof used base e55f25b plus this change. Rebasing onto current main preserved all six runtime/test postimages and merged only the strict assertion-count decrement into its updated baseline. Independent P2 review is clean. Fresh exact-head CI passed for
dc3abd02ce8fc494557bd723a9b57d02a9d552dband the current dependency graph; CodeQL also passed.