Repository navigation
fix(portals): keep worker previews reachable and owned by the active environment - #130434
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 6:56 PM ET / 22:56 UTC. ClawSweeper reviewWhat this changesThe PR repairs worker portal routing through Gateway URL prefixes, IPv6 loopback dialing, portal and stream cleanup, authority fencing, and worker JSON-output isolation. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for normal maintainer review: this current maintainer-labelled repair still has distinct value, and the focused source review found no actionable patch defect. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherWorker sessions open portals through the Gateway so an operator can reach a development server running on a paired node. The Gateway publishes the portal, validates live worker authority, and routes traffic through a node stream to the worker-local application. flowchart LR
A[Worker portal request] --> B[Gateway portal service]
B --> C[Authority and ownership check]
C --> D[Node stream transport]
D --> E[Worker-local app]
E --> F[Portal HTTP response]
C --> G[Worker tool result]
Decision needed
Why: The patch changes listener publication, carrier ownership, and authority timing; the maintainer label calls for a human to accept that lifecycle boundary despite no concrete source defect being found. Before merge
Agent review detailsSecurityNone. PR surfaceSource +7, Tests +271, Docs +2. Total +280 across 17 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk options
Maintainer options:
Technical reviewBest possible solution: Retain the serialized portal-service ownership model and worker RPC final fence, then merge only after the refreshed exact head passes its required checks. Do we have a high-confidence way to reproduce the issue? Yes, at source level: focused tests exercise IPv6 and mounted paths, interrupted stream cleanup, worker authority replacement, and valid worker JSON output; the PR body also records an after-fix authenticated Gateway/node trace. Is this the best way to solve the issue? Yes, subject to maintainer lifecycle acceptance: the portal service is the natural owner of listener publication and carrier cleanup, while callers provide the live-authority fence. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 34ccf63e1379. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
The latest review's outstanding evidence is now recorded in the PR body:
Final-commit CI is running. The latest push is test-only; it does not change the production code exercised by the live proof. No further behavior changes or review findings remain to address before the native CI/merge gate. |
|
Merged via squash.
|
* origin/main: (26 commits) fix(plugins): preserve registry epoch on activation rollback (#129232) refactor(plugins): make discovery invocation-owned (#130486) feat(ui): save appearance preferences per user profile (#130340) fix: Buzz bots recover relay stalls and reject revoked senders (#130467) fix(code-mode): serialize catalog handles nested in final values (#130276) fix(webchat): CLI skill and harness-injected turns render as operator-sent messages (#130427) fix(agents): read the published model catalog owner from session_status (#130277) fix(channels): preserve long presentation text (#130368) fix(agents): route CLI bootstrap truncation notice into the system prompt (#130325) refactor(plugins): unify setup registration and artifact selection (#130474) fix(memory): prevent forgotten session content from returning (#130451) refactor(outbound): consolidate transport completion (#130460) fix(workers): protect in-flight workspace manifests from concurrent retention (#130449) fix(portals): keep worker previews reachable and owned by the active environment (#130434) fix(config): keep core channels keys in the generated config schema (#120736) chore(deps): refresh dependencies after seven-day cooldown (#130296) fix(agents): remind exec models to quote shell metacharacters (#125485) fix(auth): honor shared-store ownership in temp-state exec and agent deletion (#130437) fix(openshell): preserve file writes during concurrent mirror commands (#130447) fix(workers): report full nodes as at capacity, not offline (#130445) ...
…environment (openclaw#130434) * fix(portals): preserve worker routes and portal lifetime ownership * fix(worker): keep diagnostics off the JSON result stream * test(portals): model worker stream closure across Node versions * test(agents): refresh compaction runtime mocks
Related: #130105
What Problem This Solves
Fixes an issue where users opening worker portals could get a permanent waiting page for IPv6-only apps or nodes behind a Gateway URL prefix. Interrupted HTTP streams could also remain open, and a revoked turn could remove a successor turn's portal while listener startup was still pending. Worker tool failures hid the actionable error behind a generic protocol rejection.
Live testing also exposed worker diagnostics contaminating the JSON result stream after an otherwise successful model turn. The original feature PR was already merged as c3ea977; this is its reviewed follow-up repair.
Why This Change Was Made
Portal publication and carrier cleanup now belong to the serialized portal service. It validates authority after listener startup and releases unused targets itself. The executor no longer rolls back a registered portal by its stable ID after another turn can reuse it. The internal
createdbookkeeping/result wrapper is removed; the public RPC result is unchanged.Auxiliary node streams retain the enrolled Gateway context path. Portal dialing uses the same localhost family selection as Gateway-local portals; desktop dialing remains IPv4. HTTP response lifetimes close their opposite side, and worker RPC errors use the existing bounded, redacted tool-result formatter before the final authority check. The worker process entry enables existing stderr routing/console capture, keeping the JSON parser strict and diagnostics intact.
Production: +158/-151 (net +7). Portal ownership simplification absorbs the race fix and removes rollback bookkeeping; remaining growth implements route preservation, dual-family dialing, response cleanup, error-result fencing, and the worker stdout boundary. Tests: +610/-339 (net +271); docs: +2. No new dependencies, config keys, schemas, persistent-store semantics, or compatibility layers. The review's stored-data detector flagged existing placement reads/test fixtures; this patch adds no store or migration.
User Impact
Worker portals support IPv4 and IPv6 loopback apps and Gateway reverse-proxy prefixes, report useful errors, and survive a revoked predecessor racing with a valid successor. Browser departures and interrupted app streams clean up promptly. The prefix fix also covers desktop streams. Worker diagnostics no longer turn a completed model run into a JSON protocol failure.
A separate existing limitation remains: worker turn cleanup cancels background development servers after the turn ends. Tracked with live reproduction in #130450. This patch does not delete cleanup or create unowned background processes.
Evidence
node scripts/check-changed.mjspassed for the portal repair. The additional worker fix passed core/core-test typechecks, targeted typed lint, formatting, and its worker/logging suites.git diff --checkpasses.OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 pnpm buildpassed, including runtime bundling, postbuild guards, and Control UI. This is the supported runtime-only build; full declaration-build validation is left to CI. The initial UI build needed this worktree's existing shared UI dependency link.Live trace
Used a disposable authenticated Gateway plus a separate enrolled node process on the same macOS host, routed through a reverse proxy mounted at
/proof. This was a real OpenClaw worker turn with a real OpenAI model; no mocked Gateway, worker carrier, or inference provider. The operator Gateway and state were untouched. Final worker bundle:74e251c82982411e1488916cdd94402b2e99148173b094043c662c6132c2fded.Worker portal is not owned by the active environment; the model recovered and opened the valid port.[::1]app in the assigned node workspace returned HTTP 200 through the portal. WebSocket echo returned the exact sent payload. The reverse proxy observed/proof/node-portal/attachrequests (and forwarded the stripped route).Referrer-Policy: no-referrerremained intact.portal.closeremoved the portal; its listener refused new connections and the portal list was empty.execplusprocess poll, confirmed the IPv6 app had started, and completed withagent.wait: status=okrather than a JSON parse failure.For sustained traffic checks, the test runner launched the same fixture in the assigned node workspace because the existing turn cleanup stops model-owned background apps (#130450). This is live same-host node transport proof, not a remote-cloud allocation or browser click-through. Chrome automation stalled on a dialog; no rendered UI/screenshot proof is claimed. No UI source changed.
Review follow-through
The requested mounted-path/IPv6 live evidence is above. Node 22's documented
socket.connectcontract explicitly supportsautoSelectFamily, trying both address families and emitting an aggregate error when all attempts fail. Node 22.23.2 compatibility checks passed for the node transport and worker stdout suites (28 tests) and the HTTP proxy suite (21 tests). The first proxy run exposed a test fixture relying on Node 26 duplex-pair destroy propagation: the corrected fixture now delivers the same peer EOF as a real WebSocket and releases its app socket. With that corrected fixture, restoring the old production proxy still reproduces all four disconnect failures; no assertions or timeouts were relaxed. Final-commit CI remains the landing gate.Regression provenance: worker IPv6 and startup ownership paths came from #130105 (2026-08-26); the shared desktop prefix bug predates it in #122724 (0c824f0, 2026-08-12). HTTP disconnect cleanup dates to the original portals implementation, #122536 (2026-08-13). The generic worker RPC catch was carried forward by #122138 (2d6a5d7, 2026-08-11), but #130105 newly exposed portal errors through it. The worker-only entry skipping logging setup dates to #124037 (78502ed, merged 2026-08-16 UTC). All five predecessor PRs and their blamed code were authored by @steipete, and GitHub records @steipete as each merger. This follow-up is also authored by @steipete. Codex remote-exec remains outside the worker tool loop (direct upstream inspection:
codex-rs/exec-server/src/environment.rs:720-925).CI follow-through
CI run 33019643520 timed out in the first xAI compaction hook test, outside the portal changes. Investigation found two existing harness mocks targeting retired module names; they now target the current
agent-bundle-*owners, matching sibling harnesses and restoring the intended tool-runtime isolation. The mock implementations, test assertions, and timeouts are unchanged. All 152 compaction hook tests pass locally on Node 24.19.0 and Node 26.7.0; the exact cause of the hosted timeout remains unproven, so the mock correction is not claimed as a measured timing fix. Typed lint, formatting, and independent Codex autoreview passed. This is a bounded test-only cleanup; compaction production code is unchanged. Blame reaches the shallow-history boundary e357203 (2026-07-12, Vincent Koc), so the original rename provenance is not established.Final head
4e27784a8b3ec235e935510c972b3ec96e613d12passed CI run 33021008211, including the previously failing compaction shard andopenclaw/ci-gate. The hydrated current-main comparison at34ccf63e1379found all seven changed runtime owners and the compaction harness unchanged from the PR base. No rebase was needed for that drift.The lifecycle choice for this repair is environment ownership after successful portal publication. Existing environment tunnel teardown already closes portals by environment/owner epoch (
src/gateway/worker-environments/service.ts:140,:608); a revoked originating turn must not delete a portal reused by its successor. Pre-publication revocation still prevents publication, and post-operation revocation still denies the stale result. This retains the service-owned cleanup simplification requested in the latest review. The Node dependency contract and supported-version proof are recorded above; no store/schema migration is involved.The latest automated live-check wrapper reported a terminal-wait/output-matching failure, while its attached test output reports 30 passing tests and a completed runner in 24.61 seconds. No test-case failure appears in that output. Our completed focused runs and final hosted CI independently cover those paths. Named tooling follow-up: audit ClawSweeper terminal completion and output matching so a completed passing test report is not presented as a product-test failure.