Repository navigation
refactor(gateway): centralize device token denial responses - #148644
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 September 15, 2026, 12:38 AM ET / 04:38 UTC (Revision 3). ClawSweeper reviewWhat this changesCentralizes device-token denial logging, security events, and error replies in the existing rotation and revocation helpers, adding coverage for six denial paths. Merge readiness✅ Ready for maintainer review This maintainer-requested cleanup remains useful and is absent from current main. No actionable introduced defect was found; the reported lint correction preserves the assertion. Priority: P3 Review scores
Verification
How this fits togetherGateway device-management handlers receive authenticated token rotation and revocation requests. Authorization checks and the token service decide whether an operation proceeds; denied requests produce a warning, a sanitized security event, and a generic error reply. flowchart TD
A[Authenticated device request] --> B[Ownership and role checks]
B -->|Allowed| C[Token service]
B -->|Denied| D[Operation denial helper]
C -->|Denied| D
C -->|Succeeded| E[Existing success handling]
D --> F[Warning and sanitized event]
F --> G[Generic error reply]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -33, Tests +108. Total +75 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep denial presentation centralized while leaving authorization, token persistence, and response authority with their existing owners. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a behavior-preserving refactor, and no introduced failure was identified through source review. Is this the best way to solve the issue? Yes. Extending the existing operation helpers removes repetition without adding a parallel authorization or response owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3f10235f1a28. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
@clawsweeper re-review Please review exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
* commit '0cd944c01416c4f9c1f6dc9d1dea9670c5b99cab': improve: speed up session search for restricted operators (#148826) fix(update): avoid retry guidance for historical abandoned runs (#146982) fix(android): reduce queued-message send overhead (#148899) refactor(slack): count table cells only for native output (#148872) fix: correct update status and apply saved model keys (#148830) refactor(nostr): share doctor state migration flow (#148647) refactor(gateway): centralize device token denial responses (#148644) test: make kitchen sink assertions runtime portable (#148891) refactor(agents): share preferred block chunk boundaries (#148391) fix(ui): use the selected timezone for Usage date shortcuts (#148277) test: probe active Node in release preflight (#148892) fix(test): restore services typecheck shard headroom (#148889)
…#148644) * refactor(gateway): centralize device token denial responses * test(gateway): retain the device registry mock handle
What Problem This Solves
This maintainer-requested refactor is part of the approved duplication and complexity reduction deliverable. Device-token rotation and revocation repeat the same denial response after logging and recording the security event. Each operation's existing denial helper now owns that complete sequence.
User Impact
No intended behavior change. Validation, ownership and role checks, awaited token-service calls, generic
INVALID_REQUESTmessages, and early returns stay in their original order. Pairing, successful token operations, invalidation, disconnection, and node-surface updates are unchanged.Why This Change Was Made
Each helper performs the existing synchronous warning → trusted denied event → response sequence. Raw identifiers and optional scope details remain in warnings; events retain normalized roles and hashed identifiers. Existing Gateway response callbacks are arrow functions, so forwarding the same callback preserves their receiver behavior and authority checks.
Production: -33 lines. Tests: +108 lines. No schema, protocol, SDK or authorization-policy change.
Evidence
cfa4705ee203d1c719b68157f04c336d7f22ffe5: 122 successful jobs and 17 planned skips. Selected lint, types, dependencies, guards, build and pinned formatting passed.2077dbe62118c84856c849ccf5935d4626ad3e25contains the exact reviewed two-file postimages.These are handler fixtures with mocked token services and real diagnostic-event dispatch. No live Gateway RPC result is claimed.