Skip to content

perf(session-share): keep remote refreshes off catalog RPCs - #165887

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-session-share-catalog-phase-20260919
Oct 6, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-session-share-catalog-phase-20260919

Conversation

@steipete

@steipete steipete commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A slow or unreachable paired Session Share node delays sessions.catalog.list, including repeated requests for an unchanged listing. The old provider invokes the node after every completed request, and the Gateway waits up to one second before returning partial or stale results.

User Impact

Catalog listing, search, and pagination return immediately from a receiver-owned snapshot. Cold callers receive an explicit loading host and progressive callers receive the completed snapshot later. Expired or disconnected hosts return no rows. Transcript reads retain the source's live sharing-permission check.

The receiver refreshes every 30 seconds after completion, backs failures off from 30 seconds to five minutes, and stops serving a snapshot after 60 seconds. Configuration changes, observed disconnect/reconnect, and service retirement invalidate it. The documented SDK has no remote share-change subscription; source changes arrive on the next successful bounded refresh. No configuration, protocol, dependency, or stored-state migration is needed.

Why This Change Was Made

The plugin service scheduler now owns one complete snapshot per admitted node/configuration/connection incarnation, cancellation, retries, and shutdown joining. Only requested hosts are admitted, with at most 32 retained snapshots and four concurrent refresh workers. Each refresh has a five-minute total pagination budget and a 30-second per-invocation limit. Complete snapshots are bounded to 10,000 rows / 16 MiB; oversized listings fail explicitly with guidance to reduce shared groups, without publishing a truncated catalog. Search and pagination are local projections.

The Gateway respects completed host errors and withdrawals even alongside pending siblings. Its stale fallback can no longer resurrect rows after the provider expires or withdraws them. Existing catalog progress continues to recheck the viewer's permissions.

Production LOC is +145 across two files (git diff --stat origin/main...HEAD -- ':!*.test.ts' ':!*test-support*' ':!docs/*'). The growth implements the required complete local search/pagination contract, joined service lifetime, and bounded node admission, concurrency, memory, expiry, and retry behavior. It replaces the old query-page cache, foreground timeout, and follower path; there is one refresh owner.

Evidence

  • Read-only journal attribution confirmed 161 slow invoke warnings over the inspected window: p50 1,585 ms, p90 5,372 ms, max 30,002 ms, including four rejections. The source call targets the selected connected node, uses openclaw.sessions.list.v1, has a 30-second timeout, and returns at most 100 rows / 2 MiB per wire page.
  • The real sessions.catalog.list handler regression fails on the old provider: none of six callers completes within 49 ms for a five-second success or a thirty-second failure. The existing simulated-clock measurement falls from 1,000 ms to 0 ms, matching the no-plugin baseline. Warm calls issue no additional invokes. Slow invocation logging belongs only to background refresh and is rate-limited to once per minute.
  • Real-clock before/after on the same isolated Linux rig (Node 26, 100 independent cold samples per scenario): unresolved-source RPC p99 1,014.28 → 10.56 ms, p50 1,005.89 → 0.78 ms. Corresponding no-plugin p99 was 2.59 / 1.60 ms; candidate max was 10.91 ms. This removes the remote wait and meets the <50 ms target, though measured cold-provider overhead is not identical to the no-plugin baseline. Both benchmark runs passed with 100 verified source invocations. Command: nice -n 10 ionice -c3 bash /srv/rig/lane524-wall-benchmark.sh, running pnpm test src/gateway/server-methods/session-catalog.session-share.test.ts --maxWorkers=1 with the same temporary benchmark before/after; exit 0. Test-body wall times were 101.33 seconds before / 0.75 seconds after; temporary source replacements were restored.
  • The paired source/receiver integration harness executes the actual source command against isolated SQLite. Consecutive unchanged responses are 844 bytes with identical SHA-256 hashes; local search/pagination uses one refresh. Revocation, source page-scoped title reads, reconnect/config invalidation, expiry, cancellation, memory bounds, and admission limits are covered. Negative controls fail on the retired implementations for the intended reasons.
  • blacksmith-testbox, profile openclaw-check, lease tbx_01m478694rgv1ty2q3qv9h1ngm: pnpm test extensions/session-share/src/session-catalog.test.ts src/gateway/server-methods/session-catalog.session-share.test.ts src/gateway/server-methods/session-catalog-budget.test.ts src/gateway/server-methods/session-catalog-progress.test.ts test/plugins/session-share.integration.test.ts --maxWorkers=1 passed 73/73 (receiver 30, Gateway 32, paired integration 11). Wrapper wall time 80.58 seconds (receiver 15.80 s, Gateway 27.41 s, paired integration 33.70 s); remote command including one frozen dependency install 96.2 seconds, exit 0. An initial preflight stopped before testing because native sync keeps the base Git HEAD and overlays candidate files; the corrected preflight verified the base plus exact candidate hashes. Hosted CI run 37395792641 passed on exact head 451ffe5c16543b05caf6194dbf3ab1eea3a54fcf: 404 seconds elapsed, 5,199 summed job-seconds across the full run (not incremental test cost), with no failed jobs or reruns. ClawSweeper also reported no actionable findings on that head.
  • Feature validation used blacksmith-testbox, profile openclaw-check, leases tbx_01m470v2cmnw5ks60gmc46djth and tbx_01m474qwavhycee0c8v763zj00. Full staged attempts passed all typecheck partitions, guards, and core lint, then exposed extension lint findings that were fixed. The final owner check passed: node scripts/check-changed.mjs --base HEAD -- extensions/session-share/src/session-catalog.ts extensions/session-share/src/session-catalog.test.ts docs/plugins/session-share.md. The last command, including focused tests and the cancellation negative control, exited 0 in 355.2 seconds. Unaffected successful checks were reused; this is not a claim that one monolithic full staged command passed.
  • After the Testbox queue exceeded 20 minutes, the authorized Linux rig ran nohup bash /srv/rig/rig-staged-check.sh lane524 b78db8b8f258 on the reviewed feature commit plus staged diagnostics patch. node scripts/check-changed.mjs --staged passed, exit 0 (00:21–00:40 UTC): formatting, extension test types, plugin boundaries, dependency/compatibility guards, all three dead-export scans, and extension lint (zero warnings/errors). Both the feature review and diagnostics-only review finished scoped-clean, P0–P2. No required check was waived.

