@ref0/git 0.20.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) hide show
  1. package/dist/access/private-refs.mjs +1 -1
  2. package/dist/auth/access-jwt.mjs +3 -3
  3. package/dist/auth/auth-namespace.d.mts +3 -3
  4. package/dist/auth/auth-namespace.mjs +3 -2
  5. package/dist/auth/auth.d.mts +3 -3
  6. package/dist/auth/auth.mjs +9 -8
  7. package/dist/auth/authorize.mjs +1 -1
  8. package/dist/auth/fences.d.mts +1 -1
  9. package/dist/auth/host-function.mjs +1 -1
  10. package/dist/auth/host-services.mjs +4 -6
  11. package/dist/auth/identify.d.mts +1 -1
  12. package/dist/auth/identify.mjs +6 -0
  13. package/dist/auth/token-cleanup.mjs +2 -2
  14. package/dist/auth/token-rows.mjs +6 -1
  15. package/dist/auth/token-text.mjs +1 -1
  16. package/dist/auth/tokens-base.d.mts +1 -1
  17. package/dist/auth/tokens.d.mts +1 -1
  18. package/dist/auth/tokens.mjs +1 -1
  19. package/dist/client/client.d.mts +15 -7
  20. package/dist/client/client.mjs +21 -12
  21. package/dist/client/git-http.mjs +1 -1
  22. package/dist/client/local.mjs +60 -24
  23. package/dist/client/negotiate.mjs +3 -3
  24. package/dist/client/push-upload.mjs +26 -10
  25. package/dist/client/remote.mjs +4 -3
  26. package/dist/client/run-remote-helper.d.mts +2 -2
  27. package/dist/client/run-remote-helper.mjs +6 -6
  28. package/dist/client/slice-push.d.mts +1 -1
  29. package/dist/client/transport.mjs +3 -3
  30. package/dist/contracts/blobs.d.mts +3 -3
  31. package/dist/contracts/blobs.mjs +1 -1
  32. package/dist/contracts/calls-spent.mjs +5 -33
  33. package/dist/contracts/client.d.mts +15 -14
  34. package/dist/contracts/commits.d.mts +4 -4
  35. package/dist/contracts/commits.mjs +1 -1
  36. package/dist/contracts/engine.d.mts +2 -2
  37. package/dist/contracts/events.d.mts +1 -1
  38. package/dist/contracts/events.mjs +1 -1
  39. package/dist/contracts/files.d.mts +4 -4
  40. package/dist/contracts/files.mjs +1 -1
  41. package/dist/contracts/forks.d.mts +4 -4
  42. package/dist/contracts/forks.mjs +1 -1
  43. package/dist/contracts/git-hooks.d.mts +1 -1
  44. package/dist/contracts/git.d.mts +9 -5
  45. package/dist/contracts/grants.d.mts +1 -1
  46. package/dist/contracts/merges.d.mts +1 -1
  47. package/dist/contracts/object-values.d.mts +1 -0
  48. package/dist/contracts/object-values.mjs +16 -1
  49. package/dist/contracts/objects.d.mts +30 -18
  50. package/dist/contracts/opaque.mjs +1 -1
  51. package/dist/contracts/operations.mjs +1 -1
  52. package/dist/contracts/queue.d.mts +208 -44
  53. package/dist/contracts/queue.mjs +5 -5
  54. package/dist/contracts/refs.d.mts +5 -5
  55. package/dist/contracts/refs.mjs +1 -1
  56. package/dist/contracts/remote.d.mts +3 -6
  57. package/dist/contracts/repos.d.mts +3 -3
  58. package/dist/contracts/repos.mjs +1 -1
  59. package/dist/contracts/result.d.mts +10 -7
  60. package/dist/contracts/result.mjs +8 -3
  61. package/dist/contracts/rules.d.mts +13 -12
  62. package/dist/contracts/server.d.mts +8 -10
  63. package/dist/contracts/services.d.mts +6 -9
  64. package/dist/contracts/services.mjs +1 -2
  65. package/dist/contracts/signin.d.mts +1 -1
  66. package/dist/contracts/store.d.mts +2 -2
  67. package/dist/contracts/sync.d.mts +63 -6
  68. package/dist/contracts/sync.mjs +3 -2
  69. package/dist/contracts/tags.d.mts +3 -3
  70. package/dist/contracts/tags.mjs +1 -1
  71. package/dist/contracts/tokens.d.mts +2 -2
  72. package/dist/contracts/tokens.mjs +1 -1
  73. package/dist/contracts/topics.d.mts +9 -9
  74. package/dist/contracts/trees.d.mts +4 -4
  75. package/dist/contracts/trees.mjs +1 -1
  76. package/dist/contracts/work.d.mts +4 -4
  77. package/dist/contracts/work.mjs +2 -2
  78. package/dist/core/access.d.mts +1 -1
  79. package/dist/core/ancestry.mjs +30 -34
  80. package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
  81. package/dist/core/call-services.mjs +1 -1
  82. package/dist/core/events/deliver.d.mts +2 -2
  83. package/dist/core/events/deliver.mjs +3 -3
  84. package/dist/core/events/retired.mjs +1 -1
  85. package/dist/core/forks.mjs +5 -5
  86. package/dist/core/hooks/groups.mjs +2 -2
  87. package/dist/core/imports.mjs +101 -21
  88. package/dist/core/index-job.mjs +14 -9
  89. package/dist/core/index-lost.d.mts +1 -1
  90. package/dist/core/loose-tally.mjs +38 -15
  91. package/dist/core/merge-parts.d.mts +17 -4
  92. package/dist/core/merge-parts.mjs +7 -2
  93. package/dist/core/mirror-rows.mjs +31 -1
  94. package/dist/core/objects/blobs.mjs +8 -10
  95. package/dist/core/objects/files.mjs +20 -17
  96. package/dist/core/objects/objects-layer.mjs +1 -1
  97. package/dist/core/objects/peel.mjs +1 -7
  98. package/dist/core/objects/reading.mjs +19 -18
  99. package/dist/core/objects/tree-edits.mjs +1 -1
  100. package/dist/core/objects/trees.mjs +257 -58
  101. package/dist/core/objects/writing.mjs +3 -9
  102. package/dist/core/own-writes.mjs +1 -1
  103. package/dist/core/parts.d.mts +8 -1
  104. package/dist/core/parts.mjs +8 -4
  105. package/dist/core/purge.mjs +31 -18
  106. package/dist/core/push.d.mts +2 -2
  107. package/dist/core/push.mjs +145 -98
  108. package/dist/core/receipts.d.mts +2 -2
  109. package/dist/core/receipts.mjs +9 -2
  110. package/dist/core/ref-index-job.mjs +4 -4
  111. package/dist/core/ref-view.mjs +74 -31
  112. package/dist/core/refs.mjs +3 -3
  113. package/dist/core/repack.mjs +25 -30
  114. package/dist/core/repo-info.mjs +1 -1
  115. package/dist/core/repos.mjs +1 -1
  116. package/dist/core/rules/changes.mjs +18 -40
  117. package/dist/core/rules/check.mjs +6 -5
  118. package/dist/core/rules/commit-changes.mjs +114 -58
  119. package/dist/core/rules/context.d.mts +3 -3
  120. package/dist/core/rules/context.mjs +18 -14
  121. package/dist/core/rules/fetch.mjs +1 -1
  122. package/dist/core/rules/protect.mjs +30 -17
  123. package/dist/core/saved-caller-views.d.mts +1 -1
  124. package/dist/core/saved-caller-views.mjs +3 -3
  125. package/dist/core/saved-callers.d.mts +1 -1
  126. package/dist/core/saved-callers.mjs +1 -1
  127. package/dist/core/seam.d.mts +1 -2
  128. package/dist/core/view.d.mts +6 -3
  129. package/dist/core/view.mjs +11 -10
  130. package/dist/core/work.mjs +2 -2
  131. package/dist/engine/allotted-xdiff.mjs +3 -16
  132. package/dist/engine/combined.d.mts +3 -0
  133. package/dist/engine/combined.mjs +200 -185
  134. package/dist/engine/content.d.mts +2 -2
  135. package/dist/engine/content.mjs +1 -1
  136. package/dist/engine/merge.mjs +7 -9
  137. package/dist/engine/reads.d.mts +2 -2
  138. package/dist/engine/reads.mjs +22 -14
  139. package/dist/engine/xdiff.d.mts +1 -1
  140. package/dist/engine/xdiff.mjs +1 -1
  141. package/dist/event-streams/event-streams.d.mts +1 -1
  142. package/dist/event-streams/event-streams.mjs +1 -1
  143. package/dist/event-streams/stream.d.mts +2 -2
  144. package/dist/event-streams/stream.mjs +3 -3
  145. package/dist/extend.d.mts +2 -6
  146. package/dist/extend.mjs +1 -5
  147. package/dist/http/core-parts.mjs +83 -26
  148. package/dist/http/handler.mjs +54 -9
  149. package/dist/http/parts.d.mts +1 -0
  150. package/dist/http/push-upload-job.mjs +138 -24
  151. package/dist/http/push-uploads.mjs +2 -2
  152. package/dist/http/receive-pack.mjs +14 -53
  153. package/dist/http/request-snapshot.mjs +258 -0
  154. package/dist/http/upload-pack.mjs +23 -18
  155. package/dist/index.d.mts +29 -21
  156. package/dist/index.mjs +11 -2
  157. package/dist/lfs/base.d.mts +1 -1
  158. package/dist/lfs/copy.d.mts +49 -1
  159. package/dist/lfs/copy.mjs +135 -22
  160. package/dist/lfs/layer.d.mts +4 -3
  161. package/dist/lfs/layer.mjs +4 -5
  162. package/dist/lfs/locks.mjs +2 -2
  163. package/dist/lfs/objects.d.mts +1 -1
  164. package/dist/lfs/objects.mjs +3 -3
  165. package/dist/lfs/pointers.mjs +1 -1
  166. package/dist/lfs/rows.d.mts +1 -1
  167. package/dist/lfs/rows.mjs +11 -4
  168. package/dist/lfs/upkeep.mjs +40 -9
  169. package/dist/lfs/uploaded.mjs +1 -1
  170. package/dist/lfs/wire.mjs +1 -1
  171. package/dist/merges/merges.mjs +17 -2
  172. package/dist/protocol/bytes/buffers.d.mts +1 -1
  173. package/dist/protocol/bytes/buffers.mjs +1 -1
  174. package/dist/protocol/bytes/deflate.d.mts +1 -1
  175. package/dist/protocol/bytes/deflate.mjs +1 -1
  176. package/dist/protocol/bytes/inflate.d.mts +1 -1
  177. package/dist/protocol/bytes/inflate.mjs +1 -1
  178. package/dist/protocol/bytes/sha1.d.mts +1 -1
  179. package/dist/protocol/bytes/sha1.mjs +1 -1
  180. package/dist/protocol/diff/read.d.mts +2 -1
  181. package/dist/protocol/diff/read.mjs +102 -8
  182. package/dist/protocol/packs/graph.mjs +1 -1
  183. package/dist/protocol/packs/idx.d.mts +1 -1
  184. package/dist/protocol/packs/idx.mjs +1 -1
  185. package/dist/protocol/packs/parts.mjs +1 -1
  186. package/dist/protocol/packs/reader.d.mts +1 -1
  187. package/dist/protocol/packs/reader.mjs +1 -1
  188. package/dist/protocol/packs/write-error.d.mts +1 -1
  189. package/dist/protocol/packs/write-error.mjs +1 -1
  190. package/dist/protocol/packs/writer.mjs +3 -3
  191. package/dist/protocol/wire/advertisement.d.mts +1 -1
  192. package/dist/protocol/wire/advertisement.mjs +3 -2
  193. package/dist/protocol/wire/fetch.d.mts +1 -1
  194. package/dist/protocol/wire/fetch.mjs +1 -1
  195. package/dist/protocol/wire/lines.d.mts +9 -1
  196. package/dist/protocol/wire/lines.mjs +28 -1
  197. package/dist/protocol/wire/push-uploads.mjs +10 -7
  198. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  199. package/dist/protocol/wire/receive-pack.mjs +1 -1
  200. package/dist/protocol/wire/report-status.d.mts +1 -1
  201. package/dist/protocol/wire/report-status.mjs +1 -1
  202. package/dist/protocol/wire/v2.d.mts +1 -1
  203. package/dist/protocol/wire/v2.mjs +1 -1
  204. package/dist/queue/advance.mjs +31 -24
  205. package/dist/queue/base.d.mts +5 -3
  206. package/dist/queue/calls.mjs +5 -5
  207. package/dist/queue/commit.mjs +1 -1
  208. package/dist/queue/host.d.mts +1 -1
  209. package/dist/queue/layer.d.mts +0 -1
  210. package/dist/queue/layer.mjs +9 -5
  211. package/dist/queue/schedule.mjs +1 -1
  212. package/dist/queue/search.mjs +1 -1
  213. package/dist/queue/state.mjs +1 -1
  214. package/dist/queue/trim.mjs +2 -2
  215. package/dist/rest/client.d.mts +1 -1
  216. package/dist/rest/client.mjs +6 -6
  217. package/dist/rest/errors.mjs +1 -1
  218. package/dist/rest/handler.mjs +2 -2
  219. package/dist/rest/handlers.mjs +16 -6
  220. package/dist/rest/layer.mjs +1 -1
  221. package/dist/rest/listen.mjs +2 -2
  222. package/dist/rest/refs.mjs +1 -1
  223. package/dist/server/edge.mjs +27 -3
  224. package/dist/server/git-layer.d.mts +1 -2
  225. package/dist/server/git-layer.mjs +4 -5
  226. package/dist/server/lifecycle.mjs +1 -1
  227. package/dist/server/registry.mjs +2 -8
  228. package/dist/server/server.mjs +62 -43
  229. package/dist/signin/context.d.mts +1 -1
  230. package/dist/signin/context.mjs +1 -1
  231. package/dist/signin/forms.mjs +1 -1
  232. package/dist/signin/grants.d.mts +2 -2
  233. package/dist/signin/grants.mjs +1 -1
  234. package/dist/signin/wire.mjs +1 -1
  235. package/dist/storage/allotted.mjs +4 -9
  236. package/dist/storage/batch-upkeep.mjs +31 -12
  237. package/dist/storage/batches.d.mts +2 -3
  238. package/dist/storage/batches.mjs +52 -49
  239. package/dist/storage/budget.mjs +23 -1
  240. package/dist/storage/calls.d.mts +1 -1
  241. package/dist/storage/calls.mjs +41 -43
  242. package/dist/storage/charged-cache.mjs +180 -0
  243. package/dist/storage/chunks.d.mts +3 -3
  244. package/dist/storage/chunks.mjs +121 -8
  245. package/dist/storage/counted-bucket.mjs +32 -10
  246. package/dist/storage/fetch-row-cache.d.mts +6 -0
  247. package/dist/storage/fetch-row-cache.mjs +211 -0
  248. package/dist/storage/fetch.d.mts +1 -0
  249. package/dist/storage/fetch.mjs +54 -242
  250. package/dist/storage/held-types.d.mts +0 -1
  251. package/dist/storage/held-types.mjs +13 -4
  252. package/dist/storage/host-bucket.mjs +9 -4
  253. package/dist/storage/index-bitmaps.mjs +340 -65
  254. package/dist/storage/index-build.d.mts +2 -3
  255. package/dist/storage/index-build.mjs +274 -56
  256. package/dist/storage/index-fetch.d.mts +3 -1
  257. package/dist/storage/index-fetch.mjs +60 -21
  258. package/dist/storage/index-graph.mjs +1 -1
  259. package/dist/storage/index-layers.mjs +55 -25
  260. package/dist/storage/index-reach.mjs +15 -22
  261. package/dist/storage/index-whole.d.mts +7 -0
  262. package/dist/storage/index-whole.mjs +145 -37
  263. package/dist/storage/largest-files.mjs +1 -7
  264. package/dist/storage/layout.mjs +17 -1
  265. package/dist/storage/lfs-pointers.mjs +1 -6
  266. package/dist/storage/link-join.mjs +55 -16
  267. package/dist/storage/list-source.d.mts +7 -0
  268. package/dist/storage/list-source.mjs +288 -0
  269. package/dist/storage/loose.d.mts +8 -8
  270. package/dist/storage/loose.mjs +157 -91
  271. package/dist/storage/memory-budget.mjs +226 -22
  272. package/dist/storage/merge-cut.mjs +9 -6
  273. package/dist/storage/merge-fence.mjs +1 -1
  274. package/dist/storage/merge-row.mjs +1 -1
  275. package/dist/storage/merge.d.mts +2 -3
  276. package/dist/storage/merge.mjs +2 -2
  277. package/dist/storage/object-rows.d.mts +3 -3
  278. package/dist/storage/object-rows.mjs +179 -38
  279. package/dist/storage/pack-order.mjs +97 -44
  280. package/dist/storage/pack-ranges.mjs +44 -16
  281. package/dist/storage/pack-reads.d.mts +5 -3
  282. package/dist/storage/pack-reads.mjs +236 -72
  283. package/dist/storage/pack-receive.d.mts +1 -2
  284. package/dist/storage/pack-receive.mjs +24 -18
  285. package/dist/storage/packs.d.mts +1 -1
  286. package/dist/storage/packs.mjs +477 -116
  287. package/dist/storage/placed-reads.mjs +33 -16
  288. package/dist/storage/prune-seen.mjs +1 -1
  289. package/dist/storage/prune-walk.mjs +1 -1
  290. package/dist/storage/prune.mjs +4 -31
  291. package/dist/storage/push-allotment.mjs +26 -14
  292. package/dist/storage/push-uploads.mjs +195 -57
  293. package/dist/storage/pushed-commits.mjs +20 -1
  294. package/dist/storage/quarantine.d.mts +2 -3
  295. package/dist/storage/range-cache.mjs +175 -40
  296. package/dist/storage/raw-ids.mjs +39 -10
  297. package/dist/storage/ready.d.mts +2 -3
  298. package/dist/storage/ready.mjs +114 -38
  299. package/dist/storage/receive-bounds.mjs +31 -9
  300. package/dist/storage/receive-cache.d.mts +7 -0
  301. package/dist/storage/receive-cache.mjs +147 -0
  302. package/dist/storage/receive-files.mjs +1 -1
  303. package/dist/storage/receive-links.mjs +1 -1
  304. package/dist/storage/receive-state.d.mts +2 -2
  305. package/dist/storage/receive-state.mjs +6 -8
  306. package/dist/storage/receive-steps.d.mts +20 -0
  307. package/dist/storage/receive-steps.mjs +298 -13
  308. package/dist/storage/repack-backlog.mjs +1 -6
  309. package/dist/storage/repack-contained.mjs +2 -2
  310. package/dist/storage/repack-job.mjs +1 -1
  311. package/dist/storage/repack.d.mts +2 -3
  312. package/dist/storage/repack.mjs +54 -9
  313. package/dist/storage/request-cache.mjs +57 -0
  314. package/dist/storage/roots.mjs +1 -24
  315. package/dist/storage/rows.d.mts +2 -2
  316. package/dist/storage/rows.mjs +1 -1
  317. package/dist/storage/runs.d.mts +2 -2
  318. package/dist/storage/runs.mjs +1 -1
  319. package/dist/storage/send-list.mjs +62 -25
  320. package/dist/storage/stream-whole.mjs +84 -63
  321. package/dist/storage/swap-walk.mjs +1 -1
  322. package/dist/storage/unpack.mjs +878 -450
  323. package/dist/storage/visible.mjs +110 -32
  324. package/dist/storage/walk.mjs +1 -0
  325. package/dist/storage/wants.mjs +22 -58
  326. package/dist/store/call-count.d.mts +2 -2
  327. package/dist/store/call-count.mjs +24 -11
  328. package/dist/store/catalogue.d.mts +1 -1
  329. package/dist/store/catalogue.mjs +19 -7
  330. package/dist/store/crossing.mjs +1 -7
  331. package/dist/store/cursor-seal.d.mts +1 -1
  332. package/dist/store/cursor-seal.mjs +1 -1
  333. package/dist/store/door.mjs +9 -4
  334. package/dist/store/errors.d.mts +2 -2
  335. package/dist/store/errors.mjs +107 -19
  336. package/dist/store/git-store.mjs +7 -2
  337. package/dist/store/job-try.mjs +90 -9
  338. package/dist/store/list-job.mjs +10 -34
  339. package/dist/store/outbox.d.mts +2 -2
  340. package/dist/store/outbox.mjs +2 -2
  341. package/dist/store/queue-jobs.mjs +6 -12
  342. package/dist/store/records.d.mts +2 -2
  343. package/dist/store/records.mjs +2 -2
  344. package/dist/store/ref-rows.d.mts +2 -2
  345. package/dist/store/ref-rows.mjs +2 -2
  346. package/dist/store/repo-record.d.mts +2 -2
  347. package/dist/store/repo-record.mjs +3 -3
  348. package/dist/store/request-snapshot.mjs +5 -0
  349. package/dist/store/reservations.mjs +2 -2
  350. package/dist/store/topic-jobs.mjs +5 -11
  351. package/dist/sync/bound.d.mts +3 -3
  352. package/dist/sync/bound.mjs +10 -7
  353. package/dist/sync/github.mjs +65 -67
  354. package/dist/sync/http.mjs +1 -1
  355. package/dist/sync/import.mjs +201 -66
  356. package/dist/sync/layer.d.mts +1 -1
  357. package/dist/sync/layer.mjs +6 -6
  358. package/dist/sync/lfs-batch.mjs +1 -1
  359. package/dist/sync/lfs-copy.mjs +175 -15
  360. package/dist/sync/mirror.mjs +5 -10
  361. package/dist/sync/said.mjs +1 -1
  362. package/dist/sync/step.mjs +268 -86
  363. package/dist/sync/tries.mjs +25 -6
  364. package/dist/sync.d.mts +2 -2
  365. package/dist/sync.mjs +2 -2
  366. package/dist/topics/advance.mjs +3 -3
  367. package/dist/topics/calls.mjs +1 -1
  368. package/dist/topics/layer.d.mts +15 -14
  369. package/dist/topics/members.mjs +1 -1
  370. package/dist/topics/topic.mjs +1 -1
  371. package/package.json +3 -13
  372. package/dist/auth/helpers.mjs +0 -17
  373. package/dist/auth.d.mts +0 -5
  374. package/dist/auth.mjs +0 -5
  375. package/dist/core/rules/commit-changes.d.mts +0 -12
  376. package/dist/effect.d.mts +0 -9
  377. package/dist/effect.mjs +0 -7
  378. package/dist/server/joined.d.mts +0 -70
  379. package/dist/server/joined.mjs +0 -41
