Skip to content

perf(gateway): bound session catalog provider waits - #159457

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-catalog-list-waits-for-slowest-provider-20260919
Sep 27, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-catalog-list-waits-for-slowest-provider-20260919

Conversation

@steipete

@steipete steipete commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Related: #127743

What Problem This Solves

A single slow or unreachable session-catalog provider holds the entire sidebar refresh open, even when other providers have already answered.

User Impact

Catalog listing waits at most one second for each provider, concurrently. Fast catalogs remain available; slow providers return catalog_pending and their last good page when available. Failed refreshes retain that page with catalog_stale. Late results refresh the next request. These markers use the existing catalog error and host pending contracts, with no new configuration.

The budget covers provider discovery and admission, not projection preparation or an event-loop stall. A cold provider can initially have no hosts; its late host publications remain supported.

Why This Change Was Made

The aggregate previously awaited every provider. The existing catalog operations owner now keeps at most 128 successful provider pages, scoped to the exact caller and query, with invalidation on config, registration/epoch, Gateway lifetime, and archive changes. Pending refreshes remain shared. Existing admission still limits each provider to one executing step, with 16 global slots and 32 queued calls per provider; a reply deadline does not release unfinished work.

Each cached provider retains its own original adoption identities through final delivery. Current visibility and session identity are rechecked before publishing. The Control UI already requests partial lists (ui/src/components/app-sidebar-session-catalog-live.ts:444), preserves pending-host rows (:174), accepts late host events (:288), and displays catalog errors (ui/src/components/app-sidebar-session-catalogs.ts:123).

Evidence

All heavy validation used blacksmith-testbox, profile openclaw-check, lease tbx_01m3ghjbcvm4pjq7dw58f6hvv8.

  • Registered-handler fixture: three immediate providers plus an eight-second provider. Before: 8,000 ms; after: 1,000 ms, an 87.5% reduction. This is deterministic controlled-clock latency, not a live-server percentile. The one-second assertion failed on the original code.
  • The real Session Share integration fixture now requires all six Gateway callers to return within 1,000 ms, retains one native invoke, and checks privacy again on the late 30-second publication.
  • Regression coverage includes late cache refresh, TIMEOUT/UNAVAILABLE fallback, exact caller/query separation, lifecycle invalidation, retained work ownership, and distinct/reused session-key identity isolation.
  • Existing resident-catalog benchmark (3,000 native + 3,000 local rows): median 2.53 ms, p95 6.35 ms across 100 lists, with its I/O assertions passing.

Validation:

  • node scripts/run-vitest.mjs src/gateway/server-methods/session-catalog*.test.ts: 21 files, 213/214 tests passed. The one failure was a new fixture importing the registry accessor before the shared mock was installed; corrected to import after fixture setup. Final affected-file rerun: 13/13 passed. The other 20 files retain their passing proof.
  • node scripts/check-changed.mjs --base e1b0d1fbdfe933a1e8463a3f26cf0b232eece15e: production and all 25 dependent test typecheck graphs, graph boundary, export audits, and prerequisite guards passed. It then stopped on six lint errors. Those were fixed; the exact targeted lint command, production typecheck, and all remaining native guards passed in a serial follow-up (exit 0). The final copy/style corrections do not change public types; the completed dependent typechecks were reused.
  • Final pnpm test <file> --maxWorkers=1, timed with /usr/bin/time -p: budget regression 12.61 s wall / about 1.0 s test bodies / 12 passed; Session Share integration 11.77 s wall / 44 ms test body / 1 passed. Startup/transform time dominates these wall times; delay fixtures use fake timers. Exact-head CI run 36298247053 passed in 925 s wall time. All PR checks finished green (140 passed, 56 skipped); CI did not publish per-file timing artifacts.
  • Independent Codex review: accepted identity-isolation findings fixed. A subsequent warning about combining live hosts with stale fallback identities was rejected against the existing catalog.error early return in resolvePublishedSessionCatalogs (session-catalog-list-operations.ts:79); error-marked fallback pages cannot enter that reconciliation path.
  • git diff --check passed. Testbox stopped after validation.
Remote validation sequence and repaired failures

All runs used the same provider/profile/lease above; no local suites, builds, or typechecks ran.

Command/scope Result
warmup --keep --timing-json Lease ready.
Initial budget fixture Missing remote dependencies; no product test ran.
pnpm install --frozen-lockfile Passed once on the lease.
Budget fixture on original code Expected regression failure; response at 8,000 ms.
Budget, progress, lifetime files 37 passed; response at 1,000 ms.
Expanded budget fixture Eight passed; fixed test misuse of the async root-admission API.
Initial changed gate Fixed new fixture registry type mismatch.
Four existing dot-named catalog files Resident benchmark passed; Session Share expectation updated from five-second host-pending response to the one-second catalog-pending contract.
All 21 catalog files 213 passed; one mock-import ordering defect, corrected.
Affected files 13 passed.
Final changed gate All typechecks and export audits passed; six style errors corrected.
Changed-gate dry run Passed; selected exact remaining native commands.
Targeted lint, production typecheck, schema/legacy-store/media/sidecar/import-cycle/webhook/pairing guards, affected tests Passed, exit 0; 13 tests passed.
Individually timed changed test files Passed: 12 and 1 tests, respectively.

No production Gateway was changed or restarted. Live deployment latency remains unmeasured.

Return completed catalogs within a one-second provider budget and retain marked stale pages for slow or unavailable providers. Keep late refreshes owned and cached adoption identities isolated through delivery.

Related: #127743
@clawsweeper

clawsweeper Bot commented Sep 27, 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 size: L labels Sep 27, 2026
@steipete
steipete marked this pull request as ready for review September 27, 2026 05:48
@steipete
steipete enabled auto-merge (squash) September 27, 2026 05:50
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 27, 2026, 1:55 AM ET / 05:55 UTC.

ClawSweeper review

What this changes

The Gateway gives each session catalog provider a one-second response budget, retains scoped successful pages for pending or failed refreshes, and adds documentation and regression tests.

Merge readiness

⛔ Blocked before merge - 4 items remain

Current main still waits for slow catalog providers, so this PR addresses a real problem. Keep it open: the proposed timeout can leave completed catalog rows absent from the sidebar and can replace healthy host updates with stale rows.

Priority: P1
Reviewed head: 4ca114a33fcaee8591290bc1b1220a5047327c44

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has focused testbox evidence and a useful performance gain, but two source-backed delivery regressions limit merge confidence.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its reported registered-handler and Session Share fixtures cover the one-second response with mocked time and transport, but do not cover the late list-only sidebar result or mixed-host final delivery; the cache is in memory and changes no stored-data contract.
Patch quality 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its reported registered-handler and Session Share fixtures cover the one-second response with mocked time and transport, but do not cover the late list-only sidebar result or mixed-host final delivery; the cache is in memory and changes no stored-data contract.
Evidence reviewed 12 items Current-main behavior: The fetched main handler still awaits Promise.all over provider lists and has no per-provider budget.
Introduced timeout and cache: The introduced provider operation races completion against one second, then returns an empty or cached page marked pending or stale.
Late completion gap: After a provider completes, this path captures identities and returns its page without publishing final hosts; the provider API makes onHost optional.
Findings 2 actionable findings [P1] Publish final hosts after a budgeted list completes
[P2] Preserve healthy hosts in a mixed-success refresh
Security None None.

How this fits together

The Gateway gathers session catalogs from plugins for clients such as the Control UI sidebar. It filters provider results for the requesting caller before returning rows or sending host progress updates.

flowchart LR
  A[Control UI list request] --> B[Gateway catalog handler]
  B --> C[Plugin providers]
  C --> D[One-second response budget]
  D --> E[Fresh or cached page]
  E --> F[Visibility and identity filter]
  F --> G[Sidebar rows and host updates]
Loading

Before merge

  • Publish final hosts after a budgeted list completes (P1) - A provider may use the required list API without calling optional onHost, as the new slow-provider fixture does. Once its one-second response returns empty catalog_pending hosts, this completion path only caches the eventual result and sends no host event. The sidebar can therefore remain empty until its scheduled refresh, up to ten minutes when catalog-change events are advertised. Publish final hosts that were not already emitted.
  • Preserve healthy hosts in a mixed-success refresh (P2) - A bundled provider can return a fresh local host alongside an offline node host. Treating any host error as failure of the whole provider substitutes the old cached page, so the final sidebar result can overwrite healthy new rows and stay stale while that node remains offline. Apply fallback to failed hosts without discarding successful hosts.
  • Resolve merge risk (P1) - The new default can leave a completed list-only provider's cold catalog absent from the sidebar until a later scheduled or manual refresh.
  • Complete next step (P2) - Repair late delivery for list-only providers and preserve healthy hosts during mixed-success refreshes, then validate both through the registered catalog handler.

Findings

  • [P1] Publish final hosts after a budgeted list completes — src/gateway/server-methods/session-catalog-list.ts:383-390
  • [P2] Preserve healthy hosts in a mixed-success refresh — src/gateway/server-methods/session-catalog-list-operations.ts:188-191
Agent review details

Security

None.

PR surface

Source +151, Tests +329, Docs +15. Total +495 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 210 59 +151
Tests 2 333 4 +329
Docs 1 15 0 +15
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 558 63 +495

Review metrics

Metric Value Why it matters
Production versus test growth production +210/-59 lines; tests +333/-4 lines The PR body justifies the production growth with provider-scoped caching and lifetime ownership; the new tests should cover the resulting delivery contract.
Changed-test wall time 12.61 s and 11.77 s reported The PR body supplies measured costs for both changed test files, as required by the repository test policy.

Root-cause cluster

Relationship: partial_overlap
Canonical: #127743
Summary: The open report describes the same slow-provider stall but asks for an immediate stale response after expiry; this PR bounds waits at one second and only partly addresses that requested behavior.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Complete late and mixed-host delivery (recommended)
    Publish final hosts from list-only providers after a budgeted response and retain fresh healthy hosts when another host fails.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Repair late completion for providers that do not call onHost and preserve fresh healthy hosts during a mixed-success refresh; add registered-handler regressions for both cases.

