Skip to content

improve: retain current worker builds between sessions - #140449

Merged
steipete merged 2 commits into
mainfrom
codex/node-worker-reconnect-preparation
Sep 7, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/node-worker-reconnect-preparation

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Related: #140425

What Problem This Solves

Fixes an issue where closing the last session on a persistent node can discard the current worker build, forcing the next session to download it again. Slow maintenance on one node can also delay another node.

Why This Change Was Made

Keep one installed current worker artifact per Gateway namespace alongside existing live/recovery references, using the existing bounded retention protocol. Coalesce maintenance independently per node. Read current enrollment ownership from the canonical store instead of caching it by inventory version, which pairing does not update.

This revision removes the earlier automatic remote installation and shared preparation lifetime. Installation remains owned by an explicit session request and its cancellation signal; maintenance only retains installed software. Existing native integrity validation and cloud execution-mode ownership remain unchanged.

User Impact

Later sessions reuse the current installed build after earlier sessions close. Unreferenced older builds remain eligible for normal cleanup. First use after a Gateway build change still installs the new artifact: this is a partial improvement toward #140425, not prewarming or a ten-second cold-start guarantee.

No schema, index, configuration, dependency, permission, or protocol changes. Node documentation describes the retention and installation boundaries. Release-note context is recorded here; CHANGELOG.md is release-owned.

Evidence

  • 137 focused tests across ten files pass, covering acknowledged retention after all sessions disappear, fresh enrollment reads, independent node progress, explicit installation cancellation, provider modes, and startup/shutdown.
  • The original current-build retention regression fails against the previous coordinator. The revised maintenance tests also verify that maintenance sends retention commands only.
  • Full canonical changed gate passed for all twelve paths: production/test typechecks, formatting, lint, dead-export scans, and architecture guards. A fresh full pnpm build also passed on the exact PR head with Node 24.20.0 and pnpm 12.3.4; that build is running in the dev Gateway.
  • Independent review of the complete replacement is clean through P2. Exact-head CI passed 108 jobs with 16 scope skips on 9f05f2ba0dcadf7276a588653d3ce96f0fe6ac5a.
  • Live test on a retained Intel Mac: first dispatch activated in 31.97 seconds; a second session after cleanup activated in 7.79 seconds. Both real agent tool calls returned Darwin successfully. After the first close, live/recovery and nonterminal-environment pins were zero; normal cleanup removed its workspace while the bundle receipt, bytes, inodes, and modification times stayed identical through the second activation. Both synthetic sessions were archived. This is two-sample warm reuse evidence, not a cold-cloud SLO or a measured network-download count.

The earlier background-installation finding was addressed by removing that design. Earlier CI and investigation results are historical evidence, not validation of the removed cancellation contract. There are no UI appearance changes.

@steipete steipete self-assigned this Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime plugin: file-transfer size: L maintainer Maintainer-authored PR labels Sep 6, 2026
@steipete
steipete marked this pull request as ready for review September 6, 2026 21:09
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 10:16 PM ET / September 7, 2026, 02:16 UTC.

ClawSweeper review

What this changes

Persistent nodes retain the current worker build between sessions, while maintenance runs independently per node and installation remains attached to explicit session requests.

Merge readiness

✅ Ready for maintainer review

This remains useful work: current main lacks the between-session retention pin. The revised scope resolves the earlier background-installation finding by removing that design, and no blocking defect was identified in the remaining patch.

Priority: P2
Reviewed head: 9f05f2ba0dcadf7276a588653d3ce96f0fe6ac5a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused retention improvement with relevant regression coverage and no identified blocking defect; live reuse evidence is not claimed.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts ordinary contributor proof. Current evidence reports focused tests and a build, with live reuse proof still planned; the removed background installer no longer requires the previous takeover-before-publication demonstration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts ordinary contributor proof. Current evidence reports focused tests and a build, with live reuse proof still planned; the removed background installer no longer requires the previous takeover-before-publication demonstration.
Evidence reviewed 8 items Current main still needs the improvement: The fetched main coordinator derives retained hashes exclusively from environments and placements; it has no independent current-build pin. This supports retaining the PR as useful work.
Retention preserves existing references and bounds: The coordinator adds the current hash to existing live/recovery hashes, rechecks enrollment after resolving the build, preserves request-size and capability negotiation, and coalesces maintenance separately for each node.
Prior finding addressed by scope removal: The captured body explicitly withdraws automatic installation and shared preparation. The verified merge-base-to-head startup diff wires only build metadata into retention and retains the request-owned installer. The previous native-publication/prewarm finding and its associated rank-up requests therefore do not apply to this design. Direct comparison with the earlier head was unavailable because a historical blob could not be fetched.
Findings None None.
Security None None.

How this fits together

The Gateway sends worker software to paired nodes that host sessions. Its retention coordinator combines current-build and session references so node maintenance can preserve needed artifacts and remove unused older builds.

flowchart TD
  A[Gateway worker build] --> C[Retention coordinator]
  B[Live and recoverable sessions] --> C
  D[Current cloud enrollment] --> C
  C --> E[Per-node retention request]
  E --> F[Preserve needed builds]
  E --> G[Remove unused older builds]
  F --> H[Reuse on next session]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +67, Tests +182, Docs +7. Total +256 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 7 166 99 +67
Tests 4 192 10 +182
Docs 1 17 10 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 375 119 +256

Review metrics

