@ref0/git 0.6.0 → 0.7.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 (431) 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 +28 -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 +4 -5
  13. package/dist/auth/fences.d.mts +1 -1
  14. package/dist/auth/host-function.mjs +17 -8
  15. package/dist/auth/identify.mjs +2 -1
  16. package/dist/auth/namespaces.d.mts +2 -2
  17. package/dist/auth/token-rows.mjs +1 -1
  18. package/dist/auth/tokens-layer.d.mts +42 -0
  19. package/dist/auth/tokens-layer.mjs +29 -0
  20. package/dist/auth/tokens-namespace.d.mts +2 -0
  21. package/dist/auth/tokens-public.d.mts +6 -0
  22. package/dist/auth/tokens-public.mjs +29 -0
  23. package/dist/auth/tokens.d.mts +13 -6
  24. package/dist/auth/tokens.mjs +5 -5
  25. package/dist/auth.d.mts +2 -2
  26. package/dist/auth.mjs +2 -2
  27. package/dist/client/git-http.mjs +1 -1
  28. package/dist/client/local.mjs +4 -3
  29. package/dist/client/remote-helper.mjs +3 -8
  30. package/dist/client/remote.mjs +26 -7
  31. package/dist/client/run-remote-helper.d.mts +1 -1
  32. package/dist/client/run-remote-helper.mjs +2 -2
  33. package/dist/client/slice-push.d.mts +1 -1
  34. package/dist/contracts/access.d.mts +18 -10
  35. package/dist/contracts/access.mjs +17 -0
  36. package/dist/contracts/actors.d.mts +17 -1
  37. package/dist/contracts/actors.mjs +8 -1
  38. package/dist/contracts/authorize.d.mts +7 -4
  39. package/dist/contracts/blobs.d.mts +1 -1
  40. package/dist/contracts/blobs.mjs +1 -1
  41. package/dist/contracts/calls-spent.d.mts +6 -4
  42. package/dist/contracts/calls-spent.mjs +10 -8
  43. package/dist/contracts/commits.d.mts +2 -2
  44. package/dist/contracts/commits.mjs +1 -1
  45. package/dist/contracts/engine.d.mts +1 -1
  46. package/dist/contracts/events.d.mts +33 -22
  47. package/dist/contracts/events.mjs +13 -4
  48. package/dist/contracts/files.d.mts +2 -2
  49. package/dist/contracts/files.mjs +1 -1
  50. package/dist/contracts/forks.d.mts +58 -58
  51. package/dist/contracts/forks.mjs +1 -1
  52. package/dist/contracts/git-events.d.mts +50 -0
  53. package/dist/contracts/git-events.mjs +23 -0
  54. package/dist/contracts/git-hooks.d.mts +37 -0
  55. package/dist/contracts/git-hooks.mjs +10 -0
  56. package/dist/contracts/git.d.mts +93 -42
  57. package/dist/contracts/git.mjs +6 -5
  58. package/dist/contracts/ids.d.mts +16 -0
  59. package/dist/contracts/ids.mjs +19 -4
  60. package/dist/contracts/lfs.d.mts +2 -0
  61. package/dist/contracts/namespaces.d.mts +2 -2
  62. package/dist/contracts/objects.d.mts +1 -1
  63. package/dist/contracts/opaque.mjs +9 -0
  64. package/dist/contracts/operations.d.mts +293 -100
  65. package/dist/contracts/promises.d.mts +2 -0
  66. package/dist/contracts/push-uploads.d.mts +4 -1
  67. package/dist/contracts/push-uploads.mjs +9 -4
  68. package/dist/contracts/queue.d.mts +218 -47
  69. package/dist/contracts/queue.mjs +81 -6
  70. package/dist/contracts/refs.d.mts +30 -8
  71. package/dist/contracts/refs.mjs +1 -1
  72. package/dist/contracts/remote.d.mts +42 -21
  73. package/dist/contracts/remote.mjs +22 -0
  74. package/dist/contracts/repo-records.d.mts +2 -2
  75. package/dist/contracts/repos.d.mts +126 -79
  76. package/dist/contracts/repos.mjs +43 -5
  77. package/dist/contracts/result.d.mts +46 -31
  78. package/dist/contracts/result.mjs +43 -16
  79. package/dist/contracts/rules.d.mts +50 -44
  80. package/dist/contracts/rules.mjs +5 -1
  81. package/dist/contracts/server.d.mts +282 -198
  82. package/dist/contracts/services.d.mts +1 -7
  83. package/dist/contracts/services.mjs +1 -3
  84. package/dist/contracts/signin.d.mts +140 -43
  85. package/dist/contracts/signin.mjs +35 -1
  86. package/dist/contracts/store.d.mts +1 -1
  87. package/dist/contracts/sync.d.mts +112 -90
  88. package/dist/contracts/sync.mjs +34 -7
  89. package/dist/contracts/tags.d.mts +1 -1
  90. package/dist/contracts/tags.mjs +1 -1
  91. package/dist/contracts/tokens.d.mts +232 -57
  92. package/dist/contracts/tokens.mjs +80 -19
  93. package/dist/contracts/topics.d.mts +22 -10
  94. package/dist/contracts/topics.mjs +6 -3
  95. package/dist/contracts/trees.d.mts +2 -2
  96. package/dist/contracts/trees.mjs +1 -1
  97. package/dist/contracts/work.d.mts +2 -2
  98. package/dist/contracts/work.mjs +2 -2
  99. package/dist/core/access.d.mts +10 -10
  100. package/dist/core/access.mjs +31 -8
  101. package/dist/core/clock.mjs +1 -1
  102. package/dist/core/events/deliver.d.mts +3 -2
  103. package/dist/core/events/deliver.mjs +170 -92
  104. package/dist/core/forks.mjs +49 -24
  105. package/dist/core/hooks/groups.d.mts +27 -0
  106. package/dist/core/hooks/groups.mjs +74 -0
  107. package/dist/core/hooks/namespace.d.mts +2 -0
  108. package/dist/core/hooks/order.d.mts +2 -2
  109. package/dist/core/hooks/order.mjs +6 -6
  110. package/dist/core/hooks/public.d.mts +7 -0
  111. package/dist/core/hooks/public.mjs +5 -0
  112. package/dist/core/imports.mjs +94 -10
  113. package/dist/core/index-job.mjs +11 -8
  114. package/dist/core/merge-parts.d.mts +1 -1
  115. package/dist/core/merge-parts.mjs +1 -1
  116. package/dist/core/mirror-rows.mjs +18 -0
  117. package/dist/core/names.mjs +1 -1
  118. package/dist/core/namespaces.d.mts +2 -1
  119. package/dist/core/objects/commit-writes.mjs +5 -5
  120. package/dist/core/objects/merges.mjs +1 -1
  121. package/dist/core/objects/objects-layer.mjs +1 -1
  122. package/dist/core/objects/reading.mjs +52 -7
  123. package/dist/core/objects/tree-edits.mjs +13 -28
  124. package/dist/core/objects/trees.mjs +4 -4
  125. package/dist/core/objects/writing.mjs +3 -3
  126. package/dist/core/own-writes.mjs +1 -1
  127. package/dist/core/parts.d.mts +22 -3
  128. package/dist/core/parts.mjs +5 -3
  129. package/dist/core/promise.mjs +23 -3
  130. package/dist/core/purge.d.mts +2 -2
  131. package/dist/core/purge.mjs +80 -30
  132. package/dist/core/push.mjs +55 -74
  133. package/dist/core/receipts.d.mts +2 -2
  134. package/dist/core/receipts.mjs +28 -4
  135. package/dist/core/ref-index-job.mjs +4 -4
  136. package/dist/core/ref-view.mjs +2 -2
  137. package/dist/core/refs.mjs +41 -10
  138. package/dist/core/registered-records.mjs +30 -0
  139. package/dist/core/{claim-rows.mjs → registered-rows.mjs} +6 -6
  140. package/dist/core/repack.d.mts +2 -2
  141. package/dist/core/repack.mjs +11 -9
  142. package/dist/core/repo-info.mjs +59 -25
  143. package/dist/core/repos.mjs +17 -11
  144. package/dist/core/rules/changes.mjs +2 -2
  145. package/dist/core/rules/commit-changes.mjs +1 -1
  146. package/dist/core/rules/context.d.mts +4 -5
  147. package/dist/core/rules/context.mjs +3 -4
  148. package/dist/core/rules/fetch.mjs +74 -21
  149. package/dist/core/saved-caller-views.d.mts +72 -0
  150. package/dist/core/saved-caller-views.mjs +123 -0
  151. package/dist/core/saved-callers-public.d.mts +5 -0
  152. package/dist/core/saved-callers-public.mjs +10 -0
  153. package/dist/core/saved-callers.mjs +95 -0
  154. package/dist/core/seam.d.mts +12 -1
  155. package/dist/core/seam.mjs +4 -2
  156. package/dist/core/tokens.mjs +5 -1
  157. package/dist/core/view.d.mts +1 -1
  158. package/dist/core/view.mjs +1 -1
  159. package/dist/core/work.mjs +6 -5
  160. package/dist/effect.d.mts +2 -2
  161. package/dist/effect.mjs +2 -2
  162. package/dist/engine/content.d.mts +2 -2
  163. package/dist/engine/content.mjs +1 -1
  164. package/dist/engine/diff.mjs +2 -2
  165. package/dist/engine/merge-base-walk.d.mts +2 -2
  166. package/dist/engine/merge-base-walk.mjs +1 -1
  167. package/dist/engine/merge-renames.mjs +1 -1
  168. package/dist/engine/reads.d.mts +2 -2
  169. package/dist/engine/reads.mjs +1 -1
  170. package/dist/engine/xdiff.d.mts +1 -1
  171. package/dist/engine/xdiff.mjs +2 -2
  172. package/dist/event-streams/event-streams.d.mts +6 -2
  173. package/dist/event-streams/event-streams.mjs +6 -2
  174. package/dist/event-streams/stream.mjs +5 -2
  175. package/dist/extend.d.mts +3 -3
  176. package/dist/extend.mjs +3 -2
  177. package/dist/http/answers.mjs +4 -3
  178. package/dist/http/core-parts.mjs +2 -2
  179. package/dist/http/handler.mjs +1 -1
  180. package/dist/http/parts.d.mts +1 -0
  181. package/dist/http/push-uploads.mjs +7 -5
  182. package/dist/http/receive-pack.mjs +3 -3
  183. package/dist/http/upload-pack.mjs +6 -5
  184. package/dist/index.d.mts +33 -20
  185. package/dist/index.mjs +13 -7
  186. package/dist/lfs/base.d.mts +2 -2
  187. package/dist/lfs/calls.mjs +3 -2
  188. package/dist/lfs/layer.d.mts +5 -4
  189. package/dist/lfs/layer.mjs +17 -16
  190. package/dist/lfs/locks.mjs +3 -3
  191. package/dist/lfs/objects.d.mts +3 -2
  192. package/dist/lfs/objects.mjs +149 -34
  193. package/dist/lfs/pointers.mjs +1 -1
  194. package/dist/lfs/purge.mjs +1 -1
  195. package/dist/lfs/rows.mjs +1 -1
  196. package/dist/lfs/upkeep.mjs +13 -9
  197. package/dist/lfs/wire.mjs +1 -1
  198. package/dist/protocol/bytes/buffers.d.mts +1 -1
  199. package/dist/protocol/bytes/buffers.mjs +1 -1
  200. package/dist/protocol/bytes/deflate.d.mts +1 -1
  201. package/dist/protocol/bytes/deflate.mjs +1 -1
  202. package/dist/protocol/bytes/hmac-sha256.mjs +3 -6
  203. package/dist/protocol/bytes/inflate.d.mts +1 -1
  204. package/dist/protocol/bytes/inflate.mjs +1 -1
  205. package/dist/protocol/bytes/sha1.d.mts +1 -1
  206. package/dist/protocol/bytes/sha1.mjs +2 -2
  207. package/dist/protocol/diff/read.d.mts +1 -1
  208. package/dist/protocol/diff/read.mjs +1 -1
  209. package/dist/protocol/diff/tree-diff.d.mts +1 -1
  210. package/dist/protocol/diff/tree-diff.mjs +11 -11
  211. package/dist/protocol/objects/lfs-pointer.mjs +6 -1
  212. package/dist/protocol/objects/tag.mjs +1 -1
  213. package/dist/protocol/objects/tree.mjs +1 -1
  214. package/dist/protocol/packs/graph.mjs +1 -1
  215. package/dist/protocol/packs/idx.d.mts +1 -1
  216. package/dist/protocol/packs/idx.mjs +1 -1
  217. package/dist/protocol/packs/parts.mjs +1 -1
  218. package/dist/protocol/packs/reader.d.mts +1 -1
  219. package/dist/protocol/packs/reader.mjs +2 -2
  220. package/dist/protocol/packs/write-error.d.mts +1 -1
  221. package/dist/protocol/packs/write-error.mjs +1 -1
  222. package/dist/protocol/packs/writer.mjs +4 -4
  223. package/dist/protocol/wire/advertisement.d.mts +1 -1
  224. package/dist/protocol/wire/advertisement.mjs +1 -1
  225. package/dist/protocol/wire/fetch.d.mts +1 -1
  226. package/dist/protocol/wire/fetch.mjs +1 -1
  227. package/dist/protocol/wire/lines.d.mts +1 -1
  228. package/dist/protocol/wire/lines.mjs +2 -2
  229. package/dist/protocol/wire/push-uploads.mjs +4 -2
  230. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  231. package/dist/protocol/wire/receive-pack.mjs +1 -1
  232. package/dist/protocol/wire/report-status.d.mts +1 -1
  233. package/dist/protocol/wire/report-status.mjs +1 -1
  234. package/dist/protocol/wire/v2.d.mts +2 -2
  235. package/dist/protocol/wire/v2.mjs +2 -2
  236. package/dist/queue/advance.mjs +155 -63
  237. package/dist/queue/callers.mjs +56 -69
  238. package/dist/queue/calls.mjs +20 -11
  239. package/dist/queue/commit.mjs +28 -22
  240. package/dist/queue/host.d.mts +10 -11
  241. package/dist/queue/host.mjs +15 -7
  242. package/dist/queue/lanes.mjs +9 -18
  243. package/dist/queue/layer.d.mts +3 -3
  244. package/dist/queue/layer.mjs +11 -10
  245. package/dist/queue/limits.mjs +17 -5
  246. package/dist/queue/rows.mjs +5 -10
  247. package/dist/queue/schedule.mjs +6 -5
  248. package/dist/queue/search.mjs +8 -13
  249. package/dist/queue/state.mjs +7 -2
  250. package/dist/queue/trim.mjs +10 -5
  251. package/dist/rest/api.d.mts +1 -1
  252. package/dist/rest/blobs.d.mts +20 -20
  253. package/dist/rest/caller.d.mts +22 -20
  254. package/dist/rest/client.mjs +6 -6
  255. package/dist/rest/commits.d.mts +335 -335
  256. package/dist/rest/errors.d.mts +10 -10
  257. package/dist/rest/errors.mjs +1 -1
  258. package/dist/rest/events.d.mts +13 -11
  259. package/dist/rest/events.mjs +3 -1
  260. package/dist/rest/files.d.mts +30 -30
  261. package/dist/rest/forks.d.mts +150 -150
  262. package/dist/rest/handler.mjs +4 -3
  263. package/dist/rest/handlers.mjs +13 -7
  264. package/dist/rest/layer.d.mts +3 -3
  265. package/dist/rest/layer.mjs +8 -7
  266. package/dist/rest/listen.mjs +2 -2
  267. package/dist/rest/me.d.mts +18 -20
  268. package/dist/rest/me.mjs +1 -1
  269. package/dist/rest/merges.d.mts +10 -10
  270. package/dist/rest/queue.d.mts +140 -140
  271. package/dist/rest/queue.mjs +1 -1
  272. package/dist/rest/refs.d.mts +95 -95
  273. package/dist/rest/refs.mjs +1 -1
  274. package/dist/rest/repos.d.mts +127 -127
  275. package/dist/rest/tags.d.mts +30 -30
  276. package/dist/rest/tokens.d.mts +250 -260
  277. package/dist/rest/tokens.mjs +10 -42
  278. package/dist/rest/topics.d.mts +63 -63
  279. package/dist/rest/topics.mjs +1 -1
  280. package/dist/rest/trees.d.mts +106 -106
  281. package/dist/rest/wire.d.mts +6 -4
  282. package/dist/rest/wire.mjs +4 -3
  283. package/dist/rest/work.d.mts +69 -69
  284. package/dist/rest/work.mjs +1 -1
  285. package/dist/server/check-fetch.mjs +9 -0
  286. package/dist/server/extension.mjs +3 -115
  287. package/dist/server/git-layer.d.mts +20 -3
  288. package/dist/server/git-layer.mjs +30 -19
  289. package/dist/server/git-namespace.d.mts +4 -4
  290. package/dist/server/git-namespace.mjs +6 -4
  291. package/dist/server/joined.d.mts +83 -0
  292. package/dist/server/joined.mjs +91 -0
  293. package/dist/server/registry.d.mts +7 -3
  294. package/dist/server/registry.mjs +135 -31
  295. package/dist/server/routes.mjs +2 -2
  296. package/dist/server/server.d.mts +9 -2
  297. package/dist/server/server.mjs +279 -191
  298. package/dist/signin/context.d.mts +2 -1
  299. package/dist/signin/context.mjs +32 -37
  300. package/dist/signin/device.mjs +5 -5
  301. package/dist/signin/forms.mjs +1 -1
  302. package/dist/signin/grants.d.mts +2 -3
  303. package/dist/signin/grants.mjs +5 -5
  304. package/dist/signin/layer.d.mts +9 -0
  305. package/dist/signin/layer.mjs +41 -0
  306. package/dist/signin/namespace.d.mts +2 -0
  307. package/dist/signin/public.d.mts +6 -0
  308. package/dist/signin/public.mjs +5 -0
  309. package/dist/signin/route.mjs +47 -21
  310. package/dist/signin/web.mjs +3 -3
  311. package/dist/signin/wire.mjs +1 -1
  312. package/dist/storage/calls.d.mts +1 -1
  313. package/dist/storage/calls.mjs +4 -4
  314. package/dist/storage/clean-up.mjs +12 -5
  315. package/dist/storage/counted-bucket.mjs +34 -51
  316. package/dist/storage/fetch.mjs +1 -1
  317. package/dist/storage/host-bucket.mjs +1 -1
  318. package/dist/storage/index-build.d.mts +2 -2
  319. package/dist/storage/index-build.mjs +3 -3
  320. package/dist/storage/index-fetch.mjs +10 -6
  321. package/dist/storage/index-graph.mjs +1 -1
  322. package/dist/storage/index-layers.mjs +1 -1
  323. package/dist/storage/index-visible.mjs +1 -1
  324. package/dist/storage/memory-budget.mjs +7 -1
  325. package/dist/storage/merge-cut.mjs +24 -1
  326. package/dist/storage/merge-fence.mjs +1 -1
  327. package/dist/storage/merge-plan.mjs +5 -2
  328. package/dist/storage/merge-row.mjs +1 -1
  329. package/dist/storage/merge-stream.mjs +16 -7
  330. package/dist/storage/merge-write.mjs +1 -1
  331. package/dist/storage/merge.d.mts +2 -2
  332. package/dist/storage/merge.mjs +1 -1
  333. package/dist/storage/object-rows.d.mts +2 -2
  334. package/dist/storage/object-rows.mjs +3 -3
  335. package/dist/storage/pack-ranges.d.mts +3 -1
  336. package/dist/storage/pack-ranges.mjs +168 -69
  337. package/dist/storage/pack-reads.mjs +4 -4
  338. package/dist/storage/pack-receive.d.mts +1 -1
  339. package/dist/storage/pack-receive.mjs +7 -9
  340. package/dist/storage/packs.d.mts +1 -1
  341. package/dist/storage/packs.mjs +45 -52
  342. package/dist/storage/placed-reads.mjs +81 -15
  343. package/dist/storage/prune-seen.mjs +126 -0
  344. package/dist/storage/prune-walk.mjs +87 -99
  345. package/dist/storage/prune.mjs +49 -14
  346. package/dist/storage/push-uploads.mjs +4 -2
  347. package/dist/storage/quarantine.d.mts +2 -2
  348. package/dist/storage/ready.d.mts +2 -2
  349. package/dist/storage/ready.mjs +3 -3
  350. package/dist/storage/receive-files.mjs +1 -1
  351. package/dist/storage/receive-links.mjs +1 -1
  352. package/dist/storage/receive-state.d.mts +2 -2
  353. package/dist/storage/receive-state.mjs +1 -1
  354. package/dist/storage/receive-steps.mjs +1 -1
  355. package/dist/storage/repack-contained.mjs +2 -2
  356. package/dist/storage/repack-job.d.mts +2 -2
  357. package/dist/storage/repack-job.mjs +5 -4
  358. package/dist/storage/repack.d.mts +1 -1
  359. package/dist/storage/repack.mjs +9 -3
  360. package/dist/storage/rows.d.mts +2 -2
  361. package/dist/storage/rows.mjs +1 -1
  362. package/dist/storage/runs.d.mts +2 -2
  363. package/dist/storage/runs.mjs +15 -6
  364. package/dist/storage/send-list.mjs +6 -6
  365. package/dist/storage/single-flight.mjs +2 -2
  366. package/dist/storage/swap-walk.mjs +1 -1
  367. package/dist/storage/unpack.mjs +1 -1
  368. package/dist/store/call-count.d.mts +1 -1
  369. package/dist/store/call-count.mjs +125 -34
  370. package/dist/store/catalogue.d.mts +1 -1
  371. package/dist/store/catalogue.mjs +2 -2
  372. package/dist/store/crossing.mjs +2 -6
  373. package/dist/store/cursor-seal.mjs +1 -1
  374. package/dist/store/errors.d.mts +7 -3
  375. package/dist/store/errors.mjs +41 -13
  376. package/dist/store/job-try.mjs +119 -15
  377. package/dist/store/list-job.mjs +5 -5
  378. package/dist/store/outbox.d.mts +2 -2
  379. package/dist/store/outbox.mjs +75 -16
  380. package/dist/store/promises.d.mts +2 -2
  381. package/dist/store/promises.mjs +31 -6
  382. package/dist/store/queue-jobs.mjs +1 -1
  383. package/dist/store/records.d.mts +2 -2
  384. package/dist/store/records.mjs +16 -24
  385. package/dist/store/ref-rows.d.mts +2 -2
  386. package/dist/store/ref-rows.mjs +6 -6
  387. package/dist/store/reservations.mjs +35 -8
  388. package/dist/store/scopes.mjs +6 -4
  389. package/dist/store/topic-jobs.mjs +8 -8
  390. package/dist/sync/bound.d.mts +1 -3
  391. package/dist/sync/bound.mjs +30 -42
  392. package/dist/sync/bridge.d.mts +6 -0
  393. package/dist/sync/bridge.mjs +29 -0
  394. package/dist/sync/github.d.mts +5 -6
  395. package/dist/sync/github.mjs +37 -42
  396. package/dist/sync/http.mjs +15 -0
  397. package/dist/sync/import.mjs +17 -18
  398. package/dist/sync/layer.d.mts +9 -0
  399. package/dist/sync/layer.mjs +68 -0
  400. package/dist/sync/mirror.mjs +137 -58
  401. package/dist/sync/publish.mjs +3 -6
  402. package/dist/sync/step.mjs +217 -79
  403. package/dist/sync/tries.mjs +22 -15
  404. package/dist/sync.d.mts +3 -6
  405. package/dist/sync.mjs +3 -6
  406. package/dist/topics/advance.mjs +205 -90
  407. package/dist/topics/calls.mjs +8 -8
  408. package/dist/topics/directory.mjs +35 -12
  409. package/dist/topics/host.d.mts +5 -8
  410. package/dist/topics/host.mjs +42 -19
  411. package/dist/topics/layer.d.mts +381 -0
  412. package/dist/topics/layer.mjs +62 -0
  413. package/dist/topics/members.mjs +1 -1
  414. package/dist/topics/namespace.d.mts +2 -0
  415. package/dist/topics/public.d.mts +6 -0
  416. package/dist/topics/public.mjs +13 -0
  417. package/dist/topics/rows.mjs +12 -3
  418. package/dist/topics/topic.mjs +11 -10
  419. package/package.json +8 -13
  420. package/dist/access.d.mts +0 -2
  421. package/dist/access.mjs +0 -1
  422. package/dist/core/hooks/post-receive.mjs +0 -216
  423. package/dist/core/hooks/pre-receive.d.mts +0 -12
  424. package/dist/core/hooks/pre-receive.mjs +0 -36
  425. package/dist/server/extension.d.mts +0 -21
  426. package/dist/sync/import.d.mts +0 -10
  427. package/dist/sync/jobs.d.mts +0 -9
  428. package/dist/sync/jobs.mjs +0 -75
  429. package/dist/sync/mirror.d.mts +0 -13
  430. package/dist/sync/publish.d.mts +0 -6
  431. /package/dist/core/{claim-rows.d.mts → registered-rows.d.mts} +0 -0
