Repository navigation
fix(codex): keep session catalog queries in memory - #150659
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: blocked before merge. Reviewed September 17, 2026, 7:43 PM ET / 23:43 UTC (Revision 18). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherThe 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]
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest 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. 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 (17 earlier review cycles; latest 8 shown)
|
dc04bc6 to
e1f99af
Compare
840111c to
c49f563
Compare
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.
|
Merged via squash.
|
…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.
* 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.
…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.
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.
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
28dbe04fd14e98c48c59b53f02b101cbb26921b8is 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 stillin_progressat 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 reportsmaintainerCanModify: 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.
thread/listcalls per 100 listsThe 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.
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.
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
Follow-ups
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
PluginStateKeyedStoreSDK 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.