@@ -3,22 +3,21 @@ import { fail } from "../contracts/result.mjs";
3
3
  import { ImportJobData, MirrorJobData, Sync } from "../contracts/sync.mjs";
4
4
  import { SyncBase } from "../core/parts.mjs";
5
5
  import { LfsBase } from "../lfs/base.mjs";
6
- import { withAudienceMemo } from "../core/ref-view.mjs";
7
6
  import { CallBudget } from "../store/call-count.mjs";
8
7
  import { importJobName, mirrorJobName } from "../store/records.mjs";
9
8
  import { importTryTimeout } from "../storage/receive-bounds.mjs";
10
9
  import { SyncState, importLimits } from "./bound.mjs";
11
- import { cancelWith, importWith } from "./import.mjs";
10
+ import { cancelWith, deepenWith, importWith } from "./import.mjs";
12
11
  import { mirrorFailed, mirrorTry, mirrorWith, mirrorsWith, removeMirrorWith } from "./mirror.mjs";
13
12
  import { publishWith } from "./publish.mjs";
14
13
  import { importFailed, importTry } from "./step.mjs";
15
14
  import { syncRetry } from "./tries.mjs";
16
- import * as Effect from "effect/Effect";
17
- import * as HttpClient from "effect/http/HttpClient";
18
- import * as Option from "effect/Option";
19
15
  import { Job } from "@ref0/infra";
