rungate 0.5.0 → 0.7.0

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 (142) hide show
  1. package/lib/affected-tests.ts +398 -0
  2. package/lib/agent-audit.ts +2 -3
  3. package/lib/agent-worktree.ts +287 -0
  4. package/lib/agents-md-sections.ts +209 -0
  5. package/lib/behavioral-cache.ts +150 -2
  6. package/lib/branch-diff.ts +139 -0
  7. package/lib/branch-protection.ts +790 -0
  8. package/lib/brief-ac-alignment.ts +104 -0
  9. package/lib/brief-references.ts +205 -0
  10. package/lib/bun-version.ts +347 -0
  11. package/lib/check-remedy.ts +140 -0
  12. package/lib/ci-checkout.ts +18 -1
  13. package/lib/ci-history-depth.ts +159 -0
  14. package/lib/ci-setup-step.ts +96 -0
  15. package/lib/claude-code-action.ts +85 -0
  16. package/lib/claude-tool-vocabulary.ts +188 -0
  17. package/lib/cli-commands.ts +15 -0
  18. package/lib/commit-sha.ts +42 -0
  19. package/lib/commit-subject.ts +90 -0
  20. package/lib/compliance-report.ts +377 -45
  21. package/lib/compliance.ts +196 -20
  22. package/lib/config-loader.ts +51 -1
  23. package/lib/config-trackable.ts +391 -0
  24. package/lib/conformity.ts +1272 -189
  25. package/lib/containment.ts +238 -0
  26. package/lib/content-hash.ts +24 -0
  27. package/lib/context-docs.ts +143 -28
  28. package/lib/create-brief.ts +2 -1
  29. package/lib/create-sc.ts +323 -4
  30. package/lib/dev-liveness.ts +180 -0
  31. package/lib/discovery-branch-points.ts +432 -0
  32. package/lib/discovery-stability.ts +481 -0
  33. package/lib/distribution-currency.ts +186 -0
  34. package/lib/doc-routing.ts +157 -0
  35. package/lib/doc-scan-targets.ts +9 -0
  36. package/lib/evidence-command-transport.ts +160 -0
  37. package/lib/evidence-prevalidator.ts +246 -2
  38. package/lib/evidence-satisfiability.ts +534 -12
  39. package/lib/failure-intake.ts +317 -0
  40. package/lib/fallow-availability.ts +286 -0
  41. package/lib/fs-write-capabilities.ts +232 -0
  42. package/lib/gate-refusal-currency.ts +112 -0
  43. package/lib/gate-run-split.ts +147 -0
  44. package/lib/gate-timeouts.ts +82 -0
  45. package/lib/generators/agent-briefs.ts +4 -1
  46. package/lib/generators/agents-md.ts +204 -48
  47. package/lib/generators/code-map.ts +2 -1
  48. package/lib/generators/types.ts +8 -0
  49. package/lib/git-dates.ts +55 -0
  50. package/lib/git-isolation.ts +140 -0
  51. package/lib/github.ts +15 -0
  52. package/lib/google-auth-action.ts +93 -0
  53. package/lib/harness-project.ts +48 -0
  54. package/lib/harness-provenance.ts +255 -0
  55. package/lib/hook-evidence.ts +235 -0
  56. package/lib/hook-scopes.ts +386 -0
  57. package/lib/hook-target-tree.ts +398 -0
  58. package/lib/hook-trees.ts +447 -0
  59. package/lib/js-top-level-code.ts +78 -10
  60. package/lib/junit-checks.ts +536 -0
  61. package/lib/launch-base.ts +253 -0
  62. package/lib/line-citation.ts +372 -0
  63. package/lib/local-calendar-day.ts +78 -0
  64. package/lib/orphan-reaper.ts +468 -0
  65. package/lib/parity-binding.ts +205 -0
  66. package/lib/per-test-timeouts.ts +219 -0
  67. package/lib/plan-coverage.ts +151 -0
  68. package/lib/prior-branch.ts +201 -8
  69. package/lib/process-table.ts +146 -0
  70. package/lib/project-state-derivation.ts +219 -0
  71. package/lib/project-state-root.ts +258 -0
  72. package/lib/project-state-shape.ts +59 -0
  73. package/lib/promote-outputs.ts +6 -2
  74. package/lib/published-artifact.ts +525 -0
  75. package/lib/readdir-sorted.ts +45 -0
  76. package/lib/report-provenance.ts +156 -0
  77. package/lib/review-execution-reading.ts +206 -0
  78. package/lib/review-tool-agreement.ts +433 -0
  79. package/lib/rule-promotion.ts +234 -0
  80. package/lib/rule-retirement.ts +525 -0
  81. package/lib/run-branch.ts +612 -0
  82. package/lib/rungate-schema.ts +19 -0
  83. package/lib/runner-home.ts +274 -0
  84. package/lib/sc-claim-forms.ts +75 -0
  85. package/lib/sc-id-cross-tree.ts +323 -0
  86. package/lib/sc-ids.ts +121 -13
  87. package/lib/sc-reservations.ts +289 -0
  88. package/lib/scaffold/ai-review-findings.ts +403 -0
  89. package/lib/scaffold/ai-review-step.ts +4777 -0
  90. package/lib/scaffold/managed-workflow.ts +587 -192
  91. package/lib/scaffold/owned-files.ts +186 -39
  92. package/lib/scaffold/pre-push-hook.ts +49 -5
  93. package/lib/scaffold/rehearsal.ts +205 -71
  94. package/lib/scaffold/steps.ts +1517 -293
  95. package/lib/scaffold/workflow-census.ts +217 -0
  96. package/lib/scaffold/workflow-drift.ts +217 -0
  97. package/lib/scaffold/write-steps.ts +10 -4
  98. package/lib/scan-budget.ts +247 -0
  99. package/lib/scanner.ts +80 -62
  100. package/lib/scratch-roots.ts +50 -5
  101. package/lib/screenshot-discovery.ts +121 -0
  102. package/lib/screenshot-upload.ts +41 -1
  103. package/lib/secret-patterns.ts +511 -8
  104. package/lib/ship-mode.ts +219 -0
  105. package/lib/source-slice.ts +294 -0
  106. package/lib/spec-listing.ts +148 -0
  107. package/lib/spec-requirements.ts +209 -0
  108. package/lib/stale-cleanup.ts +37 -3
  109. package/lib/suite-flake.ts +278 -0
  110. package/lib/suite-measurement.ts +23 -4
  111. package/lib/suite-run-reading.ts +411 -1
  112. package/lib/suite-timeout-margin.ts +193 -0
  113. package/lib/test-case-bodies.ts +883 -0
  114. package/lib/test-case-deletion.ts +653 -0
  115. package/lib/test-census.ts +97 -29
  116. package/lib/test-command-positions.ts +274 -0
  117. package/lib/test-command.ts +133 -0
  118. package/lib/test-suite-lock.ts +325 -26
  119. package/lib/tool-probe.ts +142 -0
  120. package/lib/top-level-cd.ts +393 -0
  121. package/lib/tracked-vs-ignored.ts +234 -0
  122. package/lib/tree-entries.ts +89 -0
  123. package/lib/ts-ast.ts +200 -0
  124. package/lib/validators/spec-validators.ts +3 -2
  125. package/lib/walk-test-files.ts +97 -0
  126. package/lib/workflow-actions.ts +263 -0
  127. package/lib/worktree-collect.ts +177 -5
  128. package/lib/worktree-repo.ts +36 -1
  129. package/package.json +2 -1
  130. package/scripts/ai-review-findings.ts +45 -0
  131. package/scripts/audit-specs.ts +247 -12
  132. package/scripts/audit-transcript.ts +2 -1
  133. package/scripts/convert-spec.ts +2 -1
  134. package/scripts/create-sc.ts +37 -7
  135. package/scripts/create-spec.ts +2 -1
  136. package/scripts/create-success.ts +2 -1
  137. package/scripts/extract-constraints.ts +197 -26
  138. package/scripts/generate-code-map.ts +62 -28
  139. package/scripts/scaffold-project.ts +12 -2
  140. package/scripts/split-spec.ts +2 -1
  141. package/scripts/sync-sc-status.ts +127 -14
  142. package/scripts/sync-spec-tests.ts +2 -1
