@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
@@ -2,23 +2,19 @@ import { gitError } from "../contracts/result.mjs";
2
2
  import { BufferMeter } from "../protocol/bytes/buffers.mjs";
3
3
  import { crc32Update } from "../protocol/bytes/crc32.mjs";
4
4
  import { deflatedMost } from "../protocol/bytes/deflate.mjs";
5
+ import { hexOf } from "../protocol/bytes/hex.mjs";
5
6
  import { Sha1 } from "../protocol/bytes/sha1.mjs";
6
7
  import { emptyTree } from "../protocol/objects/object.mjs";
7
8
  import { entryHeader, packStream, writePack } from "../protocol/packs/writer.mjs";
8
9
  import { untilAborted } from "../store/crossing.mjs";
9
10
  import { fetchLess } from "../store/errors.mjs";
10
11
  import { catchSpent, ownSpentOf } from "../contracts/calls-spent.mjs";
11
- import { hexOf } from "../protocol/bytes/hex.mjs";
12
- import "./pack-reads.mjs";
13
- import { isSet } from "./bits.mjs";
14
12
  import { entryHolds, planColumns } from "./plan-columns.mjs";
15
- import { typeOfCode } from "./index-files.mjs";
16
- import { ListCursor, sizeOf } from "./send-list.mjs";
17
13
  import { oidSet } from "./oid-table.mjs";
18
14
  import { planShallow, withRootsSent } from "./shallow.mjs";
19
15
  import { countedReads, fetchReadsOf, historyOf, lost, noIds, notHeld, unreadable, walk } from "./walk.mjs";
20
- import * as Clock from "effect/Clock";
21
16
  import * as Effect from "effect/Effect";
17
+ import * as Clock from "effect/Clock";
22
18
  // src/storage/fetch.ts
