Skip to content

perf(gateway): share one node.list snapshot across session catalog providers - #114646

Merged
steipete merged 1 commit into
mainfrom
perf/catalog-node-list-snapshot
Jul 27, 2026
Merged

steipete merged 1 commit into
mainfrom
perf/catalog-node-list-snapshot

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

sessions.catalog.list on team.openclaw.ai is the top remaining Control UI cost after the recent perf fleet: 962 calls averaging 567ms in 5h, with 837 of them inside a uniform 200-600ms band — and single-catalog probes cost ~450ms for every provider, including ones whose data sources are absent on the box. That uniformity is a fixed shared cost, not data weight: every catalog provider (Claude, Codex, OpenCode, Pi) independently dispatches node.list per request, and each dispatch materializes both device-pairing SQLite tables twice (4 full scans), so an unfiltered request pays ~16 table scans before any session data is read.

Why This Change Was Made

The catalog request already carries a request-owned sessionEntries snapshot (#114358); this extends the same pattern to nodes. The gateway resolves node.list lazily, at most once per catalog request, and shares the promise with every provider via a new optional listNodes field on the provider query (additive plugin-SDK surface, doc-commented; providers without it keep the runtime.nodes.list() fallback, so external SDK consumers are unaffected). Providers that never touch nodes trigger zero dispatches — laziness is part of the contract and regression-tested.

User Impact

Unfiltered catalog listings drop from ~16 pairing-table scans to 4; sidebar catalog refreshes stop multiplying node-registry work by provider count. No response-shape change; SDK change is additive-optional.

Evidence

Follow-up (separate PR): node.list's own handler still materializes both pairing tables twice per dispatch (src/gateway/server-methods/nodes.read.ts:213, src/infra/device-pairing-store.ts:247) — the remaining ~single-dispatch floor.

@steipete
steipete marked this pull request as ready for review July 27, 2026 16:59
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Jul 27, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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, 1:05 PM ET / 17:05 UTC.

ClawSweeper review

What this changes

This PR lets selected session-catalog providers share one lazy Gateway node.list result during a catalog request, avoiding repeated node discovery while retaining each provider’s existing runtime fallback.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 5 items remain

Keep this PR open for maintainer review. The request-scoped lazy snapshot is a coherent extension of the recently merged session-entry snapshot pattern, but the new optional catalog-provider SDK parameter needs explicit contract approval and the submitted evidence does not show an after-fix live catalog request or measured improvement.

Priority: P3
Reviewed head: 756ec522e115d283d05fb2a6f9a76352f39b11a8
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and regression-tested, but real after-fix behavior proof is still a merge gate.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR supplies focused tests, CI, a hosted Testbox link, and baseline production observations, but no redacted after-fix live catalog trace or measurement proving the shared node-list behavior; add that evidence to the PR body and redact private endpoints, IPs, and credentials. 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 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR supplies focused tests, CI, a hosted Testbox link, and baseline production observations, but no redacted after-fix live catalog trace or measurement proving the shared node-list behavior; add that evidence to the PR body and redact private endpoints, IPs, and credentials. 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 Request-scoped sharing: The PR adds a lazily initialized promise around the Gateway node runtime and passes the same callback into every selected provider, preserving zero dispatches when no selected provider invokes it.
Additive provider contract: The provider list parameters gain one optional listNodes callback with an explicit request-lifetime restriction; bundled providers use it when present and retain runtime.nodes.list() otherwise.
Regression coverage: The new Gateway tests assert one node-list dispatch across multiple providers and preserve laziness when the selected provider does not use nodes; extension tests cover the request callback and fallback paths.
Findings None None.
Security None None.

How this fits together

The Gateway’s sessions.catalog.list handler asks selected provider plugins to produce session hosts for clients such as the Control UI. Providers may need the Gateway node registry to find remote hosts; this change supplies one request-owned lookup so multiple providers reuse the same node-list operation.

flowchart LR
  Request[Catalog request] --> Gateway[Gateway catalog handler]
  Gateway --> Snapshot[Lazy request node snapshot]
  Gateway --> Providers[Selected catalog providers]
  Snapshot --> Providers
  Providers --> Hosts[Session catalog hosts]
  Hosts --> Response[Catalog response]
Loading

Decision needed

Question Recommendation
Should the request-owned listNodes callback become the approved session-catalog provider SDK contract, rather than remaining an internal Gateway-only optimization seam? Approve the additive provider callback: Accept listNodes as the documented request-lifetime catalog-provider capability and retain the fallback for providers called outside Gateway catalog requests.

Why: The patch is additive and preserves fallback behavior, but it introduces a new provider-list API that external plugins could adopt; that permanent boundary requires maintainer intent rather than an inferred implementation choice.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR supplies focused tests, CI, a hosted Testbox link, and baseline production observations, but no redacted after-fix live catalog trace or measurement proving the shared node-list behavior; add that evidence to the PR body and redact private endpoints, IPs, and credentials. 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.
  • Resolve merge risk (P1) - The new optional listNodes field expands the session-catalog plugin contract; its long-term public SDK ownership and retention semantics need maintainer confirmation before merge.
  • Resolve merge risk (P1) - The supplied proof establishes tests and baseline production cost, but not an observed after-fix request showing one node-list dispatch and the claimed improvement on a real Gateway setup.
  • Complete next step (P2) - The remaining gates are maintainer approval of a new plugin-contract seam and contributor-supplied real behavior proof, not a narrow mechanical repair.
Agent review details

Security

None.

PR surface

Source +24, Tests +120. Total +144 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 6 30 6 +24
Tests 5 144 24 +120
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 174 30 +144

Review metrics

Metric Value Why it matters
Catalog-provider SDK parameters 1 added, 0 removed The optional request-owned node lookup is an additive plugin contract and should be explicitly approved before external providers rely on it.

Stored data model

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

Merge-risk options

Maintainer options:

  1. Approve the SDK seam and add live proof (recommended)
    Confirm the optional callback is the intended plugin contract, then add a redacted after-fix Gateway trace or terminal capture proving one node-list dispatch for a multi-provider catalog request.
  2. Keep the optimization internal
    If maintainers do not want this provider API, redesign the request sharing behind the existing Gateway/provider boundary before landing.

Technical review

Best possible solution:

Keep the snapshot request-scoped and lazy, document and approve the optional provider callback as the intended plugin contract, then add redacted after-fix live Gateway evidence showing the shared dispatch and performance effect.

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

Yes, source-reproducible: the added Gateway test models multiple selected providers invoking the supplied callback and verifies a single node-list dispatch. The submitted context does not provide an independently observed live after-fix run.

Is this the best way to solve the issue?

Unclear: request-scoped lazy sharing matches the merged session-entry snapshot pattern and preserves provider fallbacks, but maintainers must first confirm that exposing this as a catalog-provider SDK parameter is the best permanent boundary.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a bounded performance optimization with no demonstrated correctness regression or urgent user-facing outage.
  • add merge-risk: 🚨 compatibility: Adding listNodes changes the session-catalog provider API and establishes retention and fallback expectations for plugin authors.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR supplies focused tests, CI, a hosted Testbox link, and baseline production observations, but no redacted after-fix live catalog trace or measurement proving the shared node-list behavior; add that evidence to the PR body and redact private endpoints, IPs, and credentials. 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.

Label justifications:

  • P3: This is a bounded performance optimization with no demonstrated correctness regression or urgent user-facing outage.
  • merge-risk: 🚨 compatibility: Adding listNodes changes the session-catalog provider API and establishes retention and fallback expectations for plugin authors.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR supplies focused tests, CI, a hosted Testbox link, and baseline production observations, but no redacted after-fix live catalog trace or measurement proving the shared node-list behavior; add that evidence to the PR body and redact private endpoints, IPs, and credentials. 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:

  • Request-scoped sharing: The PR adds a lazily initialized promise around the Gateway node runtime and passes the same callback into every selected provider, preserving zero dispatches when no selected provider invokes it. (src/gateway/server-methods/session-catalog.ts:34, 756ec522e115)
  • Additive provider contract: The provider list parameters gain one optional listNodes callback with an explicit request-lifetime restriction; bundled providers use it when present and retain runtime.nodes.list() otherwise. (src/plugins/session-catalog.ts:20, 756ec522e115)
  • Regression coverage: The new Gateway tests assert one node-list dispatch across multiple providers and preserve laziness when the selected provider does not use nodes; extension tests cover the request callback and fallback paths. (src/gateway/server-methods/session-catalog.test.ts:350, 756ec522e115)
  • Related merged design: The supplied related-item context identifies commit 7b71d5608e73c0f6cbe4097c04f9e4bb79544d63 as the merged request-owned session-entry snapshot work, making this node snapshot a related but distinct request-scoped optimization. (src/gateway/server-methods/session-catalog.ts:220, 7b71d5608e73)
  • Real behavior proof gap: The PR body provides baseline production timings plus focused tests, CI, and a Testbox run, but it does not include an after-fix live request trace, dispatch count, or before/after timing demonstrating the claimed reduced node-list work. (756ec522e115)

Likely related people:

  • steipete: This author previously landed the related request-owned session-entry snapshot and authored the current Gateway/provider integration, making them the strongest history-backed routing candidate for the shared catalog-request pattern. (role: recent session-catalog contributor; confidence: high; commits: 7b71d5608e73, 756ec522e115; files: src/gateway/server-methods/session-catalog.ts, src/plugins/session-catalog.ts)

Rank-up moves

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

  • Post a redacted after-fix terminal capture, log excerpt, or live output showing a multi-provider catalog request performs one node-list dispatch and improves the observed path.
  • Obtain maintainer confirmation that the optional listNodes callback is the intended durable session-catalog plugin contract.
  • After adding proof to the PR body, let the automatic review refresh; if it does not, ask a maintainer to comment @clawsweeper re-review.

Rating scale

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

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

Workflow

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

@steipete
steipete merged commit 8f8e40d into main Jul 27, 2026
181 of 191 checks passed
@steipete
steipete deleted the perf/catalog-node-list-snapshot branch July 27, 2026 17: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: acpx extensions: anthropic extensions: codex extensions: opencode 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: M 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