Skip to content

fix(codex): keep session catalog queries in memory - #150659

Merged
steipete merged 35 commits into
mainfrom
steipete/perf-resident-session-catalog-20260917
Sep 18, 2026
Merged

steipete merged 35 commits into
mainfrom
steipete/perf-resident-session-catalog-20260917

Conversation

@steipete

@steipete steipete commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #150112, #150514, #150196

What Problem This Solves

Fixes slow sidebar catalog polling when unchanged Codex histories repeatedly trigger native discovery and preview parsing.

User Impact

Catalog pages, cwd filters, and title searches use resident display rows while the home fits in memory. Native events keep Gateway-driven threads current; archive acknowledgements hide rows immediately. Ephemeral helpers are excluded, Codex's selected rollout remains authoritative, and open sources retain their live activity/settings even when cached rows are evicted.

The 20,000-row retention cap does not limit discovery. Saturated searches and older pages use bounded native database-only requests, which can be slower and perform foreground projection. Cold startup uses a bounded first-page wait with existing continuation/retry responses; saved SQLite rows remain available during reconciliation. The wire contract and sidebar polling cadence are unchanged.

Why This Change Was Made

One index per Codex home replaces per-query TTL/head-page producers. Reconstructible display rows use OpenClaw's SQLite plugin state, C2's 500-character preview bound and prefix selector, and tie-safe pagination. Native metadata owns displayed fields and selected paths. Notifications, database-only metadata walks, and a streamed 30-second day-folder stat scan maintain currency; only changed rollouts receive bounded reads.

A foreground fallback request shares one 20-native-read budget and deadline across title search, exclusion filling, scheduler steps, and nested metadata/membership/descendant reads. It retains one 64-row page at a time and preserves directional continuation. Source health settles once for the complete fallback outcome; closing abandons its probe. Background hydration keeps its separate grouped attempt and budget. Overflow uses the same live settings/status owners before filtering; remote exact access always verifies fresh non-archived membership, including resident hits. Node lookup no longer treats 100 pages as absence.

Gateway aggregation coalesces concurrent operations only and uses #150196's resident session-row projection. Current binding/state authority checks remain. Progress retains one latest one-host frame per selected catalog/host and one preparation job per subscriber; memory scales with distinct selected pairs. Retirement clears queued frames and joins admitted work. Generic admission/lifetime handling remains for providers, remote transport, progress, and shutdown.

Zero I/O applies only to local queries answered entirely from resident rows. Saturation discovery, exact actions, remote enumeration, and Gateway authority checks are outside that claim. Native thread/list has no bounded response projection: the catalog discards unused fields and detaches bounded metadata after decode, but full wire JSON still creates transient allocations.

No new configuration, sidecar, table, or schema version is introduced. Admission and restoration cap each home at 20,000 rows, evicting archived-oldest first. Fields, paths, queues, fingerprints, and cursor history are bounded; strings are detached. Realistic row JSON measures 214,561 bytes at 490 rows and 8,880,042 bytes at 20,000 rows.

Maximum admitted UTF-16 text payload per home 490 current rows 20,000 current rows
Rows only 12,219,620 B 498,760,000 B
Settled rows plus independently full field/path indexes 495,100,132 B 981,640,512 B
Conservative active-owner inventory, charging all independent caps together 4,483,373,422 B 4,969,913,802 B

Capacity charges two bytes per UTF-16 unit. The active inventory overcounts phases that normally cannot peak together and includes old row generations, pending persistence/projection work, paths, cursors, and cleanup keys. Ancillary collections can remain at 20,000 entries with only 490 current rows. Object/allocator overhead, native/caller buffers, pre-admission callbacks, provenance caches, generic SQLite predecode, and Gateway progress frames are excluded. This is not a total heap/RSS ceiling.

Evidence

Current landing CI: Exact-head run 35286681006 completed successfully for 28dbe04fd14e98c48c59b53f02b101cbb26921b8. The earlier observation below is historical.

Earlier voice-call teardown observation

Published head 28dbe04fd14e98c48c59b53f02b101cbb26921b8 is OPEN, ready, and MERGEABLE; the worktree is clean and synced. Exact-head CI is blocked by voice-call shard teardown in job 105420675832 (checks-node-changed-extensions-bundle-33). All 165 tests in its 15 files passed, then Vitest reported one unhandled teardown error: [vitest-pool-runner]: Timeout waiting for worker to respond. No test assertion failed and no specific test is attributed. The exact-head rollup failed and the bounded watch exited 15; the overall run was still in_progress at the last read, so no final run conclusion is claimed.

This is an untouched voice-call owner teardown blocker: none of the 15 shard files or other voice-call files changed in this branch. The database-worker list only adds six Codex paths and changes no runner runtime. Cause and flakiness are not established. No retry, timing change, assertion weakening, or merge followed the failure.

The previous timeout-forwarding regression is fixed in 28dbe04fd14e98c48c59b53f02b101cbb26921b8. Undefined timeout remains undefined outside foreground scope, while scoped reads retain their remaining deadline. Tests were unchanged: valid red reproduced one failure / 13 passed; the corrected run passes 253 tests in 21 files, scoped P2 review and the full changed-file check pass, and the original bundle-31 job now succeeds. The same-repository PR still reports maintainerCanModify: false; both authorized enabling attempts were rejected by tooling input protection, with no bypass or setting-success claim.

Current U/V proof passes 240 tests in 21 files: 239 regression tests in 20 files plus a disjoint composed benchmark. All seven new regressions pass after the final test-declaration cleanup. The earlier focused 61-test run overlaps and is not added. Valid red proof reproduced four failures: 400 native reads against a 20-read limit in inline/stepped filling, and six calls rather than four when a later page failed. The completed fixes preserve assertions, budgets, and background hydration ownership.

Earlier meaningful regressions cover ephemeral helpers and restart, selected paths, native metadata and live activity, cold navigation, bounded restoration, exact membership, and independent host progress. Archive and Gateway-selection fixture gaps found by CI were corrected through their real membership/readiness contracts. Earlier upstream guard failures were incorporated from main. No failed hosted job was rerun; detailed history and retained logs remain in the lane report.

A broader historical run passed 908 tests and timed out once across 79 files. The native-allocation fixture exceeded its unchanged 120,000 ms limit and was reported at 124,751 ms. It was not rerun, skipped, or given a larger budget. Its earlier successful measurements are retained below as historical evidence.

The local query measurement is refreshed from the now-committed timeout-forwarding repair. The composed result remains the prior U/V measurement; it was not rerun and is not presented as a new timing for this repair. The local fixture mocks native latency and measures 100 warm lists across the former TTL boundary. Neither fixture measures saturation fallback latency or CPU. Cold/native-walk measurements below are older and labeled separately.

Measurement Before Resident
List p50 0.106 ms 0.123917 ms
List p95 2.064 ms 0.201000 ms
thread/list calls per 100 lists 109 0
Main-thread CPU per list 0.319 ms 0.157890 ms

The composed fixture uses the actual Gateway handler, public plugin registration, real SQLite stores, 3,000 native rows, 3,000 local rows, and three actual Continue adoptions. A synthetic loopback endpoint supplies hydration. Four warmed head/search/opaque-cursor variants precede 100 measured lists; startup calibration confirms the counters see the real paths.

Composed warm request measurement Result
p50 / p95 7.060042 / 67.805084 ms
Main-thread CPU per list 7.05727 ms
Native RPCs / filesystem read-open calls / plugin-worker operations per list 0 / 0 / 0
Total explicit SQLite read statements per list 20
Global SQLite freshness / native binding authority / other SQL reads per list 3 / 3 / 14
Session-entry table SQL reads per list 0
Session payload SQL reads per list 0
Sampled allocations per list, separate instrumented pass 5,602,052.48 B
Preview / terminal-sanitizer self-samples, separate 710-sample CPU profile 0 / 0

Median meets the 20 ms goal. The observed 67.805084 ms p95 is higher than the prior pre-U/V 15.038833 ms result; no cause is inferred and the earlier value is not substituted. Global SQLite freshness counts state-database checks, not session-entry cache reads. The other-SQL bucket is not fully classified. Non-admin visibility retains its canonical profile-count authority read; administrators bypass that irrelevant query. Counters measure API calls/statements rather than disk access; sampling can miss calls shorter than its interval. No authority cache was added to force zero SQL.

The historical native comparison uses 3,000 threads, 64 KiB first-user previews, 199,026,000 rollout bytes, and 47 database-only pages, with the same prepared-preview map in both modes. It measures the retained-response boundary, not current-head or foreground-list latency. The later timed-out run produced no replacement measurements.

Instrumented native walk Ordinary response Catalog boundary
Retained 64-row page JSON 4,278,468 B 75,972 B
Retained-page heap delta after GC 4,254,496 B -296,232 B
Post-walk heap delta after GC -217,848 B 47,688 B
Sampled walk allocations 602,581,440 B 615,272,248 B
Sampled peak heap growth 45,556,480 B 76,210,880 B
Sampled peak RSS growth 88,457,216 B 112,738,304 B
Instrumented walk elapsed 4,983.840 ms 4,355.072 ms

