Repository navigation
fix(devices): authorized operator-token changes fail or lose their reply - #138492
Conversation
Derive CLI connection scopes from authenticated target metadata and requested token scopes so authorized operator rotation and revocation can complete. Keep limited self-management narrow and enforce existing server authority. Reserve each committed device mutation's final response before its own invalidation, preserving replacement-token delivery and immediate fencing. Reuse the policy-response owner and cover self-removal through the same path. Remove the duplicate scope inventory and record its assertion ratchet shrink. Validation: 394 focused tests, final changed checks, and runtime build passed. Built macOS CLI proof covers 22 scenarios across 15 original passes and seven focused rechecks, not a single green matrix run. Historical pre-CLI EPERM did not recur; its syscall remains unknown. Scoped managed review found no P0s.
|
🦞👀 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: blocked before merge. Reviewed September 4, 2026, 2:51 PM ET / 18:51 UTC. ClawSweeper reviewWhat this changesThis PR updates device-token CLI scope selection and Gateway response-close sequencing so authorized rotate, revoke, and self-removal operations complete without widening token authority. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 1 item remains No blocking correctness finding. This is an active, maintainer-owned repair for a concrete current-main CLI and Gateway authorization failure; it should remain open for normal maintainer landing once exact-head checks complete. Priority: P2 Review scores
Verification
How this fits togetherThe devices CLI opens a scoped Gateway connection for device-token maintenance, then Gateway handlers authorize and mutate the canonical pairing-token store. When an operation retires the caller’s credential, the response-close policy must send that operation’s final result while fencing subsequent requests. flowchart LR
A[Devices CLI command] --> B[Pairing visibility lookup]
B --> C[Scoped Gateway request]
C --> D[Device token owner]
D --> E[Reserve final response]
E --> F[Invalidate old credential]
E --> G[Return mutation result]
F --> H[Close and fence later requests]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +22, Tests +706, Docs +1, Other 0. Total +729 across 9 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the combined scope-selection and response-reservation repair: the token owner stays authoritative, and no smaller net-neutral change can both discover the target’s scopes and preserve its final self-operation response. Do we have a high-confidence way to reproduce the issue? Yes. Current main’s operator-token path supplies no explicit connection scope, while the introduced focused CLI and WebSocket tests cover the resulting denial and suppressed self-operation reply. Is this the best way to solve the issue? Yes. The change fixes request-scope selection and response ownership while preserving the canonical token owner’s scope, role, and device-ownership checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 26f87a37009b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Use the canonical committed-mutation response owner from #138492 for device remove, rotate and revoke, preserving immediate fencing and scoped teardown. Include the separately reviewed #138625 cleanup fix so a retired caller cannot skip removed-device worker reconciliation. Keep setup/bootstrap on their existing retirement helper and retain the Watch HTTP invalidation owner. Validation: 194 owner, Watch and authorization tests passed with zero skips; fresh scoped managed review found no P0-P3 findings. Full changed checks and new published-head native/Gateway live proof remain separate landing gates.
…8492) Derive CLI connection scopes from authenticated target metadata and requested token scopes so authorized operator rotation and revocation can complete. Keep limited self-management narrow and enforce existing server authority. Reserve each committed device mutation's final response before its own invalidation, preserving replacement-token delivery and immediate fencing. Reuse the policy-response owner and cover self-removal through the same path. Remove the duplicate scope inventory and record its assertion ratchet shrink. Validation: 394 focused tests, final changed checks, and runtime build passed. Built macOS CLI proof covers 22 scenarios across 15 original passes and seven focused rechecks, not a single green matrix run. Historical pre-CLI EPERM did not recur; its syscall remains unknown. Scoped managed review found no P0s.
* feat(watch): add native standalone realtime voice Add opt-in Talk on Watch with provider-direct WebRTC/Opus, scoped Gateway control and explicit call/audio ownership. Preserve phone-mediated voice. Resolve native endpoints consistently across ICE and Network.framework, fence late resolver/media work after cancellation, and release received Opus promptly after packet loss while dropping late speech. Keep recoverable provider notices visible without closing the session; make setup actionable. Source review passes all eleven sections through P3. Native engine RED/GREEN passes eleven final cases; real Watch Simulator resolver classification and held-result cancellation pass fifteen and sixteen cases respectively. Full device/provider/current-base CI verification remains a landing gate. Uses the already-landed app-local companion journal; adds no database schema or protocol-version change. Physical Watch microphone/speaker, background and endurance behavior remains unverified. * fix(watch): use OS entropy for ICE credentials Supply fresh ICE credentials through the native engine's existing owner API instead of relying on the pinned library's non-cryptographic defaults. Fail engine creation closed if operating-system entropy is unavailable. The actual C-ABI regression repeats dependency RNG state: credentials repeat before the repair; all twelve engine cases pass afterward. The existing locked getrandom package owns the platform entropy call; no resolved packages, configuration, database schema, or Gateway protocol are added. * test(qa): follow canonical ClawHub documentation ownership * test(ios): retain websocket frames across receive registration * test(qa): align Watch branch with landed documentation reference * test(ios): include websocket regressions in selected lifecycle suite * fix(watchos): remove unused audio startup result Remove the unused audio-format result through the audio, media-session and controller path. Periphery exposed obsolete fields in a value the sole caller discarded; activation, cancellation and codec policy stay unchanged. Include the separately reviewed Apple fixture synchronization fixes from #138207 while that prerequisite lands. No Gateway runtime, protocol, configuration or persistence changes. * chore(watch): sync landed CI prerequisites Reuse the canonical startup baseline from #138449, terminal-parent QA acknowledgment from #137342, and handle-scoped reclamation fixture from #138481. Keep the Watch, Rust and Gateway/provider production sources unchanged from the verified 907 native and real-provider checkpoint. The four-file delta has a clean independent review. Source binding retains all 148 native inputs, 10 Rust pins and 3,095 Gateway/auth facts; tests and baseline proof remain source-specific. No required check, timeout or size allowance is disabled. Co-authored-by: Ayaan Zaidi <[email protected]> * fix(gateway): compose device reply ownership with watch voice teardown Use the canonical committed-mutation response owner from #138492 for device remove, rotate and revoke, preserving immediate fencing and scoped teardown. Include the separately reviewed #138625 cleanup fix so a retired caller cannot skip removed-device worker reconciliation. Keep setup/bootstrap on their existing retirement helper and retain the Watch HTTP invalidation owner. Validation: 194 owner, Watch and authorization tests passed with zero skips; fresh scoped managed review found no P0-P3 findings. Full changed checks and new published-head native/Gateway live proof remain separate landing gates. * test(watch): isolate platform metadata regressions --------- Co-authored-by: Ayaan Zaidi <[email protected]>
* feat(watch): add native standalone realtime voice Add opt-in Talk on Watch with provider-direct WebRTC/Opus, scoped Gateway control and explicit call/audio ownership. Preserve phone-mediated voice. Resolve native endpoints consistently across ICE and Network.framework, fence late resolver/media work after cancellation, and release received Opus promptly after packet loss while dropping late speech. Keep recoverable provider notices visible without closing the session; make setup actionable. Source review passes all eleven sections through P3. Native engine RED/GREEN passes eleven final cases; real Watch Simulator resolver classification and held-result cancellation pass fifteen and sixteen cases respectively. Full device/provider/current-base CI verification remains a landing gate. Uses the already-landed app-local companion journal; adds no database schema or protocol-version change. Physical Watch microphone/speaker, background and endurance behavior remains unverified. * fix(watch): use OS entropy for ICE credentials Supply fresh ICE credentials through the native engine's existing owner API instead of relying on the pinned library's non-cryptographic defaults. Fail engine creation closed if operating-system entropy is unavailable. The actual C-ABI regression repeats dependency RNG state: credentials repeat before the repair; all twelve engine cases pass afterward. The existing locked getrandom package owns the platform entropy call; no resolved packages, configuration, database schema, or Gateway protocol are added. * test(qa): follow canonical ClawHub documentation ownership * test(ios): retain websocket frames across receive registration * test(qa): align Watch branch with landed documentation reference * test(ios): include websocket regressions in selected lifecycle suite * fix(watchos): remove unused audio startup result Remove the unused audio-format result through the audio, media-session and controller path. Periphery exposed obsolete fields in a value the sole caller discarded; activation, cancellation and codec policy stay unchanged. Include the separately reviewed Apple fixture synchronization fixes from openclaw#138207 while that prerequisite lands. No Gateway runtime, protocol, configuration or persistence changes. * chore(watch): sync landed CI prerequisites Reuse the canonical startup baseline from openclaw#138449, terminal-parent QA acknowledgment from openclaw#137342, and handle-scoped reclamation fixture from openclaw#138481. Keep the Watch, Rust and Gateway/provider production sources unchanged from the verified 907 native and real-provider checkpoint. The four-file delta has a clean independent review. Source binding retains all 148 native inputs, 10 Rust pins and 3,095 Gateway/auth facts; tests and baseline proof remain source-specific. No required check, timeout or size allowance is disabled. Co-authored-by: Ayaan Zaidi <[email protected]> * fix(gateway): compose device reply ownership with watch voice teardown Use the canonical committed-mutation response owner from openclaw#138492 for device remove, rotate and revoke, preserving immediate fencing and scoped teardown. Include the separately reviewed openclaw#138625 cleanup fix so a retired caller cannot skip removed-device worker reconciliation. Keep setup/bootstrap on their existing retirement helper and retain the Watch HTTP invalidation owner. Validation: 194 owner, Watch and authorization tests passed with zero skips; fresh scoped managed review found no P0-P3 findings. Full changed checks and new published-head native/Gateway live proof remain separate landing gates. * test(watch): isolate platform metadata regressions --------- Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #138491
Additional instructions
Maintainer-owned branch in this repository; maintainers can update it.
What Problem This Solves
Fixes an issue where authorized operators running
openclaw devices rotateordevices revokewould receive a scope denial for operator tokens carrying broader scopes. Real CLI validation also exposed a connected self-management failure: the mutation committed, but the Gateway closed the caller before returning its result or replacement token.The original Linux live report covered revoke, not rotate. Rotation was independently reproduced through the CLI/request/authorization boundary and is now live-tested. Whole-pairing removal is not used as token-only revoke proof. Related: #135617, scoped node-token management, which explicitly left operator connection-scope selection as a follow-up. The profile-avatar repair in #137995 stays separate; none of its four files is changed here.
Why This Change Was Made
The CLI now derives connection scopes from authenticated target visibility and the token's current or explicitly requested scopes, reusing the approval scope converter and the canonical scope inventory. Limited self-management stays narrow; hidden foreign targets require an admin connection. The token owner still enforces the caller's actual grants, target ownership, approved role set and scope baseline.
Device mutations now claim their exact final response through the existing policy-response owner after the awaited mutation and before their own invalidation. Already-invalidated callers cannot claim a replacement bearer, and
finallypreserves target invalidation/disconnect if the claim fails. Pipelined requests and late unrelated replies remain fenced. Device self-removal shared this reply failure and is repaired; node-role removal does not invalidate its operator-role caller and is unchanged.No new stored privileges, configuration, schema, dependencies, protocol fields, mutation retries, local token-management fallback, or production test seam. The private duplicate scope inventory and its unsafe cast are removed; the assertion-safety baseline records the required 11-to-10 shrink.
User Impact
Authorized shared-secret and paired-admin callers can rotate or revoke operator tokens, including cross-device targets. Limited paired callers can complete allowed self-management, receive the self-rotation result before disconnect, and remain unable to manage broader or foreign authority. Token-only revoke leaves the pairing intact while rejecting the old token. Shared/foreign rotations continue withholding the bearer.
CLI output of a replacement token is not automatic CLI cache persistence. The live proof separately reconnects with the returned token through the normal GatewayClient, which owns cache persistence.
Production LOC: +88/-66 (net +22). Tests: +779/-73 (net +706). The production growth supplies authenticated target discovery and final-response ownership with guaranteed teardown, reusing existing owners instead of adding an auth layer. Docs: +3/-2; one shrink-only ratchet entry.
Evidence
pnpm build qaRuntime; no ineffective dynamic-import warning. Built CLI/Gateway proof used native macOS, Node 24.20.0, an allowlisted environment, synthetic isolated HOME/state/config and dedicated loopback ports. No operator state or raw token/pairing-store injection.EPERMbefore reaching the CLI. EPERM did not recur; its historical syscall remains unknown. No result was waived or relabeled as passing.AUTH_DEVICE_TOKEN_MISMATCH. Denied requests left target/caller metadata and credentials unchanged; unrelated tokens remained usable. Self-rotation returned a usable replacement before close. The self-removal sibling is recorded separately, not counted as token-only revoke.90429b0b301e61565a9bfb6c792167a5b4c8fbfc49f80f0c5fe2e4da40d6a465. Dist digest (8,509 files) matched the original final run:6b4e65df19257173270869fc418ee19fd3fc9c737cc09b4f4a4cf684473cce79. Final production/build input hashes were independently checked against the candidate.Exact local validation commands
Redacted observed CLI outcomes
Proof limits: the new built flow was validated on macOS, not a new Linux/browser-UI run; the original Linux revoke evidence is separate. Source proof began at
0d2bc80eee0c2bcec52fc01e3727844e4c823759plus this patch. Raw credential-bearing test captures remain private; no agent transcript is included.Provenance: the node-token repair carried forward, rather than introduced, the operator-scope omission. The separate self-response regression is patch-verified in
5a9168fea34a6b62b5a97673fb5416e7504ced09against raw parentefe2dda63cff3a02ee99c80e97c0c914467c76de, where response-time authority checking was added without registering device mutations.Named follow-up, not silently included here: retained-scope device approval requests can omit broader scopes preserved by the approval owner. That distinct pending-approval mismatch is recorded separately.
Docs: https://docs.openclaw.ai/cli/devices
Committed candidate:
c5cb5dcb0c5658b068349b3c841a1f0c423c9c81. All nine files match the reviewed candidate byte-for-byte after the normal commit hook. The existing local build proves the same source bytes; exact-commit build metadata will be verified by PR CI.Landing verification
Exact head
c5cb5dcb0c5658b068349b3c841a1f0c423c9c81passed CI run 33907199817 on attempt 1, including the requiredopenclaw/ci-gate. The repository watcher exitedGREEN. There were no CI failures requiring a repair or agent rerun; a cached aggregate status lagged the completed run and was checked against fresh run/required-check evidence.Native review artifacts validated with zero findings. Hosted prepare completed at the same head and independently accepted CI run 33907199817 plus Workflow Sanity run 33907159386. No rebase, source edit or additional push was needed. Hosted mode reused CI evidence; no new Testbox lease was created.
Maintainer disposition of the completed ClawSweeper review: accept its recommended option to retain the tested authorization boundary. Its sole pre-merge item is the known production +88/-66 (net +22); the review identifies no correctness/security findings and concludes that no smaller net-neutral change covers both target-scope discovery and final self-response delivery. The canonical token owner remains authoritative, scope discovery reuses the existing converter, and final replies use the existing policy-response owner. Allowed, foreign, broader-scope and stale-caller tests remain intact. No separate rank-up list or source change was requested. This resolves the stated merge-risk item without creating parallel authorization behavior.
The live-proof qualifications above remain unchanged: 15 original passes plus seven exact rechecks, historical pre-CLI EPERM syscall unknown, macOS rather than a new Linux/browser run, and GatewayClient persistence rather than automatic CLI persistence. The separate retained-scope approval follow-up remains outside this repair.