@indigoai-us/hq-cloud 6.16.49 → 6.16.51-alpha.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/dist/bin/rescue-runner.js +1 -1
  2. package/dist/bin/sync-runner-company.d.ts +6 -0
  3. package/dist/bin/sync-runner-company.d.ts.map +1 -1
  4. package/dist/bin/sync-runner-company.js +30 -1
  5. package/dist/bin/sync-runner-company.js.map +1 -1
  6. package/dist/bin/sync-runner-company.test.js +55 -0
  7. package/dist/bin/sync-runner-company.test.js.map +1 -1
  8. package/dist/bin/sync-runner-planning.d.ts +12 -3
  9. package/dist/bin/sync-runner-planning.d.ts.map +1 -1
  10. package/dist/bin/sync-runner-planning.js +65 -3
  11. package/dist/bin/sync-runner-planning.js.map +1 -1
  12. package/dist/bin/sync-runner-planning.test.js +108 -1
  13. package/dist/bin/sync-runner-planning.test.js.map +1 -1
  14. package/dist/bin/sync-runner-watch-loop.d.ts +48 -2
  15. package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
  16. package/dist/bin/sync-runner-watch-loop.js +281 -113
  17. package/dist/bin/sync-runner-watch-loop.js.map +1 -1
  18. package/dist/bin/sync-runner.d.ts +33 -5
  19. package/dist/bin/sync-runner.d.ts.map +1 -1
  20. package/dist/bin/sync-runner.js +34 -4
  21. package/dist/bin/sync-runner.js.map +1 -1
  22. package/dist/bin/sync-runner.test.js +555 -78
  23. package/dist/bin/sync-runner.test.js.map +1 -1
  24. package/dist/cli/onepass-pull-planner-regressions.test.d.ts +2 -0
  25. package/dist/cli/onepass-pull-planner-regressions.test.d.ts.map +1 -0
  26. package/dist/cli/onepass-pull-planner-regressions.test.js +300 -0
  27. package/dist/cli/onepass-pull-planner-regressions.test.js.map +1 -0
  28. package/dist/cli/onepass-pull-planner.test.d.ts +2 -0
  29. package/dist/cli/onepass-pull-planner.test.d.ts.map +1 -0
  30. package/dist/cli/onepass-pull-planner.test.js +266 -0
  31. package/dist/cli/onepass-pull-planner.test.js.map +1 -0
  32. package/dist/cli/rescue-core.d.ts +0 -29
  33. package/dist/cli/rescue-core.d.ts.map +1 -1
  34. package/dist/cli/rescue-core.js +39 -236
  35. package/dist/cli/rescue-core.js.map +1 -1
  36. package/dist/cli/rescue-rsync-preflight.test.js +4 -256
  37. package/dist/cli/rescue-rsync-preflight.test.js.map +1 -1
  38. package/dist/cli/rescue.d.ts +0 -6
  39. package/dist/cli/rescue.d.ts.map +1 -1
  40. package/dist/cli/rescue.js +0 -12
  41. package/dist/cli/rescue.js.map +1 -1
  42. package/dist/cli/rescue.test.js +0 -6
  43. package/dist/cli/rescue.test.js.map +1 -1
  44. package/dist/cli/share-presign-transport.test.js +0 -2
  45. package/dist/cli/share-presign-transport.test.js.map +1 -1
  46. package/dist/cli/share.d.ts +19 -0
  47. package/dist/cli/share.d.ts.map +1 -1
  48. package/dist/cli/share.js +57 -37
  49. package/dist/cli/share.js.map +1 -1
  50. package/dist/cli/share.test.js +87 -93
  51. package/dist/cli/share.test.js.map +1 -1
  52. package/dist/cli/streaming-pull-planner.bench.test.d.ts +15 -0
  53. package/dist/cli/streaming-pull-planner.bench.test.d.ts.map +1 -0
  54. package/dist/cli/streaming-pull-planner.bench.test.js +273 -0
  55. package/dist/cli/streaming-pull-planner.bench.test.js.map +1 -0
  56. package/dist/cli/sync-scope.test.js +8 -0
  57. package/dist/cli/sync-scope.test.js.map +1 -1
  58. package/dist/cli/sync.d.ts +12 -0
  59. package/dist/cli/sync.d.ts.map +1 -1
  60. package/dist/cli/sync.js +226 -118
  61. package/dist/cli/sync.js.map +1 -1
  62. package/dist/cli/sync.test.js +215 -2
  63. package/dist/cli/sync.test.js.map +1 -1
  64. package/dist/cli/watch-event-push-conflict.test.js +0 -2
  65. package/dist/cli/watch-event-push-conflict.test.js.map +1 -1
  66. package/dist/cognito-auth.d.ts +0 -30
  67. package/dist/cognito-auth.d.ts.map +1 -1
  68. package/dist/cognito-auth.js +0 -175
  69. package/dist/cognito-auth.js.map +1 -1
  70. package/dist/index.d.ts +2 -2
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +1 -1
  73. package/dist/index.js.map +1 -1
  74. package/dist/journal-store.test.js +130 -7
  75. package/dist/journal-store.test.js.map +1 -1
  76. package/dist/journal.d.ts +9 -1
  77. package/dist/journal.d.ts.map +1 -1
  78. package/dist/journal.js +30 -21
  79. package/dist/journal.js.map +1 -1
  80. package/dist/lib/exit-codes.d.ts +15 -0
  81. package/dist/lib/exit-codes.d.ts.map +1 -1
  82. package/dist/lib/exit-codes.js +15 -0
  83. package/dist/lib/exit-codes.js.map +1 -1
  84. package/dist/machine-auth.test.js +0 -295
  85. package/dist/machine-auth.test.js.map +1 -1
  86. package/dist/object-io.d.ts +2 -2
  87. package/dist/object-io.d.ts.map +1 -1
  88. package/dist/object-io.js +3 -18
  89. package/dist/object-io.js.map +1 -1
  90. package/dist/personal-vault.d.ts.map +1 -1
  91. package/dist/personal-vault.js +10 -3
  92. package/dist/personal-vault.js.map +1 -1
  93. package/dist/personal-vault.test.js +35 -0
  94. package/dist/personal-vault.test.js.map +1 -1
  95. package/dist/remote-pull.d.ts.map +1 -1
  96. package/dist/remote-pull.js +9 -2
  97. package/dist/remote-pull.js.map +1 -1
  98. package/dist/remote-pull.test.js +59 -2
  99. package/dist/remote-pull.test.js.map +1 -1
  100. package/dist/s3.d.ts +1 -18
  101. package/dist/s3.d.ts.map +1 -1
  102. package/dist/s3.js +24 -47
  103. package/dist/s3.js.map +1 -1
  104. package/dist/s3.list-cost.test.d.ts +2 -0
  105. package/dist/s3.list-cost.test.d.ts.map +1 -0
  106. package/dist/s3.list-cost.test.js +51 -0
  107. package/dist/s3.list-cost.test.js.map +1 -0
  108. package/dist/s3.test.js +1 -27
  109. package/dist/s3.test.js.map +1 -1
  110. package/dist/sync/realtime-telemetry.d.ts +1 -1
  111. package/dist/sync/realtime-telemetry.d.ts.map +1 -1
  112. package/dist/sync/realtime-telemetry.js +14 -6
  113. package/dist/sync/realtime-telemetry.js.map +1 -1
  114. package/dist/sync/realtime-telemetry.test.js +136 -16
  115. package/dist/sync/realtime-telemetry.test.js.map +1 -1
  116. package/dist/sync/remote-file-spool.d.ts +16 -0
  117. package/dist/sync/remote-file-spool.d.ts.map +1 -0
  118. package/dist/sync/remote-file-spool.js +91 -0
  119. package/dist/sync/remote-file-spool.js.map +1 -0
  120. package/dist/sync/remote-file-spool.test.d.ts +2 -0
  121. package/dist/sync/remote-file-spool.test.d.ts.map +1 -0
  122. package/dist/sync/remote-file-spool.test.js +77 -0
  123. package/dist/sync/remote-file-spool.test.js.map +1 -0
  124. package/dist/sync-core.d.ts +4 -6
  125. package/dist/sync-core.d.ts.map +1 -1
  126. package/dist/sync-core.js +4 -10
  127. package/dist/sync-core.js.map +1 -1
  128. package/dist/sync-core.test.js +1 -25
  129. package/dist/sync-core.test.js.map +1 -1
  130. package/package.json +2 -1
  131. package/dist/cli/rescue-breaker.test.d.ts +0 -2
  132. package/dist/cli/rescue-breaker.test.d.ts.map +0 -1
  133. package/dist/cli/rescue-breaker.test.js +0 -314
  134. package/dist/cli/rescue-breaker.test.js.map +0 -1
  135. package/dist/cli/rescue-realpath.test.d.ts +0 -2
  136. package/dist/cli/rescue-realpath.test.d.ts.map +0 -1
  137. package/dist/cli/rescue-realpath.test.js +0 -109
  138. package/dist/cli/rescue-realpath.test.js.map +0 -1
  139. package/dist/cli/rescue-source-switch-floor.test.d.ts +0 -2
  140. package/dist/cli/rescue-source-switch-floor.test.d.ts.map +0 -1
  141. package/dist/cli/rescue-source-switch-floor.test.js +0 -210
  142. package/dist/cli/rescue-source-switch-floor.test.js.map +0 -1
