@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.
- package/dist/bin/rescue-runner.js +1 -1
- package/dist/bin/sync-runner-company.d.ts +6 -0
- package/dist/bin/sync-runner-company.d.ts.map +1 -1
- package/dist/bin/sync-runner-company.js +30 -1
- package/dist/bin/sync-runner-company.js.map +1 -1
- package/dist/bin/sync-runner-company.test.js +55 -0
- package/dist/bin/sync-runner-company.test.js.map +1 -1
- package/dist/bin/sync-runner-planning.d.ts +12 -3
- package/dist/bin/sync-runner-planning.d.ts.map +1 -1
- package/dist/bin/sync-runner-planning.js +65 -3
- package/dist/bin/sync-runner-planning.js.map +1 -1
- package/dist/bin/sync-runner-planning.test.js +108 -1
- package/dist/bin/sync-runner-planning.test.js.map +1 -1
- package/dist/bin/sync-runner-watch-loop.d.ts +48 -2
- package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
- package/dist/bin/sync-runner-watch-loop.js +281 -113
- package/dist/bin/sync-runner-watch-loop.js.map +1 -1
- package/dist/bin/sync-runner.d.ts +33 -5
- package/dist/bin/sync-runner.d.ts.map +1 -1
- package/dist/bin/sync-runner.js +34 -4
- package/dist/bin/sync-runner.js.map +1 -1
- package/dist/bin/sync-runner.test.js +555 -78
- package/dist/bin/sync-runner.test.js.map +1 -1
- package/dist/cli/onepass-pull-planner-regressions.test.d.ts +2 -0
- package/dist/cli/onepass-pull-planner-regressions.test.d.ts.map +1 -0
- package/dist/cli/onepass-pull-planner-regressions.test.js +300 -0
- package/dist/cli/onepass-pull-planner-regressions.test.js.map +1 -0
- package/dist/cli/onepass-pull-planner.test.d.ts +2 -0
- package/dist/cli/onepass-pull-planner.test.d.ts.map +1 -0
- package/dist/cli/onepass-pull-planner.test.js +266 -0
- package/dist/cli/onepass-pull-planner.test.js.map +1 -0
- package/dist/cli/rescue-core.d.ts +0 -29
- package/dist/cli/rescue-core.d.ts.map +1 -1
- package/dist/cli/rescue-core.js +39 -236
- package/dist/cli/rescue-core.js.map +1 -1
- package/dist/cli/rescue-rsync-preflight.test.js +4 -256
- package/dist/cli/rescue-rsync-preflight.test.js.map +1 -1
- package/dist/cli/rescue.d.ts +0 -6
- package/dist/cli/rescue.d.ts.map +1 -1
- package/dist/cli/rescue.js +0 -12
- package/dist/cli/rescue.js.map +1 -1
- package/dist/cli/rescue.test.js +0 -6
- package/dist/cli/rescue.test.js.map +1 -1
- package/dist/cli/share-presign-transport.test.js +0 -2
- package/dist/cli/share-presign-transport.test.js.map +1 -1
- package/dist/cli/share.d.ts +19 -0
- package/dist/cli/share.d.ts.map +1 -1
- package/dist/cli/share.js +57 -37
- package/dist/cli/share.js.map +1 -1
- package/dist/cli/share.test.js +87 -93
- package/dist/cli/share.test.js.map +1 -1
- package/dist/cli/streaming-pull-planner.bench.test.d.ts +15 -0
- package/dist/cli/streaming-pull-planner.bench.test.d.ts.map +1 -0
- package/dist/cli/streaming-pull-planner.bench.test.js +273 -0
- package/dist/cli/streaming-pull-planner.bench.test.js.map +1 -0
- package/dist/cli/sync-scope.test.js +8 -0
- package/dist/cli/sync-scope.test.js.map +1 -1
- package/dist/cli/sync.d.ts +12 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +226 -118
- package/dist/cli/sync.js.map +1 -1
- package/dist/cli/sync.test.js +215 -2
- package/dist/cli/sync.test.js.map +1 -1
- package/dist/cli/watch-event-push-conflict.test.js +0 -2
- package/dist/cli/watch-event-push-conflict.test.js.map +1 -1
- package/dist/cognito-auth.d.ts +0 -30
- package/dist/cognito-auth.d.ts.map +1 -1
- package/dist/cognito-auth.js +0 -175
- package/dist/cognito-auth.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/journal-store.test.js +130 -7
- package/dist/journal-store.test.js.map +1 -1
- package/dist/journal.d.ts +9 -1
- package/dist/journal.d.ts.map +1 -1
- package/dist/journal.js +30 -21
- package/dist/journal.js.map +1 -1
- package/dist/lib/exit-codes.d.ts +15 -0
- package/dist/lib/exit-codes.d.ts.map +1 -1
- package/dist/lib/exit-codes.js +15 -0
- package/dist/lib/exit-codes.js.map +1 -1
- package/dist/machine-auth.test.js +0 -295
- package/dist/machine-auth.test.js.map +1 -1
- package/dist/object-io.d.ts +2 -2
- package/dist/object-io.d.ts.map +1 -1
- package/dist/object-io.js +3 -18
- package/dist/object-io.js.map +1 -1
- package/dist/personal-vault.d.ts.map +1 -1
- package/dist/personal-vault.js +10 -3
- package/dist/personal-vault.js.map +1 -1
- package/dist/personal-vault.test.js +35 -0
- package/dist/personal-vault.test.js.map +1 -1
- package/dist/remote-pull.d.ts.map +1 -1
- package/dist/remote-pull.js +9 -2
- package/dist/remote-pull.js.map +1 -1
- package/dist/remote-pull.test.js +59 -2
- package/dist/remote-pull.test.js.map +1 -1
- package/dist/s3.d.ts +1 -18
- package/dist/s3.d.ts.map +1 -1
- package/dist/s3.js +24 -47
- package/dist/s3.js.map +1 -1
- package/dist/s3.list-cost.test.d.ts +2 -0
- package/dist/s3.list-cost.test.d.ts.map +1 -0
- package/dist/s3.list-cost.test.js +51 -0
- package/dist/s3.list-cost.test.js.map +1 -0
- package/dist/s3.test.js +1 -27
- package/dist/s3.test.js.map +1 -1
- package/dist/sync/realtime-telemetry.d.ts +1 -1
- package/dist/sync/realtime-telemetry.d.ts.map +1 -1
- package/dist/sync/realtime-telemetry.js +14 -6
- package/dist/sync/realtime-telemetry.js.map +1 -1
- package/dist/sync/realtime-telemetry.test.js +136 -16
- package/dist/sync/realtime-telemetry.test.js.map +1 -1
- package/dist/sync/remote-file-spool.d.ts +16 -0
- package/dist/sync/remote-file-spool.d.ts.map +1 -0
- package/dist/sync/remote-file-spool.js +91 -0
- package/dist/sync/remote-file-spool.js.map +1 -0
- package/dist/sync/remote-file-spool.test.d.ts +2 -0
- package/dist/sync/remote-file-spool.test.d.ts.map +1 -0
- package/dist/sync/remote-file-spool.test.js +77 -0
- package/dist/sync/remote-file-spool.test.js.map +1 -0
- package/dist/sync-core.d.ts +4 -6
- package/dist/sync-core.d.ts.map +1 -1
- package/dist/sync-core.js +4 -10
- package/dist/sync-core.js.map +1 -1
- package/dist/sync-core.test.js +1 -25
- package/dist/sync-core.test.js.map +1 -1
- package/package.json +2 -1
- package/dist/cli/rescue-breaker.test.d.ts +0 -2
- package/dist/cli/rescue-breaker.test.d.ts.map +0 -1
- package/dist/cli/rescue-breaker.test.js +0 -314
- package/dist/cli/rescue-breaker.test.js.map +0 -1
- package/dist/cli/rescue-realpath.test.d.ts +0 -2
- package/dist/cli/rescue-realpath.test.d.ts.map +0 -1
- package/dist/cli/rescue-realpath.test.js +0 -109
- package/dist/cli/rescue-realpath.test.js.map +0 -1
- package/dist/cli/rescue-source-switch-floor.test.d.ts +0 -2
- package/dist/cli/rescue-source-switch-floor.test.d.ts.map +0 -1
- package/dist/cli/rescue-source-switch-floor.test.js +0 -210
- 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;
|
|
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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
148
148
|
function pathEntries(pathValue) {
|
|
149
149
|
return pathValue ? pathValue.split(path.delimiter) : [];
|
|
150
150
|
}
|
|
151
|
-
|
|
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
|
|
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
|
-
|
|
177
|
+
function requireWorkingRsync(env, err) {
|
|
194
178
|
const resolvedPath = envValue(env, "PATH");
|
|
195
179
|
const entries = pathEntries(resolvedPath);
|
|
196
|
-
const foundRsync = findRsyncOnPath(entries
|
|
197
|
-
|
|
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
|
|
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
|
-
" [--
|
|
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
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
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
|
-
|
|
490
|
+
function realpathOrExit(p, err) {
|
|
520
491
|
try {
|
|
521
|
-
return fs.realpathSync
|
|
492
|
+
return fs.realpathSync(p);
|
|
522
493
|
}
|
|
523
|
-
catch {
|
|
524
|
-
|
|
525
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
630
|
-
|
|
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
|
-
|
|
641
|
-
|
|
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(`
|
|
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
|
|
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 (
|
|
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(
|
|
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
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
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)
|
|
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)
|
|
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
|
}
|