@cleocode/worktree 2026.10.27 → 2026.11.1-canary.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/.source-stamp.json +4 -0
  2. package/dist/git.d.ts +0 -13
  3. package/dist/git.d.ts.map +1 -1
  4. package/dist/git.js +0 -18
  5. package/dist/git.js.map +1 -1
  6. package/dist/index.d.ts +13 -5
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +14 -6
  9. package/dist/index.js.map +1 -1
  10. package/dist/worktree-create.d.ts +32 -1
  11. package/dist/worktree-create.d.ts.map +1 -1
  12. package/dist/worktree-create.js +153 -34
  13. package/dist/worktree-create.js.map +1 -1
  14. package/dist/worktree-destroy.d.ts +5 -5
  15. package/dist/worktree-destroy.d.ts.map +1 -1
  16. package/dist/worktree-destroy.js +79 -120
  17. package/dist/worktree-destroy.js.map +1 -1
  18. package/dist/worktree-dispose.d.ts +193 -0
  19. package/dist/worktree-dispose.d.ts.map +1 -0
  20. package/dist/worktree-dispose.js +608 -0
  21. package/dist/worktree-dispose.js.map +1 -0
  22. package/dist/worktree-locate.d.ts +2 -0
  23. package/dist/worktree-locate.d.ts.map +1 -1
  24. package/dist/worktree-locate.js +12 -1
  25. package/dist/worktree-locate.js.map +1 -1
  26. package/dist/worktree-lock.d.ts +56 -7
  27. package/dist/worktree-lock.d.ts.map +1 -1
  28. package/dist/worktree-lock.js +315 -100
  29. package/dist/worktree-lock.js.map +1 -1
  30. package/dist/worktree-prune.d.ts +1 -3
  31. package/dist/worktree-prune.d.ts.map +1 -1
  32. package/dist/worktree-prune.js +20 -241
  33. package/dist/worktree-prune.js.map +1 -1
  34. package/native/worktree-napi.darwin-arm64.node +0 -0
  35. package/native/worktree-napi.linux-arm64-gnu.node +0 -0
  36. package/native/worktree-napi.linux-x64-gnu.node +0 -0
  37. package/native/worktree-napi.win32-x64-msvc.node +0 -0
  38. package/package.json +4 -4