@@ -14,7 +14,7 @@ import { gitObjectOf, objectOfRow, receivedRows } from "../storage/object-rows.m
14
14
  import { pruneClearedKey } from "../storage/prune.mjs";
15
15
  import { abandonOwn } from "../storage/quarantine.mjs";
16
16
  import { QuarantineRow, decodeHeld } from "../storage/rows.mjs";
17
- import { bestEffort, decodeRow, storeCall } from "../store/errors.mjs";
17
+ import { bestEffort, decodeRow, fromInfra, storeCall } from "../store/errors.mjs";
18
18
  import { callScope } from "../store/call-count.mjs";
19
19
  import { decodePacks, gitStore } from "../store/git-store.mjs";
20
20
  import { WholeRepo, refBytesOf, storesPeel, wholeRefs } from "../store/ref-rows.mjs";
@@ -23,7 +23,8 @@ import { sliceOf } from "../protocol/wire/push-limits.mjs";
23
23
  import { pushCounts } from "./events/seen.mjs";
24
24
  import { refViewIn } from "./ref-view.mjs";
25
25
  import { appendEvents, decodeOutbox, firstSeq, outboxReads, repoEnvelope } from "../store/outbox.mjs";
26
- import { MirrorRow, PrunedMark, mirrorJobName } from "../store/records.mjs";
26
+ import { MirrorRow } from "./mirror-rows.mjs";
27
+ import { PrunedMark, mirrorJobName } from "../store/records.mjs";
27
28
  import { decodeTimes, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
28
29
  import { advanceRow } from "../store/queue-jobs.mjs";
29
30
  import { liveReservations, reservedTarget } from "../store/reservations.mjs";
@@ -31,8 +32,8 @@ import { settleName } from "../store/settle.mjs";
31
32
  import { collections, newChangeId, prunedKey, pushedKey, pushedUnder, reachedKey, repoScope } from "../store/scopes.mjs";
32
33
  import { headOf, indexJobs, openKeyed, openRepo, refIndexJobs, repoAccess } from "./access.mjs";
33
34
  import { kindsOf } from "./ancestry.mjs";
34
- import { savedPushRow } from "./hooks/post-receive.mjs";
35
- import { runPreReceive } from "./hooks/pre-receive.mjs";
35
+ import { isRefName } from "./names.mjs";
36
+ import { runHookGroups } from "./hooks/groups.mjs";
36
37
  import { Changes } from "./changes.mjs";
37
38
  import { batchOf, readerOf } from "./rules/changes.mjs";
38
39
  import { commitChangesOf, coveredTips } from "./rules/commit-changes.mjs";
@@ -49,11 +50,11 @@ import { peeledAll, peeledOf } from "../storage/wants.mjs";
49
50
  import { CoreParts, ObjectsParts } from "./parts.mjs";
50
51
  import { Authorize, check } from "../contracts/authorize.mjs";
51
52
  import { read } from "./objects/objects.mjs";
52
- import { checkWrites } from "@ref0/infra";
53
- import * as Effect from "effect/Effect";
54
53
  import * as Clock$1 from "effect/Clock";
55
- import * as Result from "effect/Result";
54
+ import * as Effect from "effect/Effect";
56
55
  import * as Exit from "effect/Exit";
56
+ import * as Result from "effect/Result";
57
+ import { checkWrites } from "@ref0/infra";
57
58
  import * as Equal from "effect/Equal";
58
59
  // src/core/push.ts
59
60
  /**
@@ -194,12 +195,12 @@ const markOf = (rows) => {
194
195
  const firstRead = (caller, operation, internalId) => openRepo(caller, {
195
196
  kind: "read",
196
197
  repo: operation.repo
197
- }, [packsRead, prunedKey], internalId);
198
+ }, [packsRead, prunedKey], internalId, "skip");
198
199
  /** `firstRead` for a keyed push: `undefined` once `missed`'s repo moved, as `openKeyed` says. */
199
200
  const keyedRead = (caller, operation, missed, internalId) => openKeyed(caller, {
200
201
  kind: "read",
201
202
  repo: operation.repo
202
- }, [packsRead, prunedKey], missed, internalId);
203
+ }, [packsRead, prunedKey], missed, internalId, "skip");
203
204
  /**
204
205
  * The first read's repo once `authorize` lets the caller push to it: its list, for the pack to be
205
206
  * received against, its default branch, whose move rebuilds the ready shallow pack, and its
@@ -294,8 +295,8 @@ const activeMirrors = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
294
295
  return active;
295
296
  });
296
297
  /**
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.
298
+ * `sync.mirror`'s row for each ref the commit moves that an active mirror names, found by
299
+ * name among the jobs the server knows: none until `Sync.layer` has bound them.
299
300
  */
