@indigoai-us/hq-cloud 6.14.50 → 6.15.1

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 (340) hide show
  1. package/dist/bin/sync-mutation.d.ts +14 -0
  2. package/dist/bin/sync-mutation.d.ts.map +1 -0
  3. package/dist/bin/sync-mutation.js +60 -0
  4. package/dist/bin/sync-mutation.js.map +1 -0
  5. package/dist/bin/sync-mutation.test.d.ts +2 -0
  6. package/dist/bin/sync-mutation.test.d.ts.map +1 -0
  7. package/dist/bin/sync-mutation.test.js +64 -0
  8. package/dist/bin/sync-mutation.test.js.map +1 -0
  9. package/dist/bin/sync-runner-company.d.ts +8 -0
  10. package/dist/bin/sync-runner-company.d.ts.map +1 -1
  11. package/dist/bin/sync-runner-company.js +16 -0
  12. package/dist/bin/sync-runner-company.js.map +1 -1
  13. package/dist/bin/sync-runner-company.test.d.ts +2 -0
  14. package/dist/bin/sync-runner-company.test.d.ts.map +1 -0
  15. package/dist/bin/sync-runner-company.test.js +36 -0
  16. package/dist/bin/sync-runner-company.test.js.map +1 -0
  17. package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
  18. package/dist/bin/sync-runner-watch-loop.js +98 -8
  19. package/dist/bin/sync-runner-watch-loop.js.map +1 -1
  20. package/dist/bin/sync-runner.d.ts +17 -0
  21. package/dist/bin/sync-runner.d.ts.map +1 -1
  22. package/dist/bin/sync-runner.js.map +1 -1
  23. package/dist/bin/sync-runner.test.js +109 -0
  24. package/dist/bin/sync-runner.test.js.map +1 -1
  25. package/dist/cli/conflict-recovery.test.d.ts +2 -0
  26. package/dist/cli/conflict-recovery.test.d.ts.map +1 -0
  27. package/dist/cli/conflict-recovery.test.js +201 -0
  28. package/dist/cli/conflict-recovery.test.js.map +1 -0
  29. package/dist/cli/conflict.d.ts +60 -0
  30. package/dist/cli/conflict.d.ts.map +1 -1
  31. package/dist/cli/conflict.js +333 -0
  32. package/dist/cli/conflict.js.map +1 -1
  33. package/dist/cli/reindex-knowledge.d.ts +7 -0
  34. package/dist/cli/reindex-knowledge.d.ts.map +1 -0
  35. package/dist/cli/reindex-knowledge.js +389 -0
  36. package/dist/cli/reindex-knowledge.js.map +1 -0
  37. package/dist/cli/reindex-knowledge.test.d.ts +12 -0
  38. package/dist/cli/reindex-knowledge.test.d.ts.map +1 -0
  39. package/dist/cli/reindex-knowledge.test.js +260 -0
  40. package/dist/cli/reindex-knowledge.test.js.map +1 -0
  41. package/dist/cli/reindex.d.ts.map +1 -1
  42. package/dist/cli/reindex.js +8 -0
  43. package/dist/cli/reindex.js.map +1 -1
  44. package/dist/cli/rescue-settings-reconcile.test.js +47 -0
  45. package/dist/cli/rescue-settings-reconcile.test.js.map +1 -1
  46. package/dist/cli/sync.d.ts +27 -0
  47. package/dist/cli/sync.d.ts.map +1 -1
  48. package/dist/cli/sync.js +52 -0
  49. package/dist/cli/sync.js.map +1 -1
  50. package/dist/cli/sync.test.js +31 -1
  51. package/dist/cli/sync.test.js.map +1 -1
  52. package/dist/index.d.ts +2 -0
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +1 -0
  55. package/dist/index.js.map +1 -1
  56. package/dist/skill-telemetry.d.ts +6 -0
  57. package/dist/skill-telemetry.d.ts.map +1 -1
  58. package/dist/skill-telemetry.js +14 -2
  59. package/dist/skill-telemetry.js.map +1 -1
  60. package/dist/skill-telemetry.test.js +79 -0
  61. package/dist/skill-telemetry.test.js.map +1 -1
  62. package/dist/sync/candidate-uploader.d.ts +88 -0
  63. package/dist/sync/candidate-uploader.d.ts.map +1 -0
  64. package/dist/sync/candidate-uploader.js +212 -0
  65. package/dist/sync/candidate-uploader.js.map +1 -0
  66. package/dist/sync/candidate-uploader.test.d.ts +2 -0
  67. package/dist/sync/candidate-uploader.test.d.ts.map +1 -0
  68. package/dist/sync/candidate-uploader.test.js +132 -0
  69. package/dist/sync/candidate-uploader.test.js.map +1 -0
  70. package/dist/sync/delta-client.d.ts +73 -0
  71. package/dist/sync/delta-client.d.ts.map +1 -0
  72. package/dist/sync/delta-client.js +201 -0
  73. package/dist/sync/delta-client.js.map +1 -0
  74. package/dist/sync/delta-client.test.d.ts +2 -0
  75. package/dist/sync/delta-client.test.d.ts.map +1 -0
  76. package/dist/sync/delta-client.test.js +97 -0
  77. package/dist/sync/delta-client.test.js.map +1 -0
  78. package/dist/sync/durable-apply.d.ts +76 -0
  79. package/dist/sync/durable-apply.d.ts.map +1 -0
  80. package/dist/sync/durable-apply.js +530 -0
  81. package/dist/sync/durable-apply.js.map +1 -0
  82. package/dist/sync/durable-apply.test.d.ts +2 -0
  83. package/dist/sync/durable-apply.test.d.ts.map +1 -0
  84. package/dist/sync/durable-apply.test.js +180 -0
  85. package/dist/sync/durable-apply.test.js.map +1 -0
  86. package/dist/sync/event-sync.d.ts +33 -1
  87. package/dist/sync/event-sync.d.ts.map +1 -1
  88. package/dist/sync/event-sync.js +149 -1
  89. package/dist/sync/event-sync.js.map +1 -1
  90. package/dist/sync/event-sync.test.js +142 -1
  91. package/dist/sync/event-sync.test.js.map +1 -1
  92. package/dist/sync/index.d.ts +2 -0
  93. package/dist/sync/index.d.ts.map +1 -1
  94. package/dist/sync/index.js +1 -0
  95. package/dist/sync/index.js.map +1 -1
  96. package/dist/sync/multipart-uploader.d.ts +99 -0
  97. package/dist/sync/multipart-uploader.d.ts.map +1 -0
  98. package/dist/sync/multipart-uploader.js +447 -0
  99. package/dist/sync/multipart-uploader.js.map +1 -0
  100. package/dist/sync/multipart-uploader.test.d.ts +2 -0
  101. package/dist/sync/multipart-uploader.test.d.ts.map +1 -0
  102. package/dist/sync/multipart-uploader.test.js +119 -0
  103. package/dist/sync/multipart-uploader.test.js.map +1 -0
  104. package/dist/sync/mutation-client.d.ts +82 -0
  105. package/dist/sync/mutation-client.d.ts.map +1 -0
  106. package/dist/sync/mutation-client.js +221 -0
  107. package/dist/sync/mutation-client.js.map +1 -0
  108. package/dist/sync/mutation-client.test.d.ts +2 -0
  109. package/dist/sync/mutation-client.test.d.ts.map +1 -0
  110. package/dist/sync/mutation-client.test.js +51 -0
  111. package/dist/sync/mutation-client.test.js.map +1 -0
  112. package/dist/sync/push-receiver.d.ts +45 -0
  113. package/dist/sync/push-receiver.d.ts.map +1 -1
  114. package/dist/sync/push-receiver.js +101 -0
  115. package/dist/sync/push-receiver.js.map +1 -1
  116. package/dist/sync/push-receiver.test.js +54 -2
  117. package/dist/sync/push-receiver.test.js.map +1 -1
  118. package/dist/sync/scope-inventory-client.d.ts +69 -0
  119. package/dist/sync/scope-inventory-client.d.ts.map +1 -0
  120. package/dist/sync/scope-inventory-client.js +210 -0
  121. package/dist/sync/scope-inventory-client.js.map +1 -0
  122. package/dist/sync/scope-inventory-client.test.d.ts +2 -0
  123. package/dist/sync/scope-inventory-client.test.d.ts.map +1 -0
  124. package/dist/sync/scope-inventory-client.test.js +94 -0
  125. package/dist/sync/scope-inventory-client.test.js.map +1 -0
  126. package/dist/sync/snapshot-client.d.ts +98 -0
  127. package/dist/sync/snapshot-client.d.ts.map +1 -0
  128. package/dist/sync/snapshot-client.js +402 -0
  129. package/dist/sync/snapshot-client.js.map +1 -0
  130. package/dist/sync/snapshot-client.test.d.ts +2 -0
  131. package/dist/sync/snapshot-client.test.d.ts.map +1 -0
  132. package/dist/sync/snapshot-client.test.js +169 -0
  133. package/dist/sync/snapshot-client.test.js.map +1 -0
  134. package/dist/sync/uploader-finalization.d.ts +97 -0
  135. package/dist/sync/uploader-finalization.d.ts.map +1 -0
  136. package/dist/sync/uploader-finalization.js +273 -0
  137. package/dist/sync/uploader-finalization.js.map +1 -0
  138. package/dist/sync/uploader-finalization.test.d.ts +2 -0
  139. package/dist/sync/uploader-finalization.test.d.ts.map +1 -0
  140. package/dist/sync/uploader-finalization.test.js +92 -0
  141. package/dist/sync/uploader-finalization.test.js.map +1 -0
  142. package/dist/telemetry.d.ts +11 -1
  143. package/dist/telemetry.d.ts.map +1 -1
  144. package/dist/telemetry.js +21 -2
  145. package/dist/telemetry.js.map +1 -1
  146. package/dist/telemetry.test.js +80 -0
  147. package/dist/telemetry.test.js.map +1 -1
  148. package/package.json +6 -1
  149. package/.claude/policies/hq-cloud-esm-cannot-spy-fs-builtins.md +0 -30
  150. package/.claude/policies/hq-cloud-strip-types-no-parameter-properties.md +0 -22
  151. package/.github/workflows/ci.yml +0 -84
  152. package/.github/workflows/publish.yml +0 -56
  153. package/.github/workflows/unreleased-commits-nag.yml +0 -256
  154. package/eslint.config.js +0 -67
  155. package/pnpm-workspace.yaml +0 -2
  156. package/scripts/presign-transport-e2e.mjs +0 -250
  157. package/scripts/vault-rebaseline.sh +0 -323
  158. package/scripts/vault-rescue.sh +0 -332
  159. package/src/active-company.test.ts +0 -188
  160. package/src/active-company.ts +0 -168
  161. package/src/agent-codex-instructions.test.ts +0 -332
  162. package/src/agent-codex-instructions.ts +0 -309
  163. package/src/auth.ts +0 -146
  164. package/src/backup-prune.test.ts +0 -98
  165. package/src/backup-prune.ts +0 -182
  166. package/src/bin/backup-prune-runner.ts +0 -33
  167. package/src/bin/rescue-runner.ts +0 -25
  168. package/src/bin/sync-runner-company.ts +0 -695
  169. package/src/bin/sync-runner-events.test.ts +0 -143
  170. package/src/bin/sync-runner-events.ts +0 -55
  171. package/src/bin/sync-runner-planning.test.ts +0 -311
  172. package/src/bin/sync-runner-planning.ts +0 -258
  173. package/src/bin/sync-runner-rollup.test.ts +0 -37
  174. package/src/bin/sync-runner-rollup.ts +0 -97
  175. package/src/bin/sync-runner-telemetry.ts +0 -15
  176. package/src/bin/sync-runner-watch-loop.ts +0 -1235
  177. package/src/bin/sync-runner-watch-routes.test.ts +0 -71
  178. package/src/bin/sync-runner-watch-routes.ts +0 -184
  179. package/src/bin/sync-runner.test.ts +0 -8767
  180. package/src/bin/sync-runner.ts +0 -2190
  181. package/src/cli/accept.ts +0 -124
  182. package/src/cli/conflict.ts +0 -119
  183. package/src/cli/doctor.test.ts +0 -581
  184. package/src/cli/doctor.ts +0 -642
  185. package/src/cli/index.ts +0 -49
  186. package/src/cli/invite.test.ts +0 -250
  187. package/src/cli/invite.ts +0 -214
  188. package/src/cli/promote.ts +0 -157
  189. package/src/cli/reindex.test.ts +0 -957
  190. package/src/cli/reindex.ts +0 -970
  191. package/src/cli/rescue-classify-ordering.test.ts +0 -548
  192. package/src/cli/rescue-clone-diagnostics.test.ts +0 -120
  193. package/src/cli/rescue-core.ts +0 -3011
  194. package/src/cli/rescue-drift-reconcile.test.ts +0 -179
  195. package/src/cli/rescue-drop-dir-symlink.test.ts +0 -224
  196. package/src/cli/rescue-exec-bit-preserve.test.ts +0 -187
  197. package/src/cli/rescue-hq-root-guard.test.ts +0 -232
  198. package/src/cli/rescue-journal-reconcile.test.ts +0 -215
  199. package/src/cli/rescue-mtime-preserve.test.ts +0 -203
  200. package/src/cli/rescue-settings-reconcile.test.ts +0 -583
  201. package/src/cli/rescue-snapshot.test.ts +0 -57
  202. package/src/cli/rescue-snapshot.ts +0 -51
  203. package/src/cli/rescue.reindex.test.ts +0 -63
  204. package/src/cli/rescue.test.ts +0 -131
  205. package/src/cli/rescue.ts +0 -182
  206. package/src/cli/share.test.ts +0 -7843
  207. package/src/cli/share.ts +0 -3663
  208. package/src/cli/sync-scope.test.ts +0 -652
  209. package/src/cli/sync.test.ts +0 -5207
  210. package/src/cli/sync.ts +0 -3470
  211. package/src/cli/tombstones.ts +0 -106
  212. package/src/cli/watch-event-push-conflict.test.ts +0 -234
  213. package/src/client-info.test.ts +0 -214
  214. package/src/client-info.ts +0 -121
  215. package/src/cognito-auth.test.ts +0 -712
  216. package/src/cognito-auth.ts +0 -1422
  217. package/src/company-resolver.test.ts +0 -618
  218. package/src/company-resolver.ts +0 -521
  219. package/src/context.test.ts +0 -583
  220. package/src/context.ts +0 -378
  221. package/src/daemon-worker.ts +0 -26
  222. package/src/daemon.ts +0 -99
  223. package/src/entity-resolver.test.ts +0 -315
  224. package/src/entity-resolver.ts +0 -180
  225. package/src/ignore.test.ts +0 -466
  226. package/src/ignore.ts +0 -469
  227. package/src/index.ts +0 -439
  228. package/src/journal.test.ts +0 -968
  229. package/src/journal.ts +0 -765
  230. package/src/lib/cloud-authoritative.test.ts +0 -45
  231. package/src/lib/cloud-authoritative.ts +0 -59
  232. package/src/lib/conflict-file.ts +0 -86
  233. package/src/lib/conflict-index.ts +0 -289
  234. package/src/lib/conflict.test.ts +0 -348
  235. package/src/lib/describe-error.test.ts +0 -100
  236. package/src/lib/describe-error.ts +0 -58
  237. package/src/lib/exit-codes.ts +0 -24
  238. package/src/lib/machine-id.test.ts +0 -231
  239. package/src/lib/machine-id.ts +0 -175
  240. package/src/lib/net-errors.test.ts +0 -65
  241. package/src/lib/net-errors.ts +0 -86
  242. package/src/lib/readlink-safe.test.ts +0 -43
  243. package/src/lib/readlink-safe.ts +0 -29
  244. package/src/local-path-codec.test.ts +0 -138
  245. package/src/local-path-codec.ts +0 -161
  246. package/src/machine-auth.test.ts +0 -1323
  247. package/src/manifest-reconcile.test.ts +0 -1123
  248. package/src/manifest-reconcile.ts +0 -518
  249. package/src/object-io.test.ts +0 -1221
  250. package/src/object-io.ts +0 -1306
  251. package/src/operation-lock.test.ts +0 -484
  252. package/src/operation-lock.ts +0 -680
  253. package/src/outcome-telemetry.test.ts +0 -498
  254. package/src/outcome-telemetry.ts +0 -639
  255. package/src/personal-vault-exclusions.test.ts +0 -308
  256. package/src/personal-vault-exclusions.ts +0 -354
  257. package/src/personal-vault.test.ts +0 -756
  258. package/src/personal-vault.ts +0 -496
  259. package/src/prefix-coalesce.test.ts +0 -240
  260. package/src/prefix-coalesce.ts +0 -273
  261. package/src/public-surface.test.ts +0 -117
  262. package/src/qmd-reindex.test.ts +0 -877
  263. package/src/qmd-reindex.ts +0 -842
  264. package/src/read-only-state-dir.test.ts +0 -188
  265. package/src/remote-pull.test.ts +0 -1130
  266. package/src/remote-pull.ts +0 -618
  267. package/src/s3.symlink-materialize.test.ts +0 -492
  268. package/src/s3.test.ts +0 -1789
  269. package/src/s3.ts +0 -1532
  270. package/src/schemas/signal-types.test.ts +0 -82
  271. package/src/schemas/signal-types.ts +0 -38
  272. package/src/schemas/source-channels.test.ts +0 -82
  273. package/src/schemas/source-channels.ts +0 -53
  274. package/src/scope-shrink.test.ts +0 -633
  275. package/src/scope-shrink.ts +0 -481
  276. package/src/signals/get.test.ts +0 -310
  277. package/src/signals/get.ts +0 -75
  278. package/src/signals/internals.ts +0 -195
  279. package/src/signals/list.test.ts +0 -420
  280. package/src/signals/list.ts +0 -79
  281. package/src/signals/parse.ts +0 -8
  282. package/src/signals/types.ts +0 -91
  283. package/src/skill-telemetry.test.ts +0 -1825
  284. package/src/skill-telemetry.ts +0 -1439
  285. package/src/sources/get.test.ts +0 -293
  286. package/src/sources/get.ts +0 -66
  287. package/src/sources/internals.ts +0 -198
  288. package/src/sources/list.test.ts +0 -402
  289. package/src/sources/list.ts +0 -84
  290. package/src/sources/parse.ts +0 -43
  291. package/src/sources/types.ts +0 -84
  292. package/src/sync/event-sync.test.ts +0 -594
  293. package/src/sync/event-sync.ts +0 -545
  294. package/src/sync/feature-flags.test.ts +0 -378
  295. package/src/sync/feature-flags.ts +0 -62
  296. package/src/sync/index.ts +0 -76
  297. package/src/sync/lease-client.test.ts +0 -128
  298. package/src/sync/lease-client.ts +0 -207
  299. package/src/sync/logger.test.ts +0 -242
  300. package/src/sync/logger.ts +0 -79
  301. package/src/sync/metrics.test.ts +0 -462
  302. package/src/sync/metrics.ts +0 -213
  303. package/src/sync/pull-scope.ts +0 -265
  304. package/src/sync/push-event.test.ts +0 -266
  305. package/src/sync/push-event.ts +0 -224
  306. package/src/sync/push-receiver.test.ts +0 -566
  307. package/src/sync/push-receiver.ts +0 -1048
  308. package/src/sync/push-transport.ts +0 -231
  309. package/src/sync/realtime-rollout.test.ts +0 -86
  310. package/src/sync/realtime-rollout.ts +0 -262
  311. package/src/sync/state-store.test.ts +0 -194
  312. package/src/sync/state-store.ts +0 -727
  313. package/src/sync-core.ts +0 -58
  314. package/src/sync-progress.test.ts +0 -94
  315. package/src/sync-progress.ts +0 -140
  316. package/src/telemetry-events.test.ts +0 -88
  317. package/src/telemetry-events.ts +0 -205
  318. package/src/telemetry.test.ts +0 -1280
  319. package/src/telemetry.ts +0 -1109
  320. package/src/types.ts +0 -314
  321. package/src/vault-client.test.ts +0 -1380
  322. package/src/vault-client.ts +0 -1694
  323. package/src/version.ts +0 -24
  324. package/src/watch-roots.test.ts +0 -278
  325. package/src/watch-roots.ts +0 -162
  326. package/src/watcher-event-gate.test.ts +0 -212
  327. package/src/watcher.test.ts +0 -1079
  328. package/src/watcher.ts +0 -1741
  329. package/test/e2e/sync/cross-tenant-isolation.test.ts +0 -630
  330. package/test/e2e/sync/skill-telemetry-oversized-transcript.test.ts +0 -124
  331. package/test/e2e/sync/transient-company-leg.test.ts +0 -384
  332. package/test/e2e/sync/windows-unreadable-link-leg.test.ts +0 -191
  333. package/test/e2e/watcher-real-chokidar.test.ts +0 -165
  334. package/test/e2e/watcher-recursive-backend.test.ts +0 -181
  335. package/test/e2e/watcher-scoped-coverage.test.ts +0 -381
  336. package/test/invite-flow.integration.test.ts +0 -244
  337. package/test/joiner-manifest-reconcile.integration.test.ts +0 -322
  338. package/test/share-sync.integration.test.ts +0 -213
  339. package/tsconfig.json +0 -19
  340. package/vitest.config.ts +0 -22