@@ -0,0 +1,608 @@
1
+ /**
2
+ * The one worktree disposal engine (T13924, durability C-F2).
3
+ *
4
+ * Every path that deletes a worktree (complete, cancel, `worktree destroy`,
5
+ * `worktree prune --orphaned`, the merge sweep, gc and the sentient prune)
6
+ * calls {@link disposeWorktree}. It removes a worktree only with proof that
7
+ * nothing in it is lost:
8
+ *
9
+ * - **guard**: nothing outside links into it and no evidence lives only there
10
+ * ({@link guardWorktreeDisposal}, T13696/T13700);
11
+ * - **not in use**: the caller's in-use probe (a live task lock or claim)
12
+ * answers `null`; a probe that throws counts as in use;
13
+ * - **content**: no tracked change, and every untracked or ignored path is
14
+ * either `node_modules`, rebuildable output of a merged checkout, or the
15
+ * identical tree in the main checkout ({@link unprovenContent});
16
+ * - **commits**: every commit HEAD reaches is also held by a remote-tracking
17
+ * ref or the project's local default branch ({@link unpreservedCommits}).
18
+ *
19
+ * Every probe fails closed: a git or read error is "not proven", never clean.
20
+ * Without proof the worktree is kept with the failing clause named. With
21
+ * `force` (`cleo worktree destroy --force` only) the unpreserved work is
22
+ * archived first, a ref under `refs/cleo/archive/` plus a patch and a receipt
23
+ * under `<projectRoot>/.cleo/archive/worktrees/`, and the worktree is removed
24
+ * only once the archive is verified.
25
+ *
26
+ * Nothing else in the repository may call the raw removals (arch gate 41,
27
+ * `scripts/lint-no-raw-worktree-removal.mjs`).
28
+ *
29
+ * @task T13924
30
+ * @task T14276
31
+ */
32
+ import { execFileSync } from 'node:child_process';
33
+ import { existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlinkSync, realpathSync, rmSync, writeFileSync, } from 'node:fs';
34
+ import { tmpdir } from 'node:os';
35
+ import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path';
36
+ import { destroyWorktree as napiDestroyWorktree, removeDir as napiRemoveDir, } from './napi-binding.js';
37
+ import { computeProjectHash, resolveTaskWorktreePath } from './paths.js';
38
+ import { describeDisposalBlockers, guardWorktreeDisposal } from './worktree-dependents.js';
39
+ import { releaseWorktreeTaskLock, withWorktreeTaskLockHeld } from './worktree-lock.js';
40
+ /** A probe that could not answer: git failed (T14274 classifies these `unknown`). */
41
+ const GIT_STATUS_FAILED = 'git status failed';
42
+ const GIT_CANNOT_READ = 'git cannot read the checkout';
43
+ const GIT_CANNOT_COUNT = 'git cannot count commits held elsewhere';
44
+ const PROBE_FAILURES = new Set([
45
+ GIT_STATUS_FAILED,
46
+ GIT_CANNOT_READ,
47
+ GIT_CANNOT_COUNT,
48
+ ]);
49
+ /** Variables that point git at another repository than `-C` names (T14189). */
50
+ const GIT_AMBIENT_REPO_VARS = [
51
+ 'GIT_DIR',
52
+ 'GIT_WORK_TREE',
53
+ 'GIT_INDEX_FILE',
54
+ 'GIT_COMMON_DIR',
55
+ 'GIT_OBJECT_DIRECTORY',
56
+ 'GIT_ALTERNATE_OBJECT_DIRECTORIES',
57
+ 'GIT_PREFIX',
58
+ ];
59
+ /** The process environment without the variables in {@link GIT_AMBIENT_REPO_VARS}. */
60
+ function gitEnv(extra = {}) {
61
+ const env = { ...process.env };
62
+ for (const key of GIT_AMBIENT_REPO_VARS)
63
+ delete env[key];
64
+ return { ...env, ...extra };
65
+ }
66
+ /** Run git without optional index writes; untrimmed stdout, or `null` on any failure. */
67
+ function git(cwd, args, env) {
68
+ try {
69
+ return execFileSync('git', ['--no-optional-locks', '-C', cwd, ...args], {
70
+ env: env ?? gitEnv(),
71
+ encoding: 'utf8',
72
+ stdio: ['ignore', 'pipe', 'pipe'],
73
+ timeout: 120_000,
74
+ maxBuffer: 256 * 1024 * 1024,
75
+ });
76
+ }
77
+ catch {
78
+ return null;
79
+ }
80
+ }
81
+ /**
82
+ * A fresh per-run budget: 200 000 entries and 2 GiB of file bytes.
83
+ *
84
+ * @returns A budget to share across one run's checks.
85
+ */
86
+ export function newCompareBudget() {
87
+ return { entries: 200_000, bytes: 2 * 1024 * 1024 * 1024 };
88
+ }
89
+ /** A single file larger than this is never read to prove it identical (64 MiB). */
90
+ const MAX_COMPARED_FILE_BYTES = 64 * 1024 * 1024;
91
+ /** Output directories the build writes, at the root or in a workspace package. */
92
+ const REGENERABLE_DIRS = new Set(['dist', '.turbo', 'coverage']);
93
+ /**
94
+ * Build output a merged, clean checkout can always rebuild from its source,
95
+ * so losing it loses nothing (T14146): `dist/`, `.turbo/` and `coverage/`
96
+ * (and anything inside them), and `*.tsbuildinfo` files, only where the build
97
+ * writes them: the checkout root or a `packages/<name>/` root. The same name
98
+ * deeper down (`secrets/dist/key.pem`) is not build output and stays strict.
99
+ *
100
+ * @param rel - Path relative to the checkout root, `/`-separated.
101
+ * @returns Whether the path is rebuildable output.
102
+ */
103
+ export function isRegenerable(rel) {
104
+ const parts = rel.split('/');
105
+ // The output's own root: `dist`, or `packages/<name>/dist`.
106
+ const base = parts[0] === 'packages' ? 2 : 0;
107
+ if (parts.length > base && REGENERABLE_DIRS.has(parts[base] ?? ''))
108
+ return true;
109
+ return parts.length === base + 1 && rel.endsWith('.tsbuildinfo');
110
+ }
111
+ /**
112
+ * Whether `a` and `b` hold the same tree: same names, same file bytes, same
113
+ * symlink targets. Symlinks are compared, never followed. Any read error, an
114
+ * oversized file or a spent budget answers `false` (unproven), never throws.
115
+ */
116
+ function sameTree(a, b, budget) {
117
+ const stack = [[a, b]];
118
+ try {
119
+ while (stack.length > 0) {
120
+ const [x, y] = stack.pop();
121
+ if (--budget.entries < 0)
122
+ return false;
123
+ const sx = lstatSync(x);
124
+ const sy = lstatSync(y);
125
+ if (sx.isSymbolicLink() || sy.isSymbolicLink()) {
126
+ if (!sx.isSymbolicLink() || !sy.isSymbolicLink() || readlinkSync(x) !== readlinkSync(y)) {
127
+ return false;
128
+ }
129
+ }
130
+ else if (sx.isFile() && sy.isFile()) {
131
+ if (sx.size !== sy.size || sx.size > MAX_COMPARED_FILE_BYTES)
132
+ return false;
133
+ budget.bytes -= sx.size * 2;
134
+ if (budget.bytes < 0 || !readFileSync(x).equals(readFileSync(y)))
135
+ return false;
136
+ }
137
+ else if (sx.isDirectory() && sy.isDirectory()) {
138
+ const nx = readdirSync(x).sort();
139
+ const ny = readdirSync(y).sort();
140
+ if (nx.length !== ny.length || nx.some((n, i) => n !== ny[i]))
141
+ return false;
142
+ for (const n of nx)
143
+ stack.push([join(x, n), join(y, n)]);
144
+ }
145
+ else {
146
+ return false;
147
+ }
148
+ }
149
+ }
150
+ catch {
151
+ return false;
152
+ }
153
+ return true;
154
+ }
155
+ /** Every changed, untracked and ignored path of a checkout, or `null` when git fails. */
156
+ function statusEntries(path) {
157
+ const out = git(path, ['status', '--porcelain', '-z', '-uall', '--ignored=matching']);
158
+ if (out === null)
159
+ return null;
160
+ return out
161
+ .split('\0')
162
+ .filter((e) => e.length > 0)
163
+ .map((e) => ({ code: e.slice(0, 2), rel: e.slice(3).replace(/\/$/, '') }));
164
+ }
165
+ /**
166
+ * What in a checkout is not proven redundant, or `null` when nothing is.
167
+ *
168
+ * Tracked changes never are; untracked content is when the main checkout
169
+ * holds the identical tree at the same path, or (exempt by default) when it
170
+ * is `node_modules`. Ignored content (which
171
+ * `--porcelain` alone never lists: an edited `.env`, an agent's nested
172
+ * `.claude/worktrees/x/`) is redundant only when exempted by `opts`
173
+ * (`node_modules`, merged build output) or when the main checkout holds the
174
+ * identical tree at the same path (what `.worktreeinclude` seeded, unchanged).
175
+ * Fail-closed: a git or read error is unproven.
176
+ *
177
+ * @param path - Checkout root.
178
+ * @param projectRoot - The main checkout seeded copies are compared against.
179
+ * @param opts - Budget and exemptions (default: `node_modules` exempt, nothing else).
180
+ * @returns Why the checkout must be kept, or `null`.
181
+ * @task T14142
182
+ * @task T14146
183
+ */
184
+ export function unprovenContent(path, projectRoot, opts = {}) {
185
+ const budget = opts.budget ?? newCompareBudget();
186
+ const exemptNodeModules = opts.exemptNodeModules !== false;
187
+ const entries = statusEntries(path);
188
+ if (entries === null)
189
+ return GIT_STATUS_FAILED;
190
+ for (const { code, rel } of entries) {
191
+ const untrackedOrIgnored = code === '??' || code === '!!';
192
+ // `node_modules` (a directory, or the symlink a `node_modules/` ignore
193
+ // pattern misses) reinstalls from the lockfile: redundant in a worktree.
194
+ if (untrackedOrIgnored && exemptNodeModules && rel.split('/').includes('node_modules'))
195
+ continue;
196
+ // A tracked change is never redundant; an untracked or ignored path is
197
+ // when the main checkout holds the identical tree (a copied receipt).
198
+ if (code === '??') {
199
+ if (sameTree(join(path, rel), join(projectRoot, rel), budget))
200
+ continue;
201
+ return 'uncommitted or untracked changes';
202
+ }
203
+ if (code !== '!!')
204
+ return 'uncommitted or untracked changes';
205
+ if (opts.exemptRegenerable === true && isRegenerable(rel))
206
+ continue;
207
+ if (!sameTree(join(path, rel), join(projectRoot, rel), budget)) {
208
+ return `ignored content not in the main checkout: ${rel}`;
209
+ }
210
+ }
211
+ return null;
212
+ }
213
+ // ---------------------------------------------------------------------------
214
+ // Commit proof
215
+ // ---------------------------------------------------------------------------
216
+ /** The checkout's branch (`null` when detached), or `undefined` when git fails. */
217
+ function currentBranch(path) {
218
+ const out = git(path, ['rev-parse', '--abbrev-ref', 'HEAD']);
219
+ if (out === null)
220
+ return undefined;
221
+ const name = out.trim();
222
+ return name === 'HEAD' ? null : name;
223
+ }
224
+ /**
225
+ * The project's local default branch (`refs/heads/<name>`), or `null`: the
226
+ * name `origin/HEAD` points at, else `main` or `master`, whichever exists
227
+ * locally. The same order as core's `resolveOriginDefault`/`resolveBaseRef`
228
+ * (git/base-ref.ts), which this package cannot import.
229
+ */
230
+ function localDefaultBranch(path, named) {
231
+ const symbolic = git(path, ['symbolic-ref', '--quiet', '--short', 'refs/remotes/origin/HEAD']);
232
+ const fromOrigin = symbolic?.trim().replace(/^origin\//, '');
233
+ // The probe order of core's getDefaultBranch (ADR-062).
234
+ const candidates = named ? [named] : [fromOrigin, 'main', 'master', 'develop', 'trunk'];
235
+ for (const name of candidates) {
236
+ if (name && git(path, ['rev-parse', '--verify', '-q', `refs/heads/${name}`]) !== null) {
237
+ return `refs/heads/${name}`;
238
+ }
239
+ }
240
+ return null;
241
+ }
242
+ /**
243
+ * Whether the checkout's commits survive its removal, or why not.
244
+ *
245
+ * Every commit HEAD reaches must also be reachable from a remote-tracking ref
246
+ * or from the project's local default branch (a local integration before any
247
+ * push). Another local branch does not count: it is often a task branch this
248
+ * engine, or `git branch -D`, removes later, which would chain the loss. An
249
+ * unborn HEAD holds no commits. Fail-closed: any git error is "commits not
250
+ * proven preserved".
251
+ *
252
+ * @param path - Checkout root.
253
+ * @param defaultBranch - The project's default branch; resolved as in
254
+ * {@link DisposeWorktreeOptions.defaultBranch} when omitted.
255
+ * @returns Why its commits are not preserved, or `null`.
256
+ * @task T13924
257
+ */
258
+ export function unpreservedCommits(path, defaultBranch) {
259
+ if (git(path, ['rev-parse', '--git-dir']) === null)
260
+ return GIT_CANNOT_READ;
261
+ if (git(path, ['rev-parse', '--verify', '-q', 'HEAD']) === null)
262
+ return null; // unborn
263
+ const base = localDefaultBranch(path, defaultBranch);
264
+ const out = git(path, [
265
+ 'rev-list',
266
+ '--count',
267
+ 'HEAD',
268
+ '--not',
269
+ '--remotes',
270
+ ...(base ? [base] : []),
271
+ ]);
272
+ const count = out === null ? Number.NaN : Number.parseInt(out.trim(), 10);
273
+ if (Number.isNaN(count))
274
+ return GIT_CANNOT_COUNT;
275
+ return count === 0 ? null : `${count} commit(s) on no remote and not on the default branch`;
276
+ }
277
+ // ---------------------------------------------------------------------------
278
+ // Archive
279
+ // ---------------------------------------------------------------------------
280
+ /** Paths `git add -f` must capture: ignored content bar `node_modules` and build output. */
281
+ function archivableIgnored(entries) {
282
+ return entries
283
+ .filter((e) => e.code === '!!')
284
+ .map((e) => e.rel)
285
+ .filter((rel) => !rel.split('/').includes('node_modules') && !isRegenerable(rel));
286
+ }
287
+ /**
288
+ * Archive everything a worktree holds before it is removed (T13924): an
289
+ * archive commit whose parent is HEAD and whose tree is the checkout's
290
+ * tracked, untracked and ignored content (bar `node_modules`, and ignored
291
+ * build output), held by `refs/cleo/archive/<name>/<stamp>`, plus a binary patch from
292
+ * HEAD and a JSON receipt under `<projectRoot>/.cleo/archive/worktrees/`. The
293
+ * worktree's own index and files are not touched (a temporary index is used).
294
+ *
295
+ * @param worktreePath - Checkout to archive.
296
+ * @param gitRoot - Repository the archive ref is written to.
297
+ * @param projectRoot - Main checkout whose `.cleo/archive/worktrees/` holds the patch and receipt.
298
+ * @param meta - Owning task and disposal reason, recorded on the receipt.
299
+ * @returns The verified receipt, or why the archive could not be written.
300
+ * @task T13924
301
+ */
302
+ export function archiveWorktree(worktreePath, gitRoot, projectRoot, meta) {
303
+ const entries = statusEntries(worktreePath);
304
+ if (entries === null)
305
+ return { error: 'git status failed' };
306
+ const branch = currentBranch(worktreePath);
307
+ if (branch === undefined)
308
+ return { error: 'git cannot read the checked-out branch' };
309
+ const headOut = git(worktreePath, ['rev-parse', '--verify', '-q', 'HEAD']);
310
+ const head = headOut === null ? null : headOut.trim();
311
+ const createdAt = new Date().toISOString();
312
+ const stamp = createdAt.replace(/[:.]/g, '-');
313
+ const name = (meta.taskId ?? basename(worktreePath)).replace(/[^A-Za-z0-9._-]/g, '_');
314
+ const scratch = mkdtempSync(join(tmpdir(), 'cleo-worktree-archive-'));
315
+ try {
316
+ const env = gitEnv({
317
+ GIT_INDEX_FILE: join(scratch, 'index'),
318
+ GIT_AUTHOR_NAME: process.env['GIT_AUTHOR_NAME'] ?? 'CLEO archive',
319
+ GIT_AUTHOR_EMAIL: process.env['GIT_AUTHOR_EMAIL'] ?? 'archive@cleo.invalid',
320
+ GIT_COMMITTER_NAME: process.env['GIT_COMMITTER_NAME'] ?? 'CLEO archive',
321
+ GIT_COMMITTER_EMAIL: process.env['GIT_COMMITTER_EMAIL'] ?? 'archive@cleo.invalid',
322
+ });
323
+ if (head !== null && git(worktreePath, ['read-tree', head], env) === null) {
324
+ return { error: 'git read-tree failed' };
325
+ }
326
+ const noNodeModules = [':(exclude,glob)**/node_modules', ':(exclude,glob)**/node_modules/**'];
327
+ if (git(worktreePath, ['add', '-A', '--', '.', ...noNodeModules], env) === null) {
328
+ return { error: 'git add -A failed' };
329
+ }
330
+ const ignored = archivableIgnored(entries);
331
+ for (let i = 0; i < ignored.length; i += 200) {
332
+ if (git(worktreePath, ['add', '-f', '--', ...ignored.slice(i, i + 200)], env) === null) {
333
+ return { error: 'git add -f of ignored content failed' };
334
+ }
335
+ }
336
+ const tree = git(worktreePath, ['write-tree'], env)?.trim();
337
+ if (!tree)
338
+ return { error: 'git write-tree failed' };
339
+ const message = `cleo archive of ${worktreePath} (${meta.reason})`;
340
+ const parents = head === null ? [] : ['-p', head];
341
+ const sha = git(worktreePath, ['commit-tree', tree, ...parents, '-m', message], env)?.trim();
342
+ if (!sha)
343
+ return { error: 'git commit-tree failed' };
344
+ const archiveRef = `refs/cleo/archive/${name}/${stamp}`;
345
+ if (git(gitRoot, ['update-ref', archiveRef, sha]) === null) {
346
+ return { error: 'git update-ref failed' };
347
+ }
348
+ if (git(gitRoot, ['rev-parse', '--verify', '-q', `${archiveRef}^{commit}`])?.trim() !== sha) {
349
+ return { error: `${archiveRef} does not resolve to the archive commit` };
350
+ }
351
+ const from = head ?? git(gitRoot, ['hash-object', '-t', 'tree', '/dev/null'])?.trim();
352
+ const patch = from ? git(gitRoot, ['diff', '--binary', from, sha]) : null;
353
+ if (patch === null)
354
+ return { error: 'git diff of the archive failed' };
355
+ const dir = join(projectRoot, '.cleo', 'archive', 'worktrees');
356
+ mkdirSync(dir, { recursive: true });
357
+ const patchPath = join(dir, `${name}-${stamp}.patch`);
358
+ const receiptPath = join(dir, `${name}-${stamp}.json`);
359
+ writeFileSync(patchPath, patch);
360
+ const receipt = {
361
+ worktreePath,
362
+ taskId: meta.taskId,
363
+ reason: meta.reason,
364
+ branch,
365
+ head,
366
+ archiveRef,
367
+ archiveSha: sha,
368
+ patchPath,
369
+ receiptPath,
370
+ createdAt,
371
+ restore: `git worktree add <dir> ${sha}`,
372
+ };
373
+ writeFileSync(receiptPath, `${JSON.stringify(receipt, null, 2)}\n`);
374
+ if (readFileSync(patchPath).length !== Buffer.byteLength(patch)) {
375
+ return { error: 'the patch did not write completely' };
376
+ }
377
+ return receipt;
378
+ }
379
+ catch (err) {
380
+ return { error: err instanceof Error ? err.message : String(err) };
381
+ }
382
+ finally {
383
+ rmSync(scratch, { recursive: true, force: true });
384
+ }
385
+ }
386
+ // ---------------------------------------------------------------------------
387
+ // The engine
388
+ // ---------------------------------------------------------------------------
389
+ /** The repository root and main checkout a worktree belongs to, or `null`. */
390
+ function repositoryOf(worktreePath) {
391
+ const common = git(worktreePath, ['rev-parse', '--path-format=absolute', '--git-common-dir']);
392
+ if (common === null)
393
+ return null;
394
+ const mainCheckout = dirname(common.trim());
395
+ return { gitRoot: mainCheckout, mainCheckout };
396
+ }
397
+ /**
398
+ * Move this process out of `dir` before it is deleted (T12671): a process
399
+ * whose cwd no longer exists fails every later resolution from it.
400
+ */
401
+ function leaveDirectory(dir, to) {
402
+ let cwd;
403
+ let target;
404
+ try {
405
+ cwd = realpathSync(process.cwd()); // CWD-OK: the process's own cwd is the subject
406
+ target = realpathSync(dir);
407
+ }
408
+ catch {
409
+ return;
410
+ }
411
+ const rel = relative(target, cwd);
412
+ if (rel === '' || (!rel.startsWith('..') && !isAbsolute(rel)))
413
+ process.chdir(to);
414
+ }
415
+ /** Unlock and delete a checkout and its registration; whether the directory is gone. */
416
+ function removeCheckout(gitRoot, worktreePath) {
417
+ leaveDirectory(worktreePath, gitRoot);
418
+ git(gitRoot, ['worktree', 'unlock', worktreePath]);
419
+ try {
420
+ // Forced: the proof (or the archive) has already covered everything inside.
421
+ napiDestroyWorktree({ repoRoot: gitRoot, worktreePath, force: true });
422
+ }
423
+ catch {
424
+ // verified below
425
+ }
426
+ // T11033: the binding can report success while untracked directories survive.
427
+ if (existsSync(worktreePath)) {
428
+ try {
429
+ napiRemoveDir({ path: worktreePath });
430
+ }
431
+ catch {
432
+ rmSync(worktreePath, { recursive: true, force: true });
433
+ }
434
+ }
435
+ git(gitRoot, ['worktree', 'prune']);
436
+ return !existsSync(worktreePath);
437
+ }
438
+ /**
439
+ * Dispose of a worktree with per-item proof that nothing is lost (T13924).
440
+ * See the module comment for the proof; this is the only function that
441
+ * deletes a worktree.
442
+ *
443
+ * @param opts - The worktree, its task, the reason and the overrides.
444
+ * @returns Whether it was removed, or why it was kept, and any archive written.
445
+ * @task T13924
446
+ */
447
+ export function disposeWorktree(opts) {
448
+ return disposeChecked(opts, true);
449
+ }
450
+ /**
451
+ * {@link disposeWorktree}; `releaseLock` false leaves the task lock to a
452
+ * caller that releases it with its own token ({@link disposeOwnedWorktree}).
453
+ */
454
+ function disposeChecked(opts, releaseLock) {
455
+ const { worktreePath } = opts;
456
+ const keep = (keptReason, extra = {}) => ({
457
+ worktreePath,
458
+ removed: false,
459
+ keptReason,
460
+ ...extra,
461
+ });
462
+ if (!existsSync(worktreePath))
463
+ return { worktreePath, removed: true };
464
+ const repo = repositoryOf(worktreePath);
465
+ const gitRoot = opts.gitRoot ?? repo?.gitRoot;
466
+ const projectRoot = opts.projectRoot ?? repo?.mainCheckout;
467
+ if (gitRoot === undefined || projectRoot === undefined) {
468
+ return keep(`not proven: ${GIT_CANNOT_READ}`, {
469
+ unpreserved: GIT_CANNOT_READ,
470
+ indeterminate: true,
471
+ });
472
+ }
473
+ const kept = guardWorktreeDisposal(worktreePath, {
474
+ taskId: opts.taskId,
475
+ reason: opts.reason,
476
+ gitRoot,
477
+ projectRoot,
478
+ evidence: opts.evidence,
479
+ dryRun: opts.dryRun,
480
+ });
481
+ if (kept !== null)
482
+ return keep(describeDisposalBlockers(worktreePath, kept), { kept });
483
+ if (opts.inUse) {
484
+ let inUse;
485
+ try {
486
+ inUse = opts.inUse();
487
+ }
488
+ catch {
489
+ return keep('in use: the in-use probe failed', { indeterminate: true });
490
+ }
491
+ if (inUse !== null)
492
+ return keep(`in use: ${inUse}`);
493
+ }
494
+ const unpreserved = unprovenContent(worktreePath, projectRoot, { exemptRegenerable: opts.exemptRegenerable }) ??
495
+ unpreservedCommits(worktreePath, opts.defaultBranch);
496
+ if (unpreserved !== null && opts.force !== true) {
497
+ return keep(`not proven preserved: ${unpreserved}`, {
498
+ unpreserved,
499
+ ...(PROBE_FAILURES.has(unpreserved) ? { indeterminate: true } : {}),
500
+ });
501
+ }
502
+ if (opts.dryRun === true || opts.probe === true) {
503
+ return { worktreePath, removed: false, ...(unpreserved !== null ? { unpreserved } : {}) };
504
+ }
505
+ let archive;
506
+ if (unpreserved !== null) {
507
+ const written = archiveWorktree(worktreePath, gitRoot, projectRoot, {
508
+ taskId: opts.taskId,
509
+ reason: opts.reason,
510
+ });
511
+ if ('error' in written) {
512
+ const failed = `archive failed (${written.error}); nothing removed`;
513
+ return keep(failed, { unpreserved, failed });
514
+ }
515
+ archive = written;
516
+ }
517
+ if (!removeCheckout(gitRoot, worktreePath)) {
518
+ const failed = `removal failed: ${worktreePath} is still on disk`;
519
+ return keep(failed, {
520
+ failed,
521
+ ...(unpreserved !== null ? { unpreserved } : {}),
522
+ ...(archive ? { archive } : {}),
523
+ });
524
+ }
525
+ // T12506: a removed worktree's per-task lock guards nothing.
526
+ if (releaseLock && opts.taskId !== null) {
527
+ releaseWorktreeTaskLock(computeProjectHash(projectRoot), opts.taskId);
528
+ }
529
+ return {
530
+ worktreePath,
531
+ removed: true,
532
+ ...(unpreserved !== null ? { unpreserved } : {}),
533
+ ...(archive ? { archive } : {}),
534
+ };
535
+ }
536
+ /**
537
+ * Dispose of a worktree only while the caller still owns its task lock
538
+ * (T14407). For a caller that created the worktree under the lock and must
539
+ * now remove it (a failed provision or spawn).
540
+ *
541
+ * Under the lock's own mutex, held for the whole check and disposal (a live
542
+ * holder's mutex is never broken as stale), it checks that `lockToken` still
543
+ * holds the lock, that `worktreePath` is the task's canonical path and that
544
+ * the checkout there is on `branch`, then runs {@link disposeWorktree}'s proof
545
+ * and removal, then releases the lock with `lockToken`. A concurrent re-spawn
546
+ * cannot re-enter or reclaim the lock in between, so it never loses a
547
+ * worktree it owns. Fails closed: any failed or unreadable lookup, token
548
+ * mismatch or path mismatch keeps the worktree. The branch is not deleted.
549
+ *
550
+ * @param opts - Lock identity, exact path and branch, and disposal options.
551
+ * @returns Whether it was removed or kept, why, and whether the lock was released.
552
+ * @task T14407
553
+ */
554
+ export function disposeOwnedWorktree(opts) {
555
+ const kept = (reason, disposal) => ({
556
+ outcome: 'kept',
557
+ reason,
558
+ lockReleased: false,
559
+ ...(disposal ? { disposal } : {}),
560
+ });
561
+ let canonical;
562
+ try {
563
+ canonical = resolveTaskWorktreePath(opts.projectHash, opts.taskId);
564
+ }
565
+ catch (err) {
566
+ return kept(`the task's worktree path could not be resolved (${String(err)})`);
567
+ }
568
+ if (resolve(opts.worktreePath) !== resolve(canonical)) {
569
+ return kept(`${opts.worktreePath} is not the task's worktree path (${canonical})`);
570
+ }
571
+ const hold = withWorktreeTaskLockHeld(opts.projectHash, opts.taskId, opts.lockToken, (_record, releaseLock) => {
572
+ try {
573
+ // Only ENOENT proves absence; EACCES and the like keep (T14407).
574
+ try {
575
+ lstatSync(opts.worktreePath);
576
+ }
577
+ catch (err) {
578
+ if (err.code !== 'ENOENT') {
579
+ return kept(`${opts.worktreePath} could not be looked up (${String(err)})`);
580
+ }
581
+ return { outcome: 'removed', reason: 'already gone', lockReleased: releaseLock() };
582
+ }
583
+ const head = git(opts.worktreePath, ['symbolic-ref', '--quiet', '--short', 'HEAD']);
584
+ if (head === null)
585
+ return kept(`the branch checked out at ${opts.worktreePath} could not be read`);
586
+ if (head.trim() !== opts.branch) {
587
+ return kept(`${opts.worktreePath} is on '${head.trim()}', not '${opts.branch}'`);
588
+ }
589
+ const disposal = disposeChecked({
590
+ worktreePath: opts.worktreePath,
591
+ ...(opts.gitRoot !== undefined ? { gitRoot: opts.gitRoot } : {}),
592
+ ...(opts.projectRoot !== undefined ? { projectRoot: opts.projectRoot } : {}),
593
+ taskId: opts.taskId,
594
+ reason: opts.reason,
595
+ ...(opts.force !== undefined ? { force: opts.force } : {}),
596
+ ...(opts.inUse ? { inUse: opts.inUse } : {}),
597
+ }, false);
598
+ if (!disposal.removed)
599
+ return kept(disposal.keptReason ?? 'not proven preserved', disposal);
600
+ return { outcome: 'removed', reason: 'removed', lockReleased: releaseLock(), disposal };
601
+ }
602
+ catch (err) {
603
+ return kept(`disposal failed (${err instanceof Error ? err.message : String(err)})`);
604
+ }
605
+ });
606
+ return hold.held ? hold.value : kept(`worktree kept: ${hold.reason}`);
607
+ }
608
+ //# sourceMappingURL=worktree-dispose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-dispose.js","sourceRoot":"","sources":["../src/worktree-dispose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,MAAM,EAEN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMnF,OAAO,EACL,eAAe,IAAI,mBAAmB,EACtC,SAAS,IAAI,aAAa,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEvF,qFAAqF;AACrF,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAC9C,MAAM,eAAe,GAAG,8BAA8B,CAAC;AACvD,MAAM,gBAAgB,GAAG,yCAAyC,CAAC;AACnE,MAAM,cAAc,GAA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C,CAAC,CAAC,EAAE,CAAC;gBAC1D,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC7C,EACD,KAAK,CACN,CAAC;YACF,IAAI,CAAC,QAAQ,CAAC,OAAO;gBAAE,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,sBAAsB,EAAE,QAAQ,CAAC,CAAC;YAC5F,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,QAAQ,EAAE,CAAC;QAC1F,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,IAAI,CAAC,oBAAoB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvF,CAAC;IACH,CAAC,CACF,CAAC;IACF,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AACxE,CAAC"}
@@ -45,6 +45,8 @@ export interface LocatedWorktree {
45
45
  readonly branch: string | null;
46
46
  /** Whether git holds a lock on this entry. */
47
47
  readonly locked: boolean;
48
+ /** The worktree's own HEAD commit (porcelain `HEAD <sha>`), when git reports one (T14236). */
49
+ readonly head?: string;
48
50
  /** Present (true) only for a bare repository entry: no working tree, no branch (T10866). */
49
51
  readonly bare?: true;
50
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"worktree-locate.d.ts","sourceRoot":"","sources":["../src/worktree-locate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAIH,2CAA2C;AAC3C,MAAM,WAAW,eAAe;IAC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