@indigoai-us/hq-cloud 6.16.68-alpha.0 → 6.16.68-alpha.2

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 (38) hide show
  1. package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
  2. package/dist/bin/sync-runner-watch-loop.js +56 -9
  3. package/dist/bin/sync-runner-watch-loop.js.map +1 -1
  4. package/dist/bin/sync-runner.test.js +106 -0
  5. package/dist/bin/sync-runner.test.js.map +1 -1
  6. package/dist/cli/share.d.ts +3 -6
  7. package/dist/cli/share.d.ts.map +1 -1
  8. package/dist/cli/share.js +33 -11
  9. package/dist/cli/share.js.map +1 -1
  10. package/dist/cli/share.test.js +45 -0
  11. package/dist/cli/share.test.js.map +1 -1
  12. package/dist/journal-row-cache.d.ts +102 -0
  13. package/dist/journal-row-cache.d.ts.map +1 -0
  14. package/dist/journal-row-cache.heap.test.d.ts +2 -0
  15. package/dist/journal-row-cache.heap.test.d.ts.map +1 -0
  16. package/dist/journal-row-cache.heap.test.js +102 -0
  17. package/dist/journal-row-cache.heap.test.js.map +1 -0
  18. package/dist/journal-row-cache.js +549 -0
  19. package/dist/journal-row-cache.js.map +1 -0
  20. package/dist/journal-row-cache.test.d.ts +2 -0
  21. package/dist/journal-row-cache.test.d.ts.map +1 -0
  22. package/dist/journal-row-cache.test.js +155 -0
  23. package/dist/journal-row-cache.test.js.map +1 -0
  24. package/dist/journal-row-store.d.ts +14 -0
  25. package/dist/journal-row-store.d.ts.map +1 -1
  26. package/dist/journal-row-store.js +19 -0
  27. package/dist/journal-row-store.js.map +1 -1
  28. package/dist/journal-snapshot-rows.d.ts +4 -0
  29. package/dist/journal-snapshot-rows.d.ts.map +1 -1
  30. package/dist/journal-snapshot-rows.js +12 -0
  31. package/dist/journal-snapshot-rows.js.map +1 -1
  32. package/dist/journal.d.ts +11 -0
  33. package/dist/journal.d.ts.map +1 -1
  34. package/dist/journal.js +59 -3
  35. package/dist/journal.js.map +1 -1
  36. package/dist/journal.test.js +24 -1
  37. package/dist/journal.test.js.map +1 -1
  38. package/package.json +1 -1
@@ -1000,6 +1000,37 @@ describe("target resolution", () => {
1000
1000
  });
1001
1001
  expect(deps.stdout.events().some((event) => event.type === "all-complete")).toBe(false);
1002
1002
  });
1003
+ it("skips a 404 membership and completes the live company with exit 0", async () => {
1004
+ const get = vi.fn(async (uid) => {
1005
+ if (uid === "cmp_dead")
1006
+ throw new VaultNotFoundError("company deleted");
1007
+ return {
1008
+ uid,
1009
+ slug: "live",
1010
+ type: "company",
1011
+ status: "active",
1012
+ bucketName: "bucket-live",
1013
+ };
1014
+ });
1015
+ const deps = makeDeps({
1016
+ createVaultClient: () => makeVaultStub({
1017
+ memberships: [{ companyUid: "cmp_dead" }, { companyUid: "cmp_live" }],
1018
+ entityGet: get,
1019
+ }),
1020
+ });
1021
+ expect(await runRunner(["--companies"], deps)).toBe(0);
1022
+ expect(deps.stderr.events().filter((event) => event.type === "error")).toEqual([
1023
+ {
1024
+ type: "error",
1025
+ company: "cmp_dead",
1026
+ path: "(company-resolution)",
1027
+ message: "company entity lookup returned 404",
1028
+ },
1029
+ ]);
1030
+ expect(deps.sync).toHaveBeenCalledTimes(1);
1031
+ expect(deps.sync).toHaveBeenCalledWith(expect.objectContaining({ company: "cmp_live" }));
1032
+ expect(deps.stdout.events().some((event) => event.type === "all-complete")).toBe(true);
1033
+ });
1003
1034
  it("reports an intentional skipCompanies skip without treating it as a failed pass", async () => {
1004
1035
  const previous = process.env.HQ_SYNC_SKIP_COMPANIES;
1005
1036
  process.env.HQ_SYNC_SKIP_COMPANIES = "paused";
@@ -9400,6 +9431,81 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
9400
9431
  await loop;
9401
9432
  capture.restore();
9402
9433
  });
