@indigoai-us/hq-cloud 6.15.99 → 6.15.100

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.
@@ -811,7 +811,7 @@ describe("US-002: TreeWatcher — debounce coalesce (FakeClock seam)", () => {
811
811
  clock.advance(1);
812
812
  expect(changed).toHaveBeenCalledTimes(1);
813
813
  });
814
- it("flushes a quiet, known-small batch through the short debounce window", () => {
814
+ it("flushes a quiet, known-small batch through the 60s debounce window", () => {
815
815
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), "hq-watcher-small-debounce-"));
816
816
  try {
817
817
  const small = path.join(dir, "small.md");
@@ -820,8 +820,8 @@ describe("US-002: TreeWatcher — debounce coalesce (FakeClock seam)", () => {
820
820
  const changed = vi.fn();
821
821
  const watcher = new TreeWatcher({
822
822
  hqRoot: dir,
823
- debounceMs: 15_000,
824
- smallBatchDebounceMs: 2_500,
823
+ debounceMs: 60_000,
824
+ smallBatchDebounceMs: 60_000,
825
825
  smallBatchMaxPaths: 8,
826
826
  smallBatchMaxBytes: 1024 * 1024,
827
827
  clock,
@@ -829,7 +829,10 @@ describe("US-002: TreeWatcher — debounce coalesce (FakeClock seam)", () => {
829
829
  });
830
830
  watcher.onChange(changed);
831
831
  watcher.handleEvent(small);
832
- clock.advance(2_499);
832
+ // The old 2.5s small-batch fast path must no longer fire.
833
+ clock.advance(2_500);
834
+ expect(changed).not.toHaveBeenCalled();
835
+ clock.advance(57_499);
833
836
  expect(changed).not.toHaveBeenCalled();
834
837
  clock.advance(1);
835
838
  expect(changed).toHaveBeenCalledTimes(1);
@@ -840,15 +843,15 @@ describe("US-002: TreeWatcher — debounce coalesce (FakeClock seam)", () => {
840
843
  fs.rmSync(dir, { recursive: true, force: true });
841
844
  }
842
845
  });
843
- it("keeps a burst above the small-path cap on the 15s debounce", () => {
846
+ it("keeps a burst above the small-path cap on the 60s debounce", () => {
844
847
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), "hq-watcher-burst-debounce-"));
845
848
  try {
846
849
  const clock = new FakeClock();
847
850
  const changed = vi.fn();
848
851
  const watcher = new TreeWatcher({
849
852
  hqRoot: dir,
850
- debounceMs: 15_000,
851
- smallBatchDebounceMs: 2_500,
853
+ debounceMs: 60_000,
854
+ smallBatchDebounceMs: 60_000,
852
855
  smallBatchMaxPaths: 8,
853
856
  smallBatchMaxBytes: 1024 * 1024,
854
857
  clock,
@@ -862,8 +865,8 @@ describe("US-002: TreeWatcher — debounce coalesce (FakeClock seam)", () => {
862
865
  clock.advance(100);
863
866
  }
864
867
  // The final event landed at t=800ms; the loop's final 100ms advance is
865
- // outside the quiet window, so stop one millisecond before t=15_800ms.
866
- clock.advance(14_899);
868
+ // outside the quiet window, so stop one millisecond before t=60_800ms.
869
+ clock.advance(59_899);
867
870
  expect(changed).not.toHaveBeenCalled();
868
871
  clock.advance(1);
869
872
  expect(changed).toHaveBeenCalledTimes(1);
@@ -883,9 +886,9 @@ describe("US-002: TreeWatcher — debounce coalesce (FakeClock seam)", () => {
883
886
  const changed = vi.fn();
884
887
  const watcher = new TreeWatcher({
885
888
  hqRoot: dir,
886
- debounceMs: 15_000,
889
+ debounceMs: 60_000,
887
890
  maxWaitMs: 120_000,
888
- smallBatchDebounceMs: 2_500,
891
+ smallBatchDebounceMs: 60_000,
889
892
  smallBatchMaxPaths: 8,
890
893
  smallBatchMaxBytes: 1024 * 1024,
891
894
  clock,
@@ -914,8 +917,8 @@ describe("US-002: TreeWatcher — debounce coalesce (FakeClock seam)", () => {
914
917
  const changed = vi.fn();
915
918
  const watcher = new TreeWatcher({
916
919
  hqRoot: dir,
917
- debounceMs: 15_000,
918
- smallBatchDebounceMs: 2_500,
920
+ debounceMs: 60_000,
921
+ smallBatchDebounceMs: 60_000,
919
922
  smallBatchMaxPaths: 8,
920
923
  smallBatchMaxBytes: 1024 * 1024,
921
924
  clock,
@@ -924,9 +927,9 @@ describe("US-002: TreeWatcher — debounce coalesce (FakeClock seam)", () => {
924
927
  watcher.onChange(changed);
925
928
  watcher.handleEvent(deleted, "unlinkDir");
926
929
  watcher.handleEvent(deleted, "unlink");
927
- clock.advance(2_500);
930
+ clock.advance(59_999);
928
931
  expect(changed).not.toHaveBeenCalled();
929
- clock.advance(12_500);
932
+ clock.advance(1);
930
933
  expect(changed).toHaveBeenCalledTimes(1);
931
934
  expect(changed.mock.calls[0][1].changes.get(deleted)).toMatchObject({
932
935
  kind: "unlinkDir",
@@ -948,8 +951,8 @@ describe("US-002: TreeWatcher — debounce coalesce (FakeClock seam)", () => {
948
951
  const changed = vi.fn();
949
952
  const watcher = new TreeWatcher({
950
953
  hqRoot: dir,
951
- debounceMs: 15_000,
952
- smallBatchDebounceMs: 2_500,
954
+ debounceMs: 60_000,
955
+ smallBatchDebounceMs: 60_000,
953
956
  smallBatchMaxPaths: 8,
954
957
  smallBatchMaxBytes: 1024 * 1024,
955
958
  maxPendingPaths: 1,
@@ -961,9 +964,9 @@ describe("US-002: TreeWatcher — debounce coalesce (FakeClock seam)", () => {
961
964
  watcher.onChange(changed);
962
965
  watcher.handleEvent(first);
963
966
  watcher.handleEvent(dropped);
964
- clock.advance(2_500);
967
+ clock.advance(59_999);
965
968
  expect(changed).not.toHaveBeenCalled();
966
- clock.advance(12_500);
969
+ clock.advance(1);
967
970
  expect(changed).toHaveBeenCalledTimes(1);
968
971
  expect(changed.mock.calls[0][1]).toMatchObject({ overflowed: true });
969
972
  watcher.dispose();
@@ -986,13 +989,13 @@ describe("US-002: TreeWatcher — debounce coalesce (FakeClock seam)", () => {
986
989
  const changed = vi.fn();
987
990
  const watcher = new TreeWatcher({
988
991
  hqRoot: ROOT,
989
- debounceMs: 15_000,
992
+ debounceMs: 60_000,
990
993
  maxWaitMs: 120_000,
991
994
  personalMode: false,
992
995
  clock,
993
996
  });
994
997
  watcher.onChange(changed);
995
- // Events every 10s — the quiet window (15s) never elapses, so only the
998
+ // Events every 10s — the quiet window (60s) never elapses, so only the
996
999
  // max-wait ceiling can fire. Events land at t=0s..110s.
997
1000
  for (let i = 0; i < 12; i++) {
998
1001
  watcher.handleEvent(path.join(ROOT, `personal/file-${i % 3}.md`));
@@ -1012,7 +1015,7 @@ describe("US-002: TreeWatcher — debounce coalesce (FakeClock seam)", () => {
1012
1015
  // The ceiling resets between windows: a fresh burst gets a fresh window
1013
1016
  // and settles on the ordinary quiet period.
1014
1017
  watcher.handleEvent(path.join(ROOT, "personal/next.md"));
1015
- clock.advance(15_000);
1018
+ clock.advance(60_000);
1016
1019
  expect(changed).toHaveBeenCalledTimes(2);
1017
1020
  expect(watcher.pendingTimerCount()).toBe(0);
1018
1021
  watcher.dispose();
@@ -1022,14 +1025,14 @@ describe("US-002: TreeWatcher — debounce coalesce (FakeClock seam)", () => {
1022
1025
  const changed = vi.fn();
1023
1026
  const watcher = new TreeWatcher({
1024
1027
  hqRoot: ROOT,
1025
- debounceMs: 15_000,
1028
+ debounceMs: 60_000,
1026
1029
  maxWaitMs: 1, // absurdly low — must be floored to the quiet window
1027
1030
  personalMode: false,
1028
1031
  clock,
1029
1032
  });
1030
1033
  watcher.onChange(changed);
1031
1034
  watcher.handleEvent(path.join(ROOT, "personal/a.md"));
1032
- clock.advance(14_999);
1035
+ clock.advance(59_999);
1033
1036
  expect(changed).not.toHaveBeenCalled();
1034
1037
  clock.advance(1);
1035
1038
  expect(changed).toHaveBeenCalledTimes(1);
@@ -2358,7 +2361,17 @@ describe("resolveEventDebounceConfig", () => {
2358
2361
  process.env[k] = saved[k];
2359
2362
  }
2360
2363
  });
2361
- it("defaults to a 15s quiet window and a 120s max-wait ceiling", () => {
2364
+ it("defaults to a 60s quiet window, a 60s small-batch window, and a 120s max-wait ceiling", () => {
2365
+ expect(DEFAULT_EVENT_DEBOUNCE_MS).toBe(60_000);
2366
+ expect(DEFAULT_EVENT_SMALL_BATCH_DEBOUNCE_MS).toBe(60_000);
2367
+ expect(DEFAULT_EVENT_MAX_WAIT_MS).toBe(120_000);
2368
+ expect(resolveEventDebounceConfig({})).toEqual({
2369
+ debounceMs: 60_000,
2370
+ maxWaitMs: 120_000,
2371
+ smallBatchDebounceMs: 60_000,
2372
+ smallBatchMaxPaths: DEFAULT_EVENT_SMALL_BATCH_MAX_PATHS,
2373
+ smallBatchMaxBytes: DEFAULT_EVENT_SMALL_BATCH_MAX_BYTES,
2374
+ });
2362
2375
  expect(resolveEventDebounceConfig()).toEqual({
2363
2376
  debounceMs: DEFAULT_EVENT_DEBOUNCE_MS,
2364
2377
  maxWaitMs: DEFAULT_EVENT_MAX_WAIT_MS,
@@ -2366,8 +2379,6 @@ describe("resolveEventDebounceConfig", () => {
2366
2379
  smallBatchMaxPaths: DEFAULT_EVENT_SMALL_BATCH_MAX_PATHS,
2367
2380
  smallBatchMaxBytes: DEFAULT_EVENT_SMALL_BATCH_MAX_BYTES,
2368
2381
  });
2369
- expect(DEFAULT_EVENT_DEBOUNCE_MS).toBe(15_000);
2370
- expect(DEFAULT_EVENT_MAX_WAIT_MS).toBe(120_000);
2371
2382
  });
2372
2383
  it("honors env overrides", () => {
2373
2384
  process.env[EVENT_DEBOUNCE_MS_ENV] = "5000";
@@ -2383,6 +2394,40 @@ describe("resolveEventDebounceConfig", () => {
2383
2394
  smallBatchMaxBytes: 4096,
2384
2395
  });
2385
2396
  });
2397
+ it("lets HQ_SYNC_EVENT_DEBOUNCE_MS override the quiet window independently", () => {
2398
+ expect(resolveEventDebounceConfig({
2399
+ [EVENT_DEBOUNCE_MS_ENV]: "90000",
2400
+ })).toEqual({
2401
+ debounceMs: 90_000,
2402
+ maxWaitMs: 120_000,
2403
+ smallBatchDebounceMs: 60_000,
2404
+ smallBatchMaxPaths: DEFAULT_EVENT_SMALL_BATCH_MAX_PATHS,
2405
+ smallBatchMaxBytes: DEFAULT_EVENT_SMALL_BATCH_MAX_BYTES,
2406
+ });
2407
+ });
2408
+ it("lets HQ_SYNC_EVENT_SMALL_BATCH_DEBOUNCE_MS override the small-batch window independently", () => {
2409
+ expect(resolveEventDebounceConfig({
2410
+ [EVENT_SMALL_BATCH_DEBOUNCE_MS_ENV]: "10000",
2411
+ })).toEqual({
2412
+ debounceMs: 60_000,
2413
+ maxWaitMs: 120_000,
2414
+ smallBatchDebounceMs: 10_000,
2415
+ smallBatchMaxPaths: DEFAULT_EVENT_SMALL_BATCH_MAX_PATHS,
2416
+ smallBatchMaxBytes: DEFAULT_EVENT_SMALL_BATCH_MAX_BYTES,
2417
+ });
2418
+ });
2419
+ it("clamps a small-batch override above the quiet window down to the quiet window", () => {
2420
+ expect(resolveEventDebounceConfig({
2421
+ [EVENT_DEBOUNCE_MS_ENV]: "30000",
2422
+ [EVENT_SMALL_BATCH_DEBOUNCE_MS_ENV]: "50000",
2423
+ })).toEqual({
2424
+ debounceMs: 30_000,
2425
+ maxWaitMs: 120_000,
2426
+ smallBatchDebounceMs: 30_000,
2427
+ smallBatchMaxPaths: DEFAULT_EVENT_SMALL_BATCH_MAX_PATHS,
2428
+ smallBatchMaxBytes: DEFAULT_EVENT_SMALL_BATCH_MAX_BYTES,
2429
+ });
2430
+ });
2386
2431
  it("treats 0, negative, and non-numeric values as unset (defaults)", () => {
2387
2432
  for (const bad of ["0", "-5", "banana", ""]) {
2388
2433
  process.env[EVENT_DEBOUNCE_MS_ENV] = bad;