@@ -48,7 +48,7 @@
48
48
  */
49
49
 
50
50
  import { spawnSync } from "child_process";
51
- import { mkdtempSync, rmSync, lstatSync, readdirSync, readlinkSync, realpathSync } from "fs";
51
+ import { chmodSync, mkdirSync, mkdtempSync, rmSync, lstatSync, readdirSync, readlinkSync, realpathSync, statSync } from "fs";
52
52
  import { tmpdir } from "os";
53
53
  import { join, resolve, sep } from "path";
54
54
 
@@ -189,8 +189,16 @@ export function cloneForRehearsal(root: string): Rehearsal {
189
189
  const parent = mkdtempSync(join(tmpdir(), "rungate-rehearsal-"));
190
190
  const dir = join(parent, "tree");
191
191
  const fail = (why: string): never => {
192
- rmSync(parent, { recursive: true, force: true });
193
- throw new Error(`audit did NOT run: ${why}`);
192
+ // Through `removeTree`: what a failed copy leaves behind is whatever
193
+ // made it fail, and a bare `rmSync` here throws that errno in place of
194
+ // the refusal below — so the caller is told the audit crashed rather
195
+ // than why it declined. A clone we cannot clean up is still a decline,
196
+ // so a leftover is appended to the sentence rather than replacing it.
197
+ const leaked = removeTree(parent);
198
+ throw new Error(
199
+ `audit did NOT run: ${why}` +
200
+ (leaked === null ? "" : ` (and the clone is still on disk: ${parent} — ${leaked})`),
201
+ );
194
202
  };
195
203
 
196
204
  // `-c` asks for an APFS clonefile. It fails on filesystems that cannot do
@@ -206,29 +214,13 @@ export function cloneForRehearsal(root: string): Rehearsal {
206
214
  // on, so no test could ever reach the second branch. One shared helper
207
215
  // removes the ordering rather than testing it.
208
216
  let method: Rehearsal["method"] = "clone";
209
- if (attemptCopy(["-Rc", root, dir], 300_000) !== 0) {
210
- if (attemptCopy(["-R", root, dir], 600_000) !== 0) {
217
+ if (attemptCopy(root, dir, "-Rc", 300_000) !== 0) {
218
+ if (attemptCopy(root, dir, "-R", 600_000) !== 0) {
211
219
  return fail("the tree could not be copied");
212
220
  }
213
221
  method = "copy";
214
222
  }
215
223
 
216
- // Pruning happens through `rmSync(..., { recursive: true })`, which
217
- // follows a symlinked PARENT. `.claude/worktrees` in a tree where
218
- // `.claude -> /real/.claude` therefore resolves outside the clone and
219
- // deletes the consumer's real worktrees — a destructive path traversal
220
- // performed by the mode that promises to write nothing. Found by the
221
- // commit security review.
222
- //
223
- // So nothing is deleted through a symlink. Each excluded path is walked
224
- // component by component; the moment a component is a link, the link
225
- // itself is unlinked (never followed) and the walk stops. `node_modules`
226
- // being a symlink is the common case — the pre-push hook makes one — and
227
- // must stay cheap rather than refusing the audit.
228
- for (const rel of REHEARSAL_EXCLUDES) {
229
- prunePathWithoutFollowingLinks(dir, rel);
230
- }
231
-
232
224
  const missing = missingTopLevel(root, dir);
233
225
  if (missing.length > 0) {
234
226
  return fail(`the copy is incomplete — ${missing.length} top-level entr(ies) missing: ${missing.slice(0, 5).join(", ")}`);
@@ -248,15 +240,157 @@ export function cloneForRehearsal(root: string): Rehearsal {
248
240
  }
249
241
 
250
242
  /**
251
- * Copy into `dir`, having first removed whatever is there.
243
+ * One `cp` invocation. Injectable so a test can record what was copied
244
+ * rather than infer it from the result — "this path is absent from the
245
+ * clone" is true under BOTH orderings, so absence cannot witness the fix.
246
+ */
247
+ export type CopyRunner = (args: string[], timeout: number) => number;
248
+
249
+ const realCp: CopyRunner = (args, timeout) =>
250
+ spawnSync("cp", args, { encoding: "utf-8", timeout }).status ?? 1;
251
+
252
+ /**
253
+ * Copy `src` to `dst`, never reading an excluded path (#549).
254
+ *
255
+ * The exclusion used to be applied AFTER the clone: `cp -R` copied the whole
256
+ * tree and `prunePathWithoutFollowingLinks` then deleted
257
+ * `.claude/worktrees`. On this repository that directory is **737 MB across
258
+ * 104 worktrees**, and the recursive `rm` died with `EFAULT: bad address in
259
+ * system call argument`. So `bunx rungate scaffold .` could not run on
260
+ * rungate — the harness could not scaffold itself, which is SUCCESS.md
261
+ * claim 5 pointed inward. The exclude list was right the whole time; the
262
+ * ORDERING defeated it, and a consumer with a merely LARGE gitignored
263
+ * directory got a preview that silently spent minutes copying files it was
264
+ * about to delete.
265
+ *
266
+ * ## How the level walk works, and why it is not a full recursive copy
267
+ *
268
+ * Only directories that are an ANCESTOR of an exclude are walked. Everything
269
+ * else is handed to `cp` whole, so the APFS clonefile still applies to the
270
+ * subtree and the cost stays bounded by metadata. On this repo that is two
271
+ * walked directories — the root and `.claude` — and one `cp` per top-level
272
+ * entry.
273
+ *
274
+ * ## Symlinks keep the answers `prunePathWithoutFollowingLinks` worked out
275
+ *
276
+ * They were paid for by a commit security review and the reasons have not
277
+ * changed; what changed is that they are now decisions about what to COPY
278
+ * rather than about what to delete, which is strictly safer because a
279
+ * decision not to copy cannot escape the clone.
280
+ *
281
+ * - **An excluded path that is itself a link** (`node_modules -> /elsewhere`,
282
+ * which the pre-push hook creates): skipped. Previously it was copied and
283
+ * then unlinked; now it is never read. Same clone, one fewer traversal.
284
+ * - **A link that is an ANCESTOR of an exclude** (`.claude -> /real/.claude`
285
+ * while excluding `.claude/worktrees`): copied AS A LINK and not descended
286
+ * into. Descending would read the consumer's real tree, and deleting
287
+ * through it is what the old code's `rmSync(..., { recursive: true })`
288
+ * would have done. The link then reaches `escapingSymlinks`, which refuses
289
+ * the audit — which is what an ancestor pointing out of the clone is for.
290
+ *
291
+ * Returns the first non-zero `cp` status, or 0.
292
+ */
293
+ /**
294
+ * Remove a tree we own, clearing what makes a removal refuse first.
295
+ * Returns `null` when the path is gone, or the reason it is not.
296
+ *
297
+ * Two things stop `rm` on a tree this module created, and neither is a
298
+ * permission the owner actually lacks:
252
299
  *
253
- * The clear is unconditional so there is one code path rather than two with
254
- * an ordering between them. See `cloneForRehearsal` for why.
300
+ * - **BSD file flags.** `cp -Rc` is a clonefile and a clonefile carries
301
+ * flags, so a clone of this repo holds the `uchg` files it sets on
302
+ * `gates/prompts/*.md`. `rm` answers "Operation not permitted" and bun
303
+ * reports it as `EFAULT: bad address in system call argument`, naming
304
+ * neither the file nor the flag. That is #549's error message.
305
+ * - **A directory with no owner-read or owner-execute bit.** An unreadable
306
+ * directory is one `cp` cannot copy, so it is exactly what a failed first
307
+ * attempt leaves behind — and `rmSync` cannot list it to empty it. The
308
+ * owner can always chmod it; `rm -rf` never does.
309
+ *
310
+ * Both are best-effort: `chflags` does not exist on Linux, where there are
311
+ * no BSD flags either, and a failing `chmod` is a tree we do not own, which
312
+ * the removal below will report in its own words.
255
313
  */
256
- function attemptCopy(args: string[], timeout: number): number {
257
- const dest = args[args.length - 1]!;
258
- rmSync(dest, { recursive: true, force: true });
259
- return spawnSync("cp", args, { encoding: "utf-8", timeout }).status ?? 1;
314
+ function removeTree(path: string): string | null {
315
+ spawnSync("chflags", ["-R", "nouchg,noschg", path], { timeout: 60_000 });
316
+ spawnSync("chmod", ["-R", "u+rwX", path], { timeout: 60_000 });
317
+ try {
318
+ rmSync(path, { recursive: true, force: true });
319
+ return null;
320
+ } catch (err) {
321
+ if (spawnSync("rm", ["-rf", path], { encoding: "utf-8", timeout: 120_000 }).status === 0) {
322
+ return null;
323
+ }
324
+ return (err as Error).message;
325
+ }
326
+ }
327
+
328
+ export function copyTreeExcluding(
329
+ src: string,
330
+ dst: string,
331
+ excludes: readonly string[],
332
+ cpFlag: string,
333
+ timeout: number,
334
+ run: CopyRunner = realCp,
335
+ ): number {
336
+ // Unconditional, so there is one code path rather than two with an
337
+ // ordering between them: a failed `cp -Rc` may have copied part of the
338
+ // tree, and falling back on top of that leaves a PARTIAL clone whose
339
+ // steps report less than `--fix` will do.
340
+ //
341
+ // Through `removeTree`, not a bare `rmSync`. What the first attempt left
342
+ // behind is whatever made it fail — on Linux CI an unreadable directory
343
+ // `cp -R` could not copy and `rmSync` then cannot remove — and a throw
344
+ // here escapes `cloneForRehearsal` as a raw EACCES instead of its refusal
345
+ // sentence. That is the same defect as the one in `discardRehearsal`
346
+ // below, one function earlier.
347
+ if (removeTree(dst) !== null) return 1;
348
+ const paths = excludes.map(e => e.split("/").filter(Boolean)).filter(p => p.length > 0);
349
+ return copyLevel(src, dst, paths, cpFlag, timeout, run);
350
+ }
351
+
352
+ function copyLevel(
353
+ src: string,
354
+ dst: string,
355
+ excludes: string[][],
356
+ cpFlag: string,
357
+ timeout: number,
358
+ run: CopyRunner,
359
+ ): number {
360
+ mkdirSync(dst, { recursive: true });
361
+ // The mode of a directory we created ourselves rather than let `cp`
362
+ // create. Without this an 0o700 `.claude` becomes 0o755 in the clone, and
363
+ // a step that reads permissions would see a tree that is not the
364
+ // consumer's.
365
+ try { chmodSync(dst, statSync(src).mode & 0o7777); } catch { /* best effort */ }
366
+
367
+ let entries;
368
+ try {
369
+ entries = readdirSync(src, { withFileTypes: true });
370
+ } catch {
371
+ return 1;
372
+ }
373
+
374
+ for (const e of entries) {
375
+ if (excludes.some(p => p.length === 1 && p[0] === e.name)) continue;
376
+ const deeper = excludes.filter(p => p.length > 1 && p[0] === e.name).map(p => p.slice(1));
377
+ // `isDirectory()` is false for a symlink, which is the behaviour this
378
+ // relies on: an ancestor link falls through to the `cp` below and is
379
+ // copied as a link rather than walked.
380
+ if (deeper.length > 0 && e.isDirectory()) {
381
+ const st = copyLevel(join(src, e.name), join(dst, e.name), deeper, cpFlag, timeout, run);
382
+ if (st !== 0) return st;
383
+ continue;
384
+ }
385
+ const st = run([cpFlag, join(src, e.name), join(dst, e.name)], timeout);
386
+ if (st !== 0) return st;
387
+ }
388
+ return 0;
389
+ }
390
+
391
+ /** Copy into `dir`, excluding what the clone does not want. */
392
+ function attemptCopy(root: string, dir: string, cpFlag: string, timeout: number): number {
393
+ return copyTreeExcluding(root, dir, REHEARSAL_EXCLUDES, cpFlag, timeout);
260
394
  }
261
395
 
262
396
  /**
@@ -281,54 +415,54 @@ export function missingTopLevel(root: string, dir: string): string[] {
281
415
  }
282
416
 
283
417
  /**
284
- * Remove `root/rel`, never passing through a symlink on the way.
285
- *
286
- * Two different answers, depending on WHERE the link is:
287
- *
288
- * - **The link is the path itself** (`node_modules -> /elsewhere/mods`):
289
- * unlink it. `rmSync` on a link removes the link and leaves the target
290
- * alone, and an excluded directory is one we did not want in the clone
291
- * anyway. This is the common case — the pre-push hook makes exactly this
292
- * link — and it has to stay cheap rather than refusing the audit.
293
- *
294
- * - **The link is an ANCESTOR** (`.claude -> /real/.claude`, pruning
295
- * `.claude/worktrees`): leave it entirely alone. Unlinking it would throw
296
- * away `.claude` — rules, agents, config — and the steps would then run
297
- * over a tree missing the directory half of them read, reporting less than
298
- * `--fix` will do. That is #398 itself, reintroduced by its own fix. It is
299
- * also invisible to the completeness check, which cannot ask for `.claude`
300
- * back while `.claude/worktrees` is on the exclude list.
301
- *
302
- * Deleting through it is worse still: `rmSync(..., { recursive: true })`
303
- * follows a symlinked parent, so the consumer's real worktrees go. So
304
- * neither — the link stays, and `escapingSymlinks` refuses the audit a
305
- * moment later because an ancestor pointing out of the clone is exactly
306
- * what it is for. Found by the commit security review.
418
+ * Throw the clone away. Safe to call twice. Returns why it could not, or
419
+ * `null`.
420
+ *
421
+ * ## The clone can contain files that refuse to be deleted (#549)
422
+ *
423
+ * `cp -Rc` is a clonefile, and a clonefile carries the source's BSD FILE
424
+ * FLAGS. This repository sets `uchg` on `gates/prompts/*.md` — that is the
425
+ * prompt-immutability feature working as designed — so the clone contains
426
+ * immutable files and `rm` refuses them:
427
+ *
428
+ * ```
429
+ * rm: .../tree/gates/prompts/evidence-validator.md: Operation not permitted
430
+ * ```
431
+ *
432
+ * bun reports that as `EFAULT: bad address in system call argument, rm`,
433
+ * which names neither the file nor the flag, and the THROW took down a
434
+ * scaffold run whose report had already printed. That is the whole of #549's
435
+ * symptom: `bunx rungate scaffold .` could not complete on rungate itself.
436
+ * The 737 MB `.claude/worktrees` directory the issue identified made it
437
+ * slower and held most of the flagged copies, and excluding it from the copy
438
+ * is right and necessary — but the thing `rm` was actually refusing was a
439
+ * flag, not a size.
440
+ *
441
+ * So the flags are cleared in the CLONE before it is removed. Only in the
442
+ * clone: `r.parent` always comes from `mkdtemp`, the consumer's own files
443
+ * are never touched, and the flags are deliberately left intact DURING the
444
+ * rehearsal so the steps see the tree the consumer has rather than a more
445
+ * permissive one.
446
+ *
447
+ * ## A cleanup failure is reported, not thrown
448
+ *
449
+ * The report is already printed by the time this runs. Turning a leaked temp
450
+ * directory into a non-zero exit loses the audit; saying nothing loses the
451
+ * leak, which is #437. So it returns the sentence and the caller prints it.
307
452
  */
308
- function prunePathWithoutFollowingLinks(root: string, rel: string): void {
309
- let current = root;
310
- const parts = rel.split("/").filter(Boolean);
311
- for (let i = 0; i < parts.length; i++) {
312
- current = join(current, parts[i]!);
313
- let st;
314
- try { st = lstatSync(current); } catch { return; } // absent: nothing to prune
315
- const last = i === parts.length - 1;
316
- if (st.isSymbolicLink()) {
317
- if (last) rmSync(current, { force: true });
318
- return; // an ancestor link: prune nothing, and let the refusal catch it
319
- }
320
- if (!last && !st.isDirectory()) return;
321
- }
322
- rmSync(current, { recursive: true, force: true });
323
- }
324
-
325
- /** Throw the clone away. Safe to call twice. */
326
- export function discardRehearsal(r: Rehearsal): void {
453
+ export function discardRehearsal(r: Rehearsal): string | null {
327
454
  // `r.parent`, not `join(r.dir, "..")`. Deriving a deletion target by
328
455
  // walking up from a path is how a cleanup ends up removing something it
329
456
  // does not own; the owner is recorded at creation instead. Leaving the
330
457
  // mkdtemp behind is the leak #437 is about, so it is the parent that goes.
331
- rmSync(r.parent, { recursive: true, force: true });
458
+ //
459
+ // One binding with the copy's own cleanup, so the flag-clearing and the
460
+ // mode-clearing cannot drift apart between the two places that delete a
461
+ // tree this module made.
462
+ const why = removeTree(r.parent);
463
+ if (why === null) return null;
464
+ return `the rehearsal clone could not be removed and is still on disk: ${r.parent} — ` +
465
+ `${why}. Remove it by hand; nothing in the consumer's tree was touched.`;
332
466
  }
333
467
 
334
468
  /**