@indigoai-us/hq-cloud 6.16.42 → 6.16.43

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.
@@ -4906,6 +4906,89 @@ describe("share", () => {
4906
4906
  const journal = journalAt(journalPath);
4907
4907
  expect(journal.files["flaky.md"]).toBeDefined();
4908
4908
  });
4909
+ it("scoped push defense-in-depth: a 403 on DeleteObject of a nested session-log key skips as scope-excluded without an error event", async () => {
4910
+ const companyRoot = path.join(tmpDir, "companies", "acme");
4911
+ fs.mkdirSync(companyRoot, { recursive: true });
4912
+ const journalPath = path.join(stateDir, "sync-journal.acme.json");
4913
+ const sessionLogKey = "companies/foo/workspace/.session-logs/canary-noncurrent-v1.jsonl";
4914
+ seedJournalAt(journalPath, ({
4915
+ version: "1",
4916
+ lastSync: new Date().toISOString(),
4917
+ files: {
4918
+ [sessionLogKey]: {
4919
+ hash: "h",
4920
+ size: 5,
4921
+ syncedAt: new Date().toISOString(),
4922
+ direction: "up",
4923
+ remoteEtag: "denied-etag",
4924
+ kind: "file",
4925
+ localDeleteIntent: deleteIntent("denied-etag", "h"),
4926
+ },
4927
+ },
4928
+ }));
4929
+ const denied = new Error("access denied");
4930
+ denied.name = "AccessDenied";
4931
+ vi.mocked(deleteRemoteFile).mockRejectedValueOnce(denied);
4932
+ const events = [];
4933
+ const result = await share({
4934
+ paths: [companyRoot],
4935
+ company: "acme",
4936
+ vaultConfig: mockConfig,
4937
+ hqRoot: tmpDir,
4938
+ skipUnchanged: true,
4939
+ propagateDeletes: true,
4940
+ propagateDeletePolicy: "owned-only",
4941
+ onEvent: (e) => events.push(e),
4942
+ });
4943
+ expect(result.filesDeleted).toBe(0);
4944
+ expect(result.filesExcludedByScope).toBe(1);
4945
+ expect(events.some((e) => e.type === "error")).toBe(false);
4946
+ const scopeEv = events.find((e) => e.type === "scope-excluded");
4947
+ expect(scopeEv).toBeDefined();
4948
+ expect(scopeEv.count).toBe(1);
4949
+ expect(scopeEv.samplePaths).toEqual([sessionLogKey]);
4950
+ expect(journalAt(journalPath).files[sessionLogKey]).toBeDefined();
4951
+ });
4952
+ it("scoped push defense-in-depth: a 403 on DeleteObject of an ordinary file still emits an error event", async () => {
4953
+ const companyRoot = path.join(tmpDir, "companies", "acme");
4954
+ fs.mkdirSync(companyRoot, { recursive: true });
4955
+ const journalPath = path.join(stateDir, "sync-journal.acme.json");
4956
+ seedJournalAt(journalPath, ({
4957
+ version: "1",
4958
+ lastSync: new Date().toISOString(),
4959
+ files: {
4960
+ "denied.md": {
4961
+ hash: "h",
4962
+ size: 5,
4963
+ syncedAt: new Date().toISOString(),
4964
+ direction: "up",
4965
+ remoteEtag: "denied-etag",
4966
+ kind: "file",
4967
+ localDeleteIntent: deleteIntent("denied-etag", "h"),
4968
+ },
4969
+ },
4970
+ }));
4971
+ const denied = new Error("access denied");
4972
+ denied.name = "AccessDenied";
4973
+ vi.mocked(deleteRemoteFile).mockRejectedValueOnce(denied);
4974
+ const events = [];
4975
+ const result = await share({
4976
+ paths: [companyRoot],
4977
+ company: "acme",
4978
+ vaultConfig: mockConfig,
4979
+ hqRoot: tmpDir,
4980
+ skipUnchanged: true,
4981
+ propagateDeletes: true,
4982
+ propagateDeletePolicy: "owned-only",
4983
+ onEvent: (e) => events.push(e),
4984
+ });
4985
+ expect(result.filesDeleted).toBe(0);
4986
+ expect(result.filesExcludedByScope).toBe(0);
4987
+ const errorEvent = events.find((e) => e.type === "error");
4988
+ expect(errorEvent).toMatchObject({ path: "denied.md" });
4989
+ expect(events.some((e) => e.type === "scope-excluded")).toBe(false);
4990
+ expect(journalAt(journalPath).files["denied.md"]).toBeDefined();
4991
+ });
4909
4992
  // ── Delete propagation safety: direction + filter guards (Bug B + C) ──────
4910
4993
  //
4911
4994
  // The pre-fix planner converted any journal-tracked path whose local file
@@ -6338,6 +6421,46 @@ describe("share", () => {
6338
6421
  expect(journalAfter.files["companies/foo/notes.md"]).toBeUndefined();
6339
6422
  expect(journalAfter.files["knowledge/x.md"]).toBeDefined();
6340
6423
  });
6424
+ it("decommissionPrefixes: skips nested workspace/.session-logs keys (VaultAccessRole DeleteObject deny)", async () => {
6425
+ fs.mkdirSync(path.join(tmpDir, "knowledge"), { recursive: true });
6426
+ fs.writeFileSync(path.join(tmpDir, "knowledge", "x.md"), "knowledge");
6427
+ const personalJournalPath = path.join(stateDir, "sync-journal.personal.json");
6428
+ seedJournalAt(personalJournalPath, ({
6429
+ version: "1",
6430
+ lastSync: new Date().toISOString(),
6431
+ files: {
6432
+ "companies/foo/notes.md": {
6433
+ hash: "h", size: 11, syncedAt: new Date().toISOString(),
6434
+ direction: "up",
6435
+ },
6436
+ "companies/foo/workspace/.session-logs/canary-noncurrent-v1.jsonl": {
6437
+ hash: "c", size: 8, syncedAt: new Date().toISOString(),
6438
+ direction: "up",
6439
+ },
6440
+ "knowledge/x.md": {
6441
+ hash: "k", size: 9, syncedAt: new Date().toISOString(),
6442
+ direction: "up",
6443
+ },
6444
+ },
6445
+ }));
6446
+ const result = await share({
6447
+ paths: [path.join(tmpDir, "knowledge")],
6448
+ company: "acme",
6449
+ vaultConfig: mockConfig,
6450
+ hqRoot: tmpDir,
6451
+ personalMode: true,
6452
+ journalSlug: "personal",
6453
+ skipUnchanged: true,
6454
+ propagateDeletePolicy: "owned-only",
6455
+ decommissionPrefixes: ["companies/foo"],
6456
+ });
6457
+ expect(result.filesDeleted).toBe(1);
6458
+ expect(deleteRemoteFile).toHaveBeenCalledWith(expect.anything(), "companies/foo/notes.md");
6459
+ expect(deleteRemoteFile).not.toHaveBeenCalledWith(expect.anything(), "companies/foo/workspace/.session-logs/canary-noncurrent-v1.jsonl");
6460
+ const journalAfter = journalAt(personalJournalPath);
6461
+ expect(journalAfter.files["companies/foo/notes.md"]).toBeUndefined();
6462
+ expect(journalAfter.files["companies/foo/workspace/.session-logs/canary-noncurrent-v1.jsonl"]).toBeDefined();
6463
+ });
6341
6464
  it("decommissionPrefixes: under owned-only policy, skips direction:'down' entries", async () => {
6342
6465
  // The orphan was pulled from another machine, never uploaded by this
6343
6466
  // one. owned-only refuses to remotely erase another machine's upload