@@ -18,8 +18,6 @@ interface Config {
18
18
  backupRoot: string;
19
19
  backupRetentionDays: string;
20
20
  backupRetentionCount: string;
21
- /** Move recovery-required snapshots aside and continue (`--resolve-recovery-snapshots`). */
22
- resolveRecoverySnapshots: boolean;
23
21
  }
24
22
  /** Read an environment value without relying on Windows' case-insensitive proxy. */
25
23
  export declare function envValue(env: NodeJS.ProcessEnv, name: string): string | undefined;
@@ -29,17 +27,6 @@ export declare function envValue(env: NodeJS.ProcessEnv, name: string): string |
29
27
  * drive roots explicitly instead of relying on Cygwin's native-path fallback.
30
28
  */
31
29
  export declare function toCygwinRsyncPath(localPath: string): string;
32
- interface RsyncPathCandidate {
33
- path: string;
34
- executable: boolean;
35
- }
36
- interface RsyncLauncher {
37
- command: string;
38
- leadingArgs: string[];
39
- }
40
- export declare function findRsyncOnPath(entries: string[], env: NodeJS.ProcessEnv): RsyncPathCandidate | undefined;
41
- /** The overlay requires rsync; do not allocate a recovery copy when it cannot run. */
42
- export declare function requireWorkingRsync(env: NodeJS.ProcessEnv, err: (s: string) => void): RsyncLauncher;
43
30
  /**
44
31
  * Parse the rescue argv exactly as the bash `while case` loop did, including
45
32
  * validation and the same exit codes (1 unknown/usage, 2 bad option). Throws
@@ -67,13 +54,6 @@ export declare function runRescue(argv: string[], opts?: {
67
54
  * absolute.
68
55
  */
