Skip to content

perf(infra): move device pairing database access into workers - #154671

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-worker-migrate-device-pairing-20260919
Sep 21, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-worker-migrate-device-pairing-20260919

Conversation

@steipete

@steipete steipete commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Related: #154189, #154318

What Problem This Solves

Device pairing lists, token/approval mutations, and node/push authority checks still execute SQLite on the Gateway request thread, delaying other clients.

User Impact

Paired/pending-device, bootstrap-token and node-surface database work runs in the existing readers and writer broker. List/lookup bytes, pairing decisions, and node/push ordering remain intact. No schema, config, stored representation, retention, or update changes are required.

Why This Change Was Made

Readers project pending/paired lists and keyed results in the read-only worker. The existing snapshot cache checks SQLite data_version; a content revision allows facts from different reader/writer connections to be compared. The Gateway retains compact node identity/generation bindings. Reads validate the publication epoch independently; only a superseded read joins the writer queue and rereads, so disconnects do not wait behind unrelated queued history writes. Unchanged list revisions reuse those bindings without transferring them again. Historical inspection snapshots never publish live authority; current lookups and privileged push preparation read canonical state.

Writers execute synchronous domain operations under the existing shared-state broker transaction. They reread authoritative records and obtain current host approval, node/probe, or connection admission before mutation and immediately before commit. Native commit receipts publish changed bindings and the revision before caller continuation. Bootstrap grant retirement also consumes the receipt, so a lost result reply cannot leave replaced operator grants connected; callback failure cannot redeliver retirement. Obsolete read replies cannot replace newer publications. Web Push starts sending while both subscription and pairing scopes remain held, then releases those scopes before provider completion. APNs registration moves its shared pairing reread into the same worker transaction as registration. Timestamped presence and connection/disconnection history retain their existing durable generation/timestamp semantics.

Evidence

Final same-machine comparison on Blacksmith Testbox tbx_01m31ht3xfms3p94t4jt536qdq, provider blacksmith-testbox, profile openclaw-check, Node 24.19.0. Original source 051563c9b242765a947e8b094421ff3555e6be2d ran in an isolated temporary source tree with its own frozen-lockfile installation. Fixture: 5,000 synthetic devices, 50 callers, two warm-up rounds and five measured rounds. CPU is the calling thread's CPU time; wall time is batch duration divided by 50, not individual request latency. The measurement candidate was 01d9cc6a9c2; its rebase onto aa099e492da preserves every added/removed source line, with post-rebase shared-worker validation recorded below.

Operation Before main-thread CPU After main-thread CPU Before → after amortized wall
Cached public list 30.025 ms 8.530 ms (−71.6%) 30.508 → 10.157 ms
Read-only list 38.907 ms 8.950 ms (−77.0%) 39.413 → 11.164 ms
Keyed lookup 0.080 ms 0.139 ms 0.103 → 0.174 ms

Tiny lookups pay worker admission/transfer overhead. List CPU and elapsed time improve substantially; this cutover removes SQL from the calling thread rather than promising every individual lookup is faster. Complete serialized list/lookup goldens passed. The no-host-query regression was run against original code on tbx_01m314gk9kx9rchq6stzkvv7a0 and failed for four host Kysely calls, then passed on the candidate.

Final validation: 745 tests across 28 affected files and 463 tests across 20 sibling files passed on Blacksmith Testbox (1,208 tests total). All 24 canonical core-test type graphs passed in the earlier serial campaign. Final core types and the affected infra, Gateway root/methods, and services graphs passed; the full build, lint, and selected changed-check guards passed. Independent Codex review completed through P2, with its accepted commit-reconciliation finding fixed and regression-proven.

The final read-ordering and skill-version repairs also received clean independent review through P2. The mechanical rebase to aa099e492da preserved every added/removed source line; 6c7bd52b06e additionally passed core types and 110 shared-worker tests across 11 files, plus scoped lint/format checks. Its full build passed (492.8 s). Initial exact-head CI exposed the integration gaps repaired below. Final Testbox commands used normal source sync throughout; no local tests, typechecks, lint, or builds ran on the Mac.

The separate device_pairing_join_codes store remains a synchronous runtime path for onboarding shortcode generation/redemption; it is adjacent migration work outside this store/node/push cutover, not a maintenance exception.

