@indigoai-us/hq-cloud 6.18.11 → 6.18.12-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/sync-runner-args.test.d.ts +2 -0
- package/dist/bin/sync-runner-args.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-args.test.js +82 -0
- package/dist/bin/sync-runner-args.test.js.map +1 -0
- package/dist/bin/sync-runner-company.d.ts +1 -0
- package/dist/bin/sync-runner-company.d.ts.map +1 -1
- package/dist/bin/sync-runner-company.js +3 -0
- package/dist/bin/sync-runner-company.js.map +1 -1
- package/dist/bin/sync-runner-company.test.js +31 -0
- package/dist/bin/sync-runner-company.test.js.map +1 -1
- package/dist/bin/sync-runner-delete-snapshot-mixed.bench.test.d.ts +2 -0
- package/dist/bin/sync-runner-delete-snapshot-mixed.bench.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-delete-snapshot-mixed.bench.test.js +500 -0
- package/dist/bin/sync-runner-delete-snapshot-mixed.bench.test.js.map +1 -0
- package/dist/bin/sync-runner-delete-snapshot.bench.test.d.ts +2 -0
- package/dist/bin/sync-runner-delete-snapshot.bench.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-delete-snapshot.bench.test.js +317 -0
- package/dist/bin/sync-runner-delete-snapshot.bench.test.js.map +1 -0
- package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
- package/dist/bin/sync-runner-watch-loop.js +195 -20
- package/dist/bin/sync-runner-watch-loop.js.map +1 -1
- package/dist/bin/sync-runner-watch-loop.test.js +71 -0
- package/dist/bin/sync-runner-watch-loop.test.js.map +1 -1
- package/dist/bin/sync-runner-watch-routes.d.ts +2 -1
- package/dist/bin/sync-runner-watch-routes.d.ts.map +1 -1
- package/dist/bin/sync-runner-watch-routes.js +7 -2
- package/dist/bin/sync-runner-watch-routes.js.map +1 -1
- package/dist/bin/sync-runner-watch-routes.test.js +15 -0
- package/dist/bin/sync-runner-watch-routes.test.js.map +1 -1
- package/dist/bin/sync-runner.d.ts +71 -1
- package/dist/bin/sync-runner.d.ts.map +1 -1
- package/dist/bin/sync-runner.js +52 -1
- package/dist/bin/sync-runner.js.map +1 -1
- package/dist/bin/sync-runner.test.js +119 -3
- package/dist/bin/sync-runner.test.js.map +1 -1
- package/dist/cli/share.d.ts.map +1 -1
- package/dist/cli/share.js +2 -0
- package/dist/cli/share.js.map +1 -1
- package/dist/cli/share.test.js +76 -0
- package/dist/cli/share.test.js.map +1 -1
- package/dist/cli/sync.d.ts +13 -2
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +81 -4
- package/dist/cli/sync.js.map +1 -1
- package/dist/cli/sync.test.js +228 -0
- package/dist/cli/sync.test.js.map +1 -1
- package/dist/ignore.d.ts.map +1 -1
- package/dist/ignore.js +3 -0
- package/dist/ignore.js.map +1 -1
- package/dist/ignore.test.js +8 -0
- package/dist/ignore.test.js.map +1 -1
- package/dist/journal.d.ts +15 -0
- package/dist/journal.d.ts.map +1 -1
- package/dist/journal.js +66 -2
- package/dist/journal.js.map +1 -1
- package/dist/journal.test.js +16 -1
- package/dist/journal.test.js.map +1 -1
- package/dist/manifest/build-manifest-resident-parity.test.js +5 -3
- package/dist/manifest/build-manifest-resident-parity.test.js.map +1 -1
- package/dist/sync/area-ledger.d.ts +1 -0
- package/dist/sync/area-ledger.d.ts.map +1 -1
- package/dist/sync/area-ledger.js +54 -17
- package/dist/sync/area-ledger.js.map +1 -1
- package/dist/sync/area-ledger.test.js +109 -0
- package/dist/sync/area-ledger.test.js.map +1 -1
- package/dist/sync/content-hash.d.ts +4 -0
- package/dist/sync/content-hash.d.ts.map +1 -0
- package/dist/sync/content-hash.js +11 -0
- package/dist/sync/content-hash.js.map +1 -0
- package/dist/sync/content-hash.test.d.ts +2 -0
- package/dist/sync/content-hash.test.d.ts.map +1 -0
- package/dist/sync/content-hash.test.js +16 -0
- package/dist/sync/content-hash.test.js.map +1 -0
- package/dist/sync/event-sync.d.ts.map +1 -1
- package/dist/sync/event-sync.js +58 -1
- package/dist/sync/event-sync.js.map +1 -1
- package/dist/sync/event-sync.test.js +46 -0
- package/dist/sync/event-sync.test.js.map +1 -1
- package/dist/sync/logger.test.js +3 -0
- package/dist/sync/logger.test.js.map +1 -1
- package/dist/sync/metrics.test.js +3 -0
- package/dist/sync/metrics.test.js.map +1 -1
- package/dist/sync/push-receiver.d.ts +52 -0
- package/dist/sync/push-receiver.d.ts.map +1 -1
- package/dist/sync/push-receiver.js +416 -50
- package/dist/sync/push-receiver.js.map +1 -1
- package/dist/sync/push-receiver.test.js +673 -40
- package/dist/sync/push-receiver.test.js.map +1 -1
- package/dist/sync/unchanged-push-events.d.ts +16 -0
- package/dist/sync/unchanged-push-events.d.ts.map +1 -0
- package/dist/sync/unchanged-push-events.js +51 -0
- package/dist/sync/unchanged-push-events.js.map +1 -0
- package/dist/sync/unchanged-push-events.test.d.ts +2 -0
- package/dist/sync/unchanged-push-events.test.d.ts.map +1 -0
- package/dist/sync/unchanged-push-events.test.js +76 -0
- package/dist/sync/unchanged-push-events.test.js.map +1 -0
- package/dist/watcher.d.ts +18 -0
- package/dist/watcher.d.ts.map +1 -1
- package/dist/watcher.js +78 -13
- package/dist/watcher.js.map +1 -1
- package/dist/watcher.test.js +72 -0
- package/dist/watcher.test.js.map +1 -1
- package/package.json +2 -1
package/dist/cli/sync.test.js
CHANGED
|
@@ -1649,6 +1649,7 @@ describe("sync", () => {
|
|
|
1649
1649
|
},
|
|
1650
1650
|
deleteMessage: async ({ receiptHandle }) => { deleted.push(receiptHandle); },
|
|
1651
1651
|
changeMessageVisibility: async () => { },
|
|
1652
|
+
changeMessageVisibilityBatch: async () => ({ failedEntries: [] }),
|
|
1652
1653
|
};
|
|
1653
1654
|
const results = [];
|
|
1654
1655
|
const receiver = new SqsPushReceiver({
|
|
@@ -1705,6 +1706,7 @@ describe("sync", () => {
|
|
|
1705
1706
|
},
|
|
1706
1707
|
deleteMessage: async ({ receiptHandle }) => { deleted.push(receiptHandle); },
|
|
1707
1708
|
changeMessageVisibility: async () => { },
|
|
1709
|
+
changeMessageVisibilityBatch: async () => ({ failedEntries: [] }),
|
|
1708
1710
|
};
|
|
1709
1711
|
let attempts = 0;
|
|
1710
1712
|
const receiver = new SqsPushReceiver({
|
|
@@ -3405,6 +3407,232 @@ describe("sync", () => {
|
|
|
3405
3407
|
}
|
|
3406
3408
|
expect(fs.readFileSync(localPath, "utf-8")).toBe("unchanged body");
|
|
3407
3409
|
});
|
|
3410
|
+
it("downloads the listed revision when an older same-size announcement arrives late", async () => {
|
|
3411
|
+
const companyDocs = path.join(tmpDir, "companies", "acme", "docs");
|
|
3412
|
+
fs.mkdirSync(companyDocs, { recursive: true });
|
|
3413
|
+
const localPath = path.join(companyDocs, "handoff.md");
|
|
3414
|
+
const revisionA = "revision A body\n";
|
|
3415
|
+
const revisionB = "revision B body\n";
|
|
3416
|
+
expect(Buffer.byteLength(revisionA)).toBe(Buffer.byteLength(revisionB));
|
|
3417
|
+
fs.writeFileSync(localPath, revisionA);
|
|
3418
|
+
const stat = fs.lstatSync(localPath);
|
|
3419
|
+
const hashA = crypto.createHash("sha256").update(revisionA).digest("hex");
|
|
3420
|
+
const hashB = crypto.createHash("sha256").update(revisionB).digest("hex");
|
|
3421
|
+
const listedRevisionB = {
|
|
3422
|
+
key: "docs/handoff.md",
|
|
3423
|
+
size: Buffer.byteLength(revisionB),
|
|
3424
|
+
lastModified: new Date(),
|
|
3425
|
+
etag: '"revision-b-etag"',
|
|
3426
|
+
};
|
|
3427
|
+
writeJournal("acme", {
|
|
3428
|
+
version: "2",
|
|
3429
|
+
lastSync: new Date().toISOString(),
|
|
3430
|
+
pulls: [],
|
|
3431
|
+
files: {
|
|
3432
|
+
"docs/handoff.md": {
|
|
3433
|
+
hash: hashA,
|
|
3434
|
+
size: stat.size,
|
|
3435
|
+
mtimeMs: stat.mtimeMs,
|
|
3436
|
+
ctimeMs: stat.ctimeMs,
|
|
3437
|
+
remoteEtag: "revision-a-etag",
|
|
3438
|
+
syncedAt: new Date(Date.now() - 3600000).toISOString(),
|
|
3439
|
+
direction: "down",
|
|
3440
|
+
kind: "file",
|
|
3441
|
+
},
|
|
3442
|
+
},
|
|
3443
|
+
});
|
|
3444
|
+
const listRemoteFiles = vi.mocked(s3Module.listRemoteFiles);
|
|
3445
|
+
const originalListImplementation = listRemoteFiles.getMockImplementation();
|
|
3446
|
+
listRemoteFiles.mockResolvedValue([listedRevisionB]);
|
|
3447
|
+
vi.mocked(s3Module.headRemoteFile).mockResolvedValueOnce({
|
|
3448
|
+
etag: '"revision-b-etag"',
|
|
3449
|
+
size: Buffer.byteLength(revisionB),
|
|
3450
|
+
lastModified: new Date(),
|
|
3451
|
+
metadata: { [s3Module.FILE_CONTENT_SHA256_META_KEY]: hashB },
|
|
3452
|
+
});
|
|
3453
|
+
vi.mocked(s3Module.downloadFile).mockImplementationOnce(async (_ctx, _key, stagedPath, options) => {
|
|
3454
|
+
fs.mkdirSync(path.dirname(stagedPath), { recursive: true });
|
|
3455
|
+
options?.beforeReplace?.();
|
|
3456
|
+
fs.writeFileSync(stagedPath, revisionB);
|
|
3457
|
+
return {
|
|
3458
|
+
metadata: { [s3Module.FILE_CONTENT_SHA256_META_KEY]: hashB },
|
|
3459
|
+
contentHash: hashB,
|
|
3460
|
+
contentSize: Buffer.byteLength(revisionB),
|
|
3461
|
+
};
|
|
3462
|
+
});
|
|
3463
|
+
try {
|
|
3464
|
+
await sync({
|
|
3465
|
+
company: "acme",
|
|
3466
|
+
onConflict: "keep",
|
|
3467
|
+
vaultConfig: mockConfig,
|
|
3468
|
+
hqRoot: tmpDir,
|
|
3469
|
+
pullPrefixes: ["docs/handoff.md"],
|
|
3470
|
+
// This delayed event describes A, while LIST and HEAD describe B.
|
|
3471
|
+
pullContentHashes: { "docs/handoff.md": `sha256:${hashA}` },
|
|
3472
|
+
skipReindex: true,
|
|
3473
|
+
});
|
|
3474
|
+
expect(vi.mocked(s3Module.downloadFile)).toHaveBeenCalledTimes(1);
|
|
3475
|
+
expect(fs.readFileSync(localPath, "utf8")).toBe(revisionB);
|
|
3476
|
+
expect(readJournal("acme").files["docs/handoff.md"]).toMatchObject({
|
|
3477
|
+
hash: hashB,
|
|
3478
|
+
remoteEtag: "revision-b-etag",
|
|
3479
|
+
});
|
|
3480
|
+
// B's later announcement sees B's bytes and ETag already committed.
|
|
3481
|
+
await sync({
|
|
3482
|
+
company: "acme",
|
|
3483
|
+
onConflict: "keep",
|
|
3484
|
+
vaultConfig: mockConfig,
|
|
3485
|
+
hqRoot: tmpDir,
|
|
3486
|
+
pullPrefixes: ["docs/handoff.md"],
|
|
3487
|
+
pullContentHashes: { "docs/handoff.md": `sha256:${hashB}` },
|
|
3488
|
+
skipReindex: true,
|
|
3489
|
+
});
|
|
3490
|
+
expect(vi.mocked(s3Module.downloadFile)).toHaveBeenCalledTimes(1);
|
|
3491
|
+
expect(fs.readFileSync(localPath, "utf8")).toBe(revisionB);
|
|
3492
|
+
}
|
|
3493
|
+
finally {
|
|
3494
|
+
if (originalListImplementation) {
|
|
3495
|
+
listRemoteFiles.mockImplementation(originalListImplementation);
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
});
|
|
3499
|
+
it("updates the remote ETag without downloading when a targeted event matches clean journal bytes", async () => {
|
|
3500
|
+
const companyDocs = path.join(tmpDir, "companies", "acme", "docs");
|
|
3501
|
+
fs.mkdirSync(companyDocs, { recursive: true });
|
|
3502
|
+
const localPath = path.join(companyDocs, "handoff.md");
|
|
3503
|
+
const localContent = "unchanged body";
|
|
3504
|
+
fs.writeFileSync(localPath, localContent);
|
|
3505
|
+
const stat = fs.lstatSync(localPath);
|
|
3506
|
+
const hash = crypto.createHash("sha256").update(localContent).digest("hex");
|
|
3507
|
+
writeJournal("acme", {
|
|
3508
|
+
version: "2",
|
|
3509
|
+
lastSync: new Date().toISOString(),
|
|
3510
|
+
pulls: [],
|
|
3511
|
+
files: {
|
|
3512
|
+
"docs/handoff.md": {
|
|
3513
|
+
hash,
|
|
3514
|
+
size: stat.size,
|
|
3515
|
+
mtimeMs: stat.mtimeMs,
|
|
3516
|
+
ctimeMs: stat.ctimeMs,
|
|
3517
|
+
remoteEtag: "old-etag",
|
|
3518
|
+
syncedAt: new Date(Date.now() - 3600000).toISOString(),
|
|
3519
|
+
direction: "down",
|
|
3520
|
+
kind: "file",
|
|
3521
|
+
},
|
|
3522
|
+
},
|
|
3523
|
+
});
|
|
3524
|
+
vi.mocked(s3Module.listRemoteFiles).mockResolvedValueOnce([
|
|
3525
|
+
{ key: "docs/handoff.md", size: stat.size, lastModified: new Date(), etag: '"new-etag"' },
|
|
3526
|
+
]);
|
|
3527
|
+
vi.mocked(s3Module.headRemoteFile).mockResolvedValueOnce({
|
|
3528
|
+
etag: '"new-etag"',
|
|
3529
|
+
size: stat.size,
|
|
3530
|
+
lastModified: new Date(),
|
|
3531
|
+
metadata: { [s3Module.FILE_CONTENT_SHA256_META_KEY]: hash },
|
|
3532
|
+
});
|
|
3533
|
+
const result = await sync({
|
|
3534
|
+
company: "acme",
|
|
3535
|
+
onConflict: "keep",
|
|
3536
|
+
vaultConfig: mockConfig,
|
|
3537
|
+
hqRoot: tmpDir,
|
|
3538
|
+
pullPrefixes: ["docs/handoff.md"],
|
|
3539
|
+
pullContentHashes: { "docs/handoff.md": `sha256:${hash}` },
|
|
3540
|
+
skipReindex: true,
|
|
3541
|
+
});
|
|
3542
|
+
expect(vi.mocked(s3Module.downloadFile)).not.toHaveBeenCalled();
|
|
3543
|
+
expect(result.filesDownloaded).toBe(0);
|
|
3544
|
+
expect(readJournal("acme").files["docs/handoff.md"]?.remoteEtag).toBe("new-etag");
|
|
3545
|
+
expect(fs.readFileSync(localPath, "utf8")).toBe(localContent);
|
|
3546
|
+
});
|
|
3547
|
+
it.each([
|
|
3548
|
+
"changed remote content hash",
|
|
3549
|
+
"locally modified file",
|
|
3550
|
+
"missing local file",
|
|
3551
|
+
"missing journal row",
|
|
3552
|
+
])("still GETs through the normal pull path for a %s", async (caseName) => {
|
|
3553
|
+
const companyDocs = path.join(tmpDir, "companies", "acme", "docs");
|
|
3554
|
+
fs.mkdirSync(companyDocs, { recursive: true });
|
|
3555
|
+
const localPath = path.join(companyDocs, "handoff.md");
|
|
3556
|
+
const baseline = "unchanged body";
|
|
3557
|
+
fs.writeFileSync(localPath, baseline);
|
|
3558
|
+
const stat = fs.lstatSync(localPath);
|
|
3559
|
+
const baselineHash = crypto.createHash("sha256").update(baseline).digest("hex");
|
|
3560
|
+
const announcedBody = caseName === "changed remote content hash"
|
|
3561
|
+
? "changed body!!"
|
|
3562
|
+
: baseline;
|
|
3563
|
+
const announcedHash = crypto.createHash("sha256").update(announcedBody).digest("hex");
|
|
3564
|
+
if (caseName !== "missing journal row") {
|
|
3565
|
+
writeJournal("acme", {
|
|
3566
|
+
version: "2",
|
|
3567
|
+
lastSync: new Date().toISOString(),
|
|
3568
|
+
pulls: [],
|
|
3569
|
+
files: {
|
|
3570
|
+
"docs/handoff.md": {
|
|
3571
|
+
hash: baselineHash,
|
|
3572
|
+
size: stat.size,
|
|
3573
|
+
mtimeMs: stat.mtimeMs,
|
|
3574
|
+
ctimeMs: stat.ctimeMs,
|
|
3575
|
+
remoteEtag: "old-etag",
|
|
3576
|
+
syncedAt: new Date(Date.now() - 3600000).toISOString(),
|
|
3577
|
+
direction: "down",
|
|
3578
|
+
kind: "file",
|
|
3579
|
+
},
|
|
3580
|
+
},
|
|
3581
|
+
});
|
|
3582
|
+
}
|
|
3583
|
+
if (caseName === "locally modified file") {
|
|
3584
|
+
fs.writeFileSync(localPath, "changed body!!");
|
|
3585
|
+
}
|
|
3586
|
+
else if (caseName === "missing local file") {
|
|
3587
|
+
fs.unlinkSync(localPath);
|
|
3588
|
+
}
|
|
3589
|
+
vi.mocked(s3Module.listRemoteFiles).mockResolvedValueOnce([
|
|
3590
|
+
{ key: "docs/handoff.md", size: stat.size, lastModified: new Date(), etag: '"new-etag"' },
|
|
3591
|
+
]);
|
|
3592
|
+
await sync({
|
|
3593
|
+
company: "acme",
|
|
3594
|
+
onConflict: "keep",
|
|
3595
|
+
vaultConfig: mockConfig,
|
|
3596
|
+
hqRoot: tmpDir,
|
|
3597
|
+
pullPrefixes: ["docs/handoff.md"],
|
|
3598
|
+
pullContentHashes: { "docs/handoff.md": `sha256:${announcedHash}` },
|
|
3599
|
+
skipReindex: true,
|
|
3600
|
+
});
|
|
3601
|
+
expect(vi.mocked(s3Module.downloadFile)).toHaveBeenCalled();
|
|
3602
|
+
});
|
|
3603
|
+
it("keeps local bytes in place when an unjournaled file already matches the announced content", async () => {
|
|
3604
|
+
const companyDocs = path.join(tmpDir, "companies", "acme", "docs");
|
|
3605
|
+
fs.mkdirSync(companyDocs, { recursive: true });
|
|
3606
|
+
const localPath = path.join(companyDocs, "handoff.md");
|
|
3607
|
+
const content = "already has incoming bytes";
|
|
3608
|
+
fs.writeFileSync(localPath, content);
|
|
3609
|
+
const before = fs.lstatSync(localPath);
|
|
3610
|
+
const hash = crypto.createHash("sha256").update(content).digest("hex");
|
|
3611
|
+
vi.mocked(s3Module.listRemoteFiles).mockResolvedValueOnce([
|
|
3612
|
+
{ key: "docs/handoff.md", size: before.size, lastModified: new Date(), etag: '"incoming-etag"' },
|
|
3613
|
+
]);
|
|
3614
|
+
vi.mocked(s3Module.downloadFile).mockImplementationOnce(async (_ctx, _key, probePath, options) => {
|
|
3615
|
+
fs.mkdirSync(path.dirname(probePath), { recursive: true });
|
|
3616
|
+
options?.beforeReplace?.();
|
|
3617
|
+
fs.writeFileSync(probePath, content);
|
|
3618
|
+
return { metadata: {} };
|
|
3619
|
+
});
|
|
3620
|
+
const result = await sync({
|
|
3621
|
+
company: "acme",
|
|
3622
|
+
onConflict: "keep",
|
|
3623
|
+
vaultConfig: mockConfig,
|
|
3624
|
+
hqRoot: tmpDir,
|
|
3625
|
+
pullPrefixes: ["docs/handoff.md"],
|
|
3626
|
+
pullContentHashes: { "docs/handoff.md": `sha256:${hash}` },
|
|
3627
|
+
skipReindex: true,
|
|
3628
|
+
});
|
|
3629
|
+
const after = fs.lstatSync(localPath);
|
|
3630
|
+
expect(vi.mocked(s3Module.downloadFile)).toHaveBeenCalledTimes(1);
|
|
3631
|
+
expect(fs.readFileSync(localPath, "utf8")).toBe(content);
|
|
3632
|
+
expect(after.ctimeMs).toBe(before.ctimeMs);
|
|
3633
|
+
expect(result.filesDownloaded).toBe(0);
|
|
3634
|
+
expect(result.conflicts).toBe(0);
|
|
3635
|
+
});
|
|
3408
3636
|
it("anti-rollback guard is direction-gated: a SMALLER remote on a clean CONSUMER copy (direction=down) downloads, not conflict", async () => {
|
|
3409
3637
|
// The device only ever PULLED this file (direction: "down") — a consumer
|
|
3410
3638
|
// copy with no local authorship to protect. The gardener legitimately
|