Repository navigation
refactor(gateway): simplify scope checks and tool dispatch - #154120
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 20, 2026, 7:03 PM ET / 23:03 UTC (Revision 3). ClawSweeper reviewWhat this changesSimplifies Gateway permission checks and built-in tool routing, consolidates continuation tests, and repairs filesystem test configuration isolation. Merge readiness✅ Ready for maintainer review Keep open: this maintainer-requested cleanup remains distinct from the merged scope consolidation. No actionable correctness or security findings remain at the reviewed head. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway checks operator permissions before dispatching tool requests and sending events to connected clients. Built-in agent tools use its in-process dispatcher, which retains caller identity, session access, and execution-lifetime checks. flowchart LR
A[Built-in agent tools] --> B[In-process Gateway dispatcher]
C[Caller identity and grants] --> B
B --> D[Shared scope checks]
D --> E[Authorized method handler]
F[Gateway events] --> G[Recipient scope checks]
D --> G
G --> H[Connected clients]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -40, Tests -22, Docs -4. Total -66 across 12 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep one shared scope policy and route built-in tools directly through the existing dispatcher while preserving its authorization and lifetime contracts. Do we have a high-confidence way to reproduce the issue? Not applicable to the behavior-preserving refactor. The incidental fixture failure has a documented original-order reproduction, but this read-only review did not execute it. Is this the best way to solve the issue? Yes: removing re-export indirection and redundant permission branches keeps the existing owners and avoids adding a parallel authorization path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3ec1caf958cc. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
Reuse the exact owner fix from a342c69 (#154120). The installer predecessor restores explicit fs-safe native configuration, which outranks the environment flag; the close-failure fixture must set and restore the same owner rather than changing the environment alone. Reproduced the exact CI failure with the installer-before-Claw order (58 passed,1 failed,1 existing skip). After repair all59cases pass with1skip; this host subsequently refuses temporary-namespace cleanup with EACCES, recorded separately rather than counting an exit0. Canonical Claw file alone passes28with1skip and exit0; the owning PR also has Linux/macOS order proof and a green hosted job. Independent scoped P0-P2 review clean. No production or permission changes. Co-authored-by: steipete <[email protected]>
Preserve Telegram and foreground-delivery changes while retaining the canonical Claw test repair from openclaw#154120. Co-authored-by: VACInc <[email protected]>
…154120) * refactor(gateway): simplify scope checks and tool dispatch * test(claws): isolate close-failure native configuration
Related: #153979
What Problem This Solves
Maintainer-requested simplification of the background-continuation scope fix: built-in Gateway tools unnecessarily imported the plugin loader, and scope checks carried redundant wrappers and branches.
User Impact
No permission or user-visible behavior change. Background continuations retain their existing read access through
operator.write; identity, session access, cancellation, and execution-lifetime checks remain in force. No migration or configuration change is required.Why This Change Was Made
Built-in tools now import their existing dispatcher directly. The shared scope predicate expresses exact grants, admin, and write implications once; role namespace checks no longer construct synthetic authorization requests. Event authorization keeps its existing plugin and public-event rules with fewer branches.
The continuation regression now calls the actual GitHub identity tool through each of
sessions_send,subagent_announce, andsubagent_settle, removing the duplicate method axis. Independent scope and lifecycle tests remain. Net reduction: 40 production lines, 22 test lines, and 4 documentation lines.Evidence
pnpm buildpassed, including plugin control-plane loading checks.node scripts/check-changed.mjspassed for the architecture cleanup: formatting, production/test type checks, lint, unused-export checks, and runtime import-cycle checks (0 cycles).CI fixture repair
The first CI run exposed an existing order-dependent Claw archive test introduced in #153973. An earlier installer test restores fs-safe through
configureFsSafeNative, whose explicit mode takes precedence overFS_SAFE_NATIVE_MODE. The Claw test's environment override therefore failed to disable native writes, bypassing its JavaScript close-error spy. The fixture now selects and restores its mode through the same configuration owner, retaining the rejection, single-close, and empty-directory assertions.On Linux, the Claw test and its full file passed alone. Running
src/skills/lifecycle/install-download.test.tsbeforesrc/claws/project.test.tsin one worker reproduced the exact CI failure: 58 passed, 1 failed, 1 existing skip. After the repair, that original order passes on Linux and macOS: 59 passed, 1 existing skip. A temporary Vitest sequencer fixed the order explicitly; no runner configuration was committed.Linux proof used configured Blacksmith Testbox
tbx_01m30f2c7casje5c9c135x1e21, prepared run, the existingtest/vitest/vitest.unit-src.config.ts, and--maxWorkers=1 --no-file-parallelism. Wrapper exit status was 0. Targeted lint and a fresh independent P0–P2 review of the fixture repair passed. The previously failing hosted job is now green.