From 633cbdefc71116b3e80002b2a5b2bcbfd6aaca94 Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 17:55:05 +0900 Subject: [PATCH 1/2] chore(claude): skip the target overlay when target/ is managed externally The WorktreeCreate hook mounted a fuse-overlayfs over target/ in every agent worktree. When the main checkout's target/ is a symlink owned by a build-cache manager such as mbx, the overlay diverted the worktree's builds into an unmanaged upper layer inside the worktree, outside that manager's garbage collection. Leave target/ alone in that case so Cargo creates the worktree's own managed link; the manager already shares compiled work across checkouts. --- .claude/scripts/worktree-create.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.claude/scripts/worktree-create.sh b/.claude/scripts/worktree-create.sh index 4c9c83fda2b..7d07cf2da61 100755 --- a/.claude/scripts/worktree-create.sh +++ b/.claude/scripts/worktree-create.sh @@ -39,8 +39,13 @@ if command -v fuse-overlayfs >/dev/null 2>&1; then "$dst" } - # Rust build cache - mount_overlay "target" + # Rust build cache. A symlinked target/ is owned by an external build-cache + # manager (such as mbx), which already shares compiled work across checkouts + # and garbage-collects it. An overlay would divert the worktree's builds into + # an unmanaged upper layer, so let Cargo create the worktree's own link. + if [ ! -L "$MAIN_DIR/target" ]; then + mount_overlay "target" + fi # node_modules directories (pnpm workspace) while IFS= read -r nm_dir; do From 7d670415df176607fb472b365c9e42eaee4c1eee Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 18:03:16 +0900 Subject: [PATCH 2/2] chore(claude): remove the overlayfs worktree hooks The WorktreeCreate/WorktreeRemove hooks mounted fuse-overlayfs layers over target/ and node_modules/ in every agent worktree. They are no longer useful: a build-cache manager such as mbx already shares compiled work across checkouts and garbage-collects it, while the target/ overlay diverted builds into an unmanaged upper layer outside that collection. pnpm installs node_modules from its content-addressed store cheaply. Remove the hooks, the project settings that only registered them, the fuse-overlayfs dev-shell package, and the overlay ignore entries, so agent worktrees use Claude Code's default creation and cleanup. --- .claude/scripts/worktree-create.sh | 59 ------------------------------ .claude/scripts/worktree-remove.sh | 27 -------------- .claude/settings.json | 24 ------------ .gitignore | 5 --- flake.nix | 1 - 5 files changed, 116 deletions(-) delete mode 100755 .claude/scripts/worktree-create.sh delete mode 100755 .claude/scripts/worktree-remove.sh delete mode 100644 .claude/settings.json diff --git a/.claude/scripts/worktree-create.sh b/.claude/scripts/worktree-create.sh deleted file mode 100755 index 7d07cf2da61..00000000000 --- a/.claude/scripts/worktree-create.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# WorktreeCreate hook for Claude Code -# Creates a git worktree and mounts overlayfs over target/ and node_modules/ -# so that heavy build caches and dependencies are shared copy-on-write. -# -# Input (JSON on stdin): { "name": "...", "cwd": "...", ... } -# Output (stdout): absolute path to the created worktree - -INPUT=$(cat) -NAME=$(echo "$INPUT" | jq -r '.name') -MAIN_DIR=$(echo "$INPUT" | jq -r '.cwd') - -WORKTREE_DIR="$MAIN_DIR/.claude/worktrees/$NAME" -OVERLAY_BASE="$WORKTREE_DIR/.overlays" - -# 1. Create the git worktree -git -C "$MAIN_DIR" worktree add -b "claude/$NAME" "$WORKTREE_DIR" HEAD --quiet - -# 2. Mount overlayfs layers if fuse-overlayfs is available -if command -v fuse-overlayfs >/dev/null 2>&1; then - # Mount an overlayfs for a directory (relative path from repo root) - mount_overlay() { - local rel_path="$1" - local src="$MAIN_DIR/$rel_path" - local dst="$WORKTREE_DIR/$rel_path" - - [ -d "$src" ] || return 0 - - local key - key=$(echo "$rel_path" | sed 's|/|__|g') - local upper="$OVERLAY_BASE/$key/upper" - local work="$OVERLAY_BASE/$key/work" - - mkdir -p "$dst" "$upper" "$work" - fuse-overlayfs \ - -o "lowerdir=$src,upperdir=$upper,workdir=$work" \ - "$dst" - } - - # Rust build cache. A symlinked target/ is owned by an external build-cache - # manager (such as mbx), which already shares compiled work across checkouts - # and garbage-collects it. An overlay would divert the worktree's builds into - # an unmanaged upper layer, so let Cargo create the worktree's own link. - if [ ! -L "$MAIN_DIR/target" ]; then - mount_overlay "target" - fi - - # node_modules directories (pnpm workspace) - while IFS= read -r nm_dir; do - mount_overlay "${nm_dir#"$MAIN_DIR"/}" - done < <(find "$MAIN_DIR" \ - -path "$MAIN_DIR/.claude" -prune -o \ - -name node_modules -type d -print -prune) -fi - -# 3. Print the worktree path (required by Claude Code) -echo "$WORKTREE_DIR" diff --git a/.claude/scripts/worktree-remove.sh b/.claude/scripts/worktree-remove.sh deleted file mode 100755 index ce437f85662..00000000000 --- a/.claude/scripts/worktree-remove.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# WorktreeRemove hook for Claude Code -# Unmounts all overlayfs layers and removes the git worktree. -# -# Input (JSON on stdin): { "worktree_path": "...", "cwd": "...", ... } - -INPUT=$(cat) -WORKTREE_DIR=$(echo "$INPUT" | jq -r '.worktree_path') -MAIN_DIR=$(echo "$INPUT" | jq -r '.cwd') - -# 1. Unmount all overlayfs mounts within the worktree (reverse order for safety) -mount | grep -F " on $WORKTREE_DIR/" | awk '{print $3}' | sort -r | while read -r mnt; do - fusermount3 -u "$mnt" 2>/dev/null || fusermount -u "$mnt" 2>/dev/null || true -done - -# 2. Extract branch name before removing worktree -BRANCH=$(git -C "$WORKTREE_DIR" rev-parse --abbrev-ref HEAD 2>/dev/null || true) - -# 3. Remove the git worktree -git -C "$MAIN_DIR" worktree remove --force "$WORKTREE_DIR" 2>/dev/null || rm -rf "$WORKTREE_DIR" - -# 4. Clean up the temporary branch -if [ -n "$BRANCH" ] && [[ "$BRANCH" == claude/* ]]; then - git -C "$MAIN_DIR" branch -D "$BRANCH" 2>/dev/null || true -fi diff --git a/.claude/settings.json b/.claude/settings.json deleted file mode 100644 index c25e55284a2..00000000000 --- a/.claude/settings.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "hooks": { - "WorktreeCreate": [ - { - "hooks": [ - { - "type": "command", - "command": "bash .claude/scripts/worktree-create.sh" - } - ] - } - ], - "WorktreeRemove": [ - { - "hooks": [ - { - "type": "command", - "command": "bash .claude/scripts/worktree-remove.sh" - } - ] - } - ] - } -} diff --git a/.gitignore b/.gitignore index 21578f46881..407dc7e5424 100644 --- a/.gitignore +++ b/.gitignore @@ -48,11 +48,6 @@ docs/.vitepress/.temp # TypeDoc generated API docs docs/api/ -# Overlay filesystem -.overlays/ -.overlay-upper/ -.overlay-work/ - # Benchmark output ts-output.json benches/verilator/obj_dir/ diff --git a/flake.nix b/flake.nix index f6fe96c30ac..f46b8578c74 100644 --- a/flake.nix +++ b/flake.nix @@ -71,7 +71,6 @@ pkgs.cmake pkgs.pkg-config pkgs.openssl - pkgs.fuse-overlayfs pkgs.cargo-insta pkgs.cargo-nextest pkgs.git