Repository navigation
perf: avoid repeated Codex catalog page scans - #149773
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 2:09 AM ET / 06:09 UTC. ClawSweeper reviewWhat this changesRaises the Codex session-list cache from 32 to 128 completed pages and adds regression coverage for repeated listings across three Codex homes. Merge readiness✅ Ready for maintainer review The change remains useful: current main and the latest release retain the smaller cache, and the related merged timeout fix addresses a different problem. No actionable correctness or security defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s Codex plugin reads native session pages from Codex App Server and filters them into the session catalog. Its shared in-memory cache lets repeated listings reuse completed reads across source homes. flowchart LR
A[Session catalog request] --> B[Select Codex homes]
B --> C[Shared page cache]
C -->|Cached page| E[Filter excluded sessions]
C -->|Missing or expired| D[Codex App Server]
D --> C
E --> F[Visible session listing]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +1, Tests +57. Total +58 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the existing cache owner and freshness lifecycle while retaining enough completed pages for common multi-home exclusion walks. Do we have a high-confidence way to reproduce the issue? Yes, from source: repeating a 60-page traversal against the current 32-entry insertion-order cache evicts later-needed pages as earlier misses refill it. The regression models this path, but tests were not executed during this read-only review. Is this the best way to solve the issue? Yes. Adjusting the existing bounded cache is a narrow repair for this working-set size, and the regression checks both request reuse and unchanged results without adding another cache or public setting. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9b73eb1e90be. 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.
|
#150517) Keep recent native session catalog refreshes reusable while background discovery visits older sessions. Favor at most 20 head-walk pages within the existing 32-page source cache, preserving its expiration policy, native cursors, visibility checks, and shared pending producers. The registered-provider regression eliminates 19 redundant native requests per unchanged head refresh after deeper discovery, with identical results and continuation. Focused catalog and node tests, full changed-file checks, independent review, and exact-head CI passed. Production latency and CPU measurements remain a deployment follow-up. Related: #149773, #149879, #150112.
openclaw#150517) Keep recent native session catalog refreshes reusable while background discovery visits older sessions. Favor at most 20 head-walk pages within the existing 32-page source cache, preserving its expiration policy, native cursors, visibility checks, and shared pending producers. The registered-provider regression eliminates 19 redundant native requests per unchanged head refresh after deeper discovery, with identical results and continuation. Focused catalog and node tests, full changed-file checks, independent review, and exact-head CI passed. Production latency and CPU measurements remain a deployment follow-up. Related: openclaw#149773, openclaw#149879, openclaw#150112.
…ession tests (#176630) ## What Problem This Solves Performance work in OpenClaw keeps fixing the same waste twice: caches that stop hitting, batches that get reverted, and PRs that land with a regression their own numbers already show. Agents had no repository guide for this work, and three flows where the same waste keeps returning had no test that counts it. ## User Impact No user-visible change. Agents doing performance work now have one OpenClaw skill: measure the real flow with a committed workload, count operations first, delete waste before batching or caching, and land only when every user-facing metric holds or improves. Three work-count tests fail CI if known waste comes back. ## Why This Change Was Made A corpus of 103 performance cases from the last 90 days on `main` (70 randomly sampled, 33 seeded with every perf revert; each judged from its diff and PR text): - **Deleting waste lasts:** 3 of 31 random-sample deletes were later re-fixed, and those failed deletes broke a guard, not because the waste returned. - **Caches, batches and worker moves come back:** 4 of 5, 6 of 7 and 5 of 8 were later re-fixed (biased set, a signal not a rate). In 3 of the 4 cache re-fixes the cache silently stopped hitting, e.g. #115369 → #174741 and #149773 → #149879. - **Own regressions predict reverts:** 21 PRs landed while their own numbers showed a large regression; 11 of them were later reverted or re-fixed, against 25 of the other 82. Five of the six reverts had shown the regression in their own body. - **Same waste, again and again:** SQLite schema/admission re-checks (14 PRs, one revert), session list rows (two reverts in two days), model catalog rebuilds. Changes: - `.agents/skills/openclaw-performance/SKILL.md`: measure (committed bench per flow, counts first, acceptance rule before the first run, interleaved samples), find waste (10 recurring OpenClaw patterns with real cases), fix order (delete → once at the owner → carry the prepared fact → batch → cache with a written reason, cache-identity rules and an interleaved work-count test), land (no user-facing metric worse unless the owner accepts it). - Root `AGENTS.md`: the "Do less work" line keeps its core rule and points to the skill. - Work-count tests (counts, never wall time): - `src/state/openclaw-agent-execution.schema-admission.test.ts`: warm chat turns make only their own write requests; no re-open, schema prepare or integrity validation. - `src/gateway/session-row-projection.list-page.test.ts`: after an unrelated subagent renewal, repeating the same pages renders 0 rows, materializes 0 more and does 0 worker reads or SQL. - `src/gateway/server-methods/models-auth-status.work-count.test.ts` (own file, to keep the existing test under its line cap): interleaved `models.authStatus` and `usage.status` page loads add no provider probes, auth-health builds or catalog loads after warm-up. ## Evidence | Test | Back-test (parent of the historical fix) | |---|---| | Schema admission | fails at `8b7917c79b8^` (#166253): each warm turn adds `open` and `prepare` again | | Session list | fails at `1b896e6327f^` (#162280): 80 rows materialized instead of 10, plus 1 worker read | | Models page | fails at `c3f0b6abc01^` (#174741): 3 provider probes in 2 loads; the readers evict each other | - All three pass on head (each file about 0.3–1.7 s); `models-auth-status.test.ts` still passes 52/52. The Models page test still fails at `c3f0b6abc01^` with real-module mocks (one extra provider probe). - The pre-commit hook (line-cap ratchet, `AGENTS.md` size) passed; root `AGENTS.md` is 18,917 characters. - Every PR cited by the skill is merged; every named bench script exists on `main`. Blind replay of 8 held-out performance tasks (none cited by the skill; each from the parent of its known-good fix), Codex agent with and without the skill, 2 seeds; stopped early after 12 judged pairs to free the host: | | Without skill | With skill | |---|---|---| | Pair wins (blind Codex judge) | 3 | 8 (1 tie) | | Removed the same waste as the reference fix | 11/14 runs | 11/13 runs | | Proof includes a work-count test | 5/14 | 11/13 | | Added a cache | 1 | 1 | | Judge: proof / waste found / fix order (1-5) | 3.08 / 4.50 / 4.83 | 4.33 / 4.42 / 4.50 | The skill does not change whether agents find the waste; it changes how they prove it, which is what keeps the waste from returning. One judge and 12 pairs: the win split is not significant (p ≈ 0.23). **Merge danger:** two-way door; a revert removes the skill and the tests. No runtime change. Blast radius: agent instructions for performance work, and three test files. Co-authored-by: Ayaan Zaidi <[email protected]>
…ession tests (openclaw#176630) ## What Problem This Solves Performance work in OpenClaw keeps fixing the same waste twice: caches that stop hitting, batches that get reverted, and PRs that land with a regression their own numbers already show. Agents had no repository guide for this work, and three flows where the same waste keeps returning had no test that counts it. ## User Impact No user-visible change. Agents doing performance work now have one OpenClaw skill: measure the real flow with a committed workload, count operations first, delete waste before batching or caching, and land only when every user-facing metric holds or improves. Three work-count tests fail CI if known waste comes back. ## Why This Change Was Made A corpus of 103 performance cases from the last 90 days on `main` (70 randomly sampled, 33 seeded with every perf revert; each judged from its diff and PR text): - **Deleting waste lasts:** 3 of 31 random-sample deletes were later re-fixed, and those failed deletes broke a guard, not because the waste returned. - **Caches, batches and worker moves come back:** 4 of 5, 6 of 7 and 5 of 8 were later re-fixed (biased set, a signal not a rate). In 3 of the 4 cache re-fixes the cache silently stopped hitting, e.g. openclaw#115369 → openclaw#174741 and openclaw#149773 → openclaw#149879. - **Own regressions predict reverts:** 21 PRs landed while their own numbers showed a large regression; 11 of them were later reverted or re-fixed, against 25 of the other 82. Five of the six reverts had shown the regression in their own body. - **Same waste, again and again:** SQLite schema/admission re-checks (14 PRs, one revert), session list rows (two reverts in two days), model catalog rebuilds. Changes: - `.agents/skills/openclaw-performance/SKILL.md`: measure (committed bench per flow, counts first, acceptance rule before the first run, interleaved samples), find waste (10 recurring OpenClaw patterns with real cases), fix order (delete → once at the owner → carry the prepared fact → batch → cache with a written reason, cache-identity rules and an interleaved work-count test), land (no user-facing metric worse unless the owner accepts it). - Root `AGENTS.md`: the "Do less work" line keeps its core rule and points to the skill. - Work-count tests (counts, never wall time): - `src/state/openclaw-agent-execution.schema-admission.test.ts`: warm chat turns make only their own write requests; no re-open, schema prepare or integrity validation. - `src/gateway/session-row-projection.list-page.test.ts`: after an unrelated subagent renewal, repeating the same pages renders 0 rows, materializes 0 more and does 0 worker reads or SQL. - `src/gateway/server-methods/models-auth-status.work-count.test.ts` (own file, to keep the existing test under its line cap): interleaved `models.authStatus` and `usage.status` page loads add no provider probes, auth-health builds or catalog loads after warm-up. ## Evidence | Test | Back-test (parent of the historical fix) | |---|---| | Schema admission | fails at `04c36511d39^` (openclaw#166253): each warm turn adds `open` and `prepare` again | | Session list | fails at `d13db6a6cc8^` (openclaw#162280): 80 rows materialized instead of 10, plus 1 worker read | | Models page | fails at `c373547bbbd^` (openclaw#174741): 3 provider probes in 2 loads; the readers evict each other | - All three pass on head (each file about 0.3–1.7 s); `models-auth-status.test.ts` still passes 52/52. The Models page test still fails at `c373547bbbd^` with real-module mocks (one extra provider probe). - The pre-commit hook (line-cap ratchet, `AGENTS.md` size) passed; root `AGENTS.md` is 18,917 characters. - Every PR cited by the skill is merged; every named bench script exists on `main`. Blind replay of 8 held-out performance tasks (none cited by the skill; each from the parent of its known-good fix), Codex agent with and without the skill, 2 seeds; stopped early after 12 judged pairs to free the host: | | Without skill | With skill | |---|---|---| | Pair wins (blind Codex judge) | 3 | 8 (1 tie) | | Removed the same waste as the reference fix | 11/14 runs | 11/13 runs | | Proof includes a work-count test | 5/14 | 11/13 | | Added a cache | 1 | 1 | | Judge: proof / waste found / fix order (1-5) | 3.08 / 4.50 / 4.83 | 4.33 / 4.42 / 4.50 | The skill does not change whether agents find the waste; it changes how they prove it, which is what keeps the waste from returning. One judge and 12 pairs: the win split is not significant (p ≈ 0.23). **Merge danger:** two-way door; a revert removes the skill and the tests. No runtime change. Blast radius: agent instructions for performance work, and three test files. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Repeated Codex catalog listings can refetch every native page when a multi-home exclusion walk exceeds the shared 32-page cache. Each early cache miss evicts a page needed later in the same listing.
User Impact
Repeated listings reuse their completed native pages instead of restarting the full scan. First-load latency is unchanged. The bounded completed-page capacity increases from 32 to 128 entries, trading more retained metadata for fewer repeated reads; this is an entry-count limit, not a byte limit.
Why This Change Was Made
Keep the existing cache owner and retain enough pages for several complete source walks and common query variants. The 32-second freshness interval, background refresh, in-flight ownership, source/config isolation, failure backoff, and current visibility checks are unchanged.
Evidence
A synthetic three-home exclusion walk fetches 60 native pages. Repeating the identical listing fetched another 60 pages before this change and zero additional pages afterward, with identical visible results. The regression was demonstrated against the original code.
All 59 focused catalog tests pass, including bounded eviction, stale refresh, request sharing, cancellation, failure backoff, cursor handling, and source isolation. Independent P2 review found no actionable findings. Full changed checks pass; exact-head hosted CI is running. No production latency improvement is claimed from the synthetic request-count result.