300
301
  const mirrorJobs = (core, moved, mirrored) => {
301
302
  const definition = core.jobOf?.(mirrorJobName);
@@ -400,9 +401,9 @@ const buildFence = (build) => [
400
401
  /**
401
402
  * The decide's read, one of the repo's scope: its refs, its outbox, the push's own `quarantine` row
402
403
  * 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
404
+ * reservation row of each branch in `branches`, there while a queue targets it, with the live
405
+ * reservation each holds, and the caller's grant fence, checked on what it read. A revoke after it
406
+ * moves the version, as does a write with the same key that commits first. A prune that dropped objects since the first
406
407
  * read moved the `pruned` mark: the push may name one it dropped, so unless its key's receipt
407
408
  * answers, it fails, to be sent again (Q270). `changed`: whether a row of a build's fence,
408
409
  * `unchanged`, holds another value than its plan read.
@@ -411,7 +412,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
411
412
  const own = received?.quarantine === void 0 ? [] : [received.quarantine];
412
413
  const keyed = receiptReads(kept);
413
414
  const targets = branches.map((id) => ({
414
- collection: collections.queueTargets,
415
+ collection: collections.queueReservations,
415
416
  id
416
417
  }));
417
418
  const linkedRows = received?.linked?.rows ?? [];
@@ -521,11 +522,11 @@ const settingsOf = (record) => ({
521
522
  public: record.public,
522
523
  defaultBranch: record.defaultBranch
523
524
  });
524
- /** The rules, then `hooks.preReceive`, once, at the first read the push decides on. */
525
+ /** The rules, the registrations' checks, then the hook groups, once, at the first read the push decides on. */
525
526
  const runChecks = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, facts) {
526
527
  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, {
528
+ const ruled = yield* registeredAfter(checks, input, yield* runPushRules(checks, input, context));
529
+ const whole = yield* runHookGroups(checks.reports, checks.groups?.() ?? [], context, {
529
530
  atomic: input.atomic,
530
531
  updates: ruled.updates,
531
532
  refused: ruled.refused
@@ -580,12 +581,12 @@ const checkAll = /* @__PURE__ */ Effect.fnUntraced(function* (checks, request, i
580
581
  };
581
582
  });
582
583
  /**
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.
584
+ * The rules' answer, with the refs the registered checks refuse among the rest: each in turn, by band
585
+ * then registration name, on the refs none before it refused, so a ref's first refusal is its answer.
585
586
  */
586
- const claimedAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, ruled) {
587
+ const registeredAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, ruled) {
587
588
  const refused = new Map(ruled.refused);
588
- for (const { handler } of checks.claimed?.() ?? []) {
589
+ for (const { handler } of checks.registered?.() ?? []) {
589
590
  const updates = ruled.updates.filter((update) => !refused.has(update.ref));
590
591
  if (updates.length === 0) break;
591
592
  for (const [ref, error] of yield* handler(input, updates)) if (!refused.has(ref)) refused.set(ref, error);
@@ -595,11 +596,11 @@ const claimedAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input,
595
596
  refused
596
597
  };
597
598
  });
598
- /** Whether a push has anything to check: a rule, a claimed check, or `hooks.preReceive`. */
599
+ /** Whether a push has anything to check: a rule, a registered check, or a hook group. */
599
600
  const checksOf = /* @__PURE__ */ Effect.fnUntraced(function* (core) {
600
601
  const { checks } = core;
601
602
  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;
603
+ return (yield* pushRulesFor(checks)).length > 0 || (checks.registered?.().length ?? 0) > 0 || (checks.groups?.().length ?? 0) > 0 ? checks : void 0;
603
604
  });
604
605
  /**
605
606
  * The repo's objects with the push's own, for the built-in check: `objects` and `listed` read
@@ -703,8 +704,8 @@ const fetchedRefused = /* @__PURE__ */ Effect.fnUntraced(function* (kinds, reque
703
704
  /**
704
705
  * A commit the store refuses as too large, before it applies any write, for a `loose()` push whose
705
706
  * 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.
707
+ * writes. It gets the hint those limits give. A refusal the push's own writes earn alone keeps
708
+ * the store's message: fewer objects wouldn't help it.
708
709
  * So does `packs()`'s, whose small pushes are rows too: it's on `packs()` already. `loose()` is
709
710
  * known by the quarantine it received, so a wrapper that passes it on, as Git's HTTP does, keeps it.
710
711
  */
@@ -787,6 +788,7 @@ const pushOf = (access, id, moved, request) => {
787
788
  if (slice !== void 0) push.slice = slice;
788
789
  const options = request.pushOptions ?? [];
789
790
  if (options.length > 0) push.options = options;
791
+ if (request.onBehalfOf === true) push.onBehalfOf = true;
790
792
  return push;
791
793
  };
792
794
  /**
@@ -801,32 +803,6 @@ const movedKinds = (updates, moved) => {
801
803
  }));
802
804
  };
803
805
  /**
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
806
  * The pack a push's own receive put under its `quarantine` row: none for a push with no pack, one
831
807
  * of rows alone, or a caller's `received`, which stays its caller's to end.
832
808
  */
@@ -841,11 +817,13 @@ const lists = (body, pack) => body.delete.some((key) => key.collection === objec
841
817
  * The push decide's loop past its first read, onto `listed`, keeping its answer under `key`:
842
818
  * the pack received into its quarantine; each edit's kind from the objects; then a read of the
843
819
  * 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.
820
+ * the hook groups, for a write that moves a ref; the pure decide, and one commit at that read's
821
+ * version, with the ref moves, the receipt and the events.
822
+ * `answers` says what the call answers and keeps. `checking`: the rules, the hook and the decide
823
+ * only, refused as the commit would be, its `writes` or none, and answered before it, for
824
+ * `checkPush`: nothing before that point writes, reserves or enqueues, with no pack.
847
825
  */
848
- const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, view, views }, key, answers) => Effect.scoped(Effect.gen(function* () {
826
+ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, view, views }, key, answers, checking = false) => Effect.scoped(Effect.gen(function* () {
849
827
  const core = yield* CoreParts;
850
828
  const { objects: sealed } = yield* ObjectsParts;
851
829
  const authorize = yield* Authorize;
@@ -978,7 +956,8 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
978
956
  const own = updates.filter((update) => gitsOwnMove(hidden, request.as, update.ref));
979
957
  const outside = updates.filter((update) => !gitsOwnMove(hidden, request.as, update.ref));
980
958
  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/"));
959
+ const branches = request.source === "queue" ? [] : outside.map((update) => update.ref).filter((ref) => ref.startsWith("refs/heads/") && isRefName(ref));
960
+ const touched = updates.map(({ ref }) => ref).filter(isRefName);
982
961
  const scope = yield* callScope;
983
962
  const reader = readerOf(pushedObjects, pushedListed, scope);
984
963
  const batch = batchOf(pushedObjects, pushedListed, scope);
@@ -989,7 +968,6 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
989
968
  repo,
990
969
  source: request.source,
991
970
  atomic: request.atomic,
992
- ...call,
993
971
  push: {
994
972
  bytes: received?.bytes ?? 0,
995
973
  objects: received?.objects ?? 0
@@ -1025,7 +1003,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
1025
1003
  let checked;
1026
1004
  for (let tries = 0; tries < 10; tries += 1) {
1027
1005
  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);
1006
+ const decide = yield* finalRead(store, target, fence, received, key, mark, branches, touched, request.guard, request.writes?.unchanged);
1029
1007
  const { read, receipt, outbox, record, mirrored, facts, stats, times, queued, reserved, indexRow } = decide;
1030
1008
  const indexed = SealedObjects.whole(sealed, pushWhole).index?.status(indexRow, at, listedIds(decide.at, received?.change));
1031
1009
  if (receipt !== void 0) return yield* answers.held(receipt);
@@ -1093,11 +1071,12 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
1093
1071
  const upkept = clears && jobs.length === 0 ? [core.repackJobRow()] : jobs;
1094
1072
  const planned = yield* planOf(decision, read.version, upkept);
1095
1073
  const { change } = planned;
1096
- const refusal = writes === void 0 ? void 0 : refusalOf(planned.answer);
1074
+ const refusal = writes === void 0 && !checking ? void 0 : refusalOf(planned.answer);
1097
1075
  if (refusal !== void 0) return yield* Effect.fail(refusal);
1098
1076
  const movedRefs = new Set(planned.moved.map((move) => move.ref));
1099
1077
  const liftedOnMoves = [...checked?.bypassed ?? none].filter(([ref]) => movedRefs.has(ref));
1100
1078
  const answer = yield* answers.answer(planned.answer, forced, new Map(liftedOnMoves));
1079
+ if (checking) return answer;
1101
1080
  const also = planned.answer.updates.some((update) => update.kind === "rejected") || request.also === void 0 ? void 0 : request.also(yield* Clock$1.currentTimeMillis, received);
1102
1081
  const alsoWrites = (also?.put.length ?? 0) + (also?.delete?.length ?? 0);
1103
1082
  const quiet = key === void 0 && alsoWrites === 0 && writes === void 0;
@@ -1137,15 +1116,6 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
1137
1116
  });
1138
1117
  const final = answers.committed?.(answer, appended.head.next - 1) ?? answer;
1139
1118
  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
1119
  const woken = shown.filter((move) => queued.has(move.ref)).map((move) => advanceRow(move.ref));
1150
1120
  const pushed = pushedRows(core.access, shown, times, at);
1151
1121
  const body = {
@@ -1157,7 +1127,6 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
1157
1127
  ...kept.put,
1158
1128
  ...also?.put ?? [],
1159
1129
  ...appended.put,
1160
- ...saved.put,
1161
1130
  ...writes?.put ?? []
1162
1131
  ],
1163
1132
  delete: [
@@ -1169,7 +1138,6 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
1169
1138
  jobs: withJobs([
1170
1139
  ...planned.jobs,
1171
1140
  ...appended.jobs,
1172
- ...saved.jobs,
1173
1141
  ...mirrorJobs(core, planned.moved, mirrored),
1174
1142
  ...writes?.jobs ?? [],
1175
1143
  ...woken,
@@ -1185,6 +1153,10 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
1185
1153
  moved: planned.moved.length
1186
1154
  }, core.refIndex);
1187
1155
  if (past !== void 0) return yield* Effect.fail(past);
1156
+ yield* Effect.try({
1157
+ try: () => checkWrites(body),
1158
+ catch: (cause) => fromInfra(cause)
1159
+ }).pipe(Effect.mapError(commitTooLarge(received, body)));
1188
1160
  if ((yield* storeCall(() => store.commit(scope, body)).pipe(Effect.mapError(commitTooLarge(received, body)))).ok) {
1189
1161
  listing = ownedPack !== void 0 && lists(body, ownedPack);
1190
1162
  return final;
@@ -1206,14 +1178,23 @@ const operationOf = ({ repo, edits }) => edits.length === 0 ? {
1206
1178
  * reads and decides again. A push cut before its commit leaves an unlisted pack for clean-up, and
1207
1179
  * no ref moved.
1208
1180
  */
1209
- const pushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, key) {
1181
+ const pushWith = (request, answers, key) => pushThrough(request, answers, key, false);
1182
+ /** `pushWith`, or with `checking`, its checks alone, as `pushOnto` says. */
1183
+ const pushThrough = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, key, checking) {
1210
1184
  const operation = operationOf(request);
1211
1185
  const resolved = yield* firstRead(request.caller, operation, request.internalId).pipe(Effect.tapError((error) => retriedCodes.has(error.code) ? Effect.void : refuseQueued(request, [error], "access")));
1212
1186
  const opened = yield* listedFor(request, operation, resolved);
1213
- return yield* pushOnto(request, opened, key, answers);
1187
+ return yield* pushOnto(request, opened, key, answers, checking);
1214
1188
  });
1215
1189
  /** A push or an unkeyed `refs.update`, answering the decide's ref answer. */
1216
1190
  const push = (request) => pushWith(request, refsAnswers);
1191
+ /**
1192
+ * What `push` of `request` would answer, with nothing written, reserved or enqueued: its reads,
1193
+ * `authorize`, its rules and the hook, and the decide, failing as its commit would, a queue's
1194
+ * callers told as its publish tells them. A topic asks it of each member's publish before its
1195
+ * decision (Q1159). For a request with no pack; re-exported from no index.
1196
+ */
1197
+ const checkPush = (request) => request.pack === void 0 ? pushThrough(request, refsAnswers, void 0, true) : fail("INTERNAL", "A push is checked with no pack");
1217
1198
  /** A `git push`, as `push`, with the lines Git prints for the rules `authorize` lifted. */
1218
1199
  const gitPush = (request) => pushWith(request, gitAnswers);
1219
1200
  /** A ref a forced fetch moved past its diverged tip, answered `force`; the rest as they are. */
@@ -1248,4 +1229,4 @@ const keyedPushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answ
1248
1229
  });
1249
1230
  /** `keyedPushWith` for `refs.update`, answering the decide's ref answer. */
1250
1231
  const keyedPush = (request, keyed) => keyedPushWith(request, refsAnswers, keyed);
1251
- export { buildFence, gitPush, isQueueMoved, keyedPush, keyedPushWith, push, pushFetched, pushWith, retriedCodes };
1232
+ 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";
@@ -2,8 +2,8 @@ import { fail, gitErrorFrom, httpStatus } from "../contracts/result.mjs";
2
2
  import { decodeRow } from "../store/errors.mjs";
3
3
  import { KeptRepoInfo, keyLive } from "../store/records.mjs";
4
4
  import { collections } from "../store/scopes.mjs";
5
- import * as Schema from "effect/Schema";
6
5
  import * as Effect from "effect/Effect";
6
+ import * as Schema from "effect/Schema";
7
7
  // src/core/receipts.ts
8
8
  /**
9
9
  * A receipt row's day, in milliseconds. It's `keyKept` at least, so a receipt `keyKept` hasn't
@@ -36,7 +36,9 @@ const KeptUpdate = /* @__PURE__ */ Schema.Union([Schema.Struct({
36
36
  /**
37
37
  * A keyed write's first answer: a `refs.update`'s, a repo write's, the object an object write
38
38
  * answered and whether it published a ref, which its call reads again to answer, a merge queue
39
- * call's as it answered, or none, for the rest.
39
+ * call's as it answered, a fork's create, which keeps none, or none, for the rest. A resent fork
40
+ * key answers the fork as it is now, read as `repos.get` reads it for that caller, while every
41
+ * other key answers as it first did.
40
42
  */
41
43
  const KeptAnswer = /* @__PURE__ */ Schema.Union([
42
44
  Schema.Struct({
@@ -57,7 +59,8 @@ const KeptAnswer = /* @__PURE__ */ Schema.Union([
57
59
  kind: Schema.Literal("queue"),
58
60
  answer: Schema.Json
59
61
  }),
60
- Schema.Struct({ kind: Schema.Literal("done") })
62
+ Schema.Struct({ kind: Schema.Literal("done") }),
63
+ Schema.Struct({ kind: Schema.Literal("fork") })
61
64
  ]);
62
65
  /**
63
66
  * A keyed write's receipt, in the scope it wrote, saved in the write's own commit: the input its
@@ -226,6 +229,27 @@ const refsAnswer = (held) => held.answer?.kind === "refs" ? Effect.succeed({ upd
226
229
  ...update,
227
230
  error: heldError(update.error)
228
231
  }) }) : noAnswer(held, "refs");
232
+ /**
233
+ * A fork create's receipt: its answer is asked of the view after its commit, so it keeps none, and
234
+ * the create sent again reads the fork again.
235
+ */
236
+ const forkKept = { kind: "fork" };
237
+ /**
238
+ * Whether a held receipt's write has answered, so the write sent again answers from it, or is a
239
+ * work write's still `pending`, which calls the queue again. Each kind is named, with no default
240
+ * arm, so a new kind must say which it is.
241
+ */
242
+ const receiptAnswered = (held) => {
243
+ if (held.answer === void 0) return held.pending !== true;
244
+ switch (held.answer.kind) {
245
+ case "refs":
246
+ case "repo":
247
+ case "object":
248
+ case "queue":
249
+ case "done": return true;
250
+ case "fork": return true;
251
+ }
252
+ };
229
253
  /** The answer a repo create, update or rename's receipt kept, for the write sent again. */
230
254
  const repoAnswer = (held) => held.answer?.kind === "repo" ? Effect.succeed(held.answer.info) : noAnswer(held, "repo");
231
255
  /** The object a create, merge, revert or pick's receipt kept, for the write sent again. */
@@ -239,4 +263,4 @@ const writtenOf = (kept) => {
239
263
  if (kept.renamesSkipped !== void 0) written.renamesSkipped = kept.renamesSkipped;
240
264
  return written;
241
265
  };
242
- export { KeptError, ReceiptRow, dayMs, dayOf, heldError, heldReceipt, keptError, liveReceipt, matchedReceipt, objectAnswer, receiptId, receiptKeys, receiptReads, receiptRow, receiptWrites, refsAnswer, refsKept, repoAnswer, sweepDue, sweepOf, sweepRead, withJobs };
266
+ export { KeptError, ReceiptRow, dayMs, dayOf, forkKept, heldError, heldReceipt, keptError, liveReceipt, matchedReceipt, objectAnswer, receiptAnswered, receiptId, receiptKeys, receiptReads, receiptRow, receiptWrites, refsAnswer, refsKept, repoAnswer, sweepDue, sweepOf, sweepRead, withJobs };
@@ -1,11 +1,11 @@
1
1
  import { storeCall } from "../store/errors.mjs";
2
- import { currentRepo, madeJob, repoTry } from "../store/job-try.mjs";
2
+ import { currentRepo, gitJob, repoTry } from "../store/job-try.mjs";
3
3
  import { readRecord } from "../store/repo-record.mjs";
4
4
  import { newChangeId, repoScope, selfKey } from "../store/scopes.mjs";
5
5
  import { copyRead, indexCopies, indexRowKeys, otherRowsReads, ownRowsRead } from "./ref-index.mjs";
6
- import { Job } from "@ref0/infra";
7
- import * as Schema from "effect/Schema";
8
6
  import * as Effect from "effect/Effect";
7
+ import * as Schema from "effect/Schema";
8
+ import { Job } from "@ref0/infra";
9
9
  // src/core/ref-index-job.ts
10
10
  /**
11
11
  * `git.ref-index`, a repo's ref index rebuilt under the server's stamp (#668), as
@@ -167,7 +167,7 @@ const RefIndexJob = /* @__PURE__ */ Job.make(refIndexJobName, {
167
167
  rebuild: () => ({})
168
168
  });
169
169
  /** `git.ref-index`, over the server's ref index: each try one step of its rebuild, whose `more` starts its tries again. */
170
- const refIndexJob = (parts) => madeJob(RefIndexJob.definition(() => repoTry((store, repo) => rebuildTry(parts, store, repo)), { onFailure: rebuildFailed }));
170
+ const refIndexJob = (parts) => gitJob(RefIndexJob, () => repoTry((store, repo) => rebuildTry(parts, store, repo)), { onFailure: rebuildFailed });
171
171
  /** The repo's `git.ref-index` row, due now. */
172
172
  const refIndexJobRow = (job) => job.job({
173
173
  key: refIndexJobKey,
@@ -5,10 +5,10 @@ import { advanceName, buildName, timeoutName, trimName } from "../store/queue-jo
5
5
  import { mirrorJobName } from "../store/records.mjs";
6
6
  import { CoreParts } from "./parts.mjs";
7
7
  import { Authorize, audience, check, grantOf } from "../contracts/authorize.mjs";
8
- import * as Effect from "effect/Effect";
9
- import * as Context from "effect/Context";
10
8
  import * as Clock$1 from "effect/Clock";
9
+ import * as Effect from "effect/Effect";
11
10
  import * as Option from "effect/Option";
11
+ import * as Context from "effect/Context";
12
12
  // src/core/ref-view.ts
13
13
  /**
14
14
  * What a caller who reads every pattern, or any caller of a server with no `access`, sees. It has
@@ -1,5 +1,6 @@
1
1
  import { count, get, list, protection, protections, sees, update } from "../contracts/refs.mjs";
2
- import { maxRefNameLength } from "../contracts/ids.mjs";
2
+ import { isHost } from "../contracts/git.mjs";
3
+ import "../contracts/ids.mjs";
3
4
  import { badCursor } from "../engine/reads.mjs";
4
5
  import { listBound } from "../store/cursor-seal.mjs";
5
6
  import { storeCall } from "../store/errors.mjs";
@@ -19,10 +20,11 @@ import { pushRulesFor } from "./rules/check.mjs";
19
20
  import { refProtection } from "./rules/protect.mjs";
20
21
  import { fail } from "../contracts/result.mjs";
21
22
  import { CoreParts, acting } from "./parts.mjs";
22
- import { check } from "../contracts/authorize.mjs";
23
- import { byBytes, jsonBytes, limits } from "@ref0/infra";
24
- import * as Effect from "effect/Effect";
23
+ import { bypassKinds, hostAuthorize } from "../auth/authorize.mjs";
24
+ import { Authorize, check } from "../contracts/authorize.mjs";
25
25
  import * as Clock$1 from "effect/Clock";
26
+ import * as Effect from "effect/Effect";
27
+ import { byBytes, jsonBytes, limits } from "@ref0/infra";
26
28
  const maxRefLimit = 1e3;
27
29
  /**
28
30
  * The most ranges one store call of a listing's page reads under `access`. Each span the caller
@@ -34,9 +36,9 @@ const maxRefLimit = 1e3;
34
36
  */
35
37
  const refListRangesMost = 2 * (72 + gitsOwnRefs.length) + 1;
36
38
  /** A longest ref name, of `"` past `refs/`, which JSON doubles. */
37
- const longestName = `refs/${"\"".repeat(maxRefNameLength - 5)}`;
38
- /** A longest class: a pattern as written, as long as a name, with the `*` that classes it. */
39
- const longestClass = `refs/${"\"".repeat(maxRefNameLength - 6)}*`;
39
+ const longestName = `refs/${"\"".repeat(763)}`;
40
+ /** A longest class: a pattern as written, at `maxRefPatternLength`, with the `*` that classes it. */
41
+ const longestClass = `refs/${"\"".repeat(186)}*`;
40
42
  /** A ref row's longest value: a SHA-256 `oid` and `peeled`. */
41
43
  const longestValue = {
42
44
  oid: "0".repeat(64),
@@ -44,14 +46,14 @@ const longestValue = {
44
46
  };
45
47
  /**
46
48
  * The most bytes one ref's `refs` row takes in a store's answer, as UTF-8 JSON, its collection
47
- * included: a longest name and value, about 2.2 KB. Each read of a listing's call takes as many rows
49
+ * included: a longest name and value, about 1.7 KB. Each read of a listing's call takes as many rows
48
50
  * as keep every read full within `limits.answerBytes`, so a page is short before its call is
49
51
  * refused. A read by name is sized by this, not by the longer `refIndexRowBytesMost`: one bound
50
52
  * for both cut a 1,000-ref page of four reads short, at 975.
51
53
  */
52
54
  const refRowBytesMost = refRowBytes(longestName, longestValue);
53
55
  /**
54
- * As `refRowBytesMost`, for a ref's `refIndex` row, about 4.3 KB: its stamp and class, a pattern
56
+ * As `refRowBytesMost`, for a ref's `refIndex` row, about 2.1 KB: its stamp and class, a pattern
55
57
  * as written, come before its name. Only a read of the index is sized by it.
56
58
  */
57
59
  const refIndexRowBytesMost = jsonBytes({
@@ -477,6 +479,7 @@ const refCalls = (bound) => {
477
479
  };
478
480
  if (input.signal !== void 0) request.signal = input.signal;
479
481
  if (input.internalId !== void 0) request.internalId = input.internalId;
482
+ if (input.onBehalfOf !== void 0) request.onBehalfOf = true;
480
483
  const edits = input.updates.map(({ ref, from, to }) => [
481
484
  ref,
482
485
  from,
@@ -556,6 +559,27 @@ const refCalls = (bound) => {
556
559
  update
557
560
  };
558
561
  };
562
+ /**
563
+ * `effect` with its push decided as host code's, `hostAuthorize`'s, which lifts no rule: every
564
+ * other check, its view and the publish rule among them, stays its caller's own.
565
+ */
566
+ const pushingAsHost = (effect) => Effect.updateService(effect, Authorize, (decider) => ({
567
+ ...decider,
568
+ check: (request) => request.operation.kind === "push" || bypassKinds.has(request.operation.kind) ? hostAuthorize(request) : decider.check(request)
569
+ }));
570
+ /**
571
+ * `refs.update`'s `onBehalfOf`: `for`'s own update, but its push decided as the host's, once every
572
+ * ref it moves is under a prefix a registration publishes.
573
+ */
574
+ const onBehalfOfUpdate = (repo, input, caller) => Effect.flatMap(Effect.service(CoreParts), (core) => {
575
+ const prefixes = core.publishedRefs().map(({ prefix }) => prefix);
576
+ const outside = input.updates.find(({ ref }) => !prefixes.some((one) => ref.startsWith(one)));
577
+ if (outside !== void 0) {
578
+ const allowed = prefixes.length === 0 ? "no registration publishes one" : prefixes.join(", ");
579
+ return fail("INVALID_ARGUMENT", `'onBehalfOf' moves only refs under a published prefix: ${outside.ref} is under none (${allowed})`);
580
+ }
581
+ return pushingAsHost(refCalls(caller).update(repo, input));
582
+ });
559
583
  /** `Refs`' calls, each deciding for its `by`, as `refCalls(by)`'s do. */
560
584
  const refsCalls = {
561
585
  get: (repo, input, by) => acting(by, refCalls(by).get(repo, input)),
@@ -564,7 +588,14 @@ const refsCalls = {
564
588
  sees: (repo, input, by) => acting(by, refCalls(by).sees(repo, input)),
565
589
  list: (repo, input, by) => acting(by, refCalls(by).list(repo, input)),
566
590
  count: (repo, input, by) => acting(by, refCalls(by).count(repo, input)),
567
- update: (repo, input, by) => acting(by, refCalls(by).update(repo, input))
591
+ update: (repo, input, by) => {
592
+ const { actingAs, onBehalfOf } = input;
593
+ if ((actingAs !== void 0 || onBehalfOf !== void 0) && !isHost(by)) return fail("INVALID_ARGUMENT", "Only Git.host's refs.update names 'actingAs' or 'onBehalfOf'");
594
+ if (actingAs !== void 0 && onBehalfOf !== void 0) return fail("INVALID_ARGUMENT", "A refs.update names 'actingAs' or 'onBehalfOf', never both");
595
+ if (actingAs !== void 0) return refCalls(actingAs).update(repo, input);
596
+ if (onBehalfOf !== void 0) return onBehalfOfUpdate(repo, input, onBehalfOf);
597
+ return acting(by, refCalls(by).update(repo, input));
598
+ }
568
599
  };
569
600
  /** The `refs` group deciding for `by`, over the `Refs` its runtime holds. */
570
601
  const refsAs = (by) => ({
@@ -0,0 +1,30 @@
1
+ import { storeCall, storeWatch } from "../store/errors.mjs";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Stream from "effect/Stream";
4
+ // src/core/registered-records.ts
5
+ /** Whether `scope` belongs to the exact scope or prefix `owned`. */
6
+ const ownsScope = (owned, scope) => owned.endsWith("/") ? scope.startsWith(owned) : scope === owned;
7
+ /** Records restricted to one registration's scopes, read in the calling fiber so its fence survives. */
8
+ const registeredRecords = (name, scopes, base) => {
9
+ const within = (scope, run) => Effect.suspend(() => {
10
+ if (!scopes.some((owned) => ownsScope(owned, scope))) return Effect.die(/* @__PURE__ */ new TypeError(`${name} does not own scope '${scope}'`));
11
+ const records = base();
12
+ return records === void 0 ? Effect.die(/* @__PURE__ */ new Error(`${name}'s records were used before Git.layer wired its store`)) : run(records);
13
+ });
14
+ return {
15
+ read: (scope, reads, counts) => within(scope, (records) => storeCall(records.read(scope, reads, counts))),
16
+ commit: (scope, change) => within(scope, (records) => storeCall(records.commit(scope, change), { resend: true })),
17
+ add: (scope, addition) => within(scope, (records) => storeCall(records.add(scope, addition))),
18
+ watch: (scope, watch) => Stream.unwrap(within(scope, (records) => Effect.succeed(storeWatch(() => records.watch(scope, watch))))),
19
+ jobs: {
20
+ claim: (scope, request) => within(scope, (records) => storeCall(records.jobs.claim(scope, request))),
21
+ settle: (claim, outcome) => within(claim.job.scope, (records) => storeCall(records.jobs.settle(claim, outcome))),
22
+ progress: (scope, write) => within(scope, (records) => storeCall(records.jobs.progress(scope, write))),
23
+ count: (scope) => within(scope, (records) => storeCall(records.jobs.count(scope))),
24
+ list: (scope, request) => within(scope, (records) => storeCall(records.jobs.list(scope, request))),
25
+ retry: (scope, job, input) => within(scope, (records) => storeCall(records.jobs.retry(scope, job, input))),
26
+ discard: (scope, job) => within(scope, (records) => storeCall(records.jobs.discard(scope, job)))
27
+ }
28
+ };
29
+ };
30
+ export { ownsScope, registeredRecords };
@@ -3,14 +3,14 @@ import { storeCall } from "../store/errors.mjs";
3
3
  import { readRecord } from "../store/repo-record.mjs";
4
4
  import { newChangeId, repoScope } from "../store/scopes.mjs";
5
5
  import * as Effect from "effect/Effect";
6
- // src/core/claim-rows.ts
6
+ // src/core/registered-rows.ts
7
7
  const unbound = (name) => /* @__PURE__ */ new Error(`${name}'s rows were used before Git.layer wired its store`);
8
8
  /**
9
- * Claim `name`'s rows: collections under `<name>/` in each repo's scope, over `base` once the
10
- * wiring binds it. A read or a write of any other collection is a defect, so a claim never meets
11
- * the repo's record, refs, objects or another claim's rows.
9
+ * Registration `name`'s rows: collections under `<name>/` in each repo's scope, over `base` once the
10
+ * wiring binds it. A read or a write of any other collection is a defect, so a registration never meets
11
+ * the repo's record, refs, objects or another registration's rows.
12
12
  */
13
- const claimRows = (name, base) => {
13
+ const registeredRows = (name, base) => {
14
14
  const prefix = `${name}/`;
15
15
  const outside = (touched) => touched.find((one) => !one.collection.startsWith(prefix));
16
16
  const within = (touched, run) => Effect.suspend(() => {
@@ -50,4 +50,4 @@ const claimRows = (name, base) => {
50
50
  })))
51
51
  };
52
52
  };
53
- export { claimRows };
53
+ export { registeredRows };
@@ -7,5 +7,5 @@ import "../contracts/result.mjs";
7
7
  import "../storage/repack-job.mjs";
8
8
  import "./events/deliver.mjs";
9
9
  import "./view.mjs";
10
- import { JobDefinition, JobInput, Moment } from "@ref0/infra";
11
- import "effect/Effect";
10
+ import "effect/Effect";
11
+ import { JobDefinition, JobInput, Moment } from "@ref0/infra";