23
19
  /**
24
20
  * `Git.layer`'s `fetchLimits` when it names none: a clone of a large repo fits within them.
@@ -121,6 +117,11 @@ const plannedSource = (reads, plan, rows) => {
121
117
  const ordinal = columns.sentAt(at);
122
118
  if (columns.copiedAt(ordinal)) continue;
123
119
  const each = size[ordinal] ?? 0;
120
+ const kind = columns.kindAt(ordinal);
121
+ if (kind !== void 0 && reads.ranged?.handles({
122
+ kind,
123
+ size: each
124
+ }) === true) continue;
124
125
  if (oids.length > 0 && bytes + each > 1048576) break;
125
126
  oids.push(columns.oidAt(ordinal));
126
127
  bytes += each;
@@ -145,6 +146,11 @@ const plannedSource = (reads, plan, rows) => {
145
146
  count,
146
147
  page: (from, most) => Effect.sync(() => Array.from({ length: Math.max(0, Math.min(most, count - from)) }, (_, at) => columns.sent(from + at))),
147
148
  read: Effect.fnUntraced(function* (object, at) {
149
+ if (reads.ranged?.handles(object) === true) {
150
+ const piece = yield* reads.ranged.read(object.oid, at);
151
+ if (piece === void 0) return yield* Effect.fail(gone(object.oid));
152
+ return piece;
153
+ }
148
154
  if (!window.has(object.oid)) yield* load(object.oid);
149
155
  const whole = window.get(object.oid);
150
156
  if (whole === void 0) return yield* Effect.fail(gone(object.oid));
@@ -165,234 +171,6 @@ const plannedSource = (reads, plan, rows) => {
165
171
  }
166
172
  };
167
173
  };
168
- /** A pack entry's type, in its header's first byte: 1 to 4 for the kinds, 7 for a `REF_DELTA`. */
169
- const entryTypes = {
170
- commit: 1,
171
- tree: 2,
172
- blob: 3,
173
- tag: 4
174
- };
175
- const refDeltaType = 7;
176
- /**
177
- * `copy`, refused with `DATA_LOSS` before its first range is handed over when its header's type
178
- * isn't what the index says it is: `kind` for a whole entry, a `REF_DELTA` for a delta. A copied
179
- * delta's header must name `base` too, the ID at the base position its `.bases` row gives,
180
- * checked before the range that completes the header's ID is handed over.
181
- */
182
- const typeChecked = (copy, entry, type, base) => {
183
- const wrong = gitError("DATA_LOSS", `Object ${entry.oid} in pack ${entry.pack.id} isn't the entry the index's .types and .bases say`);
184
- let head = /* @__PURE__ */ new Uint8Array(0);
185
- let checked = true;
186
- /** The base ID a `REF_DELTA`'s header names, past its type and size, once `bytes` hold it. */
187
- const named = (bytes) => {
188
- let at = 1;
189
- while (at <= bytes.byteLength && ((bytes[at - 1] ?? 0) & 128) !== 0) at += 1;
190
- return bytes.byteLength < at + 20 ? void 0 : hexOf(bytes.subarray(at, at + 20));
191
- };
192
- return {
193
- bytes: copy.bytes,
194
- read: (at) => Effect.flatMap(copy.read(at), (bytes) => {
195
- if (at === 0 && ((bytes[0] ?? 0) >> 4 & 7) !== type) return Effect.fail(wrong);
196
- if (at === 0) {
197
- head = /* @__PURE__ */ new Uint8Array(0);
198
- checked = base === void 0;
199
- }
200
- if (checked) return Effect.succeed(bytes);
201
- head = Uint8Array.from([...head, ...bytes.subarray(0, 64 - head.byteLength)]);
202
- const found = named(head);
203
- if (found === void 0 && at + bytes.byteLength < copy.bytes) return Effect.succeed(bytes);
204
- checked = true;
205
- return found === base ? Effect.succeed(bytes) : Effect.fail(wrong);
206
- })
207
- };
208
- };
209
- /**
210
- * The whole objects of `list` the writer reads at once from `cursor` on, as `plannedSource` reads
211
- * its windows: those it doesn't copy, up to `windowBytes` of them or the one.
212
- */
213
- const windowFrom = (cursor) => {
214
- const { list } = cursor;
215
- const window = [];
216
- let bytes = 0;
217
- for (const at = cursor.copy(); !at.done; at.next()) {
218
- if (isSet(list.copied, at.ordinal)) continue;
219
- const size = sizeOf(list, at.ordinal);
220
- if (window.length > 0 && bytes + size > 1048576) break;
221
- window.push({
222
- ordinal: at.ordinal,
223
- position: at.position,
224
- pack: at.inPack
225
- });
226
- bytes += size;
227
- }
228
- return window;
229
- };
230
- /**
231
- * The stored entries the writer reads through the reader's blocks for `list`, in its order, as
232
- * `writerCalls` forecasts a plan's: for each window of objects written whole, each one's entry and
233
- * the bases down its chain, as the reader resolves it. Its copies are read through `listRuns`.
234
- * None is held past `PackBlocks.gets`' count.
235
- */
236
- function* listReads(list) {
237
- let windowEnd = 0;
238
- for (const cursor = new ListCursor(list); !cursor.done; cursor.next()) {
239
- if (isSet(list.copied, cursor.ordinal) || cursor.ordinal < windowEnd) continue;
240
- const window = windowFrom(cursor);
241
- windowEnd = (window.at(-1)?.ordinal ?? cursor.ordinal) + 1;
242
- for (const each of window) for (let at = each.position, steps = 0; at !== void 0 && steps <= list.chains.size; at = list.chains.get(at), steps += 1) yield each.pack.at(at);
243
- }
244
- }
245
- /**
246
- * `list`'s copies as runs, in its order: each copy joins the run before it when it's in the same
247
- * pack and starts at most `blockBytes` past that run's end, the gap read and let go. So each run
248
- * starts in a block no run before it reads, and runs are never more gets than the blocks the
249
- * copies' bytes span. A full clone of one pack is one run (#647).
250
- */
251
- function* listRuns(list) {
252
- let run;
253
- let pack = -1;
254
- for (const cursor = new ListCursor(list); !cursor.done; cursor.next()) {
255
- if (!isSet(list.copied, cursor.ordinal)) continue;
256
- const entry = cursor.inPack.at(cursor.position);
257
- const end = entry.offset + entry.bytes;
258
- if (run !== void 0 && cursor.pack === pack && entry.offset <= run.to + 1048576) {
259
- run.to = end;
260
- run.last = cursor.ordinal;
261
- continue;
262
- }
263
- if (run !== void 0) yield run;
264
- pack = cursor.pack;
265
- run = {
266
- pack: entry.pack,
267
- from: entry.offset,
268
- to: end,
269
- first: cursor.ordinal,
270
- last: cursor.ordinal
271
- };
272
- }
273
- if (run !== void 0) yield run;
274
- }
275
- /**
276
- * The bucket gets the writer makes for `list`'s objects, with no I/O: one a run of its copies, and
277
- * its windows' reads as `PackBlocks.gets` forecasts them, as `writerCalls` forecasts a plan's
278
- * (#522).
279
- */
280
- const listCalls = (stored, list) => {
281
- let runs = 0;
282
- for (const _run of listRuns(list)) runs += 1;
283
- return {
284
- bucket: runs + stored.gets(listReads(list)),
285
- store: 0
286
- };
287
- };
288
- /**
289
- * `list`'s objects as the writer takes them, a page at a time: each one's ID, kind and size from
290
- * the index and the list, held for its page alone. A copy is its stored entry, read through its
291
- * run's one ranged get, its CRC-32 checked as it's read and its type against the index's; the rest
292
- * are read whole a window at a time, as `plannedSource` reads them. Every read is a listed pack's,
293
- * so the store is read no more. A second write, from the first object again, reads its runs again.
294
- */
295
- const listSource = (reads, list) => {
296
- let cursor = new ListCursor(list);
297
- let paged = /* @__PURE__ */ new Map();
298
- let window = /* @__PURE__ */ new Map();
299
- let runs = listRuns(list);
300
- let run;
301
- let reading;
302
- const closeRun = Effect.suspend(() => {
303
- const open = reading;
304
- reading = void 0;
305
- return open?.close ?? Effect.void;
306
- });
307
- const load = Effect.fnUntraced(function* (from) {
308
- const at = windowFrom(from).map(({ pack, position }) => {
309
- const { oid, offset } = pack.at(position);
310
- return {
311
- oid,
312
- lookup: pack.lookup,
313
- offset
314
- };
315
- });
316
- if (reads.heldAt !== void 0) window = yield* reads.heldAt(at);
317
- });
318
- /**
319
- * The copy at `ordinal`'s bytes from `at`, through its run: a run is opened as the writer reaches
320
- * it, and another from the entry on only for a read behind the one open.
321
- */
322
- const copied = Effect.fnUntraced(function* (stored, ordinal, entry, at) {
323
- while (run === void 0 || run.last < ordinal) {
324
- yield* closeRun;
325
- const next = runs.next();
326
- if (next.done === true) return yield* Effect.die(/* @__PURE__ */ new Error(`no run of the list holds its copy ${ordinal}`));
327
- run = next.value;
328
- }
329
- if (ordinal < run.first) return yield* Effect.die(/* @__PURE__ */ new Error(`the list's copy ${ordinal} is read before its run`));
330
- const offset = entry.offset + at;
331
- const open = reading !== void 0 && reading.reads(offset);
332
- if (!open && stored.kept(entry.pack, offset)) return yield* stored.read(entry, at);
333
- if (reading === void 0 || !open) {
334
- yield* closeRun;
335
- reading = stored.run(run.pack, offset, run.to);
336
- }
337
- return yield* reading.read(offset, entry.offset + entry.bytes);
338
- });
339
- return {
340
- count: list.count,
341
- page: Effect.fnUntraced(function* (from, most) {
342
- if (from === 0 && cursor.ordinal > 0) {
343
- yield* closeRun;
344
- cursor = new ListCursor(list);
345
- window = /* @__PURE__ */ new Map();
346
- runs = listRuns(list);
347
- run = void 0;
348
- }
349
- if (from !== cursor.ordinal) return yield* Effect.die(/* @__PURE__ */ new Error(`the list pages in order: ${from} isn't its next`));
350
- const page = [];
351
- paged = /* @__PURE__ */ new Map();
352
- for (; page.length < most && !cursor.done; cursor.next()) {
353
- const { oid } = cursor.inPack.at(cursor.position);
354
- const kind = typeOfCode[list.kinds[cursor.ordinal] ?? 0] ?? "blob";
355
- const size = sizeOf(list, cursor.ordinal);
356
- page.push(isSet(list.copied, cursor.ordinal) ? {
357
- oid,
358
- kind,
359
- storedBytes: size
360
- } : {
361
- oid,
362
- kind,
363
- size
364
- });
365
- paged.set(oid, cursor.copy());
366
- }
367
- return page;
368
- }),
369
- read: Effect.fnUntraced(function* (object, at) {
370
- const placed = paged.get(object.oid);
371
- if (!window.has(object.oid) && placed !== void 0) yield* load(placed);
372
- const whole = window.get(object.oid);
373
- if (whole === void 0) return yield* Effect.fail(gone(object.oid));
374
- const bytes = whole.bytes.slice(at, at + rangeBytes);
375
- if (at + bytes.byteLength >= whole.bytes.byteLength) {
376
- const left = new Map(window);
377
- left.delete(object.oid);
378
- window = left;
379
- }
380
- return bytes;
381
- }),
382
- end: closeRun,
383
- close: closeRun,
384
- copy: (object) => {
385
- const placed = paged.get(object.oid);
386
- const { stored } = reads;
387
- if (placed === void 0 || stored === void 0 || !isSet(list.copied, placed.ordinal)) return void 0;
388
- const entry = placed.inPack.at(placed.position);
389
- const copy = checkedCopy(entry, (at) => copied(stored, placed.ordinal, entry, at));
390
- if (!isSet(list.deltas, placed.ordinal)) return typeChecked(copy, entry, entryTypes[object.kind]);
391
- const base = placed.inPack.at(list.bases[placed.ordinal] ?? 0).oid;
392
- return typeChecked(copy, entry, refDeltaType, base);
393
- }
394
- };
395
- };
396
174
  /** `first`'s objects, then `second`'s, as one source: a page across the seam takes from both. */
397
175
  const joinedSources = (first, second) => {
398
176
  let fromFirst = /* @__PURE__ */ new Set();
@@ -420,7 +198,7 @@ const memorySource = (objects) => {
420
198
  kind: object.type,
421
199
  size: object.bytes.byteLength
422
200
  }))),
423
- read: (object, at) => Effect.sync(() => byOid.get(object.oid)?.bytes.slice(at, at + rangeBytes) ?? /* @__PURE__ */ new Uint8Array(0)),
201
+ read: (object, at) => Effect.sync(() => byOid.get(object.oid)?.bytes.slice(at, at + 1048576) ?? /* @__PURE__ */ new Uint8Array(0)),
424
202
  end: Effect.void
425
203
  };
426
204
  };
@@ -650,7 +428,18 @@ const planFetch = /* @__PURE__ */ Effect.fnUntraced(function* (read, request, ta
650
428
  for (let at = 0; at < parents.length; at += 20) if (hadAt(parents, at)) edges.addBytes(parents, at);
651
429
  }
652
430
  const edgeTrees = [];
653
- for (const commit of (yield* read([...edges.values()])).values()) if (commit.tree !== void 0) edgeTrees.push(commit.tree);
431
+ const unreadEdges = [];
432
+ for (const oid of edges.values()) {
433
+ const have = haves.get(oid);
434
+ if (have !== void 0) {
435
+ if (have.tree !== void 0) edgeTrees.push(have.tree);
436
+ continue;
437
+ }
438
+ unreadEdges.push(oid);
439
+ }
440
+ if (unreadEdges.length > 0) {
441
+ for (const commit of (yield* read(unreadEdges)).values()) if (commit.tree !== void 0) edgeTrees.push(commit.tree);
442
+ }
654
443
  const byId = request.wants.some((oid) => {
655
444
  const type = history.typeOf(oid);
656
445
  return type === "tree" || type === "blob";
@@ -944,10 +733,29 @@ const writerCalls = /* @__PURE__ */ Effect.fnUntraced(function* (stored, columns
944
733
  }
945
734
  }
946
735
  const rows = Array.from(whole).filter((ordinal) => packed[ordinal] !== 1).map((ordinal) => columns.oidAt(ordinal)).filter((oid) => oid !== emptyTree);
736
+ const sizeOf = (oid) => size[columns.find(oid) ?? columns.size] ?? 0;
737
+ let store;
738
+ if (rows.length === 0) store = 0;
739
+ else if (stored?.cachedRow !== void 0 && stored.pinCachedRows !== void 0) {
740
+ const rowBytes = rows.reduce((sum, oid) => sum + sizeOf(oid), 0);
741
+ if (stored.pinCachedRows(2 * rowBytes)) {
742
+ store = 0;
743
+ for (let at = 0; at < rows.length; at += 100) {
744
+ const end = Math.min(rows.length, at + 100);
745
+ for (let i = at; i < end; i += 1) {
746
+ const oid = rows[i];
747
+ if (oid !== void 0 && !stored.cachedRow(oid)) {
748
+ store += 1;
749
+ break;
750
+ }
751
+ }
752
+ }
753
+ } else store = Math.ceil(rows.length / 100);
754
+ } else store = Math.ceil(rows.length / 100);
947
755
  return {
948
756
  forecast: {
949
757
  bucket: stored?.gets(readsInTurn()) ?? 0,
950
- store: Math.ceil(rows.length / 100)
758
+ store
951
759
  },
952
760
  rows
953
761
  };
@@ -1081,7 +889,7 @@ const planFetchWithin = /* @__PURE__ */ Effect.fnUntraced(function* (reads, inpu
1081
889
  const writer = yield* writerCalls(restRead.stored, columns);
1082
890
  rows = writer.rows;
1083
891
  if (calls !== void 0) {
1084
- const listed = list === void 0 ? noCalls : listCalls(reads.stored, list);
892
+ const listed = list === void 0 || within.index === void 0 ? noCalls : within.index.calls(reads.stored, list);
1085
893
  forecast = {
1086
894
  bucket: listed.bucket + writer.forecast.bucket,
1087
895
  store: listed.store + writer.forecast.store
@@ -1113,7 +921,11 @@ const planFetchWithin = /* @__PURE__ */ Effect.fnUntraced(function* (reads, inpu
1113
921
  bytes,
1114
922
  rows
1115
923
  };
1116
- if (list !== void 0) plan.list = list;
924
+ if (list !== void 0) {
925
+ plan.list = list;
926
+ const { index } = within;
927
+ if (index !== void 0) plan.listSource = (from) => index.sourceOf(from, list);
928
+ }
1117
929
  if (unplaced !== void 0) plan.unplaced = unplaced;
1118
930
  return plan;
1119
931
  });
@@ -1123,9 +935,9 @@ const planFetchWithin = /* @__PURE__ */ Effect.fnUntraced(function* (reads, inpu
1123
935
  * read that fails then ends the stream, and so does the call's signal aborting.
1124
936
  */
1125
937
  const packOfPlan = /* @__PURE__ */ Effect.fnUntraced(function* (reads, plan, limits, writing, rows) {
1126
- const { deepened, list } = plan;
938
+ const { deepened } = plan;
1127
939
  const planned = plannedSource(restReads(reads, plan.unplaced), plan, rows);
1128
- const listed = list === void 0 ? void 0 : listSource(reads, list);
940
+ const listed = plan.listSource?.(reads);
1129
941
  const source = listed === void 0 ? planned : joinedSources(listed, planned);
1130
942
  const meter = new BufferMeter(writerBytes);
1131
943
  const writeLimits = {
@@ -1220,4 +1032,4 @@ const rowsFirst = /* @__PURE__ */ Effect.fnUntraced(function* (reads, plan, char
1220
1032
  }
1221
1033
  return rows;
1222
1034
  });
1223
- export { awaitingIndex, callsAhead, checkedCopy, defaultFetchLimits, fetchPack, fetchTooLarge, listCalls, listRuns, listSource, memoryPack, packOfPlan, pastLimits, planFetchWithin, planTooSlow, refusedWhenSpent, requestSpent, timeLeft, tooManyCalls, unreadPackMs, windowBytes };
1035
+ export { awaitingIndex, callsAhead, checkedCopy, defaultFetchLimits, fetchPack, fetchTooLarge, gone, memoryPack, packOfPlan, pastLimits, planFetchWithin, planTooSlow, rangeBytes, refusedWhenSpent, requestSpent, timeLeft, tooManyCalls, unreadPackMs, windowBytes };
@@ -1,7 +1,6 @@
1
1
  import "../contracts/ids.mjs";
2
2
  import "../contracts/objects.mjs";
3
3
  import "../contracts/result.mjs";
4
- import "../contracts/services.mjs";
5
4
  import "../contracts/store.mjs";
6
5
  import "./pack-reads.mjs";
7
6
  import "effect/Effect";
@@ -1,5 +1,6 @@
1
1
  import { gitError } from "../contracts/result.mjs";
2
2
  import { hexOf } from "../protocol/bytes/hex.mjs";
3
+ import { emptyTree } from "../protocol/objects/object.mjs";
3
4
  import { indexHeadBytes } from "../protocol/packs/idx.mjs";
4
5
  import { checkTypesHeader, checkTypesPack, typeAt, typeOfByte, typesPackAt } from "../protocol/packs/types-file.mjs";
5
6
  import { readWhole } from "./calls.mjs";
@@ -135,7 +136,7 @@ const storedOf = (pack) => isPackId(pack.id) ? Effect.succeed({
135
136
  * push asks its links, they make at most `heldTypesCalls` of the listed packs in all.
136
137
  */
137
138
  const repoTypes = (input) => {
138
- const { store, bucket, indexes, listed, memory, reader, visible } = input;
139
+ const { store, bucket, indexes, listed, memory, reader, visible, hasLooseRows = true } = input;
139
140
  const rows = rowHeaders(store, listed);
140
141
  const forward = /* @__PURE__ */ new Map();
141
142
  const opened = /* @__PURE__ */ new Map();
@@ -204,11 +205,18 @@ const repoTypes = (input) => {
204
205
  const oids = yield* shownOf(asked);
205
206
  yield* charge(oids.length, sizes);
206
207
  const answer = /* @__PURE__ */ new Map();
207
- for (const [oid, { type }] of yield* rows(oids)) answer.set(oid, {
208
+ const addRows = Effect.fnUntraced(function* (ids) {
209
+ for (const [oid, { type }] of yield* rows(ids)) answer.set(oid, {
210
+ pack: void 0,
211
+ type
212
+ });
213
+ });
214
+ if (hasLooseRows) yield* addRows(oids);
215
+ else if (oids.includes("4b825dc642cb6eb9a060e54bf8d69288fbee4904")) answer.set(emptyTree, {
208
216
  pack: void 0,
209
- type
217
+ type: "tree"
210
218
  });
211
- let left = oids.filter((oid) => !answer.has(oid));
219
+ let left = answer.size === 0 ? oids : oids.filter((oid) => !answer.has(oid));
212
220
  for (let from = 0; from < listed.packs.length && left.length > 0; from += 6) {
213
221
  const window = listed.packs.slice(from, from + 6);
214
222
  const asked = left;
@@ -226,6 +234,7 @@ const repoTypes = (input) => {
226
234
  });
227
235
  left = left.filter((oid) => !answer.has(oid));
228
236
  }
237
+ if (!hasLooseRows && left.length > 0) yield* addRows(left);
229
238
  return answer;
230
239
  }),
231
240
  beyond: Effect.fnUntraced(function* (asked) {
@@ -1,8 +1,8 @@
1
1
  import { spentAt } from "../contracts/calls-spent.mjs";
2
2
  import { isServerClosed } from "../store/closed.mjs";
3
3
  import { bucketFailed } from "./calls.mjs";
4
- import * as Effect from "effect/Effect";
5
4
  import { Unavailable } from "@ref0/infra";
5
+ import * as Effect from "effect/Effect";
6
6
  // src/storage/host-bucket.ts
7
7
  /**
8
8
  * A host bucket's own defect as `Unavailable`, which `bucketDo` answers `UNAVAILABLE`, "The bucket
@@ -13,8 +13,9 @@ const hostFailure = (cause) => isServerClosed(cause) || spentAt(cause) !== void
13
13
  cause
14
14
  }));
15
15
  /**
16
- * The host's bucket as `packs().open` takes it, each call's defect a failure: a host's promise
17
- * bucket rejects with what it likes, which infra's `bucketOf` leaves a defect.
16
+ * The host's bucket as `packs().open` takes it, each call's defect a failure: a host's own
17
+ * `Bucket` service may die with what it likes, as an adapter's call over a promise does with any
18
+ * rejection that isn't an infra error.
18
19
  */
19
20
  const hostFailures = (bucket) => ({
20
21
  ...bucket,
@@ -22,7 +23,11 @@ const hostFailures = (bucket) => ({
22
23
  read: (key, range) => Effect.catchDefect(bucket.read(key, range), hostFailure),
23
24
  remove: (key) => Effect.catchDefect(bucket.remove(key), hostFailure),
24
25
  removeMany: (keys, options) => Effect.catchDefect(bucket.removeMany(keys, options), hostFailure),
25
- list: (prefix, page) => Effect.catchDefect(bucket.list(prefix, page), hostFailure)
26
+ list: (prefix, page) => Effect.catchDefect(bucket.list(prefix, page), hostFailure),
27
+ beginPut: (key) => Effect.catchDefect(bucket.beginPut(key), hostFailure),
28
+ putPart: (key, token, part, body) => Effect.catchDefect(bucket.putPart(key, token, part, body), hostFailure),
29
+ completePut: (key, token, parts, options) => Effect.catchDefect(bucket.completePut(key, token, parts, options), hostFailure),
30
+ abortPut: (key, token) => Effect.catchDefect(bucket.abortPut(key, token), hostFailure)
26
31
  });
27
32
  /** The host's links, each call's defect a failure, as `hostFailures` says. */
28
33
  const hostLinks = (links) => ({