Skip to content

perf(gateway): reuse session catalog entry snapshots per request - #114358

Merged
steipete merged 2 commits into
mainfrom
perf/gateway-session-catalog-relist
Jul 27, 2026
Merged

steipete merged 2 commits into
mainfrom
perf/gateway-session-catalog-relist

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

sessions.catalog.list — the sidebar CODING/catalog surface — averaged 620ms (max 1829ms) on team.openclaw.ai. Profile attribution shows the catalog path re-listing and JSON-parsing entire session stores multiple times inside one request: helper scans (Claude 1, Codex local 1, Codex nodes 1) plus one gateway re-list per unique adopted session key. With ~180 sessions per store, one request repeated the same SQLite enumeration and entry_json parse H+U times.

Why This Change Was Made

One lazily built, request-scoped session-entry snapshot per touched agent/store (session-catalog-entry-snapshot.ts), shared across all catalogs, hosts, helpers, progressive frames, and the final projection. This is intra-request "carry prepared facts forward" — deliberately not a cross-request cache, since session entries are not process-stable. Callers without a snapshot keep the runtime fallback. Ordering and response shape unchanged; plugin discovery files untouched (that half landed separately in #114324).

User Impact

Catalog listing cost stops scaling with (stores × helpers × adopted sessions); the sidebar coding section loads with one store enumeration per agent. Gains grow with store size and adopted-session count.

Evidence

  • Production latency + profile attribution above (parseSqliteSessionEntryJson via listSqliteSessionEntriesFromDatabase <- resolveSqliteScope inside the catalog path).
  • Counting-stub test proves the store is listed once per request where it was previously listed per helper+key; response-equality fixtures unchanged.
  • Suites: gateway catalog 19/19, Codex catalog 89/89, Anthropic catalog 41/41 (re-run post-rebase: 3 shards green); touched-file lint + Plugin SDK boundary checks pass; git diff --check clean; no CHANGELOG edits; all new exports multi-consumer (knip-safe).
  • Autoreview (Codex gpt-5.6-sol, xhigh): clean, "patch is correct (0.86)".

@steipete
steipete marked this pull request as ready for review July 27, 2026 05:53
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 2:08 AM ET / 06:08 UTC.

ClawSweeper review

What this changes

The branch creates a lazy per-request snapshot of persisted session entries and passes it through gateway, Codex, and Anthropic catalog providers so one catalog request does not repeatedly enumerate the same agent stores.

Merge readiness

⛔ Blocked until real behavior proof is added - 6 items remain

This PR addresses a real catalog-listing cost, but it is not ready to merge. It extends the public session-catalog plugin contract without visible owner approval and still lacks inspectable after-fix runtime proof; the existing protected maintainer label also requires human handling.

Priority: P3
Reviewed head: 8c9ac6ddf6734b77cffa456e6ec757685a7338dc
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The optimization has useful implementation and test signal, but the unresolved public-contract decision and missing real behavior proof prevent merge readiness.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR describes pre-change profiling and focused tests, but it does not provide inspectable after-fix live output, a trace, or a redacted runtime artifact that demonstrates fewer session-store listings. Add such evidence with private endpoints, identifiers, and other sensitive details redacted; updating the PR body should trigger review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR describes pre-change profiling and focused tests, but it does not provide inspectable after-fix live output, a trace, or a redacted runtime artifact that demonstrates fewer session-store listings. Add such evidence with private endpoints, identifiers, and other sensitive details redacted; updating the PR body should trigger review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Public plugin contract change: The patch adds an optional request-owned sessionEntries field to the public SessionCatalogListProviderParams contract and exports new snapshot types/helpers through the plugin SDK facade. Repository policy treats plugin API additions as compatibility-sensitive and requires explicit maintainer-visible direction.
Gateway-to-provider propagation: The new gateway helper lazily reads entries per normalized agent and passes the snapshot into catalog listing, which is the intended single-request performance boundary.
Prior review blocker remains: The prior completed ClawSweeper review identified approval for the public snapshot contract as a P1 concern. The supplied follow-up context contains a typed-test/knip commit but no visible maintainer decision approving this new SDK surface.
Findings 1 actionable finding [P1] Obtain approval for the public snapshot contract
Security None None.

How this fits together

The gateway handles sessions.catalog.list by collecting catalog hosts from registered providers and projecting persisted session metadata into the response. Codex and Anthropic providers currently need session-store entries to identify adopted sessions, so the proposed snapshot carries one request-local view of those entries across the provider calls.

flowchart LR
  Client[Control UI catalog request] --> Gateway[Gateway catalog handler]
  Gateway --> Snapshot[Request-local session-entry snapshot]
  Gateway --> Providers[Registered catalog providers]
  Snapshot --> Codex[Codex catalog provider]
  Snapshot --> Anthropic[Anthropic catalog provider]
  Codex --> Result[Catalog hosts and sessions]
  Anthropic --> Result
  Result --> Client
Loading

Decision needed

Question Recommendation
Should the request-scoped session-entry snapshot become part of the public session-catalog plugin contract, or should the optimization use a narrower internal/injected runtime seam? Use a narrower internal seam: Keep request-local reuse inside the gateway/runtime injection boundary so third-party catalog providers do not inherit a new public API obligation.

Why: The patch adds a reusable public plugin API surface rather than only changing gateway internals; repository policy requires maintainer-visible direction for plugin SDK additions.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR describes pre-change profiling and focused tests, but it does not provide inspectable after-fix live output, a trace, or a redacted runtime artifact that demonstrates fewer session-store listings. Add such evidence with private endpoints, identifiers, and other sensitive details redacted; updating the PR body should trigger review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Obtain approval for the public snapshot contract (P1) - This adds sessionEntries to the public catalog-provider request and exports the associated snapshot API. The repository policy treats new plugin SDK surfaces as compatibility-sensitive, but the supplied discussion shows no maintainer decision that this should be a supported external provider contract; either obtain that approval or keep the optimization behind a narrower internal runtime seam.
  • Resolve merge risk (P1) - A new public plugin-SDK request field and helper/types can become a permanent compatibility obligation for catalog providers without an explicit owner decision on whether this contract should be public.
  • Resolve merge risk (P1) - The performance claim is plausible and covered by counting stubs, but no inspectable after-fix runtime trace currently proves that real catalog requests enumerate each affected store only once.
  • Complete next step (P2) - A maintainer must choose whether the new public plugin-SDK contract is acceptable; the remaining proof must come from the contributor’s real runtime setup.

Findings

  • [P1] Obtain approval for the public snapshot contract — src/plugins/session-catalog.ts:19
Agent review details

Security

None.

PR surface

Source +95, Tests +103. Total +198 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 8 229 134 +95
Tests 1 123 20 +103
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 352 154 +198

Review metrics

Metric Value Why it matters
Plugin SDK catalog surface 1 optional provider parameter, 2 exported types, 1 exported helper added These additions extend the contract available to catalog plugins, so their permanence and lifecycle need an explicit compatibility decision.

Stored data model

Persistent data-model change detected: serialized state: extensions/anthropic/session-catalog-runtime.ts, serialized state: extensions/anthropic/session-catalog.ts, serialized state: extensions/codex/src/session-catalog-node-adoption.ts, serialized state: extensions/codex/src/session-catalog.ts, serialized state: src/gateway/server-methods/session-catalog-entry-snapshot.ts, serialized state: src/gateway/server-methods/session-catalog.test.ts, and 8 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm or narrow the SDK contract (recommended)
    Before merge, obtain an explicit owner decision on the public snapshot API; if it is not intended as a supported plugin capability, keep the data flow behind a narrower gateway/runtime seam.
  2. Accept the public API deliberately
    Merge the exported contract only after documenting its request lifetime and maintaining compatibility coverage for external catalog providers.

Technical review

Best possible solution:

Keep the optimization request-scoped, obtain an explicit owner decision on the public plugin-SDK shape, and attach redacted after-fix runtime evidence that compares the catalog request’s store-listing behavior before and after the change.

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

No high-confidence live reproduction is included in the review material. Source inspection of the proposed path supports the repeated-read mechanism, but the claimed production latency reduction needs after-fix runtime evidence.

Is this the best way to solve the issue?

Unclear: a request-local snapshot matches the repository’s prepared-facts guidance, but exposing it through the public plugin SDK is not yet established as the best boundary; a narrower injected runtime seam may avoid a permanent provider contract.

Full review comments:

  • [P1] Obtain approval for the public snapshot contract — src/plugins/session-catalog.ts:19
    This adds sessionEntries to the public catalog-provider request and exports the associated snapshot API. The repository policy treats new plugin SDK surfaces as compatibility-sensitive, but the supplied discussion shows no maintainer decision that this should be a supported external provider contract; either obtain that approval or keep the optimization behind a narrower internal runtime seam.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.82

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ffec7731a4ac.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P3: The item is a bounded performance optimization with no reported functional outage or urgent regression.
  • merge-risk: 🚨 compatibility: The branch changes the public session-catalog plugin request contract and exports new SDK symbols that external providers could adopt.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR describes pre-change profiling and focused tests, but it does not provide inspectable after-fix live output, a trace, or a redacted runtime artifact that demonstrates fewer session-store listings. Add such evidence with private endpoints, identifiers, and other sensitive details redacted; updating the PR body should trigger review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Public plugin contract change: The patch adds an optional request-owned sessionEntries field to the public SessionCatalogListProviderParams contract and exports new snapshot types/helpers through the plugin SDK facade. Repository policy treats plugin API additions as compatibility-sensitive and requires explicit maintainer-visible direction. (src/plugins/session-catalog.ts:19, 8c9ac6ddf673)
  • Gateway-to-provider propagation: The new gateway helper lazily reads entries per normalized agent and passes the snapshot into catalog listing, which is the intended single-request performance boundary. (src/gateway/server-methods/session-catalog-entry-snapshot.ts:21, 8c9ac6ddf673)
  • Prior review blocker remains: The prior completed ClawSweeper review identified approval for the public snapshot contract as a P1 concern. The supplied follow-up context contains a typed-test/knip commit but no visible maintainer decision approving this new SDK surface. (src/plugin-sdk/session-catalog.ts:2, a37c55f8466f)
  • Related work is distinct: The related merged PR perf(plugins): memoize channel catalog discovery #114324 memoized process-stable plugin discovery. This PR instead snapshots mutable session entries only for one request, so it remains independently necessary. (ccd6845e4d48)
  • Proof remains insufficient: The PR body reports pre-change production profiling and focused test results, but the supplied discussion contains no redacted after-fix trace, live output, or artifact demonstrating the reduced session-store reads. (8c9ac6ddf673)

Likely related people:

  • steipete: Authored the related merged gateway/plugin-catalog performance work and the current session-catalog optimization, making this the strongest available routing signal for the affected catalog path. (role: recent area contributor; confidence: medium; commits: ccd6845e4d48, a37c55f8466f, 8c9ac6ddf673; files: src/gateway/server-methods/session-catalog.ts, src/plugins/session-catalog.ts, src/gateway/server-methods/session-catalog-entry-snapshot.ts)

Rank-up moves

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

  • Obtain explicit owner approval for the public plugin-SDK contract or narrow the data flow to an internal seam.
  • Attach redacted after-fix runtime output or profiling evidence showing one session-store enumeration per affected agent during a catalog request.

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 (1 earlier review cycle)
  • reviewed 2026-07-27T05:58:37.370Z sha a37c55f :: needs real behavior proof before merge. :: [P1] Obtain approval for the public snapshot contract

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 27, 2026
@steipete
steipete merged commit 7b71d56 into main Jul 27, 2026
128 of 130 checks passed
@steipete
steipete deleted the perf/gateway-session-catalog-relist branch July 27, 2026 06:14
@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

extensions: anthropic extensions: codex gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant