Repository navigation
perf: count large histories before Gateway prewarm - #117118
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 10:55 PM ET / August 1, 2026, 02:55 UTC. ClawSweeper reviewWhat this changesThis PR counts the SQLite session rows for every Gateway sidebar projection before startup prewarming, skipping optional session-list and catalog cache warming above 2,000 rows while retaining request-time handlers. Merge readinessKeep this PR open for explicit maintainer review: current Priority: P1 Review scores
Verification
How this fits togetherAfter Gateway reports ready, a background scheduler prewarms dashboard session, plugin, and catalog caches. This PR makes the scheduler inspect the session-store work first so a large history does not synchronously block health or RPC traffic behind optional cache population. flowchart LR
A[Gateway reports ready] --> B[Dashboard prewarm scheduler]
B --> C[Resolve per-agent session-store targets]
C --> D[Read-only SQLite row counts]
D --> E{Within 2,000-row budget?}
E -->|Yes| F[Warm session and catalog caches]
E -->|No| G[Skip optional caches and log reason]
G --> H[Authoritative request-time handlers]
F --> H
Before merge
Agent review detailsSecurityNone. PR surfaceSource +102, Tests +112. Total +214 across 10 files. View PR surface stats
Review metricsNone. 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: Land the shared count-before-projection guard if the Gateway owner accepts the bounded cold-cache tradeoff, preserving plugin metadata warming and authoritative request-time session/catalog handling for oversized histories. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main synchronously loads each agent’s combined session store before applying its catalog-only entry limit. The branch’s focused 2,001-row Gateway test also establishes the intended repaired behavior, although this read-only review did not execute it. Is this the best way to solve the issue? Yes. Resolving one target set at the combined-store owner and using a raw read-only row count is a narrower, safer fix than counting after projection or adding a separate Gateway-only interpretation of custom, incognito, and shared stores. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 87e900bb6409. LabelsLabel 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 (3 earlier review cycles)
|
|
Applied every move from the latest ClawSweeper review at exact head
No move was skipped. |
|
Merged via squash.
|
* origin/main: fix(onboard): stop a full reset from resetting the default workspace when the config is unreadable (openclaw#114110) refactor(i18n): remove unused Apple contradiction report (openclaw#117182) fix(google): stop scraping Gemini CLI OAuth credentials (openclaw#117167) perf: count large histories before Gateway prewarm (openclaw#117118) fix(signal): restore provider-safe original attachment filenames (openclaw#115107) refactor(channels): unify setup ownership across bundled channels (openclaw#117188) fix: allow gateway service commands for named profiles (openclaw#116314) fix(plugins): invalidate bundled artifact locations after metadata refresh (openclaw#117041) fix(ollama): honor model requests and pull completion contracts (openclaw#117171) fix(agents): prevent fallback after stale lifecycle abort (openclaw#117168) fix(telegram): confirm polling before long poll (openclaw#116970) fix(tlon): wire autoDiscoverChannels through the settings-store round-trip (openclaw#114949) fix(gateway): yield before post-ready background work (openclaw#117083) test(google): cover live transcript overflow fix(google): bound live transcript accumulation
* commit '441d6ab254df14fb6939a8a261f474904ff9c500': (388 commits) fix(qqbot): ignore blank app id fallbacks (openclaw#109460) fix(feishu): consume implicit reply targets across media delivery (openclaw#117196) fix(exec): preserve approved command output when sessions resume (openclaw#117177) fix(qa): use public subagent fanout evidence (openclaw#116832) fix(googlechat): cancel unread auth response bodies before release (openclaw#115873) fix(queue): prevent cron saturation from starving hook dispatch (openclaw#116666) fix(gateway): sessions.steer retry no longer interrupts an active run when replaying a cached idempotency key (openclaw#116969) fix(irc): config validation rejects documented channels.irc.configWrites key (openclaw#112392) fix(mistral): keep terminal error branch lint-clean fix(onboard): stop a full reset from resetting the default workspace when the config is unreadable (openclaw#114110) refactor(i18n): remove unused Apple contradiction report (openclaw#117182) fix(google): stop scraping Gemini CLI OAuth credentials (openclaw#117167) perf: count large histories before Gateway prewarm (openclaw#117118) fix(signal): restore provider-safe original attachment filenames (openclaw#115107) refactor(channels): unify setup ownership across bundled channels (openclaw#117188) fix: allow gateway service commands for named profiles (openclaw#116314) fix(plugins): invalidate bundled artifact locations after metadata refresh (openclaw#117041) fix(ollama): honor model requests and pull completion contracts (openclaw#117171) fix(agents): prevent fallback after stale lifecycle abort (openclaw#117168) fix(telegram): confirm polling before long poll (openclaw#116970) ...
* perf(gateway): count before sidebar prewarm * fix(sessions): narrow count row before normalization * fix(gateway): align sidebar prewarm admission targets * test(gateway): prove large prewarm stays optional * fix(gateway): budget repeated shared-store prewarm
* origin/main: fix(onboard): stop a full reset from resetting the default workspace when the config is unreadable (openclaw#114110) refactor(i18n): remove unused Apple contradiction report (openclaw#117182) fix(google): stop scraping Gemini CLI OAuth credentials (openclaw#117167) perf: count large histories before Gateway prewarm (openclaw#117118) fix(signal): restore provider-safe original attachment filenames (openclaw#115107) refactor(channels): unify setup ownership across bundled channels (openclaw#117188) fix: allow gateway service commands for named profiles (openclaw#116314) fix(plugins): invalidate bundled artifact locations after metadata refresh (openclaw#117041) fix(ollama): honor model requests and pull completion contracts (openclaw#117171) fix(agents): prevent fallback after stale lifecycle abort (openclaw#117168) fix(telegram): confirm polling before long poll (openclaw#116970) fix(tlon): wire autoDiscoverChannels through the settings-store round-trip (openclaw#114949) fix(gateway): yield before post-ready background work (openclaw#117083) test(google): cover live transcript overflow fix(google): bound live transcript accumulation
* commit 'ae4e662145b6aa162777cdb1c011b3f04ddd230d': (388 commits) fix(qqbot): ignore blank app id fallbacks (openclaw#109460) fix(feishu): consume implicit reply targets across media delivery (openclaw#117196) fix(exec): preserve approved command output when sessions resume (openclaw#117177) fix(qa): use public subagent fanout evidence (openclaw#116832) fix(googlechat): cancel unread auth response bodies before release (openclaw#115873) fix(queue): prevent cron saturation from starving hook dispatch (openclaw#116666) fix(gateway): sessions.steer retry no longer interrupts an active run when replaying a cached idempotency key (openclaw#116969) fix(irc): config validation rejects documented channels.irc.configWrites key (openclaw#112392) fix(mistral): keep terminal error branch lint-clean fix(onboard): stop a full reset from resetting the default workspace when the config is unreadable (openclaw#114110) refactor(i18n): remove unused Apple contradiction report (openclaw#117182) fix(google): stop scraping Gemini CLI OAuth credentials (openclaw#117167) perf: count large histories before Gateway prewarm (openclaw#117118) fix(signal): restore provider-safe original attachment filenames (openclaw#115107) refactor(channels): unify setup ownership across bundled channels (openclaw#117188) fix: allow gateway service commands for named profiles (openclaw#116314) fix(plugins): invalidate bundled artifact locations after metadata refresh (openclaw#117041) fix(ollama): honor model requests and pull completion contracts (openclaw#117171) fix(agents): prevent fallback after stale lifecycle abort (openclaw#117168) fix(telegram): confirm polling before long poll (openclaw#116970) ...
What Problem This Solves
Completes the large-history Gateway recovery from #117108. Live deployment showed the event loop still blocked before catalog prewarming, while the sidebar session-list prewarm materialized a 15k-row store. Two consecutive starts reported ready and then timed out
/healthzand RPC while consuming one CPU core for more than eight minutes.Root Cause
PR #115710 (
14ad80481ae1, 2026-07-29) added unconditional post-ready sidebar prewarming. Its 60-session output limit applied only after every configured, custom/discovered, fixed-owner, and open-incognito store had been synchronously projected. PR #117108 skipped the later catalog prewarm but still paid this earlier full-store cost.The first version of this PR had two important gaps: its count path still ran cold-handle canonical JSON validation, and it counted only default durable stores while projection could load custom/discovered and open-incognito stores. The current head fixes both at their shared combined-store owner.
Why This Change Was Made
The combined-store owner now resolves one target policy for both admission and projection. A raw count-only SQLite query checks every physical store the optional prewarm may load, including custom/discovered, fixed-owner, and open-incognito databases. Above 2,000 rows, sidebar-session and catalog prewarming are skipped while plugin metadata still warms. Request-time session and catalog handlers remain authoritative, and startup records the intentional skip without exposing paths or session data.
User Impact
Gateways with large histories remain responsive after restart instead of blocking health and update verification behind optional dashboard cache population. Normal-size stores retain the existing prewarm order.
Evidence
2a893066d499b9799de39bef81d24d1704322ed4: 127 focused tests passed across Gateway prewarm, combined/custom/incognito store selection, and the session accessor.entry_validthrough a separate SQLite connection and proves the admission count returns without parsing or validating entry JSON.sessions.listrequest in 424 ms.Exact-head CI is in progress. Production-shaped sustained health/RPC proof will run immediately after merge through the supported updater before the remaining fleet advances.