@indigoai-us/hq-cloud 6.16.86-alpha.0 → 6.16.87-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 (37) hide show
  1. package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
  2. package/dist/bin/sync-runner-watch-loop.js +59 -13
  3. package/dist/bin/sync-runner-watch-loop.js.map +1 -1
  4. package/dist/bin/sync-runner.test.js.map +1 -1
  5. package/dist/cli/sync.d.ts.map +1 -1
  6. package/dist/cli/sync.js +2 -2
  7. package/dist/cli/sync.js.map +1 -1
  8. package/dist/cli/sync.test.js +43 -9
  9. package/dist/cli/sync.test.js.map +1 -1
  10. package/dist/lib/describe-error.d.ts.map +1 -1
  11. package/dist/lib/describe-error.js +2 -0
  12. package/dist/lib/describe-error.js.map +1 -1
  13. package/dist/lib/describe-error.test.js +8 -0
  14. package/dist/lib/describe-error.test.js.map +1 -1
  15. package/dist/sync/event-sync.d.ts +2 -0
  16. package/dist/sync/event-sync.d.ts.map +1 -1
  17. package/dist/sync/event-sync.js +4 -0
  18. package/dist/sync/event-sync.js.map +1 -1
  19. package/dist/sync/event-sync.test.js +65 -0
  20. package/dist/sync/event-sync.test.js.map +1 -1
  21. package/dist/sync/pull-scope.d.ts +2 -0
  22. package/dist/sync/pull-scope.d.ts.map +1 -1
  23. package/dist/sync/pull-scope.js +10 -0
  24. package/dist/sync/pull-scope.js.map +1 -1
  25. package/dist/sync/push-receiver.d.ts +5 -0
  26. package/dist/sync/push-receiver.d.ts.map +1 -1
  27. package/dist/sync/push-receiver.js +36 -15
  28. package/dist/sync/push-receiver.js.map +1 -1
  29. package/dist/sync/push-receiver.test.js +184 -44
  30. package/dist/sync/push-receiver.test.js.map +1 -1
  31. package/dist/watcher.d.ts +4 -0
  32. package/dist/watcher.d.ts.map +1 -1
  33. package/dist/watcher.js +16 -4
  34. package/dist/watcher.js.map +1 -1
  35. package/dist/watcher.test.js +50 -3
  36. package/dist/watcher.test.js.map +1 -1
  37. package/package.json +1 -1
@@ -4933,6 +4933,22 @@ describe("sync", () => {
4933
4933
  downloadFile.mockImplementation(originalDownload);
4934
4934
  }
4935
4935
  });