16
+ import * as Effect from "effect/Effect";
20
17
  import * as Context from "effect/Context";
21
18
  import * as Layer from "effect/Layer";
19
+ import * as Option from "effect/Option";
20
+ import * as HttpClient from "effect/http/HttpClient";
22
21
  // src/sync/layer.ts
23
22
  const Import = /* @__PURE__ */ Job.make(importJobName, {
24
23
  payload: ImportJobData,
@@ -55,9 +54,10 @@ const layerWith = (options, limits) => Layer.effectContext(Effect.gen(function*
55
54
  };
56
55
  yield* registration.addJob(Import, () => importTry(bound), { onFailure: (_data, failure) => importFailed(bound, failure) });
57
56
  yield* registration.addJob(Mirror, (data) => mirrorTry(bound, data), { onFailure: (data) => mirrorFailed(bound, data) });
58
- const run = (effect) => base.through(withAudienceMemo(Effect.provide(effect, bound.needs)));
57
+ const run = (effect) => base.through(Effect.provide(effect, bound.needs));
59
58
  return Context.make(SyncState, bound).pipe(Context.add(Sync, {
60
59
  import: (input) => run(importWith(bound, input)),
60
+ deepen: (input) => run(deepenWith(bound, input)),
61
61
  cancelImport: (input) => run(cancelWith(bound, input)),
62
62
  mirror: (input) => run(mirrorWith(bound, input)),
63
63
  mirrors: (input) => run(mirrorsWith(bound, input)),
@@ -5,8 +5,8 @@ import { BatchRequest, LfsObjectAnswer } from "../lfs/wire.mjs";
5
5
  import { boundedBytes, dropBody } from "../protocol/bytes/reader.mjs";
6
6
  import { decodeJson } from "../protocol/wire/json.mjs";
7
7
  import { readBody } from "../store/errors.mjs";
8
- import * as Effect from "effect/Effect";
9
8
  import * as Schema from "effect/Schema";
9
+ import * as Effect from "effect/Effect";
10
10
  import * as Result from "effect/Result";
11
11
  /**
12
12
  * The most bytes a batch's answer is read to: one of `lfsBatchMost` objects, each a link and the
@@ -1,17 +1,16 @@
1
1
  import { gitError } from "../contracts/result.mjs";
2
2
  import { importLfsPagesMost, importRow, lfsMissedHeld, lfsPageKey, lfsPageRow, missedCounted, noImportLfs, readLfsPage } from "../core/imports.mjs";
3
3
  import { CoreParts } from "../core/parts.mjs";
4
- import { largestObject } from "../lfs/rows.mjs";
4
+ import { largestObject, lfsCollections } from "../lfs/rows.mjs";
5
5
  import { lfsOidAt, lfsSizeAt, pointersOfRecord, pointersRecords } from "../storage/lfs-pointers.mjs";
6
- import { storeCommit } from "../store/errors.mjs";
6
+ import { bestEffort, storeCommit } from "../store/errors.mjs";
7
7
  import { newChangeId, repoScope } from "../store/scopes.mjs";
8
- import { lfsCopyBytes } from "./bound.mjs";
9
8
  import { letGo, lfsDownloads } from "./lfs-batch.mjs";
10
9
  import { bodyUntil } from "./http.mjs";
11
- import { remoteOf, senderOf } from "./tries.mjs";
10
+ import { forGood, remoteOf, senderOf } from "./tries.mjs";
12
11
  import * as Effect from "effect/Effect";
13
- import * as Result from "effect/Result";
14
12
  import * as Stream from "effect/Stream";
13
+ import * as Result from "effect/Result";
15
14
  // src/sync/lfs-copy.ts
16
15
  /**
17
16
  * `row` with the pointers a segment's receive `found` kept as pages beside it, `put` in the commit
@@ -43,11 +42,11 @@ const withLfsPages = (row, found, copying) => {
43
42
  };
44
43
  /**
45
44
  * What one step asks for: the distinct objects of `pointers` from entry `from`, up to
46
- * `lfsBatchMost` of them, or until the next would take the step past `lfsCopyBytes`, an object
47
- * past it alone; and `end`, the entry after the last taken. An object past `largestObject` is
48
- * never downloaded, so it takes none of the bytes.
45
+ * `lfsBatchMost` of them, or until the next would take the step past `most` bytes, the import's
46
+ * `lfsCopyBytes`, an object past it alone; and `end`, the entry after the last taken. An object
47
+ * past `largestObject` is never downloaded, so it takes none of the bytes.
49
48
  */
50
- const takenFrom = (pointers, from) => {
49
+ const takenFrom = (pointers, from, most) => {
51
50
  const wanted = [];
52
51
  const seen = /* @__PURE__ */ new Set();
53
52
  let bytes = 0;
@@ -58,7 +57,7 @@ const takenFrom = (pointers, from) => {
58
57
  const size = lfsSizeAt(pointers, end);
59
58
  const taking = size > largestObject ? 0 : size;
60
59
  if (wanted.length === 100) break;
61
- if (wanted.length > 0 && bytes + taking > lfsCopyBytes) break;
60
+ if (wanted.length > 0 && bytes + taking > most) break;
62
61
  seen.add(oid);
63
62
  wanted.push({
64
63
  oid,
@@ -119,8 +118,9 @@ const downloaded = /* @__PURE__ */ Effect.fnUntraced(function* (send, offer, sta
119
118
  /**
120
119
  * The copy's commit at `version`: each object in `landed` listed and its staging row dropped,
121
120
  * each in `missed` the record doesn't name yet counted, and named, as `missedCounted` says, and
122
- * the cursor moved to `cursor`, the page's row deleted once it's past. Without a cursor, the
123
- * landed objects alone, as a step that failed partway keeps them, so its next try skips them.
121
+ * the cursor moved to `cursor`, the page's row deleted once it's past, and any object in parts
122
+ * dropped from it. Without a cursor, the landed objects alone, as a step that failed partway keeps
123
+ * them, so its next try skips them.
124
124
  */
125
125
  const committed = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, copy, version, row, lfs, landed, missed, cursor) {
126
126
  const { store } = yield* CoreParts;
@@ -135,8 +135,11 @@ const committed = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, copy, ve
135
135
  page: lfs.page,
136
136
  entry: cursor.end
137
137
  };
138
+ const { copying, ...rest } = lfs;
139
+ const kept = cursor === void 0 && copying !== void 0 ? { copying } : {};
138
140
  const next = {
139
- ...lfs,
141
+ ...rest,
142
+ ...kept,
140
143
  ...moved,
141
144
  copied: lfs.copied + landed.length,
142
145
  bytes: lfs.bytes + landed.reduce((sum, { size }) => sum + size, 0),
@@ -156,8 +159,156 @@ const committed = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, copy, ve
156
159
  ],
157
160
  delete: [...writes.delete, ...passed ? [lfsPageKey(lfs.page)] : []]
158
161
  }))).ok) return yield* Effect.fail(copyRaced());
162
+ const left = copying !== void 0 && !landed.some(({ staging }) => staging.key === copying.key);
163
+ if (cursor !== void 0 && left) yield* leftUpload(copy, copying);
159
164
  return next;
160
165
  });
166
+ /** The stage an object in parts goes to, as the cursor names it. */
167
+ const stagingOf = (copying) => ({
168
+ key: copying.key,
169
+ row: {
170
+ collection: lfsCollections.staging,
171
+ id: copying.staged
172
+ }
173
+ });
174
+ /**
175
+ * An upload in parts the import leaves, aborted, best effort: its staging row has upkeep abort it
176
+ * at its `removeAt` in any case.
177
+ */
178
+ const leftUpload = (copy, copying) => bestEffort(copy.abort(stagingOf(copying), copying.token));
179
+ /** A resume the source answered with other bytes than those from the copy's offset. */
180
+ const cannotResume = (offer, offset, status) => gitError("FAILED_PRECONDITION", `The LFS source at ${new URL(offer.href).host} can't resume object ${offer.oid}: asked for its bytes from ${offset}, it answered ${status} with others`, { hint: "Import from a source whose LFS downloads answer a Range request with 206" });
181
+ /** A 206's `Content-Range` of bytes, as RFC 9110 writes it: `bytes <first>-<last>/<length or *>`. */
182
+ const byteRange = /^bytes (\d+)-(\d+)\/(?:\d+|\*)$/;
183
+ /**
184
+ * Whether an answer of `status` with `contentRange` holds the bytes from `offset`: a 200, the whole
185
+ * object, only from 0, and a 206 only when its `Content-Range` starts at `offset`. Any other 206,
186
+ * one with no range, another unit or another start, holds bytes the copy can't place.
187
+ */
188
+ const resumesAt = (status, contentRange, offset) => {
189
+ if (status === 200) return offset === 0;
190
+ const range = byteRange.exec(contentRange ?? "");
191
+ return status === 206 && range !== null && Number(range[1]) === offset;
192
+ };
193
+ /** An object's upload in parts begun, at its offset 0. */
194
+ const begun = (copy, repo, oid, size) => Effect.map(copy.upload(repo, oid), ({ staging, token, sha256 }) => ({
195
+ oid,
196
+ size,
197
+ key: staging.key,
198
+ staged: staging.row.id,
199
+ token,
200
+ offset: 0,
201
+ parts: [],
202
+ sha256
203
+ }));
204
+ /** The import's record at version `at` with `copying` saved as the copy's progress: its new version. */
205
+ const savedCopying = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, at, row, lfs, copying) {
206
+ const { store } = yield* CoreParts;
207
+ const { copying: _, ...rest } = lfs;
208
+ const next = copying === void 0 ? rest : {
209
+ ...rest,
210
+ copying
211
+ };
212
+ const done = yield* storeCommit(store.commit(repoScope(attempt.internalId), {
213
+ id: newChangeId(),
214
+ expect: at,
215
+ put: [importRow({
216
+ ...row,
217
+ lfs: next
218
+ })]
219
+ }));
220
+ return done.ok ? done.version : yield* Effect.fail(copyRaced());
221
+ });
222
+ /**
223
+ * One step of an object past a step's bytes, copied in parts across tries (#2989): a multipart
224
+ * upload begun at a key of its own, then parts of the bucket's size read from the download, each
225
+ * hashed with SHA-256 as it goes on from the cursor, put, and saved in the record with the hash's
226
+ * state, at most a step's `lfsCopyBytes` of them. A resume asks for the bytes from the cursor's
227
+ * offset, and a source that answers with others fails the import, as no fallback can go on. Once
228
+ * every byte is in, the digest is held to the oid: other bytes are refused, and the upload
229
+ * aborted; the oid's own complete the upload at the start of the next step, its calls its own, and
230
+ * the object lands as any other. An upload the bucket no longer holds, as upkeep's abort at its
231
+ * `removeAt` leaves, is dropped from the cursor, so the next try starts the object again.
232
+ */
233
+ const inParts = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, copy, read, send, offer, missed, cursor) {
234
+ const { internalId, context, bound } = attempt;
235
+ const { row, lfs } = read;
236
+ let { version } = read;
237
+ const earlier = lfs.copying;
238
+ if (earlier !== void 0 && earlier.oid !== offer.oid) yield* leftUpload(copy, earlier);
239
+ let copying = earlier?.oid === offer.oid && (yield* copy.resumable(internalId, stagingOf(earlier), version)) ? earlier : yield* begun(copy, internalId, offer.oid, offer.size);
240
+ const staging = stagingOf(copying);
241
+ const ended = (landed, more) => committed(attempt, copy, version, row, {
242
+ ...lfs,
243
+ copying
244
+ }, landed, [...missed, ...more], cursor);
245
+ const gone = (error) => error.code === "NOT_FOUND" ? Effect.andThen(savedCopying(attempt, version, row, lfs, void 0), Effect.fail(error)) : Effect.fail(error);
246
+ if (copying.offset === copying.size) {
247
+ yield* Effect.catch(copy.complete(staging, copying.token, copying.parts, copying.size), gone);
248
+ return yield* ended([{
249
+ oid: offer.oid,
250
+ size: offer.size,
251
+ staging
252
+ }], []);
253
+ }
254
+ const headers = new Headers(offer.header);
255
+ if (copying.offset > 0) headers.set("range", `bytes=${copying.offset}-`);
256
+ const request = new Request(offer.href, {
257
+ headers,
258
+ signal: context.signal
259
+ });
260
+ const response = yield* Effect.mapError(send(request), () => downloadUnanswered);
261
+ const { body } = response;
262
+ const absent = response.status === 404 || response.status === 410;
263
+ if (absent || response.status === 416) {
264
+ yield* letGo(response);
265
+ const reason = absent ? "not-found" : "other-bytes";
266
+ return yield* ended([], [{
267
+ oid: offer.oid,
268
+ size: offer.size,
269
+ reason
270
+ }]);
271
+ }
272
+ const answered = response.status === 200 || response.status === 206;
273
+ const range = response.headers.get("content-range");
274
+ if (answered && !resumesAt(response.status, range, copying.offset)) {
275
+ yield* letGo(response);
276
+ return yield* forGood(cannotResume(offer, copying.offset, response.status));
277
+ }
278
+ if (!answered || body === null) {
279
+ yield* letGo(response);
280
+ return yield* Effect.fail(downloadRefused(response.status));
281
+ }
282
+ const body$ = Stream.fromReadableStream({
283
+ evaluate: () => bodyUntil(body, context.signal),
284
+ onError: () => downloadUnanswered
285
+ });
286
+ const core = yield* CoreParts;
287
+ const saved = (progress) => savedCopying(attempt, version, row, lfs, {
288
+ ...copying,
289
+ ...progress
290
+ }).pipe(Effect.map((at) => {
291
+ version = at;
292
+ copying = {
293
+ ...copying,
294
+ ...progress
295
+ };
296
+ }), Effect.provideService(CoreParts, core));
297
+ if ((yield* Effect.catch(copy.putParts({
298
+ staging,
299
+ token: copying.token,
300
+ object: offer,
301
+ progress: copying,
302
+ body: body$,
303
+ bytes: bound.limits.lfsCopyBytes,
304
+ saved
305
+ }), gone)) !== "other") return lfs;
306
+ return yield* ended([], [{
307
+ oid: offer.oid,
308
+ size: offer.size,
309
+ reason: "other-bytes"
310
+ }]);
311
+ });
161
312
  /**
162
313
  * Each distinct object of `pointers` from `from` but those `listed`, missing as a source with no
163
314
  * LFS API leaves it: `too-large` for one LFS keeps none of anyway.
@@ -193,7 +344,7 @@ const copyLfs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, r
193
344
  const pointers = pointersOfRecord(yield* readLfsPage(store, internalId, lfs.page));
194
345
  if (pointers === void 0) return yield* Effect.fail(pageUnreadable(lfs.page));
195
346
  yield* reported(context, lfs);
196
- const { wanted, end } = takenFrom(pointers, lfs.entry);
347
+ const { wanted, end } = takenFrom(pointers, lfs.entry, bound.limits.lfsCopyBytes);
197
348
  const listed = yield* copy.listed(internalId, wanted.map(({ oid }) => oid));
198
349
  const unlisted = wanted.filter(({ oid }) => !listed.has(oid));
199
350
  const tooLarge = unlisted.flatMap(({ oid, size }) => size > largestObject ? [{
@@ -224,6 +375,15 @@ const copyLfs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, r
224
375
  size: offer.size,
225
376
  reason: offer.reason
226
377
  });
378
+ const [only] = downloads;
379
+ if (downloads.length === 1 && only !== void 0 && (lfs.copying !== void 0 || only.size > bound.limits.lfsCopyBytes)) return yield* inParts(attempt, copy, {
380
+ version,
381
+ row,
382
+ lfs
383
+ }, send, only, missed, {
384
+ end,
385
+ count: pointers.count
386
+ });
227
387
  const staged = yield* copy.stage(internalId, downloads);
228
388
  const landed = [];
229
389
  for (const [index, offer] of downloads.entries()) {
@@ -259,4 +419,4 @@ const copyLfs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, r
259
419
  count: pointers.count
260
420
  });
261
421
  });
262
- export { copyLfs, takenFrom, withLfsPages };
422
+ export { copyLfs, leftUpload, resumesAt, takenFrom, withLfsPages };
@@ -14,16 +14,15 @@ import { receiveRefs, sendPush } from "../client/remote.mjs";
14
14
  import { oneShotReads } from "../storage/calls.mjs";
15
15
  import { decodeRow, storeCall, storeCommit } from "../store/errors.mjs";
16
16
  import { MirrorRow, destinationText, mirrorJobKey } from "../core/mirror-rows.mjs";
17
- import { notFailed } from "../core/events/deliver.mjs";
18
17
  import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
19
18
  import { asSync, mirrorLimits } from "./bound.mjs";
20
19
  import { readImport } from "../core/imports.mjs";
21
- import { fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, syncObjects, thrownOf, tried, unknownProvider } from "./tries.mjs";
22
- import { CoreParts, ObjectsParts, QueueParts } from "../core/parts.mjs";
23
- import * as Clock from "effect/Clock";
20
+ import { fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, reviveFailedJob, syncObjects, thrownOf, tried, unknownProvider } from "./tries.mjs";
21
+ import { CoreParts, ObjectsParts } from "../core/parts.mjs";
22
+ import { CurrentJob, jsonBytes } from "@ref0/infra";
24
23
  import * as Effect from "effect/Effect";
25
24
  import * as Result from "effect/Result";
26
- import { CurrentJob, isInfraError, jsonBytes } from "@ref0/infra";
25
+ import * as Clock from "effect/Clock";
27
26
  // src/sync/mirror.ts
28
27
  /** How long a mirror waits before it reads its repo's import again, while the import runs. */
29
28
  const importWait = 1e4;
@@ -143,11 +142,7 @@ const mirrorWith = /* @__PURE__ */ Effect.fnUntraced(function* (bound, input) {
143
142
  put: [mirrorRow(ref, row)],
144
143
  jobs: [job]
145
144
  }))).ok) continue;
146
- const { jobs } = yield* QueueParts;
147
- if ((yield* storeCall(jobs.retry(scope, job)).pipe(Effect.catchIf(notFailed, () => Effect.void), Effect.catchIf((error) => isInfraError(error.cause) && error.cause.reason === "compacted", () => Effect.succeed(false)))) === false) {
148
- yield* storeCall(jobs.discard(scope, job)).pipe(Effect.catchIf(notFailed, () => Effect.void));
149
- yield* storeCall(store.add(scope, { jobs: [job] }));
150
- }
145
+ yield* reviveFailedJob(scope, job);
151
146
  return stateOf(input.repo, ref, row);
152
147
  }
153
148
  return yield* contended();
@@ -1,9 +1,9 @@
1
1
  import { tryUnlessSpent } from "../contracts/calls-spent.mjs";
2
2
  import { boundedBytes, dropBody } from "../protocol/bytes/reader.mjs";
3
3
  import { cutWords, utf8 } from "../protocol/bytes/text.mjs";
4
+ import * as Schema from "effect/Schema";
4
5
  import * as Effect from "effect/Effect";
5
6
  import * as Option from "effect/Option";
6
- import * as Schema from "effect/Schema";
7
7
  import * as Result from "effect/Result";
8
8
  import * as Base64 from "effect/encoding/Base64";
9
9
  import * as Base64Url from "effect/encoding/Base64Url";