The proof is synthetic Testbox and mocked Gateway boundary coverage. No live Gateway deployment, provider send, or production CPU profile was performed.

Cutover inventory and synchronous exceptions

Inventory source: the program snapshot at 849c9a3c265d16dd181b1e3cddd76b26008cdfc0. The referenced program inventory records src/infra/device-pairing-store.ts as 29 primitive expressions: 19 query calls, 4 take-first calls, and 6 shared-state transaction calls. The task brief estimated 32; this report uses the reproducible scanner count, whose primitive set excludes direct SQLite methods and other wrappers. The regenerated inventory still labels the native store primitives T1 because its tier is static; caller tracing and the no-host-SQL boundary regression prove the execution-context cutover. Its runtime callers now enter the reader scope or the worker broker:

  • Pending/paired lists and exact paired/pending lookups.
  • Pairing requests, rejection, removal, role removal, silent-device pruning, and metadata/presence updates.
  • Owner/bootstrap approval and token verification, issuance, rotation, and revocation.
  • Bootstrap issuance, binding/redemption/revocation, setup consumption/confirmation/status, and completion pruning. The two queries in device-pairing-cloud-worker.ts move transitively inside setup consumption’s existing transaction; they update the owning worker_environments row.
  • Node request/approval/rejection/reconnect cleanup, surface facts, bins, session-host consent, and naming.
  • Node catalog/currentness and Web Push authority preparation; APNs registration's authoritative pairing reread.

Row codecs, native transactions, and schema probes remain synchronous inside workers. Doctor’s legacy device/node imports retain withPairedDeviceRecords; the desktop opt-out migration runs synchronously before node admission. Ordinary CLI pairing uses the worker facade. Other APNs cleanup mutations remain with their existing owner and are outside this pairing cutover. Retired runtime synchronous list/lookup and callback mutation paths were removed; there is no native fallback after worker failure.

Remote runs and diagnosed preparation failures

All leases used blacksmith-testbox / openclaw-check; commands used the installed crabbox CLI and normal sync. Linked workflow runs identify the leases, not PR CI results.

