Skip to content

fix: node workspace transfers fail after successful turns - #123564

Merged
steipete merged 3 commits into
mainfrom
steipete/transfer-client-tls-streams
Aug 14, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/transfer-client-tls-streams

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where node-hosted turns could be reported as failed after their tools and transcript had already completed when HTTPS workspace reconciliation reused a validated TLS socket whose peer-certificate accessor no longer returned a fingerprint. Retrying that false failure could repeat already-applied side effects.

The same stress campaign found cumulative stream listeners during large transfers and no operator-visible explanation when the published-origin fast path fell back to the much slower Gateway push.

Evidence source: the 2026-08-14 node-host STRESS TEST at exact revision 252bb545b47ab3c3d5bbf09a20f52728f174b3cd, captured in /tmp/openclaw-node-host-stress-evidence-20260814/REPORT.md. It reproduced the TLS failure three times, observed 33 MaxListenersExceededWarning diagnostics per node, and measured silent Gateway-push fallbacks at 133–157 seconds.

Why This Change Was Made

TLS pins are now validated once per underlying socket: a pooled socket reuses its recorded normalized fingerprint, while every new socket must still present a nonempty matching fingerprint. A typed private WORKSPACE_TRANSFER_FAILED error preserves the safe concrete mismatch through node invoke, the Gateway tunnel, and the launcher.

Backpressure waits now use Node's paired event primitive, which removes the losing error or drain listener. The same cleanup covers response and final-write waits. Origin selection now returns a closed fallback reason; the Gateway records the chosen origin or gateway-push path at info level, while the node records total, pack-download, and blob-apply timings at debug level. No config key, SQLite surface, public protocol version, or metrics framework was added.

AI-assisted: yes. The implementation and tests were reviewed with the repository autoreview workflow, and I verified the owner boundaries and Node runtime contracts directly.

User Impact

Operators can trust that a successfully completed node-hosted turn will not be turned into a false TLS-pin failure merely because its HTTP request reused an already-validated socket. Large workspace transfers no longer accumulate backpressure listeners, and logs now explain why an origin clone was skipped and where transfer time was spent.

Evidence

  • Focused proof passed three consecutive times on the final tree: 32 assertions per pass across the real pooled HTTPS transfer, wrong-pin new-socket refusal, typed node RPC/tunnel/launcher cause propagation, large download/upload backpressure, and sync-path telemetry.
  • Large-blob regression performs a real 2 MiB download and reconciliation upload, proves more than ten drain cycles in both directions, and keeps error-listener counts bounded at zero after completion.
  • OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 ... node scripts/check-changed.mjs --timed passed every selected core/core-test formatting, typecheck, lint, dead-code, import-cycle, database-first, and guard lane.
  • Remote attempt run_b0b846f0286c (provider=daytona, lease cbx_17d638ef5eed) failed before checks because raw sync omitted Git metadata; the lease was released and the documented trusted-source local fallback passed.
  • pnpm build passed, including all nine unified build invocations, runtime postbuild checks, public Plugin SDK export verification, and Control UI build.
  • pnpm protocol:gen reproduced dist/protocol.schema.json with no generated diff.
  • All nine changed files pass oxfmt --check; git diff --check is clean.
  • Final branch autoreview: clean, no accepted/actionable findings; TruffleHog clean.

Production LOC: +210/-81 (net +129: typed cross-RPC diagnostic boundary plus sync-path/stage observability; the listener repair itself is net-negative) | Tests: +329/-9

@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Aug 14, 2026
@steipete steipete self-assigned this Aug 14, 2026
@steipete
steipete marked this pull request as ready for review August 14, 2026 08:40
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Aug 14, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 4:47 AM ET / 08:47 UTC.

ClawSweeper review

What this changes

This PR makes node workspace transfers cache an already-validated TLS socket pin, clean backpressure listeners, preserve transfer failures through the node/Gateway path, and log the selected sync path.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this active maintainer PR open for normal exact-head CI and merge review. Current main still directly re-reads the peer certificate on reused sockets; the branch’s exact-socket cache and boundary tests address that failure without a supported regression finding.

