@indigoai-us/hq-cloud 6.16.26 → 6.16.28
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/cli/conflict-winner.test.d.ts +7 -0
- package/dist/cli/conflict-winner.test.d.ts.map +1 -0
- package/dist/cli/conflict-winner.test.js +98 -0
- package/dist/cli/conflict-winner.test.js.map +1 -0
- package/dist/cli/conflict.d.ts +72 -0
- package/dist/cli/conflict.d.ts.map +1 -1
- package/dist/cli/conflict.js +107 -0
- package/dist/cli/conflict.js.map +1 -1
- package/dist/cli/doctor.d.ts +12 -0
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +29 -0
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/doctor.test.js +55 -0
- package/dist/cli/doctor.test.js.map +1 -1
- package/dist/cli/index.d.ts +4 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +4 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/share.d.ts.map +1 -1
- package/dist/cli/share.js +364 -101
- package/dist/cli/share.js.map +1 -1
- package/dist/cli/share.test.js +85 -15
- package/dist/cli/share.test.js.map +1 -1
- package/dist/cli/sync.d.ts +3 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +315 -276
- package/dist/cli/sync.js.map +1 -1
- package/dist/cli/sync.test.js +94 -47
- package/dist/cli/sync.test.js.map +1 -1
- package/dist/ignore.d.ts.map +1 -1
- package/dist/ignore.js +32 -0
- package/dist/ignore.js.map +1 -1
- package/dist/ignore.test.js +28 -0
- package/dist/ignore.test.js.map +1 -1
- package/dist/lib/conflict-file.d.ts +50 -18
- package/dist/lib/conflict-file.d.ts.map +1 -1
- package/dist/lib/conflict-file.js +63 -34
- package/dist/lib/conflict-file.js.map +1 -1
- package/dist/lib/conflict-index.d.ts.map +1 -1
- package/dist/lib/conflict-index.js +6 -0
- package/dist/lib/conflict-index.js.map +1 -1
- package/dist/lib/conflict-reconcile.d.ts +106 -0
- package/dist/lib/conflict-reconcile.d.ts.map +1 -0
- package/dist/lib/conflict-reconcile.js +412 -0
- package/dist/lib/conflict-reconcile.js.map +1 -0
- package/dist/lib/conflict-reconcile.test.d.ts +7 -0
- package/dist/lib/conflict-reconcile.test.d.ts.map +1 -0
- package/dist/lib/conflict-reconcile.test.js +246 -0
- package/dist/lib/conflict-reconcile.test.js.map +1 -0
- package/dist/lib/conflict.test.d.ts +3 -2
- package/dist/lib/conflict.test.d.ts.map +1 -1
- package/dist/lib/conflict.test.js +60 -3
- package/dist/lib/conflict.test.js.map +1 -1
- package/dist/manifest/build-manifest.d.ts.map +1 -1
- package/dist/manifest/build-manifest.js +7 -0
- package/dist/manifest/build-manifest.js.map +1 -1
- package/dist/manifest/build-manifest.test.js +18 -0
- package/dist/manifest/build-manifest.test.js.map +1 -1
- package/dist/manifest/contract.d.ts +11 -1
- package/dist/manifest/contract.d.ts.map +1 -1
- package/dist/manifest/contract.js +4 -0
- package/dist/manifest/contract.js.map +1 -1
- package/dist/manifest/contract.test.js +1 -1
- package/dist/types.d.ts +23 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli/share.test.js
CHANGED
|
@@ -102,9 +102,22 @@ function journalAt(journalPath) {
|
|
|
102
102
|
return readJournal(slug);
|
|
103
103
|
}
|
|
104
104
|
function sidecarIn(dir) {
|
|
105
|
-
|
|
105
|
+
// Loser bodies are parked OUT of the tree under
|
|
106
|
+
// `<hqRoot>/.hq/conflict-backups/<relative dir>/`; walk up from `dir` to the
|
|
107
|
+
// root that owns the backup dir. A sibling `.conflict-` twin beside the live
|
|
108
|
+
// file is never acceptable any more.
|
|
109
|
+
let root = dir;
|
|
110
|
+
while (!fs.existsSync(path.join(root, ".hq", "conflict-backups"))) {
|
|
111
|
+
const parent = path.dirname(root);
|
|
112
|
+
if (parent === root)
|
|
113
|
+
throw new Error(`no .hq/conflict-backups above ${dir}`);
|
|
114
|
+
root = parent;
|
|
115
|
+
}
|
|
116
|
+
const backupDir = path.join(root, ".hq", "conflict-backups", path.relative(root, dir));
|
|
117
|
+
const found = fs.existsSync(backupDir) ? fs.readdirSync(backupDir) : [];
|
|
106
118
|
expect(found).toHaveLength(1);
|
|
107
|
-
|
|
119
|
+
expect(fs.readdirSync(dir).filter((name) => name.includes(".conflict-"))).toEqual([]);
|
|
120
|
+
return path.join(backupDir, found[0]);
|
|
108
121
|
}
|
|
109
122
|
function conflictIndexAt(hqRoot) {
|
|
110
123
|
return JSON.parse(fs.readFileSync(path.join(hqRoot, ".hq-conflicts", "index.json"), "utf-8"));
|
|
@@ -2226,11 +2239,13 @@ describe("share", () => {
|
|
|
2226
2239
|
etag: '"remote-version-etag"',
|
|
2227
2240
|
size: 40,
|
|
2228
2241
|
});
|
|
2229
|
-
// On a real unprivileged host
|
|
2230
|
-
//
|
|
2231
|
-
//
|
|
2232
|
-
//
|
|
2242
|
+
// On a real unprivileged host the fresh-collision reconciled probe, the
|
|
2243
|
+
// version-aware winner probe AND the keep adoption all materialize the
|
|
2244
|
+
// remote symlink, so every downloadFile call refuses. The probes' catches
|
|
2245
|
+
// return "differs" / "undecidable" (conflict) without erroring; the
|
|
2246
|
+
// adoption must downgrade the refusal to the deliberate skip.
|
|
2233
2247
|
vi.mocked(downloadFile)
|
|
2248
|
+
.mockRejectedValueOnce(new WindowsSymlinkPrivilegeError("../target.md", "EPERM"))
|
|
2234
2249
|
.mockRejectedValueOnce(new WindowsSymlinkPrivilegeError("../target.md", "EPERM"))
|
|
2235
2250
|
.mockRejectedValueOnce(new WindowsSymlinkPrivilegeError("../target.md", "EPERM"));
|
|
2236
2251
|
const events = [];
|
|
@@ -2276,7 +2291,7 @@ describe("share", () => {
|
|
|
2276
2291
|
});
|
|
2277
2292
|
const realRenameSync = fs.renameSync;
|
|
2278
2293
|
const renameSpy = vi.spyOn(fs, "renameSync").mockImplementation((from, to) => {
|
|
2279
|
-
if (String(from) === testFile && String(to).includes("
|
|
2294
|
+
if (String(from) === testFile && String(to).includes("conflict-backups")) {
|
|
2280
2295
|
const err = new Error("EPERM: operation not permitted, rename");
|
|
2281
2296
|
err.code = "EPERM";
|
|
2282
2297
|
throw err;
|
|
@@ -2324,7 +2339,7 @@ describe("share", () => {
|
|
|
2324
2339
|
});
|
|
2325
2340
|
const realRenameSync = fs.renameSync;
|
|
2326
2341
|
const renameSpy = vi.spyOn(fs, "renameSync").mockImplementation((from, to) => {
|
|
2327
|
-
if (String(from) === testFile && String(to).includes("
|
|
2342
|
+
if (String(from) === testFile && String(to).includes("conflict-backups")) {
|
|
2328
2343
|
const err = new Error("EPERM: operation not permitted, rename");
|
|
2329
2344
|
err.code = "EPERM";
|
|
2330
2345
|
throw err;
|
|
@@ -2585,6 +2600,48 @@ describe("share", () => {
|
|
|
2585
2600
|
preserved: "local",
|
|
2586
2601
|
});
|
|
2587
2602
|
});
|
|
2603
|
+
it("412 under keep, local wins but HEAD yields no fresh etag: holds local instead of adopting the remote", async () => {
|
|
2604
|
+
const companyRoot = path.join(tmpDir, "companies", "acme");
|
|
2605
|
+
fs.mkdirSync(companyRoot, { recursive: true });
|
|
2606
|
+
const testFile = path.join(companyRoot, "held.md");
|
|
2607
|
+
const localBody = "---\nversion: 10\n---\nlocal wins\n";
|
|
2608
|
+
fs.writeFileSync(testFile, localBody);
|
|
2609
|
+
// Pre-flight HEAD: no remote. Re-decide HEAD after the 412: still no
|
|
2610
|
+
// etag to fence a retry on (object vanished / etag-less HEAD).
|
|
2611
|
+
vi.mocked(headRemoteFile)
|
|
2612
|
+
.mockResolvedValueOnce(null)
|
|
2613
|
+
.mockResolvedValueOnce(null);
|
|
2614
|
+
vi.mocked(uploadFile).mockRejectedValueOnce(fence412());
|
|
2615
|
+
vi.mocked(downloadFile).mockImplementationOnce(async (_ctx, _key, dest) => {
|
|
2616
|
+
fs.writeFileSync(dest, "---\nversion: 8\n---\nolder cloud body\n");
|
|
2617
|
+
return undefined;
|
|
2618
|
+
});
|
|
2619
|
+
const events = [];
|
|
2620
|
+
const result = await share({
|
|
2621
|
+
paths: [testFile],
|
|
2622
|
+
company: "acme",
|
|
2623
|
+
vaultConfig: mockConfig,
|
|
2624
|
+
hqRoot: tmpDir,
|
|
2625
|
+
onConflict: "keep",
|
|
2626
|
+
onEvent: (e) => events.push(e),
|
|
2627
|
+
});
|
|
2628
|
+
expect(result.conflictPaths).toEqual(["held.md"]);
|
|
2629
|
+
expect(result.filesUploaded).toBe(0);
|
|
2630
|
+
expect(result.filesSkipped).toBe(1);
|
|
2631
|
+
expect(result.aborted).toBe(false);
|
|
2632
|
+
// Exactly one PUT: no unfenced retry, and no second attempt at all.
|
|
2633
|
+
expect(vi.mocked(uploadFile).mock.calls).toHaveLength(1);
|
|
2634
|
+
expect(events.some((e) => e.type === "error")).toBe(false);
|
|
2635
|
+
// The WINNING local body is untouched; the probed cloud body is parked
|
|
2636
|
+
// out of tree as the backup, not adopted at the working name.
|
|
2637
|
+
expect(fs.readFileSync(testFile, "utf-8")).toBe(localBody);
|
|
2638
|
+
expect(fs.readFileSync(sidecarIn(companyRoot), "utf-8")).toBe("---\nversion: 8\n---\nolder cloud body\n");
|
|
2639
|
+
expect(conflictIndexAt(tmpDir).conflicts[0]).toMatchObject({
|
|
2640
|
+
originalPath: "companies/acme/held.md",
|
|
2641
|
+
preserved: "remote",
|
|
2642
|
+
decision: { winner: "local", reason: "version" },
|
|
2643
|
+
});
|
|
2644
|
+
});
|
|
2588
2645
|
it("412 under overwrite: retries exactly once WITHOUT the fence (explicit consent)", async () => {
|
|
2589
2646
|
const companyRoot = path.join(tmpDir, "companies", "acme");
|
|
2590
2647
|
fs.mkdirSync(companyRoot, { recursive: true });
|
|
@@ -8267,13 +8324,26 @@ describe("currency-gated: journal version 2 fixtures", () => {
|
|
|
8267
8324
|
},
|
|
8268
8325
|
};
|
|
8269
8326
|
});
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8327
|
+
// An UNSET strategy only prompts when a human is on a TTY; off a TTY it
|
|
8328
|
+
// is the version-aware winner. Model the interactive terminal here.
|
|
8329
|
+
const ttyDescriptor = Object.getOwnPropertyDescriptor(process.stdin, "isTTY");
|
|
8330
|
+
Object.defineProperty(process.stdin, "isTTY", { value: true, configurable: true });
|
|
8331
|
+
let result;
|
|
8332
|
+
try {
|
|
8333
|
+
result = await share({
|
|
8334
|
+
paths: [companyRoot],
|
|
8335
|
+
company: "acme",
|
|
8336
|
+
vaultConfig: mockConfig,
|
|
8337
|
+
hqRoot: tmpDir,
|
|
8338
|
+
// onConflict intentionally omitted → interactive mode
|
|
8339
|
+
});
|
|
8340
|
+
}
|
|
8341
|
+
finally {
|
|
8342
|
+
if (ttyDescriptor)
|
|
8343
|
+
Object.defineProperty(process.stdin, "isTTY", ttyDescriptor);
|
|
8344
|
+
else
|
|
8345
|
+
delete process.stdin.isTTY;
|
|
8346
|
+
}
|
|
8277
8347
|
// Both conflicts surfaced.
|
|
8278
8348
|
expect(result.conflictPaths.length).toBe(2);
|
|
8279
8349
|
// Both prompts opened (one per conflicting file).
|