Repository navigation
fix(cli): keep concurrent Gateway calls authenticated - #166523
Conversation
|
🦞👀 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. |
|
|
Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 8:31 AM ET / 12:31 UTC (Revision 5). ClawSweeper reviewWhat this changesThe PR reduces Gateway credential-loading overhead, stops calls when selected device identity loading fails, and reuses the Gateway’s plugin registry for HTTP tool requests. Merge readiness✅ Ready for maintainer review The repair remains necessary: current main retains the snapshot reads and swallowed identity-load errors. No blocking correctness finding emerged, and the supplied real-runtime evidence supports the changed behavior. Priority: P2 Review scores
Verification
How this fits togetherGateway CLI calls load credentials before opening an authenticated WebSocket connection. The shared-state worker owns token operations, while HTTP tool requests consume the Gateway’s existing plugin registry before dispatch. flowchart TD
A[Gateway CLI calls] --> B[Identity and token loading]
C[Shared SQLite state] --> B
B --> D{Identity loading succeeds}
D -->|Yes| E[Authenticated Gateway connection]
D -->|No| F[Recovery guidance]
G[HTTP tool requests] --> H[Gateway plugin registry and authorized dispatch]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +17, Tests +83, Docs +8, Other -1. Total +107 across 26 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep credential reads and mutations under their existing SQLite owners, preserve selected identity through connection setup, and share the Gateway-owned plugin registry across transports. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the swallowed-error path on current main, and the supplied baseline-failing regressions isolate it. This read-only review did not execute the reproduction. Is this the best way to solve the issue? Yes, the patch reuses existing read and worker owners, removes superseded dispatch, and preserves authorization rather than adding competing mechanisms. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f2c5ed82c5f1. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
27c0e79 to
5db4a40
Compare
5db4a40 to
fc71f5d
Compare
|
I’m investigating one-shot |
Read existing device identities and tokens without full database snapshots, and fail before connecting when identity storage is unavailable. Prepare all device-auth commands through the narrow worker adapter while retaining the existing actor and transaction/commit admission checks.
fc71f5d to
1ed5997
Compare
Restores artifact-preserving reads for Doctor's device-identity detector during migration planning (regressed in #166523). Proven with a published-driver (2026.9.8) x candidate cell.
* fix(cli): keep concurrent Gateway calls authenticated Read existing device identities and tokens without full database snapshots, and fail before connecting when identity storage is unavailable. Prepare all device-auth commands through the narrow worker adapter while retaining the existing actor and transaction/commit admission checks. * test(gateway): align authentication failure expectations * fix(gateway): preserve plugin registry in HTTP tool requests
…w#166671) Restores artifact-preserving reads for Doctor's device-identity detector during migration planning (regressed in openclaw#166523). Proven with a published-driver (2026.9.8) x candidate cell.
What Problem This Solves
Concurrent
openclaw gateway callprocesses stalled while loading credentials and could silently connect without device identity when that loading failed. Idempotentsessions.createthen lost the identity required to bind its request.User Impact
Existing identity and token reads no longer copy the shared database. An identity-load failure stops before connecting and gives recovery guidance. Native read-only SQLite may create empty WAL/SHM coordination files; credential rows, schema, permissions, and update behavior are unchanged.
Why This Change Was Made
Authentication performed two whole-database snapshots, then loaded the broad shared-state runtime just to prepare a token command. Both readers now use the existing native read-only owner. All eight device-auth commands move together into the existing early worker registry and a narrow adapter; the old dispatch is deleted. The same actor, FIFO, transaction, and commit-authority checks remain.
CI also exposed an inherited HTTP tool-invocation defect: the adapter omitted its Gateway-owned plugin registry from request scope, causing provider discovery to register the same workspace plugin again. HTTP now carries the existing instance-owned registry, as RPC already does. The concrete factory preserves its known plugin type; generic metadata and authorization readers retain their prior view contract. Partial-registry and undeclared-provider discovery behavior is unchanged.
Production LOC delta: +17. The typed worker boundary and explicit HTTP ownership handoff preserve existing asynchronous and lifecycle contracts while removing broad runtime dispatch. No cache, configuration option, dependency, schema change, or migration is added.
Evidence
A real dist Gateway and 20 concurrent CLI processes shared one identity and 512 MiB of synthetic state. Each call used a distinct idempotency key.
A separate 16-vCPU Blacksmith Testbox run completed 20/20 calls with identity: solo 2.46 s, concurrent median 8.39 s, maximum 8.61 s. The overall five-second burst target remains unmet. The synthetic rig reproduced stalls/transport timeouts, but not spontaneous identity loss; baseline-failing load-error regressions independently prove the swallowed-error defect.
The HTTP repair has separate real dist-Gateway proof on Node 26.8.1: both requests returned HTTP 200, while registration count changed 1 → 2 before and stayed 1 → 1 after. All five candidate source files were restored byte-for-byte after the comparison.
Proof
tbx_01m4adhez7w8zt60rf8fxy0kn0: original snapshot reader fails the 20-process regression when snapshot subprocess capacity is unavailable; the native reader passes (1.79 s test time). Original broad worker preparation fails the cold-auth import regression; the narrow dispatcher passes. Gateway, storage/admission, and worker-import suites passed 179 tests.tbx_01m4akpmh9m0cf84h2n4vbq1fw: CLI suites passed 49 tests in 70.13 s with exact stored-byte assertions. The capsule receiver verified source tree70714aa030d5655c1a42ca3fe21678c390cfe4e9. ThecliStartupruntime build passed in 44.5 s, followed by the real 20-process benchmark.tbx_01m4artqr2rs5yzmbb1388qdv9: remote-onboarding 21 tests passed in 23.67 s; the credential-rotation E2E passed in 36.47 s. Both changed-file gates passed. These correct the obsolete silent-fallback expectation and the inherited error-message expectation from fix: stop recommending onboarding for OpenClaw runtime failures #166234. A full runtime build passed in 353.8 s.526ed332c00f243d52691c79ca5a58aa8f1cbecc. Its assertion was preserved. The owner handoff is proven by the before/after dist-Gateway comparison above.node scripts/check-changed.mjs --stagedpassed for the original 19-file candidate and the final five-file HTTP repair. The latter finished with exit 0 at 11:22Z, including core/test types, lint, storage guards, and zero runtime import cycles. Both HTTP-comparisoncliStartupbuilds passed. The supplemental Testbox replay did not run: one lease finished before accepting a command, and its replacement stayed queued; the authorized rig supplied the real-flow proof and gate.Individual test costs on Blacksmith Testbox
tbx_01m4ap2t31r0e4ymby3kr50kcd, usingnode scripts/run-vitest.mjs <file> --maxWorkers=1(thepnpm testwrapper):src/gateway/call.test.tssrc/infra/device-auth-store.test.tssrc/infra/device-auth-store.worker.test.tssrc/infra/device-identity-async.test.tssrc/infra/device-identity-worker.test.tssrc/infra/device-identity.test.tssrc/state/openclaw-state.worker.imports.test.tssrc/cli/gateway-backed-exit.process.test.tssrc/cli/gateway-backed-exit-health.process.test.tsAll nine runs passed. Cold compiled-worker preparation dominates the longer wall times. The process/worker tests protect SQLite concurrency, authority, clean exit, and unchanged stored bytes.
Prior CI runs
37594337983and37601573757consumed 13,839 and 14,046 job-seconds, including 8,574 and 9,090 Node-test job-seconds. They are failure evidence, not passing proof: the former found the two stale expectations and inherited HTTP defect; the latter failed only on that HTTP defect. The next run,37616530633, passed every Node test job and failed only on an inherited terminal-font fixture type error; its cost was 17,218 job-seconds, including 9,187 Node-test job-seconds. Main fixed that unused argument in1d10375ee563; rebase incorporated the fix and dropped the identical local correction. The exactui-componentstype group passed in 93.0 s in the scoped rig gate, and review found no actionable issues. Current-head CI run37620590123, attempt 2, completed successfully on1ed5997ed826; all 97 jobs in the latest result set passed or were intentionally skipped. That set accounts for 18,741 job-seconds, including 10,361 Node-test job-seconds. The first attempt failed one Android Play case,ChatComposerLayoutTest.reviewMenuLoadsCurrentConversationSnapshotAndRetiresOnSessionSwitch, on its one-second Compose wait (3,567 tests, one failure). Android sources were unchanged from the preceding passing run. One exact-job replay passed on the unchanged head; no test, timeout, or production code was changed for it, and its root cause remains unresolved. The separate aggregate CI/security status is also green on this head.Final rebase retained all reviewed HTTP and device-auth changes. It incorporated an upstream plugin-state-only transaction admission optimization; the shared worker's default admission path used by device auth remains unchanged. The generated mock baseline also incorporates upstream shrink-only removals. Only this lane's three commits remain above main.
Published head:
1ed5997ed826fae38de607f8abbbc6c629ccd91f. The latest rebase preserved all reviewed/tested file contents byte-for-byte.