Signed heap deltas include GC noise; negative values are not negative retained memory. Peaks were sampled at page boundaries. Retained responses shrink, but total allocations and RSS peaks are not shown lower. Removing wire/JSON allocation requires an upstream bounded projection.

The historical cold fixture contains 490 rollouts totaling 267,304,800 bytes. Native initialization took 12.607327 seconds. First data—64 rows and a cursor—arrived 2.263123 seconds after list start, or 14.881307 seconds since launch. All rows and the completion marker were durable 17.877998 seconds since launch: eight pages and 5.259816 seconds hydration. SQLite restart returned 64 rows in 498.922458 ms, with zero native list calls. Initialization is the largest measured component; no cause for timing variation is inferred. Test-runner compilation is excluded.

No production deployment or post-deployment CPU profile is claimed. The docs cover hydration, currency, overflow, bounds, and remaining I/O.

Complete review dispositions: 1–12 and A–V
Finding Disposition
1 — ephemeral helpers Fixed: common admission excludes ephemeral metadata and removes existing rows; completion/restart regression passes.
2 — obsolete ancestors Fixed: native metadata owns the selected path; fallback cannot retarget known rows.
3 — displayed metadata Fixed: database-only walks update displayed fields and explicit clears with revision fencing.
4 — source closure Fixed: closing a physical source withdraws only its activity/settings observations.
5 — native settings and recency Fixed for Gateway-driven threads; external sampled-record limitations remain deferred as described below.
6 — zero-I/O scope Fixed: ready Gateway entry snapshots and local queries wholly inside the resident window are memory-backed. Saturation uses foreground native discovery/projection; current native binding/state authority reads remain visible in measurements.
7 — performance proof Fixed: composed real-store fixture covers head/search/cursors, actual adoptions, calibrated I/O counters, CPU and allocations.
8 — cold startup Fixed: first-page availability is bounded, with confirmed-prefix cursors and existing retry responses.
9 — bounds Fixed for admitted rows and pending work; broader engine and generic predecode limits are disclosed.
10 — response retention Fixed at the catalog boundary; upstream wire/JSON allocations remain deferred because native thread/list has no bounded projection.
11–12 — informational contracts Preserved: mutation/persistence ownership, cache cutover, result shape, UI cadence, and metadata overlay.
Full review A — remote recovery Fixed: a completed replacement walk satisfies the pending snapshot refresh, so initialization cannot await itself; later periodic currency still works.
Full review B — snapshot read failure Fixed: the existing persistence owner invalidates completeness and cannot recertify unread stale keys in that lifetime. Memory remains available; the next successful restart enumerates and prunes stale rows.
Full review C — fresh selected path Fixed: native thread/read selection can supersede a stale resident path after revert; root containment, identity and provenance checks remain.
Full review D — moved backward anchor Fixed: both directions compare the frozen cursor ordering tuple; backward pages exclude the anchor identity after a turn moves it.
Full review E — backward round trip Fixed: forward continuation uses all eligible rows even when a backward result excludes its anchor.
Full review F — shutdown persistence failure Fixed: completeness deletion joins an already-admitted drain after retirement; new row and completion-marker writes remain rejected.
Full review G — archive during restoration Fixed: an archive persists removal even before its snapshot row materializes, preventing resurrection on the next restart.
Full review H — incomplete backward page Fixed: backward pages retain forward continuation while hydration is incomplete, including when the anchor was archived.
Full review I — snapshot-read serialization Fixed: the persistence owner drains admitted writes before reading a snapshot, while the restoration observation fences later mutations. Writer ownership clears before promise settlement, and draining joins following writes. The free snapshot export is removed; capacity regressions use the real persistence owner.
Full review J — backward clamping and empty-prefix continuation Fixed: a removed preceding page clamps backward navigation to the current matching head; an empty incomplete prefix keeps its hydration frontier for forward continuation.
Full review K — deadline excludes retired persistence drain Fixed: control.listPage starts the budget before index acquisition, bounds the retirement wait, and passes the same absolute deadline to index.list. Shared admitted writes continue draining.
Full review L — partial Zstd prefix Deferred with coordinator authorization: valid sampled compressed prefixes can fail before reaching the output bound. This affects external fallback freshness; failure is retryable and preserves existing rows. Native Gateway-driven metadata remains authoritative.
M — discovery beyond the retained window Fixed: saturated scoped searches, exhausted resident paging, and native cursors use bounded authoritative database-only pages; the snapshot records overflow. Exact remote/node access verifies authoritative membership beyond the retained window instead of reporting eviction as absence. Recent unfiltered resident pages remain memory-only.
N — remote membership on resident hits Fixed: remote exact eligibility always verifies fresh archived:false membership, including cached rows; local guards are unchanged.
O — live settings in overflow Fixed: the shared settings owner supplies live cwd/model before filtering; each native adapter is bound to its home.
P — progress per catalog/host Fixed: retain one latest one-host frame per selected catalog/host and one preparation job per subscriber; memory scales with distinct selected hosts.
Q — live settings survive resident eviction Fixed: bounded row eviction/rejection is separate from authoritative removal, retaining live fields while their source remains open.
R — source-owned status on overflow pages Fixed: capture the status revision before the native read, pass the row through the shared status observer, and project source-owned status.
S / CI — archive membership fixtures Fixed: membership/descendant responses and pinned sequencing are correct, with empty/wrong-thread rejection coverage. All 188 local tests in 15 files and the scoped review pass; the repair is included in the current candidate.
T — Gateway selection fixture readiness Fixed: initialized shared context and owner materialization before both snapshots; assertions and guard unchanged. All 1,566 tests in 37 files, full P2 review, and full checks pass. The repair is included in the current candidate.
U — complete foreground native-read budget Fixed: one shared 20-read budget/deadline spans scheduler steps, visible filling, native pages, and nested reads. Local regression/review/checks pass; the current CI blocker is unrelated voice-call teardown.
V — complete fallback source-health outcome Fixed: settle one attempt for the whole fallback; close abandons its probe. Background hydration stays independent. Local regression/review/checks pass; the current CI blocker is unrelated voice-call teardown.
CI — default timeout forwarding Fixed: undefined timeout remains undefined outside foreground scope; scoped reads retain the remaining deadline. Unchanged assertions pass in 253 tests / 21 files, and scoped review is clean. Committed, full checks pass, and the corresponding hosted bundle-31 job succeeds.
CI blocker — voice-call worker teardown Unrelated owner blocker at STOP: all 165 tests / 15 files passed, followed by one unhandled worker-response timeout. No assertion failed, no specific test attributed, and cause/flakiness unproven.
CI — import topology Fixed: unchanged resident row/fingerprint types live in a leaf module; local and hosted architecture checks pass with zero cycles.
CI — test routing order Fixed: the existing performance fixture entry is sorted without membership or assertion changes; both tooling files pass 143 tests and hosted routing checks pass.
CI — creator publication fixture Fixed: the direct-handler fixture uses the existing full Gateway context and startup projection; all 26 focused tests pass with unchanged assertions.
CI — main-side TS2741 guard Resolved upstream by #151062, included in the local candidate base.
Guard — Slack private import Resolved upstream by #151080, now incorporated by the authorized rebase. Included in the rebased base.

Follow-ups

  • External-origin fallback can miss JSONL records crossing sampled boundaries or first-user content outside the bounded prefix/tail. Gateway-driven metadata, live settings, and turn-start recency come from native observations. Existing rows keep their known preview when sampling misses it; a new immutable external rollout without a sampled preview can remain undiscovered until it changes.
  • A capped Zstd prefix can fail before reaching the decoded-output limit for some valid low-compression streams. Failures remain retryable and preserve existing rows; complete-record and compressed-tail fallback freshness remain separate work.
  • A nonempty raw preview consisting only of whitespace/control text may be sanitized again by background walks after its bounded display preview becomes empty. Queries served entirely from resident rows do no preview derivation; saturation fallback can project newly fetched native rows on the foreground path.
  • Native wire responses still include full previews. Eliminating their transient JSON allocation requires an upstream bounded projection; the retained-response reduction does not establish that all process RSS bursts are eliminated.
  • The generic plugin-state entries() API decodes a complete namespace before extension validation. Resident admission limits bound retained catalog data, not that generic predecode peak for abnormal stored values. The generic one-MiB value allowance permits 19.532 GiB serialized across 20,001 abnormal entries before validation. Normal catalog writes contain only bounded row metadata; a paged generic state reader is separate work.

Maintainer landing applicability

The maintainer ruling at 00:28Z classifies this as a reconstructible cache over the existing PluginStateKeyedStore SDK contract, stored under a new namespace. It changes no schema, migration, Doctor, update, service-lifecycle, or plugin-loading path. Older versions ignore unknown plugin-state keys; an empty candidate cache repopulates. A separate published-driver × candidate update-proof cell does not apply to this PR.

The supplemental core-tarball probe retained the published external Codex plugin because the ordinary core package excludes it. Its empty-snapshot assertion therefore did not exercise C3 and is an artifact-selection gap, not an established candidate defect. That proof work was stopped and all owned leases were closed. The coordinator-approved full-scope review and the fresh bounded review are clean at P2; older discovery, the shared scan allowance, and logical backoff settlement are covered by the recorded regressions.

@clawsweeper

clawsweeper Bot commented Sep 17, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: codex labels Sep 17, 2026
@steipete
steipete marked this pull request as ready for review September 17, 2026 06:02
@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Sep 17, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 17, 2026, 7:43 PM ET / 23:43 UTC (Revision 18).

ClawSweeper review

What this changes

The PR serves Codex session listings and searches from shared in-memory indexes, saves reconstructible metadata in SQLite, and refreshes it through native events and background reconciliation.

Merge readiness

⛔ Blocked before merge - 4 items remain

This remains useful work beyond the merged catalog optimizations. The earlier budget and backoff defects are addressed, and inspection found no new blocking correctness finding. The maintainer-authored, protected PR should remain open.

Priority: P2
Reviewed head: 28dbe04fd14e98c48c59b53f02b101cbb26921b8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful native and real-store proof supports a coherent implementation with no new blocking correctness finding; upgrade validation remains outstanding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The matching full-body evidence and inspected fixture exercise the resident catalog through a real Codex app-server and SQLite storage, including complete hydration and restart with zero native list calls. Composed Gateway measurements supplement this; published-updater compatibility remains separately unverified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The matching full-body evidence and inspected fixture exercise the resident catalog through a real Codex app-server and SQLite storage, including complete hydration and restart with zero native list calls. Composed Gateway measurements supplement this; published-updater compatibility remains separately unverified.
Evidence reviewed 11 items Complete captured PR body recovered: Read the complete body, including native measurements, review dispositions, and deferred limitations. Its 21,012 UTF-16 units and SHA-256 3173b8988146bdc6612a54eeb274d35b53b6c9ef6457332d4dffdd774966a699 match the supplied snapshot. Cold startup and same-candidate SQLite restart are reported; published-driver upgrade and rollback evidence is not supplied.
Current main still uses expiring query caches: Current main retains the 32-second cache, per-query native page production, and periodic native refreshes. The merged work at #150112 and #150514 improves that implementation but does not provide this resident-index cutover.
Introduced persistence and service lifecycle: The branch opens a per-home plugin-state namespace capped at 20,001 entries and registers a catalog startup/shutdown service. This is an actual persisted-cache and lifecycle change despite introducing no table or schema-version bump.
Findings None None.
Security None None.

How this fits together

The Codex plugin turns native session metadata into searchable session listings. The Gateway combines those listings with current OpenClaw session identity and visibility rules before returning them to clients.

flowchart TD
  A[Native Codex sessions] --> B[Background reconciliation]
  B --> D[Resident home index]
  C[SQLite metadata snapshot] --> D
  D --> C
  E[List or search request] --> D
  D -->|Beyond retained window| F[Native overflow paging]
  D --> G[Gateway visibility checks]
  F --> G
  G --> H[Session sidebar]
Loading

Before merge

  • Resolve merge risk (P1) - Existing installations will activate a new persistent catalog service; published-driver upgrade and rollback behavior remains unverified despite cold-start and same-candidate restart coverage.
  • Complete next step (P2) - Record published-driver upgrade and rollback evidence for the new catalog snapshot service using existing operator state.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +3,388 lines; tests and test support net +6,827 lines The stated production growth implements residency, persistence, reconciliation, and overflow discovery, with corresponding lifecycle regression coverage.
New persistence contract 1 per-home namespace; maximum 20,000 rows plus 1 completion marker The new durable cache needs upgrade compatibility evidence even without a schema-version change.

Stored data model

Persistent data-model change detected: unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify the installed-updater transition (recommended)
    Record a published-driver upgrade into this candidate and rollback using copied existing state, confirming catalog startup, session availability, and preserved settings.

Technical review

Best possible solution:

Keep the single resident catalog owner and native overflow discovery, with upgrade and rollback evidence demonstrating that existing installations retain usable sessions and settings.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: repeated catalog requests crossing main’s 32-second cache lifetime restart native refresh work. The PR includes measured before/after fixtures; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes, the shared resident owner removes repeated query-time discovery while preserving authoritative overflow paging and current visibility checks. Upgrade safety remains a separate validation gap.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2694bc6f3438.