Lease Commands and results
tbx_01m311rfq3brnmhgvpr790effb Initial benchmark stopped for missing remote dependencies; frozen-lockfile install passed; baseline passed. First integration run exposed old thread-pool routing, before broker admission; routes were moved to the existing fork owner. Next changed-check sync timed out before execution. Stopped.
tbx_01m314gk9kx9rchq6stzkvv7a0 Frozen install and 114 tests across six pairing/bootstrap/node files passed. Changed check found file-size growth; coherent helpers/tests were extracted. Original-code benchmark and expected failing no-host-query regression completed. Later sync timed out before execution. Stopped.
tbx_01m316bp3d9p8a9v70vtg8bz9h Initial same-machine original/candidate benchmark and goldens passed: public-list CPU 18.750→7.051 ms and read-only-list CPU 26.812→7.174 ms. The final scheduling change was measured again on the final lease (table above). Changed checks passed initial guards, formatting, graph boundary, and core types; core-test types found a benchmark callback union inference error, corrected by invoking the reader in an arrow callback. Gateway batch passed 238/240: the two failures detected one redundant early config read; it was removed without changing assertions. Subsequent sync timed out before execution. Stopped.
tbx_01m31920n5n46sdhagmfzznf2b Follow-up 46 tests across six files passed, including all 23 approval-push cases, real-worker stale publication, bootstrap expiry, APNs admission, and remote-bin ownership. Core types passed. A concurrent typecheck attempt made no useful progress and was stopped; the subsequent serial campaign passed all 24 graphs. Stopped.
tbx_01m31aadrgw1yn0jp7f0pf1cdq All 24 serial core-test type graphs passed with node scripts/run-tsgo-core-test-shards.mjs --stripe N/24. Dead-export checks then identified retired aliases; those were removed. Stopped.
tbx_01m31cgj6v4p88x2jnscx3a8x5 Dead-export scans passed with zero entries. Canonical changed-check continuation passed core/script lint, native schema, database-first, media, sidecar, import-cycle, webhook, pairing-store and pairing-account guards. Initial lint errors were required braces, an unused import, import ordering, class shadowing and exhaustive returns; corrected. Missing prototype-key lookup regression failed before its own-property guard and all four worker tests passed afterward. Full build passed in 260.4 s. A later final-proof invocation timed out during sync before execution; stopped.
tbx_01m31fe6q8bnfbk5ebqfc31ze1 pnpm install --frozen-lockfile passed. The old bootstrap result-callback path failed the lost-reply regression; receipt reconciliation passed all seven worker cases. Individual focused Gateway tests passed until watch-node-http.test.ts exposed a deadlock: a fresh currentness read queued behind the history lock deliberately held by its disconnect regression. The lease was stopped, and the read owner was repaired without changing that test.
tbx_01m31g2a0k7nvvw6f48zsvkysg All 28 affected files passed: 745 tests; per-file pnpm test <file> --maxWorkers=1 wall totaled 375.71 s. Watch-node HTTP completed in 30.95 s, including the unchanged disconnect regression (499 ms). The additional sibling batch passed 17 fast tests and 204 unit tests, but found a skill-snapshot version fence missing across the new preparation await and a cancellation fixture that assumed immediate build entry. Those three failing assertions/timeouts were diagnosed and repaired before final proof. Stopped.
tbx_01m31h19xxwt3wmv4bnacs1ma1 Exact sibling replay passed all 463 tests across 20 files (148.33 s), including unchanged version/content goldens and cancellation/shared-failure order. The subsequent core typecheck went silent for several minutes; that invocation was stopped without a verdict. The prior stall remains unexplained; the diagnostic run on a fresh lease completed in 56.93 s. The final diagnostic run is recorded below. Stopped.
tbx_01m31ht3xfms3p94t4jt536qdq Final run passed (1,174.23 s command time): pnpm tsgo:core (56.93 s; active compiler observed at ~3.9 GB RSS), node scripts/run-tsgo-core-test-shards.mjs --stripe N/24 for 7/4/22/13, regenerated inventory via the program script, canonical targeted lint, assertion/max-lines ratchets, changed-file formatting, pnpm build (560.5 s), original/candidate benchmark with OPENCLAW_DEVICE_PAIRING_BENCH=1 node scripts/run-vitest.mjs src/infra/device-pairing-worker.benchmark.test.ts --maxWorkers=1, and the measured snapshot fixture rerun. Stopped before commit.
tbx_01m31kqgfdthyxdt26r88yaaze Post-rebase 6c7bd52b06e: pnpm tsgo:core passed (74.84 s); node scripts/run-vitest.mjs for pairing worker/publication/bootstrap/bins, APNs, exec-authorization worker, shared read workers, skill resource reads, watch-node HTTP and push storage scope passed 110 tests / 11 files (68.53 s); canonical targeted lint and formatting passed for the five shared dispatch/read files; pnpm build passed (492.8 s). Overall remote command 719.61 s. Stopped.

Reused leases sometimes fell back to a full sync and reached Blacksmith's fixed two-minute sync deadline. Fresh leases restored targeted sync; no sync bypass was used. Explicit pre-fix regression probes restored the candidate source before its passing run.

Measured test cost

Each affected file was run with pnpm test <file> --maxWorkers=1 on tbx_01m31g2a0k7nvvw6f48zsvkysg; wall includes runner/compiler startup and cleanup, not just test bodies. The suite uses existing worker/fork owners and suite fixtures; the measurement flag is not a new CI pin. CI timing for the PR head is pending.

File Tests Wall seconds
src/gateway/watch-node-http.test.ts 21 30.95
src/gateway/approval-web-push.test.ts 23 10.31
src/gateway/control-ui.http.test.ts 159 20.87
src/gateway/device-pair-setup-completion.test.ts 5 9.69
src/gateway/event-web-push.storage-scope.test.ts 6 7.54
src/gateway/event-web-push.test.ts 45 19.17
src/gateway/node-reapproval-coordinator.test.ts 9 7.31
src/gateway/node-registry-pairing.test.ts 4 2.25
src/gateway/node-registry.test.ts 159 6.75
src/gateway/server-methods/nodes.apns-registration.test.ts 3 8.61
src/gateway/server.node-pairing-ssh-verify.test.ts 10 35.90
src/gateway/user-profiles-http.auth.test.ts 14 21.41
src/infra/device-bootstrap.test.ts 53 35.46
src/infra/device-bootstrap.worker.test.ts 4 10.20
src/infra/device-pairing-approval-policy.test.ts 3 8.64
src/infra/device-pairing-churn.test.ts 4 7.99
src/infra/device-pairing-migration.test.ts 7 7.24
src/infra/device-pairing-node-bins.worker.test.ts 1 7.85
src/infra/device-pairing-node-desktop-migration.test.ts 13 18.37
src/infra/device-pairing-node.lifecycle.test.ts 7 9.62
src/infra/device-pairing-node.test.ts 39 15.32
src/infra/device-pairing-prune.test.ts 10 10.02
src/infra/device-pairing-publication.test.ts 4 8.09
src/infra/device-pairing-worker.test.ts 7 8.08
src/infra/device-pairing.test.ts 82 11.25
src/infra/node-pairing-migration.test.ts 4 8.48
src/infra/push-apns.store.test.ts 11 12.91
src/skills/runtime/remote.test.ts 38 15.43

The changed cancellation fixture was additionally measured with the same command on tbx_01m31ht3xfms3p94t4jt536qdq: src/skills/runtime/session-snapshot.test.ts 2.89 s wall (all cases passed).

The opt-in 5,000-device benchmark is skipped in normal test runs. New worker tests protect native commit/rollback, publication races and live authority at real broker boundaries; a helper-only mock cannot prove those contracts.

Exact-head CI repair

Reviewed head: c702551d87dd9498b21a4e50497334bfee02ee80, one commit with the original subject, rebased onto 1ccccb02788a. Mechanical rebases preserved every added and removed PR source line while retaining conversation-binding, placement-reader, and Cron recovery registrations from main. The final Cron rebase reuses unchanged scoped proof; its complete combined context is gated by exact-head hosted CI.

CI exposed integration gaps beyond the initial focused proof. Private worker kernel exports now have distinct names, real database consumers run under the existing forked broker owners, and current-authority assertions use committed publication. Subscription fixtures update synchronous authority with their generation. The bootstrap fixture records the WebSocket challenge before awaiting token creation; startup proof observes the actual admission release instead of an event-loop tick. Gateway test paths remain sorted, and broad script watch selection retains both tooling and database-worker coverage.

The APNs domain contract and worker now own registration and both read operations together. The central dispatcher delegates after its existing database-open boundary, reducing its counted lines from 707 to 698 without baseline or suppression changes. The registration transaction, pairing-generation check, live admission, tombstone versions, and read helpers are unchanged.

Validation:

  • Pure main passed the initial 14 failing files (230 tests) and export guard, then the line-cap and routing baseline checks for the follow-up.
  • 242 targeted behavior cases across 16 files passed. The complete pinned changed-file gate passed on Testbox, including core/test types, dead exports, core/script lint, and applicable guards (42m25.5s).
  • The routing/APNs follow-up passed all baseline-ratchet commands, core types, and 1,595 tests across seven files on Blacksmith Testbox tbx_01m31tz01a7qfeqnmwmc1y0014 (environment run).
  • The final rebase passed core types and 86 shared-reader, placement, APNs, and migration tests across seven files on tbx_01m31vrjywk8xypb3rhaegwxf3 (environment run); remote command 143.58s.
  • Independent autoreview through P1 found no actionable findings after each repair. All task-owned Testboxes are stopped. No local tests, typechecks, or builds ran on the saturated Mac.

Fixture costs measured with pnpm test <file> --maxWorkers=1 on Testbox:

Changed test file Wall seconds
src/gateway/server/ws-connection.startup.test.ts 38.85
src/gateway/server-node-session-runtime.test.ts 12.25
src/gateway/server.node-pairing-memo.test.ts 35.97
src/infra/device-pairing-publication.test.ts 10.68
src/infra/node-pairing-state.test.ts 7.81
test/scripts/test-projects.test.ts 57.69

Startup and memo retain existing real handshake/Gateway fixtures to prove registered admission and node.list dispatch. The existing routing matrix covers CLI/watch ownership; the obsolete isolated case was moved into its mixed-owner table without adding a scenario. No new CI worker pin, timer, polling loop, or per-case Gateway boot was added.

Some reused Testboxes hit the provider's two-minute checksum-sync deadline before executing checks; fresh leases restored sync. The initial new-head PR workflow failed to start, and one Security Review attempt hit GitHub installation API rate limiting. The queued explicit CI run was cancelled after that head needed rebase. No failed GitHub jobs have been rerun.

The final dispatcher follow-up adds an explicit unsupported-command throw, matching sibling worker executors and the consistent-return rule. Pure-main infra/dispatcher lint passed 2,133 files; the candidate passed targeted lint on all four APNs/dispatch files with zero warnings/errors and all 11 APNs store tests on Blacksmith Testbox tbx_01m31y6kt44j4a54fqxab8rk3s. Independent P1 autoreview was clean. The preceding full CI run passed every check except this corrected lint rule.

The earlier external auto-merge request was explicitly retired after verifying its current head and squash method, so native landing can own its final recorded merge request. Exact-head CI run 35599383909 and the enforced openclaw/ci-gate passed. Native squash landing completed as 05117d9db7bf8211ac1d5fe6b3a3da6232eedb25, verified on GitHub and in main history. No admin bypass or PR-operation lock recovery was used. Native verification reported relevant main drift in docs, test routing, and tooling and proceeded under the repository’s normal drift policy; the retained merge receipt verified the landed change. Peter, repository administrator, directed this landing and authorized the native admin route if an enforced review requirement blocks it; exact-head CI remains mandatory.

@clawsweeper

clawsweeper Bot commented Sep 21, 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 agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 21, 2026, 8:38 AM ET / 12:38 UTC (Revision 8).

ClawSweeper review

What this changes

Moves device-pairing database reads and writes into existing workers and updates node, notification, and prompt consumers to use asynchronously prepared pairing facts.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 5 items remain

The worker migration remains useful and is not implemented on current main. The previously reported cancellation blocker remains in the pinned head, so this PR is not ready to merge.

Priority: P2
Reviewed head: c702551d87dd9498b21a4e50497334bfee02ee80

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Substantial implementation and validation support the migration, but the unresolved cancellation regression blocks readiness.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary contributor proof gate does not apply to this maintainer-authored PR. The matching full body reports real-worker Testbox database coverage and synthetic performance results, explicitly excludes live provider execution, and does not cover the outstanding cancellation race.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary contributor proof gate does not apply to this maintainer-authored PR. The matching full body reports real-worker Testbox database coverage and synthetic performance results, explicitly excludes live provider execution, and does not cover the outstanding cancellation race.
Evidence reviewed 9 items Introduced cancellation guard: The pinned introduction adds a publication-currentness check to both node event send paths. sendCancel still calls sendEventToSession, so cancellation also passes through this new guard.
Unrelated writes temporarily suppress authority: executeDevicePairingMutation calls beginMutation before awaiting worker execution. beginMutation blocks the publication, and getPublishedPairedDeviceBinding throws while blocked; isPublishedPairingCurrent converts that exception to false. Bootstrap issuance and metadata writes use this same path even when the running node's binding does not change.
Cancellation cannot recover after a suppressed send: Abort, hard timeout, and idle timeout take the pending invocation before sending cancellation. takePending deletes the entry and clears timers; sendCancel ignores the send result. Existing node-registry tests establish cancellation delivery as expected behavior, but their cancellation cases do not overlap a blocked pairing publication.
Findings 1 actionable finding [P1] [P1] Preserve cancellation while pairing publication is pending
Security None None.

How this fits together

Device pairing records determine which connected devices may execute node commands and receive notifications. The Gateway now obtains those records through database workers and uses published identity bindings to check subsequent operations.

flowchart TD
  A[Device and Gateway requests] --> B[Pairing operations]
  B --> C[Read workers]
  B --> D[Writer broker]
  C --> E[Shared SQLite database]
  D --> E
  C --> F[Published pairing facts]
  D --> F
  F --> G[Node and notification authorization]
  G --> H[Commands and push delivery]
Loading

Before merge

  • [P1] Preserve cancellation while pairing publication is pending (P1) - The previous blocker remains. Every pairing mutation blocks publication before awaiting its worker, including unrelated bootstrap and metadata writes. During that interval this guard rejects node.invoke.cancel from sendCancel. Abort and timeout have already deleted the pending invocation and cleared its timers, and the failed send is not retried, so remote work can continue after ABORTED or TIMEOUT. Preserve teardown delivery to the original pending connection without weakening admission for new work.
  • Resolve merge risk (P2) - Remote commands can continue consuming resources or producing effects after the caller receives ABORTED or TIMEOUT when cancellation overlaps an unrelated pairing mutation.
  • Complete next step (P2) - Repair the cancellation guard and add focused abort/timeout coverage during pending pairing publication, including replacement-connection exclusion.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P1] [P1] Preserve cancellation while pairing publication is pending — src/gateway/node-registry.ts:1425-1430
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus test growth Production net +2,265 lines; tests and test support net +1,110 lines The stated justification is the worker contract, transaction, and publication cutover; extracted code is included in these net totals.
Reported calling-thread CPU Cached lists −71.6%; read-only lists −77.0% The same-machine synthetic benchmark supports offloading list work, while keyed lookups incur additional worker overhead.