Measurements use the real handler and plugin with controlled transport in the paired/mock harness; they are not two deployed Gateways or production network latency. No production Gateway was modified. The Codex producer warning is a separate follow-up: its owner already has an event-fed resident index and background refresh, and the inclusive warning includes asynchronous control-request wait, so it does not establish main-thread CPU time.

Serve catalog searches and pages from bounded service-owned node snapshots.
Keep refresh admission, concurrency, expiry, retry, and cancellation with the
Session Share service while transcript reads retain live source checks.

Honor completed host errors and late publications in Gateway fallback pages
so expired or withdrawn snapshots cannot be replaced by older cached rows.
@clawsweeper

clawsweeper Bot commented Oct 6, 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 October 6, 2026 00:47
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime plugin: session-share size: XL labels Oct 6, 2026
@steipete
steipete enabled auto-merge (squash) October 6, 2026 00:50
@clawsweeper

clawsweeper Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 8:52 PM ET / October 6, 2026, 00:52 UTC.

ClawSweeper review

What this changes

Session Share serves catalog searches and pages from bounded background-refreshed snapshots, while the Gateway preserves completed host errors and withdrawals.

Merge readiness

✅ Ready for maintainer review

This remains a useful performance repair: pinned main and the latest release retain the foreground refresh path. No blocking introduced defect was found.

Priority: P2
Reviewed head: 451ffe5c16543b05caf6194dbf3ab1eea3a54fcf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent performance repair with bounded ownership, focused lifecycle regressions, documented tradeoffs, and no blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The verified repository administrator is exempt from ordinary external-contributor proof. Captured handler benchmarks and isolated source/receiver tests support the snapshot behavior but use controlled transport, not deployed Gateways. The patch changes runtime snapshots only, with no stored-data contract or migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The verified repository administrator is exempt from ordinary external-contributor proof. Captured handler benchmarks and isolated source/receiver tests support the snapshot behavior but use controlled transport, not deployed Gateways. The patch changes runtime snapshots only, with no stored-data contract or migration.
Evidence reviewed 9 items Pinned introduction and merge ownership: The introduced delta and verified test merge contain the same eight intended paths. Raw test-merge parents are the pinned main commit followed by the exact PR head; base-branch drift is not attributed to this PR.
Current main still needs the repair: Pinned main still invokes the source after completed requests and awaits complete responses for non-progress callers. The latest release's provider also retains this implementation, so neither establishes redundancy.
Latest-release comparison: The locally available v2026.9.8 source retains the query-page cache, source invocation, and foreground completion path.
Findings None None.
Security None None.

How this fits together

