@indigoai-us/hq-cloud 6.18.44-alpha.48 → 6.18.44-alpha.49

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 (1021) hide show
  1. package/dist/active-company.test.d.ts +2 -0
  2. package/dist/active-company.test.d.ts.map +1 -0
  3. package/dist/active-company.test.js +149 -0
  4. package/dist/active-company.test.js.map +1 -0
  5. package/dist/agent-codex-instructions.test.d.ts +2 -0
  6. package/dist/agent-codex-instructions.test.d.ts.map +1 -0
  7. package/dist/agent-codex-instructions.test.js +276 -0
  8. package/dist/agent-codex-instructions.test.js.map +1 -0
  9. package/dist/backup-prune.test.d.ts +2 -0
  10. package/dist/backup-prune.test.d.ts.map +1 -0
  11. package/dist/backup-prune.test.js +154 -0
  12. package/dist/backup-prune.test.js.map +1 -0
  13. package/dist/bandwidth.test.d.ts +2 -0
  14. package/dist/bandwidth.test.d.ts.map +1 -0
  15. package/dist/bandwidth.test.js +342 -0
  16. package/dist/bandwidth.test.js.map +1 -0
  17. package/dist/best-effort-error.test.d.ts +2 -0
  18. package/dist/best-effort-error.test.d.ts.map +1 -0
  19. package/dist/best-effort-error.test.js +54 -0
  20. package/dist/best-effort-error.test.js.map +1 -0
  21. package/dist/bin/area-ledger-migration.test.d.ts +2 -0
  22. package/dist/bin/area-ledger-migration.test.d.ts.map +1 -0
  23. package/dist/bin/area-ledger-migration.test.js +410 -0
  24. package/dist/bin/area-ledger-migration.test.js.map +1 -0
  25. package/dist/bin/backup-prune-runner.test.d.ts +2 -0
  26. package/dist/bin/backup-prune-runner.test.d.ts.map +1 -0
  27. package/dist/bin/backup-prune-runner.test.js +22 -0
  28. package/dist/bin/backup-prune-runner.test.js.map +1 -0
  29. package/dist/bin/journal-repair.test.d.ts +2 -0
  30. package/dist/bin/journal-repair.test.d.ts.map +1 -0
  31. package/dist/bin/journal-repair.test.js +53 -0
  32. package/dist/bin/journal-repair.test.js.map +1 -0
  33. package/dist/bin/layout-compatibility.test.d.ts +2 -0
  34. package/dist/bin/layout-compatibility.test.d.ts.map +1 -0
  35. package/dist/bin/layout-compatibility.test.js +87 -0
  36. package/dist/bin/layout-compatibility.test.js.map +1 -0
  37. package/dist/bin/outpost-heartbeat.test.d.ts +7 -0
  38. package/dist/bin/outpost-heartbeat.test.d.ts.map +1 -0
  39. package/dist/bin/outpost-heartbeat.test.js +84 -0
  40. package/dist/bin/outpost-heartbeat.test.js.map +1 -0
  41. package/dist/bin/outpost-session-host.test.d.ts +7 -0
  42. package/dist/bin/outpost-session-host.test.d.ts.map +1 -0
  43. package/dist/bin/outpost-session-host.test.js +52 -0
  44. package/dist/bin/outpost-session-host.test.js.map +1 -0
  45. package/dist/bin/sync-mutation.test.d.ts +2 -0
  46. package/dist/bin/sync-mutation.test.d.ts.map +1 -0
  47. package/dist/bin/sync-mutation.test.js +64 -0
  48. package/dist/bin/sync-mutation.test.js.map +1 -0
  49. package/dist/bin/sync-runner-args.test.d.ts +2 -0
  50. package/dist/bin/sync-runner-args.test.d.ts.map +1 -0
  51. package/dist/bin/sync-runner-args.test.js +82 -0
  52. package/dist/bin/sync-runner-args.test.js.map +1 -0
  53. package/dist/bin/sync-runner-auth-wait.test.d.ts +2 -0
  54. package/dist/bin/sync-runner-auth-wait.test.d.ts.map +1 -0
  55. package/dist/bin/sync-runner-auth-wait.test.js +406 -0
  56. package/dist/bin/sync-runner-auth-wait.test.js.map +1 -0
  57. package/dist/bin/sync-runner-backoff.regression.test.d.ts +29 -0
  58. package/dist/bin/sync-runner-backoff.regression.test.d.ts.map +1 -0
  59. package/dist/bin/sync-runner-backoff.regression.test.js +224 -0
  60. package/dist/bin/sync-runner-backoff.regression.test.js.map +1 -0
  61. package/dist/bin/sync-runner-company.test.d.ts +2 -0
  62. package/dist/bin/sync-runner-company.test.d.ts.map +1 -0
  63. package/dist/bin/sync-runner-company.test.js +2439 -0
  64. package/dist/bin/sync-runner-company.test.js.map +1 -0
  65. package/dist/bin/sync-runner-delete-snapshot-mixed.bench.test.d.ts +2 -0
  66. package/dist/bin/sync-runner-delete-snapshot-mixed.bench.test.d.ts.map +1 -0
  67. package/dist/bin/sync-runner-delete-snapshot-mixed.bench.test.js +648 -0
  68. package/dist/bin/sync-runner-delete-snapshot-mixed.bench.test.js.map +1 -0
  69. package/dist/bin/sync-runner-delete-snapshot.bench.test.d.ts +2 -0
  70. package/dist/bin/sync-runner-delete-snapshot.bench.test.d.ts.map +1 -0
  71. package/dist/bin/sync-runner-delete-snapshot.bench.test.js +329 -0
  72. package/dist/bin/sync-runner-delete-snapshot.bench.test.js.map +1 -0
  73. package/dist/bin/sync-runner-events.test.d.ts +2 -0
  74. package/dist/bin/sync-runner-events.test.d.ts.map +1 -0
  75. package/dist/bin/sync-runner-events.test.js +364 -0
  76. package/dist/bin/sync-runner-events.test.js.map +1 -0
  77. package/dist/bin/sync-runner-heap-telemetry.test.d.ts +2 -0
  78. package/dist/bin/sync-runner-heap-telemetry.test.d.ts.map +1 -0
  79. package/dist/bin/sync-runner-heap-telemetry.test.js +1966 -0
  80. package/dist/bin/sync-runner-heap-telemetry.test.js.map +1 -0
  81. package/dist/bin/sync-runner-manifest.test.d.ts +12 -0
  82. package/dist/bin/sync-runner-manifest.test.d.ts.map +1 -0
  83. package/dist/bin/sync-runner-manifest.test.js +921 -0
  84. package/dist/bin/sync-runner-manifest.test.js.map +1 -0
  85. package/dist/bin/sync-runner-planning.test.d.ts +2 -0
  86. package/dist/bin/sync-runner-planning.test.d.ts.map +1 -0
  87. package/dist/bin/sync-runner-planning.test.js +448 -0
  88. package/dist/bin/sync-runner-planning.test.js.map +1 -0
  89. package/dist/bin/sync-runner-post-sync-flags.test.d.ts +2 -0
  90. package/dist/bin/sync-runner-post-sync-flags.test.d.ts.map +1 -0
  91. package/dist/bin/sync-runner-post-sync-flags.test.js +64 -0
  92. package/dist/bin/sync-runner-post-sync-flags.test.js.map +1 -0
  93. package/dist/bin/sync-runner-publish-expansion.test.d.ts +2 -0
  94. package/dist/bin/sync-runner-publish-expansion.test.d.ts.map +1 -0
  95. package/dist/bin/sync-runner-publish-expansion.test.js +54 -0
  96. package/dist/bin/sync-runner-publish-expansion.test.js.map +1 -0
  97. package/dist/bin/sync-runner-receiver-unresolved-company.test.d.ts +2 -0
  98. package/dist/bin/sync-runner-receiver-unresolved-company.test.d.ts.map +1 -0
  99. package/dist/bin/sync-runner-receiver-unresolved-company.test.js +379 -0
  100. package/dist/bin/sync-runner-receiver-unresolved-company.test.js.map +1 -0
  101. package/dist/bin/sync-runner-rollup.test.d.ts +2 -0
  102. package/dist/bin/sync-runner-rollup.test.d.ts.map +1 -0
  103. package/dist/bin/sync-runner-rollup.test.js +24 -0
  104. package/dist/bin/sync-runner-rollup.test.js.map +1 -0
  105. package/dist/bin/sync-runner-watch-loop.test.d.ts +2 -0
  106. package/dist/bin/sync-runner-watch-loop.test.d.ts.map +1 -0
  107. package/dist/bin/sync-runner-watch-loop.test.js +735 -0
  108. package/dist/bin/sync-runner-watch-loop.test.js.map +1 -0
  109. package/dist/bin/sync-runner-watch-routes.test.d.ts +2 -0
  110. package/dist/bin/sync-runner-watch-routes.test.d.ts.map +1 -0
  111. package/dist/bin/sync-runner-watch-routes.test.js +181 -0
  112. package/dist/bin/sync-runner-watch-routes.test.js.map +1 -0
  113. package/dist/bin/sync-runner.test.d.ts +10 -0
  114. package/dist/bin/sync-runner.test.d.ts.map +1 -0
  115. package/dist/bin/sync-runner.test.js +19084 -0
  116. package/dist/bin/sync-runner.test.js.map +1 -0
  117. package/dist/cli/case-alias.test.d.ts +2 -0
  118. package/dist/cli/case-alias.test.d.ts.map +1 -0
  119. package/dist/cli/case-alias.test.js +96 -0
  120. package/dist/cli/case-alias.test.js.map +1 -0
  121. package/dist/cli/conflict-recovery.test.d.ts +2 -0
  122. package/dist/cli/conflict-recovery.test.d.ts.map +1 -0
  123. package/dist/cli/conflict-recovery.test.js +207 -0
  124. package/dist/cli/conflict-recovery.test.js.map +1 -0
  125. package/dist/cli/conflict-winner.test.d.ts +7 -0
  126. package/dist/cli/conflict-winner.test.d.ts.map +1 -0
  127. package/dist/cli/conflict-winner.test.js +98 -0
  128. package/dist/cli/conflict-winner.test.js.map +1 -0
  129. package/dist/cli/doctor.test.d.ts +13 -0
  130. package/dist/cli/doctor.test.d.ts.map +1 -0
  131. package/dist/cli/doctor.test.js +607 -0
  132. package/dist/cli/doctor.test.js.map +1 -0
  133. package/dist/cli/invite.test.d.ts +5 -0
  134. package/dist/cli/invite.test.d.ts.map +1 -0
  135. package/dist/cli/invite.test.js +178 -0
  136. package/dist/cli/invite.test.js.map +1 -0
  137. package/dist/cli/onepass-pull-planner-regressions.test.d.ts +2 -0
  138. package/dist/cli/onepass-pull-planner-regressions.test.d.ts.map +1 -0
  139. package/dist/cli/onepass-pull-planner-regressions.test.js +300 -0
  140. package/dist/cli/onepass-pull-planner-regressions.test.js.map +1 -0
  141. package/dist/cli/onepass-pull-planner.test.d.ts +2 -0
  142. package/dist/cli/onepass-pull-planner.test.d.ts.map +1 -0
  143. package/dist/cli/onepass-pull-planner.test.js +266 -0
  144. package/dist/cli/onepass-pull-planner.test.js.map +1 -0
  145. package/dist/cli/push-scan-exclusions.test.d.ts +2 -0
  146. package/dist/cli/push-scan-exclusions.test.d.ts.map +1 -0
  147. package/dist/cli/push-scan-exclusions.test.js +99 -0
  148. package/dist/cli/push-scan-exclusions.test.js.map +1 -0
  149. package/dist/cli/reindex-knowledge.test.d.ts +12 -0
  150. package/dist/cli/reindex-knowledge.test.d.ts.map +1 -0
  151. package/dist/cli/reindex-knowledge.test.js +318 -0
  152. package/dist/cli/reindex-knowledge.test.js.map +1 -0
  153. package/dist/cli/reindex.test.d.ts +11 -0
  154. package/dist/cli/reindex.test.d.ts.map +1 -0
  155. package/dist/cli/reindex.test.js +860 -0
  156. package/dist/cli/reindex.test.js.map +1 -0
  157. package/dist/cli/rescue-breaker.test.d.ts +2 -0
  158. package/dist/cli/rescue-breaker.test.d.ts.map +1 -0
  159. package/dist/cli/rescue-breaker.test.js +812 -0
  160. package/dist/cli/rescue-breaker.test.js.map +1 -0
  161. package/dist/cli/rescue-classify-ordering.test.d.ts +2 -0
  162. package/dist/cli/rescue-classify-ordering.test.d.ts.map +1 -0
  163. package/dist/cli/rescue-classify-ordering.test.js +500 -0
  164. package/dist/cli/rescue-classify-ordering.test.js.map +1 -0
  165. package/dist/cli/rescue-clone-diagnostics.test.d.ts +2 -0
  166. package/dist/cli/rescue-clone-diagnostics.test.d.ts.map +1 -0
  167. package/dist/cli/rescue-clone-diagnostics.test.js +101 -0
  168. package/dist/cli/rescue-clone-diagnostics.test.js.map +1 -0
  169. package/dist/cli/rescue-clone-network-retry.test.d.ts +2 -0
  170. package/dist/cli/rescue-clone-network-retry.test.d.ts.map +1 -0
  171. package/dist/cli/rescue-clone-network-retry.test.js +415 -0
  172. package/dist/cli/rescue-clone-network-retry.test.js.map +1 -0
  173. package/dist/cli/rescue-core-stamp.test.d.ts +2 -0
  174. package/dist/cli/rescue-core-stamp.test.d.ts.map +1 -0
  175. package/dist/cli/rescue-core-stamp.test.js +364 -0
  176. package/dist/cli/rescue-core-stamp.test.js.map +1 -0
  177. package/dist/cli/rescue-drift-reconcile.test.d.ts +2 -0
  178. package/dist/cli/rescue-drift-reconcile.test.d.ts.map +1 -0
  179. package/dist/cli/rescue-drift-reconcile.test.js +162 -0
  180. package/dist/cli/rescue-drift-reconcile.test.js.map +1 -0
  181. package/dist/cli/rescue-drop-dir-symlink.test.d.ts +2 -0
  182. package/dist/cli/rescue-drop-dir-symlink.test.d.ts.map +1 -0
  183. package/dist/cli/rescue-drop-dir-symlink.test.js +255 -0
  184. package/dist/cli/rescue-drop-dir-symlink.test.js.map +1 -0
  185. package/dist/cli/rescue-exec-bit-preserve.test.d.ts +2 -0
  186. package/dist/cli/rescue-exec-bit-preserve.test.d.ts.map +1 -0
  187. package/dist/cli/rescue-exec-bit-preserve.test.js +177 -0
  188. package/dist/cli/rescue-exec-bit-preserve.test.js.map +1 -0
  189. package/dist/cli/rescue-hq-root-guard.test.d.ts +2 -0
  190. package/dist/cli/rescue-hq-root-guard.test.d.ts.map +1 -0
  191. package/dist/cli/rescue-hq-root-guard.test.js +210 -0
  192. package/dist/cli/rescue-hq-root-guard.test.js.map +1 -0
  193. package/dist/cli/rescue-journal-reconcile.test.d.ts +2 -0
  194. package/dist/cli/rescue-journal-reconcile.test.d.ts.map +1 -0
  195. package/dist/cli/rescue-journal-reconcile.test.js +186 -0
  196. package/dist/cli/rescue-journal-reconcile.test.js.map +1 -0
  197. package/dist/cli/rescue-keep-local-ignore.test.d.ts +2 -0
  198. package/dist/cli/rescue-keep-local-ignore.test.d.ts.map +1 -0
  199. package/dist/cli/rescue-keep-local-ignore.test.js +315 -0
  200. package/dist/cli/rescue-keep-local-ignore.test.js.map +1 -0
  201. package/dist/cli/rescue-move.test.d.ts +2 -0
  202. package/dist/cli/rescue-move.test.d.ts.map +1 -0
  203. package/dist/cli/rescue-move.test.js +166 -0
  204. package/dist/cli/rescue-move.test.js.map +1 -0
  205. package/dist/cli/rescue-mtime-preserve.test.d.ts +2 -0
  206. package/dist/cli/rescue-mtime-preserve.test.d.ts.map +1 -0
  207. package/dist/cli/rescue-mtime-preserve.test.js +186 -0
  208. package/dist/cli/rescue-mtime-preserve.test.js.map +1 -0
  209. package/dist/cli/rescue-preserve-copy-symlink.test.d.ts +2 -0
  210. package/dist/cli/rescue-preserve-copy-symlink.test.d.ts.map +1 -0
  211. package/dist/cli/rescue-preserve-copy-symlink.test.js +483 -0
  212. package/dist/cli/rescue-preserve-copy-symlink.test.js.map +1 -0
  213. package/dist/cli/rescue-realpath.test.d.ts +2 -0
  214. package/dist/cli/rescue-realpath.test.d.ts.map +1 -0
  215. package/dist/cli/rescue-realpath.test.js +109 -0
  216. package/dist/cli/rescue-realpath.test.js.map +1 -0
  217. package/dist/cli/rescue-restore-flag.test.d.ts +2 -0
  218. package/dist/cli/rescue-restore-flag.test.d.ts.map +1 -0
  219. package/dist/cli/rescue-restore-flag.test.js +82 -0
  220. package/dist/cli/rescue-restore-flag.test.js.map +1 -0
  221. package/dist/cli/rescue-rsync-preflight.test.d.ts +2 -0
  222. package/dist/cli/rescue-rsync-preflight.test.d.ts.map +1 -0
  223. package/dist/cli/rescue-rsync-preflight.test.js +579 -0
  224. package/dist/cli/rescue-rsync-preflight.test.js.map +1 -0
  225. package/dist/cli/rescue-rsync-status.test.d.ts +2 -0
  226. package/dist/cli/rescue-rsync-status.test.d.ts.map +1 -0
  227. package/dist/cli/rescue-rsync-status.test.js +406 -0
  228. package/dist/cli/rescue-rsync-status.test.js.map +1 -0
  229. package/dist/cli/rescue-settings-reconcile.test.d.ts +2 -0
  230. package/dist/cli/rescue-settings-reconcile.test.d.ts.map +1 -0
  231. package/dist/cli/rescue-settings-reconcile.test.js +610 -0
  232. package/dist/cli/rescue-settings-reconcile.test.js.map +1 -0
  233. package/dist/cli/rescue-snapshot-copy.test.d.ts +2 -0
  234. package/dist/cli/rescue-snapshot-copy.test.d.ts.map +1 -0
  235. package/dist/cli/rescue-snapshot-copy.test.js +790 -0
  236. package/dist/cli/rescue-snapshot-copy.test.js.map +1 -0
  237. package/dist/cli/rescue-snapshot-recovery.test.d.ts +2 -0
  238. package/dist/cli/rescue-snapshot-recovery.test.d.ts.map +1 -0
  239. package/dist/cli/rescue-snapshot-recovery.test.js +265 -0
  240. package/dist/cli/rescue-snapshot-recovery.test.js.map +1 -0
  241. package/dist/cli/rescue-snapshot.test.d.ts +2 -0
  242. package/dist/cli/rescue-snapshot.test.d.ts.map +1 -0
  243. package/dist/cli/rescue-snapshot.test.js +46 -0
  244. package/dist/cli/rescue-snapshot.test.js.map +1 -0
  245. package/dist/cli/rescue-source-switch-floor.test.d.ts +2 -0
  246. package/dist/cli/rescue-source-switch-floor.test.d.ts.map +1 -0
  247. package/dist/cli/rescue-source-switch-floor.test.js +247 -0
  248. package/dist/cli/rescue-source-switch-floor.test.js.map +1 -0
  249. package/dist/cli/rescue-unchanged-delete.test.d.ts +2 -0
  250. package/dist/cli/rescue-unchanged-delete.test.d.ts.map +1 -0
  251. package/dist/cli/rescue-unchanged-delete.test.js +305 -0
  252. package/dist/cli/rescue-unchanged-delete.test.js.map +1 -0
  253. package/dist/cli/rescue.reindex.test.d.ts +2 -0
  254. package/dist/cli/rescue.reindex.test.d.ts.map +1 -0
  255. package/dist/cli/rescue.reindex.test.js +72 -0
  256. package/dist/cli/rescue.reindex.test.js.map +1 -0
  257. package/dist/cli/rescue.test.d.ts +2 -0
  258. package/dist/cli/rescue.test.d.ts.map +1 -0
  259. package/dist/cli/rescue.test.js +127 -0
  260. package/dist/cli/rescue.test.js.map +1 -0
  261. package/dist/cli/share-plan-limit-presign.test.d.ts +2 -0
  262. package/dist/cli/share-plan-limit-presign.test.d.ts.map +1 -0
  263. package/dist/cli/share-plan-limit-presign.test.js +271 -0
  264. package/dist/cli/share-plan-limit-presign.test.js.map +1 -0
  265. package/dist/cli/share-presign-transport.test.d.ts +22 -0
  266. package/dist/cli/share-presign-transport.test.d.ts.map +1 -0
  267. package/dist/cli/share-presign-transport.test.js +388 -0
  268. package/dist/cli/share-presign-transport.test.js.map +1 -0
  269. package/dist/cli/share.test.d.ts +5 -0
  270. package/dist/cli/share.test.d.ts.map +1 -0
  271. package/dist/cli/share.test.js +12336 -0
  272. package/dist/cli/share.test.js.map +1 -0
  273. package/dist/cli/streaming-pull-planner.bench.test.d.ts +15 -0
  274. package/dist/cli/streaming-pull-planner.bench.test.d.ts.map +1 -0
  275. package/dist/cli/streaming-pull-planner.bench.test.js +273 -0
  276. package/dist/cli/streaming-pull-planner.bench.test.js.map +1 -0
  277. package/dist/cli/sync-scope.test.d.ts +22 -0
  278. package/dist/cli/sync-scope.test.d.ts.map +1 -0
  279. package/dist/cli/sync-scope.test.js +903 -0
  280. package/dist/cli/sync-scope.test.js.map +1 -0
  281. package/dist/cli/sync.test.d.ts +5 -0
  282. package/dist/cli/sync.test.d.ts.map +1 -0
  283. package/dist/cli/sync.test.js +9028 -0
  284. package/dist/cli/sync.test.js.map +1 -0
  285. package/dist/cli/tombstones.test.d.ts +2 -0
  286. package/dist/cli/tombstones.test.d.ts.map +1 -0
  287. package/dist/cli/tombstones.test.js +120 -0
  288. package/dist/cli/tombstones.test.js.map +1 -0
  289. package/dist/cli/watch-event-push-conflict.test.d.ts +25 -0
  290. package/dist/cli/watch-event-push-conflict.test.d.ts.map +1 -0
  291. package/dist/cli/watch-event-push-conflict.test.js +230 -0
  292. package/dist/cli/watch-event-push-conflict.test.js.map +1 -0
  293. package/dist/client-info.test.d.ts +11 -0
  294. package/dist/client-info.test.d.ts.map +1 -0
  295. package/dist/client-info.test.js +168 -0
  296. package/dist/client-info.test.js.map +1 -0
  297. package/dist/cognito-auth-lock-no-hard-links.test.d.ts +11 -0
  298. package/dist/cognito-auth-lock-no-hard-links.test.d.ts.map +1 -0
  299. package/dist/cognito-auth-lock-no-hard-links.test.js +76 -0
  300. package/dist/cognito-auth-lock-no-hard-links.test.js.map +1 -0
  301. package/dist/cognito-auth.test.d.ts +9 -0
  302. package/dist/cognito-auth.test.d.ts.map +1 -0
  303. package/dist/cognito-auth.test.js +745 -0
  304. package/dist/cognito-auth.test.js.map +1 -0
  305. package/dist/company-resolver.test.d.ts +7 -0
  306. package/dist/company-resolver.test.d.ts.map +1 -0
  307. package/dist/company-resolver.test.js +535 -0
  308. package/dist/company-resolver.test.js.map +1 -0
  309. package/dist/company-slug.test.d.ts +7 -0
  310. package/dist/company-slug.test.d.ts.map +1 -0
  311. package/dist/company-slug.test.js +43 -0
  312. package/dist/company-slug.test.js.map +1 -0
  313. package/dist/company-vault-transport.test.d.ts +12 -0
  314. package/dist/company-vault-transport.test.d.ts.map +1 -0
  315. package/dist/company-vault-transport.test.js +97 -0
  316. package/dist/company-vault-transport.test.js.map +1 -0
  317. package/dist/context.test.d.ts +7 -0
  318. package/dist/context.test.d.ts.map +1 -0
  319. package/dist/context.test.js +646 -0
  320. package/dist/context.test.js.map +1 -0
  321. package/dist/entity-resolver.test.d.ts +10 -0
  322. package/dist/entity-resolver.test.d.ts.map +1 -0
  323. package/dist/entity-resolver.test.js +244 -0
  324. package/dist/entity-resolver.test.js.map +1 -0
  325. package/dist/getindigo-dead-refs-contract.test.d.ts +2 -0
  326. package/dist/getindigo-dead-refs-contract.test.d.ts.map +1 -0
  327. package/dist/getindigo-dead-refs-contract.test.js +58 -0
  328. package/dist/getindigo-dead-refs-contract.test.js.map +1 -0
  329. package/dist/hermetic-test-env.test.d.ts +2 -0
  330. package/dist/hermetic-test-env.test.d.ts.map +1 -0
  331. package/dist/hermetic-test-env.test.js +61 -0
  332. package/dist/hermetic-test-env.test.js.map +1 -0
  333. package/dist/hq-root-recovery.test.d.ts +2 -0
  334. package/dist/hq-root-recovery.test.d.ts.map +1 -0
  335. package/dist/hq-root-recovery.test.js +65 -0
  336. package/dist/hq-root-recovery.test.js.map +1 -0
  337. package/dist/ignore.test.d.ts +10 -0
  338. package/dist/ignore.test.d.ts.map +1 -0
  339. package/dist/ignore.test.js +958 -0
  340. package/dist/ignore.test.js.map +1 -0
  341. package/dist/index.test.d.ts +2 -0
  342. package/dist/index.test.d.ts.map +1 -0
  343. package/dist/index.test.js +26 -0
  344. package/dist/index.test.js.map +1 -0
  345. package/dist/journal-area-ledger-read-boundary.test.d.ts +2 -0
  346. package/dist/journal-area-ledger-read-boundary.test.d.ts.map +1 -0
  347. package/dist/journal-area-ledger-read-boundary.test.js +425 -0
  348. package/dist/journal-area-ledger-read-boundary.test.js.map +1 -0
  349. package/dist/journal-baseline.test.d.ts +2 -0
  350. package/dist/journal-baseline.test.d.ts.map +1 -0
  351. package/dist/journal-baseline.test.js +218 -0
  352. package/dist/journal-baseline.test.js.map +1 -0
  353. package/dist/journal-decode-window.test.d.ts +2 -0
  354. package/dist/journal-decode-window.test.d.ts.map +1 -0
  355. package/dist/journal-decode-window.test.js +99 -0
  356. package/dist/journal-decode-window.test.js.map +1 -0
  357. package/dist/journal-delta-writes.test.d.ts +2 -0
  358. package/dist/journal-delta-writes.test.d.ts.map +1 -0
  359. package/dist/journal-delta-writes.test.js +159 -0
  360. package/dist/journal-delta-writes.test.js.map +1 -0
  361. package/dist/journal-ledger-index.test.d.ts +15 -0
  362. package/dist/journal-ledger-index.test.d.ts.map +1 -0
  363. package/dist/journal-ledger-index.test.js +269 -0
  364. package/dist/journal-ledger-index.test.js.map +1 -0
  365. package/dist/journal-public-boundary.test.d.ts +2 -0
  366. package/dist/journal-public-boundary.test.d.ts.map +1 -0
  367. package/dist/journal-public-boundary.test.js +216 -0
  368. package/dist/journal-public-boundary.test.js.map +1 -0
  369. package/dist/journal-row-store.test.d.ts +2 -0
  370. package/dist/journal-row-store.test.d.ts.map +1 -0
  371. package/dist/journal-row-store.test.js +729 -0
  372. package/dist/journal-row-store.test.js.map +1 -0
  373. package/dist/journal-snapshot-memory-helpers.d.ts +35 -0
  374. package/dist/journal-snapshot-memory-helpers.d.ts.map +1 -0
  375. package/dist/journal-snapshot-memory-helpers.js +298 -0
  376. package/dist/journal-snapshot-memory-helpers.js.map +1 -0
  377. package/dist/journal-snapshot-memory.test.d.ts +2 -0
  378. package/dist/journal-snapshot-memory.test.d.ts.map +1 -0
  379. package/dist/journal-snapshot-memory.test.js +55 -0
  380. package/dist/journal-snapshot-memory.test.js.map +1 -0
  381. package/dist/journal-snapshot-v4-memory.test.d.ts +2 -0
  382. package/dist/journal-snapshot-v4-memory.test.d.ts.map +1 -0
  383. package/dist/journal-snapshot-v4-memory.test.js +24 -0
  384. package/dist/journal-snapshot-v4-memory.test.js.map +1 -0
  385. package/dist/journal-snapshot-v4-writer-memory.test.d.ts +2 -0
  386. package/dist/journal-snapshot-v4-writer-memory.test.d.ts.map +1 -0
  387. package/dist/journal-snapshot-v4-writer-memory.test.js +76 -0
  388. package/dist/journal-snapshot-v4-writer-memory.test.js.map +1 -0
  389. package/dist/journal-snapshot-v4-writer.test.d.ts +2 -0
  390. package/dist/journal-snapshot-v4-writer.test.d.ts.map +1 -0
  391. package/dist/journal-snapshot-v4-writer.test.js +282 -0
  392. package/dist/journal-snapshot-v4-writer.test.js.map +1 -0
  393. package/dist/journal-snapshot-v4.test.d.ts +2 -0
  394. package/dist/journal-snapshot-v4.test.d.ts.map +1 -0
  395. package/dist/journal-snapshot-v4.test.js +281 -0
  396. package/dist/journal-snapshot-v4.test.js.map +1 -0
  397. package/dist/journal-store.test.d.ts +2 -0
  398. package/dist/journal-store.test.d.ts.map +1 -0
  399. package/dist/journal-store.test.js +1227 -0
  400. package/dist/journal-store.test.js.map +1 -0
  401. package/dist/journal-streaming.heap.test.d.ts +2 -0
  402. package/dist/journal-streaming.heap.test.d.ts.map +1 -0
  403. package/dist/journal-streaming.heap.test.js +190 -0
  404. package/dist/journal-streaming.heap.test.js.map +1 -0
  405. package/dist/journal.test.d.ts +9 -0
  406. package/dist/journal.test.d.ts.map +1 -0
  407. package/dist/journal.test.js +1074 -0
  408. package/dist/journal.test.js.map +1 -0
  409. package/dist/kms10-etag-safe-pull.test.d.ts +2 -0
  410. package/dist/kms10-etag-safe-pull.test.d.ts.map +1 -0
  411. package/dist/kms10-etag-safe-pull.test.js +53 -0
  412. package/dist/kms10-etag-safe-pull.test.js.map +1 -0
  413. package/dist/lib/cloud-authoritative.test.d.ts +2 -0
  414. package/dist/lib/cloud-authoritative.test.d.ts.map +1 -0
  415. package/dist/lib/cloud-authoritative.test.js +42 -0
  416. package/dist/lib/cloud-authoritative.test.js.map +1 -0
  417. package/dist/lib/conflict-reconcile.test.d.ts +7 -0
  418. package/dist/lib/conflict-reconcile.test.d.ts.map +1 -0
  419. package/dist/lib/conflict-reconcile.test.js +246 -0
  420. package/dist/lib/conflict-reconcile.test.js.map +1 -0
  421. package/dist/lib/conflict.test.d.ts +9 -0
  422. package/dist/lib/conflict.test.d.ts.map +1 -0
  423. package/dist/lib/conflict.test.js +340 -0
  424. package/dist/lib/conflict.test.js.map +1 -0
  425. package/dist/lib/describe-error.test.d.ts +2 -0
  426. package/dist/lib/describe-error.test.d.ts.map +1 -0
  427. package/dist/lib/describe-error.test.js +148 -0
  428. package/dist/lib/describe-error.test.js.map +1 -0
  429. package/dist/lib/machine-id.test.d.ts +8 -0
  430. package/dist/lib/machine-id.test.d.ts.map +1 -0
  431. package/dist/lib/machine-id.test.js +228 -0
  432. package/dist/lib/machine-id.test.js.map +1 -0
  433. package/dist/lib/net-errors.test.d.ts +2 -0
  434. package/dist/lib/net-errors.test.d.ts.map +1 -0
  435. package/dist/lib/net-errors.test.js +111 -0
  436. package/dist/lib/net-errors.test.js.map +1 -0
  437. package/dist/lib/ontology-entity-meta.test.d.ts +2 -0
  438. package/dist/lib/ontology-entity-meta.test.d.ts.map +1 -0
  439. package/dist/lib/ontology-entity-meta.test.js +79 -0
  440. package/dist/lib/ontology-entity-meta.test.js.map +1 -0
  441. package/dist/lib/ontology-entity-push.test.d.ts +2 -0
  442. package/dist/lib/ontology-entity-push.test.d.ts.map +1 -0
  443. package/dist/lib/ontology-entity-push.test.js +156 -0
  444. package/dist/lib/ontology-entity-push.test.js.map +1 -0
  445. package/dist/lib/personal-connector-settings-sync.test.d.ts +2 -0
  446. package/dist/lib/personal-connector-settings-sync.test.d.ts.map +1 -0
  447. package/dist/lib/personal-connector-settings-sync.test.js +34 -0
  448. package/dist/lib/personal-connector-settings-sync.test.js.map +1 -0
  449. package/dist/lib/readlink-safe.test.d.ts +2 -0
  450. package/dist/lib/readlink-safe.test.d.ts.map +1 -0
  451. package/dist/lib/readlink-safe.test.js +34 -0
  452. package/dist/lib/readlink-safe.test.js.map +1 -0
  453. package/dist/lib/s3-content-checksum.test.d.ts +2 -0
  454. package/dist/lib/s3-content-checksum.test.d.ts.map +1 -0
  455. package/dist/lib/s3-content-checksum.test.js +26 -0
  456. package/dist/lib/s3-content-checksum.test.js.map +1 -0
  457. package/dist/lib/skill-register-landed-bytes.test.d.ts +2 -0
  458. package/dist/lib/skill-register-landed-bytes.test.d.ts.map +1 -0
  459. package/dist/lib/skill-register-landed-bytes.test.js +83 -0
  460. package/dist/lib/skill-register-landed-bytes.test.js.map +1 -0
  461. package/dist/local-path-codec.test.d.ts +14 -0
  462. package/dist/local-path-codec.test.d.ts.map +1 -0
  463. package/dist/local-path-codec.test.js +122 -0
  464. package/dist/local-path-codec.test.js.map +1 -0
  465. package/dist/machine-auth.test.d.ts +14 -0
  466. package/dist/machine-auth.test.d.ts.map +1 -0
  467. package/dist/machine-auth.test.js +1492 -0
  468. package/dist/machine-auth.test.js.map +1 -0
  469. package/dist/machine-token-cache-isolation.test.d.ts +24 -0
  470. package/dist/machine-token-cache-isolation.test.d.ts.map +1 -0
  471. package/dist/machine-token-cache-isolation.test.js +284 -0
  472. package/dist/machine-token-cache-isolation.test.js.map +1 -0
  473. package/dist/manifest/US-002.acceptance.test.d.ts +11 -0
  474. package/dist/manifest/US-002.acceptance.test.d.ts.map +1 -0
  475. package/dist/manifest/US-002.acceptance.test.js +160 -0
  476. package/dist/manifest/US-002.acceptance.test.js.map +1 -0
  477. package/dist/manifest/US-004.acceptance.test.d.ts +12 -0
  478. package/dist/manifest/US-004.acceptance.test.d.ts.map +1 -0
  479. package/dist/manifest/US-004.acceptance.test.js +173 -0
  480. package/dist/manifest/US-004.acceptance.test.js.map +1 -0
  481. package/dist/manifest/bench-gate.d.ts +30 -0
  482. package/dist/manifest/bench-gate.d.ts.map +1 -0
  483. package/dist/manifest/bench-gate.js +47 -0
  484. package/dist/manifest/bench-gate.js.map +1 -0
  485. package/dist/manifest/bench-gate.test.d.ts +2 -0
  486. package/dist/manifest/bench-gate.test.d.ts.map +1 -0
  487. package/dist/manifest/bench-gate.test.js +67 -0
  488. package/dist/manifest/bench-gate.test.js.map +1 -0
  489. package/dist/manifest/build-manifest-resident-parity.test.d.ts +2 -0
  490. package/dist/manifest/build-manifest-resident-parity.test.d.ts.map +1 -0
  491. package/dist/manifest/build-manifest-resident-parity.test.js +69 -0
  492. package/dist/manifest/build-manifest-resident-parity.test.js.map +1 -0
  493. package/dist/manifest/build-manifest.bench.test.d.ts +22 -0
  494. package/dist/manifest/build-manifest.bench.test.d.ts.map +1 -0
  495. package/dist/manifest/build-manifest.bench.test.js +931 -0
  496. package/dist/manifest/build-manifest.bench.test.js.map +1 -0
  497. package/dist/manifest/build-manifest.test.d.ts +10 -0
  498. package/dist/manifest/build-manifest.test.d.ts.map +1 -0
  499. package/dist/manifest/build-manifest.test.js +1220 -0
  500. package/dist/manifest/build-manifest.test.js.map +1 -0
  501. package/dist/manifest/contract.test.d.ts +17 -0
  502. package/dist/manifest/contract.test.d.ts.map +1 -0
  503. package/dist/manifest/contract.test.js +346 -0
  504. package/dist/manifest/contract.test.js.map +1 -0
  505. package/dist/manifest/import-graph.test.d.ts +25 -0
  506. package/dist/manifest/import-graph.test.d.ts.map +1 -0
  507. package/dist/manifest/import-graph.test.js +120 -0
  508. package/dist/manifest/import-graph.test.js.map +1 -0
  509. package/dist/manifest/ledger-shard-isolation.test.d.ts +18 -0
  510. package/dist/manifest/ledger-shard-isolation.test.d.ts.map +1 -0
  511. package/dist/manifest/ledger-shard-isolation.test.js +153 -0
  512. package/dist/manifest/ledger-shard-isolation.test.js.map +1 -0
  513. package/dist/manifest/snapshot-store.test.d.ts +11 -0
  514. package/dist/manifest/snapshot-store.test.d.ts.map +1 -0
  515. package/dist/manifest/snapshot-store.test.js +206 -0
  516. package/dist/manifest/snapshot-store.test.js.map +1 -0
  517. package/dist/manifest/upload-manifest.test.d.ts +10 -0
  518. package/dist/manifest/upload-manifest.test.d.ts.map +1 -0
  519. package/dist/manifest/upload-manifest.test.js +1335 -0
  520. package/dist/manifest/upload-manifest.test.js.map +1 -0
  521. package/dist/manifest-reconcile.test.d.ts +2 -0
  522. package/dist/manifest-reconcile.test.d.ts.map +1 -0
  523. package/dist/manifest-reconcile.test.js +1032 -0
  524. package/dist/manifest-reconcile.test.js.map +1 -0
  525. package/dist/object-io.test.d.ts +11 -0
  526. package/dist/object-io.test.d.ts.map +1 -0
  527. package/dist/object-io.test.js +2376 -0
  528. package/dist/object-io.test.js.map +1 -0
  529. package/dist/operation-lock.test.d.ts +5 -0
  530. package/dist/operation-lock.test.d.ts.map +1 -0
  531. package/dist/operation-lock.test.js +796 -0
  532. package/dist/operation-lock.test.js.map +1 -0
  533. package/dist/outcome-telemetry.test.d.ts +9 -0
  534. package/dist/outcome-telemetry.test.d.ts.map +1 -0
  535. package/dist/outcome-telemetry.test.js +663 -0
  536. package/dist/outcome-telemetry.test.js.map +1 -0
  537. package/dist/outposts/client.test.d.ts +9 -0
  538. package/dist/outposts/client.test.d.ts.map +1 -0
  539. package/dist/outposts/client.test.js +415 -0
  540. package/dist/outposts/client.test.js.map +1 -0
  541. package/dist/outposts/command.test.d.ts +18 -0
  542. package/dist/outposts/command.test.d.ts.map +1 -0
  543. package/dist/outposts/command.test.js +1230 -0
  544. package/dist/outposts/command.test.js.map +1 -0
  545. package/dist/outposts/replica-sync.test.d.ts +2 -0
  546. package/dist/outposts/replica-sync.test.d.ts.map +1 -0
  547. package/dist/outposts/replica-sync.test.js +225 -0
  548. package/dist/outposts/replica-sync.test.js.map +1 -0
  549. package/dist/outposts/self-deploy.test.d.ts +2 -0
  550. package/dist/outposts/self-deploy.test.d.ts.map +1 -0
  551. package/dist/outposts/self-deploy.test.js +218 -0
  552. package/dist/outposts/self-deploy.test.js.map +1 -0
  553. package/dist/outposts/session-heartbeat-bounds.test.d.ts +25 -0
  554. package/dist/outposts/session-heartbeat-bounds.test.d.ts.map +1 -0
  555. package/dist/outposts/session-heartbeat-bounds.test.js +159 -0
  556. package/dist/outposts/session-heartbeat-bounds.test.js.map +1 -0
  557. package/dist/outposts/session-heartbeat-guard.test.d.ts +16 -0
  558. package/dist/outposts/session-heartbeat-guard.test.d.ts.map +1 -0
  559. package/dist/outposts/session-heartbeat-guard.test.js +88 -0
  560. package/dist/outposts/session-heartbeat-guard.test.js.map +1 -0
  561. package/dist/outposts/session-heartbeat-publisher.test.d.ts +10 -0
  562. package/dist/outposts/session-heartbeat-publisher.test.d.ts.map +1 -0
  563. package/dist/outposts/session-heartbeat-publisher.test.js +153 -0
  564. package/dist/outposts/session-heartbeat-publisher.test.js.map +1 -0
  565. package/dist/outposts/session-heartbeat-retain-guard.test.d.ts +18 -0
  566. package/dist/outposts/session-heartbeat-retain-guard.test.d.ts.map +1 -0
  567. package/dist/outposts/session-heartbeat-retain-guard.test.js +106 -0
  568. package/dist/outposts/session-heartbeat-retain-guard.test.js.map +1 -0
  569. package/dist/outposts/session-heartbeat-scan.test.d.ts +20 -0
  570. package/dist/outposts/session-heartbeat-scan.test.d.ts.map +1 -0
  571. package/dist/outposts/session-heartbeat-scan.test.js +242 -0
  572. package/dist/outposts/session-heartbeat-scan.test.js.map +1 -0
  573. package/dist/outposts/session-heartbeat.test.d.ts +11 -0
  574. package/dist/outposts/session-heartbeat.test.d.ts.map +1 -0
  575. package/dist/outposts/session-heartbeat.test.js +387 -0
  576. package/dist/outposts/session-heartbeat.test.js.map +1 -0
  577. package/dist/outposts/session-host-auth.test.d.ts +16 -0
  578. package/dist/outposts/session-host-auth.test.d.ts.map +1 -0
  579. package/dist/outposts/session-host-auth.test.js +284 -0
  580. package/dist/outposts/session-host-auth.test.js.map +1 -0
  581. package/dist/outposts/session-host-command.test.d.ts +10 -0
  582. package/dist/outposts/session-host-command.test.d.ts.map +1 -0
  583. package/dist/outposts/session-host-command.test.js +182 -0
  584. package/dist/outposts/session-host-command.test.js.map +1 -0
  585. package/dist/outposts/session-host-connection.test.d.ts +18 -0
  586. package/dist/outposts/session-host-connection.test.d.ts.map +1 -0
  587. package/dist/outposts/session-host-connection.test.js +392 -0
  588. package/dist/outposts/session-host-connection.test.js.map +1 -0
  589. package/dist/outposts/session-host-fakes.d.ts +61 -0
  590. package/dist/outposts/session-host-fakes.d.ts.map +1 -0
  591. package/dist/outposts/session-host-fakes.js +115 -0
  592. package/dist/outposts/session-host-fakes.js.map +1 -0
  593. package/dist/outposts/session-host-ndjson.test.d.ts +11 -0
  594. package/dist/outposts/session-host-ndjson.test.d.ts.map +1 -0
  595. package/dist/outposts/session-host-ndjson.test.js +73 -0
  596. package/dist/outposts/session-host-ndjson.test.js.map +1 -0
  597. package/dist/outposts/session-host-protocol.test.d.ts +15 -0
  598. package/dist/outposts/session-host-protocol.test.d.ts.map +1 -0
  599. package/dist/outposts/session-host-protocol.test.js +0 -0
  600. package/dist/outposts/session-host-protocol.test.js.map +1 -0
  601. package/dist/outposts/session-host-server.test.d.ts +10 -0
  602. package/dist/outposts/session-host-server.test.d.ts.map +1 -0
  603. package/dist/outposts/session-host-server.test.js +118 -0
  604. package/dist/outposts/session-host-server.test.js.map +1 -0
  605. package/dist/outposts/session-host-sessions.test.d.ts +18 -0
  606. package/dist/outposts/session-host-sessions.test.d.ts.map +1 -0
  607. package/dist/outposts/session-host-sessions.test.js +439 -0
  608. package/dist/outposts/session-host-sessions.test.js.map +1 -0
  609. package/dist/outposts/terminal.test.d.ts +2 -0
  610. package/dist/outposts/terminal.test.d.ts.map +1 -0
  611. package/dist/outposts/terminal.test.js +146 -0
  612. package/dist/outposts/terminal.test.js.map +1 -0
  613. package/dist/outposts/transport.test.d.ts +10 -0
  614. package/dist/outposts/transport.test.d.ts.map +1 -0
  615. package/dist/outposts/transport.test.js +205 -0
  616. package/dist/outposts/transport.test.js.map +1 -0
  617. package/dist/packed-journal-phase2.test.d.ts +2 -0
  618. package/dist/packed-journal-phase2.test.d.ts.map +1 -0
  619. package/dist/packed-journal-phase2.test.js +273 -0
  620. package/dist/packed-journal-phase2.test.js.map +1 -0
  621. package/dist/path-ancestors.test.d.ts +2 -0
  622. package/dist/path-ancestors.test.d.ts.map +1 -0
  623. package/dist/path-ancestors.test.js +21 -0
  624. package/dist/path-ancestors.test.js.map +1 -0
  625. package/dist/personal-vault-exclusions.test.d.ts +22 -0
  626. package/dist/personal-vault-exclusions.test.d.ts.map +1 -0
  627. package/dist/personal-vault-exclusions.test.js +294 -0
  628. package/dist/personal-vault-exclusions.test.js.map +1 -0
  629. package/dist/personal-vault.test.d.ts +18 -0
  630. package/dist/personal-vault.test.d.ts.map +1 -0
  631. package/dist/personal-vault.test.js +1106 -0
  632. package/dist/personal-vault.test.js.map +1 -0
  633. package/dist/plan-limit-pause.test.d.ts +2 -0
  634. package/dist/plan-limit-pause.test.d.ts.map +1 -0
  635. package/dist/plan-limit-pause.test.js +150 -0
  636. package/dist/plan-limit-pause.test.js.map +1 -0
  637. package/dist/plan-limit.fixtures.d.ts +34 -0
  638. package/dist/plan-limit.fixtures.d.ts.map +1 -0
  639. package/dist/plan-limit.fixtures.js +96 -0
  640. package/dist/plan-limit.fixtures.js.map +1 -0
  641. package/dist/plan-limit.test.d.ts +2 -0
  642. package/dist/plan-limit.test.d.ts.map +1 -0
  643. package/dist/plan-limit.test.js +132 -0
  644. package/dist/plan-limit.test.js.map +1 -0
  645. package/dist/prefix-coalesce.test.d.ts +2 -0
  646. package/dist/prefix-coalesce.test.d.ts.map +1 -0
  647. package/dist/prefix-coalesce.test.js +260 -0
  648. package/dist/prefix-coalesce.test.js.map +1 -0
  649. package/dist/private-folder-transport.test.d.ts +2 -0
  650. package/dist/private-folder-transport.test.d.ts.map +1 -0
  651. package/dist/private-folder-transport.test.js +33 -0
  652. package/dist/private-folder-transport.test.js.map +1 -0
  653. package/dist/public-surface.test.d.ts +15 -0
  654. package/dist/public-surface.test.d.ts.map +1 -0
  655. package/dist/public-surface.test.js +110 -0
  656. package/dist/public-surface.test.js.map +1 -0
  657. package/dist/qmd-reindex.test.d.ts +14 -0
  658. package/dist/qmd-reindex.test.d.ts.map +1 -0
  659. package/dist/qmd-reindex.test.js +904 -0
  660. package/dist/qmd-reindex.test.js.map +1 -0
  661. package/dist/read-only-state-dir.test.d.ts +27 -0
  662. package/dist/read-only-state-dir.test.d.ts.map +1 -0
  663. package/dist/read-only-state-dir.test.js +210 -0
  664. package/dist/read-only-state-dir.test.js.map +1 -0
  665. package/dist/remote-pull.test.d.ts +2 -0
  666. package/dist/remote-pull.test.d.ts.map +1 -0
  667. package/dist/remote-pull.test.js +1147 -0
  668. package/dist/remote-pull.test.js.map +1 -0
  669. package/dist/s3-download-stream-hash.test.d.ts +2 -0
  670. package/dist/s3-download-stream-hash.test.d.ts.map +1 -0
  671. package/dist/s3-download-stream-hash.test.js +70 -0
  672. package/dist/s3-download-stream-hash.test.js.map +1 -0
  673. package/dist/s3.list-cost.test.d.ts +2 -0
  674. package/dist/s3.list-cost.test.d.ts.map +1 -0
  675. package/dist/s3.list-cost.test.js +51 -0
  676. package/dist/s3.list-cost.test.js.map +1 -0
  677. package/dist/s3.rename-retry.test.d.ts +2 -0
  678. package/dist/s3.rename-retry.test.d.ts.map +1 -0
  679. package/dist/s3.rename-retry.test.js +217 -0
  680. package/dist/s3.rename-retry.test.js.map +1 -0
  681. package/dist/s3.symlink-materialize.test.d.ts +18 -0
  682. package/dist/s3.symlink-materialize.test.d.ts.map +1 -0
  683. package/dist/s3.symlink-materialize.test.js +591 -0
  684. package/dist/s3.symlink-materialize.test.js.map +1 -0
  685. package/dist/s3.test.d.ts +9 -0
  686. package/dist/s3.test.d.ts.map +1 -0
  687. package/dist/s3.test.js +2091 -0
  688. package/dist/s3.test.js.map +1 -0
  689. package/dist/s3.windows-portability.test.d.ts +12 -0
  690. package/dist/s3.windows-portability.test.d.ts.map +1 -0
  691. package/dist/s3.windows-portability.test.js +228 -0
  692. package/dist/s3.windows-portability.test.js.map +1 -0
  693. package/dist/schemas/signal-types.test.d.ts +2 -0
  694. package/dist/schemas/signal-types.test.d.ts.map +1 -0
  695. package/dist/schemas/signal-types.test.js +65 -0
  696. package/dist/schemas/signal-types.test.js.map +1 -0
  697. package/dist/schemas/source-channels.test.d.ts +2 -0
  698. package/dist/schemas/source-channels.test.d.ts.map +1 -0
  699. package/dist/schemas/source-channels.test.js +65 -0
  700. package/dist/schemas/source-channels.test.js.map +1 -0
  701. package/dist/scope-shrink.test.d.ts +13 -0
  702. package/dist/scope-shrink.test.d.ts.map +1 -0
  703. package/dist/scope-shrink.test.js +558 -0
  704. package/dist/scope-shrink.test.js.map +1 -0
  705. package/dist/session-log-capture.test.d.ts +2 -0
  706. package/dist/session-log-capture.test.d.ts.map +1 -0
  707. package/dist/session-log-capture.test.js +533 -0
  708. package/dist/session-log-capture.test.js.map +1 -0
  709. package/dist/session-log-retention.test.d.ts +2 -0
  710. package/dist/session-log-retention.test.d.ts.map +1 -0
  711. package/dist/session-log-retention.test.js +383 -0
  712. package/dist/session-log-retention.test.js.map +1 -0
  713. package/dist/signals/get.test.d.ts +5 -0
  714. package/dist/signals/get.test.d.ts.map +1 -0
  715. package/dist/signals/get.test.js +254 -0
  716. package/dist/signals/get.test.js.map +1 -0
  717. package/dist/signals/list.test.d.ts +9 -0
  718. package/dist/signals/list.test.d.ts.map +1 -0
  719. package/dist/signals/list.test.js +330 -0
  720. package/dist/signals/list.test.js.map +1 -0
  721. package/dist/skill-telemetry.test.d.ts +2 -0
  722. package/dist/skill-telemetry.test.d.ts.map +1 -0
  723. package/dist/skill-telemetry.test.js +1484 -0
  724. package/dist/skill-telemetry.test.js.map +1 -0
  725. package/dist/sources/get.test.d.ts +5 -0
  726. package/dist/sources/get.test.d.ts.map +1 -0
  727. package/dist/sources/get.test.js +236 -0
  728. package/dist/sources/get.test.js.map +1 -0
  729. package/dist/sources/list.test.d.ts +8 -0
  730. package/dist/sources/list.test.d.ts.map +1 -0
  731. package/dist/sources/list.test.js +318 -0
  732. package/dist/sources/list.test.js.map +1 -0
  733. package/dist/sts-credential-refresh.test.d.ts +2 -0
  734. package/dist/sts-credential-refresh.test.d.ts.map +1 -0
  735. package/dist/sts-credential-refresh.test.js +181 -0
  736. package/dist/sts-credential-refresh.test.js.map +1 -0
  737. package/dist/swallowed-error-sites.test.d.ts +2 -0
  738. package/dist/swallowed-error-sites.test.d.ts.map +1 -0
  739. package/dist/swallowed-error-sites.test.js +209 -0
  740. package/dist/swallowed-error-sites.test.js.map +1 -0
  741. package/dist/swallowed-error-w32.test.d.ts +2 -0
  742. package/dist/swallowed-error-w32.test.d.ts.map +1 -0
  743. package/dist/swallowed-error-w32.test.js +186 -0
  744. package/dist/swallowed-error-w32.test.js.map +1 -0
  745. package/dist/swallowed-error-w33.test.d.ts +2 -0
  746. package/dist/swallowed-error-w33.test.d.ts.map +1 -0
  747. package/dist/swallowed-error-w33.test.js +136 -0
  748. package/dist/swallowed-error-w33.test.js.map +1 -0
  749. package/dist/swallowed-error-w34.test.d.ts +2 -0
  750. package/dist/swallowed-error-w34.test.d.ts.map +1 -0
  751. package/dist/swallowed-error-w34.test.js +110 -0
  752. package/dist/swallowed-error-w34.test.js.map +1 -0
  753. package/dist/swallowed-error-w35.test.d.ts +2 -0
  754. package/dist/swallowed-error-w35.test.d.ts.map +1 -0
  755. package/dist/swallowed-error-w35.test.js +237 -0
  756. package/dist/swallowed-error-w35.test.js.map +1 -0
  757. package/dist/sync/area-ledger-auto-migration.test.d.ts +2 -0
  758. package/dist/sync/area-ledger-auto-migration.test.d.ts.map +1 -0
  759. package/dist/sync/area-ledger-auto-migration.test.js +291 -0
  760. package/dist/sync/area-ledger-auto-migration.test.js.map +1 -0
  761. package/dist/sync/area-ledger-migration.test.d.ts +2 -0
  762. package/dist/sync/area-ledger-migration.test.d.ts.map +1 -0
  763. package/dist/sync/area-ledger-migration.test.js +554 -0
  764. package/dist/sync/area-ledger-migration.test.js.map +1 -0
  765. package/dist/sync/area-ledger-recovery.bench.test.d.ts +2 -0
  766. package/dist/sync/area-ledger-recovery.bench.test.d.ts.map +1 -0
  767. package/dist/sync/area-ledger-recovery.bench.test.js +60 -0
  768. package/dist/sync/area-ledger-recovery.bench.test.js.map +1 -0
  769. package/dist/sync/area-ledger-writer-lock.bench.test.d.ts +2 -0
  770. package/dist/sync/area-ledger-writer-lock.bench.test.d.ts.map +1 -0
  771. package/dist/sync/area-ledger-writer-lock.bench.test.js +57 -0
  772. package/dist/sync/area-ledger-writer-lock.bench.test.js.map +1 -0
  773. package/dist/sync/area-ledger.test.d.ts +2 -0
  774. package/dist/sync/area-ledger.test.d.ts.map +1 -0
  775. package/dist/sync/area-ledger.test.js +1401 -0
  776. package/dist/sync/area-ledger.test.js.map +1 -0
  777. package/dist/sync/area-resolver.test.d.ts +2 -0
  778. package/dist/sync/area-resolver.test.d.ts.map +1 -0
  779. package/dist/sync/area-resolver.test.js +234 -0
  780. package/dist/sync/area-resolver.test.js.map +1 -0
  781. package/dist/sync/base-version-resolver.test.d.ts +2 -0
  782. package/dist/sync/base-version-resolver.test.d.ts.map +1 -0
  783. package/dist/sync/base-version-resolver.test.js +24 -0
  784. package/dist/sync/base-version-resolver.test.js.map +1 -0
  785. package/dist/sync/candidate-uploader.test.d.ts +2 -0
  786. package/dist/sync/candidate-uploader.test.d.ts.map +1 -0
  787. package/dist/sync/candidate-uploader.test.js +132 -0
  788. package/dist/sync/candidate-uploader.test.js.map +1 -0
  789. package/dist/sync/child-process-sync-worker-env.test.d.ts +2 -0
  790. package/dist/sync/child-process-sync-worker-env.test.d.ts.map +1 -0
  791. package/dist/sync/child-process-sync-worker-env.test.js +38 -0
  792. package/dist/sync/child-process-sync-worker-env.test.js.map +1 -0
  793. package/dist/sync/child-process-sync-worker-errors.test.d.ts +2 -0
  794. package/dist/sync/child-process-sync-worker-errors.test.d.ts.map +1 -0
  795. package/dist/sync/child-process-sync-worker-errors.test.js +121 -0
  796. package/dist/sync/child-process-sync-worker-errors.test.js.map +1 -0
  797. package/dist/sync/child-process-sync-worker.test.d.ts +2 -0
  798. package/dist/sync/child-process-sync-worker.test.d.ts.map +1 -0
  799. package/dist/sync/child-process-sync-worker.test.js +279 -0
  800. package/dist/sync/child-process-sync-worker.test.js.map +1 -0
  801. package/dist/sync/content-hash.test.d.ts +2 -0
  802. package/dist/sync/content-hash.test.d.ts.map +1 -0
  803. package/dist/sync/content-hash.test.js +16 -0
  804. package/dist/sync/content-hash.test.js.map +1 -0
  805. package/dist/sync/delta-client.test.d.ts +2 -0
  806. package/dist/sync/delta-client.test.d.ts.map +1 -0
  807. package/dist/sync/delta-client.test.js +97 -0
  808. package/dist/sync/delta-client.test.js.map +1 -0
  809. package/dist/sync/durable-apply.test.d.ts +2 -0
  810. package/dist/sync/durable-apply.test.d.ts.map +1 -0
  811. package/dist/sync/durable-apply.test.js +187 -0
  812. package/dist/sync/durable-apply.test.js.map +1 -0
  813. package/dist/sync/event-sync.test.d.ts +14 -0
  814. package/dist/sync/event-sync.test.d.ts.map +1 -0
  815. package/dist/sync/event-sync.test.js +1717 -0
  816. package/dist/sync/event-sync.test.js.map +1 -0
  817. package/dist/sync/feature-flags.test.d.ts +24 -0
  818. package/dist/sync/feature-flags.test.d.ts.map +1 -0
  819. package/dist/sync/feature-flags.test.js +594 -0
  820. package/dist/sync/feature-flags.test.js.map +1 -0
  821. package/dist/sync/fsync-compat.test.d.ts +2 -0
  822. package/dist/sync/fsync-compat.test.d.ts.map +1 -0
  823. package/dist/sync/fsync-compat.test.js +52 -0
  824. package/dist/sync/fsync-compat.test.js.map +1 -0
  825. package/dist/sync/full-pass-cap-governor.bench.test.d.ts +2 -0
  826. package/dist/sync/full-pass-cap-governor.bench.test.d.ts.map +1 -0
  827. package/dist/sync/full-pass-cap-governor.bench.test.js +179 -0
  828. package/dist/sync/full-pass-cap-governor.bench.test.js.map +1 -0
  829. package/dist/sync/full-pass-caps.test.d.ts +2 -0
  830. package/dist/sync/full-pass-caps.test.d.ts.map +1 -0
  831. package/dist/sync/full-pass-caps.test.js +550 -0
  832. package/dist/sync/full-pass-caps.test.js.map +1 -0
  833. package/dist/sync/idle-full-reconcile.test.d.ts +2 -0
  834. package/dist/sync/idle-full-reconcile.test.d.ts.map +1 -0
  835. package/dist/sync/idle-full-reconcile.test.js +62 -0
  836. package/dist/sync/idle-full-reconcile.test.js.map +1 -0
  837. package/dist/sync/inbound-event-admission.test.d.ts +2 -0
  838. package/dist/sync/inbound-event-admission.test.d.ts.map +1 -0
  839. package/dist/sync/inbound-event-admission.test.js +128 -0
  840. package/dist/sync/inbound-event-admission.test.js.map +1 -0
  841. package/dist/sync/journal-ledger-stream.test.d.ts +12 -0
  842. package/dist/sync/journal-ledger-stream.test.d.ts.map +1 -0
  843. package/dist/sync/journal-ledger-stream.test.js +134 -0
  844. package/dist/sync/journal-ledger-stream.test.js.map +1 -0
  845. package/dist/sync/lease-client.test.d.ts +2 -0
  846. package/dist/sync/lease-client.test.d.ts.map +1 -0
  847. package/dist/sync/lease-client.test.js +119 -0
  848. package/dist/sync/lease-client.test.js.map +1 -0
  849. package/dist/sync/logger.test.d.ts +19 -0
  850. package/dist/sync/logger.test.d.ts.map +1 -0
  851. package/dist/sync/logger.test.js +204 -0
  852. package/dist/sync/logger.test.js.map +1 -0
  853. package/dist/sync/metrics.test.d.ts +19 -0
  854. package/dist/sync/metrics.test.d.ts.map +1 -0
  855. package/dist/sync/metrics.test.js +357 -0
  856. package/dist/sync/metrics.test.js.map +1 -0
  857. package/dist/sync/multipart-uploader.test.d.ts +2 -0
  858. package/dist/sync/multipart-uploader.test.d.ts.map +1 -0
  859. package/dist/sync/multipart-uploader.test.js +141 -0
  860. package/dist/sync/multipart-uploader.test.js.map +1 -0
  861. package/dist/sync/mutation-client.test.d.ts +2 -0
  862. package/dist/sync/mutation-client.test.d.ts.map +1 -0
  863. package/dist/sync/mutation-client.test.js +100 -0
  864. package/dist/sync/mutation-client.test.js.map +1 -0
  865. package/dist/sync/mutation-session.test.d.ts +2 -0
  866. package/dist/sync/mutation-session.test.d.ts.map +1 -0
  867. package/dist/sync/mutation-session.test.js +190 -0
  868. package/dist/sync/mutation-session.test.js.map +1 -0
  869. package/dist/sync/parallel-sync-coordinator.test.d.ts +2 -0
  870. package/dist/sync/parallel-sync-coordinator.test.d.ts.map +1 -0
  871. package/dist/sync/parallel-sync-coordinator.test.js +564 -0
  872. package/dist/sync/parallel-sync-coordinator.test.js.map +1 -0
  873. package/dist/sync/path-leases.test.d.ts +2 -0
  874. package/dist/sync/path-leases.test.d.ts.map +1 -0
  875. package/dist/sync/path-leases.test.js +51 -0
  876. package/dist/sync/path-leases.test.js.map +1 -0
  877. package/dist/sync/per-area-maintenance.test.d.ts +2 -0
  878. package/dist/sync/per-area-maintenance.test.d.ts.map +1 -0
  879. package/dist/sync/per-area-maintenance.test.js +100 -0
  880. package/dist/sync/per-area-maintenance.test.js.map +1 -0
  881. package/dist/sync/push-event.test.d.ts +15 -0
  882. package/dist/sync/push-event.test.d.ts.map +1 -0
  883. package/dist/sync/push-event.test.js +282 -0
  884. package/dist/sync/push-event.test.js.map +1 -0
  885. package/dist/sync/push-receiver.test.d.ts +25 -0
  886. package/dist/sync/push-receiver.test.d.ts.map +1 -0
  887. package/dist/sync/push-receiver.test.js +2851 -0
  888. package/dist/sync/push-receiver.test.js.map +1 -0
  889. package/dist/sync/push-transport.test.d.ts +2 -0
  890. package/dist/sync/push-transport.test.d.ts.map +1 -0
  891. package/dist/sync/push-transport.test.js +70 -0
  892. package/dist/sync/push-transport.test.js.map +1 -0
  893. package/dist/sync/push-walk-matchers.bench.test.d.ts +2 -0
  894. package/dist/sync/push-walk-matchers.bench.test.d.ts.map +1 -0
  895. package/dist/sync/push-walk-matchers.bench.test.js +230 -0
  896. package/dist/sync/push-walk-matchers.bench.test.js.map +1 -0
  897. package/dist/sync/realtime-network-integration.test.d.ts +2 -0
  898. package/dist/sync/realtime-network-integration.test.d.ts.map +1 -0
  899. package/dist/sync/realtime-network-integration.test.js +83 -0
  900. package/dist/sync/realtime-network-integration.test.js.map +1 -0
  901. package/dist/sync/realtime-rollout.test.d.ts +2 -0
  902. package/dist/sync/realtime-rollout.test.d.ts.map +1 -0
  903. package/dist/sync/realtime-rollout.test.js +94 -0
  904. package/dist/sync/realtime-rollout.test.js.map +1 -0
  905. package/dist/sync/realtime-telemetry.test.d.ts +2 -0
  906. package/dist/sync/realtime-telemetry.test.d.ts.map +1 -0
  907. package/dist/sync/realtime-telemetry.test.js +300 -0
  908. package/dist/sync/realtime-telemetry.test.js.map +1 -0
  909. package/dist/sync/receiver-origin-config.test.d.ts +2 -0
  910. package/dist/sync/receiver-origin-config.test.d.ts.map +1 -0
  911. package/dist/sync/receiver-origin-config.test.js +39 -0
  912. package/dist/sync/receiver-origin-config.test.js.map +1 -0
  913. package/dist/sync/reconcile-cursor.test.d.ts +2 -0
  914. package/dist/sync/reconcile-cursor.test.d.ts.map +1 -0
  915. package/dist/sync/reconcile-cursor.test.js +139 -0
  916. package/dist/sync/reconcile-cursor.test.js.map +1 -0
  917. package/dist/sync/remote-file-spool.test.d.ts +2 -0
  918. package/dist/sync/remote-file-spool.test.d.ts.map +1 -0
  919. package/dist/sync/remote-file-spool.test.js +79 -0
  920. package/dist/sync/remote-file-spool.test.js.map +1 -0
  921. package/dist/sync/scope-inventory-client.test.d.ts +2 -0
  922. package/dist/sync/scope-inventory-client.test.d.ts.map +1 -0
  923. package/dist/sync/scope-inventory-client.test.js +110 -0
  924. package/dist/sync/scope-inventory-client.test.js.map +1 -0
  925. package/dist/sync/secret-path-policy.test.d.ts +2 -0
  926. package/dist/sync/secret-path-policy.test.d.ts.map +1 -0
  927. package/dist/sync/secret-path-policy.test.js +183 -0
  928. package/dist/sync/secret-path-policy.test.js.map +1 -0
  929. package/dist/sync/snapshot-client.test.d.ts +2 -0
  930. package/dist/sync/snapshot-client.test.d.ts.map +1 -0
  931. package/dist/sync/snapshot-client.test.js +169 -0
  932. package/dist/sync/snapshot-client.test.js.map +1 -0
  933. package/dist/sync/state-store.test.d.ts +2 -0
  934. package/dist/sync/state-store.test.d.ts.map +1 -0
  935. package/dist/sync/state-store.test.js +1556 -0
  936. package/dist/sync/state-store.test.js.map +1 -0
  937. package/dist/sync/sync-contract.test.d.ts +2 -0
  938. package/dist/sync/sync-contract.test.d.ts.map +1 -0
  939. package/dist/sync/sync-contract.test.js +141 -0
  940. package/dist/sync/sync-contract.test.js.map +1 -0
  941. package/dist/sync/targeted-pull-prefixes.test.d.ts +2 -0
  942. package/dist/sync/targeted-pull-prefixes.test.d.ts.map +1 -0
  943. package/dist/sync/targeted-pull-prefixes.test.js +33 -0
  944. package/dist/sync/targeted-pull-prefixes.test.js.map +1 -0
  945. package/dist/sync/targeted-upsert-exact-list.test.d.ts +2 -0
  946. package/dist/sync/targeted-upsert-exact-list.test.d.ts.map +1 -0
  947. package/dist/sync/targeted-upsert-exact-list.test.js +247 -0
  948. package/dist/sync/targeted-upsert-exact-list.test.js.map +1 -0
  949. package/dist/sync/unchanged-push-events.test.d.ts +2 -0
  950. package/dist/sync/unchanged-push-events.test.d.ts.map +1 -0
  951. package/dist/sync/unchanged-push-events.test.js +76 -0
  952. package/dist/sync/unchanged-push-events.test.js.map +1 -0
  953. package/dist/sync/uploader-finalization.test.d.ts +2 -0
  954. package/dist/sync/uploader-finalization.test.d.ts.map +1 -0
  955. package/dist/sync/uploader-finalization.test.js +107 -0
  956. package/dist/sync/uploader-finalization.test.js.map +1 -0
  957. package/dist/sync-core.test.d.ts +2 -0
  958. package/dist/sync-core.test.d.ts.map +1 -0
  959. package/dist/sync-core.test.js +189 -0
  960. package/dist/sync-core.test.js.map +1 -0
  961. package/dist/sync-progress.test.d.ts +2 -0
  962. package/dist/sync-progress.test.d.ts.map +1 -0
  963. package/dist/sync-progress.test.js +277 -0
  964. package/dist/sync-progress.test.js.map +1 -0
  965. package/dist/telemetry-events.test.d.ts +2 -0
  966. package/dist/telemetry-events.test.d.ts.map +1 -0
  967. package/dist/telemetry-events.test.js +113 -0
  968. package/dist/telemetry-events.test.js.map +1 -0
  969. package/dist/telemetry.test.d.ts +11 -0
  970. package/dist/telemetry.test.d.ts.map +1 -0
  971. package/dist/telemetry.test.js +1603 -0
  972. package/dist/telemetry.test.js.map +1 -0
  973. package/dist/vault-client.test.d.ts +7 -0
  974. package/dist/vault-client.test.d.ts.map +1 -0
  975. package/dist/vault-client.test.js +1334 -0
  976. package/dist/vault-client.test.js.map +1 -0
  977. package/dist/watch-coverage.test.d.ts +2 -0
  978. package/dist/watch-coverage.test.d.ts.map +1 -0
  979. package/dist/watch-coverage.test.js +56 -0
  980. package/dist/watch-coverage.test.js.map +1 -0
  981. package/dist/watch-owner-lease.test.d.ts +2 -0
  982. package/dist/watch-owner-lease.test.d.ts.map +1 -0
  983. package/dist/watch-owner-lease.test.js +364 -0
  984. package/dist/watch-owner-lease.test.js.map +1 -0
  985. package/dist/watch-parent.test.d.ts +2 -0
  986. package/dist/watch-parent.test.d.ts.map +1 -0
  987. package/dist/watch-parent.test.js +131 -0
  988. package/dist/watch-parent.test.js.map +1 -0
  989. package/dist/watch-roots.test.d.ts +18 -0
  990. package/dist/watch-roots.test.d.ts.map +1 -0
  991. package/dist/watch-roots.test.js +395 -0
  992. package/dist/watch-roots.test.js.map +1 -0
  993. package/dist/watcher-continuity-hot-path.test.d.ts +2 -0
  994. package/dist/watcher-continuity-hot-path.test.d.ts.map +1 -0
  995. package/dist/watcher-continuity-hot-path.test.js +40 -0
  996. package/dist/watcher-continuity-hot-path.test.js.map +1 -0
  997. package/dist/watcher-event-gate.test.d.ts +16 -0
  998. package/dist/watcher-event-gate.test.d.ts.map +1 -0
  999. package/dist/watcher-event-gate.test.js +191 -0
  1000. package/dist/watcher-event-gate.test.js.map +1 -0
  1001. package/dist/watcher-replan-sweep.test.d.ts +2 -0
  1002. package/dist/watcher-replan-sweep.test.d.ts.map +1 -0
  1003. package/dist/watcher-replan-sweep.test.js +260 -0
  1004. package/dist/watcher-replan-sweep.test.js.map +1 -0
  1005. package/dist/watcher-stdout.test.d.ts +2 -0
  1006. package/dist/watcher-stdout.test.d.ts.map +1 -0
  1007. package/dist/watcher-stdout.test.js +86 -0
  1008. package/dist/watcher-stdout.test.js.map +1 -0
  1009. package/dist/watcher.test.d.ts +2 -0
  1010. package/dist/watcher.test.d.ts.map +1 -0
  1011. package/dist/watcher.test.js +4329 -0
  1012. package/dist/watcher.test.js.map +1 -0
  1013. package/dist/watcher.warmup-cancel.test.d.ts +2 -0
  1014. package/dist/watcher.warmup-cancel.test.d.ts.map +1 -0
  1015. package/dist/watcher.warmup-cancel.test.js +59 -0
  1016. package/dist/watcher.warmup-cancel.test.js.map +1 -0
  1017. package/dist/watcher.warmup-responsive.test.d.ts +2 -0
  1018. package/dist/watcher.warmup-responsive.test.d.ts.map +1 -0
  1019. package/dist/watcher.warmup-responsive.test.js +62 -0
  1020. package/dist/watcher.warmup-responsive.test.js.map +1 -0
  1021. package/package.json +2 -2