Labels

Label justifications:

  • P2: This improves repeated Codex session discovery with a bounded product scope; the reported CI teardown does not establish urgent user impact.
  • merge-risk: 🚨 compatibility: A new startup service writes persistent catalog snapshots, and existing-install upgrade and rollback behavior has not been demonstrated.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The matching full-body evidence and inspected fixture exercise the resident catalog through a real Codex app-server and SQLite storage, including complete hydration and restart with zero native list calls. Composed Gateway measurements supplement this; published-updater compatibility remains separately unverified.
  • proof: sufficient: Contributor real behavior proof is sufficient. The matching full-body evidence and inspected fixture exercise the resident catalog through a real Codex app-server and SQLite storage, including complete hydration and restart with zero native list calls. Composed Gateway measurements supplement this; published-updater compatibility remains separately unverified.

Evidence

What I checked:

  • Complete captured PR body recovered: Read the complete body, including native measurements, review dispositions, and deferred limitations. Its 21,012 UTF-16 units and SHA-256 3173b8988146bdc6612a54eeb274d35b53b6c9ef6457332d4dffdd774966a699 match the supplied snapshot. Cold startup and same-candidate SQLite restart are reported; published-driver upgrade and rollback evidence is not supplied. (28dbe04fd14e)
  • Current main still uses expiring query caches: Current main retains the 32-second cache, per-query native page production, and periodic native refreshes. The merged work at fix(codex): bound session catalog memory and preserve tied rows #150112 and fix(codex): reduce CPU cost of large catalog previews #150514 improves that implementation but does not provide this resident-index cutover. (extensions/codex/src/session-catalog-index.ts:15, 2694bc6f3438)
  • Introduced persistence and service lifecycle: The branch opens a per-home plugin-state namespace capped at 20,001 entries and registers a catalog startup/shutdown service. This is an actual persisted-cache and lifecycle change despite introducing no table or schema-version bump. (extensions/codex/index.ts:196, 28dbe04fd14e)
  • Persistence recovery implementation: Snapshot reads drain admitted writes; retirement joins the writer; write failures invalidate completeness. These support restart recovery but do not independently demonstrate compatibility with a published updater and rollback. (extensions/codex/src/session-catalog-index-state.ts:182, 28dbe04fd14e)
  • Prior findings addressed: Foreground work now shares one request-owned native-read budget, deadline, and terminal backoff outcome across scheduler steps and exclusion filling. Focused regressions cover the 20-read ceiling, later-page failure, nested reads, and abandoned probes. The current control code preserves undefined standalone timeout defaults. (extensions/codex/src/session-catalog-list-request.ts:84, 28dbe04fd14e)
  • Current identity before delivery: The Gateway waits for projection readiness, then synchronously resolves current visibility and compares captured adoption identity before publishing. The real-store regression replaces a session during provider enumeration and verifies that the old native row receives neither the replacement session key nor its creator. (src/gateway/server-methods/session-catalog.ts:357, 28dbe04fd14e)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record published-driver upgrade and rollback evidence for the new snapshot service.

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.

History

Review history (17 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-17T19:08:35.897Z sha 840111c :: blocked before merge. :: [P2] Share the native scan budget with exclusion filling | [P2] Settle fallback backoff after the whole search completes
  • reviewed 2026-09-17T20:14:42.951Z sha c49f563 :: blocked before merge. :: [P2] Share the native scan budget with exclusion filling | [P2] Settle fallback backoff after the whole search completes
  • reviewed 2026-09-17T20:24:40.802Z sha c49f563 :: blocked before merge. :: [P2] Share the native scan budget with exclusion filling | [P2] Settle fallback backoff after the whole search completes | [P2] Update pinned archive fixtures for fresh membership checks
  • reviewed 2026-09-17T20:54:49.921Z sha 4e10caa :: blocked before merge. :: [P2] Share the native scan budget with exclusion filling | [P2] Settle fallback backoff after the whole search completes | [P2] Synchronize the selection fixture with projection readiness
  • reviewed 2026-09-17T21:32:49.690Z sha 6e9c175 :: blocked before merge. :: [P2] [P2] Share the native scan budget with exclusion filling | [P2] [P2] Settle fallback backoff after the whole search completes
  • reviewed 2026-09-17T21:56:19.321Z sha 6e9c175 :: blocked before merge. :: [P2] [P2] Share the native scan budget with exclusion filling | [P2] [P2] Settle fallback backoff after the whole search completes
  • reviewed 2026-09-17T22:55:42.829Z sha 078cf26 :: blocked before merge. :: none
  • reviewed 2026-09-17T23:34:31.846Z sha 28dbe04 :: blocked before merge. :: none

@steipete
steipete marked this pull request as draft September 17, 2026 06:35
@steipete
steipete force-pushed the steipete/perf-resident-session-catalog-20260917 branch from dc04bc6 to e1f99af Compare September 17, 2026 16:04
@steipete
steipete marked this pull request as ready for review September 17, 2026 16:05
@steipete
steipete requested a review from a team as a code owner September 17, 2026 16:05
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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 17, 2026
@steipete
steipete force-pushed the steipete/perf-resident-session-catalog-20260917 branch from 840111c to c49f563 Compare September 17, 2026 20:06
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 17, 2026
Keep repeated sidebar catalog queries in memory instead of expiring per-query native pages. Hydrate and persist bounded per-home rows, maintain them from native events and background reconciliation, and preserve stable pagination keys.

Remove settled Gateway catalog caching so resident changes are visible on the next list. Keep the existing wire contract and 500-character display previews.
@steipete
steipete merged commit 9627506 into main Sep 18, 2026
375 of 379 checks passed
@steipete
steipete deleted the steipete/perf-resident-session-catalog-20260917 branch September 18, 2026 00:38
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 18, 2026
…1304)

