@indigoai-us/hq-cloud 5.26.0 → 5.28.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.
- package/.github/workflows/ci.yml +34 -0
- package/dist/bin/sync-runner.d.ts +38 -0
- package/dist/bin/sync-runner.d.ts.map +1 -1
- package/dist/bin/sync-runner.js +75 -1
- package/dist/bin/sync-runner.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/sync/feature-flags.d.ts +136 -0
- package/dist/sync/feature-flags.d.ts.map +1 -0
- package/dist/sync/feature-flags.js +160 -0
- package/dist/sync/feature-flags.js.map +1 -0
- package/dist/sync/feature-flags.test.d.ts +24 -0
- package/dist/sync/feature-flags.test.d.ts.map +1 -0
- package/dist/sync/feature-flags.test.js +330 -0
- package/dist/sync/feature-flags.test.js.map +1 -0
- package/dist/sync/index.d.ts +10 -2
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +5 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/logger.d.ts +61 -0
- package/dist/sync/logger.d.ts.map +1 -0
- package/dist/sync/logger.js +51 -0
- package/dist/sync/logger.js.map +1 -0
- package/dist/sync/logger.test.d.ts +19 -0
- package/dist/sync/logger.test.d.ts.map +1 -0
- package/dist/sync/logger.test.js +199 -0
- package/dist/sync/logger.test.js.map +1 -0
- package/dist/sync/metrics.d.ts +89 -0
- package/dist/sync/metrics.d.ts.map +1 -0
- package/dist/sync/metrics.js +105 -0
- package/dist/sync/metrics.js.map +1 -0
- package/dist/sync/metrics.test.d.ts +19 -0
- package/dist/sync/metrics.test.d.ts.map +1 -0
- package/dist/sync/metrics.test.js +280 -0
- package/dist/sync/metrics.test.js.map +1 -0
- package/dist/sync/push-receiver.d.ts +442 -0
- package/dist/sync/push-receiver.d.ts.map +1 -0
- package/dist/sync/push-receiver.js +782 -0
- package/dist/sync/push-receiver.js.map +1 -0
- package/dist/sync/push-receiver.test.d.ts +25 -0
- package/dist/sync/push-receiver.test.d.ts.map +1 -0
- package/dist/sync/push-receiver.test.js +477 -0
- package/dist/sync/push-receiver.test.js.map +1 -0
- package/dist/sync/push-transport.d.ts +84 -1
- package/dist/sync/push-transport.d.ts.map +1 -1
- package/dist/sync/push-transport.js +84 -0
- package/dist/sync/push-transport.js.map +1 -1
- package/dist/watcher.d.ts +127 -11
- package/dist/watcher.d.ts.map +1 -1
- package/dist/watcher.js +294 -57
- package/dist/watcher.js.map +1 -1
- package/package.json +9 -5
- package/src/bin/sync-runner.ts +102 -1
- package/src/index.ts +21 -0
- package/src/sync/feature-flags.test.ts +392 -0
- package/src/sync/feature-flags.ts +229 -0
- package/src/sync/index.ts +57 -2
- package/src/sync/logger.test.ts +241 -0
- package/src/sync/logger.ts +79 -0
- package/src/sync/metrics.test.ts +380 -0
- package/src/sync/metrics.ts +158 -0
- package/src/sync/push-receiver.test.ts +545 -0
- package/src/sync/push-receiver.ts +1077 -0
- package/src/sync/push-transport.ts +148 -1
- package/src/watcher.ts +408 -51
- package/test/e2e/sync/cross-tenant-isolation.test.ts +502 -0
- package/test/e2e/watcher-real-chokidar.test.ts +105 -0
- package/test/e2e/watcher-recursive-backend.test.ts +115 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REAL-fs regression E2E for the single-recursive-watch backend.
|
|
3
|
+
*
|
|
4
|
+
* Why this exists:
|
|
5
|
+
* chokidar 4 dropped its `fsevents` backend, so on macOS it watches via kqueue
|
|
6
|
+
* — ~1 open fd PER watched path. Over a real HQ tree (~11k files+dirs) that
|
|
7
|
+
* exhausts the default soft `ulimit -n` (256) with EMFILE, silently killing the
|
|
8
|
+
* watcher so instant sync degrades to the 10-min poll. The fix replaces the
|
|
9
|
+
* per-path chokidar watch with a SINGLE recursive `fs.watch` on macOS/Windows
|
|
10
|
+
* (1 OS handle for the whole tree), filtering events per-path at emit time.
|
|
11
|
+
*
|
|
12
|
+
* These tests pin the two load-bearing behaviors of that backend (both also
|
|
13
|
+
* hold for the chokidar Linux fallback, so the suite is backend-agnostic):
|
|
14
|
+
* 1. A file created under a subtree that DID NOT EXIST when the watcher
|
|
15
|
+
* started still fires — i.e. coverage doesn't depend on per-directory
|
|
16
|
+
* watch registration at start time.
|
|
17
|
+
* 2. An out-of-scope edit (`repos/`, excluded by DEFAULT_IGNORES) does NOT
|
|
18
|
+
* fire — the OS reports it under a recursive watch, and it must be dropped
|
|
19
|
+
* by the emit filter, not woken on.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
|
|
23
|
+
import { tmpdir } from "node:os";
|
|
24
|
+
import path from "node:path";
|
|
25
|
+
|
|
26
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
27
|
+
|
|
28
|
+
import { TreeWatcher } from "../../src/watcher.js";
|
|
29
|
+
|
|
30
|
+
let hqRoot: string;
|
|
31
|
+
let watcher: TreeWatcher | null = null;
|
|
32
|
+
|
|
33
|
+
beforeEach(async () => {
|
|
34
|
+
hqRoot = await mkdtemp(path.join(tmpdir(), "hqcloud-recwatch-e2e-"));
|
|
35
|
+
await writeFile(path.join(hqRoot, ".hqinclude"), "companies/*/knowledge/\n");
|
|
36
|
+
// Only the `acme` company exists at start; `newco` is created later to prove
|
|
37
|
+
// the recursive watch covers subtrees born after start().
|
|
38
|
+
await mkdir(path.join(hqRoot, "companies", "acme", "knowledge"), {
|
|
39
|
+
recursive: true,
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
afterEach(async () => {
|
|
44
|
+
watcher?.dispose();
|
|
45
|
+
watcher = null;
|
|
46
|
+
await rm(hqRoot, { recursive: true, force: true });
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/** Resolve true if the watcher emits a debounced change within `ms`, else false. */
|
|
50
|
+
function waitForEmit(w: TreeWatcher, ms: number): Promise<boolean> {
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
let settled = false;
|
|
53
|
+
const off = w.onChange(() => {
|
|
54
|
+
if (settled) return;
|
|
55
|
+
settled = true;
|
|
56
|
+
off();
|
|
57
|
+
clearTimeout(t);
|
|
58
|
+
resolve(true);
|
|
59
|
+
});
|
|
60
|
+
const t = setTimeout(() => {
|
|
61
|
+
if (settled) return;
|
|
62
|
+
settled = true;
|
|
63
|
+
off();
|
|
64
|
+
resolve(false);
|
|
65
|
+
}, ms);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
describe("event-push watcher -- single recursive watch backend", () => {
|
|
70
|
+
it(
|
|
71
|
+
"FIRES for an in-scope file created under a subtree that did not exist at start",
|
|
72
|
+
async () => {
|
|
73
|
+
watcher = new TreeWatcher({ hqRoot, debounceMs: 250, personalMode: false });
|
|
74
|
+
watcher.start();
|
|
75
|
+
// Let the recursive watch establish before any mutation.
|
|
76
|
+
await new Promise((r) => setTimeout(r, 600));
|
|
77
|
+
|
|
78
|
+
// Create a brand-new company subtree AFTER the watcher started. A
|
|
79
|
+
// per-directory watcher would only catch this if it dynamically
|
|
80
|
+
// registered the new dirs; the recursive watch covers it inherently.
|
|
81
|
+
await mkdir(path.join(hqRoot, "companies", "newco", "knowledge"), {
|
|
82
|
+
recursive: true,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const emitted = waitForEmit(watcher, 4000);
|
|
86
|
+
await writeFile(
|
|
87
|
+
path.join(hqRoot, "companies", "newco", "knowledge", "fresh.md"),
|
|
88
|
+
"# fresh\n",
|
|
89
|
+
);
|
|
90
|
+
expect(await emitted).toBe(true);
|
|
91
|
+
},
|
|
92
|
+
8000,
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
it(
|
|
96
|
+
"does NOT fire for an out-of-scope edit the OS reports under the recursive watch (repos/)",
|
|
97
|
+
async () => {
|
|
98
|
+
watcher = new TreeWatcher({ hqRoot, debounceMs: 250, personalMode: false });
|
|
99
|
+
watcher.start();
|
|
100
|
+
await new Promise((r) => setTimeout(r, 600));
|
|
101
|
+
|
|
102
|
+
// `repos/` is excluded by DEFAULT_IGNORES. Under a recursive OS watch the
|
|
103
|
+
// event is still delivered, so the emit filter — not watch-time pruning —
|
|
104
|
+
// is what must drop it.
|
|
105
|
+
await mkdir(path.join(hqRoot, "repos", "some-repo"), { recursive: true });
|
|
106
|
+
const emitted = waitForEmit(watcher, 2500);
|
|
107
|
+
await writeFile(
|
|
108
|
+
path.join(hqRoot, "repos", "some-repo", "code.ts"),
|
|
109
|
+
"export const x = 1;\n",
|
|
110
|
+
);
|
|
111
|
+
expect(await emitted).toBe(false);
|
|
112
|
+
},
|
|
113
|
+
8000,
|
|
114
|
+
);
|
|
115
|
+
});
|