@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
@@ -30,8 +30,6 @@ vi.mock("../s3.js", async (importOriginal) => {
30
30
  readVerifiedRemoteSymlinkTarget: vi.fn().mockResolvedValue(null),
31
31
  primeObjectTransport: vi.fn().mockResolvedValue(undefined),
32
32
  primeUploads: vi.fn().mockResolvedValue(undefined),
33
- publishedContentHash: actual.publishedContentHash,
34
- setUploadContentHash: actual.setUploadContentHash,
35
33
  // Real exports share.ts now imports for the HQ-DESKTOP-54 privilege skip.
36
34
  WINDOWS_SYMLINK_PRIVILEGE_REMEDY: "Enable Windows Developer Mode (Settings > Privacy & security > For developers) or run HQ sync once from an elevated terminal, then sync again.",
37
35
  WindowsSymlinkPrivilegeError: class WindowsSymlinkPrivilegeError extends Error {
@@ -64,13 +62,14 @@ vi.mock("readline", () => ({
64
62
  })),
65
63
  }));
66
64
  import * as readline from "readline";
67
- import { share, ServerOwnedPushPathsError, UnreachablePushPathsError, UnregisteredCompanySkillError, currentUploadBytes, parseRegisteredCompanySkillUid, _testing as shareTesting, } from "./share.js";
65
+ import { share, ServerOwnedPushPathsError, UnreachablePushPathsError, UnregisteredCompanySkillError, currentUploadBytes, FULL_PUSH_COOPERATIVE_CHECKPOINT_BATCH_SIZE, parseRegisteredCompanySkillUid, _testing as shareTesting, } from "./share.js";
68
66
  import { deleteRemoteFile, downloadFile, headRemoteFile, primeObjectTransport, primeUploads, uploadFile, uploadSymlink, WindowsSymlinkPrivilegeError, } from "../s3.js";
69
67
  import { VaultAuthError, VaultClientError, VaultPermissionDeniedError, } from "../vault-client.js";
70
68
  import { CognitoRefreshError } from "../cognito-auth.js";
71
69
  import { AreaLedgerMigration, closeCachedAreaJournalMigration, hashFile, openJournalStateStoreForMigration, readJournal, readJournalScoped, setAreaLedgerMigrationTestHooksForTest, writeJournal, } from "../journal.js";
72
70
  import { ReconcileCursorStore } from "../sync/reconcile-cursor.js";
73
71
  import { AreaResolver } from "../sync/area-resolver.js";
