Skip to content

refactor(gateway): deslop worker environments and gateway runtime - #156759

Merged
steipete merged 2 commits into
mainfrom
deslop/l17-worker-env-canonical-20260923
Sep 24, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/l17-worker-env-canonical-20260923

Conversation

@steipete

@steipete steipete commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

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
  • Worker artifact/workspace transfers share bearer parsing, serialized rate-limit accounting, rejection responses, and authorized dispatch.
  • Workspace reconciliation shares bounded manifest downloads, file comparison, inventory buffering, publication-error mapping, and the existing standalone mutation-lock helpers.
  • Inference replay uses the terminal-frame owner; streamed argument text and byte counts stay together; live-event draining retains its publication record.
  • Placement and tool operations share existing mutation/phase types and settlement predicates. Unused idle-reconciliation and worker-owner probe methods, an unused ACK argument, and forwarding layers are removed; current turn-claim coverage remains.
  • Bootstrap, bundle, credential, and attachment paths use their canonical build comparator, manifest types, normalization, deferred promises, and directory preparation.
  • Node pending pull/ack share pairing-generation admission and the final pairing fence; response projection remains after that fence. Exact and legacy node-event matching share one matcher, retaining the legacy uniqueness requirement.
  • Session reset and compaction reuse current-entry validation without moving it across drain or commit boundaries. Session projections use canonical numeric/pagination helpers and store-read option types.
  • Approval, delivery, desktop-error, and terminal handlers use existing validation, normalization, and result owners. The terminal manager directly uses the canonical PTY backend, retaining process-tree cleanup and shared deadline settlement.
  • RFB probing relies on the exact-byte reader instead of a second incomplete-buffer state machine. Portal HTTP and WebSocket adapters share dispatch and response/socket tracking while retaining exact runtime identity lookup.
  • MCP loopback methods share origin/sender authentication and diagnostics. App tool/resource reads share the existing read-authority wrapper, retaining post-await grant checks; reconstruction uses the existing global-map owner.
  • Hook action construction returns its actual action, removing unreachable error/null cases and forwarding wrappers. Absolute hook paths retain their original Windows drive-resolution semantics. Talk setup derives shared launch-option keys and uses its existing controller and coercion owners directly.
  • Agent persistence drops a marker wrapper whose fallback was unreachable after owner resolution, along with unused result fields. Chat history shares text and numeric-metadata sanitization while retaining tool-payload preservation and main's state-contention projection.
  • HTTP request/upgrade types come from the plugin routing owner. Managed image metadata consumes the already-prepared buffer instead of retaining an unused file-loading branch.

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 tree 3486fb454b0bd8c6152552757e96b3e7b8a18532, which exactly matches committed head e9fb5b9a19ba6167a317227ba72220bb9016abe1. The backing Actions run can show cancellation during successful one-shot Testbox cleanup.

  • Codex autoreview through P2: scoped-clean after rebasing onto the landed Workshop repair.
  • 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.
  • Representative Gateway benchmark: 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.
  • The two changed worker tests were also benchmarked with 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-in gateway-cron-tools-allow.live.test.ts provider 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 on e9fb5b9a19ba6167a317227ba72220bb9016abe1.

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 in 10145049f8170010d12c239b945fddb741ec67b7 and a018e414bb9d27a276217810ca81f540dc428c6b. This branch is now rebased onto both repairs, with both refactor patches unchanged according to git range-diff. On rebased head 6c7213309ec843f3894070480a26257dbf0f2a57 (tree 0aaae4826d9f35056d90b2de551e9895c18171dc), node scripts/check-changed.mjs, pnpm build, and all seven focused/cross-shard batches selecting 158 paths passed in Linux Testbox, lease tbx_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 for 6c7213309ec843f3894070480a26257dbf0f2a57; node scripts/watch-pr-ci.mjs 156759 6c7213309ec843f3894070480a26257dbf0f2a57 --repo openclaw/openclaw --timeout 3600 --interval 120 exited 0.