Session Share exposes selected sessions from paired source nodes in the receiver Gateway's session catalog. The receiver turns source listings into searchable pages, while transcript reads still check sharing permissions on the source.

flowchart TD
  A[Catalog request] --> B[Receiver snapshot owner]
  C[Paired source node] --> D[Bounded background refresh]
  D --> B
  B --> E{Snapshot available and fresh?}
  E -->|Yes| F[Local search and pagination]
  E -->|No| G[Loading or unavailable host]
  F --> H[Gateway viewer permission checks]
  G --> H
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +145, Tests +149, Docs +5. Total +299 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 2 338 193 +145
Tests 4 670 521 +149
Docs 2 10 5 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 1018 719 +299

Review metrics

Metric Value Why it matters
Production growth justification production net +145 lines; tests net +149 lines The body explains the production growth as replacing foreground page caching with bounded complete snapshots and service-owned refresh lifecycle.

Technical review

Best possible solution:

Keep remote refresh ownership in the Session Share service and preserve explicit loading, bounded freshness, authoritative withdrawals, and live transcript authorization.

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

Yes, from source: a slow paired node keeps the old provider awaiting remote completion and forces the Gateway's one-second budget path. The captured before/after harness measurements support this mechanism; this review did not execute it.

Is this the best way to solve the issue?

Yes. One service-owned complete snapshot supports local search and pagination while the Gateway honors host withdrawals, avoiding competing refresh owners.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs latency in an optional paired-session catalog with a limited blast radius.
  • add merge-risk: 🚨 compatibility: Cold callers now receive loading results, expired snapshots disappear, and oversized catalogs fail explicitly; the verified administrator-authored proposal documents and accepts these current tradeoffs.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: This repairs latency in an optional paired-session catalog with a limited blast radius.
  • merge-risk: 🚨 compatibility: Cold callers now receive loading results, expired snapshots disappear, and oversized catalogs fail explicitly; the verified administrator-authored proposal documents and accepts these current tradeoffs.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

  • Pinned introduction and merge ownership: The introduced delta and verified test merge contain the same eight intended paths. Raw test-merge parents are the pinned main commit followed by the exact PR head; base-branch drift is not attributed to this PR. (03bfb15d66f9)
  • Current main still needs the repair: Pinned main still invokes the source after completed requests and awaits complete responses for non-progress callers. The latest release's provider also retains this implementation, so neither establishes redundancy. (extensions/session-share/src/session-catalog.ts, 90c6934d630f)
  • Latest-release comparison: The locally available v2026.9.8 source retains the query-page cache, source invocation, and foreground completion path. (extensions/session-share/src/session-catalog.ts, fc23bc864e45)
  • Lifecycle and publication safeguards: The replacement owns refreshes through scheduler scopes, bounds admission and concurrency, rejects stale configuration and connection identities before snapshot publication, and suppresses cancelled viewer publications. The existing scheduler runner detaches caller authority and the service host joins scheduled work during retirement. (extensions/session-share/src/session-catalog.ts:170, 451ffe5c1654)
  • Gateway withdrawal and permission composition: Completed host results replace older fallback pages, including host-level errors. Fallback resolves late publications, and the unchanged delivery owner filters both responses and progress using current viewer permissions. Focused regressions exercise expiry, offline withdrawal, pending siblings, and a viewer losing access. (src/gateway/server-methods/session-catalog-list-operations.ts:242, 451ffe5c1654)
  • Validation evidence and its limits: The captured PR body reports 73 focused passing cases and real-clock handler p99 improvement from 1,014.28 to 10.56 ms. Inspected tests exercise the registered plugin and actual Gateway handler with controlled transport; the paired integration invokes the real source command against isolated SQLite. These are harness measurements, not deployed-network proof. No code or tests were executed during this read-only review. (src/gateway/server-methods/session-catalog.session-share.test.ts:19, 451ffe5c1654)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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.

@steipete
steipete merged commit 43b33ce into main Oct 6, 2026
184 of 187 checks passed
@steipete
steipete deleted the steipete/perf-micro-session-share-catalog-phase-20260919 branch October 6, 2026 00:54
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
…#165887)

* perf(session-share): keep remote refreshes off catalog RPCs

Serve catalog searches and pages from bounded service-owned node snapshots.
Keep refresh admission, concurrency, expiry, retry, and cancellation with the
Session Share service while transcript reads retain live source checks.

Honor completed host errors and late publications in Gateway fallback pages
so expired or withdrawn snapshots cannot be replaced by older cached rows.

* test(session-share): preserve catalog diagnostic guarantees
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 plugin: session-share size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant