Skip to content

Enable experimental sparse VHD creation - #41726

Merged
Ben Hillis (benhillis) merged 4 commits into
masterfrom
sparse-vhd-wsl
Sep 30, 2026
Merged

Ben Hillis (benhillis) merged 4 commits into
masterfrom
sparse-vhd-wsl

Conversation

@benhillis

Copy link
Copy Markdown
Member

Summary

  • honor experimental.sparseVhd when creating new distribution VHDs
  • show an experimental warning whenever sparse mode is enabled
  • allow wsl --manage --set-sparse true without requiring --allow-unsafe, while continuing to accept the legacy flag
  • update sparse VHD coverage for creation, enabling, disabling, and legacy flag compatibility

Validation

  • cmake --build . -- -m
  • bin\x64\Debug\test.bat /name:*CheckSparse*

Ben Hillis and others added 3 commits September 28, 2026 15:59
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@benhillis
Ben Hillis (benhillis) requested a review from a team as a code owner September 29, 2026 17:34
Copilot AI balanced review requested due to automatic review settings September 29, 2026 17:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Sparse configuration conflicts with fixed-VHD creation and can cause fixed installations to fail.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Enables experimental sparse VHD creation and removes the unsafe-flag requirement.

Changes:

  • Honors experimental.sparseVhd during VHD creation.
  • Emits a localized experimental warning.
  • Updates sparse-mode and legacy-flag tests.
File Description
test/​windows/​SimpleTests.cpp Updates sparse VHD coverage.
src/​windows/​service/​exe/​LxssUserSession.cpp Allows sparse mode without --allow-unsafe.
src/​windows/​common/​WslCoreFilesystem.cpp Enables sparse VHD creation and warning.
localization/​strings/​en-US/​Resources.resw Replaces the disabled warning with an experimental warning.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/windows/common/WslCoreFilesystem.cpp
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 19:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation matches the stated behavior and includes focused coverage for the relevant creation and management paths.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@benhillis
Ben Hillis (benhillis) merged commit 3e0fd40 into master Sep 30, 2026
12 checks passed
@benhillis
Ben Hillis (benhillis) deleted the sparse-vhd-wsl branch September 30, 2026 16:01
seathatflowsinourveins (seathatflowsinourveins) added a commit to seathatflowsinourveins/native-agent-stack that referenced this pull request Oct 6, 2026
…n tools; reclaim WSL VHDX with wsl --manage --compact (#753)

### Scope

One anti-pattern log row in `docs/harness-defaults.md`, following the user's 2026-10-05 request to resolve the core reasons for NativeStack's disk growth. Lane: foundation.

The row's facts:
- NativeStack's root fell to 191 GB free, and its VHDX on Z: grew to 1,065 GB for 765 GB used.
- The bulk was finished work: 403 worktrees, 124 GB of `/var/tmp` build scratch from a session that had ended, 56.5 GB of 1,802 byte-identical fixture-binary copies, 27.8 GB of per-session index databases, about 75 GB of superseded gateway builds, and 30 GB of unused images.
- The cleanup reached 529 GB free, with every uncommitted change and the one local-only gateway patch preserved first.

The rule closes each job with each tool's own command. It reclaims VHDX space with WSL 3.0.1's native `wsl --manage  --compact`, and leaves sparse VHD off while WSL refuses it without `--allow-unsafe`.

### SOTA sources

- [git-worktree](https://git-scm.com/docs/git-worktree): `remove` refuses unclean worktrees without `--force`.
- [uv `cache prune`](https://docs.astral.sh/uv/reference/cli/#uv-cache-prune) and [docker `image prune`](https://docs.docker.com/reference/cli/docker/image/prune/).
- microsoft/WSL:
  - [PR #40481](microsoft/WSL#40481): `--compact` force-terminates the target distro and runs an offline `e2fsck -E discard` before `CompactVirtualDisk`;
  - tag 3.0.1, `src/windows/service/exe/LxssUserSession.cpp:1761-1921`, where `--set-sparse true` is refused without `--allow-unsafe`;
  - [PR #41726](microsoft/WSL#41726): lifts that refusal in tag 3.0.2 and marks sparse experimental.

### Evidence-class table

| Claim | Evidence class | Source |
| --- | --- | --- |
| Sizes and counts | host measurement on NativeStack (`du`, `df`, `git worktree list`) | the coordinator's private actions log |
| WSL compact and sparse behaviour | upstream source review at tag 3.0.1, plus PRs | the links above |
| git, uv and docker commands | upstream docs | the links above |

### Local commands run

- `uv run --no-project --with pyyaml python -m unittest` over the 416 tests that reference `harness-defaults.md`: OK (2 skipped).
- `python3 scripts/validate.py`: exit 0, after the registry-last commit.
- `python3 scripts/validate_convergence.py --all-recorded`: exit 0.
- The login-name scan is clean.

### Decision record

None new; the anti-pattern log row is the record.

### Host evidence

Sanitized counts only. No host paths or user names.

### Checklist

- [x] No GitHub Actions or workflows changed.
- [x] No secrets printed, logged or committed.
- [x] No paid hosting or billing surface.
- [x] Peer-owned untracked files and worktrees preserved. Each peer pruned its own data; the coordinator removed only data from ended sessions and its own lane, by literal target.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants