@ref0/git 0.6.0 → 0.8.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 (476) hide show
  1. package/dist/access/namespace.d.mts +2 -0
  2. package/dist/access/private-refs.d.mts +6 -29
  3. package/dist/access/private-refs.mjs +26 -13
  4. package/dist/access/public.d.mts +6 -0
  5. package/dist/access/public.mjs +9 -0
  6. package/dist/auth/access-jwt.d.mts +10 -6
  7. package/dist/auth/access-jwt.mjs +59 -40
  8. package/dist/auth/auth-namespace.d.mts +6 -0
  9. package/dist/auth/auth-namespace.mjs +12 -0
  10. package/dist/auth/auth.d.mts +3 -6
  11. package/dist/auth/auth.mjs +2 -9
  12. package/dist/auth/authorize.mjs +35 -29
  13. package/dist/auth/bridge.mjs +8 -8
  14. package/dist/auth/fences.d.mts +1 -2
  15. package/dist/auth/fences.mjs +1 -1
  16. package/dist/auth/grants.d.mts +0 -1
  17. package/dist/auth/grants.mjs +2 -2
  18. package/dist/auth/host-function.d.mts +1 -7
  19. package/dist/auth/host-function.mjs +51 -42
  20. package/dist/auth/identify.d.mts +0 -1
  21. package/dist/auth/identify.mjs +3 -2
  22. package/dist/auth/namespaces.d.mts +2 -2
  23. package/dist/auth/policy.d.mts +7 -4
  24. package/dist/auth/policy.mjs +13 -10
  25. package/dist/auth/token-rows.mjs +3 -6
  26. package/dist/auth/tokens-layer.d.mts +40 -0
  27. package/dist/auth/tokens-layer.mjs +29 -0
  28. package/dist/auth/tokens-namespace.d.mts +2 -0
  29. package/dist/auth/tokens-public.d.mts +6 -0
  30. package/dist/auth/tokens-public.mjs +31 -0
  31. package/dist/auth/tokens.d.mts +19 -7
  32. package/dist/auth/tokens.mjs +12 -6
  33. package/dist/auth.d.mts +2 -2
  34. package/dist/auth.mjs +2 -2
  35. package/dist/client/client.d.mts +22 -15
  36. package/dist/client/client.mjs +31 -27
  37. package/dist/client/git-http.mjs +23 -6
  38. package/dist/client/local.mjs +5 -4
  39. package/dist/client/namespace.d.mts +2 -0
  40. package/dist/client/push-upload.d.mts +1 -0
  41. package/dist/client/push-upload.mjs +169 -2
  42. package/dist/client/remote-helper.mjs +5 -12
  43. package/dist/client/remote.mjs +63 -22
  44. package/dist/client/run-remote-helper.d.mts +1 -1
  45. package/dist/client/run-remote-helper.mjs +6 -6
  46. package/dist/client/slice-push.d.mts +1 -1
  47. package/dist/client/transport.mjs +26 -19
  48. package/dist/contracts/access.d.mts +18 -10
  49. package/dist/contracts/access.mjs +17 -0
  50. package/dist/contracts/actors.d.mts +73 -28
  51. package/dist/contracts/actors.mjs +45 -2
  52. package/dist/contracts/authorize.d.mts +26 -17
  53. package/dist/contracts/blobs.d.mts +1 -1
  54. package/dist/contracts/blobs.mjs +1 -1
  55. package/dist/contracts/callers.mjs +40 -0
  56. package/dist/contracts/calls-spent.d.mts +6 -4
  57. package/dist/contracts/calls-spent.mjs +10 -8
  58. package/dist/contracts/client.d.mts +16 -9
  59. package/dist/contracts/commits.d.mts +2 -2
  60. package/dist/contracts/commits.mjs +1 -1
  61. package/dist/contracts/engine.d.mts +1 -1
  62. package/dist/contracts/events.d.mts +45 -32
  63. package/dist/contracts/events.mjs +21 -10
  64. package/dist/contracts/files.d.mts +44 -44
  65. package/dist/contracts/files.mjs +1 -1
  66. package/dist/contracts/forks.d.mts +34 -58
  67. package/dist/contracts/forks.mjs +1 -1
  68. package/dist/contracts/git-events.d.mts +50 -0
  69. package/dist/contracts/git-events.mjs +23 -0
  70. package/dist/contracts/git-hooks.d.mts +254 -0
  71. package/dist/contracts/git-hooks.mjs +12 -0
  72. package/dist/contracts/git.d.mts +93 -42
  73. package/dist/contracts/git.mjs +6 -5
  74. package/dist/contracts/grants.d.mts +46 -27
  75. package/dist/contracts/ids.d.mts +16 -0
  76. package/dist/contracts/ids.mjs +19 -4
  77. package/dist/contracts/lfs.d.mts +19 -4
  78. package/dist/contracts/merges.d.mts +7 -7
  79. package/dist/contracts/namespaces.d.mts +2 -2
  80. package/dist/contracts/objects.d.mts +21 -5
  81. package/dist/contracts/opaque.mjs +27 -0
  82. package/dist/contracts/operations.d.mts +301 -101
  83. package/dist/contracts/operations.mjs +209 -0
  84. package/dist/contracts/promises.d.mts +2 -0
  85. package/dist/contracts/push-uploads.d.mts +4 -1
  86. package/dist/contracts/push-uploads.mjs +9 -4
  87. package/dist/contracts/queue.d.mts +220 -49
  88. package/dist/contracts/queue.mjs +68 -6
  89. package/dist/contracts/refs.d.mts +30 -8
  90. package/dist/contracts/refs.mjs +1 -1
  91. package/dist/contracts/remote.d.mts +53 -23
  92. package/dist/contracts/remote.mjs +22 -0
  93. package/dist/contracts/repo-records.d.mts +2 -2
  94. package/dist/contracts/repos.d.mts +100 -82
  95. package/dist/contracts/repos.mjs +47 -8
  96. package/dist/contracts/result.d.mts +73 -41
  97. package/dist/contracts/result.mjs +74 -17
  98. package/dist/contracts/rules.d.mts +734 -68
  99. package/dist/contracts/rules.mjs +84 -1
  100. package/dist/contracts/server.d.mts +20 -206
  101. package/dist/contracts/services.d.mts +1 -10
  102. package/dist/contracts/services.mjs +1 -5
  103. package/dist/contracts/signin.d.mts +140 -43
  104. package/dist/contracts/signin.mjs +36 -3
  105. package/dist/contracts/store.d.mts +1 -1
  106. package/dist/contracts/sync.d.mts +109 -90
  107. package/dist/contracts/sync.mjs +34 -7
  108. package/dist/contracts/tags.d.mts +1 -1
  109. package/dist/contracts/tags.mjs +1 -1
  110. package/dist/contracts/tokens.d.mts +247 -60
  111. package/dist/contracts/tokens.mjs +93 -21
  112. package/dist/contracts/topics.d.mts +59 -20
  113. package/dist/contracts/topics.mjs +14 -5
  114. package/dist/contracts/trees.d.mts +2 -2
  115. package/dist/contracts/trees.mjs +1 -1
  116. package/dist/contracts/work.d.mts +2 -2
  117. package/dist/contracts/work.mjs +2 -2
  118. package/dist/core/access.d.mts +10 -12
  119. package/dist/core/access.mjs +45 -11
  120. package/dist/core/clock.mjs +1 -1
  121. package/dist/core/events/deliver.d.mts +3 -2
  122. package/dist/core/events/deliver.mjs +188 -92
  123. package/dist/core/forks.mjs +78 -34
  124. package/dist/core/hooks/groups.d.mts +26 -0
  125. package/dist/core/hooks/groups.mjs +73 -0
  126. package/dist/core/hooks/namespace.d.mts +2 -0
  127. package/dist/core/hooks/order.d.mts +2 -2
  128. package/dist/core/hooks/order.mjs +6 -6
  129. package/dist/core/hooks/public.d.mts +7 -0
  130. package/dist/core/hooks/public.mjs +5 -0
  131. package/dist/core/imports.mjs +94 -10
  132. package/dist/core/index-job.mjs +11 -8
  133. package/dist/core/loose-tally.mjs +46 -0
  134. package/dist/core/merge-parts.d.mts +1 -1
  135. package/dist/core/merge-parts.mjs +1 -1
  136. package/dist/core/mirror-rows.mjs +18 -0
  137. package/dist/core/names.mjs +1 -1
  138. package/dist/core/namespaces.d.mts +2 -1
  139. package/dist/core/objects/commit-writes.mjs +5 -5
  140. package/dist/core/objects/merges.mjs +1 -1
  141. package/dist/core/objects/objects-layer.mjs +1 -1
  142. package/dist/core/objects/reading.mjs +52 -7
  143. package/dist/core/objects/tree-edits.mjs +13 -28
  144. package/dist/core/objects/trees.mjs +4 -4
  145. package/dist/core/objects/writing.mjs +4 -3
  146. package/dist/core/own-writes.mjs +1 -1
  147. package/dist/core/parts.d.mts +22 -3
  148. package/dist/core/parts.mjs +5 -3
  149. package/dist/core/promise.mjs +23 -17
  150. package/dist/core/purge.d.mts +2 -2
  151. package/dist/core/purge.mjs +89 -34
  152. package/dist/core/push.mjs +67 -79
  153. package/dist/core/receipts.d.mts +2 -2
  154. package/dist/core/receipts.mjs +28 -4
  155. package/dist/core/ref-index-job.mjs +4 -4
  156. package/dist/core/ref-view.mjs +16 -8
  157. package/dist/core/refs.mjs +41 -10
  158. package/dist/core/registered-records.mjs +30 -0
  159. package/dist/core/{claim-rows.mjs → registered-rows.mjs} +6 -6
  160. package/dist/core/repack.d.mts +2 -2
  161. package/dist/core/repack.mjs +30 -23
  162. package/dist/core/repo-info.mjs +62 -26
  163. package/dist/core/repos.mjs +18 -11
  164. package/dist/core/rules/changes.mjs +2 -2
  165. package/dist/core/rules/check.mjs +10 -10
  166. package/dist/core/rules/commit-changes.mjs +1 -1
  167. package/dist/core/rules/context.d.mts +7 -6
  168. package/dist/core/rules/context.mjs +18 -16
  169. package/dist/core/rules/fetch.mjs +78 -31
  170. package/dist/core/saved-caller-views.d.mts +72 -0
  171. package/dist/core/saved-caller-views.mjs +123 -0
  172. package/dist/core/saved-callers-public.d.mts +5 -0
  173. package/dist/core/saved-callers-public.mjs +10 -0
  174. package/dist/core/saved-callers.mjs +95 -0
  175. package/dist/core/seam.d.mts +12 -1
  176. package/dist/core/seam.mjs +4 -2
  177. package/dist/core/tokens.mjs +7 -2
  178. package/dist/core/view.d.mts +1 -1
  179. package/dist/core/view.mjs +1 -1
  180. package/dist/core/work.mjs +6 -5
  181. package/dist/effect.d.mts +2 -4
  182. package/dist/effect.mjs +2 -4
  183. package/dist/engine/commits.mjs +19 -47
  184. package/dist/engine/content.d.mts +2 -2
  185. package/dist/engine/content.mjs +1 -1
  186. package/dist/engine/diff.mjs +2 -2
  187. package/dist/engine/failures.d.mts +1 -2
  188. package/dist/engine/failures.mjs +1 -3
  189. package/dist/engine/merge-base-walk.mjs +57 -142
  190. package/dist/engine/merge-bases.mjs +5 -5
  191. package/dist/engine/merge-renames.mjs +1 -1
  192. package/dist/engine/merge.mjs +16 -14
  193. package/dist/engine/reads.d.mts +2 -2
  194. package/dist/engine/reads.mjs +1 -1
  195. package/dist/engine/xdiff.d.mts +1 -1
  196. package/dist/engine/xdiff.mjs +2 -2
  197. package/dist/event-streams/event-streams.d.mts +6 -2
  198. package/dist/event-streams/event-streams.mjs +6 -2
  199. package/dist/event-streams/stream.mjs +5 -2
  200. package/dist/extend.d.mts +2 -3
  201. package/dist/extend.mjs +2 -2
  202. package/dist/http/answers.mjs +4 -3
  203. package/dist/http/core-parts.mjs +3 -4
  204. package/dist/http/handler.mjs +12 -32
  205. package/dist/http/parts.d.mts +1 -1
  206. package/dist/http/push-uploads.mjs +7 -5
  207. package/dist/http/receive-pack.mjs +3 -3
  208. package/dist/http/upload-pack.mjs +6 -5
  209. package/dist/index.d.mts +44 -24
  210. package/dist/index.mjs +17 -8
  211. package/dist/lfs/base.d.mts +8 -5
  212. package/dist/lfs/base.mjs +2 -1
  213. package/dist/lfs/calls.mjs +3 -2
  214. package/dist/lfs/layer.d.mts +9 -7
  215. package/dist/lfs/layer.mjs +37 -22
  216. package/dist/lfs/locks.mjs +3 -3
  217. package/dist/lfs/objects.d.mts +3 -2
  218. package/dist/lfs/objects.mjs +235 -71
  219. package/dist/lfs/pointers.mjs +70 -19
  220. package/dist/lfs/purge.mjs +7 -3
  221. package/dist/lfs/rows.mjs +25 -8
  222. package/dist/lfs/service.d.mts +6 -3
  223. package/dist/lfs/service.mjs +8 -2
  224. package/dist/lfs/upkeep.mjs +53 -31
  225. package/dist/lfs/upload-most.mjs +41 -0
  226. package/dist/lfs/uploaded.mjs +59 -0
  227. package/dist/lfs/wire.mjs +1 -1
  228. package/dist/protocol/bytes/buffers.d.mts +1 -1
  229. package/dist/protocol/bytes/buffers.mjs +1 -1
  230. package/dist/protocol/bytes/deflate.d.mts +1 -1
  231. package/dist/protocol/bytes/deflate.mjs +1 -1
  232. package/dist/protocol/bytes/hmac-sha256.mjs +3 -6
  233. package/dist/protocol/bytes/inflate.d.mts +1 -1
  234. package/dist/protocol/bytes/inflate.mjs +1 -1
  235. package/dist/protocol/bytes/sha1.d.mts +1 -1
  236. package/dist/protocol/bytes/sha1.mjs +2 -2
  237. package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
  238. package/dist/protocol/bytes/text.mjs +6 -1
  239. package/dist/protocol/diff/read.d.mts +1 -1
  240. package/dist/protocol/diff/read.mjs +1 -1
  241. package/dist/protocol/diff/tree-diff.d.mts +1 -1
  242. package/dist/protocol/diff/tree-diff.mjs +11 -11
  243. package/dist/protocol/objects/fsck.mjs +6 -3
  244. package/dist/protocol/objects/lfs-pointer.mjs +6 -1
  245. package/dist/protocol/objects/tag.mjs +1 -1
  246. package/dist/protocol/objects/tree.mjs +1 -1
  247. package/dist/protocol/packs/graph.mjs +1 -1
  248. package/dist/protocol/packs/idx.d.mts +1 -1
  249. package/dist/protocol/packs/idx.mjs +1 -1
  250. package/dist/protocol/packs/parts.mjs +1 -1
  251. package/dist/protocol/packs/reader.d.mts +1 -1
  252. package/dist/protocol/packs/reader.mjs +2 -2
  253. package/dist/protocol/packs/write-error.d.mts +1 -1
  254. package/dist/protocol/packs/write-error.mjs +1 -1
  255. package/dist/protocol/packs/writer.mjs +4 -4
  256. package/dist/protocol/wire/advertisement.d.mts +1 -1
  257. package/dist/protocol/wire/advertisement.mjs +1 -1
  258. package/dist/protocol/wire/fetch.d.mts +1 -1
  259. package/dist/protocol/wire/fetch.mjs +1 -1
  260. package/dist/protocol/wire/lines.d.mts +1 -1
  261. package/dist/protocol/wire/lines.mjs +2 -2
  262. package/dist/protocol/wire/push-uploads.mjs +4 -2
  263. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  264. package/dist/protocol/wire/receive-pack.mjs +1 -1
  265. package/dist/protocol/wire/report-status.d.mts +1 -1
  266. package/dist/protocol/wire/report-status.mjs +1 -1
  267. package/dist/protocol/wire/v2.d.mts +2 -2
  268. package/dist/protocol/wire/v2.mjs +2 -2
  269. package/dist/queue/advance.mjs +190 -68
  270. package/dist/queue/callers.mjs +56 -69
  271. package/dist/queue/calls.mjs +10 -11
  272. package/dist/queue/commit.mjs +28 -22
  273. package/dist/queue/host.d.mts +10 -11
  274. package/dist/queue/host.mjs +15 -7
  275. package/dist/queue/lanes.mjs +9 -18
  276. package/dist/queue/layer.d.mts +3 -3
  277. package/dist/queue/layer.mjs +11 -10
  278. package/dist/queue/limits.mjs +17 -5
  279. package/dist/queue/rows.mjs +13 -10
  280. package/dist/queue/schedule.mjs +7 -6
  281. package/dist/queue/search.mjs +11 -17
  282. package/dist/queue/state.mjs +7 -2
  283. package/dist/queue/trim.mjs +10 -5
  284. package/dist/rest/api.d.mts +1 -1
  285. package/dist/rest/blobs.d.mts +20 -20
  286. package/dist/rest/caller.d.mts +22 -20
  287. package/dist/rest/client-namespace.d.mts +2 -0
  288. package/dist/rest/client.d.mts +32 -8
  289. package/dist/rest/client.mjs +314 -388
  290. package/dist/rest/commits.d.mts +284 -284
  291. package/dist/rest/errors.d.mts +10 -10
  292. package/dist/rest/errors.mjs +1 -1
  293. package/dist/rest/events.d.mts +13 -11
  294. package/dist/rest/events.mjs +3 -1
  295. package/dist/rest/files.d.mts +48 -48
  296. package/dist/rest/forks.d.mts +131 -143
  297. package/dist/rest/handler.mjs +4 -3
  298. package/dist/rest/handlers.mjs +15 -8
  299. package/dist/rest/layer.d.mts +3 -3
  300. package/dist/rest/layer.mjs +8 -7
  301. package/dist/rest/listen.d.mts +8 -6
  302. package/dist/rest/listen.mjs +33 -77
  303. package/dist/rest/me.d.mts +18 -20
  304. package/dist/rest/me.mjs +1 -1
  305. package/dist/rest/merges.d.mts +17 -17
  306. package/dist/rest/queue.d.mts +140 -140
  307. package/dist/rest/queue.mjs +1 -1
  308. package/dist/rest/refs.d.mts +214 -214
  309. package/dist/rest/refs.mjs +1 -1
  310. package/dist/rest/repos.d.mts +123 -135
  311. package/dist/rest/tags.d.mts +30 -30
  312. package/dist/rest/tokens.d.mts +250 -260
  313. package/dist/rest/tokens.mjs +10 -42
  314. package/dist/rest/topics.d.mts +162 -162
  315. package/dist/rest/topics.mjs +1 -1
  316. package/dist/rest/trees.d.mts +117 -117
  317. package/dist/rest/wire.d.mts +7 -5
  318. package/dist/rest/wire.mjs +4 -3
  319. package/dist/rest/work.d.mts +69 -69
  320. package/dist/rest/work.mjs +1 -1
  321. package/dist/rest.d.mts +1 -7
  322. package/dist/rest.mjs +1 -5
  323. package/dist/server/check-fetch.mjs +9 -0
  324. package/dist/server/extension.mjs +3 -115
  325. package/dist/server/git-layer.d.mts +30 -5
  326. package/dist/server/git-layer.mjs +59 -29
  327. package/dist/server/git-namespace.d.mts +4 -4
  328. package/dist/server/git-namespace.mjs +6 -4
  329. package/dist/server/joined.d.mts +83 -0
  330. package/dist/server/joined.mjs +91 -0
  331. package/dist/server/registry.d.mts +7 -3
  332. package/dist/server/registry.mjs +135 -31
  333. package/dist/server/server.d.mts +9 -3
  334. package/dist/server/server.mjs +277 -208
  335. package/dist/signin/context.d.mts +2 -2
  336. package/dist/signin/context.mjs +28 -37
  337. package/dist/signin/device.mjs +5 -5
  338. package/dist/signin/forms.mjs +1 -1
  339. package/dist/signin/grants.d.mts +2 -3
  340. package/dist/signin/grants.mjs +5 -5
  341. package/dist/signin/layer.d.mts +9 -0
  342. package/dist/signin/layer.mjs +41 -0
  343. package/dist/signin/namespace.d.mts +2 -0
  344. package/dist/signin/public.d.mts +6 -0
  345. package/dist/signin/public.mjs +5 -0
  346. package/dist/signin/route.mjs +47 -21
  347. package/dist/signin/web.mjs +3 -3
  348. package/dist/signin/wire.mjs +1 -1
  349. package/dist/storage/calls.d.mts +1 -1
  350. package/dist/storage/calls.mjs +4 -4
  351. package/dist/storage/clean-up.mjs +15 -6
  352. package/dist/storage/counted-bucket.mjs +34 -51
  353. package/dist/storage/fetch.mjs +1 -1
  354. package/dist/storage/fsck.mjs +12 -2
  355. package/dist/storage/graph-rebuild.mjs +262 -0
  356. package/dist/storage/host-bucket.mjs +1 -1
  357. package/dist/storage/index-build.d.mts +2 -2
  358. package/dist/storage/index-build.mjs +103 -15
  359. package/dist/storage/index-fetch.mjs +10 -6
  360. package/dist/storage/index-graph.mjs +1 -1
  361. package/dist/storage/index-layers.mjs +1 -1
  362. package/dist/storage/index-visible.mjs +1 -1
  363. package/dist/storage/lfs-pointers.d.mts +5 -5
  364. package/dist/storage/lfs-pointers.mjs +37 -11
  365. package/dist/storage/loose.mjs +4 -1
  366. package/dist/storage/memory-budget.mjs +8 -2
  367. package/dist/storage/merge-cut.mjs +24 -1
  368. package/dist/storage/merge-fence.mjs +82 -20
  369. package/dist/storage/merge-most.mjs +1 -0
  370. package/dist/storage/merge-plan.mjs +5 -2
  371. package/dist/storage/merge-row.mjs +17 -5
  372. package/dist/storage/merge-stream.mjs +25 -13
  373. package/dist/storage/merge-write.mjs +1 -1
  374. package/dist/storage/merge.d.mts +2 -2
  375. package/dist/storage/merge.mjs +1 -1
  376. package/dist/storage/object-rows.d.mts +2 -2
  377. package/dist/storage/object-rows.mjs +20 -4
  378. package/dist/storage/pack-ranges.d.mts +3 -1
  379. package/dist/storage/pack-ranges.mjs +168 -69
  380. package/dist/storage/pack-reads.mjs +4 -4
  381. package/dist/storage/pack-receive.d.mts +1 -1
  382. package/dist/storage/pack-receive.mjs +17 -15
  383. package/dist/storage/packs.d.mts +1 -1
  384. package/dist/storage/packs.mjs +103 -79
  385. package/dist/storage/placed-reads.mjs +81 -15
  386. package/dist/storage/prune-seen.mjs +126 -0
  387. package/dist/storage/prune-walk.mjs +87 -99
  388. package/dist/storage/prune.mjs +113 -50
  389. package/dist/storage/push-uploads.mjs +4 -2
  390. package/dist/storage/quarantine.d.mts +2 -2
  391. package/dist/storage/ready.d.mts +2 -2
  392. package/dist/storage/ready.mjs +15 -6
  393. package/dist/storage/receive-files.mjs +1 -1
  394. package/dist/storage/receive-links.mjs +1 -1
  395. package/dist/storage/receive-state.d.mts +2 -2
  396. package/dist/storage/receive-state.mjs +2 -2
  397. package/dist/storage/receive-steps.mjs +1 -1
  398. package/dist/storage/repack-contained.mjs +24 -16
  399. package/dist/storage/repack-job.d.mts +2 -2
  400. package/dist/storage/repack-job.mjs +5 -4
  401. package/dist/storage/repack.d.mts +2 -2
  402. package/dist/storage/repack.mjs +12 -5
  403. package/dist/storage/rows.d.mts +2 -2
  404. package/dist/storage/rows.mjs +1 -1
  405. package/dist/storage/runs.d.mts +2 -2
  406. package/dist/storage/runs.mjs +15 -6
  407. package/dist/storage/send-list.mjs +6 -6
  408. package/dist/storage/single-flight.mjs +2 -2
  409. package/dist/storage/swap-walk.mjs +1 -1
  410. package/dist/storage/unpack.mjs +8 -1
  411. package/dist/store/call-count.d.mts +24 -4
  412. package/dist/store/call-count.mjs +158 -44
  413. package/dist/store/catalogue.d.mts +1 -1
  414. package/dist/store/catalogue.mjs +2 -2
  415. package/dist/store/crossing.mjs +2 -6
  416. package/dist/store/cursor-seal.mjs +1 -1
  417. package/dist/store/errors.d.mts +7 -3
  418. package/dist/store/errors.mjs +41 -13
  419. package/dist/store/job-try.mjs +119 -15
  420. package/dist/store/list-job.mjs +5 -5
  421. package/dist/store/outbox.d.mts +2 -2
  422. package/dist/store/outbox.mjs +75 -16
  423. package/dist/store/promises.d.mts +2 -2
  424. package/dist/store/promises.mjs +31 -6
  425. package/dist/store/queue-jobs.mjs +1 -1
  426. package/dist/store/records.d.mts +2 -2
  427. package/dist/store/records.mjs +22 -24
  428. package/dist/store/ref-rows.d.mts +2 -2
  429. package/dist/store/ref-rows.mjs +6 -6
  430. package/dist/store/repo-record.mjs +29 -12
  431. package/dist/store/reservations.mjs +35 -8
  432. package/dist/store/scopes.mjs +12 -5
  433. package/dist/store/topic-jobs.mjs +8 -8
  434. package/dist/sync/bound.d.mts +1 -3
  435. package/dist/sync/bound.mjs +30 -42
  436. package/dist/sync/github.d.mts +5 -6
  437. package/dist/sync/github.mjs +37 -42
  438. package/dist/sync/http.mjs +15 -0
  439. package/dist/sync/import.mjs +30 -19
  440. package/dist/sync/layer.d.mts +13 -0
  441. package/dist/sync/layer.mjs +73 -0
  442. package/dist/sync/mirror.mjs +137 -58
  443. package/dist/sync/publish.mjs +3 -6
  444. package/dist/sync/step.mjs +223 -85
  445. package/dist/sync/tries.mjs +22 -15
  446. package/dist/sync.d.mts +3 -6
  447. package/dist/sync.mjs +3 -6
  448. package/dist/topics/advance.mjs +210 -94
  449. package/dist/topics/calls.mjs +8 -8
  450. package/dist/topics/directory.mjs +35 -12
  451. package/dist/topics/host.d.mts +5 -8
  452. package/dist/topics/host.mjs +42 -19
  453. package/dist/topics/layer.d.mts +381 -0
  454. package/dist/topics/layer.mjs +62 -0
  455. package/dist/topics/members.mjs +39 -10
  456. package/dist/topics/namespace.d.mts +2 -0
  457. package/dist/topics/public.d.mts +6 -0
  458. package/dist/topics/public.mjs +13 -0
  459. package/dist/topics/rows.mjs +12 -3
  460. package/dist/topics/topic.mjs +11 -10
  461. package/package.json +8 -13
  462. package/dist/access.d.mts +0 -2
  463. package/dist/access.mjs +0 -1
  464. package/dist/core/hooks/post-receive.mjs +0 -216
  465. package/dist/core/hooks/pre-receive.d.mts +0 -12
  466. package/dist/core/hooks/pre-receive.mjs +0 -36
  467. package/dist/engine/merge-base-walk.d.mts +0 -3
  468. package/dist/server/extension.d.mts +0 -21
  469. package/dist/server/routes.d.mts +0 -32
  470. package/dist/server/routes.mjs +0 -69
  471. package/dist/sync/import.d.mts +0 -10
  472. package/dist/sync/jobs.d.mts +0 -9
  473. package/dist/sync/jobs.mjs +0 -75
  474. package/dist/sync/mirror.d.mts +0 -13
  475. package/dist/sync/publish.d.mts +0 -6
  476. /package/dist/core/{claim-rows.d.mts → registered-rows.d.mts} +0 -0
@@ -3,6 +3,7 @@ import { fail } from "../contracts/result.mjs";
3
3
  import { objectsFace, oneShotReads } from "../storage/calls.mjs";
4
4
  import { indexRowKey, isPackId, objectCollections } from "../storage/layout.mjs";
5
5
  import { noLfsPointers } from "../storage/lfs-pointers.mjs";
6
+ import { noRows } from "../storage/object-rows.mjs";
6
7
  import { holdingsOf, swapsOf } from "../storage/repack.mjs";
7
8
  import { SwapsSettled, holdingKey, swapsKey } from "../storage/swap-walk.mjs";
8
9
  import { ApartRow, apartAfter, apartKey } from "../storage/repack-contained.mjs";
@@ -14,11 +15,12 @@ import { appendEvents, decodeOutbox, dropUnconfirmed, emptyOutbox, outboxReads,
14
15
  import { keptKey } from "../store/records.mjs";
15
16
  import { WholeRepo, refBytesOf, storesPeel, wholeRef, wholeRefs } from "../store/ref-rows.mjs";
16
17
  import { peeledAll } from "../storage/wants.mjs";
17
- import { commitRecord, decodeTimes, readRecord, timeRow, writeRecord } from "../store/repo-record.mjs";
18
+ import { commitRecord, decodeStats, looseRows, readRecord, timeRow, writeRecord } from "../store/repo-record.mjs";
18
19
  import { afterCommit } from "../store/call-count.mjs";
19
20
  import { listBound } from "../store/cursor-seal.mjs";
20
21
  import { settleName } from "../store/settle.mjs";
21
- import { collections, newChangeId, newInternalId, pushedKey, repoScope, selfKey } from "../store/scopes.mjs";
22
+ import { rowsPut } from "./loose-tally.mjs";
23
+ import { collections, looseKey, newChangeId, newInternalId, pushedKey, repoScope, selfKey } from "../store/scopes.mjs";
22
24
  import { alreadyExists, callerFor, contended, contendedAfterWrites, hiddenCodes, indexJobs, keyedRecord, nameMoved, openKeyed, openRepo, refIndexJobs, repoAccess, sizedRead, statsReads, unlessHidden } from "./access.mjs";
23
25
  import { infoReads, repoInfo } from "./repo-info.mjs";
24
26
  import { kindsOf } from "./ancestry.mjs";
@@ -26,23 +28,23 @@ import { isHolder } from "./names.mjs";
26
28
  import { decidePush } from "./push-decide.mjs";
27
29
  import { gitsOwnRef } from "./rules/check.mjs";
28
30
  import { refCopies } from "./ref-index.mjs";
29
- import { heldReceipt, receiptKeys, receiptReads, receiptWrites, repoAnswer, withJobs } from "./receipts.mjs";
31
+ import { forkKept, heldReceipt, receiptKeys, receiptReads, receiptWrites, repoAnswer, withJobs } from "./receipts.mjs";
30
32
  import { badRepoName, repoKept } from "./repos.mjs";
31
33
  import { pushCounts } from "./events/seen.mjs";
32
34
  import { refViewIn } from "./ref-view.mjs";
33
35
  import { SealedObjects } from "./view.mjs";
34
36
  import { CoreParts, ObjectsParts } from "./parts.mjs";
35
37
  import { check } from "../contracts/authorize.mjs";
36
- import { jsonBytes, limits } from "@ref0/infra";
37
- import * as Effect from "effect/Effect";
38
38
  import * as Clock$1 from "effect/Clock";
39
+ import * as Effect from "effect/Effect";
40
+ import { jsonBytes, limits } from "@ref0/infra";
39
41
  // src/core/forks.ts
40
42
  /**
41
- * A fork copies every ref and object of its source, private or not, until piece 3 copies only
42
- * what its caller sees: see `before-production.md`.
43
+ * A fork reads its source's refs and packs whole, then copies only the refs its caller sees there
44
+ * (`seenSource`): the packs are shared whole, and its reads by ID follow its own tips' reach.
43
45
  */
44
46
  const forkWhole = /* @__PURE__ */ WholeRepo.mint();
45
- /** A fork's `index` row as `repoInfo` reads it, by its place after `statsReads`'. */
47
+ /** A fork's `index` row as `repoInfo` reads it, by its place after `statsReads`' four. */
46
48
  const indexRowsOf = (rows) => rows.indexRow === void 0 ? [] : [rows.indexRow];
47
49
  const refsRead = { collection: collections.refs };
48
50
  const packsRead = { collection: collections.packs };
@@ -293,20 +295,35 @@ const copyRoom = {
293
295
  bytes: 524288
294
296
  };
295
297
  const mib = 1048576;
296
- /** `RESOURCE_EXHAUSTED` for a copy of `source` whose commit takes `writes` and `bytes`, past one's. */
297
- const refuseCopy = (source, writes, bytes) => {
298
- const past = writes > limits.writes ? `${limits.writes} writes` : bytes > limits.bytes ? `${limits.bytes / mib} MiB` : void 0;
299
- if (past === void 0) return Effect.void;
300
- return fail("RESOURCE_EXHAUSTED", `'${source}' is too large to fork: its copy passes one commit's ${past}`, {
301
- hint: "Forks of repos this large aren't supported yet",
298
+ /**
299
+ * `RESOURCE_EXHAUSTED`, reason `too-large`, for a copy of `source` whose commit `measured` passes
300
+ * one commit's writes or bytes: it names each it passes, with what was measured, as a lower bound
301
+ * when `atLeast`. Every storage copies a fork in one commit; `loose()`'s keeps each object as a
302
+ * row of it, which `Objects.layer()` keeps in the bucket.
303
+ */
304
+ const refuseCopy = (source, measured) => {
305
+ const { writes, bytes, room } = measured;
306
+ const takes = measured.atLeast ? "at least " : "";
307
+ const kept = (part) => part === 0 ? "" : `, ${part} of them kept beside the copy`;
308
+ const past = [...writes > limits.writes ? [`${takes}${writes} writes${kept(room.writes)}, past one commit's ${limits.writes} writes`] : [], ...bytes > limits.bytes ? [`${takes}${bytes} bytes${kept(room.bytes)}, past one commit's ${limits.bytes / mib} MiB`] : []];
309
+ if (past.length === 0) return Effect.void;
310
+ return fail("RESOURCE_EXHAUSTED", `'${source}' is too large to fork: its commit takes ${past.join(", and ")}`, {
311
+ hint: "A fork is made in one commit, and this repo's copy doesn't fit one",
312
+ hostHint: "A fork is copied in one commit on every storage. With loose() storage, which keeps each object as a row, use Objects.layer(), which keeps objects in the bucket",
302
313
  context: { reason: "too-large" }
303
314
  });
304
315
  };
305
316
  /**
306
- * `refuseCopy` for a copy of `source` whose rows, with `copyRoom`, pass one commit's. A create or
307
- * sync checks its first read, before any marker, so a refusal there leaves none.
317
+ * `refuseCopy` for a copy of `source` whose rows, with `copyRoom`, pass one commit's: at least,
318
+ * as its commit adds its record, receipt and events. A create or sync checks its first read,
319
+ * before any marker, so a refusal there leaves none.
308
320
  */
309
- const checkCopy = (source, rows) => refuseCopy(source, rows.length + copyRoom.writes, jsonBytes(rows) + copyRoom.bytes);
321
+ const checkCopy = (source, rows) => refuseCopy(source, {
322
+ writes: rows.length + copyRoom.writes,
323
+ bytes: jsonBytes(rows) + copyRoom.bytes,
324
+ room: copyRoom,
325
+ atLeast: true
326
+ });
310
327
  /**
311
328
  * `refuseCopy` for the change a create or sync commits, its puts, deletes and jobs counted as the
312
329
  * store counts them, with `room` for what the write adds beside: the read it lists may be a
@@ -317,7 +334,12 @@ const checkChange = (source, change, room = {
317
334
  bytes: 0
318
335
  }) => {
319
336
  const writes = (change.put?.length ?? 0) + (change.delete?.length ?? 0) + (change.jobs?.length ?? 0);
320
- return refuseCopy(source, writes + room.writes, jsonBytes(change) + room.bytes);
337
+ return refuseCopy(source, {
338
+ writes: writes + room.writes,
339
+ bytes: jsonBytes(change) + room.bytes,
340
+ room,
341
+ atLeast: false
342
+ });
321
343
  };
322
344
  /** Whether `record` is a live fork of `source`. */
323
345
  const isForkOf = (record, source) => record !== void 0 && record.deleted !== true && record.fork?.upstreamInternalId === source;
@@ -364,9 +386,14 @@ const sourceRows = /* @__PURE__ */ Effect.fnUntraced(function* (read, lacking, s
364
386
  if (signal !== void 0) input.signal = signal;
365
387
  const page = yield* copyRows(read.listed, input);
366
388
  if ("moved" in page) return void 0;
389
+ if (page.rows.length > 0) bytes += jsonBytes(page.rows) - (rows.length > 0 ? 1 : 0);
367
390
  rows.push(...page.rows);
368
- bytes += jsonBytes(page.rows);
369
- yield* refuseCopy(read.name, rows.length + copyRoom.writes, bytes + copyRoom.bytes);
391
+ yield* refuseCopy(read.name, {
392
+ writes: rows.length + copyRoom.writes,
393
+ bytes: bytes + copyRoom.bytes,
394
+ room: copyRoom,
395
+ atLeast: true
396
+ });
370
397
  if (page.next === void 0) return rows;
371
398
  after = page.next;
372
399
  }
@@ -560,6 +587,7 @@ const forkCalls = (bound) => {
560
587
  id
561
588
  ], at);
562
589
  const looked = yield* lookUp(id, kept, caller);
590
+ if (looked.kind === "answered" && looked.receipt.answer?.kind === "fork") return (yield* forkInfo(caller, source, looked.repo.internalId)) ?? (yield* fail("NOT_FOUND", `No repo '${looked.repo.name}'`));
563
591
  if (looked.kind === "answered") return yield* repoAnswer(looked.receipt);
564
592
  const { entry } = looked;
565
593
  const existing = yield* holdersFork(caller, opened.name, source, holder);
@@ -615,17 +643,13 @@ const forkCalls = (bound) => {
615
643
  const listing = new Set(read.listed.packs.map((pack) => pack.id));
616
644
  const covered = read.listed.packs.flatMap(({ id }) => isPackId(id) ? [leavingKey(id)] : []);
617
645
  const pushed = read.refs.length === 0 ? [] : [timeRow(pushedKey, void 0, at)];
646
+ const loose = looseRows(void 0, rowsPut(objects));
618
647
  const rows = [
619
648
  ...forkRows(core.refIndex, read, objects),
620
649
  ...pushed,
650
+ ...loose,
621
651
  ...unlisted(marked, listing, at)
622
652
  ];
623
- const info = yield* repoInfo(caller, internalId, record, [
624
- read.refs,
625
- read.packs,
626
- pushed
627
- ]);
628
- const receipt = receiptWrites(kept, repoKept(info), core.repackJobRow);
629
653
  const created = {
630
654
  type: "repo.created",
631
655
  ...repoEnvelope(caller, id),
@@ -642,6 +666,7 @@ const forkCalls = (bound) => {
642
666
  options.from = entry.nextSeq;
643
667
  options.after = entry.internalId;
644
668
  }
669
+ const receipt = receiptWrites(kept, forkKept, core.repackJobRow);
645
670
  const appended = yield* appendEvents(core.events, emptyOutbox, [created], options);
646
671
  const put = [
647
672
  ...rows,
@@ -671,7 +696,11 @@ const forkCalls = (bound) => {
671
696
  jobs
672
697
  });
673
698
  if (written === void 0) return yield* contended();
674
- if (written.outcome === "won") return info;
699
+ if (written.outcome === "won") return yield* afterCommit(repoInfo(caller, internalId, record, [
700
+ read.refs,
701
+ read.packs,
702
+ [...pushed, ...loose]
703
+ ]));
675
704
  const dropped = dropUnconfirmed(appended.head);
676
705
  const aside = commitRecord(store, internalId, {
677
706
  expect: written.version,
@@ -831,7 +860,7 @@ const forkCalls = (bound) => {
831
860
  repo: name
832
861
  }), hiddenFork);
833
862
  if (record === void 0 || record.deleted === true) return yield* fail("NOT_FOUND", `No repo '${fork}'`);
834
- const [, refRows = [], packRows = [], timeRows = [], leavingRows = [], coverRows = [], indexRows = [], apartRows = [], swapsRows = []] = snapshot.results;
863
+ const [, refRows = [], packRows = [], timeRows = [], readyRows = [], leavingRows = [], coverRows = [], indexRows = [], apartRows = [], swapsRows = []] = snapshot.results;
835
864
  const [headRows = [], cursorRows = [], ...afterOutbox] = snapshot.results.slice(1 + reads.length);
836
865
  const keyed = receiptReads(kept).length;
837
866
  yield* fence.check(afterOutbox.slice(keyed));
@@ -871,6 +900,7 @@ const forkCalls = (bound) => {
871
900
  refRows,
872
901
  packRows,
873
902
  timeRows,
903
+ readyRows,
874
904
  leavingRows,
875
905
  coverRows,
876
906
  apartRows,
@@ -975,10 +1005,14 @@ const forkCalls = (bound) => {
975
1005
  ...lacked,
976
1006
  ...unlisted(shared, covered, into.at),
977
1007
  ...swapped,
978
- ...apartAfter(found, { remove }),
1008
+ ...apartAfter(found, {
1009
+ remove,
1010
+ rows: noRows
1011
+ }),
979
1012
  ...swapsAfter(/* @__PURE__ */ new Set([...kept, ...source.listed.packs.map(({ id }) => id)]), swapsBefore, into.walks)
980
1013
  ],
981
- delete: [...added.flatMap(({ id }) => isPackId(id) ? [leavingKey(id)] : []), ...held.flatMap(({ key, pack }) => key.collection === objectCollections.cover && adding.has(pack) ? [key] : [])]
1014
+ delete: [...added.flatMap(({ id }) => isPackId(id) ? [leavingKey(id)] : []), ...held.flatMap(({ key, pack }) => key.collection === objectCollections.cover && adding.has(pack) ? [key] : [])],
1015
+ rows: rowsPut(lacked)
982
1016
  },
983
1017
  bytes: added.reduce((sum, pack) => sum + pack.bytes, 0),
984
1018
  objects: added.reduce((sum, pack) => sum + pack.objects, 0),
@@ -1017,7 +1051,7 @@ const forkCalls = (bound) => {
1017
1051
  const read = yield* forkTry(fork, caller, internalId, kept, (target, record) => authorizeSync(caller, target, record));
1018
1052
  if (read === void 0) continue;
1019
1053
  const { record, snapshot, name, outbox, rows } = read;
1020
- const { refRows, packRows, timeRows, leavingRows } = rows;
1054
+ const { refRows, packRows, timeRows, readyRows, leavingRows } = rows;
1021
1055
  const receipt = yield* heldReceipt(read.receipts, kept);
1022
1056
  if (receipt !== void 0) return yield* repoAnswer(receipt);
1023
1057
  const named = {
@@ -1043,6 +1077,7 @@ const forkCalls = (bound) => {
1043
1077
  refRows,
1044
1078
  packRows,
1045
1079
  timeRows,
1080
+ readyRows,
1046
1081
  indexRowsOf(rows)
1047
1082
  ]);
1048
1083
  const left = unlisted(shared, /* @__PURE__ */ new Set([...listing, ...leavingRows.map(({ id }) => id)]), at);
@@ -1140,13 +1175,19 @@ const forkCalls = (bound) => {
1140
1175
  value: { oid: to }
1141
1176
  }];
1142
1177
  const listedRows = [...packRows.filter(({ id }) => !removing.has(id)), ...added.map(packRow)];
1143
- const times = yield* decodeTimes(timeRows);
1178
+ const times = yield* decodeStats(timeRows);
1144
1179
  const pushed = timeRow(pushedKey, times.pushed, at);
1145
- const timed = [...timeRows.filter(({ id }) => id !== pushedKey.id), pushed];
1180
+ const loose = looseRows(times.loose, received.change.rows);
1181
+ const timed = [
1182
+ ...timeRows.filter(({ id }) => id !== pushedKey.id && (loose.length === 0 || id !== looseKey.id)),
1183
+ pushed,
1184
+ ...loose
1185
+ ];
1146
1186
  const info = yield* repoInfo(caller, internalId, named, [
1147
1187
  moved,
1148
1188
  listedRows,
1149
1189
  timed,
1190
+ readyRows,
1150
1191
  indexRowsOf(rows)
1151
1192
  ]);
1152
1193
  const keptWrites = receiptWrites(kept, repoKept(info), core.repackJobRow);
@@ -1179,6 +1220,7 @@ const forkCalls = (bound) => {
1179
1220
  put: leavingLate([
1180
1221
  ...decision.change.put,
1181
1222
  pushed,
1223
+ ...loose,
1182
1224
  ...keptWrites.put,
1183
1225
  ...appended.put
1184
1226
  ], late),
@@ -1282,9 +1324,11 @@ const forkCalls = (bound) => {
1282
1324
  return answer.kind === "error" ? yield* Effect.fail(answer.error) : fetched;
1283
1325
  }
1284
1326
  const late = (yield* Clock$1.currentTimeMillis) - at;
1327
+ const times = yield* decodeStats(rows.timeRows);
1328
+ const loose = looseRows(times.loose, received.change.rows);
1285
1329
  const change = {
1286
1330
  ...decision.change,
1287
- put: leavingLate(decision.change.put, late),
1331
+ put: [...leavingLate(decision.change.put, late), ...loose],
1288
1332
  jobs: [core.repackJobRow()]
1289
1333
  };
1290
1334
  yield* checkChange(source.name, change);
@@ -0,0 +1,26 @@
1
+ import { Git } from "../../contracts/git.mjs";
2
+ import { GroupOptions, Handlers, HookPoint, PushCheckHandler } from "../../contracts/git-hooks.mjs";
3
+ import "../../contracts/ids.mjs";
4
+ import "../../contracts/refs.mjs";
5
+ import { GitError } from "../../contracts/result.mjs";
6
+ import "../rules/context.mjs";
7
+ import "./order.mjs";
8
+ import "effect/Effect";
9
+ import * as Layer from "effect/Layer";
10
+ /** A host's hook group as Git's registry keeps it: its name, its handlers' services given. */
11
+ export interface HookGroup {
12
+ readonly name: string;
13
+ readonly check?: PushCheckHandler<never>;
14
+ /** How long its handler may run, in milliseconds. */
15
+ readonly timeout?: number;
16
+ }
17
+ /** A group's build: it takes the points left, and gives the handlers it added. */
18
+ type Build<R> = (hooks: Handlers<HookPoint, never>) => Handlers<never, R> | Handlers<HookPoint, R>;
19
+ /**
20
+ * A host's hook group, `name`: a contribution Layer that registers `name`, so no registration, delivery
21
+ * or other group takes it, and adds its handlers. Every group in the runtime runs on each push, by
22
+ * band then name, after the rules and every registration's push check. A refusal, a failure, a
23
+ * defect or a run past `timeout` refuses the whole push.
24
+ */
25
+ export declare const group: <R = never>(name: string, ...input: readonly [build: Build<R>] | readonly [options: GroupOptions, build: Build<R>]) => Layer.Layer<never, GitError, Git | R>;
26
+ export {};
@@ -0,0 +1,73 @@
1
+ import { hostEffect, logRefusal, rejectedError } from "../../auth/host-function.mjs";
2
+ import { register } from "../../contracts/git.mjs";
3
+ import { handlersOf } from "../../contracts/git-hooks.mjs";
4
+ import { millis } from "../../contracts/promises.mjs";
5
+ import { checkedAnswer, plainAnswer, pushContextOf } from "../rules/context.mjs";
6
+ import * as Effect from "effect/Effect";
7
+ import * as Layer from "effect/Layer";
8
+ // src/core/hooks/groups.ts
9
+ const adders = /* @__PURE__ */ new WeakMap();
10
+ /** Lets `group` add to `registration`'s registry: the registry calls it for each registration it makes. */
11
+ const bindHookGroups = (registration, add) => {
12
+ adders.set(registration, add);
13
+ };
14
+ /** Adds `group` to the registry that made `registration`: a defect for one no registry made. */
15
+ const addHookGroup = (registration, group) => Effect.suspend(() => {
16
+ const add = adders.get(registration);
17
+ return add === void 0 ? Effect.die(/* @__PURE__ */ new Error(`Git's registry takes no hook group for '${registration.name}'`)) : add(group);
18
+ });
19
+ /**
20
+ * A host's hook group, `name`: a contribution Layer that registers `name`, so no registration, delivery
21
+ * or other group takes it, and adds its handlers. Every group in the runtime runs on each push, by
22
+ * band then name, after the rules and every registration's push check. A refusal, a failure, a
23
+ * defect or a run past `timeout` refuses the whole push.
24
+ */
25
+ const group = (name, ...input) => Layer.effectDiscard(Effect.gen(function* () {
26
+ const [options, build] = input.length === 1 ? [{}, input[0]] : input;
27
+ const registration = yield* register({ name });
28
+ const context = yield* Effect.context();
29
+ const { handlers } = build(handlersOf({}));
30
+ const check = handlers["push.check"];
31
+ const made = { name };
32
+ if (check !== void 0) made.check = (push) => Effect.provideContext(check(push), context);
33
+ if (options.timeout !== void 0) made.timeout = millis(options.timeout);
34
+ yield* addHookGroup(registration, options.order === void 0 ? made : {
35
+ order: options.order,
36
+ handler: made
37
+ });
38
+ }));
39
+ /**
40
+ * Every host group's `push.check`, once on the whole write, by band then name: with the refs the
41
+ * checks before left, unless none is left, or an atomic push already lost one. The first refusal,
42
+ * failure or run past its timeout is the answer, which refuses every ref; `undefined` lets it on.
43
+ */
44
+ const runHookGroups = /* @__PURE__ */ Effect.fnUntraced(function* (groups, checking, write) {
45
+ const left = write.updates.filter((update) => !write.refused.has(update.ref));
46
+ const lost = left.length < write.updates.length;
47
+ if (left.length === 0 || write.atomic && lost) return void 0;
48
+ const { about } = checking;
49
+ const input = pushContextOf(checking, left, {
50
+ key: "",
51
+ updates: left
52
+ }, { atomic: write.atomic });
53
+ for (const { handler } of groups) {
54
+ const { check } = handler;
55
+ if (check === void 0) continue;
56
+ const label = `The '${handler.name}' hook group`;
57
+ const options = handler.timeout === void 0 ? { label } : {
58
+ label,
59
+ timeout: handler.timeout
60
+ };
61
+ const call = hostEffect("hooks", about, checkedAnswer(label, plainAnswer, () => check(input)), options);
62
+ const refusal = yield* Effect.matchEffect(call, {
63
+ onFailure: (error) => Effect.succeed(error),
64
+ onSuccess: (answer) => {
65
+ if (answer.kind === "accept") return Effect.succeed(void 0);
66
+ const error = rejectedError(answer);
67
+ return Effect.as(logRefusal("hooks", about, error), error);
68
+ }
69
+ });
70
+ if (refusal !== void 0) return refusal;
71
+ }
72
+ });
73
+ export { addHookGroup, bindHookGroups, group, runHookGroups };
@@ -0,0 +1,2 @@
1
+ import { public_d_exports } from "./public.mjs";
2
+ export { public_d_exports as GitHooks };
@@ -1,9 +1,9 @@
1
1
  import "../../contracts/git.mjs";
2
2
  /** A hook's band: `pre`, then the plain ones, then `post` (Q3). */
3
3
  export type Band = 'pre' | 'plain' | 'post';
4
- /** One claim's hook, as the registry keeps it: its claim, its band and its handler. */
4
+ /** One registration's hook, as the registry keeps it: its registration, its band and its handler. */
5
5
  export interface Ordered<F> {
6
- readonly claim: string;
6
+ readonly registration: string;
7
7
  readonly band: Band;
8
8
  readonly handler: F;
9
9
  }
@@ -2,15 +2,15 @@ import * as Predicate from "effect/Predicate";
2
2
  // src/core/hooks/order.ts
3
3
  /** Whether `hook` declares its order: an object with `order` and `handler`, which no hook is. */
4
4
  const declared = (hook) => Predicate.hasProperty(hook, "order") && Predicate.hasProperty(hook, "handler");
5
- /** `hook` as `claim`'s, in its band: plain when it declares no order. */
6
- const orderedOf = (claim, hook) => {
5
+ /** `hook` as `registration`'s, in its band: plain when it declares no order. */
6
+ const orderedOf = (registration, hook) => {
7
7
  if (declared(hook)) return {
8
- claim,
8
+ registration,
9
9
  band: hook.order,
10
10
  handler: hook.handler
11
11
  };
12
12
  return {
13
- claim,
13
+ registration,
14
14
  band: "plain",
15
15
  handler: hook
16
16
  };
@@ -20,6 +20,6 @@ const bandRank = {
20
20
  plain: 1,
21
21
  post: 2
22
22
  };
23
- /** `a` before `b` by band, then claim name: the order every hook kind runs in. */
24
- const byOrder = (a, b) => bandRank[a.band] - bandRank[b.band] || (a.claim < b.claim ? -1 : a.claim > b.claim ? 1 : 0);
23
+ /** `a` before `b` by band, then registration name: the order every hook kind runs in. */
24
+ const byOrder = (a, b) => bandRank[a.band] - bandRank[b.band] || (a.registration < b.registration ? -1 : a.registration > b.registration ? 1 : 0);
25
25
  export { bandRank, byOrder, orderedOf };
@@ -0,0 +1,7 @@
1
+ import { group } from "./groups.mjs";
2
+ import { GroupOptions, Handlers, HookPoint, PushCheckHandler, PushHookInput } from "../../contracts/git-hooks.mjs";
3
+ import { DecisionAnswer } from "../../contracts/result.mjs";
4
+ declare namespace public_d_exports {
5
+ export { DecisionAnswer, GroupOptions, Handlers, HookPoint, PushCheckHandler, PushHookInput, group };
6
+ }
7
+ export { type DecisionAnswer, type GroupOptions, type Handlers, type HookPoint, type PushCheckHandler, type PushHookInput, group, public_d_exports };
@@ -0,0 +1,5 @@
1
+ import { __exportAll } from "../../_virtual/_rolldown/runtime.mjs";
2
+ import { group } from "./groups.mjs";
3
+ // src/core/hooks/public.ts
4
+ var public_exports = /* @__PURE__ */ __exportAll({ group: () => group });
5
+ export { group, public_exports };
@@ -1,23 +1,31 @@
1
1
  import { SyncSource } from "../contracts/sync.mjs";
2
2
  import { KeptError, keptError } from "./receipts.mjs";
3
+ import { SavedCaller } from "./saved-callers.mjs";
3
4
  import { hexOf } from "../protocol/bytes/hex.mjs";
4
5
  import { oidBytes } from "../protocol/packs/idx.mjs";
5
6
  import { decodeRow, storeCall } from "../store/errors.mjs";
6
7
  import { importJobName } from "../store/records.mjs";
8
+ import { refRowBytes, storesPeel } from "../store/ref-rows.mjs";
7
9
  import { isPackId } from "../storage/layout.mjs";
8
10
  import { receiveKey } from "../storage/receive-steps.mjs";
9
11
  import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
10
12
  import { gitError } from "../contracts/result.mjs";
11
- import * as Schema from "effect/Schema";
12
13
  import * as Effect from "effect/Effect";
14
+ import * as Schema from "effect/Schema";
13
15
  import * as Result from "effect/Result";
16
+ import { jsonBytes } from "@ref0/infra";
14
17
  import * as Base64 from "effect/encoding/Base64";
15
18
  // src/core/imports.ts
16
19
  /**
17
20
  * An import's own record, `imports/self` in its repo's scope, written by the create that starts it
18
21
  * and by each step's commit, so a try after a crash goes on from the last step that landed:
19
- * - `tips`: the remote's branches and tags as the import's first step listed them, each moved
20
- * to its tip by the last step, `publish`;
22
+ * - `tipPages`: how many pages of tips the import's first step listed, the remote's branches and
23
+ * tags, each moved to its tip by the last step, `publish`, a page at a time, as `TipPage` says;
24
+ * none until that step lands;
25
+ * - `publishedPages`: how many of those pages `publish` has moved, the cursor each page's commit
26
+ * moves with its refs;
27
+ * - `head`: the branch the remote's `HEAD` named at that listing, kept only when it's one of
28
+ * the tips, which `publish` makes the repo's default branch, in the last page's commit;
21
29
  * - `roots`: where the history copied so far stops, the remote's `shallow` lines; `deepest`, how
22
30
  * many commits from each tip it holds; `step`, how many more the next segment asks for;
23
31
  * - `copied`: whether the history is whole, so the next step publishes;
@@ -45,14 +53,21 @@ const ImportReceiving = /* @__PURE__ */ Schema.Struct({
45
53
  bytes: Schema.Int
46
54
  })
47
55
  });
56
+ /**
57
+ * An import's record. `by`: who started it, as `SavedCaller` keeps them, asked again before each
58
+ * step, so the import fetches, publishes and offers the remote only what they may still see.
59
+ */
48
60
  const ImportRow = /* @__PURE__ */ Schema.Struct({
49
61
  source: SyncSource,
62
+ by: SavedCaller,
50
63
  state: Schema.Literals([
51
64
  "running",
52
65
  "done",
53
66
  "failed"
54
67
  ]),
55
- tips: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
68
+ tipPages: Schema.optionalKey(Schema.Int),
69
+ publishedPages: Schema.optionalKey(Schema.Int),
70
+ head: Schema.optionalKey(Schema.String),
56
71
  roots: Schema.Array(Schema.String),
57
72
  deepest: Schema.Int,
58
73
  step: Schema.Int,
@@ -99,11 +114,80 @@ const cutKey = {
99
114
  id: "cut"
100
115
  };
101
116
  /**
117
+ * One page of the tips the import's listing kept, `imports/tip/<page>` beside its record: each ref
118
+ * by name, to the OID `publish` moves it to. The listing packs them by their bytes and by the most
119
+ * one push moves, as `tipPagesOf` says, so the record stays small whatever the remote holds, and
120
+ * each page's refs move in one commit with the cursor.
121
+ */
122
+ const TipPage = /* @__PURE__ */ Schema.Record(Schema.String, Schema.String);
123
+ /** Page `page`'s key, zero-padded so the pages list in their order. */
124
+ const tipPageKey = (page) => ({
125
+ collection: collections.imports,
126
+ id: `tip/${String(page).padStart(4, "0")}`
127
+ });
128
+ const tipPageRow = (page, tips) => ({
129
+ ...tipPageKey(page),
130
+ value: tips
131
+ });
132
+ /** The keys of pages `from` to `to`, `to` left out. */
133
+ const tipPageKeys = (from, to) => Array.from({ length: Math.max(0, to - from) }, (_, at) => tipPageKey(from + at));
134
+ /**
102
135
  * What every end of an import deletes in the commit that ends it, publish's, a failure's and a
103
- * cancel's: each key it keeps only while it runs, its cut and the record of the segment `row` is
104
- * receiving in steps, whose keys the quarantine's clean-up takes.
136
+ * cancel's: each key it keeps only while it runs, its cut, the record of the segment `row` is
137
+ * receiving in steps, whose keys the quarantine's clean-up takes, and the pages of tips it hasn't
138
+ * published.
139
+ */
140
+ const importEndDeletes = (row) => [
141
+ { ...cutKey },
142
+ ...row?.receiving === void 0 ? [] : [receiveKey(row.receiving.pack)],
143
+ ...tipPageKeys(row?.publishedPages ?? 0, row?.tipPages ?? 0)
144
+ ];
145
+ const pageMissing = (page) => gitError("DATA_LOSS", `The import's page ${page} of tips is gone`, { hint: failedHint });
146
+ /** Pages `from` to `to` of the import's tips, `to` left out, in one read. */
147
+ const readTipPages = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, from, to) {
148
+ const keys = tipPageKeys(from, to);
149
+ if (keys.length === 0) return [];
150
+ const snapshot = yield* storeCall(() => store.read(repoScope(internalId), keys));
151
+ return yield* Effect.forEach(snapshot.results, ([held], at) => held === void 0 ? Effect.fail(pageMissing(from + at)) : decodeRow(TipPage, held, "Import tip page"));
152
+ });
153
+ /**
154
+ * The bytes the ref row a tip of `ref` puts takes, as `refBytesMost` counts it: a tag's with its
155
+ * peel, its most, since the listing doesn't say which tags are annotated. Its entry in a page
156
+ * takes 42 bytes less, its comma included.
105
157
  */
106
- const importEndDeletes = (row) => row?.receiving === void 0 ? [{ ...cutKey }] : [{ ...cutKey }, receiveKey(row.receiving.pack)];
158
+ const tipRowBytes = (ref, oid) => refRowBytes(ref, storesPeel(ref) ? {
159
+ oid,
160
+ peeled: oid
161
+ } : { oid });
162
+ /** A tip's entry in its page, as UTF-8 JSON: its name, `:`, its OID. */
163
+ const entryBytes = (ref, oid) => jsonBytes(ref) + 1 + jsonBytes(oid);
164
+ /**
165
+ * `tips` packed into pages: each at most `most` entries and, as UTF-8 JSON, `bytes` with its braces
166
+ * and commas, unless one entry alone is past it. `last`'s entry, the head the import adopts, goes on
167
+ * the last page, so the record's fence and the default's move stay in the commit that ends the
168
+ * import.
169
+ */
170
+ const tipPagesOf = (tips, last, limits) => {
171
+ const ordered = [...tips.filter(([ref]) => ref !== last), ...tips.filter(([ref]) => ref === last)];
172
+ const pages = [];
173
+ let page = {};
174
+ let count = 0;
175
+ let bytes = 2;
176
+ for (const [ref, oid] of ordered) {
177
+ const size = entryBytes(ref, oid);
178
+ if (count > 0 && (count >= limits.most || bytes + 1 + size > limits.bytes)) {
179
+ pages.push(page);
180
+ page = {};
181
+ count = 0;
182
+ bytes = 2;
183
+ }
184
+ bytes += (count === 0 ? 0 : 1) + size;
185
+ count += 1;
186
+ page[ref] = oid;
187
+ }
188
+ if (count > 0) pages.push(page);
189
+ return pages;
190
+ };
107
191
  /** `cut` as its row, beside `roots`: none of their parents are anywhere but in it. */
108
192
  const cutRow = (roots, cut) => {
109
193
  const parents = roots.flatMap((root) => cut[root] ?? []);
@@ -163,7 +247,7 @@ const readImport = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalI
163
247
  };
164
248
  });
165
249
  /**
166
- * `ExtendedGit.importState`: the repo's import as its row and cancel row hold it, in one read, or
250
+ * `JoinedCalls.importState`: the repo's import as its row and cancel row hold it, in one read, or
167
251
  * `undefined` for a repo no import made. A running row whose job has gone stays `running`: this
168
252
  * read writes nothing, where `importLive` commits it `failed`.
169
253
  */
@@ -172,7 +256,7 @@ const importStateOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, intern
172
256
  if (row === void 0) return void 0;
173
257
  return row.state === "running" && cancelled ? "cancelled" : row.state;
174
258
  });
175
- /** Whether the repo's `git.sync.import` job is waiting or running: a try is due or under way. */
259
+ /** Whether the repo's `sync.import` job is waiting or running: a try is due or under way. */
176
260
  const jobLive = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId) {
177
261
  const scope = repoScope(internalId);
178
262
  let after;
@@ -209,4 +293,4 @@ const importLive = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalI
209
293
  }
210
294
  return true;
211
295
  });
212
- export { ImportReceiving, ImportRow, cancelKey, cutKey, cutRow, failedHint, failedRow, importEndDeletes, importKey, importLive, importRow, importStateOf, readImport, stoppedTry };
296
+ export { ImportReceiving, ImportRow, cancelKey, cutKey, cutRow, failedHint, failedRow, importEndDeletes, importKey, importLive, importRow, importStateOf, readImport, readTipPages, stoppedTry, tipPageKey, tipPageRow, tipPagesOf, tipRowBytes };