Skip to content

fix(sessions): avoid saved-prompt reads when list metadata is current - #149118

Merged
steipete merged 1 commit into
mainfrom
codex/perf-current-session-metadata
Sep 16, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-current-session-metadata

Conversation

@steipete

@steipete steipete commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session lists repeatedly process large saved prompt snapshots while rechecking a page whose current metadata is already loaded.

User Impact

Listing sessions with large saved skill prompts spends less time blocking the Gateway. Full session reads still return their saved prompts, and cache misses retain the existing exact reader.

Why This Change Was Made

Reuse the existing complete metadata cache after fresh database-generation and selected-row identity checks. Copy only requested entries, preserve delivery validation and per-key failures, and recheck freshness after copying. Partial caches, transactions, missing entries, changed generations and uncertain reads use the original path. Profile aliases and membership keep their existing owners.

This adds no persistent cache, schema, migration or permission change.

Evidence

Candidate ad8663633dd6d11c6c753555e303828d803075f5 preserves the complete published four-file patch on fixed main 932846b521c0a9fc0eba711f346621cd3398bcf7, containing planner repair #149726 and the Goal-read/renderer-lint repairs landed with #149697. All four feature files remain byte-identical to 8cb0bd60, and the current-main audit preserves the metadata reader, identity, canonical-validation, transaction and dependency contracts.

The current composition passed 88 tests across seven files on macOS arm64 / Node 26.8.2, including the original Goal edit three-read budget, exact metadata reads, identity publication, canonical validation and transcript import boundaries. Source and runtime hashes remained stable. The retained 148-case integration proof, complete selected checks and independent P2 review apply to the unchanged metadata scope; these test populations overlap and are not summed. No new full typecheck, review, build or benchmark was run solely for the patch-identical refresh.

A retained macOS Node 26.8.2 source-Gateway benchmark used 5,000 synthetic sessions, selecting 200 rows with a valid 128 KiB skill prompt each. Sharing fell from 20 ms to 2–3 ms, and warm descendant requests from 58–64 ms to 40–44 ms. All 12 candidate responses preserved keys, order, metadata and cache roles; copying cost is included. These historical component measurements are bound to their original source and environment, were not repeated for this refresh, and do not establish production page-load performance. Cold first-use probes still reached 122 ms.

Earlier Linux Node 24.19.0 boundary proof passed 62 cases, overlapping later coverage. The previous 8cb0bd60 run 35058496182 failed in renderer line count, planner fixtures and the Goal edit read budget; exact-source comparisons established these as inherited main defects, now repaired in the candidate base. The still-earlier ecd3b604 Active Memory assertion failure remains unattributed. Fresh CI on this candidate remains required before landing.

@clawsweeper

clawsweeper Bot commented Sep 15, 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 15, 2026 13:11
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Sep 15, 2026
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 2:22 AM ET / 06:22 UTC (Revision 6).

ClawSweeper review

What this changes

Reuse current session-list metadata for selected session reads, avoiding repeated saved-prompt processing while preserving full reads and existing fallbacks.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused optimization absent from current main. No actionable correctness or security defect was found, and the retained behavior evidence supports the unchanged patch.

Priority: P2
Reviewed head: ad8663633dd6d11c6c753555e303828d803075f5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with meaningful boundary coverage and relevant retained runtime evidence; no blocking defect was found.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The retained source-Gateway benchmark exercises selected-session sharing and descendant reads through the changed accessor, records lower warm timings with preserved response contents, and remains relevant to the verified unchanged feature files. It does not establish end-to-end production page-load performance.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The retained source-Gateway benchmark exercises selected-session sharing and descendant reads through the changed accessor, records lower warm timings with preserved response contents, and remains relevant to the verified unchanged feature files. It does not establish end-to-end production page-load performance.
Evidence reviewed 9 items Guarded reuse of the existing cache: The new reader requires a complete cache outside a transaction, checks database generations and selected-row identity, clones requested entries, validates canonical delivery keys, and checks freshness again before returning. Uncertain results fall back to the existing reader.
Current main still performs the expensive read: Fetched main unconditionally prepares exact database rows for each batch, including list projections; it does not reuse the complete metadata cache. The inspected implementation uses OpenClaw’s SQLite accessor and has no Codex dependency contract.
Release comparison: The latest supplied release, v2026.9.4, reads each exact candidate through the database reader and also lacks this cache fast path.
Findings None None.
Security None None.

How this fits together

The Gateway rechecks selected sessions before returning lists and sharing metadata. The session accessor reads each agent’s SQLite database and supplies current entries to those callers.

