Skip to content

perf: avoid repeated Codex catalog page scans - #149773

Merged
steipete merged 1 commit into
mainfrom
codex/perf-catalog-2582
Sep 16, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-catalog-2582

Conversation

@steipete

@steipete steipete commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

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.

@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 16, 2026 05:57
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 2:09 AM ET / 06:09 UTC.

ClawSweeper review

What this changes

Raises 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
Reviewed head: ace4afa7dbac45bfabb059375f18564355a77aee

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused cache adjustment with meaningful regression coverage, an explicit memory tradeoff, and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository context identifies this as maintainer-authored work, exempt from the external-contributor proof gate. Its reported 60-page before/after comparison uses mocked RPC responses through the production cache and traversal; it supports request reuse, not measured production latency.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository context identifies this as maintainer-authored work, exempt from the external-contributor proof gate. Its reported 60-page before/after comparison uses mocked RPC responses through the production cache and traversal; it supports request reuse, not measured production latency.
Evidence reviewed 9 items Verified introduced scope: The pinned merge-base-to-head diff changes only the completed-page capacity and its tests. The supplied verified test merge likewise changes only those two files; unrelated base-branch changes are not attributed to this PR.
Cache ownership and safety: Full control-module inspection confirms the capacity applies to settled results. Pending producers remain separate, configuration identities partition caches, freshness remains 32 seconds, and action eligibility uses uncached native verification rather than trusting cached listing membership.
Meaningful regression coverage: The new test exercises the production control factory and visible-page traversal with three homes and 20 pages each, checking identical visible results and no additional requests on repetition. Existing eviction and pending-refresh pressure tests are updated to the new capacity. The captured PR body reports a failing original-code regression and 59 passing focused tests; this read-only review did not execute them.
Findings None None.
Security None None.

How this fits together

OpenClaw’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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +1, Tests +57. Total +58 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 62 5 +57
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 64 6 +58

Review metrics

Metric Value Why it matters
Completed-page capacity 32 → 128 entries; freshness remains 32 seconds This retains four times as many page entries without extending freshness; the PR explicitly acknowledges that the bound counts entries rather than bytes.

Technical review

Best 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.

Labels

Label changes:

  • add P2: This is a bounded performance improvement for repeated Codex session listings, with no demonstrated urgent outage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository context identifies this as maintainer-authored work, exempt from the external-contributor proof gate. Its reported 60-page before/after comparison uses mocked RPC responses through the production cache and traversal; it supports request reuse, not measured production latency.

Label justifications:

  • P2: This is a bounded performance improvement for repeated Codex session listings, with no demonstrated urgent outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository context identifies this as maintainer-authored work, exempt from the external-contributor proof gate. Its reported 60-page before/after comparison uses mocked RPC responses through the production cache and traversal; it supports request reuse, not measured production latency.

Evidence

What I checked:

  • Verified introduced scope: The pinned merge-base-to-head diff changes only the completed-page capacity and its tests. The supplied verified test merge likewise changes only those two files; unrelated base-branch changes are not attributed to this PR. (extensions/codex/src/session-catalog-control.ts:57, ace4afa7dbac)
  • Cache ownership and safety: Full control-module inspection confirms the capacity applies to settled results. Pending producers remain separate, configuration identities partition caches, freshness remains 32 seconds, and action eligibility uses uncached native verification rather than trusting cached listing membership. (extensions/codex/src/session-catalog-control.ts:606, ace4afa7dbac)
  • Meaningful regression coverage: The new test exercises the production control factory and visible-page traversal with three homes and 20 pages each, checking identical visible results and no additional requests on repetition. Existing eviction and pending-refresh pressure tests are updated to the new capacity. The captured PR body reports a failing original-code regression and 59 passing focused tests; this read-only review did not execute them. (extensions/codex/src/session-catalog-listing-cache.test.ts:23, ace4afa7dbac)
  • Production listing path: The catalog operation constructs the same visible-page traversal for each selected home, passing the current managed-thread exclusion snapshot. Cached pages still pass through exclusion filtering. (extensions/codex/src/session-catalog-list-operation.ts:247, ace4afa7dbac)
  • Current main still uses 32 entries: The fetched main revision retains CODEX_SESSION_CATALOG_LIST_CACHE_MAX_ENTRIES = 32, so this capacity improvement is not already present. (extensions/codex/src/session-catalog-control.ts:56, 9b73eb1e90be)
  • Latest release check: GitHub’s source for v2026.9.4 also retains the 32-entry limit. Its older cache implementation does not contain the requested capacity improvement. (extensions/codex/src/session-catalog-control.ts:48, 3a9d69db306c)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 7b47d7a into main Sep 16, 2026
176 checks passed
@steipete
steipete deleted the codex/perf-catalog-2582 branch September 16, 2026 06:13
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 17, 2026
#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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
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.
obviyus added a commit that referenced this pull request Oct 19, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant