@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,6 @@ import "../contracts/git.mjs";
3
3
  import "../contracts/result.mjs";
4
4
  import "../contracts/ids.mjs";
5
5
  import "../contracts/objects.mjs";
6
- import { JobDefinition, JobInput, Moment } from "@ref0/infra";
6
+ import "effect/Effect";
7
7
  import "effect/Schema";
8
- import "effect/Effect";
8
+ import { JobDefinition, JobInput, Moment } from "@ref0/infra";
@@ -3,27 +3,41 @@ import { objectCollections } from "../storage/layout.mjs";
3
3
  import { tooLargeRead } from "../storage/object-rows.mjs";
4
4
  import { forkedFrom, reconcile, releaseHold } from "../store/catalogue.mjs";
5
5
  import { storeCall } from "../store/errors.mjs";
6
- import { madeJob, repoTry } from "../store/job-try.mjs";
6
+ import { gitJob, repoTry } from "../store/job-try.mjs";
7
7
  import { outboxCollections } from "../store/outbox.mjs";
8
8
  import { readRecord } from "../store/repo-record.mjs";
9
9
  import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
10
- import { isDeliverJob } from "./events/deliver.mjs";
11
- import "./hooks/post-receive.mjs";
10
+ import { isDeliverJob, sentThrough } from "./events/deliver.mjs";
12
11
  import { indexJobName } from "./index-job.mjs";
13
- import { Job, limits } from "@ref0/infra";
14
- import * as Schema from "effect/Schema";
15
12
  import * as Effect from "effect/Effect";
13
+ import * as Schema from "effect/Schema";
14
+ import { Job, limits } from "@ref0/infra";
16
15
  // src/core/purge.ts
17
16
  /**
18
- * `git.purge`, a deleted repo's last job (L61, L130). Once the jobs that drain its bytes have
19
- * ended, it deletes the rows of its scope a page a step, each feature's part first with the bytes
17
+ * `git.purge`, a deleted repo's last job (L61, L130). Not before its delete's `fetchLimits` has
18
+ * passed, so a fetch begun before the delete reads to its end, and once the jobs that drain its
19
+ * bytes have ended, it deletes the rows of its scope a page a step, each feature's part first with the bytes
20
20
  * its rows name, then its record last, so a late try of any other job reads no record and ends.
21
21
  * A source waits while a fork holds it, deleted or not, since a fork's LFS reads through its
22
- * source; a fork's purge releases its hold just before its record goes.
22
+ * source; a fork's purge releases its hold just before its record goes. Then it drops the repo's
23
+ * scopes, the registrations' and its own, so a store frees each, as Turso's deletes its database
24
+ * (#1911, Q1160, Q1161).
23
25
  */
24
26
  /** The most rows a step deletes: inside one commit's `limits.writes`. */
25
27
  const purgePage = 1e3;
26
28
  /**
29
+ * When a waiting purge looks again while what holds it has no time of its own: a failed drain job,
30
+ * a drained row with no job to drain it, a fork's hold or a part's `waits`. Their end wakes no
31
+ * purge, so this bounds how long one stands after it.
32
+ */
33
+ const purgeBackstop = 6e5;
34
+ /**
35
+ * When a waiting purge looks again while a drain job runs, or is due and not yet claimed: a try's
36
+ * default timeout, 30 s, and its lease margin, 30 s. A drain's end wakes no purge, since its row
37
+ * goes only after its try returns, so a purge woken from inside the try would read it running.
38
+ */
39
+ const purgeRunningRelook = 6e4;
40
+ /**
27
41
  * A step's page where its rows passed one read's `limits.answerBytes`, as object rows can: rows
28
42
  * of `limits.valueBytes` each fill half an answer.
29
43
  */
@@ -32,11 +46,11 @@ const purgeLargePage = /* @__PURE__ */ Math.floor(limits.answerBytes / limits.va
32
46
  * The jobs whose work a purge waits for, while one is waiting, running or failed in the repo's
33
47
  * scope: git.repack's moves its packs' bytes out and runs its upkeep's, git.index's deleted round
34
48
  * deletes its index's files, and each delivery's, `git.deliver.<name>`, sends `repo.deleted`. A
35
- * failed one holds the purge until a host retries or discards it. A new job that deletes a repo's
36
- * bytes joins this list, or its check below. Every
37
- * other job ends on the record the purge deletes last: git.list's projection the purge runs itself
38
- * before it, and git.post-receive reads no push once the purge has deleted them. A post-receive try
39
- * already running holds it too: the cursor row it adds once its host returns would outlive the record.
49
+ * failed one holds the purge until a host retries or discards it. A delivery's waiting job that
50
+ * has sent `repo.deleted` holds it no longer, since it waits only to trim events the purge
51
+ * deletes itself. A new job that deletes a repo's bytes joins this list, or its check below.
52
+ * Every other job ends on the record the purge deletes last: git.list's projection the purge runs
53
+ * itself before it.
40
54
  */
41
55
  const drainJobs = /* @__PURE__ */ new Set([repackJobName, indexJobName]);
42
56
  /**
@@ -61,8 +75,6 @@ const drainedCollections = [
61
75
  const purgeCollections = [
62
76
  collections.refs,
63
77
  collections.refIndex,
64
- collections.pushes,
65
- collections.postReceive,
66
78
  collections.receipts,
67
79
  collections.receiptIndex,
68
80
  collections.ownWrites,
@@ -73,6 +85,7 @@ const purgeCollections = [
73
85
  collections.tokenExpiry,
74
86
  collections.queue,
75
87
  collections.queueTargets,
88
+ collections.queueReservations,
76
89
  collections.queueEntries,
77
90
  collections.queueCandidates,
78
91
  collections.queueHolds,
@@ -99,16 +112,33 @@ const purgeJobKey = "purge";
99
112
  const PurgeData = /* @__PURE__ */ Schema.Struct({});
100
113
  const again = { kind: "more" };
101
114
  /**
102
- * Whether a drain job is waiting, running or failed in `scope`, or a post-receive try is running:
103
- * a page of its jobs at a time.
115
+ * When a purge at `at` looks again for one drain job or delivery's: a waiting one's due, a running
116
+ * one's `purgeRunningRelook`, a failed one's `purgeBackstop`. A due time no later than the
117
+ * running re-look's is the queue's to claim at once.
104
118
  */
105
- const draining = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope) {
119
+ const relookFor = (item, at) => {
120
+ if (item.state === "failed") return at + purgeBackstop;
121
+ return item.state === "waiting" ? Math.max(item.due, at + purgeRunningRelook) : at + purgeRunningRelook;
122
+ };
123
+ /**
124
+ * When a purge at `at` looks again for the drain jobs and deliveries waiting, running or failed in
125
+ * `scope`, the soonest of theirs: none when none is left. A page of its jobs at a time. `deleted`
126
+ * is `repo.deleted`'s `seq`, past which a waiting delivery holds nothing; with none, each holds.
127
+ */
128
+ const draining = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope, at, deleted) {
106
129
  let after;
130
+ let soonest;
107
131
  for (;;) {
108
132
  const page = after === void 0 ? {} : { page: { after } };
109
133
  const listing = yield* storeCall(() => store.list(scope, page));
110
- if (listing.items.some((item) => drainJobs.has(item.name) || isDeliverJob(item) || item.name === "git.post-receive" && item.state === "running")) return true;
111
- if (listing.next === void 0) return false;
134
+ for (const item of listing.items) {
135
+ const delivery = isDeliverJob(item);
136
+ if (!drainJobs.has(item.name) && !delivery) continue;
137
+ if (delivery && item.state === "waiting" && deleted !== void 0 && (yield* sentThrough(store, scope, item, deleted))) continue;
138
+ const relook = relookFor(item, at);
139
+ soonest = soonest === void 0 ? relook : Math.min(soonest, relook);
140
+ }
141
+ if (listing.next === void 0) return soonest;
112
142
  after = listing.next;
113
143
  }
114
144
  });
@@ -175,9 +205,22 @@ const discardFailed = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope)
175
205
  }
176
206
  });
177
207
  /**
178
- * One step in the repo's scope: none for a repo with no record, or one that isn't deleted. It
179
- * waits while a drain job or a drained row stands, or a fork holds the repo; else each part's
180
- * step, then a page of `purgeCollections`, then the fork's hold on its source, then the record.
208
+ * Drops the scopes the registrations name for the repo, then its own, whose `git.purge` row is
209
+ * the last to go: a drop that fails leaves the row, whose next try drops each again. Past
210
+ * `purgeScopesMost` named, it drops none.
211
+ */
212
+ const dropScopes = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, internalId) {
213
+ const named = yield* parts.scopes(internalId);
214
+ if (named.length > 64) return yield* Effect.die(/* @__PURE__ */ new TypeError(`The registrations name ${named.length} scopes of '${internalId}', past 64`));
215
+ for (const scope of [...named, repoScope(internalId)]) yield* storeCall(() => store.drop(scope));
216
+ });
217
+ /**
218
+ * One step in the repo's scope: none for a repo that isn't deleted. It waits until its delete's
219
+ * `fetchLimits` has passed, then while a drain job or a drained row stands, or a fork holds the
220
+ * repo, each wait till its own time to look again; else each part's step, then a page of
221
+ * `purgeCollections`, then the fork's hold on its source, then the record, then the drops. A repo
222
+ * with no record is one whose record this purge deleted, since only a delete queues it: its
223
+ * drops run again, each done already or done now.
181
224
  */