4936
+ it("preserves the typed cause on a per-file download error event", async () => {
4937
+ vi.mocked(s3Module.listRemoteFiles).mockResolvedValueOnce([
4938
+ { key: "docs/linked/notes.md", size: 42, lastModified: new Date(), etag: '"linked"' },
4939
+ ]);
4940
+ vi.mocked(s3Module.downloadFile).mockRejectedValueOnce(new s3Module.DanglingSymlinkParentError("docs/linked/notes.md", "docs/linked"));
4941
+ const events = [];
4942
+ await sync({
4943
+ company: "acme",
4944
+ vaultConfig: mockConfig,
4945
+ hqRoot: tmpDir,
4946
+ skipReindex: true,
4947
+ onEvent: (event) => events.push(event),
4948
+ });
4949
+ const error = events.find((event) => event.type === "error" && event.path === "docs/linked/notes.md");
4950
+ expect(error?.message).toContain("DanglingSymlinkParentError");
4951
+ });
4936
4952
  it("retains the journal entry when tombstone unlink fails with EACCES (Codex P1 — Bug #9 follow-up)", async () => {
4937
4953
  // Codex review on PR #24 caught this: pre-fix the tombstone branch
4938
4954
  // dropped the journal entry unconditionally even when the local
@@ -4947,12 +4963,16 @@ describe("sync", () => {
4947
4963
  fs.mkdirSync(path.join(companyRoot, "docs"), { recursive: true });
4948
4964
  const lockedPath = path.join(companyRoot, "docs", "locked-by-peer.md");
4949
4965
  fs.writeFileSync(lockedPath, "still here");
4966
+ const matchingBaselineHash = crypto
4967
+ .createHash("sha256")
4968
+ .update("still here")
4969
+ .digest("hex");
4950
4970
  fs.writeFileSync(journalPath, JSON.stringify({
4951
4971
  version: "1",
4952
4972
  lastSync: new Date(Date.now() - 60_000).toISOString(),
4953
4973
  files: {
4954
4974
  "docs/locked-by-peer.md": {
4955
- hash: "locked-hash",
4975
+ hash: matchingBaselineHash,
4956
4976
  size: 10,
4957
4977
  syncedAt: new Date(Date.now() - 60_000).toISOString(),
4958
4978
  direction: "down",
@@ -4962,16 +4982,27 @@ describe("sync", () => {
4962
4982
  }));
4963
4983
  // Remote LIST is empty → tombstone candidate.
4964
4984
  vi.mocked(s3Module.listRemoteFiles).mockResolvedValueOnce([]);
4965
- // Strip write perms from the parent dir so the unlink throws EACCES
4966
- // (and EPERM on some POSIX variants — both must be retained). The
4967
- // dir read perm is retained so the planner can still lstat the file.
4968
- const parentDir = path.join(companyRoot, "docs");
4969
- fs.chmodSync(parentDir, 0o500);
4985
+ vi.mocked(s3Module.headRemoteFile).mockResolvedValue(null);
4986
+ const events = [];
4987
+ let unlinkAttempted = false;
4988
+ const originalUnlinkSync = fs.unlinkSync;
4989
+ const unlinkSync = vi.spyOn(fs, "unlinkSync").mockImplementation((candidate) => {
4990
+ if (String(candidate) === lockedPath) {
4991
+ unlinkAttempted = true;
4992
+ throw Object.assign(new Error("permission denied"), {
4993
+ code: "EACCES",
4994
+ syscall: "unlink",
4995
+ path: lockedPath,
4996
+ });
4997
+ }
4998
+ return originalUnlinkSync(candidate);
4999
+ });
4970
5000
  try {
4971
5001
  const result = await sync({
4972
5002
  company: "acme",
4973
5003
  vaultConfig: mockConfig,
4974
5004
  hqRoot: tmpDir,
5005
+ onEvent: (event) => events.push(event),
4975
5006
  });
4976
5007
  // Local file is still present (unlink failed).
4977
5008
  expect(fs.existsSync(lockedPath)).toBe(true);
@@ -4980,11 +5011,14 @@ describe("sync", () => {
4980
5011
  // Journal entry MUST be retained so the next sync retries.
4981
5012
  const journal = journalAt(journalPath);
4982
5013
  expect(journal.files["docs/locked-by-peer.md"]).toBeDefined();
4983
- expect(journal.files["docs/locked-by-peer.md"].hash).toBe("locked-hash");
5014
+ expect(journal.files["docs/locked-by-peer.md"].hash).toBe(matchingBaselineHash);
5015
+ expect(unlinkAttempted).toBe(true);
5016
+ const unlinkError = events.find((event) => event.type === "error" && event.path === "docs/locked-by-peer.md");
5017
+ expect(unlinkError?.message).toContain("code=EACCES");
5018
+ expect(unlinkError?.message).toContain("syscall=unlink");
4984
5019
  }
4985
5020
  finally {
4986
- // Restore write perms so afterEach rmSync can clean the tmp dir.
4987
- fs.chmodSync(parentDir, 0o700);
5021
+ unlinkSync.mockRestore();
4988
5022
  }
4989
5023
  });
4990
5024
  it("does NOT tombstone keys that are now ignored by .hqignore (safety guard)", async () => {