69
56
  export declare function isUsableRescueRoot(root: string, platformPath?: path.PlatformPath): boolean;
70
- /**
71
- * Canonicalize the rescue root without treating a known-good directory as
72
- * unusable when Node's JavaScript realpath walker cannot inspect a Windows
73
- * drive prefix. Prefer the native syscall, retain the JS walker as a fallback,
74
- * and use an absolute path only after stat confirms it is a directory.
75
- */
76
- export declare function realpathOrExit(p: string, err: (s: string) => void): string;
77
57
  export type RescueDecision = {
78
58
  kind: "skip";
79
59
  rel: string;
@@ -207,14 +187,5 @@ interface ReconcileCtx {
207
187
  * rescue's posture elsewhere.
208
188
  */
209
189
  export declare function reconcileClaudeSettings(ctx: ReconcileCtx, preRescueSettingsJson: string | null, out: (s: string) => void, err: (s: string) => void): void;
210
- /**
211
- * Paths the current process cannot write among the action plan's rename/delete
212
- * sources (and their parents) plus rename destination parents. Empty means the
213
- * plan is writable; a non-empty result must refuse before allocating a snapshot.
214
- */
215
- export declare function collectUnwritableRescueMutationPaths(hqRoot: string, actions: ReadonlyArray<{
216
- affectedRels: readonly string[];
217
- destParentRels?: readonly string[];
218
- }>): string[];
219
190
  export {};
220
191
  //# sourceMappingURL=rescue-core.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rescue-core.d.ts","sourceRoot":"","sources":["../../src/cli/rescue-core.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAa7B,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AA0CD,UAAU,MAAM;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,4FAA4F;IAC5F,wBAAwB,EAAE,OAAO,CAAC;CACnC;AA6CD,oFAAoF;AACpF,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CASpB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAS3D;AA0BD,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,aAAa;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE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E,CAAC;CAC5B;AAeD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,YAAY,EACjB,qBAAqB,EAAE,MAAM,GAAG,IAAI,EACpC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,EACxB,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,GACvB,IAAI,CA8LN"}
@@ -148,26 +148,10 @@ function boundedDiagnostic(value, limit) {
148
148
  function pathEntries(pathValue) {
149
149
  return pathValue ? pathValue.split(path.delimiter) : [];
150
150
  }
151
- const DEFAULT_WINDOWS_EXECUTABLE_EXTENSIONS = [".COM", ".EXE", ".BAT", ".CMD"];
152
- function rsyncCandidateNames(env) {
153
- if (process.platform !== "win32")
154
- return ["rsync", "rsync.exe"];
155
- const configuredExtensions = envValue(env, "PATHEXT")
156
- ?.split(";")
157
- .map((extension) => extension.trim())
158
- .filter((extension) => /^\.[A-Za-z0-9]+$/.test(extension));
159
- const extensions = [
160
- ...(configuredExtensions?.length
161
- ? configuredExtensions
162
- : DEFAULT_WINDOWS_EXECUTABLE_EXTENSIONS),
163
- ...DEFAULT_WINDOWS_EXECUTABLE_EXTENSIONS,
164
- ];
165
- return [...new Set(["rsync", ...extensions.map((extension) => `rsync${extension.toLowerCase()}`)])];
166
- }
167
- export function findRsyncOnPath(entries, env) {
151
+ function findRsyncOnPath(entries) {
168
152
  let firstUnexecutable;
169
153
  for (const entry of entries) {
170
- for (const name of rsyncCandidateNames(env)) {
154
+ for (const name of ["rsync", "rsync.exe"]) {
171
155
  const candidate = path.resolve(entry || ".", name);
172
156
  try {
173
157
  if (!fs.statSync(candidate).isFile())
@@ -190,22 +174,14 @@ export function findRsyncOnPath(entries, env) {
190
174
  : undefined;
191
175
  }
192
176
  /** The overlay requires rsync; do not allocate a recovery copy when it cannot run. */
193
- export function requireWorkingRsync(env, err) {
177
+ function requireWorkingRsync(env, err) {
194
178
  const resolvedPath = envValue(env, "PATH");
195
179
  const entries = pathEntries(resolvedPath);
196
- const foundRsync = findRsyncOnPath(entries, env);
197
- // Node documents that Windows .cmd/.bat files require cmd.exe rather than a
198
- // direct child-process launch. Keep the path and fixed argument as distinct
199
- // arguments instead of enabling shell:true for a constructed command string.
200
- const launcher = process.platform === "win32" && /\.(?:cmd|bat)$/i.test(foundRsync?.path ?? "")
201
- ? { command: "cmd.exe", leadingArgs: ["/d", "/s", "/c", foundRsync.path] }
202
- : { command: "rsync", leadingArgs: [] };
203
- const probe = runWithSpawnError(launcher.command, [...launcher.leadingArgs, "--version"], {
204
- env,
205
- });
180
+ const foundRsync = findRsyncOnPath(entries);
181
+ const probe = runWithSpawnError("rsync", ["--version"], { env });
206
182
  const output = `${probe.stdout}\n${probe.stderr}`;
207
183
  if (probe.status === 0 && /\brsync\b.*\bversion\b/i.test(output))
208
- return launcher;
184
+ return;
209
185
  err("error: rsync preflight failed before any safety snapshot was allocated.\n");
210
186
  if (probe.error) {
211
187
  const errorDetail = "code" in probe.error && typeof probe.error.code === "string"
@@ -327,7 +303,6 @@ export function parseRescueArgs(argv) {
327
303
  backupRoot: process.env.HQ_BACKUP_DIR || path.join(os.homedir(), ".hq", "backups"),
328
304
  backupRetentionDays: process.env.HQ_BACKUP_RETENTION_DAYS || "7",
329
305
  backupRetentionCount: process.env.HQ_BACKUP_RETENTION_COUNT || "2",
330
- resolveRecoverySnapshots: false,
331
306
  };
332
307
  const usage = () => {
333
308
  // The legacy script printed its comment header here; we emit a concise
@@ -336,7 +311,7 @@ export function parseRescueArgs(argv) {
336
311
  " [--preserve PATH]... [--preserve-subpath REL]...\n" +
337
312
  " [--hq-root DIR] [--no-history-check] [--floor-sha SHA]\n" +
338
313
  " [--no-backup] [--backup-dir DIR] [--cloud-update]\n" +
339
- " [--resolve-recovery-snapshots] [--dry-run] [--yes]\n");
314
+ " [--dry-run] [--yes]\n");
340
315
  throw new ExitError(1);
341
316
  };
342
317
  let narrowCsv = "";
@@ -385,9 +360,6 @@ export function parseRescueArgs(argv) {
385
360
  case "--backup-dir":
386
361
  cfg.backupRoot = need(a);
387
362
  break;
388
- case "--resolve-recovery-snapshots":
389
- cfg.resolveRecoverySnapshots = true;
390
- break;
391
363
  case "--dry-run":
392
364
  cfg.dryRun = true;
393
365
  break;
@@ -511,33 +483,17 @@ export function isUsableRescueRoot(root, platformPath = path) {
511
483
  return platformPath.isAbsolute(root);
512
484
  }
513
485
  /**
514
- * Canonicalize the rescue root without treating a known-good directory as
515
- * unusable when Node's JavaScript realpath walker cannot inspect a Windows
516
- * drive prefix. Prefer the native syscall, retain the JS walker as a fallback,
517
- * and use an absolute path only after stat confirms it is a directory.
486
+ * `fs.realpathSync` that converts failure into the rescue's clean error path
487
+ * (message + ExitError) instead of an uncaught exception. An uncaught throw
488
+ * here is what turned one bad `--hq-root` into a daily crash-loop on Windows.
518
489
  */
519
- export function realpathOrExit(p, err) {
490
+ function realpathOrExit(p, err) {
520
491
  try {
521
- return fs.realpathSync.native(p);
492
+ return fs.realpathSync(p);
522
493
  }
523
- catch {
524
- try {
525
- return fs.realpathSync(p);
526
- }
527
- catch (realpathError) {
528
- const resolved = path.resolve(p);
529
- try {
530
- if (!fs.statSync(resolved).isDirectory()) {
531
- throw new Error("resolved path is not a directory");
532
- }
533
- }
534
- catch {
535
- err(`error: cannot resolve --hq-root ${p}: ${realpathError instanceof Error ? realpathError.message : String(realpathError)}\n`);
536
- throw new ExitError(1);
537
- }
538
- err("warning: could not canonicalize --hq-root; using a normalized absolute path.\n");
539
- return resolved;
540
- }
494
+ catch (e) {
495
+ err(`error: cannot resolve --hq-root ${p}: ${e instanceof Error ? e.message : String(e)}\n`);
496
+ throw new ExitError(1);
541
497
  }
542
498
  }
543
499
  function doRescue(cfg, env, out, err, setTmp) {
@@ -592,7 +548,7 @@ function doRescue(cfg, env, out, err, setTmp) {
592
548
  // Both the release overlay and a restorable snapshot require rsync. A shim
593
549
  // which merely starts but exits non-zero used to trigger an enormous cp -a
594
550
  // fallback, then fail later at overlay. Stop before classification/allocation.
595
- const rsyncLauncher = requireWorkingRsync(env, err);
551
+ requireWorkingRsync(env, err);
596
552
  // --- Capture the pre-rescue .claude/settings.json (BEFORE the wipe) ---
597
553
  // This is `ours` for the post-overlay settings reconcile. It must be read now
598
554
  // because the overlay-safe classification deletes/overwrites it before
@@ -626,9 +582,8 @@ function doRescue(cfg, env, out, err, setTmp) {
626
582
  prevSyncRef = yq('.replaced_from_source.ref // .replaced_from_staging.ref // ""');
627
583
  prevSyncAt = yq('.replaced_from_source.last_sync_at // .replaced_from_staging.last_sync_at // ""');
628
584
  }
629
- // An explicit caller floor is the recovery path for a missing or stale stamp.
630
- // It remains safe because the selected release clone must still contain it.
631
- if (cfg.floorShaOverride) {
585
+ // Caller override (--floor-sha) wins only when the on-disk stamp is empty.
586
+ if (!prevSyncSha && cfg.floorShaOverride) {
632
587
  prevSyncSha = cfg.floorShaOverride;
633
588
  prevSyncSource = cfg.sourceRepo;
634
589
  prevSyncRef = "(caller-supplied floor)";
@@ -637,8 +592,12 @@ function doRescue(cfg, env, out, err, setTmp) {
637
592
  out(`==> HQ root: ${hqRoot}\n`);
638
593
  out(`==> Source: https://github.com/${cfg.sourceRepo} @ ${cfg.ref}\n`);
639
594
  if (prevSyncSha) {
640
- const sourceLabel = prevSyncSource || "(source not recorded)";
641
- out(`==> Prior sync: ${prevSyncSha} from ${sourceLabel}@${prevSyncRef} (${prevSyncAt}) — checking cloned release history for floor\n`);
595
+ if (prevSyncSource === cfg.sourceRepo) {
596
+ out(`==> Prior sync: ${prevSyncSha} from ${prevSyncSource}@${prevSyncRef} (${prevSyncAt}) — will use as history floor\n`);
597
+ }
598
+ else {
599
+ out(`==> Prior sync: ${prevSyncSha} from ${prevSyncSource} (different source — ignoring as floor)\n`);
600
+ }
642
601
  }
643
602
  if (cfg.narrowPaths.length !== 0) {
644
603
  out("==> Mode: narrow (--paths)\n");
@@ -794,22 +753,21 @@ function doRescue(cfg, env, out, err, setTmp) {
794
753
  // --- Resolve history floor ---
795
754
  let historyFloor = "";
796
755
  let baselineMode = "head_compare";
797
- if (cfg.historyCheck && prevSyncSha) {
756
+ if (cfg.historyCheck && prevSyncSha && prevSyncSource === cfg.sourceRepo) {
798
757
  if (run("git", ["cat-file", "-e", prevSyncSha], { cwd: srcDir, env })
799
758
  .status === 0) {
800
759
  historyFloor = prevSyncSha;
801
760
  baselineMode = "history_floor";
802
761
  }
803
762
  else {
804
- out(` WARN: prior-sync SHA ${prevSyncSha} is not reachable in the cloned release history; falling back to head_compare\n`);
763
+ out(` prior-sync SHA ${prevSyncSha} not reachable in clone (rebased/dropped?); falling back to head_compare\n`);
805
764
  }
806
765
  }
807
766
  if (baselineMode === "history_floor") {
808
767
  out(`==> Baseline: ${historyFloor} (last-sync floor reachable)\n`);
809
768
  }
810
769
  else {
811
- out("==> Baseline: HEAD compare (no usable reachable last-sync floor)\n");
812
- out("==> WARNING: retired release files cannot be detected or removed in head_compare mode. Re-run with history checking and --floor-sha <sha> for a reachable baseline.\n");
770
+ out("==> Baseline: HEAD compare (no usable last-sync stamp; first-ever run or stamp mismatch)\n");
813
771
  }
814
772
  // --- Build wipe/overlay arg sets per mode ---
815
773
  const pruneNames = [];
@@ -934,7 +892,7 @@ function doRescue(cfg, env, out, err, setTmp) {
934
892
  if (cfg.dryRun) {
935
893
  out("\n");
936
894
  out("==> DRY RUN classification summary:\n");
937
- out(` user-only (left in place under release-managed roots): ${counts.userOnly} files\n`);
895
+ out(` user-only (leave in place): ${counts.userOnly} files\n`);
938
896
  out(` unchanged (preserved/re-laid): ${counts.unchanged} files\n`);
939
897
  out(` user-edit (rescue / diff-append): ${counts.userEdit} files\n`);
940
898
  out(` user-edit (conflict quarantine): ${counts.userConflict} files\n`);
@@ -1010,21 +968,12 @@ function doRescue(cfg, env, out, err, setTmp) {
1010
968
  ];
1011
969
  // Exercise the exact overlay command before any classified delete/move. A
1012
970
  // Cygwin path conversion or filter failure therefore leaves the root intact.
1013
- const overlayPreflight = run(rsyncLauncher.command, [...rsyncLauncher.leadingArgs, "--dry-run", ...overlayArgs], { env });
971
+ const overlayPreflight = run("rsync", ["--dry-run", ...overlayArgs], { env });
1014
972
  if (overlayPreflight.status !== 0) {
1015
973
  err(overlayPreflight.stderr);
1016
974
  throw new ExitError(overlayPreflight.status || 1);
1017
975
  }
1018
976
  ctx.actions = buildRescueActions(ctx);
1019
- // Permission preflight is deliberately before snapshot allocation. A
1020
- // root-owned release tree (EACCES on rename/delete) used to allocate a
1021
- // snapshot, fail apply twice, and then freeze rescue behind the
1022
- // recovery-required circuit breaker. Fail closed with no snapshot instead.
1023
- const unwritable = collectUnwritableRescueMutationPaths(hqRoot, ctx.actions);
1024
- if (unwritable.length > 0) {
1025
- reportUnwritableRescuePaths(hqRoot, unwritable, err);
1026
- throw new ExitError(1);
1027
- }
1028
977
  // Snapshot allocation is deliberately after the entire read-only walk and
1029
978
  // action-plan build. A no-op (or a classifier fault above) cannot consume
1030
979
  // backup space.
@@ -1038,15 +987,9 @@ function doRescue(cfg, env, out, err, setTmp) {
1038
987
  const prePlan = pruneManagedBackups(cfg, hqRoot, out, false);
1039
988
  const unresolved = prePlan.protected.filter((x) => x.reason === "recovery-required-no-later-good");
1040
989
  if (unresolved.length >= 2) {
1041
- const snapshotNames = unresolved.map((x) => x.entry.name);
1042
- writeRescueBlockedMarker(hqRoot, snapshotNames);
1043
- if (!cfg.resolveRecoverySnapshots) {
1044
- err("error: safety snapshot circuit breaker is open: two unresolved recovery-required snapshots exist.\n");
1045
- err(" Inspect/restore those snapshots and repair the release source before retrying (operator override required).\n");
1046
- err(" Re-run with --resolve-recovery-snapshots to move those snapshot directories aside (never deleted) and continue.\n");
1047
- throw new ExitError(1);
1048
- }
1049
- resolveRecoveryRequiredSnapshots(cfg.backupRoot, RUN_TS, snapshotNames, out);
990
+ err("error: safety snapshot circuit breaker is open: two unresolved recovery-required snapshots exist.\n");
991
+ err(" Inspect/restore those snapshots and repair the release source before retrying (operator override required).\n");
992
+ throw new ExitError(1);
1050
993
  }
1051
994
  requireBackupCapacity(cfg, hqRoot, wipeToplevel, env, err);
1052
995
  fs.mkdirSync(cfg.backupRoot, { recursive: true });
@@ -1110,7 +1053,7 @@ function doRescue(cfg, env, out, err, setTmp) {
1110
1053
  toCygwinRsyncPath(hqRoot + "/"),
1111
1054
  ]
1112
1055
  : overlayArgs;
1113
- const overlay = run(rsyncLauncher.command, [...rsyncLauncher.leadingArgs, ...overlayRunArgs], { env });
1056
+ const overlay = run("rsync", overlayRunArgs, { env });
1114
1057
  if (overlay.status !== 0) {
1115
1058
  // bash runs under set -e: a failed rsync aborts with its status.
1116
1059
  err(overlay.stderr);
@@ -1251,7 +1194,7 @@ function doRescue(cfg, env, out, err, setTmp) {
1251
1194
  }
1252
1195
  out("\n");
1253
1196
  out("==> Classification:\n");
1254
- out(` user-only (left in place under release-managed roots): ${counts.userOnly} files\n`);
1197
+ out(` user-only (left in place): ${counts.userOnly} files\n`);
1255
1198
  out(` unchanged (preserved/re-laid): ${counts.unchanged} files\n`);
1256
1199
  out(` user-edits (rescued): ${counts.userEdit} files\n`);
1257
1200
  out(` user-edits (conflict quarantine): ${counts.userConflict} files\n`);
@@ -1286,7 +1229,7 @@ function doRescue(cfg, env, out, err, setTmp) {
1286
1229
  lines.push("Baseline: head_compare (no last-sync stamp; first run or floor unreachable)");
1287
1230
  }
1288
1231
  lines.push("", "## What the rescue did");
1289
- lines.push(` user-only (left in place under release-managed roots): ${counts.userOnly}`);
1232
+ lines.push(` user-only (left in place): ${counts.userOnly}`);
1290
1233
  lines.push(` unchanged (preserved/re-laid): ${counts.unchanged}`);
1291
1234
  lines.push(` user-edit (rescued into personal/): ${counts.userEdit}`);
1292
1235
  lines.push(` user-edit (conflict quarantine): ${counts.userConflict}`);
@@ -1338,7 +1281,6 @@ function doRescue(cfg, env, out, err, setTmp) {
1338
1281
  if (cfg.doBackup && backupDir) {
1339
1282
  out(` A filtered pre-update snapshot is at ${backupDir} (RECOVERY.md explains restore).\n`);
1340
1283
  }
1341
- clearRescueBlockedMarker(hqRoot);
1342
1284
  return { status: 0 };
1343
1285
  }
1344
1286
  catch (error) {
@@ -2430,11 +2372,10 @@ function renderDryRunDecision(ctx, decision) {
2430
2372
  }
2431
2373
  function buildRescueActions(ctx) {
2432
2374
  const actions = [];
2433
- const add = (label, affectedRels, runAction, destParentRels = []) => {
2375
+ const add = (label, affectedRels, runAction) => {
2434
2376
  actions.push({
2435
2377
  label,
2436
2378
  affectedRels,
2437
- destParentRels,
2438
2379
  expectedPaths: affectedRels.map((rel) => ({
2439
2380
  rel,
2440
2381
  kind: rescuePathKind(path.join(ctx.hqRoot, rel)),
@@ -2473,7 +2414,7 @@ function buildRescueActions(ctx) {
2473
2414
  });
2474
2415
  break;
2475
2416
  case "user-edit-diff-append":
2476
- add(`rescue diff-append: ${decision.rel}`, [decision.rel], () => rescueOne(ctx, decision.rel), [path.posix.dirname(mapRescueTarget(decision.rel))]);
2417
+ add(`rescue diff-append: ${decision.rel}`, [decision.rel], () => rescueOne(ctx, decision.rel));
2477
2418
  break;
2478
2419
  case "user-edit-overwrite-safe":
2479
2420
  add(`overwrite-safe: ${decision.rel}`, [decision.rel], () => {
@@ -2494,12 +2435,10 @@ function buildRescueActions(ctx) {
2494
2435
  });
2495
2436
  break;
2496
2437
  case "user-edit-conflict":
2497
- add(`conflict quarantine: ${decision.rel}`, [decision.rel], () => conflictOne(ctx, decision.rel), [
2498
- path.posix.dirname(`.hq-conflicts/rescue-${ctx.runTs}/${decision.rel}`),
2499
- ]);
2438
+ add(`conflict quarantine: ${decision.rel}`, [decision.rel], () => conflictOne(ctx, decision.rel));
2500
2439
  break;
2501
2440
  case "user-edit-rescue":
2502
- add(`rescue: ${decision.rel}`, [decision.rel], () => rescueOne(ctx, decision.rel), [path.posix.dirname(mapRescueTarget(decision.rel))]);
2441
+ add(`rescue: ${decision.rel}`, [decision.rel], () => rescueOne(ctx, decision.rel));
2503
2442
  break;
2504
2443
  case "unchanged-preserve":
2505
2444
  add(`preserve unchanged: ${decision.rel}`, [], () => {
@@ -2772,142 +2711,6 @@ function restoreMtimesFromGit(srcDir, env, out) {
2772
2711
  }
2773
2712
  }
2774
2713
  }
2775
- const RESCUE_BLOCKED_MARKER_REL = ".hq/rescue-blocked.json";
2776
- const RESCUE_BLOCKED_REASON = "recovery-snapshot-breaker";
2777
- function posixRelFromRoot(hqRoot, abs) {
2778
- const root = path.resolve(hqRoot);
2779
- const resolved = path.resolve(abs);
2780
- if (resolved === root)
2781
- return ".";
2782
- const prefix = root.endsWith(path.sep) ? root : root + path.sep;
2783
- if (resolved.startsWith(prefix)) {
2784
- return resolved.slice(prefix.length).split(path.sep).join("/");
2785
- }
2786
- return resolved;
2787
- }
2788
- function firstExistingAncestor(abs) {
2789
- let current = abs;
2790
- for (;;) {
2791
- if (lexists(current))
2792
- return current;
2793
- const parent = path.dirname(current);
2794
- if (parent === current)
2795
- return null;
2796
- current = parent;
2797
- }
2798
- }
2799
- function canWrite(abs) {
2800
- try {
2801
- fs.accessSync(abs, fs.constants.W_OK);
2802
- return true;
2803
- }
2804
- catch {
2805
- return false;
2806
- }
2807
- }
2808
- function topLevelRel(rel) {
2809
- const normalized = rel.replace(/\\/g, "/").replace(/^\.\//, "");
2810
- if (normalized === "." || normalized === "")
2811
- return ".";
2812
- return normalized.split("/")[0] ?? ".";
2813
- }
2814
- /**
2815
- * Paths the current process cannot write among the action plan's rename/delete
2816
- * sources (and their parents) plus rename destination parents. Empty means the
2817
- * plan is writable; a non-empty result must refuse before allocating a snapshot.
2818
- */
2819
- export function collectUnwritableRescueMutationPaths(hqRoot, actions) {
2820
- const failed = new Set();
2821
- const note = (abs) => {
2822
- failed.add(posixRelFromRoot(hqRoot, abs));
2823
- };
2824
- const checkParent = (abs) => {
2825
- const existing = firstExistingAncestor(abs);
2826
- if (!existing || !canWrite(existing))
2827
- note(existing ?? abs);
2828
- };
2829
- for (const action of actions) {
2830
- for (const rel of action.affectedRels) {
2831
- if (!rel)
2832
- continue;
2833
- const abs = path.join(hqRoot, rel);
2834
- const st = lstatOrNull(abs);
2835
- if (st && !st.isSymbolicLink() && !canWrite(abs))
2836
- note(abs);
2837
- checkParent(path.dirname(abs));
2838
- }
2839
- for (const rel of action.destParentRels ?? []) {
2840
- if (!rel || rel === ".")
2841
- continue;
2842
- checkParent(path.join(hqRoot, rel));
2843
- }
2844
- }
2845
- return [...failed].sort();
2846
- }
2847
- function reportUnwritableRescuePaths(hqRoot, unwritable, err) {
2848
- const shown = unwritable.slice(0, 10);
2849
- err("error: cannot write the paths rescue would rename or delete (permission denied).\n");
2850
- err(" Refusing before a safety snapshot is allocated so this cannot trip the recovery-snapshot circuit breaker.\n");
2851
- err(unwritable.length > 10
2852
- ? ` Unwritable paths (showing 10 of ${unwritable.length}):\n`
2853
- : " Unwritable paths:\n");
2854
- for (const rel of shown)
2855
- err(` ${rel}\n`);
2856
- const uid = typeof process.getuid === "function" ? String(process.getuid()) : "<uid>";
2857
- const gid = typeof process.getgid === "function" ? String(process.getgid()) : "<gid>";
2858
- const tops = [
2859
- ...new Set(unwritable.map((rel) => topLevelRel(rel)).filter((top) => top !== ".")),
2860
- ].sort();
2861
- err(" Repair ownership, then retry:\n");
2862
- if (tops.length === 0) {
2863
- err(` chown -R ${uid}:${gid} ${hqRoot}\n`);
2864
- }
2865
- else {
2866
- for (const top of tops) {
2867
- err(` chown -R ${uid}:${gid} ${path.join(hqRoot, top)}\n`);
2868
- }
2869
- }
2870
- }
2871
- function rescueBlockedMarkerPath(hqRoot) {
2872
- return path.join(hqRoot, RESCUE_BLOCKED_MARKER_REL);
2873
- }
2874
- function writeRescueBlockedMarker(hqRoot, snapshots) {
2875
- const body = {
2876
- at: new Date().toISOString(),
2877
- reason: RESCUE_BLOCKED_REASON,
2878
- snapshots,
2879
- hint: "Inspect/restore those snapshots and repair the release source before retrying, or re-run with --resolve-recovery-snapshots (moves the snapshot directories aside under <backup-dir>-resolved-<timestamp>/; never deletes).",
2880
- };
2881
- try {
2882
- fs.mkdirSync(path.dirname(rescueBlockedMarkerPath(hqRoot)), {
2883
- recursive: true,
2884
- });
2885
- fs.writeFileSync(rescueBlockedMarkerPath(hqRoot), JSON.stringify(body, null, 2) + "\n");
2886
- }
2887
- catch {
2888
- /* stderr remains the operator-facing signal if .hq is unwritable */
2889
- }
2890
- }
2891
- function clearRescueBlockedMarker(hqRoot) {
2892
- try {
2893
- fs.unlinkSync(rescueBlockedMarkerPath(hqRoot));
2894
- }
2895
- catch {
2896
- /* absent is the success state */
2897
- }
2898
- }
2899
- function resolveRecoveryRequiredSnapshots(backupRoot, runTs, names, out) {
2900
- const destRoot = `${backupRoot}-resolved-${runTs}`;
2901
- fs.mkdirSync(destRoot, { recursive: true });
2902
- out(`==> Resolving recovery-required snapshots (--resolve-recovery-snapshots) -> ${destRoot}\n`);
2903
- for (const name of names) {
2904
- const from = path.join(backupRoot, name);
2905
- const to = path.join(destRoot, name);
2906
- fs.renameSync(from, to);
2907
- out(` moved ${name} -> ${to}\n`);
2908
- }
2909
- return destRoot;
2910
- }
2911
2714
  function allocateSnapshotDir(backupRoot, runTs, rootHash, runId) {
2912
2715
  return path.join(backupRoot, `pre-update-${runTs}-${rootHash}-${runId}`);
2913
2716
  }