You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(source-control): npm ci in every worktree uses 154 GB of disk #17084
source-controlscripts/worktree-create.sh runs npm ci in every new worktree that has a package-lock.json (lines 1382+ in 11.20.1). On one WSL lane on 2026-11-18, a du -x survey found:
330 worktree node_modules directories of at least 100 MB under ~/worktrees, median 521 MB, 154 GB in total: 47% of the 331 GB ~/worktrees tree and 29% of the whole / filesystem (539 GB used).
23.6 M of the filesystem's 28 M inodes are under ~/worktrees.
Free space on / fell from ~785 GB (2026-11-09) to ~475 GB (2026-11-17) even though worktree-reap removed 19-39 GB per day.
du counts a hard-linked inode once, so these are real copies. The helper runs npm ci because the tree has a package-lock.json (the repo also carries pnpm-lock.yaml and yarn.lock).
Proposed fix
Pick one, cheapest first:
Install lazily: skip npm ci at create time and let the first command that needs node_modules install it. Most agent worktrees edit markdown and never run JS.
Share one store: switch the repo to pnpm (content-addressed store, hard links), or point npm's cache plus --prefer-offline at a shared cache and hard-link from a template tree.
At minimum, have worktree-reap drop node_modules from worktrees idle past N hours even when it keeps the worktree.
Basis: du -x -k --threshold=100M / run 2026-11-18 06:25Z-07:12Z; worktree-create.sh 11.20.1 lines 8, 281-284, 1382.
Size: Medium
Complexity: Medium
Uncertainty: Knowable
Flags: intent
Blocked by: none
Blast radius: source-control's worktree-create.sh and worktree-reap, plus every agent or person who creates worktrees and expects node_modules to be present.
Reversible: yes; each option is a script change that can be reverted. Disk already used stays until the worktrees are reaped.
Open questions:
Which of the three listed fixes is the intended design: lazy install, a shared store or a package-manager switch, or reaping node_modules from idle worktrees? The issue says "pick one, cheapest first" but doesn't choose.
RECOMMENDED: option 1, install lazily, with option 3 as a follow-up safety net. Basis: the issue says most agent worktrees only edit markdown, and this option needs no change of package manager.
If installs become lazy, what triggers the first install? Examples are a wrapper command, a hook, or an explicit worktree-create --install flag.
RECOMMENDED: an explicit opt-in flag on worktree-create, plus a documented one-line install command. Basis: judgment; the issue doesn't say how a worktree that needs JS should get its dependencies.
I understood this as a disk-use defect: npm ci in every new worktree caused 154 GB of node_modules on one lane. Related work: #16683 covers provisioning prerequisites in worktrees automatically. It pulls the opposite way from lazy install, so the two should be reconciled, but I don't count it as a duplicate. No merged pull request appears to fix this.
To answer, post a comment that starts with this line:
Refinement. A read-only run explored this repository, searched its issues and pull requests, and read the allowed docs to draft what follows. On an issue a listed human filed, it counts as the issue's spec once posted, while unedited; it is still model text, so check it.
Intended outcome: worktree-create.sh stops running npm ci by default, and a documented opt-in or on-demand step installs node_modules when a worktree needs it; the owner has not chosen this yet.
Which of the three fixes is the intended design: lazy install, a shared store or package-manager switch, or reaping node_modules from idle worktrees?
RECOMMENDED: Option 1: skip npm ci by default in worktree-create.sh, with option 3 as a later safety net. Basis: plugins/source-control/scripts/worktree-create.sh:1382 runs npm ci unconditionally; the issue says pick one, cheapest first, and does not choose.
Option 3 needs worktree-reap, which is not in this repository. Is it in scope here, or does it need its own issue in the repo that holds it?
RECOMMENDED: Treat option 3 as out of scope here and file it against the dotfiles repo that holds worktree-reap.timer. Basis: scripts/lane-transcripts/README.md:174 says worktree-reap.timer is kept in dotfiles; no worktree-reap script exists in the checkout.
If install becomes lazy, what triggers the first install, and what happens to a first commit whose pre-commit hook needs node_modules/.bin?
RECOMMENDED: Add an opt-in flag or env var on worktree-create.sh that keeps today's capped npm ci, and make the warning print the one-line install command; check the hooks fail with a clear message when node_modules is absent. Basis: plugins/source-control/scripts/worktree-create.sh:1367-1369 says the install exists so the first commit does not fail on markdownlint-cli2.
How should lazy install reconcile with #16683, which provisions worktree prerequisites automatically?
RECOMMENDED: Keep npm ci out of default provisioning and let #16683 call the opt-in install only where a JS toolchain is needed. Basis: judgment
Sources read
plugins/source-control/scripts/worktree-create.sh:8: header says the helper runs npm ci when the new tree has a package-lock.json
plugins/source-control/scripts/worktree-create.sh:281: documents the npm ci step, capped by WORKTREE_CREATE_DEPS_CAP_SECONDS (default 45), warn-only on failure
plugins/source-control/scripts/worktree-create.sh:1367: comment says the install exists so pre-commit hooks using node_modules/.bin do not fail the first commit
plugins/source-control/scripts/worktree-create.sh:1382: npm ci runs whenever package-lock.json exists, via run_capped
scripts/lane-transcripts/README.md:174: only mention of worktree-reap, as a timer kept in dotfiles
To answer, post a comment that starts with this line:
**Decision recorded.** <answer>
Automated refinement by the lanes App. Answer with a comment whose first line is **Decision recorded.**.
Activity
github-actions commentedon Nov 18, 2026
Size: Medium
Complexity: Medium
Uncertainty: Knowable
Flags: intent
Blocked by: none
Blast radius:
source-control'sworktree-create.shandworktree-reap, plus every agent or person who creates worktrees and expectsnode_modulesto be present.Reversible: yes; each option is a script change that can be reverted. Disk already used stays until the worktrees are reaped.
Open questions:
node_modulesfrom idle worktrees? The issue says "pick one, cheapest first" but doesn't choose.RECOMMENDED: option 1, install lazily, with option 3 as a follow-up safety net. Basis: the issue says most agent worktrees only edit markdown, and this option needs no change of package manager.
worktree-create --installflag.RECOMMENDED: an explicit opt-in flag on
worktree-create, plus a documented one-line install command. Basis: judgment; the issue doesn't say how a worktree that needs JS should get its dependencies.I understood this as a disk-use defect:
npm ciin every new worktree caused 154 GB ofnode_moduleson one lane. Related work: #16683 covers provisioning prerequisites in worktrees automatically. It pulls the opposite way from lazy install, so the two should be reconciled, but I don't count it as a duplicate. No merged pull request appears to fix this.To answer, post a comment that starts with this line:
Automated triage. A maintainer reviews it.
melodic-automation-lanes commentedon Nov 18, 2026
The triage verdict left this issue at
needs-owner-decision:Reason:
intentmelodic-automation-lanes commentedon Nov 18, 2026
Refinement. A read-only run explored this repository, searched its issues and pull requests, and read the allowed docs to draft what follows. On an issue a listed human filed, it counts as the issue's spec once posted, while unedited; it is still model text, so check it.
Intended outcome: worktree-create.sh stops running npm ci by default, and a documented opt-in or on-demand step installs node_modules when a worktree needs it; the owner has not chosen this yet.
Related work
Open questions
RECOMMENDED: Option 1: skip npm ci by default in worktree-create.sh, with option 3 as a later safety net. Basis: plugins/source-control/scripts/worktree-create.sh:1382 runs npm ci unconditionally; the issue says pick one, cheapest first, and does not choose.
RECOMMENDED: Treat option 3 as out of scope here and file it against the dotfiles repo that holds worktree-reap.timer. Basis: scripts/lane-transcripts/README.md:174 says worktree-reap.timer is kept in dotfiles; no worktree-reap script exists in the checkout.
RECOMMENDED: Add an opt-in flag or env var on worktree-create.sh that keeps today's capped npm ci, and make the warning print the one-line install command; check the hooks fail with a clear message when node_modules is absent. Basis: plugins/source-control/scripts/worktree-create.sh:1367-1369 says the install exists so the first commit does not fail on markdownlint-cli2.
RECOMMENDED: Keep npm ci out of default provisioning and let #16683 call the opt-in install only where a JS toolchain is needed. Basis: judgment
Sources read
To answer, post a comment that starts with this line:
Automated refinement by the lanes App. Answer with a comment whose first line is
**Decision recorded.**.