@indigoai-us/hq-cloud 6.18.4-alpha.0 → 6.18.4

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.
@@ -3427,9 +3427,10 @@ describe("share", () => {
3427
3427
  expect(result.conflictPaths).toEqual([entityRel]);
3428
3428
  expect(fs.readFileSync(file, "utf-8")).toBe("---\nserver: raced\n---\n");
3429
3429
  });
3430
- it("flag on: never recreates a journaled entity the server removed", async () => {
3430
+ it("flag on: never recreates an unedited journaled entity the server removed", async () => {
3431
3431
  const file = writeEntity();
3432
- seedEntityJournal("merged-away-etag");
3432
+ const crypto = await import("crypto");
3433
+ seedEntityJournal("merged-away-etag", crypto.createHash("sha256").update(entityBody).digest("hex"));
3433
3434
  vi.mocked(headRemoteFile).mockResolvedValueOnce(null);
3434
3435
  const result = await share({
3435
3436
  paths: [file],
@@ -3441,8 +3442,35 @@ describe("share", () => {
3441
3442
  });
3442
3443
  expect(uploadFile).not.toHaveBeenCalled();
3443
3444
  expect(result.filesUploaded).toBe(0);
3445
+ // Unedited: the pull leg's remote-delete sweep removes it (local still
3446
+ // matches the journal baseline), so this is not a conflict.
3447
+ expect(result.conflictPaths).toEqual([]);
3444
3448
  expect(fs.readFileSync(file, "utf-8")).toBe(entityBody);
3445
3449
  });
3450
+ it("flag on: a locally edited entity the server removed is set aside and converges", async () => {
3451
+ const file = writeEntity("---\nlocal: checkpoint edit\n---\n");
3452
+ seedEntityJournal("merged-away-etag");
3453
+ vi.mocked(headRemoteFile).mockResolvedValueOnce(null);
3454
+ const events = [];
3455
+ const result = await share({
3456
+ paths: [file],
3457
+ company: "acme",
3458
+ vaultConfig: mockConfig,
3459
+ hqRoot: tmpDir,
3460
+ onConflict: "overwrite",
3461
+ ontologyEntityPush: true,
3462
+ onEvent: (e) => events.push(e),
3463
+ });
3464
+ expect(uploadFile).not.toHaveBeenCalled();
3465
+ expect(result.filesUploaded).toBe(0);
3466
+ expect(result.conflictPaths).toEqual([entityRel]);
3467
+ // The cloud deletion wins: the live path is gone and the journal row is
3468
+ // dropped, so the next pass has nothing left to report.
3469
+ expect(fs.existsSync(file)).toBe(false);
3470
+ expect(fs.readFileSync(sidecarIn(path.dirname(file)), "utf-8")).toBe("---\nlocal: checkpoint edit\n---\n");
3471
+ expect(journalAt(path.join(stateDir, "sync-journal.acme.json")).files[entityRel]).toBeUndefined();
3472
+ expect(events).toContainEqual(expect.objectContaining({ type: "conflict", path: entityRel, resolution: "keep" }));
3473
+ });
3446
3474
  it("unset option: reads the flag, and the local override turns the push on", async () => {
3447
3475
  const file = writeEntity();
3448
3476
  process.env.HQ_FLAG_CHECKPOINT_ONTOLOGY = "true";