Priority: P1
Reviewed head: a507fe1481ee1dbf4d862639ae89ccd0b4fc5b26

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has focused boundary coverage for the real socket-reuse and stream-drain behavior, with no supported correctness or security finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR reports focused real pooled-HTTPS and large-transfer proof in its body; the external-contributor proof gate does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR reports focused real pooled-HTTPS and large-transfer proof in its body; the external-contributor proof gate does not apply.
Evidence reviewed 7 items Current-main defect location: Current main validates every HTTPS request by reading the socket peer certificate, including reused sockets; the PR replaces that with an exact-socket cache populated only after a normalized fingerprint match.
TLS boundary and fail-closed behavior: The PR keys cached pins by TLSSocket, compares a cached actual pin with the requested pin on reuse, and rejects uncached or mismatched sockets before sending the request body.
Regression coverage at the real transport seam: The pooled HTTPS test hides getPeerCertificate after the first socket is freed, then completes download and upload on that one connection; the fresh-socket test separately proves a wrong pin reaches no HTTP handler.
Findings None None.
Security None None.

How this fits together

A node-hosted worker transfers workspace state through the Gateway before and after a turn. The transfer client validates Gateway TLS and streams files, while the node supervisor and Gateway tunnel carry the result into final worker reconciliation.

flowchart LR
  A[Node-hosted worker] --> B[Workspace transfer client]
  B --> C[TLS socket validation]
  B --> D[Stream backpressure waits]
  C --> E[Node supervisor]
  D --> E
  E --> F[Gateway workspace tunnel]
  F --> G[Final worker reconciliation]
Loading

Before merge

  • Resolve merge risk (P1) - Production code grows by net 129 lines; the typed cross-RPC error boundary and closed synchronization outcome are justified by separate owner boundaries, but should remain confined to this transfer path.
  • Complete next step (P2) - No repair job is needed: this active maintainer PR has no actionable review finding and remains on the normal exact-head CI and merge path.
Agent review details

Security

None.

PR surface

Source +129, Tests +320. Total +449 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 210 81 +129
Tests 4 329 9 +320
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 539 90 +449

Review metrics

Metric Value Why it matters
Production versus test delta production +210/-81 (net +129); tests +329/-9 (net +320) The production growth introduces the typed cross-RPC diagnostic and structured sync outcome in addition to the listener repair, so its owner-boundary justification matters before merge.

Stored data model

Persistent data-model change detected: durable storage schema: src/gateway/worker-environments/node-worker-tunnel.test.ts, durable storage schema: src/gateway/worker-environments/node-worker-tunnel.ts, durable storage schema: src/gateway/worker-environments/node-worker-workspace-fallback.ts, durable storage schema: src/gateway/worker-environments/worker-turn-launcher-terminal-results.test.ts, durable storage schema: src/worker/node-workspace-transfer-protocol.ts, serialized state: src/node-host/invoke-worker-supervisor.test.ts, and 3 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep validation at the transfer client's TLS socket boundary, carry the closed transfer failure across the private RPC boundary, and retain the structured sync-path record; no net-neutral alternative preserves all three contracts.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep validation at the transfer client's TLS socket boundary, carry the closed transfer failure across the private RPC boundary, and retain the structured sync-path record; no net-neutral alternative preserves all three contracts.

Do we have a high-confidence way to reproduce the issue?

Yes—source reproducible. The new pooled-HTTPS regression hides the peer-certificate accessor after the first request frees its socket; current main would then reject the reused request, while the proposed cache preserves the prior verified pin.

Is this the best way to solve the issue?

Yes. Caching only a successfully normalized pin on the exact TLS socket fixes the Node certificate-lifetime behavior without weakening validation; re-reading an unavailable accessor fails, and bypassing the pin check would be unsafe.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0bd50cc0a5ba.

Labels

Label changes:

  • add P1: A false post-turn workspace-transfer failure can cause an operator to retry work whose tools or transcript already completed.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR reports focused real pooled-HTTPS and large-transfer proof in its body; the external-contributor proof gate does not apply.