Stored data model

Persistent data-model change detected: serialized state: src/skills/runtime/remote.ts, unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Preserve invocation teardown (recommended)
    Allow cancellation of the original pending invocation during publication gaps while preserving connection replacement checks and strict admission for new work.

Technical review

Best possible solution:

Keep worker-backed pairing authority while giving invocation teardown a narrowly scoped path bound to the original pending connection.

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

Yes, source establishes the patch regression: start an invocation, hold an unrelated pairing mutation before publication, then abort or expire the invocation. The cancellation send is rejected after pending state is removed; no runtime reproduction was executed in this read-only review.

Is this the best way to solve the issue?

The existing reader and writer owners are the appropriate migration path, but the blanket event-send guard must distinguish teardown from admission of new work.

Full review comments:

  • [P1] [P1] Preserve cancellation while pairing publication is pending — src/gateway/node-registry.ts:1425-1430
    The previous blocker remains. Every pairing mutation blocks publication before awaiting its worker, including unrelated bootstrap and metadata writes. During that interval this guard rejects node.invoke.cancel from sendCancel. Abort and timeout have already deleted the pending invocation and cleared its timers, and the failed send is not retried, so remote work can continue after ABORTED or TIMEOUT. Preserve teardown delivery to the original pending connection without weakening admission for new work.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a useful internal performance improvement with a concrete pre-merge regression, not an established urgent production incident.
  • merge-risk: 🚨 availability: The introduced publication guard can suppress cancellation and leave remote execution running after local settlement.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool 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 ordinary contributor proof gate does not apply to this maintainer-authored PR. The matching full body reports real-worker Testbox database coverage and synthetic performance results, explicitly excludes live provider execution, and does not cover the outstanding cancellation race.

Evidence

What I checked:

  • Introduced cancellation guard: The pinned introduction adds a publication-currentness check to both node event send paths. sendCancel still calls sendEventToSession, so cancellation also passes through this new guard. (src/gateway/node-registry.ts:1428, c702551d87dd)
  • Unrelated writes temporarily suppress authority: executeDevicePairingMutation calls beginMutation before awaiting worker execution. beginMutation blocks the publication, and getPublishedPairedDeviceBinding throws while blocked; isPublishedPairingCurrent converts that exception to false. Bootstrap issuance and metadata writes use this same path even when the running node's binding does not change. (src/infra/device-pairing-publication.ts:127, c702551d87dd)
  • Cancellation cannot recover after a suppressed send: Abort, hard timeout, and idle timeout take the pending invocation before sending cancellation. takePending deletes the entry and clears timers; sendCancel ignores the send result. Existing node-registry tests establish cancellation delivery as expected behavior, but their cancellation cases do not overlap a blocked pairing publication. (src/gateway/node-registry.invoke-stream.ts:397, c702551d87dd)
  • Verified merge result retains the defect: The test merge's raw parents are the pinned base c47c7fb followed by the exact PR head. Comparing its result with that base retains the introduced event-send guard. (src/gateway/node-registry.ts:1428, f7377c19acca)
  • Current main still needs the migration: Fetched main still resolves synchronous node-binding currentness through loadPairedDevicePairingStoreRecord. Inspection of v2026.9.5 shows that same synchronous path; neither inspected revision contains this worker publication cutover. (src/infra/device-pairing-node-state.ts:66, f914e0f5f86c)
  • Complete captured proof body inspected: Retrieved the omitted body remainder and verified SHA-256 eb5b7b6a803ddbce7330b23b5518f57bf105029c99c9c4680dce10526e2b1dc9, matching the supplied snapshot. It reports synthetic Testbox benchmarks, real-worker database regressions, mocked Gateway coverage, and subsequent integration repairs; it explicitly reports no live Gateway deployment or provider send. No cancellation-during-publication repair or proof is supplied. (c702551d87dd)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Repair cancellation delivery and verify abort and timeout during an unrelated pairing mutation reach the original invocation while replacement connections remain excluded.

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 (7 earlier review cycles)
  • reviewed 2026-09-21T09:12:29.558Z sha 01d9cc6a9c2617b05b816ad509bf80e0c7956b9f :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-21T09:42:36.847Z sha 6c7bd52 :: blocked before merge. :: [P2] Give the extracted kernels distinct exported names
  • reviewed 2026-09-21T10:31:09.161Z sha 4fa6f5a :: blocked before merge. :: [P1] Preserve cancellation while pairing publication is pending
  • reviewed 2026-09-21T11:02:35.131Z sha 073f331888563230c53e1ea053113568ab24b526 :: blocked before merge. :: [P1] Preserve cancellation while pairing publication is pending
  • reviewed 2026-09-21T11:35:49.075Z sha e212e1f8d6c75047861a4d3bd880d2af79a00c65 :: blocked before merge. :: [P1] Preserve cancellation while pairing publication is pending
  • reviewed 2026-09-21T11:50:06.188Z sha 6b1fd3ed3bc0c1beb7349ab75c75141cf018852e :: blocked before merge. :: [P1] [P1] Preserve cancellation while pairing publication is pending
  • reviewed 2026-09-21T12:18:38.830Z sha bdd90ae7892f96c6561244dea3e58913edac7891 :: blocked before merge. :: [P1] [P1] Preserve cancellation while pairing publication is pending

@steipete
steipete force-pushed the steipete/perf-micro-worker-migrate-device-pairing-20260919 branch from 01d9cc6 to 6c7bd52 Compare September 21, 2026 09:14
@steipete
steipete marked this pull request as ready for review September 21, 2026 09:20
@steipete
steipete enabled auto-merge (squash) September 21, 2026 09:34
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: c702551d87dd9498b21a4e50497334bfee02ee80
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/sandbox/context.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/gateway/node-registry-pairing.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/web-push-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-bootstrap.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-bootstrap.worker-kernel.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-bootstrap.worker-types.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-approval.kernel.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-approval.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-binding.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-card-renderer.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-core.kernel.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-core.types.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-core.worker-contract.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-core.worker.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-dispatch.worker.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-identity.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-lock.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-mutation.worker.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-node-desktop-migration.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-node-facts.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-node-state.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-node.records.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-node.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-node.worker-contract.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-node.worker.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • 15 additional sensitive files; see the workflow summary.

Carefully review these changes before merging.

@steipete
steipete force-pushed the steipete/perf-micro-worker-migrate-device-pairing-20260919 branch from 6c7bd52 to 4fa6f5a Compare September 21, 2026 10:19
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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 21, 2026
@steipete
steipete force-pushed the steipete/perf-micro-worker-migrate-device-pairing-20260919 branch 4 times, most recently from 6b1fd3e to bdd90ae Compare September 21, 2026 11:57
@steipete
steipete disabled auto-merge September 21, 2026 12:10
Move runtime pairing reads into the read-only worker scope and mutations through the shared SQLite broker. Publish committed authority facts and revalidate live approval and node leases before commit; reconcile replaced grants even when result delivery fails.

Testbox: 1,208 focused and sibling tests passed, plus type, lint, build, and golden checks. At 5,000 devices and 50 callers, list main-thread CPU fell 30.025 to 8.530 ms; readonly lists fell 38.907 to 8.950 ms. Tiny keyed lookups add worker overhead. No schema or config changes.
@steipete
steipete force-pushed the steipete/perf-micro-worker-migrate-device-pairing-20260919 branch from bdd90ae to c702551 Compare September 21, 2026 12:24
@steipete
steipete merged commit 05117d9 into main Sep 21, 2026
220 checks passed
@steipete
steipete deleted the steipete/perf-micro-worker-migrate-device-pairing-20260919 branch September 21, 2026 12:55
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…aw#154671)

Move runtime pairing reads into the read-only worker scope and mutations through the shared SQLite broker. Publish committed authority facts and revalidate live approval and node leases before commit; reconcile replaced grants even when result delivery fails.

Testbox: 1,208 focused and sibling tests passed, plus type, lint, build, and golden checks. At 5,000 devices and 50 callers, list main-thread CPU fell 30.025 to 8.530 ms; readonly lists fell 38.907 to 8.950 ms. Tiny keyed lookups add worker overhead. No schema or config changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: XL 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