Repository navigation
Conversation
Share in-flight approval snapshots by session and reviewer, retain per-client authority checks, and bound subscription replay to one reread. Preserve expiry publication and roll back provisional subscriptions when replay remains stale.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
steipete
deleted the
steipete/perf-micro-messages-subscribe-approval-replay-20260919
branch
September 23, 2026 09:14
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Sep 24, 2026
2 of 8 tasks
This was referenced Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #154619.
What Problem This Solves
Concurrent chat opens repeat the same pending-approval expiry and scan work, while two nested revision loops can keep subscription acknowledgments waiting during approval changes.
User Impact
Subscribers with the same session and reviewer share in-flight replay preparation. Replay contents and per-client authorization stay unchanged. A subscription retries a changed snapshot once; if that attempt also becomes stale, it returns
UNAVAILABLEand rolls back its provisional subscription so the client can retry.Why This Change Was Made
The existing approval session event runtime owns the shared preparation and clears it on lifecycle publication or settlement. The handler owns the single retry. This adds 26 net production lines and no configuration, schema, dependency, or retained cache.
Only in-flight work is shared: the current publication revision is observational, not a durable store revision, so retaining completed snapshots could miss durable changes. Different sessions and reviewer bindings remain separate, and each caller rechecks its own authority after the shared await. Expiry still commits and publishes its tombstones before replay.
Evidence
Real
sessions.messages.subscribehandler, real approval worker/store, 200 pending approvals, three concurrent admin subscribers, 30 measured batches (90 subscriptions), one warm-up batch. Latency is captured in the response callback; golden result assertions run outside the timed batch.Instrumented worker-await time per subscriber fell from 4.46 to 0.415 ms for expiry and 12.36 to 1.40 ms for pending selection. Shared waits are attributed once per preparation; these are elapsed waits, not CPU time.
The scan and expiry numbers count store API operations, not individual SQL statements. Both variants use the same synthetic data and exact replay expectations. The bounded-retry regression fails on the original handler and passes on the candidate.
Provider:
blacksmith-testbox, profileopenclaw-check. Initial leasetbx_01m36hh79jd3c6m8jsv3tcb5ey; initial Testbox run.The original lease was stopped after two checksum-sync timeouts prevented the controlled comparison from starting. Replacement lease
tbx_01m36kg5thcn6s1gjnpmsjrjmkinstalled dependencies successfully and ran both measured variants in one synced invocation.pnpm install --frozen-lockfilerepaired the lease.node scripts/run-vitest.mjs src/gateway/server-methods/sessions.messages-subscribe-perf.test.ts src/gateway/server-methods/sessions.messages-subscribe-approvals.test.ts src/gateway/operator-approval-session-events.test.ts src/gateway/operator-approval-store.worker.test.ts: 36 tests passed. Covers replay equality, per-client revocation, session/reviewer isolation, expiry reconciliation/publication, stale snapshots, rollback, and off-thread storage.node scripts/check-changed.mjs: initial gate found a missing explicit type on the new fixture array; fixed. A subsequent gate exposed the Testbox’s divergentorigin/mainreference (unrelated line-cap failures). Read-only inspection confirmed its materializedHEADis the exact local baseline5e5f9c27559, with only these six files changed.node scripts/check-changed.mjs --base HEAD -- <production/docs paths>and the corresponding test-path invocation: production/docs gate passed, including all 25 test typecheck graphs. The test-only gate passed its typechecks and guards, then found a missingifbrace; fixed. The same targeted lint command (node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <three test files>) passed on the final source; unchanged successful checks were reused.pnpm test src/gateway/server-methods/sessions.messages-subscribe-perf.test.ts src/gateway/server-methods/sessions.messages-subscribe-approvals.test.ts --maxWorkers=1 -t 'shares prepared approval replay|rolls back after one retry': baseline failed the retry regression as expected (3reads versus the bound of2), while its golden replay passed; candidate passed both tests. Total command walls 28.45 s / 20.50 s, including worker compilation.pnpm test <three changed test files> --maxWorkers=1passed all 28 tests (52.62 s wrapper wall).pnpm test <file> --maxWorkers=1:operator-approval-session-events.test.ts24.70 s (13 tests);sessions.messages-subscribe-approvals.test.ts12.23 s (14 tests);sessions.messages-subscribe-perf.test.ts13.00 s (1 test). All passed; command walls include transform/import startup.07487b7bfeba69b38035797b123a09c322a6322d: 1,890 s elapsed including queue time (08:33:49–09:05:19 UTC). All compact Node test jobs and the nativeopenclaw/ci-gatecheck passed. Per-file CI seconds are not available in a timing/plan artifact; the measured per-file walls above are from Testbox.git diff --checkpassed.A later full-suite candidate run measured 10.28/15.41 ms p50/p90 with the same 1/3 scan and expiry counts; the standalone cost run measured 9.11/15.99 ms. Latency is load-dependent. The table above uses the controlled paired comparison.
Gaps: this isolated rig does not reproduce the reported production median, and no live Gateway was changed or benchmarked. Sequential subscribers still acquire a fresh worker snapshot.
chat.startupalready uses prepared session facts and does not duplicate approval replay; restricted-role subscribers can still perform separate synchronous exact session-access lookups outside this change.