@@ -1,466 +0,0 @@
1
- /**
2
- * Unit tests for createIgnoreFilter.
3
- *
4
- * Covers both modes: legacy permissive (no .hqinclude) and allowlist mode
5
- * (.hqinclude present). The allowlist tests guard against accidentally
6
- * leaking sensitive subtrees like data/ or workers/ to S3 — a regression
7
- * here would silently push private content on the next sync.
8
- */
9
-
10
- import { describe, it, expect, beforeEach, afterEach } from "vitest";
11
- import * as fs from "fs";
12
- import * as os from "os";
13
- import * as path from "path";
14
- import { createIgnoreFilter, isExpectedIgnore } from "./ignore.js";
15
- import { wrapFilterWithIgnoreVisibility } from "./cli/share.js";
16
-
17
- describe("isExpectedIgnore", () => {
18
- it("classifies top-level HQ-managed roots as expected", () => {
19
- expect(isExpectedIgnore("repos")).toBe(true);
20
- expect(isExpectedIgnore("repos/private/x.ts")).toBe(true);
21
- expect(isExpectedIgnore("workspace/tmp/file.md")).toBe(true);
22
- });
23
-
24
- it("classifies build, VCS, cache, and known basename noise as expected", () => {
25
- expect(isExpectedIgnore("node_modules/react/index.js")).toBe(true);
26
- expect(isExpectedIgnore("apps/web/node_modules/react/index.js")).toBe(true);
27
- expect(isExpectedIgnore(".git/config")).toBe(true);
28
- expect(isExpectedIgnore(".DS_Store")).toBe(true);
29
- expect(isExpectedIgnore("x/.env")).toBe(true);
30
- expect(isExpectedIgnore("a/b/.hq-sync.pid")).toBe(true);
31
- expect(isExpectedIgnore("y/foo.pyc")).toBe(true);
32
- // Cloud-only skill hero images (US-014) are an expected by-design exclusion.
33
- expect(isExpectedIgnore(".claude/skills/foo/.skill-media/hero.png")).toBe(true);
34
- });
35
-
36
- it("classifies macOS Finder Icon\\r files as expected noise", () => {
37
- // Finder scatters one into every directory it renders a custom icon for,
38
- // and a folder-level cloud-sync agent propagates them tree-wide. Treated
39
- // exactly like .DS_Store so a seeded tree stays silent rather than firing
40
- // the "EXCLUDED from sync — review in case this is unintended" warning
41
- // once per file.
42
- expect(isExpectedIgnore("Icon\r")).toBe(true);
43
- expect(isExpectedIgnore("companies/indigo/Icon\r")).toBe(true);
44
- });
45
-
46
- it("keeps a real file named Icons noteworthy (no `Icon?` over-match)", () => {
47
- // The `Icon?` gitignore workaround would swallow these. Dropping real
48
- // user content is a worse failure than the cruft being excluded.
49
- expect(isExpectedIgnore("companies/indigo/Icons")).toBe(false);
50
- expect(isExpectedIgnore("companies/indigo/Icon")).toBe(false);
51
- expect(isExpectedIgnore("companies/indigo/Icons.md")).toBe(false);
52
- });
53
-
54
- it("keeps nested repos/workspace and ordinary content noteworthy", () => {
55
- expect(isExpectedIgnore("companies/indigo/knowledge/repos/foo/notes.md")).toBe(false);
56
- expect(isExpectedIgnore("companies/indigo/knowledge/overview.md")).toBe(false);
57
- });
58
- });
59
-
60
- describe("createIgnoreFilter", () => {
61
- let hqRoot: string;
62
-
63
- beforeEach(() => {
64
- hqRoot = fs.mkdtempSync(path.join(os.tmpdir(), "hq-ignore-test-"));
65
- });
66
-
67
- afterEach(() => {
68
- fs.rmSync(hqRoot, { recursive: true, force: true });
69
- });
70
-
71
- it("permissive mode: regular files sync, defaults are ignored", () => {
72
- const shouldSync = createIgnoreFilter(hqRoot);
73
- expect(shouldSync(path.join(hqRoot, "companies/indigo/notes.md"))).toBe(true);
74
- expect(shouldSync(path.join(hqRoot, "node_modules/foo/x.js"))).toBe(false);
75
- expect(shouldSync(path.join(hqRoot, ".env"))).toBe(false);
76
- });
77
-
78
- it("permissive mode: project-local .qmd index is ignored by default", () => {
79
- // feedback_332c7ccc / sqlite-vec#297 — never round-trip a project-local
80
- // qmd index through the vault.
81
- const shouldSync = createIgnoreFilter(hqRoot);
82
- expect(shouldSync(path.join(hqRoot, ".qmd"), true)).toBe(false);
83
- expect(shouldSync(path.join(hqRoot, ".qmd/index.sqlite"))).toBe(false);
84
- expect(shouldSync(path.join(hqRoot, ".qmd/index.sqlite-wal"))).toBe(false);
85
- expect(isExpectedIgnore(".qmd/index.sqlite")).toBe(true);
86
- });
87
-
88
- it("permissive mode: pnpm content-addressed store is ignored by default", () => {
89
- // .pnpm-store/ is pnpm's content-addressed package store. Like
90
- // node_modules/ it is large and machine-local and must never sync — a
91
- // synced store writes a `.conflict-` copy of every blob each cycle, which
92
- // then re-syncs and amplifies into tens of thousands of files. Regression
93
- // guard for that storm.
94
- const shouldSync = createIgnoreFilter(hqRoot);
95
- // The store directory and everything beneath it is excluded.
96
- expect(shouldSync(path.join(hqRoot, ".pnpm-store"), true)).toBe(false);
97
- expect(shouldSync(path.join(hqRoot, ".pnpm-store/v10/files/00/abc123"))).toBe(false);
98
- // Caught at any depth — a project store nested under a synced subtree.
99
- expect(
100
- shouldSync(path.join(hqRoot, "companies/indigo/repos/x/.pnpm-store/v10/blob")),
101
- ).toBe(false);
102
- // node_modules/ is already covered; asserted here so the pair travels together.
103
- expect(shouldSync(path.join(hqRoot, "node_modules/react/index.js"))).toBe(false);
104
- });
105
-
106
- it("permissive mode: macOS Finder Icon\\r files never enter the walk", () => {
107
- // A CR is a control character, so the vault key validator rejects the key
108
- // (INVALID_KEY_CONTROL_CHARS) and the upload can only ever throw. Dropping
109
- // them during the walk is what keeps them off the upload path entirely.
110
- const shouldSync = createIgnoreFilter(hqRoot);
111
- expect(shouldSync(path.join(hqRoot, "Icon\r"))).toBe(false);
112
- expect(shouldSync(path.join(hqRoot, "companies/indigo/Icon\r"))).toBe(false);
113
- expect(shouldSync(path.join(hqRoot, ".agents/Icon\r"))).toBe(false);
114
- // Caught at any depth, like the other OS-cruft exclusions.
115
- expect(shouldSync(path.join(hqRoot, "a/b/c/d/Icon\r"))).toBe(false);
116
- });
117
-
118
- it("permissive mode: a real file named Icons still syncs", () => {
119
- // Regression guard for the `Icon?` gitignore workaround, whose `?`
120
- // single-char wildcard also matches Icons / Icon1 / IconX. This exclusion
121
- // matches the exact Finder byte sequence instead, so real content survives.
122
- const shouldSync = createIgnoreFilter(hqRoot);
123
- expect(shouldSync(path.join(hqRoot, "companies/indigo/Icons"))).toBe(true);
124
- expect(shouldSync(path.join(hqRoot, "companies/indigo/Icon"))).toBe(true);
125
- expect(shouldSync(path.join(hqRoot, "companies/indigo/Icon1"))).toBe(true);
126
- expect(shouldSync(path.join(hqRoot, "companies/indigo/Icons.md"))).toBe(true);
127
- });
128
-
129
- it("a literal Icon+CR line in .gitignore does NOT reach the ignore lib", () => {
130
- // This is why the exclusion is a predicate and not a DEFAULT_IGNORES
131
- // entry. ignore@5 strips a trailing CR from a pattern line, so the
132
- // spelling git itself requires silently never matches. Pinning the
133
- // upstream behavior here means a future ignore-lib bump that changes it
134
- // surfaces as a failing test rather than a silent double-exclusion.
135
- fs.writeFileSync(path.join(hqRoot, ".gitignore"), "Icon\r\n");
136
- const shouldSync = createIgnoreFilter(hqRoot);
137
- // Still excluded — by the predicate, not by the pattern.
138
- expect(shouldSync(path.join(hqRoot, "Icon\r"))).toBe(false);
139
- // Proof the pattern itself is inert: it did not take `Icons` with it.
140
- expect(shouldSync(path.join(hqRoot, "Icons"))).toBe(true);
141
- });
142
-
143
- it("repos/ exclusion is root-anchored to hqRoot (DEV-1791)", () => {
144
- const shouldSync = createIgnoreFilter(hqRoot);
145
- expect(shouldSync(path.join(hqRoot, "repos/private/hq-cloud/src/x.ts"))).toBe(false);
146
- expect(shouldSync(path.join(hqRoot, "repos/public/hq-core/README.md"))).toBe(false);
147
- expect(
148
- shouldSync(path.join(hqRoot, "companies/lutiq/knowledge/repos/dev-docs-mcp/overview.md")),
149
- ).toBe(true);
150
- expect(shouldSync(path.join(hqRoot, "companies/indigo/knowledge/repos/foo/notes.md"))).toBe(
151
- true,
152
- );
153
- expect(shouldSync(path.join(hqRoot, "companies/lutiq/knowledge/repos"), true)).toBe(true);
154
- });
155
-
156
- it("permissive mode: .hqignore patterns are honored", () => {
157
- fs.writeFileSync(path.join(hqRoot, ".hqignore"), "companies/*/data/\n");
158
- const shouldSync = createIgnoreFilter(hqRoot);
159
- expect(shouldSync(path.join(hqRoot, "companies/indigo/data/x.csv"))).toBe(false);
160
- expect(shouldSync(path.join(hqRoot, "companies/indigo/notes.md"))).toBe(true);
161
- });
162
-
163
- it("visibility fires on an OVER-BROAD exclusion (real filter + recorder, DEV-1791)", () => {
164
- // Simulate the regressed over-broad bug: an un-anchored `repos/` in
165
- // .hqignore that matches ANY nested repos segment — exactly what
166
- // silently ate /discover knowledge under companies/*/knowledge/repos/
167
- // before the root-anchor fix. The visibility recorder must surface the
168
- // dropped knowledge as NOTEWORTHY while staying quiet on build noise.
169
- fs.writeFileSync(path.join(hqRoot, ".hqignore"), "repos/\n");
170
- const ignoreFilter = createIgnoreFilter(hqRoot);
171
- const noteworthy: string[] = [];
172
- let total = 0;
173
- const recorded = wrapFilterWithIgnoreVisibility(
174
- ignoreFilter,
175
- hqRoot,
176
- (rel) => { noteworthy.push(rel); },
177
- () => { total++; },
178
- );
179
-
180
- // Knowledge under a nested repos/ is dropped by the over-broad rule and
181
- // is genuine content → captured as noteworthy.
182
- expect(recorded(path.join(hqRoot, "companies/indigo/knowledge/repos/foo/notes.md"))).toBe(false);
183
- // Build noise is also excluded but is EXPECTED → counted, not noteworthy.
184
- expect(recorded(path.join(hqRoot, "node_modules/react/index.js"))).toBe(false);
185
- // Ordinary knowledge that the filter ALLOWS fires nothing.
186
- expect(recorded(path.join(hqRoot, "companies/indigo/knowledge/overview.md"))).toBe(true);
187
-
188
- expect(noteworthy).toEqual(["companies/indigo/knowledge/repos/foo/notes.md"]);
189
- expect(total).toBe(2); // both exclusions counted; only one is noteworthy
190
- });
191
-
192
- it("v15+ layout (core/core.yaml present): root core.yaml is ignored, nested core/core.yaml syncs", () => {
193
- // On v15+ the scaffold/version manifest lives at `core/core.yaml` (a real
194
- // project file that DOES sync). Any root-level `core.yaml` here is a stale
195
- // per-machine duplicate that must never round-trip — pulling another
196
- // machine's marker would corrupt root discovery. The exclusion is anchored
197
- // (`/core.yaml`) so it never touches `core/core.yaml`.
198
- fs.mkdirSync(path.join(hqRoot, "core"), { recursive: true });
199
- fs.writeFileSync(path.join(hqRoot, "core/core.yaml"), 'version: 1\nhqVersion: "15.0.12"\n');
200
- fs.writeFileSync(path.join(hqRoot, "core.yaml"), 'version: 1\nhqVersion: "15.0.12"\n');
201
- const shouldSync = createIgnoreFilter(hqRoot);
202
- expect(shouldSync(path.join(hqRoot, "core.yaml"))).toBe(false);
203
- expect(shouldSync(path.join(hqRoot, "core/core.yaml"))).toBe(true);
204
- });
205
-
206
- it("v12–v14 layout (no core/core.yaml): root core.yaml IS the manifest and MUST sync", () => {
207
- // Regression for DEV-1729 / the ~98 "no core.yaml in vault, version
208
- // undetectable" sync users. On v12–v14 roots there is NO `core/core.yaml`
209
- // — the ROOT `core.yaml` is the scaffold/version manifest. The old
210
- // unconditional `/core.yaml` exclusion silently dropped it (while
211
- // computePersonalVaultPaths still enumerated it), so the vault never
212
- // received a version marker. With no `core/core.yaml` on disk, the root
213
- // `core.yaml` must round-trip like any other top-level file.
214
- fs.writeFileSync(path.join(hqRoot, "core.yaml"), 'version: 1\nhqVersion: "14.0.0"\n');
215
- const shouldSync = createIgnoreFilter(hqRoot);
216
- expect(shouldSync(path.join(hqRoot, "core.yaml"))).toBe(true);
217
- });
218
-
219
- it("permissive mode: modules/modules.yaml manifest is ignored", () => {
220
- // modules.yaml is the local modules-resolution manifest. Per-machine
221
- // state, never synced.
222
- const shouldSync = createIgnoreFilter(hqRoot);
223
- expect(shouldSync(path.join(hqRoot, "modules/modules.yaml"))).toBe(false);
224
- });
225
-
226
- it("permissive mode: per-company company.yaml is ignored", () => {
227
- // company.yaml is written locally on first sync from the entity context.
228
- // Round-tripping it would let one machine's identity overwrite another's.
229
- const shouldSync = createIgnoreFilter(hqRoot);
230
- expect(shouldSync(path.join(hqRoot, "companies/indigo/company.yaml"))).toBe(false);
231
- expect(shouldSync(path.join(hqRoot, "company.yaml"))).toBe(false);
232
- });
233
-
234
- it("permissive mode: INDEX.md and policies/_digest.md are ignored", () => {
235
- // Both are auto-generated locally — INDEX.md by the tools indexer and
236
- // policies/_digest.md by the policies digest builder.
237
- const shouldSync = createIgnoreFilter(hqRoot);
238
- expect(shouldSync(path.join(hqRoot, "INDEX.md"))).toBe(false);
239
- expect(shouldSync(path.join(hqRoot, "companies/ghq/tools/INDEX.md"))).toBe(false);
240
- expect(shouldSync(path.join(hqRoot, "policies/_digest.md"))).toBe(false);
241
- });
242
-
243
- it("permissive mode: .claude/worktrees/ is ignored", () => {
244
- const shouldSync = createIgnoreFilter(hqRoot);
245
- expect(shouldSync(path.join(hqRoot, ".claude/worktrees/foo/file.ts"))).toBe(false);
246
- expect(shouldSync(path.join(hqRoot, "companies/indigo/.claude/worktrees/bar/x.md"))).toBe(false);
247
- // The .claude/ dir itself (commands, skills, hooks) still syncs.
248
- expect(shouldSync(path.join(hqRoot, ".claude/skills/foo/SKILL.md"))).toBe(true);
249
- });
250
-
251
- it("permissive mode: .skill-media/ (cloud-only skill images) is ignored (US-014)", () => {
252
- const shouldSync = createIgnoreFilter(hqRoot);
253
- // Skill hero images are cloud-only — excluded from push AND pull at any depth.
254
- expect(
255
- shouldSync(path.join(hqRoot, ".claude/skills/lead-qualifier/.skill-media/hero.png")),
256
- ).toBe(false);
257
- expect(
258
- shouldSync(path.join(hqRoot, "companies/indigo/skills/foo/.skill-media/cover.jpg")),
259
- ).toBe(false);
260
- expect(shouldSync(path.join(hqRoot, "skills/bar/.skill-media"), true)).toBe(false);
261
- // The skill's SKILL.md and other content still sync — the rule is scoped to
262
- // the media dir only, never the skill.
263
- expect(shouldSync(path.join(hqRoot, ".claude/skills/lead-qualifier/SKILL.md"))).toBe(true);
264
- });
265
-
266
- it("permissive mode: .hq-* internal state is ignored, .hqignore family still sync", () => {
267
- const shouldSync = createIgnoreFilter(hqRoot);
268
- // Internal state files that must never round-trip through the bucket.
269
- expect(shouldSync(path.join(hqRoot, ".hq-sync.pid"))).toBe(false);
270
- expect(shouldSync(path.join(hqRoot, ".hq-sync-journal.json"))).toBe(false);
271
- expect(shouldSync(path.join(hqRoot, ".hq-sync-state.json"))).toBe(false);
272
- expect(shouldSync(path.join(hqRoot, ".hq-embeddings-pending.json"))).toBe(false);
273
- expect(shouldSync(path.join(hqRoot, "companies/indigo/.hq-foo.json"))).toBe(false);
274
- expect(shouldSync(path.join(hqRoot, ".hq-cache/blob.bin"))).toBe(false);
275
- // Sync-config files still sync (no hyphen, doesn't match `.hq-*`).
276
- expect(shouldSync(path.join(hqRoot, ".hqignore"))).toBe(true);
277
- expect(shouldSync(path.join(hqRoot, ".hqsyncignore"))).toBe(true);
278
- expect(shouldSync(path.join(hqRoot, ".hqinclude"))).toBe(true);
279
- });
280
-
281
- it("permissive mode: .claude/state/ and .claude/audit/ are per-host, never synced", () => {
282
- // 5.34.0 live cross-machine sync test (macOS ↔ Lightsail) wrote
283
- // ~25 of the 30 conflict mirrors directly to these paths. They're
284
- // session-/host-scoped by design:
285
- // - .claude/state/active-session-project: the active project
286
- // pointer for the currently-foregrounded Claude Code session.
287
- // - .claude/state/auto-session-project-<sessionUuid>: one
288
- // marker per spawned session; entirely host-local.
289
- // - .claude/audit/: hook-decision audit log + suppressions
290
- // config; host-specific by nature.
291
- // Syncing produces guaranteed conflicts per machine per session.
292
- const shouldSync = createIgnoreFilter(hqRoot);
293
- expect(shouldSync(path.join(hqRoot, ".claude/state/active-session-project"))).toBe(false);
294
- expect(
295
- shouldSync(
296
- path.join(hqRoot, ".claude/state/auto-session-project-571177ff-59bb-4728-8670-0bf66a6410a5"),
297
- ),
298
- ).toBe(false);
299
- expect(shouldSync(path.join(hqRoot, ".claude/audit/instructions.md"))).toBe(false);
300
- expect(shouldSync(path.join(hqRoot, ".claude/audit/suppressions.yaml"))).toBe(false);
301
- expect(shouldSync(path.join(hqRoot, ".claude/state"), true)).toBe(false);
302
- expect(shouldSync(path.join(hqRoot, ".claude/audit"), true)).toBe(false);
303
- // Nested .claude/ inside a company also stays local — same anchor
304
- // shape as the .claude/worktrees/ rule directly above.
305
- expect(
306
- shouldSync(path.join(hqRoot, "companies/indigo/.claude/state/active-session-project")),
307
- ).toBe(false);
308
- expect(
309
- shouldSync(path.join(hqRoot, "companies/indigo/.claude/audit/instructions.md")),
310
- ).toBe(false);
311
- // The .claude/ dir's other contents (commands, skills, hooks) still
312
- // sync — the rule MUST NOT broaden to .claude/.
313
- expect(shouldSync(path.join(hqRoot, ".claude/skills/foo/SKILL.md"))).toBe(true);
314
- expect(shouldSync(path.join(hqRoot, ".claude/hooks/foo.sh"))).toBe(true);
315
- });
316
-
317
- it("permissive mode: .claude/settings*.json is machine-local, never synced (qmd PATH regression)", () => {
318
- // 2026-07-01 e2e-mac report (20260701-qmd-path): cloud sync pulled the
319
- // operator's .claude/settings.json over a fresh install's copy ~40s
320
- // after install, byte-identical to the source machine — reverting the
321
- // installer's day-one env.PATH fix and propagating one host's PATH
322
- // snapshot to every machine/teammate. This is the recurrence mechanism
323
- // behind the recurring "qmd: command not found" reports. Settings are
324
- // machine-local (PATH snapshot, model prefs) and must never round-trip
325
- // in EITHER direction — the pull planner consults this same filter, so
326
- // an existing vault copy is also never applied locally.
327
- const shouldSync = createIgnoreFilter(hqRoot);
328
- expect(shouldSync(path.join(hqRoot, ".claude/settings.json"))).toBe(false);
329
- expect(shouldSync(path.join(hqRoot, ".claude/settings.local.json"))).toBe(false);
330
- // Nested .claude/ inside a company stays local too — same anchor shape
331
- // as the state/audit rules above.
332
- expect(
333
- shouldSync(path.join(hqRoot, "companies/indigo/.claude/settings.json")),
334
- ).toBe(false);
335
- // Siblings still sync — the rule must not broaden past settings files.
336
- expect(shouldSync(path.join(hqRoot, ".claude/skills/foo/SKILL.md"))).toBe(true);
337
- expect(shouldSync(path.join(hqRoot, ".claude/hooks/foo.sh"))).toBe(true);
338
- expect(shouldSync(path.join(hqRoot, ".claude/CLAUDE.md"))).toBe(true);
339
- });
340
-
341
- it("permissive mode: .hq/ directory is per-host state, never synced (Bug #1/#6/#8)", () => {
342
- // Bug catalog: `.hq/install-manifest.json`, `.hq/machine-id`, and
343
- // `.hq/machine.json` are per-host source-of-truth files. The original
344
- // `DEFAULT_IGNORES` only covered the `.hq-*` wildcard (with hyphen) and
345
- // explicitly left the `.hq/` directory unaffected — so the install
346
- // manifest and machine-id round-tripped through S3 between hosts,
347
- // breaking the per-machine identity contract that the 5.33.0
348
- // machine-id fix relies on.
349
- const shouldSync = createIgnoreFilter(hqRoot);
350
- expect(shouldSync(path.join(hqRoot, ".hq/install-manifest.json"))).toBe(false);
351
- expect(shouldSync(path.join(hqRoot, ".hq/machine-id"))).toBe(false);
352
- expect(shouldSync(path.join(hqRoot, ".hq/machine.json"))).toBe(false);
353
- expect(shouldSync(path.join(hqRoot, ".hq/config.json"))).toBe(false);
354
- expect(shouldSync(path.join(hqRoot, ".hq"), true)).toBe(false);
355
- // Nested .hq/ inside a company also stays local (per-host scoping).
356
- expect(shouldSync(path.join(hqRoot, "companies/indigo/.hq/config.json"))).toBe(false);
357
- });
358
-
359
- it("allowlist mode: presence of .hqinclude switches to opt-in", () => {
360
- fs.writeFileSync(
361
- path.join(hqRoot, ".hqinclude"),
362
- "companies/*/knowledge/\ncompanies/*/projects/\n",
363
- );
364
- const shouldSync = createIgnoreFilter(hqRoot);
365
- // Allowlisted paths sync.
366
- expect(shouldSync(path.join(hqRoot, "companies/indigo/knowledge/foo.md"))).toBe(true);
367
- expect(shouldSync(path.join(hqRoot, "companies/indigo/projects/p1/prd.json"))).toBe(true);
368
- // Anything else stays local — this is the privacy guarantee.
369
- expect(shouldSync(path.join(hqRoot, "companies/indigo/data/leads.csv"))).toBe(false);
370
- expect(shouldSync(path.join(hqRoot, "companies/indigo/workers/cmo/skill.md"))).toBe(false);
371
- expect(shouldSync(path.join(hqRoot, "companies/indigo/settings/aws.json"))).toBe(false);
372
- expect(shouldSync(path.join(hqRoot, "personal/journal/2026-04-26.md"))).toBe(false);
373
- });
374
-
375
- it("allowlist mode: directory entries match dir-suffix include patterns (walker descent)", () => {
376
- // Regression: walkDir tests directory entries when deciding whether to
377
- // descend. The `ignore` lib only matches dir-only patterns like
378
- // `companies/*/knowledge/` against paths that end with `/`. The filter
379
- // accepts an `isDir` hint and appends the trailing slash before probing,
380
- // mirroring how git itself decides (it knows from the index whether
381
- // each entry is a tree or a blob). Without the hint the walker would
382
- // see `companies/indigo/knowledge` -> not allowed -> never descend ->
383
- // entire subtree silently lost. Files inside still work because
384
- // `ignore` walks ancestors internally; the bug only bites the descent
385
- // decision for directory entries.
386
- fs.writeFileSync(
387
- path.join(hqRoot, ".hqinclude"),
388
- "companies/*/knowledge/\ncompanies/*/projects/\n.claude/\n",
389
- );
390
- const shouldSync = createIgnoreFilter(hqRoot);
391
- // Directory entries must be allowed when the caller hints isDir=true.
392
- expect(shouldSync(path.join(hqRoot, "companies/indigo/knowledge"), true)).toBe(true);
393
- expect(shouldSync(path.join(hqRoot, "companies/indigo/projects"), true)).toBe(true);
394
- expect(shouldSync(path.join(hqRoot, ".claude"), true)).toBe(true);
395
- // Files inside still resolve correctly without the hint.
396
- expect(shouldSync(path.join(hqRoot, "companies/indigo/knowledge/x.md"))).toBe(true);
397
- expect(shouldSync(path.join(hqRoot, ".claude/skills/foo/SKILL.md"))).toBe(true);
398
- // Machine-local settings stay excluded even inside an allowlisted
399
- // subtree — exclusion layers subtract on top of the allowlist.
400
- expect(shouldSync(path.join(hqRoot, ".claude/settings.json"))).toBe(false);
401
- // Non-allowlisted siblings stay excluded — privacy guarantee intact.
402
- expect(shouldSync(path.join(hqRoot, "companies/indigo/data"), true)).toBe(false);
403
- expect(shouldSync(path.join(hqRoot, "companies/indigo/workers"), true)).toBe(false);
404
- });
405
-
406
- it("allowlist mode: walker descends through intermediate ancestor dirs", () => {
407
- // Full gitignore semantics: a walker starting at hqRoot must be able to
408
- // descend through `companies/` and `companies/indigo/` to reach the
409
- // allowlisted leaf `companies/*/knowledge/`. The ancestor matcher
410
- // permits this for dir-mode queries while keeping files directly inside
411
- // those intermediate dirs excluded — privacy invariant intact.
412
- fs.writeFileSync(
413
- path.join(hqRoot, ".hqinclude"),
414
- "companies/*/knowledge/\n",
415
- );
416
- const shouldSync = createIgnoreFilter(hqRoot);
417
- // Intermediate directories along the path to the leaf are descent-allowed.
418
- expect(shouldSync(path.join(hqRoot, "companies"), true)).toBe(true);
419
- expect(shouldSync(path.join(hqRoot, "companies/indigo"), true)).toBe(true);
420
- // The leaf itself is allowed.
421
- expect(shouldSync(path.join(hqRoot, "companies/indigo/knowledge"), true)).toBe(true);
422
- // Files directly inside intermediate dirs are still excluded — only the
423
- // dir is descent-allowed, the dir's loose files are not.
424
- expect(shouldSync(path.join(hqRoot, "companies/indigo/notes.md"))).toBe(false);
425
- expect(shouldSync(path.join(hqRoot, "companies/README.md"))).toBe(false);
426
- // Files inside the allowlisted leaf still sync.
427
- expect(shouldSync(path.join(hqRoot, "companies/indigo/knowledge/x.md"))).toBe(true);
428
- });
429
-
430
- it("dir-only ignore patterns honor the isDir hint symmetrically", () => {
431
- // Gitignore semantics: a trailing-slash pattern (`foo/`) matches only
432
- // directories, never files of the same name. The filter applies this
433
- // on BOTH layers — exclude and include — by appending `/` to the probe
434
- // when the caller passes isDir=true, and leaving it as-is otherwise.
435
- // This guarantees:
436
- // - a directory `node_modules` is excluded (descent skipped),
437
- // - but a regular file literally named `node_modules` is NOT
438
- // mistakenly excluded by the dir-only pattern.
439
- fs.writeFileSync(path.join(hqRoot, ".hqignore"), "build/\n");
440
- const shouldSync = createIgnoreFilter(hqRoot);
441
- // Directory `build` matches the dir-only exclusion.
442
- expect(shouldSync(path.join(hqRoot, "build"), true)).toBe(false);
443
- // A file literally named `build` (not a dir) does NOT match `build/`.
444
- // This is the asymmetry that previous PR comments warned about and
445
- // that the isDir hint resolves cleanly.
446
- expect(shouldSync(path.join(hqRoot, "build"), false)).toBe(true);
447
- // Default-call (no hint) is treated as "not a directory" — matches
448
- // gitignore's blob-default and preserves the file-side guarantee.
449
- expect(shouldSync(path.join(hqRoot, "build"))).toBe(true);
450
- });
451
-
452
- it("allowlist mode: exclusion layers still subtract on top", () => {
453
- // Even when a subtree is allowlisted, default ignores like node_modules/
454
- // and .env must still apply. Otherwise an allowlisted subdir would sync
455
- // gigabytes of dependency junk or leak secret env files.
456
- fs.writeFileSync(path.join(hqRoot, ".hqinclude"), "companies/*/projects/\n");
457
- const shouldSync = createIgnoreFilter(hqRoot);
458
- expect(
459
- shouldSync(path.join(hqRoot, "companies/indigo/projects/p1/prd.json")),
460
- ).toBe(true);
461
- expect(
462
- shouldSync(path.join(hqRoot, "companies/indigo/projects/p1/node_modules/react/index.js")),
463
- ).toBe(false);
464
- expect(shouldSync(path.join(hqRoot, "companies/indigo/projects/p1/.env"))).toBe(false);
465
- });
466
- });