@indigoai-us/hq-cli 5.345.244 → 5.345.245
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/CHANGELOG.md +5 -0
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +2016 -1819
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/sync-core/engine-holds.d.ts +17 -1
- package/dist/lib/sync-core/engine-holds.js +73 -3
- package/dist/lib/sync-core/reconcile.js +10 -2
- package/package.json +8 -8
|
@@ -8,7 +8,23 @@ export interface EngineHeldDeletes {
|
|
|
8
8
|
count: number;
|
|
9
9
|
deletes: EngineHeldDelete[];
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* hq-cloud's runner reads this file and never applies a delete it lists: the
|
|
13
|
+
* server copy stays (and downloads again when the local file is missing) and
|
|
14
|
+
* the local copy stays. The runner drops a path after a later positive signal.
|
|
15
|
+
*/
|
|
16
|
+
export declare function handbackKeepFile(home: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Adds a vault's held deletes to the hand-back keep list, merged with any
|
|
19
|
+
* paths already listed for it. Throws when the file cannot be written.
|
|
20
|
+
*/
|
|
21
|
+
export declare function writeHandbackKeep(home: string, vault: {
|
|
22
|
+
uid: string;
|
|
23
|
+
slug?: string;
|
|
24
|
+
}, held: EngineHeldDeletes, at: string,
|
|
25
|
+
/** Test seam: runs after the temp file is written, before the re-read that guards the rename. */
|
|
26
|
+
beforeRename?: (attempt: number) => void): void;
|
|
11
27
|
export declare function engineHoldFile(engineHome: string, vaultUid: string): string;
|
|
12
28
|
export declare function readEngineHeldDeletes(engineHome: string, vaultUid: string): EngineHeldDeletes | "unreadable" | null;
|
|
13
|
-
export declare function heldDeletesHandoverLine(vaultUid: string, held: EngineHeldDeletes | "unreadable", engineHome: string): string;
|
|
29
|
+
export declare function heldDeletesHandoverLine(vaultUid: string, held: EngineHeldDeletes | "unreadable", engineHome: string, home: string): string;
|
|
14
30
|
//# sourceMappingURL=engine-holds.d.ts.map
|
|
@@ -5,6 +5,76 @@ const HOLD_FILE_MAX_BYTES = 16 * 1024 * 1024;
|
|
|
5
5
|
function record(value) {
|
|
6
6
|
return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* hq-cloud's runner reads this file and never applies a delete it lists: the
|
|
10
|
+
* server copy stays (and downloads again when the local file is missing) and
|
|
11
|
+
* the local copy stays. The runner drops a path after a later positive signal.
|
|
12
|
+
*/
|
|
13
|
+
export function handbackKeepFile(home) {
|
|
14
|
+
return path.join(home, ".hq", "sync-core", "handback-keep.json");
|
|
15
|
+
}
|
|
16
|
+
const HANDBACK_KEEP_VERSION = 1;
|
|
17
|
+
/**
|
|
18
|
+
* Adds a vault's held deletes to the hand-back keep list, merged with any
|
|
19
|
+
* paths already listed for it. Throws when the file cannot be written.
|
|
20
|
+
*/
|
|
21
|
+
export function writeHandbackKeep(home, vault, held, at,
|
|
22
|
+
/** Test seam: runs after the temp file is written, before the re-read that guards the rename. */
|
|
23
|
+
beforeRename) {
|
|
24
|
+
const file = handbackKeepFile(home);
|
|
25
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
26
|
+
for (let attempt = 0; attempt < HANDBACK_KEEP_WRITE_ATTEMPTS; attempt++) {
|
|
27
|
+
const text = readTextOrNull(file);
|
|
28
|
+
let current;
|
|
29
|
+
try {
|
|
30
|
+
current = text === null ? {} : record(JSON.parse(text)) ?? {};
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
current = {};
|
|
34
|
+
}
|
|
35
|
+
const vaults = { ...(record(current.vaults) ?? {}) };
|
|
36
|
+
const before = record(vaults[vault.uid]);
|
|
37
|
+
const paths = new Map();
|
|
38
|
+
for (const value of Array.isArray(before?.paths) ? before.paths : []) {
|
|
39
|
+
const entry = record(value);
|
|
40
|
+
if (entry && typeof entry.path === "string")
|
|
41
|
+
paths.set(entry.path, entry);
|
|
42
|
+
}
|
|
43
|
+
for (const entry of held.deletes) {
|
|
44
|
+
const known = paths.get(entry.path);
|
|
45
|
+
paths.set(entry.path, known?.direction === entry.direction ? known : { path: entry.path, direction: entry.direction });
|
|
46
|
+
}
|
|
47
|
+
vaults[vault.uid] = {
|
|
48
|
+
...(vault.slug ? { slug: vault.slug } : {}),
|
|
49
|
+
...(held.holdId ? { holdId: held.holdId } : {}),
|
|
50
|
+
writtenAt: at,
|
|
51
|
+
paths: [...paths.values()],
|
|
52
|
+
};
|
|
53
|
+
const version = typeof current.version === "number" && current.version > HANDBACK_KEEP_VERSION ? current.version : HANDBACK_KEEP_VERSION;
|
|
54
|
+
const temp = `${file}.${process.pid}.${attempt}.tmp`;
|
|
55
|
+
fs.writeFileSync(temp, `${JSON.stringify({ ...current, version, vaults }, null, 2)}\n`, { mode: 0o600 });
|
|
56
|
+
// The runner also rewrites this file: rename only over the version just read.
|
|
57
|
+
beforeRename?.(attempt);
|
|
58
|
+
if (readTextOrNull(file) !== text) {
|
|
59
|
+
fs.rmSync(temp, { force: true });
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
fs.renameSync(temp, file);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`${file} kept changing while it was written`);
|
|
66
|
+
}
|
|
67
|
+
const HANDBACK_KEEP_WRITE_ATTEMPTS = 5;
|
|
68
|
+
function readTextOrNull(file) {
|
|
69
|
+
try {
|
|
70
|
+
return fs.readFileSync(file, "utf8");
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (error.code === "ENOENT")
|
|
74
|
+
return null;
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
8
78
|
export function engineHoldFile(engineHome, vaultUid) {
|
|
9
79
|
return path.join(engineHome, ".hq", "sync-core", "holds", `${vaultUid}.json`);
|
|
10
80
|
}
|
|
@@ -48,13 +118,13 @@ export function readEngineHeldDeletes(engineHome, vaultUid) {
|
|
|
48
118
|
function printable(value) {
|
|
49
119
|
return JSON.stringify(value);
|
|
50
120
|
}
|
|
51
|
-
export function heldDeletesHandoverLine(vaultUid, held, engineHome) {
|
|
121
|
+
export function heldDeletesHandoverLine(vaultUid, held, engineHome, home) {
|
|
52
122
|
if (held === "unreadable") {
|
|
53
|
-
return `${vaultUid}: the new sync engine's hold file ${engineHoldFile(engineHome, vaultUid)} could not be read;
|
|
123
|
+
return `${vaultUid}: the new sync engine's hold file ${engineHoldFile(engineHome, vaultUid)} could not be read; nothing it held is passed to the current sync, which decides each path again from its own journal and delete checks`;
|
|
54
124
|
}
|
|
55
125
|
const shown = held.deletes.slice(0, HELD_DELETE_LOG_LIMIT).map((entry) => `${entry.direction === "delete_local" ? "local copy of" : "server copy of"} ${printable(entry.path)}`);
|
|
56
126
|
const more = held.count > shown.length ? `; and ${held.count - shown.length} more` : "";
|
|
57
127
|
const id = held.holdId ? ` (hold ${/^[A-Za-z0-9_-]{1,64}$/.test(held.holdId) ? held.holdId : printable(held.holdId)})` : "";
|
|
58
|
-
return `${vaultUid}: switching back with ${held.count} delete${held.count === 1 ? "" : "s"} the new sync engine held${id}; the current sync
|
|
128
|
+
return `${vaultUid}: switching back with ${held.count} delete${held.count === 1 ? "" : "s"} the new sync engine held${id}; the current sync keeps these files and does not apply those deletes (listed in ${handbackKeepFile(home)}): ${shown.join(", ")}${more}`;
|
|
59
129
|
}
|
|
60
130
|
//# sourceMappingURL=engine-holds.js.map
|
|
@@ -7,7 +7,7 @@ import { clearEngineStatus, engineFirstCycle, isSyncCoreVaultUid, removeEngineOw
|
|
|
7
7
|
import { SYNC_CORE_FULL_RELEASE, SYNC_CORE_RELEASE, compareSyncCoreReleases, fullModeAllowed, installedSyncCoreRelease, syncCoreBinaryPath, windowsFullRelease, } from "./release.js";
|
|
8
8
|
import { readSyncCoreSkips } from "./skip.js";
|
|
9
9
|
import { isLiveCompanyEntity, joinedCompanySlug, setUpJoinedCompany } from "./company-adoption.js";
|
|
10
|
-
import { heldDeletesHandoverLine, readEngineHeldDeletes } from "./engine-holds.js";
|
|
10
|
+
import { heldDeletesHandoverLine, readEngineHeldDeletes, writeHandbackKeep } from "./engine-holds.js";
|
|
11
11
|
import { SYNC_RUST_ENGINE_ROLLOUT_FLAG } from "./flag.js";
|
|
12
12
|
import { readSyncCoreRolloutState, syncCoreRolloutStatePath, writeSyncCoreRolloutState, } from "./rollout-state.js";
|
|
13
13
|
function message(error) {
|
|
@@ -336,8 +336,16 @@ export async function reconcileSyncCore(deps) {
|
|
|
336
336
|
continue;
|
|
337
337
|
const engineHome = syncCoreEngineHome(deps.home, vault.uid);
|
|
338
338
|
const heldDeletes = readEngineHeldDeletes(engineHome, vault.uid);
|
|
339
|
+
if (heldDeletes && heldDeletes !== "unreadable") {
|
|
340
|
+
try {
|
|
341
|
+
writeHandbackKeep(deps.home, vault, heldDeletes, at);
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
warnings.push(`could not record the ${heldDeletes.count} deletes the new sync engine held for ${vault.uid}; the current sync may apply them: ${message(error)}`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
339
347
|
if (heldDeletes)
|
|
340
|
-
handover.push(heldDeletesHandoverLine(vault.uid, heldDeletes, engineHome));
|
|
348
|
+
handover.push(heldDeletesHandoverLine(vault.uid, heldDeletes, engineHome, deps.home));
|
|
341
349
|
handedBack.push(vault);
|
|
342
350
|
}
|
|
343
351
|
const handingBack = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indigoai-us/hq-cli",
|
|
3
|
-
"version": "5.345.
|
|
3
|
+
"version": "5.345.245",
|
|
4
4
|
"description": "HQ by Indigo management CLI — modules and cloud sync",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@aws-sdk/client-iot-data-plane": "^3.1096.0",
|
|
64
64
|
"@aws-sdk/client-s3": "^3.1049.0",
|
|
65
65
|
"@aws-sdk/dsql-signer": "^3.1146.0",
|
|
66
|
-
"@indigoai-us/hq-cloud": "6.18.
|
|
66
|
+
"@indigoai-us/hq-cloud": "6.18.120",
|
|
67
67
|
"@indigoai-us/hq-flags-client": "^0.2.0",
|
|
68
68
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
69
69
|
"@sentry/node": "^10.49.0",
|
|
@@ -126,11 +126,11 @@
|
|
|
126
126
|
"*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
|
|
127
127
|
},
|
|
128
128
|
"optionalDependencies": {
|
|
129
|
-
"@indigoai-us/hq-hook-win32-x64": "5.345.
|
|
130
|
-
"@indigoai-us/hq-hook-win32-arm64": "5.345.
|
|
131
|
-
"@indigoai-us/hq-hook-darwin-x64": "5.345.
|
|
132
|
-
"@indigoai-us/hq-hook-darwin-arm64": "5.345.
|
|
133
|
-
"@indigoai-us/hq-hook-linux-x64": "5.345.
|
|
134
|
-
"@indigoai-us/hq-hook-linux-arm64": "5.345.
|
|
129
|
+
"@indigoai-us/hq-hook-win32-x64": "5.345.245",
|
|
130
|
+
"@indigoai-us/hq-hook-win32-arm64": "5.345.245",
|
|
131
|
+
"@indigoai-us/hq-hook-darwin-x64": "5.345.245",
|
|
132
|
+
"@indigoai-us/hq-hook-darwin-arm64": "5.345.245",
|
|
133
|
+
"@indigoai-us/hq-hook-linux-x64": "5.345.245",
|
|
134
|
+
"@indigoai-us/hq-hook-linux-arm64": "5.345.245"
|
|
135
135
|
}
|
|
136
136
|
}
|