182
225
  const purgeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, internalId) {
183
226
  const scope = repoScope(internalId);
@@ -186,18 +229,29 @@ const purgeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, int
186
229
  limit: 1
187
230
  }));
188
231
  const { record, snapshot } = yield* readRecord(store, internalId, drainedReads);
189
- if (record?.deleted !== true) return void 0;
232
+ if (record === void 0) return yield* dropScopes(parts, store, internalId);
233
+ if (record.deleted !== true) return void 0;
190
234
  const at = yield* parts.now;
191
- const waits = {
235
+ const guard = record.changedAt + parts.fetchLimits.milliseconds;
236
+ if (at < guard) return {
237
+ ...again,
238
+ at: guard
239
+ };
240
+ const backstop = {
241
+ ...again,
242
+ at: at + purgeBackstop
243
+ };
244
+ const deleted = record.nextSeq === void 0 ? void 0 : record.nextSeq - 1;
245
+ const drain = yield* draining(store, scope, at, deleted);
246
+ if (drain !== void 0) return {
192
247
  ...again,
193
- at: at + parts.fetchLimits.milliseconds
248
+ at: drain
194
249
  };
195
- if (snapshot.results.slice(1).some((rows) => rows.length > 0)) return waits;
196
- if (yield* draining(store, scope)) return waits;
197
- if (yield* forkedFrom(store, internalId)) return waits;
250
+ if (snapshot.results.slice(1).some((rows) => rows.length > 0)) return backstop;
251
+ if (yield* forkedFrom(store, internalId)) return backstop;
198
252
  for (const part of parts.parts) {
199
253
  const step = yield* part(store, internalId);
200
- if (step === "waits") return waits;
254
+ if (step === "waits") return backstop;
201
255
  if (step === "did") return again;
202
256
  }
203
257
  const { left, version } = yield* firstLeft(store, scope);
@@ -215,11 +269,12 @@ const purgeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, int
215
269
  yield* discardFailed(store, scope);
216
270
  const own = yield* pageOf(store, scope, collections.repo);
217
271
  if (own.version !== version) return again;
218
- return (yield* storeCall(() => store.commit(scope, {
272
+ if (!(yield* storeCall(() => store.commit(scope, {
219
273
  id: newChangeId(),
220
274
  expect: version,
221
275
  delete: own.keys
222
- }))).ok ? void 0 : again;
276
+ }))).ok) return again;
277
+ return yield* dropScopes(parts, store, internalId);
223
278
  });