flowchart TD
  A[Selected session keys] --> B[Session accessor]
  B --> C{Complete current metadata cache?}
  C -->|Yes| D[Check row identity and copy metadata]
  D --> E{Still current and canonical?}
  E -->|Yes| G[Return selected entries]
  C -->|No| F[Existing exact database reader]
  E -->|No| F
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +72, Tests +333. Total +405 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 81 9 +72
Tests 1 339 6 +333
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 420 15 +405

Review metrics

Metric Value Why it matters
Production versus test growth production +72 net lines; tests +333 net lines Production growth implements guarded reuse of the existing cache; most added code protects freshness and exact-read equivalence.

Technical review

Best possible solution:

Keep metadata reuse inside the existing cache owner, with exact reads retaining responsibility for full payloads, misses, invalid rows, and uncertain freshness.

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

Yes: current main reprocesses selected entry payloads even after list metadata is loaded; the source path and retained large-prompt Gateway benchmark establish the trigger. This review did not execute tests or a Gateway.

Is this the best way to solve the issue?

Yes: the patch extends the existing cache owner and preserves the exact-reader fallback, avoiding a competing cache or a persistent-data change.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded session-list performance improvement for stores with large saved prompts.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 retained source-Gateway benchmark exercises selected-session sharing and descendant reads through the changed accessor, records lower warm timings with preserved response contents, and remains relevant to the verified unchanged feature files. It does not establish end-to-end production page-load performance.
  • proof: sufficient: Contributor real behavior proof is sufficient. The retained source-Gateway benchmark exercises selected-session sharing and descendant reads through the changed accessor, records lower warm timings with preserved response contents, and remains relevant to the verified unchanged feature files. It does not establish end-to-end production page-load performance.

Evidence

What I checked:

  • Guarded reuse of the existing cache: The new reader requires a complete cache outside a transaction, checks database generations and selected-row identity, clones requested entries, validates canonical delivery keys, and checks freshness again before returning. Uncertain results fall back to the existing reader. (src/config/sessions/session-accessor.sqlite-entry-cache.ts:144, ad8663633dd6)
  • Current main still performs the expensive read: Fetched main unconditionally prepares exact database rows for each batch, including list projections; it does not reuse the complete metadata cache. The inspected implementation uses OpenClaw’s SQLite accessor and has no Codex dependency contract. (src/config/sessions/session-accessor.sqlite-exact-read.ts:175, e2d3d80676f7)
  • Release comparison: The latest supplied release, v2026.9.4, reads each exact candidate through the database reader and also lacks this cache fast path. (src/config/sessions/session-accessor.sqlite-exact-read.ts, 3a9d69db306c)
  • Meaningful regression coverage: The complete test file covers avoided payload reads, returned-object isolation, owner and participant updates, same-connection and external writes, copying races, corrupt identity, per-key errors, incomplete caches, transaction companions, and native-equivalent keys. Tests were inspected, not executed in this read-only review. (src/config/sessions/session-accessor.sqlite-exact-read.test.ts:122, ad8663633dd6)
  • Retained real behavior evidence: The captured PR body reports a macOS arm64 / Node 26.8.2 source-Gateway benchmark with 5,000 synthetic sessions and 200 selected rows carrying 128 KiB prompts: sharing decreased from 20 ms to 2–3 ms and warm descendant requests from 58–64 ms to 40–44 ms, with all 12 candidate responses preserving keys, order, metadata and cache roles. These are historical component measurements, not production page-load claims; the body separately reports 88 passing tests on the refreshed composition.
  • Re-review continuity verified: GitHub’s file blob identities at the previous reviewed head 8cb0bd60f785c98ddf58ffcd1154e71029558b55 match all four current feature-file blobs. This independently confirms the body’s patch-identical refresh claim. The previous completed review retained no findings. (8cb0bd60f785)

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.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-15T13:22:18.719Z sha 73e7bb4 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T19:10:12.656Z sha d8ab064 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T22:35:05.762Z sha 19b521b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-16T02:32:05.482Z sha ecd3b60 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-16T05:20:26.312Z sha 8cb0bd60f785c98ddf58ffcd1154e71029558b55 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/perf-current-session-metadata branch from 8cb0bd6 to ad86636 Compare September 16, 2026 06:07
@steipete
steipete merged commit e1472df into main Sep 16, 2026
329 of 331 checks passed
@steipete
steipete deleted the codex/perf-current-session-metadata branch September 16, 2026 07:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR 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: M 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