9434
+ it("skips a 404 company route in a mixed drain and records a completed full reconcile", async () => {
9435
+ const previousCoordinator = process.env.HQ_SYNC_PARALLEL_COORDINATOR;
9436
+ const previousInterval = process.env.HQ_SYNC_FULL_RECONCILE_MS;
9437
+ process.env.HQ_SYNC_PARALLEL_COORDINATOR = "1";
9438
+ process.env.HQ_SYNC_FULL_RECONCILE_MS = "10800000";
9439
+ const failedLines = [];
9440
+ const decisions = [];
9441
+ const spy = vi
9442
+ .spyOn(process.stderr, "write")
9443
+ .mockImplementation((chunk) => {
9444
+ const text = String(chunk);
9445
+ if (text.includes("watch pass failed"))
9446
+ failedLines.push(text);
9447
+ if (typeof chunk === "string" && chunk.startsWith("{")) {
9448
+ try {
9449
+ const parsed = JSON.parse(text);
9450
+ if (typeof parsed === "object" &&
9451
+ parsed !== null &&
9452
+ parsed.type === "full-reconcile-decision") {
9453
+ decisions.push(parsed);
9454
+ }
9455
+ }
9456
+ catch {
9457
+ // non-JSON diagnostic
9458
+ }
9459
+ }
9460
+ return true;
9461
+ });
9462
+ const runPass = vi.fn(async (argv) => {
9463
+ const companyIdx = argv.indexOf("--company");
9464
+ if (companyIdx >= 0 && argv[companyIdx + 1] === "acme") {
9465
+ return UNRESOLVED_COMPANY_EXIT;
9466
+ }
9467
+ return 0;
9468
+ });
9469
+ try {
9470
+ const { loop, watcher, tick, shutdown } = startBatchDrainLoop(runPass);
9471
+ await flushLoopMicrotasks(40);
9472
+ expect(failedLines).toEqual([]);
9473
+ expect(decisions.some((record) => record.mode === "full")).toBe(true);
9474
+ watcher.emit("companies/acme/note.md", {
9475
+ paths: new Map([
9476
+ ["/tmp/hq/companies/acme/note.md", "companies/acme/note.md"],
9477
+ ["/tmp/hq/companies/indigo/note.md", "companies/indigo/note.md"],
9478
+ ]),
9479
+ });
9480
+ tick();
9481
+ await flushLoopMicrotasks(40);
9482
+ expect(failedLines).toEqual([]);
9483
+ expect(runPass.mock.calls.some((call) => Array.isArray(call[0]) &&
9484
+ call[0].includes("--company") &&
9485
+ call[0].includes("acme"))).toBe(true);
9486
+ expect(runPass.mock.calls.some((call) => Array.isArray(call[0]) &&
9487
+ call[0].includes("--company") &&
9488
+ call[0].includes("indigo"))).toBe(true);
9489
+ tick();
9490
+ await flushLoopMicrotasks(20);
9491
+ const later = decisions.filter((record) => record.pollTick >= 2);
9492
+ expect(later.length).toBeGreaterThan(0);
9493
+ expect(later.some((record) => record.elapsedSinceLastCompletedFullReconcileMs !== null)).toBe(true);
9494
+ shutdown();
9495
+ await loop;
9496
+ }
9497
+ finally {
9498
+ spy.mockRestore();
9499
+ if (previousCoordinator === undefined)
9500
+ delete process.env.HQ_SYNC_PARALLEL_COORDINATOR;
9501
+ else
9502
+ process.env.HQ_SYNC_PARALLEL_COORDINATOR = previousCoordinator;
9503
+ if (previousInterval === undefined)
9504
+ delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
9505
+ else
9506
+ process.env.HQ_SYNC_FULL_RECONCILE_MS = previousInterval;
9507
+ }
9508
+ });
9403
9509
  it("does not escalate a fully-enumerated over-limit batch to a full reconcile", async () => {
9404
9510
  const savedLimit = process.env.HQ_SYNC_EVENT_BATCH_LIMIT;
9405
9511
  const savedInterval = process.env.HQ_SYNC_FULL_RECONCILE_MS;