Repository navigation
refactor(device-identity): admit runtime identities through the shared worker - #166539
Conversation
…d worker Move live client, call, sharing, goal, APNs, and monitor identity preparation off the caller thread while retaining read-only discovery, process caches, boot/Doctor paths, and accepted client settlement. Reuse the existing shared-state owner and avoid a redundant warm freshness lookup.
Keep warm codecs synchronous and authorize against a fresh session row after cold identity preparation. Reject ownership changes during codec loading, including foreign publication that was absent from resident sharing facts.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: blocked before merge. Reviewed October 7, 2026, 2:00 PM ET / 18:00 UTC (Revision 14). ClawSweeper reviewWhat this changesMove runtime device identity preparation into the shared database worker, preserve authentication and shutdown ordering, and reduce redundant pairing and retired-plugin cleanup work. Merge readiness⛔ Blocked before merge - 3 items remain Keep open: this remains useful, distinct work that current main does not implement. No actionable introduced code or security defect was found, but the agreed performance and integrated compatibility qualifications remain incomplete. Priority: P2 Review scores
Verification
How this fits togetherDevice identity supplies signing keys for Gateway connections, public session links, goal receipts, and push delivery. Runtime callers now prepare those keys through the existing shared-state worker before continuing their authorized operations. flowchart TD
A[Gateway and runtime requests] --> B[Identity preparation]
B --> C[Process cache]
B --> D[Shared database worker]
D --> E[Canonical identity state]
C --> F[Current authority and lifetime checks]
D --> F
F --> G[Connection signing and authorized effects]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +207, Tests +506, Docs +44, Other +6. Total +763 across 79 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one worker-backed identity owner with fresh final-effect authority checks, stable released client contracts, and demonstrated non-growing workload SQL cost. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction: source confirms the native runtime identity paths being moved, and the body records a real Gateway workload comparison; no new failing current-main execution was performed during this read-only review. Is this the best way to solve the issue? Yes: extending the existing shared-state worker and preserving current authority guards is the appropriate ownership boundary, subject to completing the agreed cost and integrated compatibility checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5e01ab02de35. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (13 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
The real-socket service-auth probes now reach asynchronous identity admission. Select the existing fork-based worker test owner so the unchanged cases retain real broker admission, socket behavior, and read-only assertions.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
8 upstream commits. One conflict, in src/infra/heartbeat-runner.ts: upstream openclaw#166539 (de7c3b7) dropped the resolveHeartbeatSchedulerSeed re-export and keeps re-exporting runHeartbeatOnce/startHeartbeatRunner. The feature defines those two locally as wrappers over the split runner, so the resolution keeps the feature side and follows upstream's removal of the seed re-export; nothing imports it through this module. The worker access inventory is regenerated for this tree. Checks, all on the canonical runner: - Typecheck: core plus test shards infra and gateway-methods, all clean. - Ratchets: assertion-safety OK; database-worker ratchet OK. - Tests: src/infra/heartbeat-runner*.test.ts plus sessions-sharing (+authority), 33 files, 361 tests, all green. heartbeat-runner.live.test.ts is excluded by config (*.live.test.ts) and byte-identical to upstream. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
Culprit de7c3b7 (#166539) moved health device-identity reads into the shared SQLite worker. The threaded wizard fixture lacks its host broker. Register the unchanged test with the existing isolated fork-based owner, preserving real health authentication and ambient-endpoint isolation. Validation: focused finalization/health/Doctor tests, whole wizard and unit-fast configs, registry and planner guards, full test-types, typed and boundary lint, complete check-changed, four real manifest shapes, and P2. Whole tooling completed with 941 files passed and 7 skipped; its sole failure is the inherited logging-suppression inventory from #166701. Full infra config gate waived by coordinator: fleet at cap; registry/planner/tooling proof passed
…d worker (openclaw#166539) * refactor(device-identity): admit runtime identities through the shared worker Move live client, call, sharing, goal, APNs, and monitor identity preparation off the caller thread while retaining read-only discovery, process caches, boot/Doctor paths, and accepted client settlement. Reuse the existing shared-state owner and avoid a redundant warm freshness lookup. * fix(device-identity): preserve probe helpers and monitor service types * fix(device-identity): refresh sharing facts after codec admission Keep warm codecs synchronous and authorize against a fresh session row after cold identity preparation. Reject ownership changes during codec loading, including foreign publication that was absent from resident sharing facts. * test(device-identity): isolate CLI drain and probe credentials * test(device-identity): isolate transport fixtures from identity admission * test(gateway): wait for child settlement before public reads The transcript append checkpoint precedes final session metadata writes. Join the real session-work admission before asserting a stable public response. Reuse the fixture correction prepared for openclaw#166293 (1444b89); keep the public-read and permission assertions unchanged. * test(cli): run reachability probes with the host broker The real-socket service-auth probes now reach asynchronous identity admission. Select the existing fork-based worker test owner so the unchanged cases retain real broker admission, socket behavior, and read-only assertions. * perf(state): reuse pairing freshness and synchronous chat validation * perf(plugins): avoid idle cleanup writes and reuse inventory facts * refactor(plugins): name lazy cleanup import
Culprit 8b189ec (openclaw#166539) moved health device-identity reads into the shared SQLite worker. The threaded wizard fixture lacks its host broker. Register the unchanged test with the existing isolated fork-based owner, preserving real health authentication and ambient-endpoint isolation. Validation: focused finalization/health/Doctor tests, whole wizard and unit-fast configs, registry and planner guards, full test-types, typed and boundary lint, complete check-changed, four real manifest shapes, and P2. Whole tooling completed with 941 files passed and 7 skipped; its sole failure is the inherited logging-suppression inventory from openclaw#166701. Full infra config gate waived by coordinator: fleet at cap; registry/planner/tooling proof passed
What Problem This Solves
Cold device identity discovery and creation still run SQLite on the caller thread during Gateway/client authentication, public sharing, goal requests, APNs delivery, and monitor reconciliation.
User Impact
Identity preparation uses the existing shared-state worker while preserving identity bytes, read-only versus creating behavior, and released client contracts. Schemas, configuration, retention, durability, and update behavior are unchanged.
Qualification passed. The final alternating comparison reduces warmed-turn and first-turn medians, reduces control plus cron, and leaves every phase median no higher than its pinned main baseline. Exact-head CI is green; native merge admission is next.
Why This Change Was Made
Callers await the identity owner and reuse its process identity/signing-codec caches. Client shutdown joins accepted preparation and prevents late connection effects. Sharing prepares its codec before the final row/authority read; only cold preparation requires a bounded reread if that read first reveals a share. Goal and APNs callers recheck authority after preparation. Cron prepares one seed for both monitor families. APNs URL policy remains in a leaf module, outside relay transport imports.
Pairing reads reuse freshness within their admitted synchronous operation, preserving the fresh probe after
BEGINand foreign-commit visibility on the next unpinned read. Ordinary chat normalization stays synchronous; goal fingerprinting remains asynchronous.Retired-plugin cleanup now avoids lease writes when its conservative filesystem scan finds no candidates. Actual cleanup shares one fresh, unfiltered installed-index payload in a private operation-scoped cache under the existing lifecycle lease. It preserves malformed-receipt checks, live deletion guards, and hot Gateway cache facts. Cache disposal finishes before lease release. Timers and deletion criteria are unchanged; concurrent artifacts missed by enumeration remain for later cleanup.
The released
GatewayClientconstructor, methods, options, and synchronous custom identity callback remain compatible. Boot pairing, node startup/connect CLI, configuration preflight, Doctor identity/cadence migrations, and worker kernels retain native admission. No SQL is added inside host grant callbacks.Overlap: #162433, #164265, #166094, #166364, #166444, and #166445; integration also preserves #166621 and #166657. Later main #166683 changes heap-snapshot/runtime-instance cleanup; this PR’s private metadata-only cleanup cache creates no runtime instances. The publication-fixture repair reuses #166293's design, also recorded in #166519. Integration preserves #166447's atomic row/member snapshot and #166523's device-auth error policy.
Evidence
Current candidate:
6ab6119e85627f90896f44559492fe50a88d0dbe, merging maind72a907b6125aef3ad98b709c533c8dec2f16c49into pushed repair head823ac87709a182149e3e99cbd6eaa5d0354eaa7e(merge commit, no rebase). GitHub reported real conflicts incall.tsandchat-send-request.ts. The resolutions keep main’s literal-credential-aware auth resolver and ordinary-chat predicate, plus awaited identity admission and synchronous ordinary normalization. Main’s client leaf imports, prepared public-session rows, and retained database/write context remain intact.The reviewed merge tree passed 234 tests across 15 files in 865.651s, core types in 33.778s, all core-test type lanes in 901.135s, Madge in 120.941s (zero cycles), and conflict-file lint in 50.464s. Full integrated P2 review is scoped-clean. No dependency or lockfile change needed installation. The performance fixes are:
31bee3c994783aa627c45904f333ae31c2d621d9: pairing freshness and synchronous normalizationd08563c74b8a8d6379147ee8e9563391844b45d9: cleanup and docsThe production Knip scan exposed a namespace-binding analysis gap, reproduced in an isolated fixture.
823ac87709a182149e3e99cbd6eaa5d0354eaa7euses named destructuring in the same dynamic import tuple; no import targets or runtime semantics change. Production Knip now passes, 11 cleanup tests passed in 136.099s, core types passed in 8.403s, and P2 review is scoped-clean. The original changed-file gate stopped only at that Knip finding. After repair, all three export scans and every remaining planned check passed; earlier successful checks were retained, with no exemption or disabled guard.Test wall times include compilation/worker startup; they are not product latency claims. Final exact-head CI completed in 879s overall, with an 875s active-job window; these are whole-run costs, not invented per-file CI timings.
6ab6119e85627/d72a907b61258c288ff99868821bbaa881dd0a2e695ad2d3f0e48e03969562a1ab6e86eb6790.6ab6119eat 2026-10-07 18:00:31.926 UTC; no actionable code or security findings. Its then-pending SQL/SDK checklist is satisfied by the completed results here.The previous head
c1e9bbfe1b99ae9e2fba8d9a6898b8e7c1e56e12passed CI 37636985496: 74 successful jobs, 23 skipped, 17m35s overall. ClawSweeper subsequently completed the823ac877review at 2026-10-07 17:24:17 UTC without actionable code or security findings; it retained conflict resolution, current SQL qualification, and the compatibility scope clarified below. The later integrated-head review is recorded above. These are prior-head results. No inherited-CI exception was used; old admin evidence for subsequently fixed failures is retired.Released-contract checks covered
v2026.10.1-beta.1and stablev2026.9.8. Changed helpers/removed exports are internal, outside Plugin SDK andapi.runtimeexports. The pre-integration SDK report for7a75498→d08563cpassed in 1311.822s: 131 reachable fingerprints and one private client declaration change, with no changed public callable, export, or entrypoint. Digest:4599fa905ad0487db51123156ef9927253c553e3874976d4e09ef86c9efa09ad, structurally identical to the prior report. The binding-only823ac877follow-up preserves import targets, explicit signatures and every emitted-declaration contract input, so that proof is reused without relabeling its tested head. SDK temporary checkouts for that report were removed. The freshd72a907b→6ab6119ecomparison passed in 1472.138s. Digest:8c288ff99868821bbaa881dd0a2e695ad2d3f0e48e03969562a1ab6e86eb6790. It retains 131 reachable fingerprint changes and one private-client declaration change, with no public callable or entrypoint change; its temporary checkouts were removed.Published 2026.9.8 driver → exact-SHA candidate
2fa3b18cpassed the Docker update proof in 469.09s on Linux/Node 24.21.0: readiness HTTP 200, expected version, durable session/marker preserved, empty incognito history after restart, and artifact inspection passed. Native-drain and service integration passed 14/121 tests.scripts/database-worker-inventory.mjschanges classification only; the newmanaged-npm-retention.tspredicate only enumerates existing marker directories. Marker writers, serialized fields, schema versions, and deletion eligibility are unchanged. This driver run proves the originally approved head, not subsequent source. The follow-up repairs preserve updater behavior, schema and stored formats; current legacy-layout and native-capture recovery tests cover their cleanup boundary. No new updater contract requires another driver matrix. Task-owned infrastructure was released.Final SQL cost verification
The unchanged canonical workload passed in alternating order (main, candidate, repeated three times) on one isolated host, using Node 24.21.0 and SQLite 3.53.4. Exact sources: main
d72a907b6125aef3ad98b709c533c8dec2f16c49and candidate6ab6119e85627f90896f44559492fe50a88d0dbe(treefb3e5c8a5037ae9b7844ad6db78edf83d77ded32). Independent verification matched 259 retained input files against the downloaded archive, checked source/harness hashes and all 12 calibration traces, and reconciled raw phase/thread/SQL counts exactly. All six flows and child-process cleanups passed; SQL execution and preparation errors were zero.Every individual phase median is no greater than main. Warmed and combined-window duration ratios are 1.0170 and 1.00194, respectively; no phase exceeds the 1.5 invalidation limit. Combined totals are 4,888 → 4,842 (−46), and all 16 nonzero median-delta SQL/full-stack groups occur in baseline traces. The first-turn, warmed-turn and remaining phase gates therefore pass without an exception.
The tables below group native statements by their complete captured producer stack. The deltas use the actual median-bearing runs, so they add to the window median change; they are not sums of independently selected family medians. Each row preserves all six sample counts.
device-pairing-*)openclaw-state-lease-*)installed-plugin-index-row)maintainPeriodic)maintainPeriodic)The remaining session/state deltas include shared-state schema/freshness checks, session row reads/writes and transcript projection snapshots; the full SQL strings, stacks and raw file/line examples are retained in the verification summary. The candidate removes the observed warmed lease/metadata cycle and reduces pairing SQL, consistent with skipping empty cleanup and reusing admitted pairing freshness. Canonical traces contain no worker request IDs or command inputs, so these are statement/producer counts, not worker request counts; they do not independently identify a particular logical lease caller. No diagnostic observer was used for these gates. The isolated lease is released and cleanup is complete. Final archive SHA-256:
2c3ea1c3c0d9a382d3b41851f6641c7c985573052e0cf0cd5df1de14078229e0.Earlier CI failures and repairs
d52042643c7cf83132123cf2a8479fcb443d92easupplies explicit null/synthetic identities; transport assertions remain intact. Repaired files passed 72 tests in 77.23s.6ecf7e58aae63fccde9f08eb30ee58c209e47445waits for existing session-work release without sleeps/retries or weakened assertions. Full flow passed 5/5; median wall 45.625s. CI's 404 and merge-base's 503 in 3/5 runs remain distinct observations.7a75498. Earlier terminal-font TS2353 also reproduced on mainde38a045; its published correction was integrated. Old admin evidence is no longer applicable.c1e9bbfe1b99ae9e2fba8d9a6898b8e7c1e56e12routes it into the existing fork inventory. No test/deadline/assertion changes; corrected 9/9 passed in 148.025s.One earlier
probe.device-auth-scopecase ended before its connect frame under its existing 2000ms deadline; unchanged replay passed 9/9. The original cause remains unestablished, and the replay is not claimed as a fix.Historical integration proof passed 190 tests/11 files in 494.12s, core/core-test types, zero-cycle Madge, runtime process graph, reply/worker import closures, and wrapper inventory. Final changed-file/static qualification remains separate.
Approved phase move and completed pre-repair SQL attribution
The maintainer approved only the original +4 first-turn schema-admission phase move: connect MAIN fell 14→0 while first-turn all-thread counts changed 6126→6130. Raw stacks matched four existing checks moving from connect to first turn: schema version, user version, schema catalog, and schema content marker. The schema owner and complete-workload MAIN catalog/content counts (17/33) were unchanged. Connect's other ten saved MAIN statements are separate identity/admission work. This exception does not authorize unrelated first-turn growth or warmed-turn increases.
An earlier grouped comparison (
1b395594→d6298c8a) failed control alone, 50→64. Its adjacent control-plus-cron medians were 2002→2001, but grouped ordering and two unmatched stack groups prevented qualification. The alternating replacement below is the operative historical evidence.Unchanged harness, M,C,M,C,M,C, one isolated host, Node 24.21.0/SQLite 3.53.4: main
7a75498beb6ece381f483f7e194dd8665c77f3a1versus production77ecbf16d11f6e90125c4fad9938d18b53f85fef. All six workloads, conservation assertions, and child cleanup checks passed without SQL execution/preparation errors.c1e9bbfechanged only test routing.Raw first-turn runs: main
[5986,5987,6023], candidate[5971,5978,6097]; warmed[23191,23169,23162]versus[23228,23231,23169]; combined[1889,1880,1917]versus[1928,1899,2053]. Warmed/combined median duration ratios were 1.0021/1.0006. Combined aggregates increased 5686→5880; complete-workload aggregates decreased 136897→136780. Workload savings do not waive failed phase gates; independently computed medians need not sum.The following uses median-bearing runs: warmed M2/C1 and combined M1/C1. Families follow full producer stacks; unidentified outer admission remains in other reads.
All 90 changed combined-window SQL/stack groups exist in baseline traces; that does not waive the increase. Every candidate executes the lease/metadata cycle during warmed turns; M1/M2 do so during second-session, M3 not after boot. Whole-workload lease totals are
[372,372,351]versus[372,372,372]; metadata[27,27,21]versus[27,27,27]. Pairing combined-window snapshot misses are two per baseline and three per candidate.A separate diagnostic-only observer copy found equal warmed pairing/plugin-state request counts (13/6 each side). Lease→metadata→metadata→release shared one actor/connection, but lacked host caller information. Retired-plugin cleanup is a source-supported candidate, not a proven trace identity or identity-commit trigger. Diagnostic retention retries were absent from all six original warmed traces and are excluded as the cause. This diagnostic is not gate evidence.
The repaired final-source medians are recorded above. Historical measurement archive SHA-256:
47b7526855e0ef58b3f1e7c723d0d56294306c76955282ef8e8c1cefa49485ec.