Metric Value Why it matters
Retention policy 1 current build per Gateway namespace, plus existing live/recovery pins This bounds the additional retained software without retaining every historical build.
Production versus test growth Production +67 net lines; tests +182 net lines Production growth implements the current-build pin and independent maintenance; added coverage targets retention and lifecycle regressions.

Technical review

Best possible solution:

Keep retention on the existing bounded maintenance protocol, preserve request-owned installation, and leave preparation-before-first-use to the broader linked issue.

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

Yes, from source: after session references disappear and installation generations are acknowledged, main's retained-hash set can omit the current build and native cleanup can collect it. No runtime reproduction was executed during this review.

Is this the best way to solve the issue?

Yes. Extending the existing retention snapshot is a narrow solution that preserves integrity validation and avoids introducing a separate background installation owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c371a00aadcf.

Labels

Label changes:

  • 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: The supplied MEMBER association exempts ordinary contributor proof. Current evidence reports focused tests and a build, with live reuse proof still planned; the removed background installer no longer requires the previous takeover-before-publication demonstration.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Avoids repeated worker downloads between sessions with a bounded change to persistent-node maintenance.
  • 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: The supplied MEMBER association exempts ordinary contributor proof. Current evidence reports focused tests and a build, with live reuse proof still planned; the removed background installer no longer requires the previous takeover-before-publication demonstration.

Evidence

What I checked:

  • Current main still needs the improvement: The fetched main coordinator derives retained hashes exclusively from environments and placements; it has no independent current-build pin. This supports retaining the PR as useful work. (src/gateway/worker-environments/node-workspace-retain-coordinator.ts:155, c371a00aadcf)
  • Retention preserves existing references and bounds: The coordinator adds the current hash to existing live/recovery hashes, rechecks enrollment after resolving the build, preserves request-size and capability negotiation, and coalesces maintenance separately for each node. (src/gateway/worker-environments/node-workspace-retain-coordinator.ts:164, 9f05f2ba0dca)
  • Prior finding addressed by scope removal: The captured body explicitly withdraws automatic installation and shared preparation. The verified merge-base-to-head startup diff wires only build metadata into retention and retains the request-owned installer. The previous native-publication/prewarm finding and its associated rank-up requests therefore do not apply to this design. Direct comparison with the earlier head was unavailable because a historical blob could not be fetched. (src/gateway/server-worker-environment-startup.ts:296, 9f05f2ba0dca)
  • Existing native maintenance boundary: The native retention command applies the workspace snapshot, invokes bounded bundle retention, and optionally inspects the requested hash. It does not install or prewarm software. Installation remains called from explicit provisioning with its cancellation signal. (src/node-host/node-worker-supervisor-commands.ts:197, 9f05f2ba0dca)
  • Focused regression coverage: Inspected tests cover retention across acknowledged passes after all sessions disappear, cloud-node exclusion, independent node progress, and enrollment changes during build resolution. Installer tests check request cancellation; store tests exercise fresh ownership reads without an inventory-version change. These were inspected, not executed. (src/gateway/worker-environments/node-workspace-retain-coordinator.test.ts:693, 9f05f2ba0dca)
  • Related issue remains broader: The supplied discussion for Slow first session start on persistent nodes after Gateway updates #140425 requests preparation before first use and shared preparation lifetime as well as retention. The current PR body explicitly presents retention as a partial improvement and leaves those broader latency goals unresolved.

Likely related people:

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

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 (2 earlier review cycles)
  • reviewed 2026-09-06T21:17:29.255Z sha ece788d :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-06T21:58:16.192Z sha ece788d :: needs real behavior proof before merge. :: [P1] Fence enrollment takeover before native publication and prewarm

@steipete
steipete marked this pull request as draft September 6, 2026 21:52
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 6, 2026
@steipete steipete changed the title improve: prepare connected session hosts before first use improve: retain current worker builds between sessions Sep 7, 2026
@steipete
steipete marked this pull request as ready for review September 7, 2026 02:09
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 7, 2026
@steipete
steipete merged commit 4cf8d68 into main Sep 7, 2026
259 of 260 checks passed
@steipete
steipete deleted the codex/node-worker-reconnect-preparation branch September 7, 2026 02:52
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
* perf(gateway): prepare node worker builds on reconnect

* refactor: keep node maintenance limited to installed build retention
necromman pushed a commit to necromman/openclaw that referenced this pull request Sep 20, 2026
* perf(gateway): prepare node worker builds on reconnect

* refactor: keep node maintenance limited to installed build retention

(cherry picked from commit 4cf8d68)
steipete added a commit that referenced this pull request Oct 24, 2026
…es (#182115)

After a Gateway update, the first session on each persistent node paid the full worker-bundle download (about 24 s measured in #140449). Nodes that negotiate the new capability now receive a low-priority, archive-only prefetch: the node downloads and verifies the pinned bundle archive but never extracts, repairs, publishes or activates it; a session's own install preempts any in-flight prefetch and reuses the verified archive. Prefetch failures are warnings only, old nodes keep the session-owned install, and existing retention handles the archive.

Fixes #140425
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 24, 2026
…es (openclaw#182115)

After a Gateway update, the first session on each persistent node paid the full worker-bundle download (about 24 s measured in openclaw#140449). Nodes that negotiate the new capability now receive a low-priority, archive-only prefetch: the node downloads and verifies the pinned bundle archive but never extracts, repairs, publishes or activates it; a session's own install preempts any in-flight prefetch and reuses the verified archive. Prefetch failures are warnings only, old nodes keep the session-owned install, and existing retention handles the archive.

Fixes openclaw#140425
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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