Compatibility review clarification

There is no configuration, default, protocol, or stored-schema change in this diff. In provider-lifecycle.ts, the removed verifyWorkerAdmissionHandshake wrapper did nothing except return sameWorkerBuild(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.ts shares 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, including provider-runtime-refresh.test.ts cases that upgrade attached runtimes while retaining machines and workspaces.

Historical Linux A/B used node --import tsx scripts/ci-run-node-test-shard.mts with the saved original CI group payloads and ordering for compact-small-40 and compact-small-42. Both complete jobs passed on original base 764c9331a31, prior branch head e9fb5b9a19b, and the rebased candidate. Both failed on CI's old main parent 735e46e75b8 and old merge snapshot fa207a0a6e0, 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.

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 6c7213309ec843f3894070480a26257dbf0f2a57
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server-http-plugin-auth.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/worker-environments/credential-broker.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 23, 2026, 10:25 PM ET / September 24, 2026, 02:25 UTC (Revision 4).

ClawSweeper review

What this changes

The 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
Reviewed head: 6c7213309ec843f3894070480a26257dbf0f2a57

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The consolidation is coherent and broadly validated, but its required existing-state upgrade behavior remains unshown.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Reported Testbox boundary and loopback validation covers the refactored paths, but does not show a published updater over an attached worker. No persisted data shape change was identified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Reported Testbox boundary and loopback validation covers the refactored paths, but does not show a published updater over an attached worker. No persisted data shape change was identified.
Evidence reviewed 9 items Worker lifecycle refactor: The introduced change replaces a wrapper with the same build comparator at bootstrap and runtime-refresh call sites; the receipt check remains before committing a ready worker.
Request authority retained: The shared pending-node path checks the connection against its pairing generation and rechecks that generation before returning a result.
MCP read authority retained: The consolidated MCP App read path checks the interaction grant before upstream work and again before returning protected results.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

  • Resolve merge risk (P1) - An installed updater has not been shown moving this candidate over an existing attached cloud worker, so continued session attachment, credential use, and workspace recovery across that upgrade remain unverified.
  • Complete next step (P2) - Record a published-updater × candidate run over an already attached cloud worker, including session, credential, workspace, and recovery outcomes.
  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/gateway/portals/portal-service.ts, unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Prove an attached-worker upgrade (recommended)
    Run a published updater against an already attached worker and record its post-update session, credential, workspace, and recovery outcomes.
  2. Defer the consolidation
    Keep this PR open until an existing-state upgrade environment is available for that check.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is an internal cleanup with no intended user-visible behavior change.
  • merge-risk: 🚨 compatibility: The refactor touches attached-worker lifecycle and credential paths whose published-upgrade behavior remains unshown.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Reported Testbox boundary and loopback validation covers the refactored paths, but does not show a published updater over an attached worker. No persisted data shape change was identified.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Josh Lehman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record a published-updater-to-candidate run with an attached cloud worker and show its post-update session, credential, and workspace outcome.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-23T20:45:06.681Z sha 21439de :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-23T22:30:04.605Z sha 21439de :: blocked before merge. :: none
  • reviewed 2026-09-24T01:04:24.068Z sha e9fb5b9 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 23, 2026
@steipete
steipete force-pushed the deslop/l17-worker-env-canonical-20260923 branch from 21439de to e9fb5b9 Compare September 24, 2026 00:54
@steipete steipete changed the title refactor(workers): deslop worker environments refactor(gateway): deslop worker environments and gateway runtime Sep 24, 2026
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.
@steipete
steipete force-pushed the deslop/l17-worker-env-canonical-20260923 branch from e9fb5b9 to 6c72133 Compare September 24, 2026 02:16
@steipete
steipete merged commit 4a11f89 into main Sep 24, 2026
237 checks passed
@steipete
steipete deleted the deslop/l17-worker-env-canonical-20260923 branch September 24, 2026 03:35
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 24, 2026
…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
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant