@ref0/git 0.14.0 → 0.25.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 (492) hide show
  1. package/dist/access/private-refs.mjs +1 -1
  2. package/dist/auth/access-jwt.mjs +4 -4
  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 +4 -4
  8. package/dist/auth/fences.d.mts +1 -2
  9. package/dist/auth/fences.mjs +3 -3
  10. package/dist/auth/grants.mjs +4 -4
  11. package/dist/auth/host-function.mjs +19 -2
  12. package/dist/auth/host-services.mjs +4 -6
  13. package/dist/auth/identify.d.mts +1 -1
  14. package/dist/auth/identify.mjs +9 -3
  15. package/dist/auth/token-cleanup.mjs +67 -0
  16. package/dist/auth/token-rows.mjs +7 -2
  17. package/dist/auth/token-text.mjs +9 -1
  18. package/dist/auth/tokens-base.d.mts +35 -0
  19. package/dist/auth/tokens-base.mjs +13 -0
  20. package/dist/auth/tokens-layer.d.mts +2 -27
  21. package/dist/auth/tokens-layer.mjs +6 -11
  22. package/dist/auth/tokens-public.d.mts +3 -3
  23. package/dist/auth/tokens.d.mts +7 -10
  24. package/dist/auth/tokens.mjs +10 -81
  25. package/dist/client/answer.mjs +21 -42
  26. package/dist/client/client.d.mts +17 -11
  27. package/dist/client/client.mjs +21 -12
  28. package/dist/client/git-http.mjs +18 -8
  29. package/dist/client/local.mjs +74 -37
  30. package/dist/client/negotiate.mjs +3 -3
  31. package/dist/client/push-upload.mjs +34 -17
  32. package/dist/client/remote.mjs +12 -13
  33. package/dist/client/run-remote-helper.d.mts +2 -1
  34. package/dist/client/run-remote-helper.mjs +61 -27
  35. package/dist/client/slice-push.d.mts +1 -1
  36. package/dist/client/transport.mjs +105 -46
  37. package/dist/contracts/blobs.d.mts +58 -11
  38. package/dist/contracts/blobs.mjs +17 -3
  39. package/dist/contracts/call-allowance.d.mts +13 -0
  40. package/dist/contracts/call-allowance.mjs +44 -0
  41. package/dist/contracts/calls-spent.mjs +12 -35
  42. package/dist/contracts/client.d.mts +18 -18
  43. package/dist/contracts/commits.d.mts +28 -28
  44. package/dist/contracts/commits.mjs +1 -1
  45. package/dist/contracts/engine.d.mts +8 -3
  46. package/dist/contracts/engine.mjs +10 -1
  47. package/dist/contracts/events.d.mts +1 -1
  48. package/dist/contracts/events.mjs +1 -1
  49. package/dist/contracts/files.d.mts +14 -14
  50. package/dist/contracts/files.mjs +1 -1
  51. package/dist/contracts/forks.d.mts +21 -21
  52. package/dist/contracts/forks.mjs +1 -1
  53. package/dist/contracts/git-events.d.mts +29 -1
  54. package/dist/contracts/git-hooks.d.mts +2 -2
  55. package/dist/contracts/git.d.mts +30 -5
  56. package/dist/contracts/grants.d.mts +24 -4
  57. package/dist/contracts/handlers.d.mts +1 -1
  58. package/dist/contracts/lfs.d.mts +28 -2
  59. package/dist/contracts/merges.d.mts +3 -2
  60. package/dist/contracts/object-values.d.mts +1 -0
  61. package/dist/contracts/object-values.mjs +16 -1
  62. package/dist/contracts/objects.d.mts +42 -41
  63. package/dist/contracts/opaque.mjs +1 -1
  64. package/dist/contracts/operations.mjs +1 -1
  65. package/dist/contracts/queue.d.mts +247 -55
  66. package/dist/contracts/queue.mjs +8 -9
  67. package/dist/contracts/refs.d.mts +30 -27
  68. package/dist/contracts/refs.mjs +1 -1
  69. package/dist/contracts/remote.d.mts +8 -12
  70. package/dist/contracts/remote.mjs +4 -1
  71. package/dist/contracts/repos.d.mts +32 -141
  72. package/dist/contracts/repos.mjs +6 -4
  73. package/dist/contracts/result.d.mts +40 -18
  74. package/dist/contracts/result.mjs +42 -9
  75. package/dist/contracts/rules.d.mts +2 -2
  76. package/dist/contracts/server.d.mts +25 -52
  77. package/dist/contracts/services.d.mts +6 -9
  78. package/dist/contracts/services.mjs +1 -2
  79. package/dist/contracts/signin.d.mts +1 -1
  80. package/dist/contracts/store.d.mts +7 -6
  81. package/dist/contracts/sync.d.mts +73 -12
  82. package/dist/contracts/sync.mjs +14 -3
  83. package/dist/contracts/tags.d.mts +13 -13
  84. package/dist/contracts/tags.mjs +1 -1
  85. package/dist/contracts/time.d.mts +3 -0
  86. package/dist/contracts/{promises.mjs → time.mjs} +1 -1
  87. package/dist/contracts/tokens.d.mts +17 -19
  88. package/dist/contracts/tokens.mjs +4 -3
  89. package/dist/contracts/topics.d.mts +10 -10
  90. package/dist/contracts/trees.d.mts +16 -16
  91. package/dist/contracts/trees.mjs +1 -1
  92. package/dist/contracts/work.d.mts +28 -17
  93. package/dist/contracts/work.mjs +2 -2
  94. package/dist/core/access.d.mts +1 -2
  95. package/dist/core/access.mjs +20 -9
  96. package/dist/core/ancestry.d.mts +1 -0
  97. package/dist/core/ancestry.mjs +30 -34
  98. package/dist/core/asked.mjs +1 -1
  99. package/dist/core/call-groups.mjs +48 -0
  100. package/dist/core/call-names.mjs +6 -1
  101. package/dist/core/call-services.mjs +11 -3
  102. package/dist/core/events/deliver.d.mts +2 -3
  103. package/dist/core/events/deliver.mjs +45 -38
  104. package/dist/core/events/retired.mjs +119 -0
  105. package/dist/core/forks.mjs +929 -433
  106. package/dist/core/hooks/groups.mjs +3 -3
  107. package/dist/core/imports.mjs +127 -41
  108. package/dist/core/index-job.mjs +131 -38
  109. package/dist/core/index-lost.d.mts +1 -2
  110. package/dist/core/index-lost.mjs +2 -2
  111. package/dist/core/loose-tally.mjs +38 -15
  112. package/dist/core/merge-parts.d.mts +17 -4
  113. package/dist/core/merge-parts.mjs +7 -2
  114. package/dist/core/mirror-rows.mjs +31 -1
  115. package/dist/core/objects/blobs.mjs +127 -3
  116. package/dist/core/objects/files.mjs +20 -17
  117. package/dist/core/objects/lines.mjs +2 -2
  118. package/dist/core/objects/merges.mjs +4 -1
  119. package/dist/core/objects/objects-layer.d.mts +1 -1
  120. package/dist/core/objects/objects-layer.mjs +4 -4
  121. package/dist/core/objects/peel.mjs +1 -7
  122. package/dist/core/objects/reading.mjs +41 -29
  123. package/dist/core/objects/tags.mjs +4 -1
  124. package/dist/core/objects/tree-edits.mjs +1 -1
  125. package/dist/core/objects/trees.mjs +257 -58
  126. package/dist/core/objects/writing.mjs +4 -10
  127. package/dist/core/own-writes.mjs +2 -2
  128. package/dist/core/parts.d.mts +11 -5
  129. package/dist/core/parts.mjs +9 -10
  130. package/dist/core/purge.mjs +310 -93
  131. package/dist/core/push-decide.mjs +2 -0
  132. package/dist/core/push-files.d.mts +1 -1
  133. package/dist/core/push.d.mts +2 -2
  134. package/dist/core/push.mjs +170 -128
  135. package/dist/core/receipts.d.mts +2 -2
  136. package/dist/core/receipts.mjs +17 -5
  137. package/dist/core/ref-index-job.mjs +7 -7
  138. package/dist/core/ref-view.mjs +75 -32
  139. package/dist/core/refs.mjs +7 -7
  140. package/dist/core/registered-rows.mjs +2 -2
  141. package/dist/core/repack.mjs +58 -48
  142. package/dist/core/repo-info.mjs +3 -3
  143. package/dist/core/repos.mjs +21 -9
  144. package/dist/core/rules/changes.mjs +18 -40
  145. package/dist/core/rules/check.mjs +6 -5
  146. package/dist/core/rules/commit-changes.mjs +3 -15
  147. package/dist/core/rules/context.d.mts +3 -3
  148. package/dist/core/rules/context.mjs +18 -14
  149. package/dist/core/rules/fetch.mjs +1 -1
  150. package/dist/core/rules/protect.mjs +30 -17
  151. package/dist/core/saved-caller-views.d.mts +8 -3
  152. package/dist/core/saved-caller-views.mjs +4 -4
  153. package/dist/core/saved-callers.d.mts +19 -2
  154. package/dist/core/saved-callers.mjs +1 -1
  155. package/dist/core/seam.d.mts +17 -28
  156. package/dist/core/seam.mjs +7 -28
  157. package/dist/core/tokens.mjs +1 -1
  158. package/dist/core/view.d.mts +6 -3
  159. package/dist/core/view.mjs +18 -25
  160. package/dist/core/work.mjs +60 -15
  161. package/dist/engine/allotted-xdiff.mjs +3 -16
  162. package/dist/engine/combined.d.mts +3 -0
  163. package/dist/engine/combined.mjs +200 -185
  164. package/dist/engine/content.d.mts +2 -2
  165. package/dist/engine/content.mjs +1 -1
  166. package/dist/engine/failures.mjs +2 -1
  167. package/dist/engine/merge.mjs +7 -9
  168. package/dist/engine/reads.d.mts +2 -2
  169. package/dist/engine/reads.mjs +25 -17
  170. package/dist/engine/xdiff.d.mts +1 -1
  171. package/dist/engine/xdiff.mjs +1 -1
  172. package/dist/event-streams/event-streams.d.mts +1 -1
  173. package/dist/event-streams/event-streams.mjs +1 -1
  174. package/dist/event-streams/stream.d.mts +3 -3
  175. package/dist/event-streams/stream.mjs +39 -16
  176. package/dist/extend.d.mts +2 -7
  177. package/dist/extend.mjs +1 -4
  178. package/dist/http/answers.mjs +8 -5
  179. package/dist/http/core-parts.mjs +169 -96
  180. package/dist/http/handler.mjs +82 -10
  181. package/dist/http/node.d.mts +14 -1
  182. package/dist/http/node.mjs +56 -27
  183. package/dist/http/parts.d.mts +2 -0
  184. package/dist/http/push-upload-job.mjs +165 -47
  185. package/dist/http/push-uploads.mjs +37 -22
  186. package/dist/http/receive-pack.mjs +14 -53
  187. package/dist/http/request-snapshot.mjs +258 -0
  188. package/dist/http/upload-pack.mjs +25 -20
  189. package/dist/index.d.mts +36 -28
  190. package/dist/index.mjs +12 -3
  191. package/dist/lfs/answer.mjs +37 -0
  192. package/dist/lfs/base.d.mts +3 -1
  193. package/dist/lfs/base.mjs +25 -1
  194. package/dist/lfs/copy.d.mts +70 -8
  195. package/dist/lfs/copy.mjs +217 -21
  196. package/dist/lfs/layer.d.mts +19 -4
  197. package/dist/lfs/layer.mjs +25 -13
  198. package/dist/lfs/locks.mjs +3 -3
  199. package/dist/lfs/objects.d.mts +2 -1
  200. package/dist/lfs/objects.mjs +89 -19
  201. package/dist/lfs/pointers.mjs +2 -2
  202. package/dist/lfs/rows.d.mts +1 -1
  203. package/dist/lfs/rows.mjs +50 -9
  204. package/dist/lfs/upkeep.mjs +82 -17
  205. package/dist/lfs/uploaded.mjs +1 -1
  206. package/dist/lfs/wire.mjs +7 -32
  207. package/dist/merges/merges.mjs +19 -4
  208. package/dist/node.d.mts +2 -2
  209. package/dist/protocol/bytes/buffers.d.mts +1 -1
  210. package/dist/protocol/bytes/buffers.mjs +14 -6
  211. package/dist/protocol/bytes/deflate.d.mts +1 -1
  212. package/dist/protocol/bytes/deflate.mjs +1 -1
  213. package/dist/protocol/bytes/inflate.d.mts +1 -1
  214. package/dist/protocol/bytes/inflate.mjs +1 -1
  215. package/dist/protocol/bytes/reader.mjs +6 -1
  216. package/dist/protocol/bytes/sha1.d.mts +1 -1
  217. package/dist/protocol/bytes/sha1.mjs +1 -1
  218. package/dist/protocol/bytes/streams.mjs +27 -1
  219. package/dist/protocol/diff/read.d.mts +6 -4
  220. package/dist/protocol/diff/read.mjs +110 -11
  221. package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
  222. package/dist/protocol/objects/lfs-pointer.mjs +1 -3
  223. package/dist/protocol/objects/links-raw.mjs +24 -10
  224. package/dist/protocol/objects/tag.d.mts +1 -1
  225. package/dist/protocol/objects/tree.mjs +23 -6
  226. package/dist/protocol/packs/delta.d.mts +6 -3
  227. package/dist/protocol/packs/delta.mjs +96 -32
  228. package/dist/protocol/packs/graph.mjs +1 -1
  229. package/dist/protocol/packs/idx.d.mts +3 -2
  230. package/dist/protocol/packs/idx.mjs +23 -4
  231. package/dist/protocol/packs/parts.d.mts +4 -1
  232. package/dist/protocol/packs/parts.mjs +10 -7
  233. package/dist/protocol/packs/reader.d.mts +6 -1
  234. package/dist/protocol/packs/reader.mjs +4 -3
  235. package/dist/protocol/packs/write-error.d.mts +1 -1
  236. package/dist/protocol/packs/write-error.mjs +1 -1
  237. package/dist/protocol/packs/writer.mjs +26 -8
  238. package/dist/protocol/wire/advertisement.d.mts +1 -1
  239. package/dist/protocol/wire/advertisement.mjs +3 -2
  240. package/dist/protocol/wire/fetch.d.mts +1 -1
  241. package/dist/protocol/wire/fetch.mjs +1 -1
  242. package/dist/protocol/wire/lines.d.mts +9 -1
  243. package/dist/protocol/wire/lines.mjs +28 -1
  244. package/dist/protocol/wire/push-uploads.mjs +10 -7
  245. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  246. package/dist/protocol/wire/receive-pack.mjs +1 -1
  247. package/dist/protocol/wire/report-status.d.mts +1 -1
  248. package/dist/protocol/wire/report-status.mjs +1 -1
  249. package/dist/protocol/wire/v2.d.mts +1 -1
  250. package/dist/protocol/wire/v2.mjs +1 -1
  251. package/dist/queue/advance.mjs +48 -44
  252. package/dist/queue/base.d.mts +57 -0
  253. package/dist/queue/base.mjs +44 -0
  254. package/dist/queue/calls.mjs +54 -57
  255. package/dist/queue/commit.mjs +2 -2
  256. package/dist/queue/host.d.mts +2 -16
  257. package/dist/queue/host.mjs +2 -7
  258. package/dist/queue/layer.d.mts +2 -2
  259. package/dist/queue/layer.mjs +19 -8
  260. package/dist/queue/limits.mjs +2 -0
  261. package/dist/queue/push-option.mjs +9 -24
  262. package/dist/queue/schedule.mjs +2 -2
  263. package/dist/queue/search.mjs +1 -1
  264. package/dist/queue/state.mjs +3 -11
  265. package/dist/queue/trim.mjs +6 -4
  266. package/dist/rest/blobs.mjs +29 -5
  267. package/dist/rest/caller.d.mts +4 -4271
  268. package/dist/rest/caller.mjs +4 -0
  269. package/dist/rest/client.d.mts +9 -6
  270. package/dist/rest/client.mjs +25 -8
  271. package/dist/rest/errors.mjs +1 -1
  272. package/dist/rest/handler.mjs +2 -2
  273. package/dist/rest/handlers.mjs +66 -11
  274. package/dist/rest/layer.d.mts +2 -2
  275. package/dist/rest/layer.mjs +6 -13
  276. package/dist/rest/listen.mjs +2 -2
  277. package/dist/rest/me.d.mts +3 -432
  278. package/dist/rest/refs.mjs +1 -1
  279. package/dist/server/check-fetch.mjs +3 -3
  280. package/dist/server/edge-node.d.mts +11 -8
  281. package/dist/server/edge-node.mjs +9 -6
  282. package/dist/server/edge.d.mts +21 -7
  283. package/dist/server/edge.mjs +56 -11
  284. package/dist/server/extension.mjs +1 -1
  285. package/dist/server/git-layer.d.mts +5 -6
  286. package/dist/server/git-layer.mjs +28 -23
  287. package/dist/server/git-namespace.d.mts +4 -3
  288. package/dist/server/git-namespace.mjs +3 -2
  289. package/dist/server/lifecycle.mjs +19 -107
  290. package/dist/server/registry.mjs +24 -13
  291. package/dist/server/server.mjs +249 -371
  292. package/dist/signin/context.d.mts +1 -2
  293. package/dist/signin/context.mjs +1 -1
  294. package/dist/signin/forms.mjs +1 -1
  295. package/dist/signin/grants.d.mts +2 -2
  296. package/dist/signin/grants.mjs +1 -1
  297. package/dist/signin/layer.d.mts +1 -1
  298. package/dist/signin/layer.mjs +1 -1
  299. package/dist/signin/wire.mjs +1 -1
  300. package/dist/storage/allotted.mjs +22 -12
  301. package/dist/storage/batch-upkeep.mjs +293 -0
  302. package/dist/storage/batches.d.mts +7 -0
  303. package/dist/storage/batches.mjs +347 -0
  304. package/dist/storage/budget.mjs +23 -1
  305. package/dist/storage/calls.d.mts +2 -3
  306. package/dist/storage/calls.mjs +166 -182
  307. package/dist/storage/charged-cache.mjs +180 -0
  308. package/dist/storage/chunks.d.mts +9 -0
  309. package/dist/storage/chunks.mjs +410 -0
  310. package/dist/storage/clean-up.mjs +72 -9
  311. package/dist/storage/counted-bucket.mjs +35 -13
  312. package/dist/storage/fetch-row-cache.d.mts +6 -0
  313. package/dist/storage/fetch-row-cache.mjs +211 -0
  314. package/dist/storage/fetch.d.mts +2 -0
  315. package/dist/storage/fetch.mjs +339 -450
  316. package/dist/storage/held-types.d.mts +0 -1
  317. package/dist/storage/host-bucket.mjs +10 -6
  318. package/dist/storage/id-mix.mjs +19 -5
  319. package/dist/storage/index-bitmaps.mjs +86 -51
  320. package/dist/storage/index-build.d.mts +2 -4
  321. package/dist/storage/index-build.mjs +324 -67
  322. package/dist/storage/index-fetch.d.mts +3 -1
  323. package/dist/storage/index-fetch.mjs +163 -83
  324. package/dist/storage/index-files.d.mts +3 -0
  325. package/dist/storage/index-files.mjs +10 -5
  326. package/dist/storage/index-graph.mjs +73 -23
  327. package/dist/storage/index-layers.mjs +55 -25
  328. package/dist/storage/index-reach.mjs +15 -22
  329. package/dist/storage/index-remap.mjs +200 -64
  330. package/dist/storage/index-whole.d.mts +7 -0
  331. package/dist/storage/index-whole.mjs +235 -0
  332. package/dist/storage/largest-files.mjs +1 -7
  333. package/dist/storage/layout.mjs +40 -1
  334. package/dist/storage/lfs-pointers.mjs +1 -6
  335. package/dist/storage/link-join.mjs +55 -16
  336. package/dist/storage/list-source.d.mts +7 -0
  337. package/dist/storage/list-source.mjs +288 -0
  338. package/dist/storage/loose.d.mts +10 -7
  339. package/dist/storage/loose.mjs +293 -82
  340. package/dist/storage/memory-budget.mjs +242 -26
  341. package/dist/storage/merge-cut.mjs +9 -6
  342. package/dist/storage/merge-fence.mjs +1 -1
  343. package/dist/storage/merge-plan.mjs +3 -2
  344. package/dist/storage/merge-row.mjs +8 -2
  345. package/dist/storage/merge-stream.mjs +164 -25
  346. package/dist/storage/merge-walk.mjs +8 -4
  347. package/dist/storage/merge-write.mjs +1 -1
  348. package/dist/storage/merge.d.mts +3 -4
  349. package/dist/storage/merge.mjs +3 -3
  350. package/dist/storage/object-rows.d.mts +4 -3
  351. package/dist/storage/object-rows.mjs +545 -84
  352. package/dist/storage/oid-table.mjs +171 -0
  353. package/dist/storage/pack-order.mjs +104 -47
  354. package/dist/storage/pack-ranges.d.mts +1 -2
  355. package/dist/storage/pack-ranges.mjs +48 -21
  356. package/dist/storage/pack-reads.d.mts +6 -3
  357. package/dist/storage/pack-reads.mjs +378 -98
  358. package/dist/storage/pack-receive.d.mts +2 -3
  359. package/dist/storage/pack-receive.mjs +22 -18
  360. package/dist/storage/packs.d.mts +2 -2
  361. package/dist/storage/packs.mjs +587 -156
  362. package/dist/storage/placed-reads.mjs +34 -17
  363. package/dist/storage/plan-columns.d.mts +4 -0
  364. package/dist/storage/plan-columns.mjs +238 -0
  365. package/dist/storage/prune-keep.mjs +134 -41
  366. package/dist/storage/prune-seen.mjs +1 -1
  367. package/dist/storage/prune-walk.mjs +203 -63
  368. package/dist/storage/prune.mjs +197 -121
  369. package/dist/storage/push-allotment.mjs +116 -25
  370. package/dist/storage/push-uploads.mjs +196 -58
  371. package/dist/storage/pushed-commits.mjs +24 -3
  372. package/dist/storage/quarantine.d.mts +3 -4
  373. package/dist/storage/range-cache.mjs +293 -41
  374. package/dist/storage/raw-ids.mjs +39 -10
  375. package/dist/storage/ready.d.mts +3 -4
  376. package/dist/storage/ready.mjs +121 -43
  377. package/dist/storage/receive-bounds.mjs +50 -13
  378. package/dist/storage/receive-cache.d.mts +7 -0
  379. package/dist/storage/receive-cache.mjs +147 -0
  380. package/dist/storage/receive-files.mjs +1 -1
  381. package/dist/storage/receive-links.mjs +1 -1
  382. package/dist/storage/receive-state.d.mts +2 -2
  383. package/dist/storage/receive-state.mjs +6 -8
  384. package/dist/storage/receive-steps.d.mts +20 -0
  385. package/dist/storage/receive-steps.mjs +298 -13
  386. package/dist/storage/repack-backlog.mjs +1 -3
  387. package/dist/storage/repack-contained.mjs +2 -2
  388. package/dist/storage/repack-job.mjs +1 -1
  389. package/dist/storage/repack.d.mts +3 -4
  390. package/dist/storage/repack.mjs +54 -9
  391. package/dist/storage/request-cache.mjs +57 -0
  392. package/dist/storage/roots.mjs +1 -24
  393. package/dist/storage/rows.d.mts +3 -3
  394. package/dist/storage/rows.mjs +2 -2
  395. package/dist/storage/runs.d.mts +2 -2
  396. package/dist/storage/runs.mjs +196 -44
  397. package/dist/storage/send-list.d.mts +1 -0
  398. package/dist/storage/send-list.mjs +112 -31
  399. package/dist/storage/single-flight.mjs +13 -7
  400. package/dist/storage/stream-whole.mjs +188 -66
  401. package/dist/storage/swap-walk.mjs +1 -1
  402. package/dist/storage/unpack.mjs +919 -199
  403. package/dist/storage/visible.mjs +112 -34
  404. package/dist/storage/walk.mjs +193 -38
  405. package/dist/storage/wants.mjs +27 -63
  406. package/dist/store/bodies.mjs +38 -0
  407. package/dist/store/call-count.d.mts +10 -14
  408. package/dist/store/call-count.mjs +58 -57
  409. package/dist/store/catalogue.d.mts +2 -2
  410. package/dist/store/catalogue.mjs +158 -36
  411. package/dist/store/crossing.mjs +1 -9
  412. package/dist/store/cursor-seal.d.mts +1 -2
  413. package/dist/store/cursor-seal.mjs +17 -7
  414. package/dist/store/door.mjs +188 -0
  415. package/dist/store/errors.d.mts +4 -5
  416. package/dist/store/errors.mjs +119 -49
  417. package/dist/store/git-store.mjs +30 -7
  418. package/dist/store/job-try.mjs +98 -40
  419. package/dist/store/list-job.mjs +32 -20
  420. package/dist/store/outbox.d.mts +2 -2
  421. package/dist/store/outbox.mjs +2 -2
  422. package/dist/store/queue-jobs.mjs +6 -12
  423. package/dist/store/records.d.mts +5 -2
  424. package/dist/store/records.mjs +5 -2
  425. package/dist/store/ref-rows.d.mts +2 -2
  426. package/dist/store/ref-rows.mjs +2 -2
  427. package/dist/store/repo-record.d.mts +2 -3
  428. package/dist/store/repo-record.mjs +34 -22
  429. package/dist/store/request-snapshot.mjs +5 -0
  430. package/dist/store/reservations.mjs +3 -3
  431. package/dist/store/scopes.mjs +11 -0
  432. package/dist/store/settle.mjs +4 -4
  433. package/dist/store/topic-jobs.mjs +5 -11
  434. package/dist/sync/bound.d.mts +3 -3
  435. package/dist/sync/bound.mjs +10 -7
  436. package/dist/sync/github.mjs +67 -69
  437. package/dist/sync/http.mjs +1 -1
  438. package/dist/sync/import.mjs +205 -57
  439. package/dist/sync/layer.d.mts +1 -1
  440. package/dist/sync/layer.mjs +6 -6
  441. package/dist/sync/lfs-batch.mjs +5 -6
  442. package/dist/sync/lfs-copy.mjs +191 -20
  443. package/dist/sync/mirror.mjs +34 -36
  444. package/dist/sync/said.mjs +17 -38
  445. package/dist/sync/step.mjs +292 -102
  446. package/dist/sync/tries.mjs +34 -15
  447. package/dist/sync.d.mts +2 -2
  448. package/dist/sync.mjs +2 -2
  449. package/dist/topics/advance.mjs +12 -13
  450. package/dist/topics/base.d.mts +15 -0
  451. package/dist/topics/base.mjs +8 -0
  452. package/dist/topics/calls.mjs +1 -1
  453. package/dist/topics/host.mjs +1 -1
  454. package/dist/topics/layer.d.mts +17 -21
  455. package/dist/topics/layer.mjs +2 -3
  456. package/dist/topics/members.mjs +4 -4
  457. package/dist/topics/public.d.mts +2 -1
  458. package/dist/topics/topic.mjs +2 -2
  459. package/package.json +5 -14
  460. package/dist/auth/helpers.mjs +0 -17
  461. package/dist/auth.d.mts +0 -5
  462. package/dist/auth.mjs +0 -5
  463. package/dist/contracts/promises.d.mts +0 -39
  464. package/dist/core/call-names.d.mts +0 -3
  465. package/dist/core/clock.mjs +0 -18
  466. package/dist/core/promise.mjs +0 -74
  467. package/dist/core/rules/commit-changes.d.mts +0 -13
  468. package/dist/effect.d.mts +0 -18
  469. package/dist/effect.mjs +0 -16
  470. package/dist/lfs/calls.mjs +0 -26
  471. package/dist/rest/api.d.mts +0 -23
  472. package/dist/rest/blobs.d.mts +0 -833
  473. package/dist/rest/commits.d.mts +0 -3543
  474. package/dist/rest/errors.d.mts +0 -2124
  475. package/dist/rest/events.d.mts +0 -426
  476. package/dist/rest/files.d.mts +0 -1342
  477. package/dist/rest/forks.d.mts +0 -2160
  478. package/dist/rest/handlers.d.mts +0 -8
  479. package/dist/rest/merges.d.mts +0 -477
  480. package/dist/rest/queue.d.mts +0 -5917
  481. package/dist/rest/refs.d.mts +0 -2988
  482. package/dist/rest/repos.d.mts +0 -2567
  483. package/dist/rest/tags.d.mts +0 -1316
  484. package/dist/rest/tokens.d.mts +0 -2614
  485. package/dist/rest/topics.d.mts +0 -2224
  486. package/dist/rest/trees.d.mts +0 -1709
  487. package/dist/rest/work.d.mts +0 -1695
  488. package/dist/server/joined.d.mts +0 -82
  489. package/dist/server/joined.mjs +0 -68
  490. package/dist/server/lifecycle.d.mts +0 -2
  491. package/dist/store/promises.d.mts +0 -11
  492. package/dist/store/promises.mjs +0 -327
@@ -1,4 +1,5 @@
1
1
  import "../contracts/ids.mjs";
2
+ import { objectsReadMost } from "../contracts/object-values.mjs";
2
3
  import { gitError, gitErrorFrom } from "../contracts/result.mjs";
3
4
  import { partialImporter } from "./import.mjs";
4
5
  import { importedPullRefs } from "../contracts/sync.mjs";
@@ -6,33 +7,35 @@ import { push } from "../core/push.mjs";
6
7
  import { refusedLead } from "../client/answer.mjs";
7
8
  import { isRefName } from "../core/names.mjs";
8
9
  import { cutWords, utf8 } from "../protocol/bytes/text.mjs";
10
+ import { readCommit } from "../protocol/objects/commit.mjs";
9
11
  import { negotiate } from "../client/negotiate.mjs";
10
12
  import { discover, fetchTerms, remoteRefsAndHeadOf } from "../client/remote.mjs";
11
- import { objectsFace, oneShotReads, scopedReceiveStep } from "../storage/calls.mjs";
13
+ import { heldOnce, oneShotReads, scopedReader, scopedReceiveStep } from "../storage/calls.mjs";
12
14
  import { isPackId } from "../storage/layout.mjs";
13
15
  import { receiveCutParentsMost } from "../storage/receive-bounds.mjs";
14
16
  import { ReceiveRow, receiveKey, stagedRow } from "../storage/receive-steps.mjs";
15
17
  import { decodeHeld } from "../storage/rows.mjs";
16
18
  import { infiniteDepth } from "../storage/shallow.mjs";
17
- import { decodeRow, storeCall } from "../store/errors.mjs";
18
- import { gitStore } from "../store/git-store.mjs";
19
+ import { decodeRow, storeCall, storeCommit } from "../store/errors.mjs";
20
+ import { tryGitStore } from "../store/git-store.mjs";
19
21
  import { decodeRecord, hostRecordOf } from "../store/catalogue.mjs";
20
22
  import { listJobRow } from "../store/list-job.mjs";
21
23
  import { StoredRepo } from "../store/records.mjs";
22
24
  import { newChangeId, repoScope, selfKey } from "../store/scopes.mjs";
23
25
  import { asSync } from "./bound.mjs";
24
- import { copyLfs, withLfsPages } from "./lfs-copy.mjs";
25
- import { ImportRow, cancelKey, cutKey, cutRow, failedHint, failedRow, importEndDeletes, importKey, importRow, readImport, readTipPages, stoppedTry, tipPageKey, tipPageRow, tipPagesOf, tipRowBytes } from "../core/imports.mjs";
26
- import { ForGood, SyncTryError, forGood, fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, syncObjects, thrownOf, tried } from "./tries.mjs";
26
+ import { copyLfs, leftUpload, withLfsPages } from "./lfs-copy.mjs";
27
+ import { ImportRow, cancelKey, cutKey, cutRow, deepenReceiptPut, failedHint, failedRow, importEndDeletes, importKey, importRow, readImport, readTipPages, startRootsKey, startRootsOf, stoppedDeepen, stoppedTry, tipPageKey, tipPageRow, tipPagesOf, tipRowBytes } from "../core/imports.mjs";
28
+ import { infoReads, repoInfo } from "../core/repo-info.mjs";
29
+ import { ForGood, SyncTryError, forGood, fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, syncObjects, thrownOf, tooManyRoots, tried } from "./tries.mjs";
27
30
  import { currentRepo } from "../store/job-try.mjs";
28
- import { CoreParts, ObjectsParts, overStore } from "../core/parts.mjs";
31
+ import { CoreParts, ObjectsParts } from "../core/parts.mjs";
29
32
  import { importOwner } from "../protocol/wire/lines.mjs";
30
33
  import { repoAccess } from "../core/access.mjs";
31
34
  import { viewAgainOf } from "../core/saved-caller-views.mjs";
32
- import * as Effect from "effect/Effect";
35
+ import { CurrentJob } from "@ref0/infra";
33
36
  import * as Schema from "effect/Schema";
37
+ import * as Effect from "effect/Effect";
34
38
  import * as Result from "effect/Result";
35
- import { CurrentJob } from "@ref0/infra";
36
39
  // src/sync/step.ts
37
40
  /**
38
41
  * One try of `sync.import`: one step of the import, committed with its record, so a try after
@@ -57,7 +60,7 @@ import { CurrentJob } from "@ref0/infra";
57
60
  */
58
61
  /** The deepest a segment's step grows: past it, a segment's history is whole anyway. */
59
62
  const stepMost = 1 << 20;
60
- const shallowRemote = () => gitError("FAILED_PRECONDITION", "The remote is a shallow clone, without its oldest parents", { hint: "Import from a full clone, or run `git fetch --unshallow` in the remote first" });
63
+ const noDeepen = (relative = false) => gitError("FAILED_PRECONDITION", relative ? "The remote doesn't take a relative deepen" : "The remote doesn't take a shallow fetch, so no import of it stops at a depth", { hint: relative ? "Pass 'unshallow: true' to fetch the rest of the history" : "Import it again without a depth" });
61
64
  const tooManyTips = (limits, bytes) => gitError("RESOURCE_EXHAUSTED", `The remote's branches and tags take ${bytes} bytes as refs`, {
62
65
  hint: `An import takes branches and tags of at most ${limits.tipBytes} bytes together, as a repo's refs count them`,
63
66
  context: {
@@ -195,7 +198,7 @@ const readOwn = (attempt) => Effect.flatMap(Effect.service(CoreParts), ({ store
195
198
  * The import's record at `row`, committed at `version` with `deletes`: a commit another beat is read
196
199
  * next try.
197
200
  */
198
- const saved = (attempt, version, row, deletes = [], puts = []) => Effect.flatMap(Effect.service(CoreParts), ({ store }) => storeCall(() => store.commit(repoScope(attempt.internalId), {
201
+ const saved = (attempt, version, row, deletes = [], puts = []) => Effect.flatMap(Effect.service(CoreParts), ({ store }) => storeCommit(store.commit(repoScope(attempt.internalId), {
199
202
  id: newChangeId(),
200
203
  expect: version,
201
204
  put: [importRow(row), ...puts],
@@ -203,35 +206,34 @@ const saved = (attempt, version, row, deletes = [], puts = []) => Effect.flatMap
203
206
  })));
204
207
  const more = { kind: "more" };
205
208
  const endedUnder = () => gitError("FAILED_PRECONDITION", "The import ended while its step ran", { hint: "Its record is no longer running, so the step writes nothing" });
206
- /** The import's record as a guard's read finds it, failing `endedUnder` unless it's running. */
207
- const runningIn = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
209
+ /** The import's record as a guard's read finds it, failing `endedUnder` unless running for `run`. */
210
+ const runningIn = /* @__PURE__ */ Effect.fnUntraced(function* (rows, run) {
208
211
  const [own] = rows ?? [];
209
212
  const row = own === void 0 ? void 0 : yield* decodeRow(ImportRow, own, "Import");
210
- if (row?.state !== "running") return yield* Effect.fail(endedUnder());
213
+ if (row?.state !== "running" || row.deepen?.run !== run) return yield* Effect.fail(endedUnder());
211
214
  return row;
212
215
  });
213
216
  /**
214
- * A step's push guard: the import's record still `running` in the push's own read, so a step whose
215
- * import another write ended since, such as the core's `failed` for a job gone, writes nothing.
217
+ * A step's push guard: the import's record still `running` for `run` in the push's own read, so a
218
+ * step whose import another write ended or superseded writes nothing.
216
219
  */
217
- const stillRunning = {
220
+ const stillRunning = (run) => ({
218
221
  reads: [importKey],
219
- check: (results) => Effect.asVoid(runningIn(results[0]))
220
- };
222
+ check: (results) => Effect.asVoid(runningIn(results[0], run))
223
+ });
221
224
  const cancelledUnder = () => gitError("FAILED_PRECONDITION", "The import was cancelled while it published", { hint: "It moves no more refs, and answers as cancelled" });
222
225
  const pageMovedUnder = () => gitError("UNAVAILABLE", "Another try moved the import's publish past this page first", { hint: "The job tries again, from the page its record names then" });
223
226
  /**
224
- * Publish's push guard for `page`: `stillRunning`, the record's cursor still at `page`, and no
225
- * cancel saved beside the record. So a try that read the record before another's page landed
226
- * never moves the cursor back, and a cancel saved since the try read the import moves no more
227
- * refs, the pages published before it staying, and `import` answers `import-cancelled`. A landing
228
- * keeps `stillRunning` alone: a segment in flight as a cancel commits still lands, and its objects
229
- * stay readable, as `CancelImport` says.
227
+ * Publish's push guard for `page` and optional deepen `run`: `stillRunning(run)`, the record's
228
+ * cursor still at `page`, and no cancel saved beside the record. So a try that read the record
229
+ * before another's page landed or another deepen replaced it never overwrites the newer run, and a
230
+ * cancel saved since moves no more refs. A landing keeps `stillRunning(run)` alone: a segment in
231
+ * flight as a cancel commits still lands, and its objects stay readable, as `CancelImport` says.
230
232
  */
231
- const uncancelled = (page) => ({
232
- reads: [...stillRunning.reads, cancelKey],
233
+ const uncancelled = (page, run) => ({
234
+ reads: [importKey, cancelKey],
233
235
  check: /* @__PURE__ */ Effect.fnUntraced(function* (results) {
234
- if (((yield* runningIn(results[0])).publishedPages ?? 0) !== page) return yield* Effect.fail(pageMovedUnder());
236
+ if (((yield* runningIn(results[0], run)).publishedPages ?? 0) !== page) return yield* Effect.fail(pageMovedUnder());
235
237
  const [cancel] = results[1] ?? [];
236
238
  if (cancel !== void 0) return yield* Effect.fail(cancelledUnder());
237
239
  })
@@ -265,10 +267,61 @@ const pullTips = (refs, own, limits) => {
265
267
  }
266
268
  return kept;
267
269
  };
270
+ /** Which of `oids` are already held in `listed`, checked in batches of `objectsReadMost`. */
271
+ const heldBatched = /* @__PURE__ */ Effect.fnUntraced(function* (objects, listed, oids) {
272
+ const held = /* @__PURE__ */ new Set();
273
+ for (let at = 0; at < oids.length; at += objectsReadMost) {
274
+ const found = yield* heldOnce(objects, listed, { oids: oids.slice(at, at + objectsReadMost) });
275
+ for (const oid of found) held.add(oid);
276
+ }
277
+ return held;
278
+ });
279
+ /** Bytes held at once while reading stored shallow-root commits to seed a deepen's cut. */
280
+ const rootReadBytes = 4194304;
281
+ /**
282
+ * The initial cut for a deepen: every stored parent of every shallow root in `roots`, read from
283
+ * the commits' raw stored bytes within an allotment so storage's `needs` check requires every
284
+ * parent of every unshallowed root before any segment lands or any root moves.
285
+ */
286
+ const cutOfRoots = (objects, listed, roots) => Effect.scoped(Effect.gen(function* () {
287
+ const tooLarge = gitError("RESOURCE_EXHAUSTED", "Shallow root too large", { context: { reason: "too-large" } });
288
+ const reader = yield* scopedReader(objects, listed);
289
+ const bytes = reader.allotment(rootReadBytes, tooLarge);
290
+ const cut = {};
291
+ let total = 0;
292
+ const queue = [...roots];
293
+ while (queue.length > 0) {
294
+ const batch = queue.splice(0, objectsReadMost);
295
+ const read = yield* reader.objects({
296
+ oids: batch,
297
+ bytes
298
+ });
299
+ const leftSet = new Set(read.left);
300
+ for (const oid of batch) {
301
+ if (leftSet.has(oid)) continue;
302
+ const object = read.objects.get(oid);
303
+ if (object !== void 0) bytes.shrink(object.bytes.byteLength);
304
+ const commit = object?.type === "commit" ? readCommit(object.bytes) : void 0;
305
+ if (commit === void 0 || Result.isFailure(commit)) return yield* forGood(gitError("DATA_LOSS", `Shallow root ${oid} unreadable`));
306
+ const { parents } = commit.success;
307
+ if (parents.length === 0) continue;
308
+ total += parents.length;
309
+ if (total > receiveCutParentsMost) return yield* forGood(gitError("RESOURCE_EXHAUSTED", `Over ${receiveCutParentsMost} shallow root parents`, { context: {
310
+ reason: "too-large",
311
+ limit: receiveCutParentsMost
312
+ } }));
313
+ cut[oid] = parents;
314
+ }
315
+ if (read.left.length >= batch.length) return yield* forGood(tooLarge);
316
+ queue.unshift(...read.left);
317
+ }
318
+ return cut;
319
+ }));
268
320
  /**
269
321
  * Step 1: the remote's branches and tags, and their tips, kept in pages beside the import's
270
322
  * record, with the pull requests' heads that fit beside them, in the commit that moves the record
271
- * past the listing.
323
+ * past the listing. For a deepen, also seeds `imports/cut` from the repo's stored shallow roots
324
+ * and adopts no default branch.
272
325
  */
273
326
  const listTips = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, row, remote) {
274
327
  yield* report(attempt.context, "fetch", row);
@@ -286,7 +339,7 @@ const listTips = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version,
286
339
  const { limits } = attempt.bound;
287
340
  if (own > limits.tipBytes) return yield* forGood(tooManyTips(limits, own));
288
341
  const all = [...refs, ...pullTips(listing, own, limits)];
289
- const adopts = head?.startsWith("refs/heads/") === true && refs.has(head) ? head : void 0;
342
+ const adopts = row.deepen === void 0 && head?.startsWith("refs/heads/") === true && refs.has(head) ? head : void 0;
290
343
  const pages = tipPagesOf(all.sort(([a], [b]) => a < b ? -1 : 1), adopts, {
291
344
  bytes: limits.tipPageBytes,
292
345
  most: limits.publishBatch
@@ -295,10 +348,17 @@ const listTips = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version,
295
348
  ...row,
296
349
  tipPages: pages.length,
297
350
  publishedPages: 0,
298
- copied: all.length === 0
351
+ copied: row.deepen === void 0 && all.length === 0
299
352
  };
300
353
  if (adopts !== void 0) listedRow.head = adopts;
301
- yield* saved(attempt, version, listedRow, [], pages.map((tips, page) => tipPageRow(page, tips)));
354
+ const puts = pages.map((tips, page) => tipPageRow(page, tips));
355
+ if (row.deepen !== void 0) {
356
+ const opened = yield* openedRepo(attempt);
357
+ if (opened === void 0) return void 0;
358
+ const initialCut = yield* cutOfRoots(syncObjects(yield* ObjectsParts), opened.listed, row.roots);
359
+ if (Object.keys(initialCut).length > 0) puts.push(cutRow(row.roots, initialCut));
360
+ }
361
+ yield* saved(attempt, version, listedRow, [], puts);
302
362
  return more;
303
363
  });
304
364
  /**
@@ -306,6 +366,20 @@ const listTips = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version,
306
366
  * check's refusal answers no: a defect in it stays a defect.
307
367
  */
308
368
  const deepens = (upload) => Effect.isSuccess(fetchTerms(upload, { depth: 1 }));
369
+ /** Most unreachable shallow root OIDs named verbatim in `unreachableRoots`' error message. */
370
+ const unreachableRootsMost = 8;
371
+ /** Typed refusal when the remote cannot serve history behind one or more hosted shallow roots. */
372
+ const unreachableRoots = (roots) => {
373
+ const shown = roots.slice(0, unreachableRootsMost).join(", ");
374
+ const rest = roots.length > unreachableRootsMost ? ` (+${roots.length - unreachableRootsMost} more)` : "";
375
+ return gitError("FAILED_PRECONDITION", `Remote cannot serve shallow root(s): ${shown}${rest}`, {
376
+ hint: "Pass a source with these commits",
377
+ context: {
378
+ reason: "shallow-roots-unreachable",
379
+ total: roots.length
380
+ }
381
+ });
382
+ };
309
383
  /** The pack as it arrives, counted, and stopped once it runs past `most` bytes. */
310
384
  const counted = (bytes, most) => {
311
385
  const seen = {
@@ -373,8 +447,10 @@ const stepAfter = (step, bytes, most) => bytes < most / 4 ? Math.min(step * 2, s
373
447
  * objects alone with the import's record moved past it in the same commit. Its oldest commits, the
374
448
  * remote's `shallow` lines, are its boundary: their parents a later segment brings, so only they
375
449
  * may be absent, and every other link is checked as a whole push's is. A remote that takes no
376
- * deepen sends the whole history in one segment, with no boundary. One whose roots stay as they
377
- * were is itself shallow, and fails the import for good. The parents a boundary left out are kept
450
+ * deepen sends the whole history in one segment, with no boundary, and fails an import with a
451
+ * `depth` for good. A segment as deep as `depth`, or one whose roots stay as they were, the remote
452
+ * being a shallow clone itself, is the last: its roots are the repo's, which publish writes. The
453
+ * parents a boundary left out are kept
378
454
  * as the import's cut, in the commit that lands the segment, and the segment after which their
379
455
  * root is no longer one needs them, in its pack or the repo, whatever its answer claims, so no ref
380
456
  * is published on a commit whose parents the repo lacks.
@@ -387,51 +463,118 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
387
463
  const tips = [...new Set(listed.flatMap((page) => Object.values(page)))];
388
464
  const opened = yield* openedRepo(attempt);
389
465
  if (opened === void 0) return void 0;
390
- const objects = objectsFace(syncObjects(yield* ObjectsParts));
466
+ const objects = syncObjects(yield* ObjectsParts);
391
467
  yield* report(context, "fetch", row);
392
468
  const { http, heard } = yield* httpOf(remote, keptFieldsOf(bound, row.source));
393
469
  const upload = yield* Effect.mapError(discover(http), advertisedFrom(remote, "advertise its refs", heard));
394
470
  const shallow = yield* deepens(upload);
395
- const wanted = row.deepest + row.step;
396
- const request = {
397
- wants: tips,
398
- shallows: [...row.roots],
399
- includeTag: false
400
- };
401
- if (shallow) request.depth = wanted;
402
- const terms = yield* fetchTerms(upload, shallow ? { depth: wanted } : {});
403
- const negotiated = yield* negotiate({
471
+ const deepening = row.deepen;
472
+ if (!shallow && (deepening === void 0 ? row.depth !== void 0 : deepening.more !== void 0)) return yield* forGood(noDeepen());
473
+ const relative = deepening !== void 0 && shallow && (yield* Effect.isSuccess(fetchTerms(upload, { deepen: 1 }, true)));
474
+ const rootsWithParents = deepening === void 0 ? [] : row.roots.filter((oid) => (cut[oid]?.length ?? 0) > 0);
475
+ const missingParents = [...new Set(rootsWithParents.flatMap((oid) => cut[oid] ?? []))];
476
+ const tipSet = new Set(tips);
477
+ const canWantParents = missingParents.length > 0 && (upload.version === "v2" || upload.capabilities.includes("allow-tip-sha1-in-want") || upload.capabilities.includes("allow-reachable-sha1-in-want") || missingParents.every((oid) => tipSet.has(oid)));
478
+ const deepenStep = deepening?.more === void 0 ? row.step : Math.min(row.step, deepening.more - row.deepest);
479
+ const runNegotiate = (req, reqTerms, useHeld) => negotiate({
404
480
  http,
405
481
  version: upload.version,
406
- ...terms,
482
+ ...reqTerms,
407
483
  ofsDelta: false,
408
- request,
484
+ request: req,
409
485
  objects: oneShotReads(objects),
410
486
  listed: opened.listed,
411
- tips: [...new Set(opened.refs.values())],
412
- held: row.deepest > 0 ? tips : []
413
- }).pipe(Effect.mapError(fromRemote("negotiate a fetch", heard)));
487
+ tips: !useHeld ? [] : deepening === void 0 ? [...new Set(opened.refs.values())] : shallow ? [.../* @__PURE__ */ new Set([...opened.refs.values(), ...row.roots])] : [],
488
+ held: useHeld && row.deepest > 0 && shallow ? tips : []
489
+ });
490
+ let negotiated;
491
+ let nextDeepest = infiniteDepth;
492
+ let reachedTarget = true;
493
+ let canHalve = false;
494
+ let parentAnchored = false;
495
+ if (deepening?.more !== void 0 && !relative && tips.length > 0 && !canWantParents) return yield* forGood(noDeepen(true));
496
+ const negotiateError = fromRemote("negotiate a fetch", heard);
497
+ if (deepening === void 0 || tips.length > 0 && (relative || deepening.more === void 0)) {
498
+ const request = {
499
+ wants: tips,
500
+ shallows: shallow ? [...row.roots] : [],
501
+ includeTag: false
502
+ };
503
+ let terms;
504
+ if (deepening === void 0) {
505
+ const asked = row.depth ?? 2147483647;
506
+ const wanted = Math.min(row.deepest + row.step, asked);
507
+ if (shallow) request.depth = wanted;
508
+ terms = yield* fetchTerms(upload, shallow ? { depth: wanted } : {});
509
+ nextDeepest = shallow ? wanted : infiniteDepth;
510
+ reachedTarget = wanted >= asked;
511
+ canHalve = shallow;
512
+ } else if (relative) {
513
+ request.depth = deepenStep;
514
+ request.deepenRelative = true;
515
+ terms = yield* fetchTerms(upload, { deepen: deepenStep }, true);
516
+ nextDeepest = row.deepest + deepenStep;
517
+ reachedTarget = deepening.more !== void 0 && nextDeepest >= deepening.more;
518
+ canHalve = true;
519
+ } else {
520
+ if (shallow) request.depth = infiniteDepth;
521
+ terms = yield* fetchTerms(upload, shallow ? { unshallow: true } : {}, shallow);
522
+ }
523
+ negotiated = yield* runNegotiate(request, terms, true).pipe(Effect.mapError(negotiateError));
524
+ }
525
+ if (deepening !== void 0) {
526
+ const unshallowed = new Set(negotiated?.unshallow ?? []);
527
+ const uncovered = rootsWithParents.filter((oid) => !unshallowed.has(oid));
528
+ if (negotiated === void 0 || uncovered.length > 0) {
529
+ negotiated?.pack.cancel();
530
+ const missed = uncovered.length > 0 ? uncovered : row.roots;
531
+ if (!canWantParents) return yield* forGood(unreachableRoots(missed));
532
+ const depth = shallow ? deepenStep : void 0;
533
+ const parentRequest = {
534
+ wants: missingParents,
535
+ shallows: [],
536
+ includeTag: false
537
+ };
538
+ if (depth !== void 0) parentRequest.depth = depth;
539
+ const parentTerms = yield* fetchTerms(upload, depth !== void 0 ? { depth } : {});
540
+ nextDeepest = shallow ? row.deepest + deepenStep : infiniteDepth;
541
+ reachedTarget = !shallow || deepening.more !== void 0 && nextDeepest >= deepening.more;
542
+ canHalve = shallow;
543
+ negotiated = yield* runNegotiate(parentRequest, parentTerms, false).pipe(Effect.catchIf((error) => error.code === "FAILED_PRECONDITION", () => forGood(unreachableRoots(missed))), Effect.mapError((error) => error instanceof ForGood ? error : negotiateError(error)));
544
+ parentAnchored = true;
545
+ }
546
+ }
547
+ if (negotiated === void 0) return yield* forGood(unreachableRoots(row.roots));
414
548
  yield* report(context, "receive", row);
415
549
  const { pack } = negotiated;
416
550
  const { stream, seen } = counted(pack.bytes, most);
417
- const roots = shallow ? rootsAfter(row.roots, negotiated) : [];
551
+ const roots = !shallow ? [] : parentAnchored ? rootsAfter(row.roots, {
552
+ shallow: negotiated.shallow,
553
+ unshallow: rootsWithParents
554
+ }) : rootsAfter(row.roots, negotiated);
418
555
  if (roots.length > bound.limits.rootsMost) {
419
556
  pack.cancel();
420
- return yield* forGood(gitError("RESOURCE_EXHAUSTED", `An import takes at most ${bound.limits.rootsMost} shallow roots`, { context: {
421
- reason: "too-large",
422
- limit: bound.limits.rootsMost
423
- } }));
424
- }
425
- if (roots.length > 0 && row.roots.length > 0 && sameRoots(roots, row.roots)) {
426
- pack.cancel();
427
- return yield* forGood(shallowRemote());
557
+ return yield* forGood(tooManyRoots(bound.limits.rootsMost));
428
558
  }
429
- const copied = roots.length === 0;
559
+ const copied = roots.length === 0 || reachedTarget || deepening === void 0 && row.roots.length > 0 && sameRoots(roots, row.roots);
430
560
  const pushedPack = {
431
561
  bytes: stream,
432
562
  objects: pack.objects
433
563
  };
434
- if (shallow && negotiated.shallow.length > 0) pushedPack.boundary = negotiated.shallow;
564
+ const beforeRoots = new Set(row.roots);
565
+ const candidateBoundary = shallow ? negotiated.shallow.filter((oid) => !beforeRoots.has(oid)) : [];
566
+ let boundary = candidateBoundary;
567
+ if (candidateBoundary.length > 0) boundary = yield* Effect.gen(function* () {
568
+ const heldInRepo = yield* heldBatched(objects, opened.listed, candidateBoundary);
569
+ const inRepo = candidateBoundary.filter((oid) => heldInRepo.has(oid));
570
+ if (inRepo.length === 0) return candidateBoundary;
571
+ const parentsByRoot = yield* cutOfRoots(objects, opened.listed, inRepo);
572
+ const allParents = [...new Set(Object.values(parentsByRoot).flat())];
573
+ const heldParents = yield* heldBatched(objects, opened.listed, allParents);
574
+ const complete = new Set(inRepo.filter((oid) => (parentsByRoot[oid] ?? []).every((p) => heldParents.has(p))));
575
+ return candidateBoundary.filter((oid) => !complete.has(oid));
576
+ }).pipe(Effect.onError(() => Effect.sync(() => pack.cancel())));
577
+ if (boundary.length > 0) pushedPack.boundary = boundary;
435
578
  const { needs, kept } = carriedCut(row.roots, roots, cut);
436
579
  if (needs.length > 0) pushedPack.needs = needs;
437
580
  pushedPack.cutMost = kept.reduce((left, [, parents]) => left - parents.length, receiveCutParentsMost);
@@ -440,7 +583,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
440
583
  const next = () => ({
441
584
  ...fetched,
442
585
  roots,
443
- deepest: shallow ? wanted : infiniteDepth,
586
+ deepest: nextDeepest,
444
587
  step: stepAfter(row.step, seen.bytes, most),
445
588
  copied,
446
589
  objects: row.objects + pack.objects,
@@ -480,7 +623,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
480
623
  jobs: []
481
624
  };
482
625
  },
483
- guard: stillRunning,
626
+ guard: stillRunning(row.deepen?.run),
484
627
  signal: stopped.signal
485
628
  });
486
629
  const pushed = yield* Effect.result(sent.pipe(Effect.mapError((error) => {
@@ -498,7 +641,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
498
641
  if (final !== void 0) return yield* forGood(final);
499
642
  const refused = failure.code === "RESOURCE_EXHAUSTED" && halvedReasons.has(failure.context?.reason);
500
643
  if (!seen.over && !refused) return yield* Effect.fail(failure);
501
- if (!shallow || row.step === 1) return yield* forGood(seen.over ? overBudget(most) : leastRefused(failure, shallow));
644
+ if (!canHalve || row.step === 1) return yield* forGood(seen.over ? overBudget(most) : leastRefused(failure, canHalve));
502
645
  return yield* unstaged(attempt, row, { step: halvedStep(row) }, halvingRaced);
503
646
  });
504
647
  /** The fields of `row` a segment's landing writes, as its fetch made them. */
@@ -523,7 +666,7 @@ const staged = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, stagin
523
666
  if (!isPackId(pack)) return yield* Effect.fail(unsteppedPack(pack));
524
667
  const read = yield* readOwn(attempt);
525
668
  const now = read.row;
526
- const same = now?.state === "running" && now.step === row.step && now.deepest === row.deepest;
669
+ const same = now?.state === "running" && now.deepen?.run === row.deepen?.run && now.step === row.step && now.deepest === row.deepest;
527
670
  if (read.cancelled || now === void 0 || !same || now.receiving !== void 0) return;
528
671
  if (!(yield* saved(attempt, read.version, {
529
672
  ...now,
@@ -540,7 +683,7 @@ const staged = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, stagin
540
683
  */
541
684
  const receiveJoining = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, pack) {
542
685
  const { store } = yield* CoreParts;
543
- const held = (yield* storeCall(() => store.read(repoScope(attempt.internalId), [receiveKey(pack)]))).results[0]?.[0];
686
+ const held = (yield* storeCall(store.read(repoScope(attempt.internalId), [receiveKey(pack)]))).results[0]?.[0];
544
687
  if (held === void 0) return false;
545
688
  const { value } = yield* decodeHeld(ReceiveRow, held);
546
689
  return value.phase === "joining";
@@ -562,7 +705,7 @@ const resumedIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, rec
562
705
  const { pack, lands } = receiving;
563
706
  const { needs, kept } = carriedCut(row.roots, lands.roots, cut);
564
707
  const input = {
565
- store: gitStore((yield* CoreParts).store),
708
+ store: yield* tryGitStore((yield* CoreParts).store),
566
709
  pack,
567
710
  objects: lands.objects - row.objects
568
711
  };
@@ -611,7 +754,7 @@ const resumedIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, rec
611
754
  jobs: []
612
755
  };
613
756
  },
614
- guard: stillRunning
757
+ guard: stillRunning(row.deepen?.run)
615
758
  });
616
759
  return more;
617
760
  });
@@ -642,7 +785,7 @@ const stageGoneAgain = () => gitError("FAILED_PRECONDITION", "Clean-up ended the
642
785
  const unstaged = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, next, raced) {
643
786
  const read = yield* readOwn(attempt);
644
787
  const now = read.row;
645
- const same = now?.state === "running" && now.step === row.step && now.deepest === row.deepest;
788
+ const same = now?.state === "running" && now.deepen?.run === row.deepen?.run && now.step === row.step && now.deepest === row.deepest;
646
789
  if (read.cancelled || now === void 0 || !same) return more;
647
790
  const { receiving, restaged: _restaged, ...rest } = now;
648
791
  const deletes = receiving === void 0 ? [] : [receiveKey(receiving.pack)];
@@ -687,16 +830,56 @@ const publishGuard = (read, page) => {
687
830
  };
688
831
  };
689
832
  /**
690
- * Step 3: the next page's refs moved to their tips, in one atomic commit that moves the record's
691
- * cursor past the page and deletes it. The last page's marks the import done instead, with the
692
- * remote's default branch made the repo's when it's one of the tips, which the listing put on that
693
- * page. A ref another write moved first fails the try, and the next moves the page's refs from
694
- * where they are then; a refusal of another kind fails it with that ref's own error.
833
+ * Step 3: for a deepen, moves the repo's shallow roots in one atomic write via `rootsMoved`
834
+ * (moving no ref and adopting no default branch), marks the deepen done, and cleans up temporary
835
+ * import keys. For an initial import, moves the next page's refs to their tips, writing the
836
+ * import's roots on the first page and adopting the remote's default branch on the last.
695
837
  */
696
- const publish = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row) {
838
+ const publish = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, caller) {
697
839
  const opened = yield* openedRepo(attempt);
698
840
  if (opened === void 0) return void 0;
699
841
  const { store } = yield* CoreParts;
842
+ const baseRequest = {
843
+ caller: attempt.bound.caller,
844
+ repo: opened.name,
845
+ internalId: attempt.internalId,
846
+ source: "import",
847
+ as: importOwner,
848
+ atomic: true
849
+ };
850
+ if (row.deepen !== void 0) {
851
+ const { deepen } = row;
852
+ const [startRootsRows, ...infoResults] = (yield* storeCall(store.read(repoScope(attempt.internalId), [startRootsKey, ...deepen.receipt !== void 0 ? infoReads : []]))).results;
853
+ const startRoots = yield* startRootsOf(startRootsRows).pipe(Effect.catchIf((error) => error.code === "DATA_LOSS", forGood));
854
+ yield* report(attempt.context, "publish", row);
855
+ const startSet = new Set(startRoots);
856
+ const finalSet = new Set(row.roots);
857
+ const shallow = row.roots.filter((oid) => !startSet.has(oid));
858
+ const unshallow = startRoots.filter((oid) => !finalSet.has(oid));
859
+ const receiptPut = deepen.receipt === void 0 ? [] : deepenReceiptPut(deepen, { info: {
860
+ ...yield* repoInfo(caller, attempt.internalId, opened.record, infoResults),
861
+ shallow: row.roots.length > 0
862
+ } });
863
+ yield* push({
864
+ ...baseRequest,
865
+ edits: [],
866
+ roots: {
867
+ shallow,
868
+ unshallow,
869
+ sent: startRoots
870
+ },
871
+ also: () => ({
872
+ put: [importRow({
873
+ ...row,
874
+ state: "done"
875
+ }), ...receiptPut],
876
+ delete: importEndDeletes(row),
877
+ jobs: []
878
+ }),
879
+ guard: uncancelled(0, deepen.run)
880
+ }).pipe(Effect.catchIf((error) => error.code === "FAILED_PRECONDITION" && error.context?.reason === "changed-while-checked" || error.code === "RESOURCE_EXHAUSTED", forGood));
881
+ return;
882
+ }
700
883
  const page = row.publishedPages ?? 0;
701
884
  const pages = row.tipPages ?? 0;
702
885
  const last = page + 1 >= pages;
@@ -715,14 +898,9 @@ const publish = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row) {
715
898
  to
716
899
  }];
717
900
  });
718
- const rejected = (yield* push({
719
- caller: attempt.bound.caller,
720
- repo: opened.name,
721
- internalId: attempt.internalId,
722
- source: "import",
723
- as: importOwner,
901
+ const request = {
902
+ ...baseRequest,
724
903
  edits,
725
- atomic: true,
726
904
  also: (at) => {
727
905
  const cursor = importRow(last ? {
728
906
  ...next,
@@ -750,7 +928,13 @@ const publish = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row) {
750
928
  };
751
929
  },
752
930
  guard: publishGuard(adopting?.read, page)
753
- })).updates.flatMap((update) => update.kind === "rejected" ? [update] : []);
931
+ };
932
+ if (page === 0 && row.roots.length > 0) request.roots = {
933
+ shallow: row.roots,
934
+ unshallow: [],
935
+ sent: []
936
+ };
937
+ const rejected = (yield* push(request)).updates.flatMap((update) => update.kind === "rejected" ? [update] : []);
754
938
  const [first] = rejected;
755
939
  if (first === void 0) return last ? void 0 : more;
756
940
  const now = (yield* openedRepo(attempt))?.refs;
@@ -765,7 +949,7 @@ const stepIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt) {
765
949
  const read = yield* readOwn(attempt);
766
950
  const { row } = read;
767
951
  if (read.cancelled && (Object.keys(read.cut).length > 0 || row?.receiving !== void 0)) {
768
- if (!(yield* storeCall(() => store.commit(repoScope(attempt.internalId), {
952
+ if (!(yield* storeCommit(store.commit(repoScope(attempt.internalId), {
769
953
  id: newChangeId(),
770
954
  expect: read.version,
771
955
  delete: importEndDeletes(row)
@@ -776,10 +960,11 @@ const stepIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt) {
776
960
  if (viewed === void 0) return void 0;
777
961
  if (viewed.kind === "refused") return yield* forGood(viewed.error);
778
962
  if (!viewed.view.whole) return yield* forGood(partialImporter());
779
- return yield* asSync(stepAs(attempt, read, row));
963
+ const { deepen } = row;
964
+ return yield* asSync(stepAs(attempt, read, row, viewed.caller)).pipe(Effect.catch((error) => deepen === void 0 ? Effect.fail(error) : Effect.flatMap(readOwn(attempt), (now) => now.row?.deepen?.run !== deepen.run ? Effect.succeed(more) : Effect.fail(error))));
780
965
  });
781
966
  /** The step the record says is next, once who started the import is asked again. */
782
- const stepAs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, read, row) {
967
+ const stepAs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, read, row, caller) {
783
968
  if (row.receiving !== void 0) return yield* resumed(attempt, row, row.receiving, read.cut);
784
969
  if (row.copied) {
785
970
  const { lfs } = row;
@@ -788,7 +973,7 @@ const stepAs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, read, row)
788
973
  yield* copyLfs(attempt, read.version, row, lfs, copy);
789
974
  return more;
790
975
  }
791
- return yield* publish(attempt, row);
976
+ return yield* publish(attempt, row, caller);
792
977
  }
793
978
  const remote = yield* remoteOf(attempt.bound, row.source, attempt.context.signal, "read");
794
979
  if (row.tipPages === void 0) return yield* listTips(attempt, read.version, row, remote);
@@ -825,7 +1010,7 @@ const importTry = /* @__PURE__ */ Effect.fnUntraced(function* (bound) {
825
1010
  internalId: yield* currentRepo,
826
1011
  context
827
1012
  };
828
- return yield* tried(Effect.provideContext(overStore(context.store)(stepOf(attempt)), bound.needs));
1013
+ return yield* tried(Effect.provideContext(stepOf(attempt), bound.needs));
829
1014
  });
830
1015
  /**
831
1016
  * The import's record marked failed with the last try's error, once the job is failed: read again
@@ -834,31 +1019,36 @@ const importTry = /* @__PURE__ */ Effect.fnUntraced(function* (bound) {
834
1019
  * the cancel is what failed the last try: only the keys its run kept go.
835
1020
  */
836
1021
  const importFailed = /* @__PURE__ */ Effect.fnUntraced(function* (bound, { error }) {
837
- const context = yield* CurrentJob.CurrentJob;
838
1022
  const internalId = yield* currentRepo;
839
1023
  const passing = error instanceof SyncTryError && !error.permanent;
840
- const last = error instanceof SyncTryError ? error.kept : stoppedTry;
841
- const cut = {
842
- ...last,
843
- message: cutWords(last.message, failedMessageMost)
844
- };
845
- const kept = passing ? {
846
- ...cut,
847
- hint: failedHint
848
- } : cut;
849
1024
  const marked = Effect.gen(function* () {
1025
+ const { store } = yield* CoreParts;
850
1026
  for (;;) {
851
- const read = yield* readImport(context.store, internalId);
1027
+ const read = yield* readImport(store, internalId);
852
1028
  const { row } = read;
853
1029
  if (row === void 0 || row.state !== "running") return;
854
- if ((yield* storeCall(() => context.store.commit(repoScope(internalId), {
1030
+ const isDeepen = row.deepen !== void 0;
1031
+ const last = error instanceof SyncTryError ? error.kept : isDeepen ? stoppedDeepen : stoppedTry;
1032
+ const cut = {
1033
+ ...last,
1034
+ message: cutWords(last.message, failedMessageMost)
1035
+ };
1036
+ const kept = passing ? {
1037
+ ...cut,
1038
+ hint: isDeepen ? "Deepen again with a new key" : failedHint
1039
+ } : cut;
1040
+ const receiptPut = read.cancelled ? [] : deepenReceiptPut(row.deepen, { error: kept });
1041
+ if ((yield* storeCommit(store.commit(repoScope(internalId), {
855
1042
  id: newChangeId(),
856
1043
  expect: read.version,
857
- put: read.cancelled ? [] : [importRow(failedRow(row, kept))],
1044
+ put: read.cancelled ? [] : [importRow(failedRow(row, kept)), ...receiptPut],
858
1045
  delete: importEndDeletes(row)
859
- }))).ok) return;
1046
+ }))).ok) return row.lfs?.copying;
860
1047
  }
861
1048
  });
862
- yield* Effect.provideContext(marked, bound.needs).pipe(Effect.mapError(thrownOf));
1049
+ const copying = yield* Effect.provideContext(marked, bound.needs).pipe(Effect.mapError(thrownOf));
1050
+ if (copying === void 0) return;
1051
+ const copy = yield* bound.lfs;
1052
+ if (copy !== void 0) yield* leftUpload(copy, copying);
863
1053
  });
864
1054
  export { advertisedFrom, importFailed, importTry };