224
279
  const PurgeJob = /* @__PURE__ */ Job.make(purgeJobName, {
225
280
  payload: PurgeData,
@@ -227,11 +282,11 @@ const PurgeJob = /* @__PURE__ */ Job.make(purgeJobName, {
227
282
  rebuild: () => ({})
228
283
  });
229
284
  /** `git.purge`, over one server's parts: each try one page of the repo's rows. */
230
- const purgeJob = (parts) => madeJob(PurgeJob.definition(() => repoTry((store, repo) => purgeStep(parts, store, repo))));
285
+ const purgeJob = (parts) => gitJob(PurgeJob, () => repoTry((store, repo) => purgeStep(parts, store, repo)));
231
286
  /** The repo's `git.purge` row, due at `at`. */
232
287
  const purgeJobRow = (job, at) => job.job({
233
288
  key: purgeJobKey,
234
289
  data: {},
235
290
  at
236
291
  });
237
- export { purgeCollections, purgeJob, purgeJobKey, purgeJobName, purgeJobRow, purgePage };
292
+ export { purgeBackstop, purgeCollections, purgeJob, purgeJobKey, purgeJobName, purgeJobRow, purgePage, purgeRunningRelook };
@@ -10,11 +10,12 @@ import { noLfsPointers } from "../storage/lfs-pointers.mjs";
10
10
  import { isShallowRoot } from "../storage/links.mjs";
11
11
  import { isAwaitingRepack } from "../storage/repack-backlog.mjs";
12
12
  import { allottedRows } from "../storage/allotted.mjs";
13
- import { gitObjectOf, objectOfRow, receivedRows } from "../storage/object-rows.mjs";
13
+ import { gitObjectOf, noRows, objectOfRow, receivedRows } from "../storage/object-rows.mjs";
14
14
  import { pruneClearedKey } from "../storage/prune.mjs";
15
15
  import { abandonOwn } from "../storage/quarantine.mjs";
16
+ import { readyBytesOf, readyKey } from "../storage/ready.mjs";
16
17
  import { QuarantineRow, decodeHeld } from "../storage/rows.mjs";
17
- import { bestEffort, decodeRow, storeCall } from "../store/errors.mjs";
18
+ import { bestEffort, decodeRow, fromInfra, storeCall } from "../store/errors.mjs";
18
19
  import { callScope } from "../store/call-count.mjs";
19
20
  import { decodePacks, gitStore } from "../store/git-store.mjs";
20
21
  import { WholeRepo, refBytesOf, storesPeel, wholeRefs } from "../store/ref-rows.mjs";
@@ -23,16 +24,18 @@ import { sliceOf } from "../protocol/wire/push-limits.mjs";
23
24
  import { pushCounts } from "./events/seen.mjs";
24
25
  import { refViewIn } from "./ref-view.mjs";
25
26
  import { appendEvents, decodeOutbox, firstSeq, outboxReads, repoEnvelope } from "../store/outbox.mjs";
26
- import { MirrorRow, PrunedMark, mirrorJobName } from "../store/records.mjs";
27
- import { decodeTimes, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
27
+ import { rowsAtCommit } from "./loose-tally.mjs";
28
+ import { MirrorRow } from "./mirror-rows.mjs";
29
+ import { PrunedMark, mirrorJobName } from "../store/records.mjs";
30
+ import { decodeStats, looseRows, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
28
31
  import { advanceRow } from "../store/queue-jobs.mjs";
29
32
  import { liveReservations, reservedTarget } from "../store/reservations.mjs";
30
33
  import { settleName } from "../store/settle.mjs";
31
34
  import { collections, newChangeId, prunedKey, pushedKey, pushedUnder, reachedKey, repoScope } from "../store/scopes.mjs";
32
35
  import { headOf, indexJobs, openKeyed, openRepo, refIndexJobs, repoAccess } from "./access.mjs";
33
36
  import { kindsOf } from "./ancestry.mjs";
34
- import { savedPushRow } from "./hooks/post-receive.mjs";
35
- import { runPreReceive } from "./hooks/pre-receive.mjs";
37
+ import { isRefName } from "./names.mjs";
38
+ import { runHookGroups } from "./hooks/groups.mjs";
36
39
  import { Changes } from "./changes.mjs";
37
40
  import { batchOf, readerOf } from "./rules/changes.mjs";
38
41
  import { commitChangesOf, coveredTips } from "./rules/commit-changes.mjs";
@@ -49,11 +52,11 @@ import { peeledAll, peeledOf } from "../storage/wants.mjs";
49
52
  import { CoreParts, ObjectsParts } from "./parts.mjs";
50
53
  import { Authorize, check } from "../contracts/authorize.mjs";
51
54
  import { read } from "./objects/objects.mjs";
52
- import { checkWrites } from "@ref0/infra";
53
- import * as Effect from "effect/Effect";
54
55
  import * as Clock$1 from "effect/Clock";
55
- import * as Result from "effect/Result";
56
+ import * as Effect from "effect/Effect";
56
57
  import * as Exit from "effect/Exit";
58
+ import * as Result from "effect/Result";
59
+ import { checkWrites } from "@ref0/infra";
57
60
  import * as Equal from "effect/Equal";
58
61
  // src/core/push.ts
59
62
  /**
@@ -194,12 +197,12 @@ const markOf = (rows) => {
194
197
  const firstRead = (caller, operation, internalId) => openRepo(caller, {
195
198
  kind: "read",
196
199
  repo: operation.repo
197
- }, [packsRead, prunedKey], internalId);
200
+ }, [packsRead, prunedKey], internalId, "skip");
198
201
  /** `firstRead` for a keyed push: `undefined` once `missed`'s repo moved, as `openKeyed` says. */
199
202
  const keyedRead = (caller, operation, missed, internalId) => openKeyed(caller, {
200
203
  kind: "read",
201
204
  repo: operation.repo
202
- }, [packsRead, prunedKey], missed, internalId);
205
+ }, [packsRead, prunedKey], missed, internalId, "skip");
203
206
  /**
204
207
  * The first read's repo once `authorize` lets the caller push to it: its list, for the pack to be
205
208
  * received against, its default branch, whose move rebuilds the ready shallow pack, and its
@@ -294,8 +297,8 @@ const activeMirrors = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
294
297
  return active;
295
298
  });
296
299
  /**
297
- * `git.sync.mirror`'s row for each ref the commit moves that an active mirror names, found by
298
- * name among the jobs the server knows: none until `syncJobs` has bound them.
300
+ * `sync.mirror`'s row for each ref the commit moves that an active mirror names, found by
301
+ * name among the jobs the server knows: none until `Sync.layer` has bound them.
299
302
  */
300
303
  const mirrorJobs = (core, moved, mirrored) => {
301
304
  const definition = core.jobOf?.(mirrorJobName);
@@ -400,9 +403,9 @@ const buildFence = (build) => [
400
403
  /**
401
404
  * The decide's read, one of the repo's scope: its refs, its outbox, the push's own `quarantine` row
402
405
  * if it has one, its key's receipt if it has a key, the mirror of each ref in `touched`, the
403
- * queue's row of each branch in `branches`,
404
- * with the live reservation each holds, and the caller's grant fence, checked on what it read. A revoke after it moves the version, as
405
- * does a write with the same key that commits first. A prune that dropped objects since the first
406
+ * reservation row of each branch in `branches`, there while a queue targets it, with the live
407
+ * reservation each holds, and the caller's grant fence, checked on what it read. A revoke after it
408
+ * moves the version, as does a write with the same key that commits first. A prune that dropped objects since the first
406
409
  * read moved the `pruned` mark: the push may name one it dropped, so unless its key's receipt
407
410
  * answers, it fails, to be sent again (Q270). `changed`: whether a row of a build's fence,
408
411
  * `unchanged`, holds another value than its plan read.
@@ -411,7 +414,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
411
414
  const own = received?.quarantine === void 0 ? [] : [received.quarantine];
412
415
  const keyed = receiptReads(kept);
413
416
  const targets = branches.map((id) => ({
414
- collection: collections.queueTargets,
417
+ collection: collections.queueReservations,
415
418
  id
416
419
  }));
417
420
  const linkedRows = received?.linked?.rows ?? [];
@@ -428,6 +431,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
428
431
  cruftRead,
429
432
  indexRowKey,
430
433
  reachedKey,
434
+ readyKey,
431
435
  ...own,
432
436
  ...keyed,
433
437
  ...targets,
@@ -444,7 +448,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
444
448
  ], rowCounts);
445
449
  if (record === void 0 || record.deleted === true) return yield* fail("NOT_FOUND", `No repo '${repo.name}'`);
446
450
  const [, refRows = [], headRows = [], cursorRows = [], packRows = [], ...more] = snapshot.results;
447
- const [markRows = [], timeRows = [], cruftRows = [], indexRows = [], reachedRows = [], ...rest] = more;
451
+ const [markRows = [], timeRows = [], cruftRows = [], indexRows = [], reachedRows = [], readyRows = [], ...rest] = more;
448
452
  const receipt = yield* heldReceipt(rest.slice(own.length, own.length + keyed.length), kept);
449
453
  if (receipt === void 0 && (yield* markOf(markRows)) !== mark) return yield* fail("UNAVAILABLE", "The repo was pruned during the push", { hint: "Push again" });
450
454
  const targeted = rest.slice(own.length + keyed.length, own.length + keyed.length + targets.length);
@@ -463,7 +467,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
463
467
  const mirrorRows = rest.slice(guardedAt + unchanged.length).flat();
464
468
  const changed = unchanged.some((row, at) => !Equal.equals(row.value, now[at]?.[0]?.value));
465
469
  const packs = yield* decodePacks(packRows);
466
- const times = yield* decodeTimes(timeRows);
470
+ const times = yield* decodeStats(timeRows);
467
471
  const [ownRow] = own.length === 0 ? [] : rest[0] ?? [];
468
472
  const refs = yield* wholeRefs(pushWhole, refRows);
469
473
  const outbox = yield* decodeOutbox([headRows, cursorRows]);
@@ -498,7 +502,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
498
502
  tips: /* @__PURE__ */ new Map(),
499
503
  revoked: revoked !== void 0
500
504
  };
501
- const stats = repoStats(record, refs.size, packs, times);
505
+ const stats = repoStats(record, refs.size, packs, times, yield* readyBytesOf(readyRows));
502
506
  const [indexRow] = indexRows;
503
507
  return {
504
508
  read,
@@ -521,11 +525,11 @@ const settingsOf = (record) => ({
521
525
  public: record.public,
522
526
  defaultBranch: record.defaultBranch
523
527
  });
524
- /** The rules, then `hooks.preReceive`, once, at the first read the push decides on. */
528
+ /** The rules, the registrations' checks, then the hook groups, once, at the first read the push decides on. */
525
529
  const runChecks = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, facts) {
526
530
  const context = checking(input);
527
- const ruled = yield* claimedAfter(checks, input, yield* runPushRules(checks, input, context));
528
- const whole = yield* runPreReceive(checks.reports, checks.preReceive, context, {
531
+ const ruled = yield* registeredAfter(checks, input, yield* runPushRules(checks, input, context));
532
+ const whole = yield* runHookGroups(checks.groups?.() ?? [], context, {
529
533
  atomic: input.atomic,
530
534
  updates: ruled.updates,
531
535
  refused: ruled.refused
@@ -580,12 +584,12 @@ const checkAll = /* @__PURE__ */ Effect.fnUntraced(function* (checks, request, i
580
584
  };
581
585
  });
582
586
  /**
583
- * The rules' answer, with the refs the claimed checks refuse among the rest: each in turn, by band
584
- * then claim name, on the refs none before it refused, so a ref's first refusal is its answer.
587
+ * The rules' answer, with the refs the registered checks refuse among the rest: each in turn, by band
588
+ * then registration name, on the refs none before it refused, so a ref's first refusal is its answer.
585
589
  */
586
- const claimedAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, ruled) {
590
+ const registeredAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, ruled) {
587
591
  const refused = new Map(ruled.refused);
588
- for (const { handler } of checks.claimed?.() ?? []) {
592
+ for (const { handler } of checks.registered?.() ?? []) {
589
593
  const updates = ruled.updates.filter((update) => !refused.has(update.ref));
590
594
  if (updates.length === 0) break;
591
595
  for (const [ref, error] of yield* handler(input, updates)) if (!refused.has(ref)) refused.set(ref, error);
@@ -595,11 +599,11 @@ const claimedAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input,
595
599
  refused
596
600
  };
597
601
  });
598
- /** Whether a push has anything to check: a rule, a claimed check, or `hooks.preReceive`. */
602
+ /** Whether a push has anything to check: a rule, a registered check, or a hook group. */
599
603
  const checksOf = /* @__PURE__ */ Effect.fnUntraced(function* (core) {
600
604
  const { checks } = core;
601
605
  if (checks === void 0) return void 0;
602
- return (yield* pushRulesFor(checks)).length > 0 || checks.preReceive !== void 0 || (checks.claimed?.().length ?? 0) > 0 ? checks : void 0;
606
+ return (yield* pushRulesFor(checks)).length > 0 || (checks.registered?.().length ?? 0) > 0 || (checks.groups?.().length ?? 0) > 0 ? checks : void 0;
603
607
  });
604
608
  /**
605
609
  * The repo's objects with the push's own, for the built-in check: `objects` and `listed` read
@@ -703,8 +707,8 @@ const fetchedRefused = /* @__PURE__ */ Effect.fnUntraced(function* (kinds, reque
703
707
  /**
704
708
  * A commit the store refuses as too large, before it applies any write, for a `loose()` push whose
705
709
  * objects are rows of it: its objects fit `loose()`'s limits, but not beside the push's own
706
- * writes. It gets the hint those limits give. A refusal the push's own writes earn alone, as a
707
- * saved push of many long ref names, keeps the store's message: fewer objects wouldn't help it.
710
+ * writes. It gets the hint those limits give. A refusal the push's own writes earn alone keeps
711
+ * the store's message: fewer objects wouldn't help it.
708
712
  * So does `packs()`'s, whose small pushes are rows too: it's on `packs()` already. `loose()` is
709
713
  * known by the quarantine it received, so a wrapper that passes it on, as Git's HTTP does, keeps it.
710
714
  */
@@ -787,6 +791,7 @@ const pushOf = (access, id, moved, request) => {
787
791
  if (slice !== void 0) push.slice = slice;
788
792
  const options = request.pushOptions ?? [];
789
793
  if (options.length > 0) push.options = options;
794
+ if (request.onBehalfOf === true) push.onBehalfOf = true;
790
795
  return push;
791
796
  };
792
797
  /**
@@ -801,32 +806,6 @@ const movedKinds = (updates, moved) => {
801
806
  }));
802
807
  };
803
808
  /**
804
- * What a push's commit saves for `hooks.postReceive`, when the host passed one: the push, with
805
- * the refs it moved and their kinds, at the version the commit makes, and the repo's
806
- * `git.post-receive` row. Its ID is the commit's own.
807
- */
808
- const savedPush = (checks, push) => {
809
- const jobRow = checks?.postReceiveJobRow;
810
- if (jobRow === void 0 || push.moved.length === 0) return {
811
- put: [],
812
- jobs: []
813
- };
814
- const updates = movedKinds(push.updates, push.moved);
815
- const { pushOptions, source } = push.request;
816
- const saved = {
817
- pushId: push.id,
818
- repo: push.name,
819
- caller: push.caller,
820
- source,
821
- updates
822
- };
823
- if (pushOptions !== void 0) saved.pushOptions = pushOptions;
824
- return {
825
- put: [savedPushRow(push.version, saved)],
826
- jobs: [jobRow()]
827
- };
828
- };
829
- /**
830
809
  * The pack a push's own receive put under its `quarantine` row: none for a push with no pack, one
831
810
  * of rows alone, or a caller's `received`, which stays its caller's to end.
832
811
  */
@@ -841,11 +820,13 @@ const lists = (body, pack) => body.delete.some((key) => key.collection === objec
841
820
  * The push decide's loop past its first read, onto `listed`, keeping its answer under `key`:
842
821
  * the pack received into its quarantine; each edit's kind from the objects; then a read of the
843
822
  * refs, the push's `quarantine` row and the caller's fence; a held receipt's answer; the rules and
844
- * `preReceive`, for a write that moves a ref; the pure decide, and one commit at that read's
845
- * version, with the ref moves, the receipt, the events and the push `hooks.postReceive` owes.
846
- * `answers` says what the call answers and keeps.
823
+ * the hook groups, for a write that moves a ref; the pure decide, and one commit at that read's
824
+ * version, with the ref moves, the receipt and the events.
825
+ * `answers` says what the call answers and keeps. `checking`: the rules, the hook and the decide
826
+ * only, refused as the commit would be, its `writes` or none, and answered before it, for
827
+ * `checkPush`: nothing before that point writes, reserves or enqueues, with no pack.
847
828
  */
848
- const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, view, views }, key, answers) => Effect.scoped(Effect.gen(function* () {
829
+ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, view, views }, key, answers, checking = false) => Effect.scoped(Effect.gen(function* () {
849
830
  const core = yield* CoreParts;
850
831
  const { objects: sealed } = yield* ObjectsParts;
851
832
  const authorize = yield* Authorize;
@@ -978,7 +959,8 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
978
959
  const own = updates.filter((update) => gitsOwnMove(hidden, request.as, update.ref));
979
960
  const outside = updates.filter((update) => !gitsOwnMove(hidden, request.as, update.ref));
980
961
  const checks = outside.length === 0 ? void 0 : yield* checksOf(core);
981
- const branches = request.source === "queue" ? [] : outside.map((update) => update.ref).filter((ref) => ref.startsWith("refs/heads/"));
962
+ const branches = request.source === "queue" ? [] : outside.map((update) => update.ref).filter((ref) => ref.startsWith("refs/heads/") && isRefName(ref));
963
+ const touched = updates.map(({ ref }) => ref).filter(isRefName);
982
964
  const scope = yield* callScope;
983
965
  const reader = readerOf(pushedObjects, pushedListed, scope);
984
966
  const batch = batchOf(pushedObjects, pushedListed, scope);
@@ -989,7 +971,6 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
989
971
  repo,
990
972
  source: request.source,
991
973
  atomic: request.atomic,
992
- ...call,
993
974
  push: {
994
975
  bytes: received?.bytes ?? 0,
995
976
  objects: received?.objects ?? 0
@@ -1025,7 +1006,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
1025
1006
  let checked;
1026
1007
  for (let tries = 0; tries < 10; tries += 1) {
1027
1008
  const at = yield* Clock$1.currentTimeMillis;
1028
- const decide = yield* finalRead(store, target, fence, received, key, mark, branches, updates.map(({ ref }) => ref), request.guard, request.writes?.unchanged);
1009
+ const decide = yield* finalRead(store, target, fence, received, key, mark, branches, touched, request.guard, request.writes?.unchanged);
1029
1010
  const { read, receipt, outbox, record, mirrored, facts, stats, times, queued, reserved, indexRow } = decide;
1030
1011
  const indexed = SealedObjects.whole(sealed, pushWhole).index?.status(indexRow, at, listedIds(decide.at, received?.change));
1031
1012
  if (receipt !== void 0) return yield* answers.held(receipt);
@@ -1093,11 +1074,12 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
1093
1074
  const upkept = clears && jobs.length === 0 ? [core.repackJobRow()] : jobs;
1094
1075
  const planned = yield* planOf(decision, read.version, upkept);
1095
1076
  const { change } = planned;
1096
- const refusal = writes === void 0 ? void 0 : refusalOf(planned.answer);
1077
+ const refusal = writes === void 0 && !checking ? void 0 : refusalOf(planned.answer);
1097
1078
  if (refusal !== void 0) return yield* Effect.fail(refusal);
1098
1079
  const movedRefs = new Set(planned.moved.map((move) => move.ref));
1099
1080
  const liftedOnMoves = [...checked?.bypassed ?? none].filter(([ref]) => movedRefs.has(ref));
1100
1081
  const answer = yield* answers.answer(planned.answer, forced, new Map(liftedOnMoves));
1082
+ if (checking) return answer;
1101
1083
  const also = planned.answer.updates.some((update) => update.kind === "rejected") || request.also === void 0 ? void 0 : request.also(yield* Clock$1.currentTimeMillis, received);
1102
1084
  const alsoWrites = (also?.put.length ?? 0) + (also?.delete?.length ?? 0);
1103
1085
  const quiet = key === void 0 && alsoWrites === 0 && writes === void 0;
@@ -1137,27 +1119,21 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
1137
1119
  });
1138
1120
  const final = answers.committed?.(answer, appended.head.next - 1) ?? answer;
1139
1121
  const kept = receiptWrites(key, answers.kept(final), core.repackJobRow);
1140
- const saved = savedPush(core.checks, {
1141
- id,
1142
- version: planned.expect + 1,
1143
- caller,
1144
- name,
1145
- request,
1146
- updates: decided.updates,
1147
- moved: shown
1148
- });
1149
1122
  const woken = shown.filter((move) => queued.has(move.ref)).map((move) => advanceRow(move.ref));
1150
1123
  const pushed = pushedRows(core.access, shown, times, at);
1124
+ const moved = received === void 0 || !planned.moves ? noRows : yield* rowsAtCommit(store, listed.repo, received.change, read.version);
1125
+ if (moved === void 0) continue;
1126
+ const loose = looseRows(times.loose, moved);
1151
1127
  const body = {
1152
1128
  id,
1153
1129
  expect: planned.expect,
1154
1130
  put: [
1155
1131
  ...change.put,
1156
1132
  ...pushed,
1133
+ ...loose,
1157
1134
  ...kept.put,
1158
1135
  ...also?.put ?? [],
1159
1136
  ...appended.put,
1160
- ...saved.put,
1161
1137
  ...writes?.put ?? []
1162
1138
  ],
1163
1139
  delete: [
@@ -1169,7 +1145,6 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
1169
1145
  jobs: withJobs([
1170
1146
  ...planned.jobs,
1171
1147
  ...appended.jobs,
1172
- ...saved.jobs,
1173
1148
  ...mirrorJobs(core, planned.moved, mirrored),
1174
1149
  ...writes?.jobs ?? [],
1175
1150
  ...woken,
@@ -1185,6 +1160,10 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
1185
1160
  moved: planned.moved.length
1186
1161
  }, core.refIndex);
1187
1162
  if (past !== void 0) return yield* Effect.fail(past);
1163
+ yield* Effect.try({
1164
+ try: () => checkWrites(body),
1165
+ catch: (cause) => fromInfra(cause)
1166
+ }).pipe(Effect.mapError(commitTooLarge(received, body)));
1188
1167
  if ((yield* storeCall(() => store.commit(scope, body)).pipe(Effect.mapError(commitTooLarge(received, body)))).ok) {
1189
1168
  listing = ownedPack !== void 0 && lists(body, ownedPack);
1190
1169
  return final;
@@ -1206,14 +1185,23 @@ const operationOf = ({ repo, edits }) => edits.length === 0 ? {
1206
1185
  * reads and decides again. A push cut before its commit leaves an unlisted pack for clean-up, and
1207
1186
  * no ref moved.
1208
1187
  */
1209
- const pushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, key) {
1188
+ const pushWith = (request, answers, key) => pushThrough(request, answers, key, false);
1189
+ /** `pushWith`, or with `checking`, its checks alone, as `pushOnto` says. */
1190
+ const pushThrough = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, key, checking) {
1210
1191
  const operation = operationOf(request);
1211
1192
  const resolved = yield* firstRead(request.caller, operation, request.internalId).pipe(Effect.tapError((error) => retriedCodes.has(error.code) ? Effect.void : refuseQueued(request, [error], "access")));
1212
1193
  const opened = yield* listedFor(request, operation, resolved);
1213
- return yield* pushOnto(request, opened, key, answers);
1194
+ return yield* pushOnto(request, opened, key, answers, checking);
1214
1195
  });
1215
1196
  /** A push or an unkeyed `refs.update`, answering the decide's ref answer. */
1216
1197
  const push = (request) => pushWith(request, refsAnswers);
1198
+ /**
1199
+ * What `push` of `request` would answer, with nothing written, reserved or enqueued: its reads,
1200
+ * `authorize`, its rules and the hook, and the decide, failing as its commit would, a queue's
1201
+ * callers told as its publish tells them. A topic asks it of each member's publish before its
1202
+ * decision (Q1159). For a request with no pack; re-exported from no index.
1203
+ */
1204
+ const checkPush = (request) => request.pack === void 0 ? pushThrough(request, refsAnswers, void 0, true) : fail("INTERNAL", "A push is checked with no pack");
1217
1205
  /** A `git push`, as `push`, with the lines Git prints for the rules `authorize` lifted. */
1218
1206
  const gitPush = (request) => pushWith(request, gitAnswers);
1219
1207
  /** A ref a forced fetch moved past its diverged tip, answered `force`; the rest as they are. */
@@ -1248,4 +1236,4 @@ const keyedPushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answ
1248
1236
  });
1249
1237
  /** `keyedPushWith` for `refs.update`, answering the decide's ref answer. */
1250
1238
  const keyedPush = (request, keyed) => keyedPushWith(request, refsAnswers, keyed);
1251
- export { buildFence, gitPush, isQueueMoved, keyedPush, keyedPushWith, push, pushFetched, pushWith, retriedCodes };
1239
+ export { buildFence, checkPush, gitPush, isQueueMoved, keyedPush, keyedPushWith, push, pushFetched, pushWith, retriedCodes };
@@ -3,6 +3,6 @@ import "../contracts/refs.mjs";
3
3
  import "../contracts/repos.mjs";
4
4
  import "../contracts/result.mjs";
5
5
  import "../store/records.mjs";
6
- import { JobInput, Key, Moment, Read, Row } from "@ref0/infra";
6
+ import "effect/Effect";
7
7
  import "effect/Schema";
8
- import "effect/Effect";
8
+ import { JobInput, Key, Moment, Read, Row } from "@ref0/infra";