Repository navigation
fix(worktrees): follow the current process environment - #199572
Merged
Merged
Conversation
Resolve the default environment when the singleton and its helpers use it so stock Bun worker environment promotion does not split registry paths. Explicit environment overrides and Node behavior remain unchanged.
Contributor
|
🦞👀 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. |
steipete
marked this pull request as ready for review
November 15, 2026 11:11
Contributor
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 16, 2026
Resolve the default environment when the singleton and its helpers use it so stock Bun worker environment promotion does not split registry paths. Explicit environment overrides and Node behavior remain unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Fixes managed-worktree lookups, archive restoration, and cleanup losing their registry records after stock Bun replaces
process.envwhile starting aSHARE_ENVworker.User Impact
Managed worktree creation, session reset/move, archive restoration, and shutdown use the current state directory consistently. Node behavior is unchanged because its environment object remains stable, and explicitly supplied environment objects remain fixed.
Why This Change Was Made
This is a stock-Bun
process.envidentity fix; upstream oven-sh/bun#44371.The service stores only an explicit environment override and resolves the default environment at each use. The capacity and Git-maintenance helpers do the same. Maintenance failure and cadence maps remain single instances keyed by repository path; registry/lifecycle state uses database coordination keys. No environment-identity cache is duplicated, and no runtime branch, feature probe, or lifecycle wait is added.
The worktree directory and registry-owner audit found no other module-level default-environment captures. Other defaults are resolved within individual calls. Existing tests cover the regression, so no test or fixture changes are needed.
Evidence
Local evidence is from macOS arm64. 27 reproduced cases fail on stock before this change and pass on stock, the pinned fork, and Node afterward. Reverting only this patch reproduces the same stock failures, then the patch is restored.
src/gateway/server.sessions.archive-worktree-lifecycle.test.tssrc/gateway/server.sessions.archive-failed-worker.test.tssrc/auto-reply/reply/session.worktree-reset.test.tssrc/agents/subagents/spawn/subagent-spawn.production-boundary.test.tssrc/commands/agent.test.tssrc/gateway/server-close.worktree-run-end.test.tssrc/gateway/server.placement-abandonment.test.tsThe archive lifecycle file runs with
--maxWorkers=1under the shared build lock; wall times above exclude lock queue time. Its complete 21-test file passes after the change. Stock before/after checks use complete files except for the two spawn cases. Node/fork confirmation targets assigned cases except the complete reset and archive files. These command timings include setup/build work and are not a performance comparison.The final service, capacity, and Git-maintenance owner runs pass on all three runtimes. One earlier Node capacity run passed 23/24:
serializes distinct repositories competing for disk headroomobserved zero successful creations instead of one. The complete unmodified baseline and a complete fixed confirmation both pass 24/24. No code or fixture change was made for this failure; its intermittent cause remains unproven and is retained as an investigated local failure rather than claimed fixed. Core typecheck, targeted lint, formatting, and independent P0–P2 review pass. The builtin-mock consumer gate does not apply because no import forms change. Construction/teardown scheduling is unchanged; the shutdown boundary passes directly on all three runtimes.A synthetic benchmark of the actual service property (2,000,000 reads per round; median of five measured rounds after warm-up) measured approximately 10 ns of additional work per default environment read and less than 1 ns for explicit environments.
Linux-only-unverified (passes on macOS stock before the fix and remains in the test file):
src/agents/subagents/spawn/subagent-spawn.production-boundary.test.ts :: recursive spawn production boundary > managed worktrees > runs a hidden managed worktree with cleanup=keepInitial missing workspace-dependency and stale runtime-path attempts stopped before assertions and are excluded from the evidence. An unfiltered spawn run was stopped after 409.58 seconds without a completed report; the two assigned cases were then proved with a test-name filter. The one extra archive failure outside the assigned set also disappears in the complete after run.