Repository navigation
refactor(gateway): deslop worker environments and gateway runtime - #156759
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: blocked before merge. Reviewed September 23, 2026, 10:25 PM ET / September 24, 2026, 02:25 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch consolidates Gateway worker, session, transfer, portal, terminal, MCP, and display code around existing helpers and removes redundant wrappers and tests. Merge readiness⛔ Blocked before merge - 5 items remain Keep this PR open. Its consolidation is absent from current main and the latest release, and the inspected paths show no concrete introduced defect. The repository-required upgrade check over an already attached cloud worker remains unresolved. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway receives client and agent requests, checks authority, manages sessions and attached workers, and returns replies or events. This refactor changes internal paths between those requests and their worker, transport, and storage owners. flowchart LR
A[Clients and agents] --> B[Gateway requests]
B --> C[Authority and admission]
C --> D[Sessions and worker lifecycle]
D --> E[Transport adapters]
E --> F[Workers and storage]
F --> G[Replies and events]
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the consolidated Gateway owners while preserving attached-worker session, credential, and workspace behavior through upgrades. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR addresses duplicated internal code and does not report a current-main failure. Is this the best way to solve the issue? Yes in direction: reusing the existing Gateway owners is a maintainable simplification, subject to the attached-worker upgrade check. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d9d8f0829d87. 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
History |
21439de to
e9fb5b9
Compare
Consolidate transport admission, workspace I/O, inference projections, and internal store contracts onto their existing owners. Remove retired placement methods and redundant forwarding layers while preserving lifecycle, authority, protocol, and persistence behavior.
e9fb5b9 to
6c72133
Compare
|
Merged via squash.
|
…enclaw#156759) * refactor(workers): deslop worker environments Consolidate transport admission, workspace I/O, inference projections, and internal store contracts onto their existing owners. Remove retired placement methods and redundant forwarding layers while preserving lifecycle, authority, protocol, and persistence behavior. * refactor(gateway): deslop worker environments and gateway runtime
What Problem This Solves
Gateway runtime and worker-environment code repeat admission, lifecycle validation, transport adapters, result projection, and internal type contracts, increasing the cost of keeping those paths consistent.
User Impact
No user-visible behavior change or migration is intended. Worker custody and fencing, request authority, protocols, configuration, SDK exports, and persisted state retain their existing contracts.
Why This Change Was Made
The existing owners now serve the repeated paths directly. Request handlers retain their original options objects, and authority checks remain at their original invocation points, including after awaited work.
Consolidations and removed obsolete paths
The required merge-base production shortstat is 85 files changed, 1,047 insertions(+), 2,289 deletions(-): 1,242 net lines removed. This includes the required assertion-baseline shrink and two deleted test-harness lines. The baseline only reduces allowances for ten removed casts in six files.
Evidence
The pre-rebase candidate passed validation in Blacksmith Testbox, lease
tbx_01m388jzd1fvpeh8bw2aak05km. The wrapper returned exit 0 and the lease is confirmed completed. It verified tree3486fb454b0bd8c6152552757e96b3e7b8a18532, which exactly matches committed heade9fb5b9a19ba6167a317227ba72220bb9016abe1. The backing Actions run can show cancellation during successful one-shot Testbox cleanup.node scripts/check-changed.mjs: passed on the final rebased source, including all 25 test-type shards, lint/format, dead-export scans, import-cycle checks, and schema/boundary guards.pnpm build: passed, including runtime assets, declarations, SDK entry validation, and UI assets.pnpm test src/gateway/desktop/rfb-probe.test.ts src/gateway/hooks-mapping.test.ts src/gateway/chat-display-projection.test.ts src/gateway/terminal/session-manager.test.ts --maxWorkers=1: 131 tests pass on both current main (764c9331a31) and the final candidate; 391.93 s versus 395.88 s wall. Compilation dominates both runs.pnpm test src/gateway/worker-environments/admission.test.ts src/gateway/worker-environments/placement-store.test.ts --maxWorkers=1: original base 32 tests passed in 85.56 s, worker candidate 31 tests passed in 177.39 s. Those earlier measurements used different Vitest versions/cache states; the final Linux selection repeats both files.node scripts/run-vitest.mjs <explicit focused and importer paths>: all 22 bounded batches passed; native project runs reported 10,573 passing test executions, 13 skips, zero failures. The selection contained 528 paths and includes direct importers, cross-shard consumers, worker lifecycle tests, real loopback HTTP routes, and isolated Gateway artifact/credential scenarios. The existing opt-ingateway-cron-tools-allow.live.test.tsprovider suite was not enabled; ordinary project routing also exercises shared fixtures.The previous head's Workshop clock failure reproduced on clean base and candidate. Main fixed it in
764c9331a31; #156776 was closed as superseded by that landed repair. This branch is rebased onto that fix and makes no Workshop changes. Earlier deferred-compaction disposal watchdog failures did not reproduce in complete Linux A/B shards and did not recur in the completed CI run one9fb5b9a19ba6167a317227ba72220bb9016abe1.The completed CI run on the prior head passed 157 jobs. Its two failing tooling jobs tested merge
fa207a0a6e07d981d8343e8c6c9485a83f3d321e, whose main parent was newer than this branch's base: the wrapper inventory omitted the new shared-loader dependency closure, and two newly added Codex attempt tests had no full-suite owner. Main repaired those inputs in10145049f8170010d12c239b945fddb741ec67b7anda018e414bb9d27a276217810ca81f540dc428c6b. This branch is now rebased onto both repairs, with both refactor patches unchanged according togit range-diff. On rebased head6c7213309ec843f3894070480a26257dbf0f2a57(tree0aaae4826d9f35056d90b2de551e9895c18171dc),node scripts/check-changed.mjs,pnpm build, and all seven focused/cross-shard batches selecting 158 paths passed in Linux Testbox, leasetbx_01m38g78gjnvv49er51mrt5yxw. The build verified all 158 public plugin-SDK subpaths. Fresh Codex autoreview through P2 is scoped-clean. The Testbox completed with wrapper exit 0 and its lease is confirmed completed. Its command ran for 1h33m50.812s, including historical failure comparisons. Exact-head CI is green for6c7213309ec843f3894070480a26257dbf0f2a57;node scripts/watch-pr-ci.mjs 156759 6c7213309ec843f3894070480a26257dbf0f2a57 --repo openclaw/openclaw --timeout 3600 --interval 120exited 0.Compatibility review clarification
There is no configuration, default, protocol, or stored-schema change in this diff. In
provider-lifecycle.ts, the removedverifyWorkerAdmissionHandshakewrapper did nothing except returnsameWorkerBuild(handshake, expected); the same owner now receives the same arguments at each original call site. Attached-worker state transitions, credential refresh, recovery, and build mismatch handling retain their existing paths.portal-service.tsshares request/upgrade adapters and retains exact runtime identity lookup and response/socket custody; it adds no migration or backfill. The automated stored-data/configuration flags do not identify a changed contract. An installed-updater/cloud-worker deployment was not run for this behavior-preserving refactor; the required campaign proof uses the existing lifecycle/recovery and Gateway boundary tests, includingprovider-runtime-refresh.test.tscases that upgrade attached runtimes while retaining machines and workspaces.Historical Linux A/B used
node --import tsx scripts/ci-run-node-test-shard.mtswith the saved original CI group payloads and ordering forcompact-small-40andcompact-small-42. Both complete jobs passed on original base764c9331a31, prior branch heade9fb5b9a19b, and the rebased candidate. Both failed on CI's old main parent735e46e75b8and old merge snapshotfa207a0a6e0, with the identical missing shared-loader import and the identical two unrouted Codex test paths. This confirms the failures came from intervening main changes; the two owning fixes above resolve them. No tests, baselines, or assertions were weakened. The compaction disposal-watchdog failure did not recur in the final CI run.