diff --git a/.gitattributes b/.gitattributes
index 48956e0..ee19d20 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -4,4 +4,5 @@
*.sh text eol=lf
*.json text eol=lf
*.md text eol=lf
+*.svg text eol=lf
*.yml text eol=lf
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index b7abe09..69cbaa0 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -25,7 +25,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v7
- name: Show environment
shell: bash
run: |
@@ -44,7 +44,7 @@ jobs:
matrix:
fs: [btrfs, xfs, zfs]
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v7
- name: Make a loopback ${{ matrix.fs }} volume
shell: bash
run: |
diff --git a/README.md b/README.md
index c28d443..30947fa 100644
--- a/README.md
+++ b/README.md
@@ -12,36 +12,49 @@ private `Library/`; only the disk blocks are shared, and they diverge on write.
Unity Version Control (Plastic) workspaces work the same way, with `cm` doing
the reconciling; see `SKILL.md`.
-Measured per worktree on Windows 11, ReFS:
-
-| project | plain checkout + its own Library | `uwt new` | after first open + work |
-|---|---|---|---|
-| asset-heavy, 41k files | 33.7 GiB · 94 s + 573 s import | 344 MiB · 29 s | 1.98 GiB · **17×** |
-| monorepo subdir, 39k files | 16.3 GiB · 46 s + 370 s | 318 MiB · 28 s | 1.31 GiB · **12×** |
-| URP sample, 3k files | 3.4 GiB · 4 s + 121 s | 124 MiB · 11 s | 462 MiB · **7.6×** |
-| DOTS, code only | 1.1 GiB · 0.2 s + 61 s | 100 MiB · 9 s | 583 MiB · **2.0×** |
-| production, 41.5k files, 25 GiB Library | ~31 GiB (estimated) | 405 MiB · 34–40 s | 2.50–2.64 GiB · **~12×** |
-
-The first four are Unity 6000.7 after a first open and 100 scripted edits; the
-fifth is Unity 6000.6 after four agent-driven editors compiled and ran tests in
-parallel. All are measured by physical-cluster overlap (`uwt measure`).
+
+
+
+
+
+Four projects on Windows 11 (ReFS) with Unity 6.7: a code-only DOTS project
+(1.1 GiB), the URP sample (3.4 GiB), a project in a monorepo subdirectory
+(16 GiB) and an asset-heavy one (34 GiB, 41k tracked files). Project size is a
+plain checkout plus its own imported `Library/`. The uwt line is `uwt new`, a
+first open, then 50 scripted code edits and up to 50 material edits, measured
+by physical-cluster overlap (`uwt measure`). `SKILL.md` has the table.
+
+The cost follows the project's file count and code, not its size:
+
+- A fresh worktree is about one 4 KiB cluster per file: 100–344 MiB here, in
+ 9–29 s.
+- The first open adds what Unity regenerates per checkout (`PackageCache`
+ binaries, `Bee`, `BurstCache`): 0.3–1.6 GiB.
+- Assets and their import results stay shared, so the saving grows with the
+ project: 2.0×, 7.6×, 12× and 17× here.
+
+Elsewhere: a production project (41.5k files, 25 GiB `Library/`, Unity 6.6)
+with four agent-driven editors compiling and running tests in parallel came to
+2.50–2.64 GiB per worktree, against an estimated 31 GiB. On macOS
+(APFS) the 34 GiB project is 0 MiB
+fresh and 1.45 GiB after a first open and 100 edits (23×); `new` takes about
+80 s there, because git re-hashes LFS content once per clone.
A hydrated worktree opens without a reimport (0–6 assets imported, against
4,035–23,451 cold) but not without a compile: the first open rebuilds every
-script assembly and resolves packages, about 400 s on the production project
-with four editors opening at once, most of it contention between them, and
-about a minute for one editor alone on the test projects. Seed from a clean
-checkout: uncommitted edits in the donor reimport in every worktree.
-Its cost is about one 4 KiB cluster per file, so it is close
-to fixed per project and the saving grows with project size. After the first
-open it grows slowly, except that on Unity 6.6+ a texture or model reimport
-can turn a whole `DataStore` segment private (0.1–0.5 GiB); see `SKILL.md`.
+script assembly and resolves packages. That took 36–104 s for one editor alone
+on the four projects above, and about 400 s on the production project with
+four editors opening at once, most of it contention between them. Seed from a
+clean checkout: uncommitted edits in the donor reimport in every worktree.
+After the first open a worktree grows slowly, except that on Unity 6.6+ a
+texture or model reimport can turn a whole `DataStore` segment private
+(0.1–0.5 GiB); see `SKILL.md`.
## Install
-Copy `skills/unity-worktree-cow/` into the Unity project's repo, in the folder
-your agent reads skills from, and commit it: `uwt new` resets every worktree to
-its branch, so an uncommitted skill does not reach the worktrees it creates.
+`npx skills add Unity-Technologies/unity-worktree-cow` (the `skills` CLI)
+installs it for most agents. By hand, copy `skills/unity-worktree-cow/` into
+the Unity project's repo, in the folder your agent reads skills from:
| agent | folder in the repo |
|---|---|
@@ -49,14 +62,15 @@ its branch, so an uncommitted skill does not reach the worktrees it creates.
| Claude Code | `.claude/skills/` |
| Copilot in VS Code | `.github/skills/` |
+Commit it either way: `uwt new` resets every worktree to its branch, so an
+uncommitted skill does not reach the worktrees it creates.
+
Cursor and the Copilot coding agent also read `.claude/skills/`, so a repo
used only with those and Claude Code needs just that one. A repo shared with
Codex or Gemini as well needs both folders; keep the full skill in one and, in
the other, a `SKILL.md` that repeats the frontmatter and points at the first, so
there is only one script to update.
-`npx skills add Unity-Technologies/unity-worktree-cow` (the `skills` CLI) does the copy for most agents.
-
An agent without skill support can be pointed at it from `AGENTS.md`:
```markdown
@@ -94,22 +108,22 @@ an editor is using the project.
A filesystem that block-clones, with the repo and the worktrees on the same
volume:
-- **Windows** — ReFS (Dev Drive) on Windows 11 24H2 or later. NTFS cannot.
-- **macOS** — APFS. Suite green; measured end to end on the 41k-file project: a fresh worktree is 0 MiB private, 1.45 GiB after a first open
- and 100 edits, against 33.8 GiB for a plain checkout plus cold import
- (23×). `new` takes 80 s there, 69 s of it the verify `git status`
- re-hashing 23.5 GB of LFS content once, because every clone has a new
- inode. Windows skips that; see `SKILL.md` Troubleshooting.
-- **Linux** — btrfs, XFS with `reflink=1`, or ZFS ≥ 2.2 (where `measure`
- refuses: ZFS does not report physical extents). ext4 cannot.
+- **Windows**: ReFS (Dev Drive) on Windows 11 24H2 or later. NTFS cannot.
+- **macOS**: APFS.
+- **Linux**: btrfs, XFS with `reflink=1`, or ZFS ≥ 2.2. ext4 cannot.
On anything else `doctor` says so and the tool refuses. There is no copy
fallback: a byte copy of the project is the problem this exists to avoid.
-Dependencies are bash, git and coreutils. Windows adds robocopy and fsutil,
-both in-box. Plastic workspaces need `cm` on `PATH`. `measure` alone also needs PowerShell on Windows (in-box) or
-`python3` elsewhere, because reading physical extents needs ioctls. The editor interlock needs nothing extra: a rename probe on
-Windows, a `/proc` scan on Linux, `lsof` on macOS.
+Tested with Unity 6.0, 6.3, 6.6, 6.7 (beta) and 7.0 (alpha), on Windows 11
+(ReFS), macOS (APFS) and Linux (btrfs, XFS).
+
+Dependencies are bash, git and coreutils, plus:
+
+- Windows: robocopy and fsutil, both in-box.
+- Plastic workspaces: `cm` on `PATH`.
+- `measure` only: PowerShell on Windows (in-box) or `python3` elsewhere, to
+ read physical extents. It refuses on ZFS, which does not report them.
## Documentation
diff --git a/docs/worktree-cost-dark.svg b/docs/worktree-cost-dark.svg
new file mode 100644
index 0000000..3d96b2a
--- /dev/null
+++ b/docs/worktree-cost-dark.svg
@@ -0,0 +1,61 @@
+
diff --git a/docs/worktree-cost-light.svg b/docs/worktree-cost-light.svg
new file mode 100644
index 0000000..5efa70a
--- /dev/null
+++ b/docs/worktree-cost-light.svg
@@ -0,0 +1,61 @@
+
diff --git a/skills/unity-worktree-cow/SKILL.md b/skills/unity-worktree-cow/SKILL.md
index 49b433c..da4fda9 100644
--- a/skills/unity-worktree-cow/SKILL.md
+++ b/skills/unity-worktree-cow/SKILL.md
@@ -25,8 +25,8 @@ Measured per worktree on Windows 11, ReFS:
| DOTS, code only | 1.1 GiB · 0.2 s + 61 s | 100 MiB · 9 s | 583 MiB · **2.0×** |
| production, 41.5k files, 25 GiB Library | ~31 GiB (estimated) | 405 MiB · 34–40 s | 2.50–2.64 GiB · **~12×** |
-The first four are Unity 6000.7, "work" being a first open plus 100 scripted
-code and material edits. The fifth is Unity 6000.6 with four agent-driven
+The first four are Unity 6000.7, "work" being a first open, 50 scripted code
+edits and 50 material edits (3 on the DOTS project, all it has). The fifth is Unity 6000.6 with four agent-driven
editors compiling and running tests in parallel. All are measured by
physical-cluster overlap (`uwt measure`). Four editors compiling and running
tests at once on the first four projects ended within 2% of the scripted figures or below them
@@ -53,12 +53,16 @@ checkout near the branches you will work on. `Search` is denied too, so the
editor rebuilds its index in the background after the refresh; that is
separate from the first-open times above.
-The first open is also where the private cost comes from. The largest item is
-usually `PackageCache`: Unity re-creates a fixed set of large package binaries
-(executables in `~` folders such as `com.unity.ai.assistant/RelayApp~/relay_win.exe`)
-byte-identical but in fresh blocks, 0.8–1.0 GiB on projects that carry them
-and nothing on projects that do not. Then `Bee` and `BurstCache` regenerating
-(~0.3 and 0.2–0.4 GiB). After that, code, material, shader, prefab and scene
+The first open is also where the private cost comes from: `Bee` and
+`BurstCache` regenerating (~0.3 and 0.2–0.4 GiB). Up to 6000.7.0b3 the largest
+item was usually `PackageCache`: Unity re-created a fixed set of large package
+binaries (executables in `~` folders such as
+`com.unity.ai.assistant/RelayApp~/relay_win.exe`) byte-identical but in fresh
+blocks, 0.3–1.0 GiB on projects that carry them. On 6000.7.0b10, with
+`Library/PackageManager` cloned, it re-creates none: the monorepo project's
+`PackageCache` stayed at 139 MiB through the first open, which cost 416 MiB
+against 729 on b3, and the worktree ended the same work at 1.02 GiB (16×).
+After that, code, material, shader, prefab and scene
edits grow a worktree slowly
(+17 to +77 MiB over a second open and 250 edits).
@@ -173,6 +177,9 @@ A filesystem that block-clones, with golden and worktrees on **one volume**:
- **Linux**: btrfs, XFS with `reflink=1`, ZFS ≥ 2.2 (`measure` excepted). ext4
cannot.
+Tested with Unity 6.0, 6.3, 6.6, 6.7 (beta) and 7.0 (alpha), on Windows 11
+(ReFS), macOS (APFS) and Linux (btrfs, XFS).
+
There is no copy fallback. On a volume that cannot clone, `doctor` says so and
every command refuses, because a byte copy of the project is the problem this
tool exists to avoid. A silent byte copy is also the single most likely way a
@@ -320,14 +327,15 @@ by the first build.
- **Denied**: `Bee`, `BurstCache`, `BuildCache` (build-system state keyed by
absolute path), `ScriptAssemblies` (compiled output of *this* branch's
- scripts), `PackageManager` (regenerated from the lock file), `Search`,
- `TempArtifacts` (indexes derived from the artifact DB).
+ scripts), `Search`, `TempArtifacts` (indexes derived from the artifact DB).
- **Never**: `EditorInstance.json`, `ProtocolInstance.json`, `Pipeline/`,
`*.pid`, `*-lock`, `uds.lock`, `*.index-lock`. These identify or lock a
running editor; they are stripped after every clone.
-- **Everything else is cloned**: `PackageCache`, `DataStore`, `ArtifactDB`,
- `SourceAssetDB`, `ShaderCache`, the `Build*` settings, `PlayerDataCache`,
- per-user UI state. The `Build*` files are the best value per byte: they
+- **Everything else is cloned**: `PackageCache`, `PackageManager` (its install
+ record is what stops the package manager reinstalling `PackageCache`),
+ `DataStore`, `ArtifactDB`, `SourceAssetDB`, `ShaderCache`, the `Build*`
+ settings, `PlayerDataCache`, per-user UI state. The `Build*` files are the
+ best value per byte: they
carry the active build target, so the worktree opens on the same platform
without a platform-switch reimport.
diff --git a/skills/unity-worktree-cow/scripts/unity-worktree-cow.sh b/skills/unity-worktree-cow/scripts/unity-worktree-cow.sh
index 81042fd..52d6cc4 100644
--- a/skills/unity-worktree-cow/scripts/unity-worktree-cow.sh
+++ b/skills/unity-worktree-cow/scripts/unity-worktree-cow.sh
@@ -41,7 +41,10 @@ esac
# output of THIS branch's scripts, and indexes derived from the artifact DB.
# They are also all cheap to rebuild, so denying them costs almost nothing.
# (Bee was measured directly: grafting it ships the donor's compiled output.)
-LIBRARY_DENY="Bee BurstCache BuildCache ScriptAssemblies PackageManager Search TempArtifacts"
+# PackageManager is not on it: without its install.db, UPM 9.36+ (6000.7,
+# 7000.0) reinstalls every package and PackageCache stops being shared. The
+# absolute paths it holds are checked by the editor and re-resolved on open.
+LIBRARY_DENY="Bee BurstCache BuildCache ScriptAssemblies Search TempArtifacts"
# Files that identify or lock a running editor. Copying them cross-wires two
# editors or trips LMDB's reader table. Stripped after every Library clone.
@@ -381,7 +384,9 @@ cow_tree() { # cow_tree [--globs] [exclude-name...]
fi
mkdir -p "$dst" || return 1
for e in "$src"/* "$src"/.[!.]*; do
- [ -e "$e" ] || continue
+ # Skips a glob that matched nothing. -e follows links, so a dangling
+ # symlink needs -L to count as the entry it is.
+ [ -e "$e" ] || [ -L "$e" ] || continue
local n; n="$(basename "$e")"; skip=0
for x in "$@"; do [ "$n" = "$x" ] && skip=1; done
# shellcheck disable=SC2254
@@ -699,6 +704,10 @@ cmd_hydrate() {
local why; why="$(cow_probe "$wt")" || REASON=unsupported_volume die "this volume cannot block-clone ($why)"
if [ -d "$lib" ]; then
hydrate_library "$gd" "$wt" "$new" || die "hydrate failed; the existing Library/ is untouched"
+ # The clone takes long enough for an editor to have opened the project.
+ # Off Windows the move below succeeds under it, and the editor is left
+ # running on a Library that is then deleted.
+ ( require_editor_closed "$wt" hydrate ) || { local rc=$?; rm -rf "$new"; exit $rc; }
mv "$lib" "$old" || { rm -rf "$new"; die "could not move the existing Library/ aside; it is untouched"; }
mv "$new" "$lib" || { mv "$old" "$lib"; rm -rf "$new"; die "could not put the new Library/ in place; the previous one is restored"; }
rm -rf "$old" || warn "the new Library/ is in place, but $old could not be deleted; delete it by hand"
diff --git a/tests/README.md b/tests/README.md
index 9c90eae..e1fce46 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -21,10 +21,10 @@ Synthetic fixtures: a fake git repo shaped like a Unity project with a fake
| group | covers |
|---|---|
| 1 | `doctor` resolves the project from a subdirectory and reports state |
-| 2 | `seed` snapshots the tracked tree and `Library`, applies the deny list and the never-list, leaves the source alone, honours `--force`, rejects an empty `ArtifactDB` |
+| 2 | `seed` snapshots the tracked tree and `Library`, applies the deny list and the never-list, leaves the source alone, honours `--force`, rejects an empty `ArtifactDB`, keeps a dangling top-level symlink (Linux and macOS) |
| 3 | the interlock refuses while a database is held open by another process (Linux and macOS) and while it is memory-mapped with the fd already closed, the way LMDB holds it (Linux; python3 builds the mapping); `doctor` names the open-file mechanism; a dead pid does not block. Windows needs a real editor, see below |
| 4 | `new` registers, clones, reconciles to the target branch (same-commit and cross-branch), cleans inherited untracked files, honours `--path`, `--base`, `--inherit-untracked`, checks out an existing branch, gives committed content for files the source hides behind `assume-unchanged`/`skip-worktree`, and refuses before registering when it cannot proceed |
-| 5 | `hydrate` fills a plain worktree, refuses to overwrite without `--force`, warns on a Unity version mismatch |
+| 5 | `hydrate` fills a plain worktree, refuses to overwrite without `--force`, warns on a Unity version mismatch; `--force` refuses (exit 3) when the project is opened while the replacement is being cloned (Linux and macOS) |
| 6 | CLI errors exit 2 |
| 7 | a project in a subdirectory of its repo: `seed` records the prefix, `new` clones back to it and leaves files outside it to git, `hydrate` given the worktree root finds the project |
| 8 | `list` (text and `--json`) and where each `Library` came from; `remove` refuses the main worktree, a non-root path, a dirty worktree without `--force`, and a worktree whose `ArtifactDB` is open (exit 3), and keeps the branch, or with `--delete-branch` deletes it only when it has no commits of its own; `new --json` success and error records; `new --verify` rolls back a snapshot whose content changed behind matching stat data (which plain `new` lets through on Windows), runs its fresh-index pass only on Windows, and a configured `core.checkStat=minimal` does not weaken the check |
diff --git a/tests/run-tests.sh b/tests/run-tests.sh
index 35ff9c3..31ff063 100644
--- a/tests/run-tests.sh
+++ b/tests/run-tests.sh
@@ -61,7 +61,7 @@ mkdir -p "$PROJ" && cd "$PROJ" || exit 2
# The branch is named, never left to init.defaultBranch: the groups below return to it by name.
git init -q -b main && git config user.email t@t && git config user.name t && git config core.autocrlf false \
|| { echo "fixture: git init failed"; exit 2; }
-mkdir -p ProjectSettings Assets/Scenes Packages Library/PackageCache/com.x@abc Library/DataStore/00 \
+mkdir -p ProjectSettings Assets/Scenes Packages Library/PackageCache/com.x@abc Library/PackageManager/Cache Library/DataStore/00 \
Library/Bee Library/BurstCache Library/ScriptAssemblies Library/Search Library/Pipeline Library/ShaderCache Temp obj
printf 'm_EditorVersion: 6000.7.0b1\nm_EditorVersionWithRevision: 6000.7.0b1 (deadbeef)\n' > ProjectSettings/ProjectVersion.txt
echo scene > Assets/Scenes/A.unity; echo '{}' > Packages/manifest.json; echo tracked > README.md
@@ -71,6 +71,7 @@ head -c 200000 /dev/urandom > Library/SourceAssetDB
head -c 100000 /dev/urandom > Library/DataStore/uds.db
head -c 100000 /dev/urandom > Library/DataStore/UDSData_3.bin
echo pkg > Library/PackageCache/com.x@abc/package.json
+echo '{"packages":{"com.x":{"fingerprint":"abc"}}}' > Library/PackageManager/install.db; echo sig > Library/PackageManager/Cache/sig
echo dag > Library/Bee/x.dag; echo burst > Library/BurstCache/b.dll; echo dll > Library/ScriptAssemblies/a.dll
echo idx > Library/Search/i.index; echo pipe > Library/Pipeline/p; echo sc > Library/ShaderCache/s.bin
# The smallest EditorUserBuildSettings.asset uwt reads the build target from:
@@ -119,6 +120,8 @@ if [ $CLONES = 1 ]; then
check "cloned: ArtifactDB, SourceAssetDB, DataStore, PackageCache, ShaderCache" \
nonempty "$GD/Library/ArtifactDB" "$GD/Library/SourceAssetDB" "$GD/Library/DataStore/uds.db" \
"$GD/Library/PackageCache/com.x@abc/package.json" "$GD/Library/ShaderCache/s.bin"
+ check "cloned: PackageManager, whose install.db keeps PackageCache shared" \
+ nonempty "$GD/Library/PackageManager/install.db" "$GD/Library/PackageManager/Cache/sig"
check "denied: Bee, BurstCache, ScriptAssemblies, Search" \
absent "$GD/Library/Bee" "$GD/Library/BurstCache" "$GD/Library/ScriptAssemblies" "$GD/Library/Search"
check "never-files stripped: EditorInstance.json, *-lock, *.pid, Pipeline/" \
@@ -128,6 +131,15 @@ if [ $CLONES = 1 ]; then
check "seed --force republishes" bash -c "touch -d '2000-01-01' '$GD.txt'; bash '$UWT' seed '$PROJ' --force >/dev/null && [ \"\$(find '$GD.txt' -newermt '2001-01-01')\" ]"
check "seed refuses an empty ArtifactDB" bash -c "cp -r '$PROJ' '$ROOT/proj-empty' && : > '$ROOT/proj-empty/Library/ArtifactDB'; bash '$UWT' seed '$ROOT/proj-empty' --force; [ \$? = 2 ]"
rm -rf "$ROOT/proj-empty"
+ if [ $WIN = 0 ]; then
+ # The tree clone walks top-level entries; one that is a dangling symlink
+ # still has to be cloned. Re-seeded without it so later groups see the
+ # fixture they expect.
+ ln -s nowhere "$PROJ/dangling"
+ check "a dangling top-level symlink is in the snapshot" bash -c "bash '$UWT' seed '$PROJ' --force >/dev/null 2>&1 && [ -L '$GD/dangling' ]"
+ rm -f "$PROJ/dangling"
+ uwt seed "$PROJ" --force >/dev/null 2>&1 || { echo "fixture: re-seed failed"; exit 2; }
+ fi
else
check "seed refuses on a non-cloning volume with exit 2" [ $rc = 2 ]
check "seed says why" grep -qi 'cannot block-clone' <<<"$out"
@@ -173,6 +185,7 @@ if [ $CLONES = 1 ]; then
check "inherited untracked file was cleaned" [ ! -e "$WT/scratch.txt" ]
check "Library hydrated with a stamp" nonempty "$WT/Library/ArtifactDB" "$WT/Library/.uwt-hydration.txt"
check "Library has no denied or never entries" absent "$WT/Library/Bee" "$WT/Library/EditorInstance.json"
+ check "Library carries the package install record" nonempty "$WT/Library/PackageManager/install.db" "$WT/Library/PackageManager/Cache/sig"
check "Library is writable" bash -c "echo x >> '$WT/Library/ArtifactDB'"
check "new refuses an existing path" bash -c "bash '$UWT' new feature/y --path '$WT' >/dev/null 2>&1; [ \$? = 2 ]"
check "existing branch is checked out, not recreated" bash -c "bash '$UWT' new keep --path '$ROOT/wt-keep' >/dev/null 2>&1 && [ \"\$(git -C '$ROOT/wt-keep' branch --show-current)\" = keep ]"
@@ -268,6 +281,21 @@ if [ $CLONES = 1 ]; then
check "and leaves the existing Library byte-identical" bash -c "cmp -s '$ROOT/plain/Library/ArtifactDB' '$ROOT/plain-adb' && [ -f '$ROOT/plain/Library/MINE' ]"
check "and leaves no staging directory" absent "$ROOT/plain/Library.uwt-new" "$ROOT/plain/Library.uwt-old"
done
+ # An editor that opens the project while the replacement is being cloned is
+ # caught before the swap. Forced the same way: the real cp, then an fd held
+ # open on the existing ArtifactDB. Not on Windows, for the reason group 3 gives.
+ if [ $WIN = 0 ]; then
+ mkdir -p "$SH/editor"
+ printf '#!/usr/bin/env bash\ncase "$*" in *.uwt-probe*) exec "%s" "$@" ;; esac\n"%s" "$@" || exit 1\n[ -e "%s" ] && exit 0\nexec 9<>"%s"\nsleep 8 >/dev/null 2>&1 & echo $! > "%s"\n' \
+ "$(command -v cp)" "$(command -v cp)" "$SH/editor/pid" "$ROOT/plain/Library/ArtifactDB" "$SH/editor/pid" > "$SH/editor/cp"
+ chmod +x "$SH/editor/cp"
+ PATH="$SH/editor:$PATH" uwt hydrate "$ROOT/plain" --force >/dev/null 2>&1; rc=$?
+ holder="$(cat "$SH/editor/pid" 2>/dev/null)"
+ if [ -n "$holder" ]; then kill "$holder" 2>/dev/null; while kill -0 "$holder" 2>/dev/null; do sleep 0.1; done; fi
+ check "hydrate --force refuses (exit 3) when an editor opens the project during the clone" [ $rc = 3 ]
+ check "and leaves the existing Library byte-identical" bash -c "cmp -s '$ROOT/plain/Library/ArtifactDB' '$ROOT/plain-adb' && [ -f '$ROOT/plain/Library/MINE' ]"
+ check "and leaves no staging directory" absent "$ROOT/plain/Library.uwt-new" "$ROOT/plain/Library.uwt-old"
+ fi
out="$(PATH="$SH/probe:$PATH" uwt hydrate "$ROOT/plain" --force --json 2>/dev/null)"
check "a volume that cannot clone is reason unsupported_volume" json_is "d['status']=='error' and d['exit']==2 and d['reason']=='unsupported_volume'" <<<"$out"
mv "$ROOT/plain/Library" "$ROOT/plain/Library.uwt-old" && mkdir "$ROOT/plain/Library.uwt-new"