72
+ import { CooperativePassScheduler } from "../bin/sync-runner-watch-loop.js";
74
73
  /**
75
74
  * Read a journal the way production does.
76
75
  *
@@ -1167,6 +1166,91 @@ describe("share", () => {
1167
1166
  // Remote key must be company-relative, not hqRoot-relative
1168
1167
  expect(uploadFile).toHaveBeenCalledWith(expect.anything(), testFile, "test.md", undefined, expect.anything());
1169
1168
  });
1169
+ it("hands queued realtime work a settled full-push boundary without losing journal rows", async () => {
1170
+ const companyRoot = path.join(tmpDir, "companies", "acme");
1171
+ const fileCount = FULL_PUSH_COOPERATIVE_CHECKPOINT_BATCH_SIZE + 1;
1172
+ for (let index = 0; index < fileCount; index++) {
1173
+ const file = path.join(companyRoot, "docs", "full-push", `${index}.md`);
1174
+ fs.mkdirSync(path.dirname(file), { recursive: true });
1175
+ fs.writeFileSync(file, "full-push body");
1176
+ }
1177
+ const scheduler = new CooperativePassScheduler(() => 0);
1178
+ let uploadsCompleted = 0;
1179
+ let uploadsInFlight = 0;
1180
+ let maxUploadsInFlight = 0;
1181
+ let realtimeQueued = false;
1182
+ let realtimeDispatchedAt = -1;
1183
+ let checkpointCalls = 0;
1184
+ let realtimePass;
1185
+ const upload = vi.mocked(uploadFile);
1186
+ const originalUpload = upload.getMockImplementation();
1187
+ upload.mockImplementation(async () => {
1188
+ uploadsInFlight++;
1189
+ maxUploadsInFlight = Math.max(maxUploadsInFlight, uploadsInFlight);
1190
+ await Promise.resolve();
1191
+ uploadsCompleted++;
1192
+ if (uploadsCompleted === 1) {
1193
+ realtimeQueued = true;
1194
+ realtimePass = scheduler.submit(async () => {
1195
+ // `executeUploads` drains the full unit before the scheduler grants
1196
+ // realtime the root lock: no two durable writers overlap.
1197
+ expect(uploadsInFlight).toBe(0);
1198
+ realtimeDispatchedAt = uploadsCompleted;
1199
+ const realtimePath = path.join(companyRoot, "docs", "realtime.md");
1200
+ fs.writeFileSync(realtimePath, "realtime body");
1201
+ const journal = readJournal("acme");
1202
+ journal.files["docs/realtime.md"] = {
1203
+ hash: hashFile(realtimePath),
1204
+ size: fs.statSync(realtimePath).size,
1205
+ syncedAt: "2026-09-17T12:00:00.000Z",
1206
+ direction: "up",
1207
+ remoteEtag: "realtime",
1208
+ mtimeMs: fs.statSync(realtimePath).mtimeMs,
1209
+ ctimeMs: fs.statSync(realtimePath).ctimeMs,
1210
+ };
1211
+ writeJournal("acme", journal);
1212
+ }, "realtime");
1213
+ }
1214
+ uploadsInFlight--;
1215
+ return { etag: '"full-push-etag"' };
1216
+ });
1217
+ try {
1218
+ await scheduler.submit(async ({ checkpoint }) => {
1219
+ await share({
1220
+ paths: [companyRoot],
1221
+ company: "acme",
1222
+ vaultConfig: mockConfig,
1223
+ hqRoot: tmpDir,
1224
+ skipUnchanged: true,
1225
+ propagateDeletes: true,
1226
+ cooperativeCheckpoint: async () => {
1227
+ checkpointCalls++;
1228
+ return checkpoint();
1229
+ },
1230
+ });
1231
+ }, "chore");
1232
+ await realtimePass;
1233
+ }
1234
+ finally {
1235
+ if (originalUpload)
1236
+ upload.mockImplementation(originalUpload);
1237
+ else
1238
+ upload.mockReset();
1239
+ }
1240
+ expect(maxUploadsInFlight).toBeGreaterThan(1);
1241
+ expect(realtimeQueued).toBe(true);
1242
+ expect(checkpointCalls).toBeGreaterThan(0);
1243
+ expect(realtimeDispatchedAt).toBeGreaterThan(0);
1244
+ expect(realtimeDispatchedAt).toBeLessThanOrEqual(FULL_PUSH_COOPERATIVE_CHECKPOINT_BATCH_SIZE);
1245
+ // Reopen the durable journal, rather than inspecting the stale first-pass
1246
+ // object: every pre-handoff key and the realtime key must survive.
1247
+ const durable = readJournal("acme");
1248
+ expect(Object.keys(durable.files)).toHaveLength(fileCount + 1);
1249
+ expect(durable.files["docs/realtime.md"]).toBeDefined();
1250
+ for (let index = 0; index < fileCount; index++) {
1251
+ expect(durable.files[`docs/full-push/${index}.md`]).toBeDefined();
1252
+ }
1253
+ }, 120_000);
1170
1254
  it("replans an upload from the bytes present when its action starts", async () => {
1171
1255
  const companyRoot = path.join(tmpDir, "companies", "acme");
1172
1256
  fs.mkdirSync(companyRoot, { recursive: true });
@@ -2437,96 +2521,6 @@ describe("share", () => {
2437
2521
  remoteEtag: "288bfa91684ae21f9ae27c061254d412",
2438
2522
  });
2439
2523
  });
2440
- it("does not PUT when the remote publishes the same SHA-256 under a new SSE-KMS ETag", async () => {
2441
- const companyRoot = path.join(tmpDir, "companies", "acme");
2442
- fs.mkdirSync(companyRoot, { recursive: true });
2443
- const testFile = path.join(companyRoot, "lineage-noop.md");
2444
- fs.writeFileSync(testFile, "same bytes, new encrypted version");
2445
- const stat = fs.lstatSync(testFile);
2446
- const localHash = hashFile(testFile);
2447
- seedJournalAt(path.join(stateDir, "sync-journal.acme.json"), {
2448
- version: "1",
2449
- lastSync: new Date().toISOString(),
2450
- files: {
2451
- "lineage-noop.md": {
2452
- hash: "b".repeat(64),
2453
- size: stat.size,
2454
- mtimeMs: stat.mtimeMs - 1,
2455
- ctimeMs: stat.ctimeMs - 1,
2456
- remoteEtag: "journal-kms-etag",
2457
- syncedAt: new Date().toISOString(),
2458
- direction: "up",
2459
- },
2460
- },
2461
- });
2462
- vi.mocked(headRemoteFile).mockResolvedValueOnce({
2463
- lastModified: new Date(),
2464
- etag: '"new-kms-etag"',
2465
- size: stat.size,
2466
- metadata: { "hq-content-sha256": localHash },
2467
- });
2468
- const result = await share({
2469
- paths: [testFile],
2470
- company: "acme",
2471
- vaultConfig: mockConfig,
2472
- hqRoot: tmpDir,
2473
- onConflict: "overwrite",
2474
- });
2475
- expect(result.filesUploaded).toBe(0);
2476
- expect(result.conflictPaths).toEqual([]);
2477
- expect(uploadFile).not.toHaveBeenCalled();
2478
- expect(readJournal("acme").files["lineage-noop.md"]).toMatchObject({
2479
- hash: localHash,
2480
- remoteEtag: "new-kms-etag",
2481
- });
2482
- });
2483
- it("refuses an unchanged journal baseline after a published remote hash advances", async () => {
2484
- const companyRoot = path.join(tmpDir, "companies", "acme");
2485
- fs.mkdirSync(companyRoot, { recursive: true });
2486
- const testFile = path.join(companyRoot, "lineage-stale-replay.md");
2487
- fs.writeFileSync(testFile, "the old local generation");
2488
- const stat = fs.lstatSync(testFile);
2489
- const localHash = hashFile(testFile);
2490
- seedJournalAt(path.join(stateDir, "sync-journal.acme.json"), {
2491
- version: "1",
2492
- lastSync: new Date().toISOString(),
2493
- files: {
2494
- "lineage-stale-replay.md": {
2495
- hash: localHash,
2496
- size: stat.size,
2497
- mtimeMs: stat.mtimeMs,
2498
- ctimeMs: stat.ctimeMs,
2499
- remoteEtag: "old-kms-etag",
2500
- syncedAt: new Date().toISOString(),
2501
- direction: "up",
2502
- },
2503
- },
2504
- });
2505
- vi.mocked(headRemoteFile).mockResolvedValueOnce({
2506
- lastModified: new Date(),
2507
- etag: '"new-kms-etag"',
2508
- size: stat.size,
2509
- metadata: { "hq-content-sha256": "b".repeat(64) },
2510
- });
2511
- const events = [];
2512
- const result = await share({
2513
- paths: [testFile],
2514
- company: "acme",
2515
- vaultConfig: mockConfig,
2516
- hqRoot: tmpDir,
2517
- onConflict: "overwrite",
2518
- onEvent: (event) => events.push(event),
2519
- });
2520
- expect(result.filesUploaded).toBe(0);
2521
- expect(result.conflictPaths).toEqual(["lineage-stale-replay.md"]);
2522
- expect(uploadFile).not.toHaveBeenCalled();
2523
- expect(events).toContainEqual({
2524
- type: "conflict",
2525
- path: "lineage-stale-replay.md",
2526
- direction: "push",
2527
- resolution: "skip",
2528
- });
2529
- });
2530
2524
  it("fresh-install multipart collision: byte-identical remote is NOT a conflict (reconciled, no mirror)", async () => {
2531
2525
  // Root cause of "HQ installs with conflicts": on a first push the
2532
2526
  // journal is empty, so the fresh-collision branch decides conflict-vs-