The plugin npm security scan flagged the new
src/session-catalog-native-performance.test-support.ts in @openclaw/codex
(#150659) as an unexpected dangerous-exec finding and blocked release
2026.9.5 validation (run 35294789789). The helper spawns the real Codex
app-server once under its owned test state to time catalog queries, which
is the same reviewed class as the existing app-server test fixtures. Record
it in the current reviewed inventory.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 18, 2026
* perf(codex): serve session catalogs from resident home indexes

Keep repeated sidebar catalog queries in memory instead of expiring per-query native pages. Hydrate and persist bounded per-home rows, maintain them from native events and background reconciliation, and preserve stable pagination keys.

Remove settled Gateway catalog caching so resident changes are visible on the next list. Keep the existing wire contract and 500-character display previews.

* fix(codex): bound catalog scans and backward pages

Stream rollout directories into a bounded fingerprint inventory while retaining presence checks for existing rows. End backward pages before their cursor anchor when page sizes or preceding rows change.

Preserve the upstream preview selector for optional rollout messages and migrate the incoming discovery and node-listing tests to resident paging.

* refactor(codex): keep catalog fingerprints in the state contract

Remove the type-only state/scanner import cycle while preserving the fingerprint shape and runtime behavior. Both runtime and Madge cycle checks now pass.

* fix(codex): preserve lazy catalog registration imports

Load the canonical sanitizer only when native or rollout metadata is derived. Keep plugin registration and resident list queries outside the text-chunking runtime while preserving preview output.

* fix(codex): exclude ephemeral helper threads from resident catalog

Apply native ephemeral admission to hydration and lifecycle refreshes, removing previously admitted rows. Verify helper-owned completion and SQLite restart keep these threads absent.

* fix(codex): preserve native selected rollout paths during reconciliation

Use the database-only metadata walk for selected paths and prevent retained ancestors from retargeting resident rows. Preserve local membership when the native database is unavailable, with removals owned by events and verified file absence.

* perf(codex): bound recurring catalog response retention

Reduce native catalog replies before promise delivery and reuse resident previews for unchanged metadata. Keep ordinary native responses exact and measure retained pages separately from unavoidable wire parsing allocations.

* fix(codex): scope catalog activity to native connections

Preserve activity observed by another connection when a helper closes. Attribute native replies without retaining clients or persisting activity, and fence stale replies after source withdrawals.

* fix(codex): refresh all displayed resident catalog metadata

Project native metadata changes and clears even when activity timestamps remain unchanged. Reuse prepared previews and preserve newer Gateway observations against delayed catalog pages.

* fix(codex): keep catalog workspace and activity current

Preserve native workspace metadata during rollout reconciliation and publish live resume settings. Keep bounded previews current and preserve observed turn-start order across delayed reads and reconciliation.

* fix(codex): show catalog progress during cold startup

Wait for usable hydration progress instead of returning a false empty catalog. Keep partial cursors within the confirmed prefix and restore complete SQLite views before database-only reconciliation.

* fix(codex): bound resident catalog metadata and pending work

Keep oversized snapshots and background work from retaining unbounded catalog metadata. Apply one row admission limit during restoration and live updates, detach retained strings, and replace recursive watching with streamed reconciliation.

* test(gateway): measure resident catalogs through real stores

Exercise catalog polling and continuation bindings through the registered provider and real SQLite stores. Report authority reads separately from the resident query and verify warm lists avoid native discovery and file reads.

* refactor(codex): keep app-server protocol under the line cap

Keep the native session-source vocabulary in one sibling while preserving protocol exports. Place the existing assertion explanation beside its use and apply the authorized one-entry assertion baseline reduction.

* test(codex): preserve resident search continuation coverage

Keep the upstream sparse-search and managed-session exclusion regression on the resident provider boundary after the native producer cutover.

* refactor(codex): keep snapshot row decoding private

* refactor(codex): satisfy catalog lifecycle lint contracts

Keep source lifetime control flow explicit and remove unnecessary allocations from the regression fixtures without changing catalog behavior.

* fix(codex): recover catalogs after connection and snapshot faults

Finish replacement hydration without awaiting its own initializer. Invalidate durable completeness after a failed snapshot read so unread stale rows cannot be recertified. Cover both recovery paths and keep the index construction contract in a bounded sibling module.

* perf(gateway): use resident session rows for catalog queries

Read catalog planning and delivery entries from the runtime session-row projection while preserving fresh identity checks. Bound deferred progress to one pending publication per subscriber and measure the composed flow with the real resident owner and SQLite stores.

* test(gateway): type deferred catalog progress payloads

* test(gateway): await catalog fixture cleanup

* fix(codex): preserve catalog selection across thread changes

Accept the native selected rollout after a revert while preserving provenance validation. Keep backward pagination anchored to the cursor's frozen ordering key when a turn moves its row.

* fix(codex): preserve catalog navigation and shutdown recovery

Keep forward continuation after backward navigation, and invalidate snapshot completeness when an admitted write fails during shutdown. Drain startup currency before arranging the reconciliation race regression.

* fix(codex): retain catalog changes during startup

Persist archive notifications before snapshot rows materialize, and keep forward continuation on backward pages while hydration remains incomplete.

* fix(codex): order catalog restoration after pending mutations

Keep snapshot reads with the persistence owner and drain writes admitted during settlement. Preserve navigation when earlier catalog rows disappear, including during hydration.

* refactor(codex): separate catalog row contracts from persistence

Move shared row and fingerprint types into a leaf module so ordering and persistence no longer form a type dependency cycle.

* test(gateway): initialize catalog creator fixture projection

Use the shared Gateway context and startup projection in the creator-alias catalog publication regression. Preserve its visibility, freshness, and lookup-budget assertions.

* fix(codex): bound catalog waits across configuration reloads

Start the list deadline before acquiring the resident index and carry it through page availability. Expired callers return the existing loading response while admitted persistence writes continue safely.

* fix(codex): preserve discovery beyond resident catalog limits

Keep older native sessions discoverable after metadata eviction through bounded authoritative paging and exact-thread lookup. Preserve resident fast paths, request deadlines, cursor direction, and the existing memory limits.

* fix(catalog): keep native eligibility and progress current

Verify remote non-archived membership even for retained threads, apply live workspace settings to overflow pages, and retain each catalog and host update while identity preparation waits.

* fix(codex): preserve live catalog state beyond retention

Older resumed threads retain their live workspace and activity after row eviction. Overflow pages share the source-owned status projection and fence delayed native observations.

* test(codex): align archive fixtures with current membership

Exercise pinned archive actions after fresh native membership verification. Preserve status, descendant, connection, and outcome assertions, and explicitly reject empty or missing membership.

* test(gateway): await catalog projection readiness

Initialize the selection fixture through the shared session read context and drain materialization before planning and delivery snapshots. Preserve every selection assertion and the production snapshot guard.

* fix(codex): bound the complete native catalog fallback

Share the existing read budget and deadline across search, exclusion filling, and nested lookups. Settle source backoff once per completed request and release abandoned probes while preserving grouped hydration.

* fix(codex): preserve passive read timeout defaults

Keep standalone catalog reads on the control client timeout default. Apply the shared remaining deadline only inside a foreground fallback request.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 18, 2026
…nclaw#151304)

The plugin npm security scan flagged the new
src/session-catalog-native-performance.test-support.ts in @openclaw/codex
(openclaw#150659) as an unexpected dangerous-exec finding and blocked release
2026.9.5 validation (run 35294789789). The helper spawns the real Codex
app-server once under its owned test state to time catalog queries, which
is the same reviewed class as the existing app-server test fixtures. Record
it in the current reviewed inventory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: codex gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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