Label justifications:

  • P1: A false post-turn workspace-transfer failure can cause an operator to retry work whose tools or transcript already completed.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR reports focused real pooled-HTTPS and large-transfer proof in its body; the external-contributor proof gate does not apply.

Evidence

What I checked:

  • Current-main defect location: Current main validates every HTTPS request by reading the socket peer certificate, including reused sockets; the PR replaces that with an exact-socket cache populated only after a normalized fingerprint match. (src/node-host/node-worker-transfer-client.ts:52, 0bd50cc0a5ba)
  • TLS boundary and fail-closed behavior: The PR keys cached pins by TLSSocket, compares a cached actual pin with the requested pin on reuse, and rejects uncached or mismatched sockets before sending the request body. (src/node-host/node-worker-transfer-client.ts:52, a507fe1481ee)
  • Regression coverage at the real transport seam: The pooled HTTPS test hides getPeerCertificate after the first socket is freed, then completes download and upload on that one connection; the fresh-socket test separately proves a wrong pin reaches no HTTP handler. (src/node-host/node-worker-transfer-client.test.ts:191, a507fe1481ee)
  • Node event contract: Node 24.19's built-in events.once implementation installs an error listener while waiting and removes it when the target event resolves, supporting the listener-cleanup replacement for drain and finish waits.
  • Owner-boundary propagation: The transfer owner invokes the client, the supervisor serializes only the typed transfer failure, and the Gateway tunnel reconstructs it before terminal reconciliation. (src/node-host/node-worker-workspace.ts:166, a507fe1481ee)
  • Feature provenance: The current transfer client and tunnel were introduced together in this recent mainline commit; blame ties the pre-fix peer-certificate branch to that implementation. (src/node-host/node-worker-transfer-client.ts:83, c636cf559ae1)

Likely related people:

  • steipete: Peter Steinberger introduced the current node transfer client and tunnel in the baseline commit and authored all three commits in this repair series. (role: feature owner and recent area contributor; confidence: high; commits: c636cf559ae1, 0e40ebcb60f6, 1de98b473e63; files: src/node-host/node-worker-transfer-client.ts, src/gateway/worker-environments/node-worker-tunnel.ts, src/gateway/worker-environments/node-worker-workspace-fallback.ts)
  • Josh Avant: Josh Avant recently changed the worker terminal/reconciliation area that consumes tunnel results, making this a useful secondary routing contact. (role: recent adjacent contributor; confidence: medium; commits: 73a9eed95ba2; files: src/gateway/worker-environments/worker-turn-launcher.ts)

Rank-up moves

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

  • Let the in-progress required checks complete against the current head before merging.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head a507fe1481ee1dbf4d862639ae89ccd0b4fc5b26:

  • Required exact-head CI is green: https://github.com/openclaw/openclaw/actions/runs/31784883914
  • Focused transfer proof passed three consecutive times (32 assertions per pass), including a real pooled HTTPS socket with hidden post-first-request certificate data, fresh-socket wrong-pin refusal before the HTTP handler, typed cause propagation to the launcher, and a 2 MiB download/upload roundtrip with more than ten drain cycles in each direction.
  • The complete changed gate passed through the documented trusted-source local fallback. Remote run run_b0b846f0286c failed before checks because its raw-sync workspace omitted Git metadata; lease cbx_17d638ef5eed was released.
  • pnpm build, protocol generation/no-diff verification, changed-file formatting, and git diff --check passed.
  • Final branch autoreview and TruffleHog are clean.

ClawSweeper disposition: the only Rank-up moves: item was completion of required checks, now satisfied. The net +129 production lines are an explicit owner decision: they establish two missing owner contracts—the typed private transfer-failure boundary and the recorded sync-path/stage telemetry—while the listener repair itself is net-negative. No config, SQLite, public protocol-version, or compatibility surface is added; there is no net-neutral shape that preserves all three requested fixes.

@steipete
steipete merged commit 8a3964f into main Aug 14, 2026
225 checks passed
@steipete
steipete deleted the steipete/transfer-client-tls-streams branch August 14, 2026 08:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
…23564)

* fix(node-host): preserve TLS transfer failures

* fix(node-host): clean transfer backpressure listeners

* fix(gateway): explain node workspace sync paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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