@@ -0,0 +1,2091 @@
1
+ /**
2
+ * Unit tests for s3.uploadFile.
3
+ *
4
+ * Regression coverage for the bug where hq-console vault UI's "CREATED BY"
5
+ * column rendered `—` for every file: every PutObject went out without
6
+ * `Metadata`, so the listing's HEAD fan-out had nothing to attribute.
7
+ */
8
+ import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
9
+ import * as fs from "fs";
10
+ import * as os from "os";
11
+ import * as path from "path";
12
+ import * as crypto from "crypto";
13
+ // Capture every command sent to the S3Client across the test suite. Cleared
14
+ // in beforeEach so per-test assertions don't leak from neighbours.
15
+ const sentCommands = [];
16
+ // Per-test override for the ListObjectsV2Command response. Tests of
17
+ // `listRemoteFiles` push the Contents shape they want returned; the default
18
+ // is an empty bucket. Reset in beforeEach so cross-test leakage is impossible.
19
+ let nextListObjectsResponse = { Contents: [] };
20
+ // Per-test override for the GetObjectCommand response. The default fake
21
+ // doesn't model GET (downloadFile previously had no s3.test.ts coverage);
22
+ // downloadFile tests push the Body + Metadata shape they want returned.
23
+ // HEAD answer for the next HeadObjectCommand. Default: object exists with no
24
+ // metadata and no storage class (STANDARD). Tests override per case.
25
+ let nextHeadObjectResponse = { Metadata: {} };
26
+ let nextGetObjectResponse = {
27
+ Body: (async function* () {
28
+ yield new Uint8Array();
29
+ })(),
30
+ Metadata: {},
31
+ };
32
+ vi.mock("@aws-sdk/client-s3", () => {
33
+ class FakeS3Client {
34
+ async send(command) {
35
+ sentCommands.push({ name: command.constructor.name, input: command.input });
36
+ if (command.constructor.name === "HeadObjectCommand") {
37
+ // Default: object exists with no metadata. Tests that need a
38
+ // metadata-bearing or archived HEAD set nextHeadObjectResponse.
39
+ return nextHeadObjectResponse;
40
+ }
41
+ if (command.constructor.name === "PutObjectCommand") {
42
+ return { ETag: '"fake-etag"' };
43
+ }
44
+ if (command.constructor.name === "ListObjectsV2Command") {
45
+ return nextListObjectsResponse;
46
+ }
47
+ if (command.constructor.name === "GetObjectCommand") {
48
+ return nextGetObjectResponse;
49
+ }
50
+ return {};
51
+ }
52
+ }
53
+ // Each command class records constructor.name + input so the spy above can
54
+ // tell them apart. Mirrors the real SDK's command shape closely enough for
55
+ // the assertion surface the s3.ts code touches.
56
+ class PutObjectCommand {
57
+ input;
58
+ constructor(input) {
59
+ this.input = input;
60
+ }
61
+ }
62
+ class GetObjectCommand {
63
+ input;
64
+ constructor(input) {
65
+ this.input = input;
66
+ }
67
+ }
68
+ class HeadObjectCommand {
69
+ input;
70
+ constructor(input) {
71
+ this.input = input;
72
+ }
73
+ }
74
+ class ListObjectsV2Command {
75
+ input;
76
+ constructor(input) {
77
+ this.input = input;
78
+ }
79
+ }
80
+ class DeleteObjectCommand {
81
+ input;
82
+ constructor(input) {
83
+ this.input = input;
84
+ }
85
+ }
86
+ return {
87
+ S3Client: FakeS3Client,
88
+ PutObjectCommand,
89
+ GetObjectCommand,
90
+ HeadObjectCommand,
91
+ ListObjectsV2Command,
92
+ DeleteObjectCommand,
93
+ };
94
+ });
95
+ import { uploadFile, uploadSymlink, toPosixKey, primeUploads, downloadFile, listRemoteFiles, SYMLINK_BODY_PREFIX, SYMLINK_MARKER_META_VALUE, encodeSymlinkMetadataValue, decodeSymlinkMetadataValue, FILE_MTIME_META_KEY, FILE_BTIME_META_KEY, setUploadContentHash, classifyVaultKey, validateVaultUploadKey, createStagedSymlink, replaceStagedPath, sweepStaleStagedFiles, DanglingSymlinkParentError, headRemoteFile } from "./s3.js";
96
+ import { setObjectIOFactory, presignObjectIOFactory, } from "./object-io.js";
97
+ function makeCtx() {
98
+ return {
99
+ uid: "cmp_TEST",
100
+ slug: "acme",
101
+ bucketName: "hq-vault-acme-123",
102
+ region: "us-east-1",
103
+ credentials: {
104
+ accessKeyId: "ASIA_TEST",
105
+ secretAccessKey: "secret",
106
+ sessionToken: "session",
107
+ },
108
+ expiresAt: new Date(Date.now() + 15 * 60 * 1000).toISOString(),
109
+ };
110
+ }
111
+ describe("backslash key normalization (Windows client → POSIX S3 key)", () => {
112
+ // Regression for the Ridges vault bug: a non-POSIX (Windows) HQ Sync client
113
+ // built object keys from path.relative(), whose separator is "\\". Stored
114
+ // verbatim, `knowledge\books-eoi.md` had no "/", so the vault listing (which
115
+ // splits keys on "/") rendered it flat at the root as one oddly-named file.
116
+ let tmpFile;
117
+ beforeEach(() => {
118
+ sentCommands.length = 0;
119
+ tmpFile = path.join(os.tmpdir(), `s3-backslash-test-${Date.now()}-${Math.random()}.md`);
120
+ fs.writeFileSync(tmpFile, "hello");
121
+ });
122
+ it("toPosixKey converts every backslash to a forward slash", () => {
123
+ expect(toPosixKey("knowledge\\books-eoi.md")).toBe("knowledge/books-eoi.md");
124
+ expect(toPosixKey("data\\sub\\boots-accounts.json")).toBe("data/sub/boots-accounts.json");
125
+ });
126
+ it("toPosixKey leaves an already-POSIX key unchanged (idempotent)", () => {
127
+ expect(toPosixKey("knowledge/books-eoi.md")).toBe("knowledge/books-eoi.md");
128
+ expect(toPosixKey("flat.md")).toBe("flat.md");
129
+ });
130
+ it("uploadFile stores a POSIX key when given a Windows-style backslash path", async () => {
131
+ await uploadFile(makeCtx(), tmpFile, "knowledge\\books-eoi.md");
132
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
133
+ expect(put).toBeDefined();
134
+ expect(put.input.Key).toBe("knowledge/books-eoi.md");
135
+ });
136
+ it("uploadSymlink stores a POSIX key when given a Windows-style backslash path", async () => {
137
+ await uploadSymlink(makeCtx(), "../knowledge-ridges/target.md", "data\\boots-accounts.json");
138
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
139
+ expect(put).toBeDefined();
140
+ expect(put.input.Key).toBe("data/boots-accounts.json");
141
+ });
142
+ });
143
+ describe("backslash key normalization on the PRESIGNED (GA) transport", () => {
144
+ // The tests above assert normalization on the S3-SDK transport (sentCommands
145
+ // capture SDK PutObjectCommands). As of 6.5.0 the presigned-URL transport is
146
+ // GA for every company vault (cmp_*) — that's the path a real Windows client
147
+ // like Ridge's now takes. These lock the SAME write-side invariant on that
148
+ // transport: a backslash key is canonicalized to POSIX before the server is
149
+ // ever asked to presign it, so a non-POSIX vault key can never be minted.
150
+ let tmpFile;
151
+ let presignCalls;
152
+ function presignKeysFor(op) {
153
+ return presignCalls
154
+ .filter((c) => c.op === op)
155
+ .flatMap((c) => c.keys.map((k) => k.key ?? ""));
156
+ }
157
+ beforeEach(() => {
158
+ tmpFile = path.join(os.tmpdir(), `s3-presign-backslash-${Date.now()}-${Math.random()}.md`);
159
+ fs.writeFileSync(tmpFile, "hello");
160
+ presignCalls = [];
161
+ const vault = {
162
+ // Echo each requested key back as a usable URL so putObject's PUT
163
+ // resolves; record the op + keys so we can assert what was signed.
164
+ presign: async (input) => {
165
+ presignCalls.push({ op: input.op, keys: input.keys });
166
+ const results = input.keys.map((k) => ({
167
+ key: k.key,
168
+ op: input.op ?? "put",
169
+ url: `https://s3.test/${k.key}`,
170
+ }));
171
+ return { results, expiresAt: "2099-01-01T00:00:00.000Z" };
172
+ },
173
+ listFiles: async () => ({ objects: [], cursor: null, truncated: false }),
174
+ };
175
+ setObjectIOFactory(presignObjectIOFactory(vault));
176
+ // putObject moves bytes over the presigned URL via global fetch.
177
+ vi.stubGlobal("fetch", vi.fn(async () => new Response(null, { status: 200, headers: { etag: '"e"' } })));
178
+ });
179
+ afterEach(() => {
180
+ setObjectIOFactory(null);
181
+ vi.unstubAllGlobals();
182
+ });
183
+ it("uploadFile presigns + PUTs a POSIX key for a Windows-style backslash path", async () => {
184
+ await uploadFile(makeCtx(), tmpFile, "knowledge\\books-eoi.md");
185
+ expect(presignKeysFor("put")).toContain("knowledge/books-eoi.md");
186
+ // The malformed backslash key is never presigned (so never PUT).
187
+ expect(presignKeysFor("put")).not.toContain("knowledge\\books-eoi.md");
188
+ });
189
+ it("uploadSymlink presigns a POSIX key for a Windows-style backslash path", async () => {
190
+ await uploadSymlink(makeCtx(), "../target.md", "data\\boots-accounts.json");
191
+ expect(presignKeysFor("put")).toContain("data/boots-accounts.json");
192
+ expect(presignKeysFor("put")).not.toContain("data\\boots-accounts.json");
193
+ });
194
+ it("primeUploads canonicalizes keys so the primed PUT URL matches the upload lookup", async () => {
195
+ // Prime then upload the SAME Windows-origin key. Both must key the cache
196
+ // under the POSIX form: prime signs the POSIX PUT URL, and uploadFile's
197
+ // hasPrimedPut(toPosixKey(...)) reuses it instead of re-presigning — proving
198
+ // the primed fast-path can't strand a backslash key (and can't store one).
199
+ await primeUploads(makeCtx(), [
200
+ { key: "knowledge\\books-eoi.md", localPath: tmpFile, isSymlink: false },
201
+ ]);
202
+ // prime("get") + prime("put") both went out under the POSIX key only.
203
+ expect(presignKeysFor("get")).toEqual(["knowledge/books-eoi.md"]);
204
+ expect(presignKeysFor("put")).toEqual(["knowledge/books-eoi.md"]);
205
+ const putCountAfterPrime = presignKeysFor("put").length;
206
+ await uploadFile(makeCtx(), tmpFile, "knowledge\\books-eoi.md");
207
+ // No NEW put presign: uploadFile reused the primed POSIX URL (cache hit).
208
+ expect(presignKeysFor("put").length).toBe(putCountAfterPrime);
209
+ });
210
+ it("primeUploads signs hq-entity-last-updated for an ontology entity file", async () => {
211
+ fs.writeFileSync(tmpFile, "---\nid: a\nlast_updated: 2026-09-26T10:00:00.000Z\n---\n");
212
+ await primeUploads(makeCtx(), [
213
+ { key: "ontology/entities/person/a.md", localPath: tmpFile, isSymlink: false },
214
+ { key: "knowledge/a.md", localPath: tmpFile, isSymlink: false },
215
+ ]);
216
+ const signed = presignCalls
217
+ .filter((c) => c.op === "put")
218
+ .flatMap((c) => c.keys);
219
+ const entity = signed.find((k) => k.key === "ontology/entities/person/a.md");
220
+ const other = signed.find((k) => k.key === "knowledge/a.md");
221
+ expect(entity?.metadata?.["hq-entity-last-updated"]).toBe("2026-09-26T10:00:00.000Z");
222
+ expect(other?.metadata?.["hq-entity-last-updated"]).toBeUndefined();
223
+ });
224
+ it("uploadFile refuses an entity body that no longer matches the planned hash", async () => {
225
+ const planned = "---\nid: a\nlast_updated: 2026-09-26T10:00:00.000Z\n---\n";
226
+ fs.writeFileSync(tmpFile, planned);
227
+ const plannedHash = crypto.createHash("sha256").update(planned).digest("hex");
228
+ setUploadContentHash(tmpFile, plannedHash);
229
+ fs.writeFileSync(tmpFile, planned + "edited after the check\n");
230
+ await expect(uploadFile(makeCtx(), tmpFile, "ontology/entities/person/a.md")).rejects.toThrow("changed after this sync pass checked it");
231
+ expect(presignKeysFor("put")).not.toContain("ontology/entities/person/a.md");
232
+ setUploadContentHash(tmpFile, crypto.createHash("sha256").update(fs.readFileSync(tmpFile)).digest("hex"));
233
+ await uploadFile(makeCtx(), tmpFile, "ontology/entities/person/a.md");
234
+ expect(presignKeysFor("put")).toContain("ontology/entities/person/a.md");
235
+ });
236
+ it("does not replay a primed PUT URL after the planner hash changed", async () => {
237
+ const primedHash = "a".repeat(64);
238
+ const currentHash = "b".repeat(64);
239
+ await primeUploads(makeCtx(), [
240
+ {
241
+ key: "lineage.md",
242
+ localPath: tmpFile,
243
+ isSymlink: false,
244
+ contentHash: primedHash,
245
+ },
246
+ ]);
247
+ const putCountAfterPrime = presignKeysFor("put").length;
248
+ setUploadContentHash(tmpFile, currentHash);
249
+ await uploadFile(makeCtx(), tmpFile, "lineage.md");
250
+ expect(presignKeysFor("put").length).toBe(putCountAfterPrime + 1);
251
+ });
252
+ });
253
+ describe("uploadFile", () => {
254
+ let tmpFile;
255
+ beforeEach(() => {
256
+ sentCommands.length = 0;
257
+ tmpFile = path.join(os.tmpdir(), `s3-upload-test-${Date.now()}-${Math.random()}.md`);
258
+ fs.writeFileSync(tmpFile, "hello");
259
+ });
260
+ it("uploads a supplied byte buffer without rereading a changed source path", async () => {
261
+ const uploadedBytes = Buffer.from("the bytes captured before the scheduler handoff\r\n");
262
+ fs.writeFileSync(tmpFile, "later bytes from the changed path\n");
263
+ await uploadFile(makeCtx(), tmpFile, "captured.md", undefined, undefined, undefined, uploadedBytes);
264
+ const put = sentCommands.find((command) => command.name === "PutObjectCommand");
265
+ expect(put?.input.Body).toEqual(uploadedBytes);
266
+ });
267
+ it("omits author Metadata fields when no author is provided (back-compat)", async () => {
268
+ // Pre-Bug-#5: this test asserted Metadata was undefined entirely. Now
269
+ // \`hq-mode\` is stamped on every upload to preserve source-side
270
+ // permissions, so the assertion is narrower: author fields stay absent
271
+ // when no author is passed, but \`hq-mode\` is present.
272
+ await uploadFile(makeCtx(), tmpFile, "attribution-test.md");
273
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
274
+ expect(put).toBeDefined();
275
+ const meta = put.input.Metadata;
276
+ expect(meta?.["created-by"]).toBeUndefined();
277
+ expect(meta?.["created-by-sub"]).toBeUndefined();
278
+ expect(meta?.["created-at"]).toBeUndefined();
279
+ // portableModeStamp returns undefined on win32 (file-mode-portability.ts:34,
280
+ // called from s3.ts:1184). POSIX still stamps a 3-digit octal mode.
281
+ if (process.platform === "win32") {
282
+ expect(meta?.["hq-mode"]).toBeUndefined();
283
+ }
284
+ else {
285
+ expect(meta?.["hq-mode"]).toMatch(/^[0-7]{3}$/);
286
+ }
287
+ });
288
+ it("stamps created-by + created-by-sub + created-at when author is provided", async () => {
289
+ await uploadFile(makeCtx(), tmpFile, "attribution-test.md", {
290
+ userSub: "abc-123",
291
+ email: "alice@example.com",
292
+ });
293
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
294
+ expect(put).toBeDefined();
295
+ const meta = put.input.Metadata;
296
+ expect(meta["created-by"]).toBe("alice@example.com");
297
+ expect(meta["created-by-sub"]).toBe("abc-123");
298
+ // ISO-8601 with 'Z' suffix.
299
+ expect(meta["created-at"]).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/);
300
+ });
301
+ it("preserves the existing created-at on re-upload (NEW-pill ageing window)", async () => {
302
+ // First upload happened a week ago; second run must keep that timestamp
303
+ // so the hq-console "NEW" pill doesn't reset on every sync tick.
304
+ // Override the FakeS3Client's HeadObject to return the legacy timestamp
305
+ // for this one test. The mock factory returns a fresh object per send
306
+ // invocation so we patch at the class level via a one-shot wrapper.
307
+ const { HeadObjectCommand } = await import("@aws-sdk/client-s3");
308
+ const originalHead = HeadObjectCommand.prototype;
309
+ // Easier: drop in a sentry that recognizes the head command and answers.
310
+ // We do this by monkey-patching sendCommands handler — but actually our
311
+ // FakeS3Client always returns Metadata: {} for HEAD. Switch strategy:
312
+ // mock the S3Client.send for this test only.
313
+ void originalHead;
314
+ // Use vi.spyOn on the prototype is painful; instead push a marker file
315
+ // that the next test re-reads. Since the FakeS3Client is in a module
316
+ // singleton, the cleanest path is: temporarily replace the global handler.
317
+ // For this test we accept slight indirection — push a head response stub
318
+ // by mutating the captured queue's expectations via beforeEach below.
319
+ // Simpler approach: directly assert the new path covers the no-existing
320
+ // case (createdAt = now) and rely on integration coverage to verify the
321
+ // preserve path. The assertion below uses a fresh upload (no priors).
322
+ await uploadFile(makeCtx(), tmpFile, "fresh.md", {
323
+ userSub: "abc-123",
324
+ email: "alice@example.com",
325
+ });
326
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
327
+ expect(put).toBeDefined();
328
+ const meta = put.input.Metadata;
329
+ // The default FakeS3Client.HEAD returns Metadata: {} (no created-at),
330
+ // so the implementation must fall through to "now" — assert the
331
+ // timestamp is within the last minute. The "preserve" branch is
332
+ // exercised by share-sync.integration.test.ts where a real round-trip
333
+ // catches drift.
334
+ const stamped = new Date(meta["created-at"]).getTime();
335
+ expect(Date.now() - stamped).toBeLessThan(60 * 1000);
336
+ });
337
+ it("stamps source file mode as hq-mode metadata (Bug #5 — preserve permissions)", async () => {
338
+ // Bug #5 (broader than originally reported): every uploaded file's mode
339
+ // collapsed to the receiver's umask default (0644 on the verification
340
+ // hosts). 0755 scripts arrived non-executable, breaking every shell-tool
341
+ // workflow. Fix: stamp the source-side \`mode & 0o777\` into S3 user
342
+ // metadata as \`hq-mode\` (octal string), then chmod on download.
343
+ fs.chmodSync(tmpFile, 0o755);
344
+ await uploadFile(makeCtx(), tmpFile, "exec.sh");
345
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
346
+ expect(put).toBeDefined();
347
+ const meta = put.input.Metadata;
348
+ // portableModeStamp omits hq-mode on win32 (file-mode-portability.ts:34).
349
+ if (process.platform === "win32") {
350
+ expect(meta?.["hq-mode"]).toBeUndefined();
351
+ }
352
+ else {
353
+ expect(meta?.["hq-mode"]).toBe("755");
354
+ }
355
+ });
356
+ it("stamps various modes correctly (0600, 0640, 0700, 0750)", async () => {
357
+ // Verification report V5: all four modes collapsed to 0644 receiver-side
358
+ // because the upload carried no mode at all. Pin each mode round-trips
359
+ // through the metadata header in canonical octal-string form (no leading
360
+ // zero — the parser uses parseInt(..., 8)).
361
+ for (const mode of [0o600, 0o640, 0o700, 0o750]) {
362
+ sentCommands.length = 0;
363
+ fs.chmodSync(tmpFile, mode);
364
+ await uploadFile(makeCtx(), tmpFile, "f.bin");
365
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
366
+ const meta = put.input.Metadata;
367
+ // Same win32 omission as the 0755 stamp (file-mode-portability.ts:34).
368
+ if (process.platform === "win32") {
369
+ expect(meta?.["hq-mode"]).toBeUndefined();
370
+ }
371
+ else {
372
+ expect(meta?.["hq-mode"]).toBe(mode.toString(8));
373
+ }
374
+ }
375
+ });
376
+ it("stamps source file mtimeMs as hq-mtime metadata (5.37.0 — preserve mtime)", async () => {
377
+ // Symmetric to Bug #5's mode preservation. A file's modification time
378
+ // should follow it across machines instead of resetting to "the time of
379
+ // sync." Push stamps `hq-mtime` = integer-ms epoch string; pull applies
380
+ // it via utimesSync. See FILE_MTIME_META_KEY doc.
381
+ const knownMs = 1_700_000_000_000; // 2023-11-14T22:13:20Z, comfortably finite
382
+ const knownDate = new Date(knownMs);
383
+ fs.utimesSync(tmpFile, knownDate, knownDate);
384
+ await uploadFile(makeCtx(), tmpFile, "stamped.md");
385
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
386
+ expect(put).toBeDefined();
387
+ const meta = put.input.Metadata;
388
+ expect(meta?.[FILE_MTIME_META_KEY]).toBe(String(knownMs));
389
+ });
390
+ it("stamps an ontology entity's frontmatter last_updated as hq-entity-last-updated", async () => {
391
+ fs.writeFileSync(tmpFile, "---\nid: a\ntype: person\nlast_updated: 2026-09-26T10:00:00.000Z\n---\nbody\n");
392
+ await uploadFile(makeCtx(), tmpFile, "ontology/entities/person/a.md");
393
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
394
+ const meta = put.input.Metadata;
395
+ expect(meta?.["hq-entity-last-updated"]).toBe("2026-09-26T10:00:00.000Z");
396
+ });
397
+ it("does not stamp hq-entity-last-updated on other keys or on an entity without a date", async () => {
398
+ fs.writeFileSync(tmpFile, "---\nlast_updated: 2026-09-26T10:00:00.000Z\n---\n");
399
+ await uploadFile(makeCtx(), tmpFile, "knowledge/a.md");
400
+ fs.writeFileSync(tmpFile, "---\nid: a\n---\n");
401
+ await uploadFile(makeCtx(), tmpFile, "ontology/entities/person/a.md");
402
+ const puts = sentCommands.filter((c) => c.name === "PutObjectCommand");
403
+ expect(puts).toHaveLength(2);
404
+ for (const put of puts) {
405
+ expect(put.input.Metadata["hq-entity-last-updated"]).toBeUndefined();
406
+ }
407
+ });
408
+ it("stamps the planner's existing SHA-256 as hq-content-sha256", async () => {
409
+ const contentHash = crypto.createHash("sha256").update("hello").digest("hex");
410
+ // The sync planner already owns this digest. Passing it through this
411
+ // boundary must not make uploadFile read or hash the file again.
412
+ setUploadContentHash(tmpFile, contentHash);
413
+ await uploadFile(makeCtx(), tmpFile, "lineage.md");
414
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
415
+ const meta = put.input.Metadata;
416
+ expect(meta?.["hq-content-sha256"]).toBe(contentHash);
417
+ });
418
+ it("stamps hq-btime only when birthtime is supported AND distinct from mtime", async () => {
419
+ // Many filesystems (Linux/ext4 historically, tmpfs, some FUSE mounts)
420
+ // return birthtimeMs === 0 or birthtimeMs === mtimeMs. Stamping in
421
+ // those cases would be pure noise; the upload side filters it out.
422
+ // We don't control the test filesystem's birthtime semantics, so the
423
+ // assertion is shape-only: IF hq-btime is present, it's a numeric
424
+ // string AND it's distinct from hq-mtime.
425
+ await uploadFile(makeCtx(), tmpFile, "btime.md");
426
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
427
+ const meta = put.input.Metadata;
428
+ const btime = meta?.[FILE_BTIME_META_KEY];
429
+ const mtime = meta?.[FILE_MTIME_META_KEY];
430
+ if (typeof btime === "string") {
431
+ expect(btime).toMatch(/^[0-9]{1,16}$/);
432
+ expect(btime).not.toBe(mtime);
433
+ }
434
+ });
435
+ it("does NOT stamp hq-mtime / hq-btime for symlinks (uploadFile branch)", async () => {
436
+ // uploadFile is the regular-file path; uploadSymlink is the symlink
437
+ // path. uploadFile's lstat.isSymbolicLink() guard skips ALL three of
438
+ // mode + mtime + btime stamping for symlinks, mirroring the existing
439
+ // hq-mode policy: symlink times are OS-controlled and fs.utimesSync
440
+ // would follow the link and mutate the target. The link is set up
441
+ // pointing at a real target so fs.readFileSync (which follows links)
442
+ // doesn't ENOENT before the metadata stamping branch even runs.
443
+ const targetPath = path.join(os.tmpdir(), `s3-link-target-${Date.now()}-${Math.random()}.txt`);
444
+ fs.writeFileSync(targetPath, "real-bytes");
445
+ const linkPath = path.join(os.tmpdir(), `s3-link-test-${Date.now()}-${Math.random()}.lnk`);
446
+ fs.symlinkSync(targetPath, linkPath);
447
+ await uploadFile(makeCtx(), linkPath, "link.md");
448
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
449
+ const meta = put.input.Metadata;
450
+ expect(meta?.[FILE_MTIME_META_KEY]).toBeUndefined();
451
+ expect(meta?.[FILE_BTIME_META_KEY]).toBeUndefined();
452
+ fs.unlinkSync(linkPath);
453
+ fs.unlinkSync(targetPath);
454
+ });
455
+ it("elides non-ASCII or empty author fields rather than throwing", async () => {
456
+ // S3 user-defined metadata must be ASCII-only and total ≤ 2KB. Partial
457
+ // attribution beats hard failure — values that fail the printable check
458
+ // are dropped silently.
459
+ await uploadFile(makeCtx(), tmpFile, "partial.md", {
460
+ userSub: " ",
461
+ email: "user@example.com",
462
+ });
463
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
464
+ const meta = put.input.Metadata;
465
+ expect(meta["created-by"]).toBe("user@example.com");
466
+ expect(meta["created-by-sub"]).toBeUndefined();
467
+ });
468
+ });
469
+ describe("listRemoteFiles", () => {
470
+ beforeEach(() => {
471
+ sentCommands.length = 0;
472
+ nextListObjectsResponse = { Contents: [] };
473
+ });
474
+ // Regression: pre-fix, `if (!obj.Key || !obj.Size) continue;` skipped every
475
+ // 0-byte object on the listing. The user's personal vault stored
476
+ // `projects/.gitkeep` (a 0-byte placeholder) and the sync pull plan never
477
+ // saw it — the file existed on S3 but was invisible to the runner, so the
478
+ // box never created `projects/` on first pull. The fix narrows the guard
479
+ // to `if (!obj.Key) continue;` so Size === 0 passes through with its real
480
+ // value (handled `?? 0` to keep TS Size?: number happy).
481
+ it("includes 0-byte objects in the result (no implicit skip-on-empty)", async () => {
482
+ nextListObjectsResponse = {
483
+ Contents: [
484
+ { Key: "projects/.gitkeep", Size: 0, LastModified: new Date(), ETag: '"d41d8cd98f00b204e9800998ecf8427e"' },
485
+ { Key: "AGENTS.md", Size: 100, LastModified: new Date(), ETag: '"e1"' },
486
+ ],
487
+ };
488
+ const files = await listRemoteFiles(makeCtx());
489
+ expect(files).toHaveLength(2);
490
+ const gitkeep = files.find((f) => f.key === "projects/.gitkeep");
491
+ expect(gitkeep).toBeDefined();
492
+ expect(gitkeep.size).toBe(0);
493
+ expect(gitkeep.storageClass).toBe("STANDARD");
494
+ });
495
+ it("threads S3 storage class from LIST without an extra metadata request", async () => {
496
+ nextListObjectsResponse = {
497
+ Contents: [
498
+ {
499
+ Key: "workspace/.session-logs/codex/rollout.jsonl",
500
+ Size: 42,
501
+ LastModified: new Date(),
502
+ ETag: '"deep"',
503
+ StorageClass: "DEEP_ARCHIVE",
504
+ },
505
+ ],
506
+ };
507
+ const files = await listRemoteFiles(makeCtx());
508
+ expect(files).toEqual([
509
+ expect.objectContaining({
510
+ key: "workspace/.session-logs/codex/rollout.jsonl",
511
+ storageClass: "DEEP_ARCHIVE",
512
+ }),
513
+ ]);
514
+ expect(sentCommands.filter((command) => command.name === "HeadObjectCommand")).toHaveLength(0);
515
+ });
516
+ it("still skips Contents entries with no Key (defensive against malformed responses)", async () => {
517
+ nextListObjectsResponse = {
518
+ Contents: [
519
+ { Size: 100, LastModified: new Date(), ETag: '"e1"' }, // no Key
520
+ { Key: "real.md", Size: 100, LastModified: new Date(), ETag: '"e2"' },
521
+ ],
522
+ };
523
+ const files = await listRemoteFiles(makeCtx());
524
+ expect(files).toHaveLength(1);
525
+ expect(files[0].key).toBe("real.md");
526
+ });
527
+ // Regression: pre-fix, the 0-byte-guard relaxation (`if (!obj.Key) continue;`
528
+ // replacing `if (!obj.Key || !obj.Size) continue;`) was correct for
529
+ // legitimate placeholder files like `.gitkeep` but accidentally also let
530
+ // S3 directory-marker objects (0-byte, key ends in `/`) through to the
531
+ // planner. Two downstream sites blow up on those:
532
+ // 1. pull planner (cli/sync.ts `computePullPlan`): for any marker whose
533
+ // `path.join(root, key)` resolves to an existing local directory,
534
+ // `localExists=true` → `hashFile(localPath)` → `readFileSync` on dir
535
+ // → EISDIR "read". The runner reported this for `personal:(company)`.
536
+ // 2. download path (s3.ts `downloadFile`): for any marker whose local
537
+ // path doesn't exist, the planner classifies it `download`;
538
+ // `mkdirSync(path.dirname(localPath), recursive)` strips the trailing
539
+ // slash and creates the leaf as a directory, then `writeFileSync`
540
+ // on the trailing-slash path → EISDIR "open". The runner reported
541
+ // this for `indigo:lambda/`.
542
+ // The fix drops the *definitional* marker shape (trailing-slash AND
543
+ // size 0) at this site so neither path ever sees them. Real 0-byte
544
+ // placeholders (`.gitkeep`) never end in `/` and continue to flow
545
+ // through — covered by the test immediately above.
546
+ it("drops S3 directory-marker keys (trailing '/', size 0) from list results", async () => {
547
+ nextListObjectsResponse = {
548
+ Contents: [
549
+ { Key: "real.md", Size: 42, LastModified: new Date(), ETag: '"e1"' },
550
+ { Key: "projects/.gitkeep", Size: 0, LastModified: new Date(), ETag: '"e2"' },
551
+ { Key: "lambda/", Size: 0, LastModified: new Date(), ETag: '"e3"' },
552
+ { Key: "core/", Size: 0, LastModified: new Date(), ETag: '"e4"' },
553
+ { Key: "deeply/nested/marker/", Size: 0, LastModified: new Date(), ETag: '"e5"' },
554
+ ],
555
+ };
556
+ const files = await listRemoteFiles(makeCtx());
557
+ // Real files (including the 0-byte .gitkeep placeholder) pass through;
558
+ // every 0-byte trailing-slash marker is dropped.
559
+ expect(files.map((f) => f.key).sort()).toEqual([
560
+ "projects/.gitkeep",
561
+ "real.md",
562
+ ]);
563
+ });
564
+ // Codex P2 follow-up: the marker filter must be definitionally
565
+ // constrained to size-0 trailing-slash keys. A hypothetical non-empty
566
+ // object whose key ends in `/` (no hq-cloud code path creates one,
567
+ // but `ListObjectsV2` returns whatever lives in the bucket) must
568
+ // NOT be silently hidden — that would mask real bucket state from
569
+ // the operator. Such an object will still surface EISDIR "open" at
570
+ // downloadFile when the local path is materialized, which is the
571
+ // signal needed to reconcile.
572
+ it("does NOT drop non-empty trailing-slash keys (preserves operator visibility)", async () => {
573
+ nextListObjectsResponse = {
574
+ Contents: [
575
+ { Key: "real.md", Size: 42, LastModified: new Date(), ETag: '"e1"' },
576
+ // 0-byte marker — filtered.
577
+ { Key: "marker/", Size: 0, LastModified: new Date(), ETag: '"e2"' },
578
+ // Non-zero, trailing slash — pathological but unfiltered so it
579
+ // stays visible. (Cannot be materialized locally; downloadFile
580
+ // will raise an explicit error pointing at this exact key.)
581
+ { Key: "exports/report/", Size: 1024, LastModified: new Date(), ETag: '"e3"' },
582
+ ],
583
+ };
584
+ const files = await listRemoteFiles(makeCtx());
585
+ expect(files.map((f) => f.key).sort()).toEqual([
586
+ "exports/report/",
587
+ "real.md",
588
+ ]);
589
+ // Spot-check that the non-empty marker carried its real size.
590
+ expect(files.find((f) => f.key === "exports/report/").size).toBe(1024);
591
+ });
592
+ });
593
+ describe("uploadSymlink", () => {
594
+ beforeEach(() => {
595
+ sentCommands.length = 0;
596
+ });
597
+ it("PUTs the prefixed target as the body bytes and a marker-only metadata flag", async () => {
598
+ // Body = SYMLINK_BODY_PREFIX + target is the source of truth for
599
+ // the target string and is load-bearing for two distinct
600
+ // drift-detection properties:
601
+ // 1. S3 ETag = MD5(body) varies with target → cross-machine
602
+ // target-change propagation works through LIST etags.
603
+ // 2. The prefix means a symlink to "bar.md" doesn't share an
604
+ // ETag with a regular file containing "bar.md" → symlink ↔
605
+ // regular-file transitions on the same key are visible to
606
+ // peers via LIST.
607
+ // The metadata is now a fixed marker only — we used to store the
608
+ // base64'd target there, but S3's 2 KiB header limit made that
609
+ // brittle for long POSIX targets. Marker-only is bounded.
610
+ const target = "../real-target.md";
611
+ await uploadSymlink(makeCtx(), target, "policies/link.md");
612
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
613
+ expect(put).toBeDefined();
614
+ const meta = put.input.Metadata;
615
+ expect(meta["hq-symlink-target"]).toBe(SYMLINK_MARKER_META_VALUE);
616
+ expect(put.input.Body).toBeDefined();
617
+ const body = put.input.Body;
618
+ expect(Buffer.from(body).toString("utf-8")).toBe(SYMLINK_BODY_PREFIX + target);
619
+ expect(put.input.Key).toBe("policies/link.md");
620
+ });
621
+ it("handles arbitrary Unicode targets via the body (metadata stays marker-only)", async () => {
622
+ // Codex round-9 P2 follow-up: S3 user-metadata is HTTP-header-
623
+ // bound. A POSIX symlink target can include any Unicode bytes;
624
+ // storing the target in metadata risked PutObject rejecting it.
625
+ // Now the body carries the target — UTF-8 bytes pass through
626
+ // S3 object content unmolested, no ASCII restriction, no header
627
+ // limit. Metadata stays as the constant marker.
628
+ sentCommands.length = 0;
629
+ const unicodeTarget = "café/🌳/Übung.md";
630
+ await uploadSymlink(makeCtx(), unicodeTarget, "weird-link.md");
631
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
632
+ expect(put).toBeDefined();
633
+ const meta = put.input.Metadata;
634
+ expect(meta["hq-symlink-target"]).toBe(SYMLINK_MARKER_META_VALUE);
635
+ const body = Buffer.from(put.input.Body).toString("utf-8");
636
+ expect(body).toBe(SYMLINK_BODY_PREFIX + unicodeTarget);
637
+ });
638
+ it("handles long targets without exceeding S3's 2 KiB user-metadata limit", async () => {
639
+ // Codex round-13 P2 follow-up: pre-fix, the metadata value was
640
+ // base64(target) plus author fields plus the metadata key name.
641
+ // A target around 1.5 KiB after base64 inflation could push the
642
+ // total over S3's 2 KiB user-metadata cap and PutObject would
643
+ // reject the upload. With marker-only metadata, the target's
644
+ // size only contributes to the body — bounded by S3's 5 GB
645
+ // object size, not the header limit. Verify a 4 KiB target (well
646
+ // beyond the old breaking point) round-trips cleanly.
647
+ sentCommands.length = 0;
648
+ const longTarget = "deeply/nested/" + "x".repeat(4096);
649
+ await uploadSymlink(makeCtx(), longTarget, "long-link.md");
650
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
651
+ const meta = put.input.Metadata;
652
+ expect(meta["hq-symlink-target"]).toBe(SYMLINK_MARKER_META_VALUE);
653
+ const body = Buffer.from(put.input.Body).toString("utf-8");
654
+ expect(body).toBe(SYMLINK_BODY_PREFIX + longTarget);
655
+ // Sanity: marker fits in the header limit by an enormous margin
656
+ // (1 byte vs 2048).
657
+ expect(meta["hq-symlink-target"].length).toBeLessThan(10);
658
+ });
659
+ it("encodeSymlinkMetadataValue / decodeSymlinkMetadataValue round-trip arbitrary UTF-8", async () => {
660
+ // Direct property test of the helpers — covers the legacy-fallback
661
+ // path via the round-trip check inside decodeSymlinkMetadataValue.
662
+ for (const sample of [
663
+ "",
664
+ "real.md",
665
+ "../sibling/file.md",
666
+ "café/🌳/Übung.md",
667
+ "/absolute/path/with spaces.md",
668
+ "deeply/nested/path/" + "x".repeat(200),
669
+ ]) {
670
+ expect(decodeSymlinkMetadataValue(encodeSymlinkMetadataValue(sample))).toBe(sample);
671
+ }
672
+ // Legacy-fallback: a value that isn't valid base64 of UTF-8 (e.g.
673
+ // a raw target written by a pre-PR uploader) round-trips as-is.
674
+ // "real.md" happens to NOT be valid base64 (length not multiple
675
+ // of 4), so the decoder falls through to returning it raw.
676
+ expect(decodeSymlinkMetadataValue("real.md")).toBe("real.md");
677
+ });
678
+ it("produces a different body (and therefore a different S3 ETag) when target changes", async () => {
679
+ // Direct regression for the cross-machine target-propagation bug:
680
+ // two uploads with different targets must produce different bodies
681
+ // so S3-side etag comparison can detect the change. We assert on
682
+ // the body bytes rather than asking S3 for an ETag (the fake
683
+ // returns a constant ETag) — equality of body bytes is a necessary
684
+ // and sufficient property for ETag equality on PutObject.
685
+ sentCommands.length = 0;
686
+ await uploadSymlink(makeCtx(), "old-target.md", "policies/link.md");
687
+ await uploadSymlink(makeCtx(), "new-target.md", "policies/link.md");
688
+ const puts = sentCommands.filter((c) => c.name === "PutObjectCommand");
689
+ expect(puts).toHaveLength(2);
690
+ const bodies = puts.map((p) => Buffer.from(p.input.Body).toString("utf-8"));
691
+ expect(bodies[0]).not.toBe(bodies[1]);
692
+ expect(bodies[0]).toBe(SYMLINK_BODY_PREFIX + "old-target.md");
693
+ expect(bodies[1]).toBe(SYMLINK_BODY_PREFIX + "new-target.md");
694
+ });
695
+ it("produces a different body from a regular file containing the same target string (ETag distinguishability)", async () => {
696
+ // Codex round-4 P2 follow-up: pre-fix, a symlink whose target
697
+ // string equaled some regular file's exact contents produced an
698
+ // identical S3 ETag (since ETag = MD5(body) and bodies were equal).
699
+ // The LIST-based pull planner can't see per-object metadata, so
700
+ // it would classify a symlink ↔ regular-file transition on the
701
+ // same key as "no change" and never replace the local
702
+ // representation. The SYMLINK_BODY_PREFIX makes the bodies
703
+ // distinguishable for any realistic regular-file content.
704
+ sentCommands.length = 0;
705
+ const sharedString = "real.md";
706
+ // Make a regular file whose contents are exactly the target string
707
+ // — the worst-case collision shape pre-prefix.
708
+ const localFile = path.join(os.tmpdir(), `etag-distinguishability-${Date.now()}-${Math.random()}.md`);
709
+ fs.writeFileSync(localFile, sharedString);
710
+ await uploadSymlink(makeCtx(), sharedString, "case-key.md");
711
+ await uploadFile(makeCtx(), localFile, "regular-key.md");
712
+ fs.rmSync(localFile, { force: true });
713
+ const puts = sentCommands.filter((c) => c.name === "PutObjectCommand");
714
+ expect(puts).toHaveLength(2);
715
+ const symlinkBody = Buffer.from(puts[0].input.Body).toString("utf-8");
716
+ const regularBody = Buffer.from(puts[1].input.Body).toString("utf-8");
717
+ // The point of the prefix: symlink record body ≠ regular file body
718
+ // even when they describe the same string. Different bytes ⇒
719
+ // different MD5 ⇒ different S3 ETag ⇒ pull planner detects the
720
+ // transition via LIST without needing a per-object HEAD.
721
+ expect(symlinkBody).not.toBe(regularBody);
722
+ expect(regularBody).toBe(sharedString);
723
+ expect(symlinkBody).toBe(SYMLINK_BODY_PREFIX + sharedString);
724
+ });
725
+ it("forwards UploadAuthor alongside the symlink-target metadata", async () => {
726
+ await uploadSymlink(makeCtx(), "real.md", "policies/link.md", {
727
+ userSub: "abc-123",
728
+ email: "alice@example.com",
729
+ });
730
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
731
+ const meta = put.input.Metadata;
732
+ // Marker-only metadata; target lives in the body.
733
+ expect(meta["hq-symlink-target"]).toBe(SYMLINK_MARKER_META_VALUE);
734
+ const body = Buffer.from(put.input.Body).toString("utf-8");
735
+ expect(body).toBe(SYMLINK_BODY_PREFIX + "real.md");
736
+ expect(meta["created-by"]).toBe("alice@example.com");
737
+ expect(meta["created-by-sub"]).toBe("abc-123");
738
+ });
739
+ });
740
+ describe("createStagedSymlink", () => {
741
+ it("uses an absolute junction for a Windows directory without requiring symlink privilege", () => {
742
+ const linkPath = path.join(path.sep, "vault", ".agents", "skills");
743
+ const target = "../.claude/skills";
744
+ const absTarget = path.resolve(path.dirname(linkPath), target);
745
+ const symlink = vi.fn((_target, _linkPath, type) => {
746
+ if (type !== "junction") {
747
+ throw Object.assign(new Error("operation not permitted, symlink"), {
748
+ code: "EPERM",
749
+ });
750
+ }
751
+ });
752
+ expect(() => createStagedSymlink(target, linkPath, {
753
+ platform: "win32",
754
+ symlink,
755
+ statIsDirectory: () => true,
756
+ })).not.toThrow();
757
+ expect(symlink).toHaveBeenCalledWith(absTarget, linkPath, "junction");
758
+ expect(path.isAbsolute(symlink.mock.calls[0][0])).toBe(true);
759
+ });
760
+ it("resolves a relative Windows overlay target before creating a junction", () => {
761
+ const linkPath = path.join(path.sep, "vault", ".codex", "claude");
762
+ const target = "../.claude/skills";
763
+ const symlink = vi.fn();
764
+ createStagedSymlink(target, linkPath, {
765
+ platform: "win32",
766
+ symlink,
767
+ statIsDirectory: () => undefined,
768
+ });
769
+ expect(symlink).toHaveBeenCalledWith(path.resolve(path.dirname(linkPath), target), linkPath, "junction");
770
+ });
771
+ it("preserves a relative target and omits the type outside Windows", () => {
772
+ const linkPath = path.join(path.sep, "vault", ".agents", "skills");
773
+ const target = "../.claude/skills";
774
+ const symlink = vi.fn();
775
+ const statIsDirectory = vi.fn(() => true);
776
+ createStagedSymlink(target, linkPath, {
777
+ platform: "linux",
778
+ symlink,
779
+ statIsDirectory,
780
+ });
781
+ expect(symlink).toHaveBeenCalledWith(target, linkPath);
782
+ expect(statIsDirectory).not.toHaveBeenCalled();
783
+ });
784
+ it("uses a genuine Windows file symlink for a regular-file target", () => {
785
+ const linkPath = path.join(path.sep, "vault", "config-link.json");
786
+ const target = "../shared/config.json";
787
+ const absTarget = path.resolve(path.dirname(linkPath), target);
788
+ const symlink = vi.fn();
789
+ const statIsDirectory = vi.fn(() => false);
790
+ createStagedSymlink(target, linkPath, {
791
+ platform: "win32",
792
+ symlink,
793
+ statIsDirectory,
794
+ });
795
+ expect(statIsDirectory).toHaveBeenCalledWith(absTarget);
796
+ expect(symlink).toHaveBeenCalledWith(target, linkPath, "file");
797
+ });
798
+ });
799
+ /**
800
+ * readlink of a link downloadFile just created.
801
+ *
802
+ * createStagedSymlink stores a directory junction of the absolute target on
803
+ * win32 (s3.ts:742). Node's readlink of that junction is the absolute path
804
+ * plus a trailing separator. Every other platform keeps the POSIX target
805
+ * string (s3.ts:715).
806
+ */
807
+ function expectedMaterializedLink(linkPath, posixTarget) {
808
+ if (process.platform !== "win32")
809
+ return posixTarget;
810
+ const absolute = path.isAbsolute(posixTarget)
811
+ ? posixTarget
812
+ : path.resolve(path.dirname(linkPath), posixTarget);
813
+ return absolute.endsWith(path.sep) ? absolute : `${absolute}${path.sep}`;
814
+ }
815
+ describe("downloadFile", () => {
816
+ let tmpRoot;
817
+ beforeEach(() => {
818
+ sentCommands.length = 0;
819
+ tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), "s3-download-test-"));
820
+ });
821
+ it("materializes a symlink record as a real symlink, sourcing the target from the body", async () => {
822
+ // Round-13 contract: metadata is just a marker; the body
823
+ // (after stripping SYMLINK_BODY_PREFIX) is the source of truth
824
+ // for the target string. downloadFile must consume the body
825
+ // and use the post-prefix slice as the link target.
826
+ const target = "../real-target.md";
827
+ nextGetObjectResponse = {
828
+ Body: (async function* () {
829
+ yield new TextEncoder().encode(SYMLINK_BODY_PREFIX + target);
830
+ })(),
831
+ Metadata: { "hq-symlink-target": SYMLINK_MARKER_META_VALUE },
832
+ };
833
+ const localPath = path.join(tmpRoot, "policies", "link.md");
834
+ await downloadFile(makeCtx(), "policies/link.md", localPath);
835
+ const lstat = fs.lstatSync(localPath);
836
+ expect(lstat.isSymbolicLink()).toBe(true);
837
+ expect(fs.readlinkSync(localPath)).toBe(expectedMaterializedLink(localPath, target));
838
+ });
839
+ it("skips (typed, non-fatal) when the parent directory is a DANGLING symlink", async () => {
840
+ // The vault stores directory symlinks as objects (e.g.
841
+ // companies/<co>/.obsidian -> ../../.obsidian) AND files beneath them. On a
842
+ // machine where the link target is absent, mkdir of the parent throws
843
+ // ENOENT — not EEXIST — because mkdir(2) returns EEXIST for the link and
844
+ // Node's recursive impl then stats it, which fails on a dangling link.
845
+ // Raw, that marked the WHOLE company errored/partial on every sync cycle
846
+ // (2026-07-24 dogfood box). It must be a typed per-object skip instead.
847
+ nextGetObjectResponse = {
848
+ Body: (async function* () {
849
+ yield new TextEncoder().encode("hotkeys");
850
+ })(),
851
+ Metadata: {},
852
+ };
853
+ const parent = path.join(tmpRoot, ".obsidian");
854
+ fs.symlinkSync(path.join(tmpRoot, "does-not-exist"), parent);
855
+ // Precondition: existsSync follows the link and reports absent, while
856
+ // lstat still sees it — the exact shape the fix keys on.
857
+ expect(fs.existsSync(parent)).toBe(false);
858
+ expect(fs.lstatSync(parent).isSymbolicLink()).toBe(true);
859
+ await expect(downloadFile(makeCtx(), ".obsidian/hotkeys.json", path.join(parent, "hotkeys.json"))).rejects.toBeInstanceOf(DanglingSymlinkParentError);
860
+ // The link is left exactly as found — no target materialized outside the
861
+ // directory being synced, which the caller's containment guard refuses.
862
+ expect(fs.lstatSync(parent).isSymbolicLink()).toBe(true);
863
+ expect(fs.existsSync(path.join(tmpRoot, "does-not-exist"))).toBe(false);
864
+ });
865
+ it("still creates an ordinary missing parent directory", async () => {
866
+ nextGetObjectResponse = {
867
+ Body: (async function* () {
868
+ yield new TextEncoder().encode("plain");
869
+ })(),
870
+ Metadata: {},
871
+ };
872
+ const localPath = path.join(tmpRoot, "deep", "nested", "file.md");
873
+ await downloadFile(makeCtx(), "deep/nested/file.md", localPath);
874
+ expect(fs.readFileSync(localPath, "utf8")).toBe("plain");
875
+ });
876
+ it("recovers the target from legacy metadata-only uploads (body lacks the prefix)", async () => {
877
+ // Backward-compat: an in-flight upload from earlier in this
878
+ // PR's lifetime stored the target in metadata (raw or base64'd)
879
+ // rather than in the body. downloadFile must fall back to
880
+ // decoding the metadata value when the body doesn't start with
881
+ // SYMLINK_BODY_PREFIX. Tested with a base64'd metadata value
882
+ // and an empty body — the round-trip-validating decoder
883
+ // should recover the original target.
884
+ const target = "legacy/target.md";
885
+ const legacyMetadata = encodeSymlinkMetadataValue(target);
886
+ nextGetObjectResponse = {
887
+ Body: (async function* () {
888
+ yield new Uint8Array(); // empty body, like a v1-of-this-PR upload
889
+ })(),
890
+ Metadata: { "hq-symlink-target": legacyMetadata },
891
+ };
892
+ const localPath = path.join(tmpRoot, "legacy-link.md");
893
+ await downloadFile(makeCtx(), "legacy-link.md", localPath);
894
+ expect(fs.lstatSync(localPath).isSymbolicLink()).toBe(true);
895
+ expect(fs.readlinkSync(localPath)).toBe(expectedMaterializedLink(localPath, target));
896
+ });
897
+ it("recovers a target longer than the legacy 2 KiB metadata limit from the body", async () => {
898
+ // Codex round-13 P2 motivating case: targets between ~1.5 KiB
899
+ // (after base64 inflation) and ~5 GiB (S3 object cap) used to
900
+ // fail PutObject under the metadata-based design but now
901
+ // round-trip cleanly through the body. We pick 600 chars: well
902
+ // past the old metadata-only break point (~1500 base64 bytes ≈
903
+ // ~1100 raw, plus header overhead crosses 2 KiB), and well
904
+ // under any sane filesystem's PATH_MAX symlink-target limit
905
+ // (Linux: 4096, macOS: 1024) so the test creates a real link.
906
+ const longTarget = "deeply/nested/path/" + "x".repeat(600);
907
+ nextGetObjectResponse = {
908
+ Body: (async function* () {
909
+ yield new TextEncoder().encode(SYMLINK_BODY_PREFIX + longTarget);
910
+ })(),
911
+ Metadata: { "hq-symlink-target": SYMLINK_MARKER_META_VALUE },
912
+ };
913
+ const localPath = path.join(tmpRoot, "long-link.md");
914
+ await downloadFile(makeCtx(), "long-link.md", localPath);
915
+ expect(fs.lstatSync(localPath).isSymbolicLink()).toBe(true);
916
+ expect(fs.readlinkSync(localPath)).toBe(expectedMaterializedLink(localPath, longTarget));
917
+ });
918
+ it("falls back to writing a regular file when hq-symlink-target metadata is absent", async () => {
919
+ nextGetObjectResponse = {
920
+ Body: (async function* () {
921
+ yield new Uint8Array([104, 105]); // "hi"
922
+ })(),
923
+ Metadata: {},
924
+ };
925
+ const localPath = path.join(tmpRoot, "regular.md");
926
+ await downloadFile(makeCtx(), "regular.md", localPath);
927
+ const lstat = fs.lstatSync(localPath);
928
+ expect(lstat.isSymbolicLink()).toBe(false);
929
+ expect(fs.readFileSync(localPath, "utf-8")).toBe("hi");
930
+ });
931
+ it("recovers a symlink from the body prefix when the metadata marker is lost (header-loss fallback)", async () => {
932
+ // Regression: a transport/replication/console-copy that drops user
933
+ // metadata — or a poisoned regular-file re-upload of a sentinel —
934
+ // leaves an object with NO hq-symlink-target marker but a body of
935
+ // `hq-symlink:<target>`. The read path must honor the body prefix as
936
+ // a fallback discriminator and rematerialize a real link, NOT write
937
+ // out the `hq-symlink:` text as a regular file (which poisons the key
938
+ // on the next push). See s3.ts downloadFile + SYMLINK_BODY_PREFIX doc.
939
+ const target = "../../../some/real/target.md";
940
+ nextGetObjectResponse = {
941
+ Body: (async function* () {
942
+ yield new TextEncoder().encode(SYMLINK_BODY_PREFIX + target);
943
+ })(),
944
+ Metadata: {}, // marker stripped / never set
945
+ };
946
+ const localPath = path.join(tmpRoot, "marker-lost-link.md");
947
+ await downloadFile(makeCtx(), "marker-lost-link.md", localPath);
948
+ const lstat = fs.lstatSync(localPath);
949
+ expect(lstat.isSymbolicLink()).toBe(true);
950
+ expect(fs.readlinkSync(localPath)).toBe(expectedMaterializedLink(localPath, target));
951
+ });
952
+ it("replaces a stale local symlink with a regular file when remote transitions symlink → regular", async () => {
953
+ // Codex P2 follow-up: pre-fix, the regular-file branch went
954
+ // straight to writeFileSync. If localPath was a stale symlink from
955
+ // a prior sync (when this key was a symlink in cloud), writeFileSync
956
+ // would FOLLOW the link and overwrite the link's target file
957
+ // contents — leaving the link in place and the new "regular file at
958
+ // localPath" never materializing. The fix: lstat before write; if
959
+ // the existing entry is a symlink, unlink it first.
960
+ const localPath = path.join(tmpRoot, "transitioned.md");
961
+ const targetFile = path.join(tmpRoot, "stale-target.md");
962
+ fs.writeFileSync(targetFile, "do-not-clobber-me");
963
+ fs.symlinkSync(targetFile, localPath);
964
+ nextGetObjectResponse = {
965
+ Body: (async function* () {
966
+ yield new Uint8Array([110, 101, 119]); // "new"
967
+ })(),
968
+ Metadata: {}, // no symlink metadata → regular file path
969
+ };
970
+ await downloadFile(makeCtx(), "transitioned.md", localPath);
971
+ // localPath is now a regular file with the new content...
972
+ expect(fs.lstatSync(localPath).isSymbolicLink()).toBe(false);
973
+ expect(fs.readFileSync(localPath, "utf-8")).toBe("new");
974
+ // ...and the link's former target was NOT clobbered.
975
+ expect(fs.readFileSync(targetFile, "utf-8")).toBe("do-not-clobber-me");
976
+ });
977
+ it("replaces an existing entry when the link is rewritten (target change)", async () => {
978
+ // Pre-existing regular file at the target location must not block
979
+ // creation of a symlink — fs.symlinkSync would EEXIST otherwise.
980
+ // Same applies to a stale symlink whose target has changed: the new
981
+ // target string must win.
982
+ const localPath = path.join(tmpRoot, "rewrite.md");
983
+ fs.writeFileSync(localPath, "stale regular file");
984
+ nextGetObjectResponse = {
985
+ Body: (async function* () {
986
+ yield new Uint8Array();
987
+ })(),
988
+ Metadata: { "hq-symlink-target": "fresh-target.md" },
989
+ };
990
+ await downloadFile(makeCtx(), "rewrite.md", localPath);
991
+ expect(fs.lstatSync(localPath).isSymbolicLink()).toBe(true);
992
+ expect(fs.readlinkSync(localPath)).toBe(expectedMaterializedLink(localPath, "fresh-target.md"));
993
+ });
994
+ it("F11: failed symlink downloads preserve the previous local file", async () => {
995
+ const localPath = path.join(tmpRoot, "preserve-on-failure.md");
996
+ fs.writeFileSync(localPath, "existing local copy");
997
+ nextGetObjectResponse = {
998
+ Body: (async function* () {
999
+ yield new TextEncoder().encode(SYMLINK_BODY_PREFIX + "x".repeat(10_000));
1000
+ })(),
1001
+ Metadata: { "hq-symlink-target": SYMLINK_MARKER_META_VALUE },
1002
+ };
1003
+ await expect(downloadFile(makeCtx(), "preserve-on-failure.md", localPath)).rejects.toThrow();
1004
+ expect(fs.existsSync(localPath)).toBe(true);
1005
+ expect(fs.lstatSync(localPath).isSymbolicLink()).toBe(false);
1006
+ expect(fs.readFileSync(localPath, "utf-8")).toBe("existing local copy");
1007
+ });
1008
+ it("replaces an existing directory link without changing its target", async () => {
1009
+ const targetDir = path.join(tmpRoot, "generated-skill-source");
1010
+ const localPath = path.join(tmpRoot, "generated-skill-link");
1011
+ fs.mkdirSync(targetDir);
1012
+ fs.writeFileSync(path.join(targetDir, "sentinel.txt"), "source-owned");
1013
+ fs.symlinkSync(targetDir, localPath, "dir");
1014
+ nextGetObjectResponse = {
1015
+ Body: (async function* () {
1016
+ yield Buffer.from("remote replacement");
1017
+ })(),
1018
+ Metadata: {},
1019
+ };
1020
+ await downloadFile(makeCtx(), "generated-skill-link", localPath);
1021
+ expect(fs.lstatSync(localPath).isSymbolicLink()).toBe(false);
1022
+ expect(fs.readFileSync(localPath, "utf8")).toBe("remote replacement");
1023
+ expect(fs.readFileSync(path.join(targetDir, "sentinel.txt"), "utf8")).toBe("source-owned");
1024
+ });
1025
+ it("default ops replace a directory symlink destination end-to-end (dir-reparse-safe cleanup)", () => {
1026
+ // No ops seam: exercises DEFAULT_REPLACE_STAGED_PATH_OPS on the real
1027
+ // filesystem. The backup of the old DIR-type link must be removable on
1028
+ // every platform (unlink with rmdir fallback for directory reparse
1029
+ // points), or the replacement rolls back and the Windows churn returns.
1030
+ const oldTarget = path.join(tmpRoot, "default-ops-old");
1031
+ const newTarget = path.join(tmpRoot, "default-ops-new");
1032
+ const localPath = path.join(tmpRoot, "default-ops-link");
1033
+ const stagedPath = path.join(tmpRoot, ".hq-tmp-default-ops-test");
1034
+ fs.mkdirSync(oldTarget);
1035
+ fs.mkdirSync(newTarget);
1036
+ fs.symlinkSync(oldTarget, localPath, "dir");
1037
+ fs.symlinkSync(newTarget, stagedPath, "dir");
1038
+ replaceStagedPath(stagedPath, localPath);
1039
+ expect(fs.lstatSync(localPath).isSymbolicLink()).toBe(true);
1040
+ expect(fs.readlinkSync(localPath)).toBe(newTarget);
1041
+ expect(fs.readdirSync(tmpRoot).filter((n) => n.startsWith(".hq-backup-"))).toEqual([]);
1042
+ expect(fs.existsSync(stagedPath)).toBe(false);
1043
+ });
1044
+ it("restores an existing directory link when staged replacement fails", () => {
1045
+ const targetDir = path.join(tmpRoot, "rollback-source");
1046
+ const localPath = path.join(tmpRoot, "rollback-link");
1047
+ const stagedPath = path.join(tmpRoot, ".hq-tmp-rollback-test");
1048
+ fs.mkdirSync(targetDir);
1049
+ fs.symlinkSync(targetDir, localPath, "dir");
1050
+ fs.writeFileSync(stagedPath, "staged replacement");
1051
+ let renameCalls = 0;
1052
+ expect(() => replaceStagedPath(stagedPath, localPath, {
1053
+ lstat: (p) => fs.lstatSync(p),
1054
+ platform: "win32",
1055
+ withReplacementMarker: (_path, replace) => replace(),
1056
+ rename: (from, to) => {
1057
+ renameCalls++;
1058
+ if (renameCalls === 2) {
1059
+ throw Object.assign(new Error("simulated Windows replacement failure"), {
1060
+ code: "EPERM",
1061
+ });
1062
+ }
1063
+ fs.renameSync(from, to);
1064
+ },
1065
+ remove: (p) => fs.unlinkSync(p),
1066
+ })).toThrow("simulated Windows replacement failure");
1067
+ expect(renameCalls).toBe(3);
1068
+ expect(fs.lstatSync(localPath).isSymbolicLink()).toBe(true);
1069
+ expect(fs.readlinkSync(localPath)).toBe(targetDir);
1070
+ expect(fs.readFileSync(stagedPath, "utf8")).toBe("staged replacement");
1071
+ expect(fs.readdirSync(tmpRoot).filter((name) => name.startsWith(".hq-backup-"))).toEqual([]);
1072
+ });
1073
+ it("restores an existing directory link when backup cleanup fails", () => {
1074
+ const targetDir = path.join(tmpRoot, "cleanup-rollback-source");
1075
+ const localPath = path.join(tmpRoot, "cleanup-rollback-link");
1076
+ const stagedPath = path.join(tmpRoot, ".hq-tmp-cleanup-rollback-test");
1077
+ fs.mkdirSync(targetDir);
1078
+ fs.symlinkSync(targetDir, localPath, "dir");
1079
+ fs.writeFileSync(stagedPath, "staged replacement");
1080
+ let renameCalls = 0;
1081
+ expect(() => replaceStagedPath(stagedPath, localPath, {
1082
+ lstat: (p) => fs.lstatSync(p),
1083
+ platform: "win32",
1084
+ withReplacementMarker: (_path, replace) => replace(),
1085
+ rename: (from, to) => {
1086
+ renameCalls++;
1087
+ fs.renameSync(from, to);
1088
+ },
1089
+ remove: () => {
1090
+ throw Object.assign(new Error("simulated backup cleanup failure"), {
1091
+ code: "EPERM",
1092
+ });
1093
+ },
1094
+ })).toThrow("simulated backup cleanup failure");
1095
+ expect(renameCalls).toBe(4);
1096
+ expect(fs.lstatSync(localPath).isSymbolicLink()).toBe(true);
1097
+ expect(fs.readlinkSync(localPath)).toBe(targetDir);
1098
+ expect(fs.readFileSync(stagedPath, "utf8")).toBe("staged replacement");
1099
+ expect(fs.readdirSync(tmpRoot).filter((name) => name.startsWith(".hq-backup-"))).toEqual([]);
1100
+ });
1101
+ it("R-F11: downloads to a near component-limit basename via a bounded temp name", async () => {
1102
+ nextGetObjectResponse = {
1103
+ Body: (async function* () {
1104
+ yield Buffer.from("near-limit bytes");
1105
+ })(),
1106
+ Metadata: {},
1107
+ };
1108
+ const localPath = path.join(tmpRoot, "x".repeat(240));
1109
+ await downloadFile(makeCtx(), "near-limit.bin", localPath);
1110
+ expect(fs.readFileSync(localPath, "utf-8")).toBe("near-limit bytes");
1111
+ });
1112
+ it("F20: regular downloads do not decode the full body as UTF-8", async () => {
1113
+ const body = Buffer.alloc(64 * 1024, 0x61);
1114
+ const originalToString = body.toString;
1115
+ body.toString = ((encoding, start, end) => {
1116
+ const sliceStart = start ?? 0;
1117
+ const sliceEnd = end ?? body.length;
1118
+ if (sliceEnd - sliceStart > SYMLINK_BODY_PREFIX.length) {
1119
+ throw new Error("full-body UTF-8 decode attempted");
1120
+ }
1121
+ return originalToString.call(body, encoding, start, end);
1122
+ });
1123
+ const io = {
1124
+ putObject: async () => ({ etag: '"unused"' }),
1125
+ getObject: async () => ({ body, metadata: {} }),
1126
+ listObjects: async () => ({ objects: [] }),
1127
+ deleteObject: async () => undefined,
1128
+ headObject: async () => null,
1129
+ };
1130
+ const localPath = path.join(tmpRoot, "large-regular.bin");
1131
+ setObjectIOFactory(() => io);
1132
+ try {
1133
+ await downloadFile(makeCtx(), "large-regular.bin", localPath);
1134
+ }
1135
+ finally {
1136
+ setObjectIOFactory(null);
1137
+ }
1138
+ const written = fs.readFileSync(localPath);
1139
+ expect(written.length).toBe(body.length);
1140
+ expect(written[0]).toBe(0x61);
1141
+ expect(written[written.length - 1]).toBe(0x61);
1142
+ });
1143
+ it("R-F20: streams regular downloads with hash metadata and still detects symlink records", async () => {
1144
+ const regularChunks = [
1145
+ Buffer.from("alpha-"),
1146
+ Buffer.from("beta-"),
1147
+ Buffer.from("gamma"),
1148
+ ];
1149
+ const regularBody = Buffer.concat(regularChunks);
1150
+ const linkTarget = "../target.md";
1151
+ const io = {
1152
+ putObject: async () => ({ etag: '"unused"' }),
1153
+ getObject: async () => {
1154
+ throw new Error("buffered getObject attempted");
1155
+ },
1156
+ getObjectStream: async (key) => {
1157
+ if (key === "streamed-link") {
1158
+ return {
1159
+ body: (async function* () {
1160
+ yield Buffer.from("hq-");
1161
+ yield Buffer.from("symlink:");
1162
+ yield Buffer.from(linkTarget);
1163
+ })(),
1164
+ metadata: {},
1165
+ };
1166
+ }
1167
+ return {
1168
+ body: (async function* () {
1169
+ for (const chunk of regularChunks)
1170
+ yield chunk;
1171
+ })(),
1172
+ metadata: {},
1173
+ };
1174
+ },
1175
+ listObjects: async () => ({ objects: [] }),
1176
+ deleteObject: async () => undefined,
1177
+ headObject: async () => null,
1178
+ };
1179
+ setObjectIOFactory(() => io);
1180
+ try {
1181
+ const localPath = path.join(tmpRoot, "streamed.bin");
1182
+ const result = await downloadFile(makeCtx(), "streamed.bin", localPath);
1183
+ expect(fs.readFileSync(localPath)).toEqual(regularBody);
1184
+ expect(result.contentHash).toBe(crypto.createHash("sha256").update(regularBody).digest("hex"));
1185
+ expect(result.contentSize).toBe(regularBody.length);
1186
+ const linkPath = path.join(tmpRoot, "streamed-link");
1187
+ await downloadFile(makeCtx(), "streamed-link", linkPath);
1188
+ expect(fs.lstatSync(linkPath).isSymbolicLink()).toBe(true);
1189
+ expect(fs.readlinkSync(linkPath)).toBe(expectedMaterializedLink(linkPath, linkTarget));
1190
+ }
1191
+ finally {
1192
+ setObjectIOFactory(null);
1193
+ }
1194
+ });
1195
+ /**
1196
+ * Pam bulk path: mid-stream write EPIPE / socket hang up after a 200 must
1197
+ * restart the WHOLE temp-file download (fresh getObjectStream + clean temp),
1198
+ * not buffer the object in the transport. Partial temps must not remain.
1199
+ */
1200
+ it("retries a mid-stream EPIPE around the whole temp download with a fresh stream", async () => {
1201
+ // Real timers: stream pipeline + backoff sleep do not play well with
1202
+ // fake timers (hangs runAllTimersAsync and poisons later mtime checks).
1203
+ let streamOpens = 0;
1204
+ const io = {
1205
+ putObject: async () => ({ etag: '"unused"' }),
1206
+ getObject: async () => {
1207
+ throw new Error("buffered getObject attempted");
1208
+ },
1209
+ getObjectStream: async () => {
1210
+ streamOpens++;
1211
+ if (streamOpens === 1) {
1212
+ return {
1213
+ body: (async function* () {
1214
+ // Enough prefix to pass symlink detection and open the temp
1215
+ // write path, then cut mid-stream so the attempt must clean
1216
+ // a partial .hq-tmp-* before the outer retry.
1217
+ yield Buffer.from("not-a-symlink-prefix-bytes-");
1218
+ throw Object.assign(new Error("write EPIPE"), { code: "EPIPE" });
1219
+ })(),
1220
+ metadata: { "hq-mode": "644" },
1221
+ };
1222
+ }
1223
+ return {
1224
+ body: (async function* () {
1225
+ yield Buffer.from("complete-body");
1226
+ })(),
1227
+ metadata: { "hq-mode": "644" },
1228
+ };
1229
+ },
1230
+ listObjects: async () => ({ objects: [] }),
1231
+ deleteObject: async () => undefined,
1232
+ headObject: async () => null,
1233
+ };
1234
+ setObjectIOFactory(() => io);
1235
+ const localPath = path.join(tmpRoot, "mission-control-prd.json");
1236
+ try {
1237
+ const result = await downloadFile(makeCtx(), "projects/mission-control/prd.json", localPath);
1238
+ expect(fs.readFileSync(localPath, "utf-8")).toBe("complete-body");
1239
+ expect(result.contentHash).toBe(crypto.createHash("sha256").update("complete-body").digest("hex"));
1240
+ expect(streamOpens).toBe(2);
1241
+ // Failed attempt cleaned its partial temp; successful attempt renamed
1242
+ // its temp into place — no .hq-tmp-* orphans left beside the destination.
1243
+ const leftovers = fs
1244
+ .readdirSync(tmpRoot)
1245
+ .filter((name) => name.startsWith(".hq-tmp-"));
1246
+ expect(leftovers).toEqual([]);
1247
+ expect(fs.existsSync(localPath)).toBe(true);
1248
+ }
1249
+ finally {
1250
+ setObjectIOFactory(null);
1251
+ }
1252
+ }, 15_000);
1253
+ it("retries a content-length-truncated stream around the whole temp download", async () => {
1254
+ let streamOpens = 0;
1255
+ const io = {
1256
+ putObject: async () => ({ etag: '"unused"' }),
1257
+ getObject: async () => {
1258
+ throw new Error("buffered getObject attempted");
1259
+ },
1260
+ getObjectStream: async () => {
1261
+ streamOpens++;
1262
+ if (streamOpens === 1) {
1263
+ return {
1264
+ body: (async function* () {
1265
+ yield Buffer.from("partial-body");
1266
+ throw Object.assign(new Error("presigned GET content-length mismatch: expected 20 bytes, received 12"), { code: "ERR_HQ_TRUNCATED_RESPONSE" });
1267
+ })(),
1268
+ metadata: { "hq-mode": "644" },
1269
+ };
1270
+ }
1271
+ return {
1272
+ body: (async function* () {
1273
+ yield Buffer.from("complete-body");
1274
+ })(),
1275
+ metadata: { "hq-mode": "644" },
1276
+ };
1277
+ },
1278
+ listObjects: async () => ({ objects: [] }),
1279
+ deleteObject: async () => undefined,
1280
+ headObject: async () => null,
1281
+ };
1282
+ setObjectIOFactory(() => io);
1283
+ const localPath = path.join(tmpRoot, "content-length-retry.bin");
1284
+ try {
1285
+ const result = await downloadFile(makeCtx(), "truncated.bin", localPath);
1286
+ expect(fs.readFileSync(localPath, "utf-8")).toBe("complete-body");
1287
+ expect(result.contentHash).toBe(crypto.createHash("sha256").update("complete-body").digest("hex"));
1288
+ expect(streamOpens).toBe(2);
1289
+ expect(fs.readdirSync(tmpRoot).filter((name) => name.startsWith(".hq-tmp-"))).toEqual([]);
1290
+ }
1291
+ finally {
1292
+ setObjectIOFactory(null);
1293
+ }
1294
+ }, 15_000);
1295
+ it("never lets two overlapping downloads of one key share the resumable stage", async () => {
1296
+ // A realtime pull may overlap a chore pull of the same key. Both derive
1297
+ // the same resumable stage from (dir, key), so they must not write it at
1298
+ // the same time: the second GET may open only after the first finishes.
1299
+ const key = "projects/overlap.bin";
1300
+ const localPath = path.join(tmpRoot, "overlap.bin");
1301
+ const body = Buffer.from("ordinary-file-body-for-overlap");
1302
+ let openStreams = 0;
1303
+ let peakOpenStreams = 0;
1304
+ let releaseFirst = () => { };
1305
+ const firstGate = new Promise((resolve) => { releaseFirst = resolve; });
1306
+ let gets = 0;
1307
+ const io = {
1308
+ putObject: async () => ({ etag: '"unused"' }),
1309
+ getObject: async () => { throw new Error("buffered getObject attempted"); },
1310
+ getObjectStream: async () => {
1311
+ gets++;
1312
+ const gate = gets === 1 ? firstGate : Promise.resolve();
1313
+ openStreams++;
1314
+ peakOpenStreams = Math.max(peakOpenStreams, openStreams);
1315
+ return {
1316
+ body: (async function* () {
1317
+ try {
1318
+ yield body.subarray(0, 10);
1319
+ await gate;
1320
+ yield body.subarray(10);
1321
+ }
1322
+ finally {
1323
+ openStreams--;
1324
+ }
1325
+ })(),
1326
+ metadata: { "hq-mode": "644" },
1327
+ etag: '"etag-a"',
1328
+ versionId: "version-a",
1329
+ contentLength: body.length,
1330
+ statusCode: 200,
1331
+ };
1332
+ },
1333
+ listObjects: async () => ({ objects: [] }),
1334
+ deleteObject: async () => undefined,
1335
+ headObject: async () => ({
1336
+ lastModified: new Date("2026-09-24T00:00:00Z"),
1337
+ etag: '"etag-a"',
1338
+ size: body.length,
1339
+ versionId: "version-a",
1340
+ }),
1341
+ };
1342
+ setObjectIOFactory(() => io);
1343
+ try {
1344
+ const first = downloadFile(makeCtx(), key, localPath);
1345
+ await vi.waitFor(() => expect(gets).toBe(1));
1346
+ const second = downloadFile(makeCtx(), key, localPath, { bypassBandwidthGovernor: true });
1347
+ await new Promise((resolve) => setTimeout(resolve, 20));
1348
+ expect(gets).toBe(1);
1349
+ releaseFirst();
1350
+ await Promise.all([first, second]);
1351
+ expect(gets).toBe(2);
1352
+ expect(peakOpenStreams).toBe(1);
1353
+ expect(fs.readFileSync(localPath)).toEqual(body);
1354
+ }
1355
+ finally {
1356
+ setObjectIOFactory(null);
1357
+ }
1358
+ });
1359
+ it("discards an invalid ranged response without an unhandled stream error", async () => {
1360
+ // An intermediary that ignores Range answers the resume with a plain 200.
1361
+ // The response is rejected and the stage discarded; closing that body must
1362
+ // not emit an `error` event nobody listens to (which would crash the
1363
+ // runner), and the download must fall back to a full GET.
1364
+ const { PassThrough } = await import("node:stream");
1365
+ const key = "projects/invalid-range.bin";
1366
+ const localPath = path.join(tmpRoot, "invalid-range.bin");
1367
+ const prefix = Buffer.from("ordinary-file-prefix-");
1368
+ const fullBody = Buffer.concat([prefix, Buffer.from("remaining-payload")]);
1369
+ let call = 0;
1370
+ const io = {
1371
+ putObject: async () => ({ etag: '"unused"' }),
1372
+ getObject: async () => { throw new Error("buffered getObject attempted"); },
1373
+ getObjectStream: async (_requestedKey, transferOptions) => {
1374
+ call++;
1375
+ const ranged = transferOptions?.rangeStart !== undefined;
1376
+ if (call === 1) {
1377
+ return {
1378
+ body: (async function* () {
1379
+ yield prefix;
1380
+ throw new Error("simulated interrupted transfer");
1381
+ })(),
1382
+ metadata: { "hq-mode": "644" },
1383
+ etag: '"etag-a"',
1384
+ versionId: "version-a",
1385
+ contentLength: fullBody.length,
1386
+ statusCode: 200,
1387
+ };
1388
+ }
1389
+ if (ranged) {
1390
+ const body = new PassThrough();
1391
+ body.write(fullBody);
1392
+ return {
1393
+ body,
1394
+ destroy: (error) => { body.destroy(error); },
1395
+ metadata: { "hq-mode": "644" },
1396
+ etag: '"etag-a"',
1397
+ versionId: "version-a",
1398
+ contentLength: fullBody.length,
1399
+ statusCode: 200,
1400
+ };
1401
+ }
1402
+ return {
1403
+ body: (async function* () { yield fullBody; })(),
1404
+ metadata: { "hq-mode": "644" },
1405
+ etag: '"etag-a"',
1406
+ versionId: "version-a",
1407
+ contentLength: fullBody.length,
1408
+ statusCode: 200,
1409
+ };
1410
+ },
1411
+ listObjects: async () => ({ objects: [] }),
1412
+ deleteObject: async () => undefined,
1413
+ headObject: async () => ({
1414
+ lastModified: new Date("2026-09-24T00:00:00Z"),
1415
+ etag: '"etag-a"',
1416
+ size: fullBody.length,
1417
+ versionId: "version-a",
1418
+ }),
1419
+ };
1420
+ const unhandled = [];
1421
+ const onUncaught = (error) => { unhandled.push(error); };
1422
+ process.on("uncaughtException", onUncaught);
1423
+ setObjectIOFactory(() => io);
1424
+ try {
1425
+ await expect(downloadFile(makeCtx(), key, localPath)).rejects.toThrow("simulated interrupted transfer");
1426
+ await downloadFile(makeCtx(), key, localPath);
1427
+ await new Promise((resolve) => setImmediate(resolve));
1428
+ expect(unhandled).toEqual([]);
1429
+ expect(fs.readFileSync(localPath)).toEqual(fullBody);
1430
+ }
1431
+ finally {
1432
+ process.off("uncaughtException", onUncaught);
1433
+ setObjectIOFactory(null);
1434
+ }
1435
+ });
1436
+ it("resumes a staged partial when the remote ETag and version still match", async () => {
1437
+ const key = "projects/resume.bin";
1438
+ const localPath = path.join(tmpRoot, "resume.bin");
1439
+ const prefix = Buffer.from("ordinary-file-prefix-");
1440
+ const suffix = Buffer.from("remaining-payload");
1441
+ const fullBody = Buffer.concat([prefix, suffix]);
1442
+ const requests = [];
1443
+ let fullGets = 0;
1444
+ const io = {
1445
+ putObject: async () => ({ etag: '"unused"' }),
1446
+ getObject: async () => { throw new Error("buffered getObject attempted"); },
1447
+ getObjectStream: async (_requestedKey, transferOptions) => {
1448
+ const request = transferOptions;
1449
+ requests.push(request);
1450
+ if (request.rangeStart !== undefined) {
1451
+ const response = {
1452
+ body: (async function* () { yield suffix; })(),
1453
+ metadata: { "hq-mode": "644" },
1454
+ etag: '"etag-a"',
1455
+ versionId: "version-a",
1456
+ contentLength: suffix.length,
1457
+ contentRange: `bytes ${prefix.length}-${fullBody.length - 1}/${fullBody.length}`,
1458
+ statusCode: 206,
1459
+ };
1460
+ return response;
1461
+ }
1462
+ fullGets++;
1463
+ const response = {
1464
+ body: (async function* () {
1465
+ yield prefix;
1466
+ throw new Error("simulated interrupted transfer");
1467
+ })(),
1468
+ metadata: { "hq-mode": "644" },
1469
+ etag: '"etag-a"',
1470
+ versionId: "version-a",
1471
+ contentLength: fullBody.length,
1472
+ statusCode: 200,
1473
+ };
1474
+ return response;
1475
+ },
1476
+ listObjects: async () => ({ objects: [] }),
1477
+ deleteObject: async () => undefined,
1478
+ headObject: async () => {
1479
+ const head = {
1480
+ lastModified: new Date("2026-09-24T00:00:00Z"),
1481
+ etag: '"etag-a"',
1482
+ size: fullBody.length,
1483
+ versionId: "version-a",
1484
+ };
1485
+ return head;
1486
+ },
1487
+ };
1488
+ setObjectIOFactory(() => io);
1489
+ try {
1490
+ await expect(downloadFile(makeCtx(), key, localPath)).rejects.toThrow("simulated interrupted transfer");
1491
+ const stageNames = fs.readdirSync(tmpRoot).filter((name) => name.startsWith(".hq-tmp-resume-"));
1492
+ expect(stageNames.some((name) => name.endsWith(".json"))).toBe(true);
1493
+ const stageName = stageNames.find((name) => !name.endsWith(".json"));
1494
+ expect(stageName).toBeDefined();
1495
+ expect(fs.readFileSync(path.join(tmpRoot, stageName))).toEqual(prefix);
1496
+ const result = await downloadFile(makeCtx(), key, localPath);
1497
+ expect(requests).toHaveLength(2);
1498
+ expect(requests[1]).toEqual({ rangeStart: prefix.length, ifMatch: '"etag-a"' });
1499
+ expect(fullGets).toBe(1);
1500
+ expect(fs.readFileSync(localPath)).toEqual(fullBody);
1501
+ expect(result.contentSize).toBe(fullBody.length);
1502
+ expect(result.contentHash).toBe(crypto.createHash("sha256").update(fullBody).digest("hex"));
1503
+ expect(fs.readdirSync(tmpRoot).filter((name) => name.startsWith(".hq-tmp-resume-"))).toEqual([]);
1504
+ }
1505
+ finally {
1506
+ setObjectIOFactory(null);
1507
+ }
1508
+ });
1509
+ it("deletes a staged partial when the remote validator has changed", async () => {
1510
+ const key = "projects/stale.bin";
1511
+ const localPath = path.join(tmpRoot, "stale.bin");
1512
+ const prefix = Buffer.from("ordinary-file-prefix-");
1513
+ const fullBody = Buffer.from("fresh-complete-object");
1514
+ const requests = [];
1515
+ let fullGets = 0;
1516
+ const io = {
1517
+ putObject: async () => ({ etag: '"unused"' }),
1518
+ getObject: async () => { throw new Error("buffered getObject attempted"); },
1519
+ getObjectStream: async (_requestedKey, transferOptions) => {
1520
+ const request = transferOptions;
1521
+ requests.push(request);
1522
+ if (request.rangeStart !== undefined) {
1523
+ throw new Error("stale partial must not issue a ranged GET");
1524
+ }
1525
+ fullGets++;
1526
+ if (fullGets === 1) {
1527
+ const response = {
1528
+ body: (async function* () {
1529
+ yield prefix;
1530
+ throw new Error("simulated interrupted transfer");
1531
+ })(),
1532
+ metadata: { "hq-mode": "644" },
1533
+ etag: '"etag-old"',
1534
+ versionId: "version-old",
1535
+ contentLength: prefix.length + 20,
1536
+ statusCode: 200,
1537
+ };
1538
+ return response;
1539
+ }
1540
+ const response = {
1541
+ body: (async function* () { yield fullBody; })(),
1542
+ metadata: { "hq-mode": "644" },
1543
+ etag: '"etag-new"',
1544
+ versionId: "version-new",
1545
+ contentLength: fullBody.length,
1546
+ statusCode: 200,
1547
+ };
1548
+ return response;
1549
+ },
1550
+ listObjects: async () => ({ objects: [] }),
1551
+ deleteObject: async () => undefined,
1552
+ headObject: async () => {
1553
+ const head = {
1554
+ lastModified: new Date("2026-09-24T00:00:00Z"),
1555
+ etag: '"etag-new"',
1556
+ size: fullBody.length,
1557
+ versionId: "version-new",
1558
+ };
1559
+ return head;
1560
+ },
1561
+ };
1562
+ setObjectIOFactory(() => io);
1563
+ try {
1564
+ await expect(downloadFile(makeCtx(), key, localPath)).rejects.toThrow("simulated interrupted transfer");
1565
+ const stageNames = fs.readdirSync(tmpRoot).filter((name) => name.startsWith(".hq-tmp-resume-"));
1566
+ expect(stageNames.some((name) => name.endsWith(".json"))).toBe(true);
1567
+ await downloadFile(makeCtx(), key, localPath);
1568
+ expect(requests.map((request) => request.rangeStart)).toEqual([undefined, undefined]);
1569
+ expect(fullGets).toBe(2);
1570
+ expect(fs.readFileSync(localPath)).toEqual(fullBody);
1571
+ expect(fs.readdirSync(tmpRoot).filter((name) => name.startsWith(".hq-tmp-resume-"))).toEqual([]);
1572
+ }
1573
+ finally {
1574
+ setObjectIOFactory(null);
1575
+ }
1576
+ });
1577
+ it("does NOT retry a definitive Forbidden mid-download as a transport cut", async () => {
1578
+ let streamOpens = 0;
1579
+ const io = {
1580
+ putObject: async () => ({ etag: '"unused"' }),
1581
+ getObject: async () => {
1582
+ throw new Error("buffered getObject attempted");
1583
+ },
1584
+ getObjectStream: async () => {
1585
+ streamOpens++;
1586
+ throw Object.assign(new Error("Access denied for secret/x: ACL"), {
1587
+ name: "Forbidden",
1588
+ });
1589
+ },
1590
+ listObjects: async () => ({ objects: [] }),
1591
+ deleteObject: async () => undefined,
1592
+ headObject: async () => null,
1593
+ };
1594
+ setObjectIOFactory(() => io);
1595
+ try {
1596
+ await expect(downloadFile(makeCtx(), "secret/x", path.join(tmpRoot, "secret-x"))).rejects.toMatchObject({ name: "Forbidden" });
1597
+ expect(streamOpens).toBe(1);
1598
+ }
1599
+ finally {
1600
+ setObjectIOFactory(null);
1601
+ }
1602
+ });
1603
+ it("applies hq-mode metadata via chmod after byte write (Bug #5 — preserve permissions)", async () => {
1604
+ // Round-trip pair to the s3.upload test: source-side mode lives in
1605
+ // \`Metadata['hq-mode']\` as an octal string; the receiver must chmod
1606
+ // the file to that exact mode after writing the bytes. Pre-fix the
1607
+ // receiver took the umask default and 0755 scripts arrived 0644.
1608
+ nextGetObjectResponse = {
1609
+ Body: (async function* () {
1610
+ yield new Uint8Array([35, 33, 47, 98, 105, 110]); // "#!/bin"
1611
+ })(),
1612
+ Metadata: { "hq-mode": "755" },
1613
+ };
1614
+ const localPath = path.join(tmpRoot, "exec.sh");
1615
+ await downloadFile(makeCtx(), "exec.sh", localPath);
1616
+ // mask to permission bits — the upper bits encode file-type (S_IFREG)
1617
+ // and are not preserved on chmod.
1618
+ const stat = fs.statSync(localPath);
1619
+ // chmodSync still applies the stamp (s3.ts:2160). Node on win32 then
1620
+ // reports 0o666 for every writable file (file-mode-portability.ts:23).
1621
+ expect((stat.mode & 0o777).toString(8)).toBe(process.platform === "win32" ? "666" : "755");
1622
+ });
1623
+ it("rounds-trips multiple modes (0600/0640/0700/0750/0755) via hq-mode", async () => {
1624
+ // Verification report V5 multi-mode pin: every mode collapsed to 0644
1625
+ // because the receiver had no mode signal at all. With \`hq-mode\` in
1626
+ // metadata, all five modes must arrive at their exact source value.
1627
+ for (const octal of ["600", "640", "700", "750", "755"]) {
1628
+ nextGetObjectResponse = {
1629
+ Body: (async function* () {
1630
+ yield new Uint8Array([97]); // "a"
1631
+ })(),
1632
+ Metadata: { "hq-mode": octal },
1633
+ };
1634
+ const localPath = path.join(tmpRoot, `mode-${octal}.bin`);
1635
+ await downloadFile(makeCtx(), `mode-${octal}.bin`, localPath);
1636
+ // Every mode in this list is writable, so win32 stats 0o666 (s3.ts:2160).
1637
+ expect((fs.statSync(localPath).mode & 0o777).toString(8)).toBe(process.platform === "win32" ? "666" : octal);
1638
+ }
1639
+ });
1640
+ it("rejects malformed hq-mode metadata via strict-octal regex (Codex P2)", async () => {
1641
+ // Codex review on PR #24 caught: parseInt(modeOctal, 8) accepts
1642
+ // partial-prefix garbage — "755junk" parses to 0o755 instead of
1643
+ // NaN — so tampered or malformed metadata could still chmod the
1644
+ // local file. Strict regex MUST reject anything that isn't pure
1645
+ // octal digits before parseInt sees it; the file then arrives at
1646
+ // umask default like the legacy back-compat path.
1647
+ const malformed = [
1648
+ "755junk", // trailing garbage — parseInt parses 0o755 pre-fix
1649
+ "0x755", // hex-looking prefix
1650
+ "8", // out-of-octal-range digit
1651
+ "9", // ditto
1652
+ "-755", // signed
1653
+ "abc", // non-numeric
1654
+ "", // empty
1655
+ "7777", // mode > 0o777 after parse
1656
+ "12345", // too long (more than 4 octal digits)
1657
+ " 755 ", // whitespace
1658
+ ];
1659
+ for (const bad of malformed) {
1660
+ nextGetObjectResponse = {
1661
+ Body: (async function* () {
1662
+ yield new Uint8Array([116]); // "t"
1663
+ })(),
1664
+ Metadata: { "hq-mode": bad },
1665
+ };
1666
+ const localPath = path.join(tmpRoot, `bad-${malformed.indexOf(bad)}.bin`);
1667
+ await downloadFile(makeCtx(), `bad-${malformed.indexOf(bad)}.bin`, localPath);
1668
+ // Mode MUST be the umask default (whatever the test process inherits),
1669
+ // NOT a partial-parse of the malformed string. Specifically, even if
1670
+ // the malformed string would partial-parse to 0755, the file must NOT
1671
+ // arrive at 0755 — it must take the umask default. We can't pin the
1672
+ // exact default value (test runner umask varies), but we can pin that
1673
+ // a partial-parse value (0o755) does NOT match for "755junk" cases.
1674
+ const mode = (fs.statSync(localPath).mode & 0o777);
1675
+ // Heuristic: if the parsed mode would have been 0o755, fail loudly.
1676
+ // (umask default on most CI runners is 0o644 or 0o664, never 0o755.)
1677
+ if (bad.startsWith("755") || bad === "0x755") {
1678
+ expect(mode).not.toBe(0o755);
1679
+ }
1680
+ }
1681
+ });
1682
+ it("downloads with default umask permissions when hq-mode metadata is absent (back-compat)", async () => {
1683
+ // Legacy uploads from pre-fix engines have no \`hq-mode\` metadata.
1684
+ // The receiver must NOT crash and must NOT change the mode — let
1685
+ // the OS default apply, mirroring the pre-fix behavior.
1686
+ nextGetObjectResponse = {
1687
+ Body: (async function* () {
1688
+ yield new Uint8Array([108, 101, 103, 97, 99, 121]); // "legacy"
1689
+ })(),
1690
+ Metadata: {},
1691
+ };
1692
+ const localPath = path.join(tmpRoot, "legacy.bin");
1693
+ await expect(downloadFile(makeCtx(), "legacy.bin", localPath)).resolves.toBeDefined();
1694
+ // No assertion on mode — receiver default is whatever umask set.
1695
+ expect(fs.readFileSync(localPath, "utf-8")).toBe("legacy");
1696
+ });
1697
+ it("applies hq-mtime via utimesSync after byte write (5.37.0 — preserve mtime)", async () => {
1698
+ // Round-trip pair to the s3.upload mtime stamp test. The receiver must
1699
+ // set the local file's mtime to the metadata-stamped value AFTER the
1700
+ // byte write, mirroring the chmod-after-write shape from Bug #5.
1701
+ const knownMs = 1_700_000_000_000;
1702
+ nextGetObjectResponse = {
1703
+ Body: (async function* () {
1704
+ yield new Uint8Array([116, 105, 109, 101]); // "time"
1705
+ })(),
1706
+ Metadata: { [FILE_MTIME_META_KEY]: String(knownMs) },
1707
+ };
1708
+ const localPath = path.join(tmpRoot, "mtime-applied.bin");
1709
+ await downloadFile(makeCtx(), "mtime-applied.bin", localPath);
1710
+ const stat = fs.statSync(localPath);
1711
+ // ±50ms tolerance accommodates ms-precision filesystems and the
1712
+ // utimesSync→stat round-trip rounding. macOS APFS reports full ms;
1713
+ // some Linux filesystems round to seconds — guard with tolerance.
1714
+ expect(Math.abs(stat.mtimeMs - knownMs)).toBeLessThanOrEqual(50);
1715
+ });
1716
+ it("rejects malformed hq-mtime metadata via strict-numeric regex", async () => {
1717
+ // Symmetric to the hq-mode Codex P2 lesson: parseInt accepts partial-
1718
+ // prefix garbage ("175junk" → 175). A strict `^[0-9]{1,16}$` regex
1719
+ // BEFORE parseInt rejects empty / signed / decimals / whitespace /
1720
+ // oversized / non-numeric and falls through to "no utimes call,"
1721
+ // leaving the file at write-time mtime — the legacy back-compat path.
1722
+ // NOTE: `-100` is intentionally NOT in this list — Codex PR #27 P2 pointed
1723
+ // out that legitimate epoch values include 0 (Unix epoch) and negatives
1724
+ // (e.g. reproducible-build clamping pre-1970). Negative-but-well-formed
1725
+ // strings are now accepted; see the dedicated round-trip tests below.
1726
+ const malformed = [
1727
+ "175junk", // trailing garbage — parseInt parses 175 pre-fix
1728
+ "abc", // non-numeric
1729
+ "", // empty
1730
+ " 100 ", // whitespace
1731
+ "--100", // double-sign — only ONE optional leading "-" allowed
1732
+ "+100", // explicit plus rejected (regex only allows optional "-")
1733
+ "3.14", // decimal
1734
+ "99999999999999999", // >16 digits
1735
+ ];
1736
+ for (const bad of malformed) {
1737
+ // Establish a known pre-write mtime by writing the file first.
1738
+ const localPath = path.join(tmpRoot, `bad-mtime-${malformed.indexOf(bad)}.bin`);
1739
+ nextGetObjectResponse = {
1740
+ Body: (async function* () {
1741
+ yield new Uint8Array([98]); // "b"
1742
+ })(),
1743
+ Metadata: { [FILE_MTIME_META_KEY]: bad },
1744
+ };
1745
+ const before = Date.now();
1746
+ await downloadFile(makeCtx(), `bad-mtime-${malformed.indexOf(bad)}.bin`, localPath);
1747
+ const stat = fs.statSync(localPath);
1748
+ // The file's mtime MUST be wall-clock-now (write-time), NOT the
1749
+ // partial-parse value. For "175junk", that means mtime is in the
1750
+ // current millis range, not ms=175 (1970-01-01T00:00:00.175Z).
1751
+ // Generic check: mtime is near `before` (within 5s).
1752
+ expect(Math.abs(stat.mtimeMs - before)).toBeLessThan(5000);
1753
+ // Specific check: never the partial-parse epoch (~175ms after epoch).
1754
+ expect(stat.mtimeMs).toBeGreaterThan(1_000_000_000_000);
1755
+ }
1756
+ });
1757
+ it("round-trips mtimeMs === 0 (Unix epoch — Codex PR #27 P2)", async () => {
1758
+ // Codex flagged that filtering `mtimeMs > 0` drops legitimate epoch-0
1759
+ // timestamps (and reproducible-build clamping uses exactly 0). The
1760
+ // receiver must accept "0", parse it, and stamp `new Date(0)` on disk.
1761
+ const sourcePath = path.join(tmpRoot, "epoch-zero-src.bin");
1762
+ fs.writeFileSync(sourcePath, "epoch-bytes");
1763
+ fs.utimesSync(sourcePath, new Date(0), new Date(0));
1764
+ sentCommands.length = 0;
1765
+ await uploadFile(makeCtx(), sourcePath, "epoch-zero.bin");
1766
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
1767
+ const stampedMeta = put.input.Metadata;
1768
+ const stampedBody = put.input.Body;
1769
+ expect(stampedMeta[FILE_MTIME_META_KEY]).toBe("0");
1770
+ fs.unlinkSync(sourcePath);
1771
+ nextGetObjectResponse = {
1772
+ Body: (async function* () {
1773
+ yield new Uint8Array(stampedBody);
1774
+ })(),
1775
+ Metadata: stampedMeta,
1776
+ };
1777
+ await downloadFile(makeCtx(), "epoch-zero.bin", sourcePath);
1778
+ const stat = fs.statSync(sourcePath);
1779
+ // 0 is integer-clean — exact match expected, but allow 50ms tolerance
1780
+ // for any underlying FS rounding shenanigans.
1781
+ expect(Math.abs(stat.mtimeMs - 0)).toBeLessThanOrEqual(50);
1782
+ expect(fs.readFileSync(sourcePath, "utf-8")).toBe("epoch-bytes");
1783
+ });
1784
+ // NTFS cannot store a pre-epoch mtime: fs.utimesSync wraps it (Windows CI
1785
+ // turned -86400000 into 4294880896000) before upload stamps hq-mtime
1786
+ // (s3.ts:1187) and before download applies it (s3.ts:2202). POSIX coverage
1787
+ // of the negative round-trip stays in this test.
1788
+ it.skipIf(process.platform === "win32")("round-trips a negative mtime (pre-epoch — Codex PR #27 P2)", async () => {
1789
+ // Some filesystems / reproducible-build pipelines clamp mtime to values
1790
+ // before the Unix epoch (negative ms). `new Date(-86400000)` is a legal
1791
+ // Date; `fs.utimesSync` accepts it. The receiver MUST NOT drop these.
1792
+ const sourceMs = -86_400_000; // 1969-12-31T00:00:00Z, one day before epoch
1793
+ const sourcePath = path.join(tmpRoot, "pre-epoch-src.bin");
1794
+ fs.writeFileSync(sourcePath, "pre-epoch-bytes");
1795
+ fs.utimesSync(sourcePath, new Date(sourceMs), new Date(sourceMs));
1796
+ sentCommands.length = 0;
1797
+ await uploadFile(makeCtx(), sourcePath, "pre-epoch.bin");
1798
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
1799
+ const stampedMeta = put.input.Metadata;
1800
+ const stampedBody = put.input.Body;
1801
+ expect(stampedMeta[FILE_MTIME_META_KEY]).toBe(String(sourceMs));
1802
+ fs.unlinkSync(sourcePath);
1803
+ nextGetObjectResponse = {
1804
+ Body: (async function* () {
1805
+ yield new Uint8Array(stampedBody);
1806
+ })(),
1807
+ Metadata: stampedMeta,
1808
+ };
1809
+ await downloadFile(makeCtx(), "pre-epoch.bin", sourcePath);
1810
+ const stat = fs.statSync(sourcePath);
1811
+ expect(Math.abs(stat.mtimeMs - sourceMs)).toBeLessThanOrEqual(50);
1812
+ expect(fs.readFileSync(sourcePath, "utf-8")).toBe("pre-epoch-bytes");
1813
+ });
1814
+ // Same NTFS wrap as the pre-epoch round-trip: utimesSync of -100 becomes
1815
+ // 4294967296000 (s3.ts:2202). No other clock setup produces a pre-epoch
1816
+ // stamp on Windows. POSIX coverage stays in this test.
1817
+ it.skipIf(process.platform === "win32")("accepts well-formed negative hq-mtime (e.g. '-100') on download", async () => {
1818
+ // Migration of the old rejection-list case for `-100`. Codex PR #27 P2:
1819
+ // negative epoch-ms values are legitimate; the regex now allows a single
1820
+ // optional leading `-`, and utimesSync handles it.
1821
+ const localPath = path.join(tmpRoot, "negative-mtime.bin");
1822
+ nextGetObjectResponse = {
1823
+ Body: (async function* () {
1824
+ yield new Uint8Array([110]); // "n"
1825
+ })(),
1826
+ Metadata: { [FILE_MTIME_META_KEY]: "-100" },
1827
+ };
1828
+ await downloadFile(makeCtx(), "negative-mtime.bin", localPath);
1829
+ const stat = fs.statSync(localPath);
1830
+ // mtime should be ~ -100 ms, NOT wall-clock-now. The old code would have
1831
+ // left this at write-time; the new code applies the negative stamp.
1832
+ expect(Math.abs(stat.mtimeMs - -100)).toBeLessThanOrEqual(50);
1833
+ });
1834
+ it("downloads with default mtime when hq-mtime metadata is absent (back-compat)", async () => {
1835
+ // Legacy uploads (pre-5.37.0) carry no hq-mtime header. The receiver
1836
+ // must NOT crash and must NOT alter the on-disk mtime away from the
1837
+ // default `fs.writeFileSync` wall-clock-now behavior. Mirrors the
1838
+ // hq-mode back-compat test.
1839
+ nextGetObjectResponse = {
1840
+ Body: (async function* () {
1841
+ yield new Uint8Array([108, 101, 103]); // "leg"
1842
+ })(),
1843
+ Metadata: {},
1844
+ };
1845
+ const before = Date.now();
1846
+ const localPath = path.join(tmpRoot, "legacy-mtime.bin");
1847
+ await downloadFile(makeCtx(), "legacy-mtime.bin", localPath);
1848
+ const stat = fs.statSync(localPath);
1849
+ expect(Math.abs(stat.mtimeMs - before)).toBeLessThan(5000);
1850
+ expect(fs.readFileSync(localPath, "utf-8")).toBe("leg");
1851
+ });
1852
+ it("does NOT call utimesSync on the symlink branch (5.37.0)", async () => {
1853
+ // fs.utimesSync follows symlinks (mutates the target's mtime, not the
1854
+ // link's). On the symlink branch we must skip the utimes block entirely
1855
+ // so we don't accidentally mutate an unrelated target file. The
1856
+ // symlink record's hq-mtime, if any, is ignored — symlink mtime is
1857
+ // OS-controlled and Node has no stable lutimes API. Easiest verifier:
1858
+ // the link is materialized AND the test doesn't crash.
1859
+ const targetPath = path.join(tmpRoot, "untouched-target.txt");
1860
+ fs.writeFileSync(targetPath, "do-not-touch");
1861
+ const knownTargetMs = 1_500_000_000_000;
1862
+ fs.utimesSync(targetPath, new Date(knownTargetMs), new Date(knownTargetMs));
1863
+ const linkPath = path.join(tmpRoot, "the-link");
1864
+ nextGetObjectResponse = {
1865
+ Body: (async function* () {
1866
+ yield Buffer.from(SYMLINK_BODY_PREFIX + "untouched-target.txt");
1867
+ })(),
1868
+ Metadata: {
1869
+ "hq-symlink-target": SYMLINK_MARKER_META_VALUE,
1870
+ // Even if a misbehaving uploader stamped hq-mtime on a symlink
1871
+ // record, the downloader's symlink branch returns BEFORE the
1872
+ // utimes block, so the target's mtime stays at knownTargetMs.
1873
+ [FILE_MTIME_META_KEY]: "1_900_000_000_000",
1874
+ },
1875
+ };
1876
+ await downloadFile(makeCtx(), "the-link", linkPath);
1877
+ expect(fs.lstatSync(linkPath).isSymbolicLink()).toBe(true);
1878
+ expect(fs.readlinkSync(linkPath)).toBe("untouched-target.txt");
1879
+ // Target's mtime is unchanged — utimes block was skipped.
1880
+ const targetStat = fs.statSync(targetPath);
1881
+ expect(Math.abs(targetStat.mtimeMs - knownTargetMs)).toBeLessThanOrEqual(50);
1882
+ });
1883
+ it("round-trips mtime across upload + download (5.37.0 user-visible promise)", async () => {
1884
+ // The whole point of the feature: a file's mtime should follow it
1885
+ // across the wire. Push captures source mtime → metadata; pull applies
1886
+ // metadata → local mtime. This test wires upload's PutObject capture
1887
+ // into download's GetObject response so the contract round-trips end-
1888
+ // to-end through s3.ts without bringing in journal/CLI state.
1889
+ const sourceMs = 1_650_000_000_000; // 2022-04-15T03:33:20Z
1890
+ const sourcePath = path.join(tmpRoot, "round-trip-src.bin");
1891
+ fs.writeFileSync(sourcePath, "round-trip-bytes");
1892
+ fs.utimesSync(sourcePath, new Date(sourceMs), new Date(sourceMs));
1893
+ sentCommands.length = 0;
1894
+ await uploadFile(makeCtx(), sourcePath, "round-trip.bin");
1895
+ const put = sentCommands.find((c) => c.name === "PutObjectCommand");
1896
+ const stampedMeta = put.input.Metadata;
1897
+ const stampedBody = put.input.Body;
1898
+ // Wipe the local copy and pull via download — simulating a different
1899
+ // machine receiving the file.
1900
+ fs.unlinkSync(sourcePath);
1901
+ nextGetObjectResponse = {
1902
+ Body: (async function* () {
1903
+ yield new Uint8Array(stampedBody);
1904
+ })(),
1905
+ Metadata: stampedMeta,
1906
+ };
1907
+ await downloadFile(makeCtx(), "round-trip.bin", sourcePath);
1908
+ const stat = fs.statSync(sourcePath);
1909
+ // Within 100ms — covers FS rounding on both ends of the round-trip.
1910
+ expect(Math.abs(stat.mtimeMs - sourceMs)).toBeLessThanOrEqual(100);
1911
+ expect(fs.readFileSync(sourcePath, "utf-8")).toBe("round-trip-bytes");
1912
+ });
1913
+ it("returns the object's user-metadata (including created-by) for a regular file", async () => {
1914
+ nextGetObjectResponse = {
1915
+ Body: (async function* () {
1916
+ yield new Uint8Array([104, 105]); // "hi"
1917
+ })(),
1918
+ Metadata: { "created-by": "alice@example.com", "created-by-sub": "sub-123" },
1919
+ };
1920
+ const localPath = path.join(tmpRoot, "authored.md");
1921
+ const result = await downloadFile(makeCtx(), "authored.md", localPath);
1922
+ expect(result.metadata?.["created-by"]).toBe("alice@example.com");
1923
+ expect(fs.readFileSync(localPath, "utf-8")).toBe("hi");
1924
+ });
1925
+ it("returns the object's user-metadata for a symlink record", async () => {
1926
+ const localPath = path.join(tmpRoot, "authored-link.md");
1927
+ nextGetObjectResponse = {
1928
+ Body: (async function* () {
1929
+ yield new Uint8Array();
1930
+ })(),
1931
+ Metadata: { "hq-symlink-target": "x", "created-by": "bob@example.com" },
1932
+ };
1933
+ const result = await downloadFile(makeCtx(), "authored-link.md", localPath);
1934
+ expect(result.metadata?.["created-by"]).toBe("bob@example.com");
1935
+ expect(fs.lstatSync(localPath).isSymbolicLink()).toBe(true);
1936
+ });
1937
+ });
1938
+ describe("validateVaultUploadKey — tenant-contained vault key guard", () => {
1939
+ // The direct-S3 STS transport bypasses hq-pro's server-side validateObjectKey
1940
+ // (files-acl.ts), so uploadFile/uploadSymlink must enforce the SAME rules
1941
+ // before the PUT. Incident: a stale doubled local tree
1942
+ // A key is relative to the selected vault root. A nested `companies/`
1943
+ // directory is content, while absolute and traversal spellings remain
1944
+ // invalid regardless of the vault kind.
1945
+ let tmpFile;
1946
+ function makePersonalCtx() {
1947
+ return { ...makeCtx(), uid: "prs_TEST" };
1948
+ }
1949
+ beforeEach(() => {
1950
+ sentCommands.length = 0;
1951
+ tmpFile = path.join(os.tmpdir(), `s3-keyguard-test-${Date.now()}-${Math.random()}.md`);
1952
+ fs.writeFileSync(tmpFile, "hello");
1953
+ });
1954
+ afterEach(() => {
1955
+ try {
1956
+ fs.unlinkSync(tmpFile);
1957
+ }
1958
+ catch {
1959
+ // already gone
1960
+ }
1961
+ });
1962
+ it.each(["company", "personal"])("allows nested companies/ directories in %s vaults", (scope) => {
1963
+ expect(() => validateVaultUploadKey("companies/indigo/audit/chat-skills/x.json", scope)).not.toThrow();
1964
+ });
1965
+ it("allows arbitrarily deep nested companies/ segments in a company vault", () => {
1966
+ expect(() => validateVaultUploadKey("companies/a/companies/b/companies/c/f.md", "company")).not.toThrow();
1967
+ });
1968
+ it.each([
1969
+ ["", "INVALID_KEY_EMPTY"],
1970
+ ["/leading.md", "INVALID_KEY_LEADING_SLASH"],
1971
+ ["folder/", "INVALID_KEY_TRAILING_SLASH"],
1972
+ ["a//b.md", "INVALID_KEY_DOUBLE_SLASH"],
1973
+ ["a/../b.md", "INVALID_KEY_DOT_COMPONENT"],
1974
+ ["../../other-co/secret.md", "INVALID_KEY_DOT_COMPONENT"],
1975
+ ["a/./b.md", "INVALID_KEY_DOT_COMPONENT"],
1976
+ ["bad\x00key.md", "INVALID_KEY_CONTROL_CHARS"],
1977
+ // macOS Finder custom-icon file. Named explicitly because this is the
1978
+ // spelling that reaches the validator in the wild: Finder writes one into
1979
+ // every directory it renders a custom icon for, and the push walker now
1980
+ // excludes them precisely because this throw is unavoidable.
1981
+ ["Icon\r", "INVALID_KEY_CONTROL_CHARS"],
1982
+ ["docs/Icon\r", "INVALID_KEY_CONTROL_CHARS"],
1983
+ ])("validateVaultUploadKey mirrors the server rule set: %j → %s", (key, code) => {
1984
+ expect(() => validateVaultUploadKey(key, "company")).toThrowError(expect.objectContaining({ code }));
1985
+ expect(() => validateVaultUploadKey(key, "personal")).toThrowError(expect.objectContaining({ code }));
1986
+ });
1987
+ it.each([
1988
+ ["companies/indigo/audit/chat-skills/x.json", "company", null],
1989
+ ["bad\x00key.md", "personal", "INVALID_KEY_CONTROL_CHARS"],
1990
+ ["docs/good.md", "personal", null],
1991
+ ])("classifyVaultKey reports the validator outcome without throwing: %j", (key, scope, code) => {
1992
+ expect(classifyVaultKey(key, scope)).toEqual(code === null ? null : expect.objectContaining({ code }));
1993
+ });
1994
+ it("uploadFile PUTs a nested companies/ key into a company (cmp_) vault", async () => {
1995
+ await expect(uploadFile(makeCtx(), tmpFile, "companies/indigo/audit/chat-skills/x.json")).resolves.toBeDefined();
1996
+ expect(sentCommands.length).toBeGreaterThan(0);
1997
+ });
1998
+ it("uploadFile still allows companies/-prefixed keys for a personal (prs_) vault", async () => {
1999
+ await expect(uploadFile(makePersonalCtx(), tmpFile, "companies/indigo/knowledge/x.md")).resolves.toBeDefined();
2000
+ expect(sentCommands.length).toBeGreaterThan(0);
2001
+ });
2002
+ });
2003
+ describe("sweepStaleStagedFiles", () => {
2004
+ let tmpRoot;
2005
+ const HOUR = 60 * 60 * 1000;
2006
+ beforeEach(() => {
2007
+ tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), "hq-sweep-test-"));
2008
+ });
2009
+ afterEach(() => {
2010
+ fs.rmSync(tmpRoot, { recursive: true, force: true });
2011
+ });
2012
+ function makeAged(name, ageMs) {
2013
+ const full = path.join(tmpRoot, name);
2014
+ fs.writeFileSync(full, "x");
2015
+ const stamp = new Date(Date.now() - ageMs);
2016
+ fs.utimesSync(full, stamp, stamp);
2017
+ return full;
2018
+ }
2019
+ it("removes stale .hq-tmp-* and .hq-backup-* files, keeps everything else", () => {
2020
+ const staleTmp = makeAged(".hq-tmp-deadbeef01", 2 * HOUR);
2021
+ const staleBackup = makeAged(".hq-backup-deadbeef02", 2 * HOUR);
2022
+ const freshTmp = makeAged(".hq-tmp-deadbeef03", 0);
2023
+ const ordinary = makeAged("notes.md", 2 * HOUR);
2024
+ // A directory matching the pattern must never be touched.
2025
+ const dirSentinel = path.join(tmpRoot, ".hq-tmp-a-directory");
2026
+ fs.mkdirSync(dirSentinel);
2027
+ const removed = sweepStaleStagedFiles(tmpRoot);
2028
+ expect(removed.sort()).toEqual([staleTmp, staleBackup].sort());
2029
+ expect(fs.existsSync(staleTmp)).toBe(false);
2030
+ expect(fs.existsSync(staleBackup)).toBe(false);
2031
+ expect(fs.existsSync(freshTmp)).toBe(true);
2032
+ expect(fs.existsSync(ordinary)).toBe(true);
2033
+ expect(fs.existsSync(dirSentinel)).toBe(true);
2034
+ });
2035
+ it("returns empty for a missing directory without throwing", () => {
2036
+ expect(sweepStaleStagedFiles(path.join(tmpRoot, "does-not-exist"))).toEqual([]);
2037
+ });
2038
+ it("respects a custom age threshold", () => {
2039
+ const halfHourOld = makeAged(".hq-tmp-halfhour", HOUR / 2);
2040
+ expect(sweepStaleStagedFiles(tmpRoot, HOUR / 4)).toEqual([halfHourOld]);
2041
+ expect(fs.existsSync(halfHourOld)).toBe(false);
2042
+ });
2043
+ it("keeps a validator-bound partial stage pair across the age sweep", () => {
2044
+ const keyHash = crypto
2045
+ .createHash("sha256")
2046
+ .update("projects/resumable.bin")
2047
+ .digest("hex");
2048
+ const stagePath = path.join(tmpRoot, `.hq-tmp-resume-${keyHash}`);
2049
+ const metadataPath = `${stagePath}.json`;
2050
+ fs.writeFileSync(stagePath, "partial");
2051
+ fs.writeFileSync(metadataPath, JSON.stringify({
2052
+ version: 1,
2053
+ keyHash,
2054
+ etag: '"etag-a"',
2055
+ versionId: "version-a",
2056
+ expectedSize: 100,
2057
+ }));
2058
+ const old = new Date(Date.now() - 2 * HOUR);
2059
+ fs.utimesSync(stagePath, old, old);
2060
+ fs.utimesSync(metadataPath, old, old);
2061
+ expect(sweepStaleStagedFiles(tmpRoot)).toEqual([]);
2062
+ expect(fs.readFileSync(stagePath, "utf8")).toBe("partial");
2063
+ expect(fs.existsSync(metadataPath)).toBe(true);
2064
+ });
2065
+ });
2066
+ describe("headRemoteFile storage class", () => {
2067
+ afterEach(() => {
2068
+ nextHeadObjectResponse = { Metadata: {} };
2069
+ });
2070
+ it("surfaces the S3 storage class so push can refuse to fetch an archived body", async () => {
2071
+ // A lifecycle rule moves old session transcripts to DEEP_ARCHIVE. HEAD still
2072
+ // answers (etag, size) but every GET fails with InvalidObjectState 403, so a
2073
+ // push-side conflict that tries to adopt the remote body can never succeed.
2074
+ // The pull side already skips these on storageClass; push needs the same
2075
+ // signal from HEAD.
2076
+ nextHeadObjectResponse = {
2077
+ ETag: '"abc"',
2078
+ ContentLength: 12,
2079
+ LastModified: new Date("2026-08-20T20:24:00Z"),
2080
+ Metadata: {},
2081
+ StorageClass: "DEEP_ARCHIVE",
2082
+ };
2083
+ const head = await headRemoteFile(makeCtx(), "workspace/.session-logs/codex/r.jsonl");
2084
+ expect(head).toMatchObject({ etag: '"abc"', size: 12, storageClass: "DEEP_ARCHIVE" });
2085
+ });
2086
+ it("reports STANDARD when S3 omits the storage class", async () => {
2087
+ nextHeadObjectResponse = { ETag: '"abc"', ContentLength: 1, Metadata: {} };
2088
+ expect((await headRemoteFile(makeCtx(), "a.md"))?.storageClass).toBe("STANDARD");
2089
+ });
2090
+ });
2091
+ //# sourceMappingURL=s3.test.js.map