Technical review

Best possible solution:

Return fast provider pages promptly, publish late completed hosts to active subscribers, and preserve fresh healthy hosts when another host fails.

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

Yes. Current main awaits all providers, and the PR body reports a registered-handler fixture that took eight seconds before the patch and one second afterward; I did not execute it in this read-only checkout.

Is this the best way to solve the issue?

No. The provider budget is a useful repair, but completed list-only results need a late delivery path and partial host failures must not replace healthy updates.

Full review comments:

  • [P1] Publish final hosts after a budgeted list completes — src/gateway/server-methods/session-catalog-list.ts:383-390
    A provider may use the required list API without calling optional onHost, as the new slow-provider fixture does. Once its one-second response returns empty catalog_pending hosts, this completion path only caches the eventual result and sends no host event. The sidebar can therefore remain empty until its scheduled refresh, up to ten minutes when catalog-change events are advertised. Publish final hosts that were not already emitted.
    Confidence: 0.91
  • [P2] Preserve healthy hosts in a mixed-success refresh — src/gateway/server-methods/session-catalog-list-operations.ts:188-191
    A bundled provider can return a fresh local host alongside an offline node host. Treating any host error as failure of the whole provider substitutes the old cached page, so the final sidebar result can overwrite healthy new rows and stay stale while that node remains offline. Apply fallback to failed hosts without discarding successful hosts.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.87

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: A cold slow catalog can remain absent from the ordinary sidebar after its provider completes, affecting a core session-browsing workflow.
  • add merge-risk: 🚨 compatibility: The default response changes from completed rows to provisional rows, and supported list-only plugins have no late publication path in this patch.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its reported registered-handler and Session Share fixtures cover the one-second response with mocked time and transport, but do not cover the late list-only sidebar result or mixed-host final delivery; the cache is in memory and changes no stored-data contract.

Label justifications:

  • P1: A cold slow catalog can remain absent from the ordinary sidebar after its provider completes, affecting a core session-browsing workflow.
  • merge-risk: 🚨 compatibility: The default response changes from completed rows to provisional rows, and supported list-only plugins have no late publication path in this patch.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its reported registered-handler and Session Share fixtures cover the one-second response with mocked time and transport, but do not cover the late list-only sidebar result or mixed-host final delivery; the cache is in memory and changes no stored-data contract.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/gateway/server-methods/session-catalog-budget.test.ts src/gateway/server-methods/session-catalog-progress.test.ts src/gateway/server-methods/session-catalog.session-share.test.ts.
  • [P1] node scripts/check-changed.mjs --base e1b0d1f.
  • [P1] git diff --check.

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit d1d05ae adds src/gateway/server-methods/session-catalog-list.ts:60 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d1d05aea8a11; files: src/gateway/server-methods/session-catalog-list.ts)

Rank-up moves

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

  • Add a registered-handler case that times out a list-only provider, then verifies its completed hosts reach the active sidebar subscriber.
  • Cover a refresh with one healthy host and one errored host, asserting that the healthy host stays fresh.

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 4a2115c into main Sep 27, 2026
266 of 267 checks passed
@steipete
steipete deleted the steipete/perf-micro-catalog-list-waits-for-slowest-provider-20260919 branch September 27, 2026 06:04
@clawsweeper

clawsweeper Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: perf(gateway): bound session catalog provider waits This is item 3/3 in the current shard. Shard 14/80.

This temporary status tracks the active review worker. The completed review will appear in the durable ClawSweeper review comment.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 28, 2026
Return completed catalogs within a one-second provider budget and retain marked stale pages for slow or unavailable providers. Keep late refreshes owned and cached adoption identities isolated through delivery.

Related: openclaw#127743
steipete added a commit that referenced this pull request Oct 10, 2026
Let in-flight catalog reads finish across registry reactivation while retaining current caller visibility, provider execution authority, disconnect handling, and shutdown settlement. Config and registration changes still invalidate subsequent requests.

Remove map-identity checks around captured usage entries: displaced refreshes cannot overwrite their replacement. Keep all usage-cache behavior tests and remove only epoch/reactivation-only catalog cases.

Best-effort tradeoffs accepted: rare mid-read registry/context replacement can return the original catalog, and epoch-only reactivation may retain a bounded stale page until refresh. Provenance: #138674 addressed slow-host delivery; #159457 added bounded stale catalog results.
steipete added a commit that referenced this pull request Oct 11, 2026
Let in-flight catalog reads finish across registry reactivation while retaining current caller visibility, provider execution authority, disconnect handling, and shutdown settlement. Config and registration changes still invalidate subsequent requests.

Remove map-identity checks around captured usage entries: displaced refreshes cannot overwrite their replacement. Keep all usage-cache behavior tests and remove only epoch/reactivation-only catalog cases.

Best-effort tradeoffs accepted: rare mid-read registry/context replacement can return the original catalog, and epoch-only reactivation may retain a bounded stale page until refresh. Provenance: #138674 addressed slow-host delivery; #159457 added bounded stale catalog results.
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 gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant