@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
@@ -1,9 +1,11 @@
1
1
  import { CallsSpent } from "../contracts/calls-spent.mjs";
2
2
  import * as Effect from "effect/Effect";
3
- import * as Context from "effect/Context";
4
- import * as Predicate from "effect/Predicate";
3
+ import * as HttpClient from "effect/http/HttpClient";
5
4
  import * as Option from "effect/Option";
5
+ import * as Predicate from "effect/Predicate";
6
+ import * as Context from "effect/Context";
6
7
  import * as Layer from "effect/Layer";
8
+ import * as References from "effect/References";
7
9
  // src/store/call-count.ts
8
10
  /**
9
11
  * The store calls a Git fetch's request makes before its count starts, which its `callLimits`
@@ -11,18 +13,34 @@ import * as Layer from "effect/Layer";
11
13
  * call. Every call from the serve on counts on the request's one count, the repo's record, its
12
14
  * refs, its haves and its tags' peels with its pack's (#709). Measured locally, not at a colo, by
13
15
  * negotiation-calls.test.ts: a token's request refused at its bound made 1 call more than it
14
- * counted. The host's own `auth`, grants and `resolve` aren't Git's calls: a host whose run
15
- * subrequests sets `callLimits` lower by them.
16
+ * counted. The host's own `auth` and grants aren't Git's calls: a host whose run subrequests sets
17
+ * `callLimits` lower by them. Its fetch rules are `hookCallsBefore`'s.
16
18
  */
17
19
  const requestCallsBefore = {
18
20
  bucket: 0,
19
21
  subrequests: 1
20
22
  };
21
- /** `most` less `requestCallsBefore`, never below none: a request's bound once `identify` has read. */
22
- const lessCallsBefore = (most) => ({
23
- bucket: Math.max(0, most.bucket - requestCallsBefore.bucket),
24
- subrequests: Math.max(0, most.subrequests - requestCallsBefore.subrequests)
25
- });
23
+ /**
24
+ * The calls one of the host's hooks makes before a Git request's count starts, beside
25
+ * `requestCallsBefore`'s: the fetch rules, on a fetch. B1a's K read measured it on Workers, 2
26
+ * calls before the count with a hook against 1 with none. A hook that
27
+ * makes more sets `callLimits` lower by them.
28
+ */
29
+ const hookCallsBefore = {
30
+ bucket: 0,
31
+ subrequests: 1
32
+ };
33
+ /**
34
+ * The store calls a job's try makes outside its handler, which its job budget leaves room for: the
35
+ * claim its invocation takes, or the settle an earlier one left, and the settle that ends it, which
36
+ * takes the next claim in the same call, as a Worker's job object runs a try through infra's
37
+ * `tryOnce`, one try an invocation. No bucket call. A try's progress, written at most once a
38
+ * second, isn't counted: a host whose tries run long sets `callLimits` lower by it.
39
+ */
40
+ const jobCallsAround = {
41
+ bucket: 0,
42
+ subrequests: 2
43
+ };
26
44
  /** The kind of `counted`'s calls `kind` would pass `most` of, if any. */
27
45
  const spentOf = (counted, most, kind, calls = 1, of = "request", budget) => {
28
46
  if (most === void 0) return void 0;
@@ -76,12 +94,17 @@ const requestCount = Effect.map(Effect.serviceOption(RequestCount), Option.getOr
76
94
  * `effect`, run after its request's deciding commit, as `AfterCommit` says, the request in scope
77
95
  * marked `committed` too, so its later Git calls, each a run of its own, are refused no more.
78
96
  */
79
- const afterCommit = (effect) => Effect.flatMap(requestCount, (request) => {
97
+ const afterCommit = (effect) => Effect.flatMap(Effect.all([requestCount, inScope]), ([request, budget]) => {
80
98
  if (request !== void 0) request.committed = true;
99
+ for (const at of chainOf(budget)) markCommitted(at);
81
100
  return Effect.provideService(effect, AfterCommit, true);
82
101
  });
83
102
  /** Whether a call in scope runs after its request's deciding commit, as `afterCommit` marks it. */
84
- const committedNow = Effect.map(Effect.all([requestCount, AfterCommit]), ([request, marked]) => marked || request?.committed === true);
103
+ const committedNow = Effect.suspend(() => Effect.map(Effect.all([
104
+ requestCount,
105
+ inScope,
106
+ AfterCommit
107
+ ]), ([request, budget, marked]) => marked || request?.committed === true || committedIn(budget)));
85
108
  /**
86
109
  * A lost commit's `resends`, counted into the request and its budgets but never refused, and the
87
110
  * request left unmarked: each may have landed, and none decided anything yet.
@@ -90,6 +113,10 @@ const chargeResends = (resends) => resends === 0 ? Effect.void : Effect.provideS
90
113
  /** A budget's calls so far, and the budget it nests in, read only in this module. */
91
114
  let madeOf;
92
115
  let parentOf;
116
+ /** Marks `budget` past its request's deciding commit, when it's a request's: others it leaves. */
117
+ let markCommitted;
118
+ /** Whether `budget` is a request's, past its deciding commit. */
119
+ let committedOf;
93
120
  let budgetOf;
94
121
  /** What `CallAllowance`'s constructor takes to make one: module-private, so only `make` can. */
95
122
  const madeHere = Symbol("ref0/git CallAllowance");
@@ -102,23 +129,39 @@ var CallAllowance = class CallAllowance {
102
129
  limits;
103
130
  /** The name its spent refusal gives it, as `CallBudget.make` was given it, if any. */
104
131
  name;
105
- #made = {
106
- bucket: 0,
107
- subrequests: 0
108
- };
132
+ #made;
109
133
  #parent;
134
+ /** Whether it's a request's, as `requestBudget` makes one, whose commit mark outlasts a run. */
135
+ #request;
136
+ #committed = false;
110
137
  static {
111
138
  madeOf = (budget) => budget.#made;
112
139
  parentOf = (budget) => budget.#parent;
113
- budgetOf = (limits, parent, name) => new CallAllowance(madeHere, limits, parent, name);
140
+ markCommitted = (budget) => {
141
+ if (budget.#request) budget.#committed = true;
142
+ };
143
+ committedOf = (budget) => budget.#committed;
144
+ budgetOf = (limits, parent, name, request = false, shared) => new CallAllowance(madeHere, limits, parent, name, request, shared === void 0 ? void 0 : shared.#made);
114
145
  }
115
- constructor(token, limits, parent, name) {
146
+ constructor(token, limits, parent, name, request, made = {
147
+ bucket: 0,
148
+ subrequests: 0
149
+ }) {
116
150
  if (token !== madeHere) throw new TypeError("A CallAllowance is made only by CallBudget.make");
117
151
  this.limits = limits;
118
152
  this.name = name;
153
+ this.#made = made;
119
154
  this.#parent = parent;
155
+ this.#request = request;
120
156
  }
121
157
  };
158
+ /** Whether `budget`, or one it nests in, is a request's past its deciding commit. */
159
+ const committedIn = (budget) => chainOf(budget).some(committedOf);
160
+ /**
161
+ * The counts of `chain`'s budgets, each once: a part's budget from `budgetWithin` keeps its step's
162
+ * count, so a call counted into both counts once.
163
+ */
164
+ const countsOf = (chain) => new Set(chain.map((at) => madeOf(at)));
122
165
  /** `budget` and the budgets it nests in, the innermost first. */
123
166
  const chainOf = (budget) => {
124
167
  const chain = [];
@@ -142,20 +185,21 @@ const checkedLimits = (limits, what = "A CallBudget's ") => {
142
185
  }
143
186
  return Object.freeze(copied);
144
187
  };
145
- /** `limits` less `requestCallsBefore`, never below none. */
146
- const lessBefore = (limits) => {
147
- const less = (most, before) => most === void 0 ? void 0 : Math.max(0, most - before);
148
- const bucket = less(limits.bucket, requestCallsBefore.bucket);
149
- const subrequests = less(limits.subrequests, requestCallsBefore.subrequests);
188
+ /** `limits` less `before`, `requestCallsBefore` unless given, never below none. */
189
+ const lessBefore = (limits, before = requestCallsBefore) => {
190
+ const less = (most, made) => most === void 0 ? void 0 : Math.max(0, most - made);
191
+ const bucket = less(limits.bucket, before.bucket);
192
+ const subrequests = less(limits.subrequests, before.subrequests);
150
193
  const lessened = {};
151
194
  if (bucket !== void 0) lessened.bucket = bucket;
152
195
  if (subrequests !== void 0) lessened.subrequests = subrequests;
153
196
  return lessened;
154
197
  };
155
198
  /**
156
- * A limit on the store and bucket calls an Effect makes, below the platform's on its request.
157
- * Each call Git makes in its scope counts into it as it starts: a store call as a subrequest, and
158
- * a bucket call as a bucket call and a subrequest, as `CallLimits` counts them.
199
+ * A limit on the store and bucket calls an Effect makes, and its outbound HTTP requests, below the
200
+ * platform's on its request. Each call Git makes in its scope counts into it as it starts: a store
201
+ * call or a request through a `charged` client as a subrequest, and a bucket call as a bucket call
202
+ * and a subrequest, as `CallLimits` counts them.
159
203
  *
160
204
  * A budget lives as long as the Layer that built it: provide one around one call or one step,
161
205
  * never in a runtime's Layer, where every request would share it until the runtime ends. Each
@@ -181,6 +225,18 @@ var CallBudget = class CallBudget extends (/* @__PURE__ */ Context.Service()("@r
181
225
  /** `make`'s budget, as a Layer: one new budget each time it's built. */
182
226
  static layer = (limits, options = {}) => Layer.effect(CallBudget, CallBudget.make(limits, options));
183
227
  /**
228
+ * `http`, each request it sends charged first, as one subrequest, to the request and every
229
+ * budget in scope when it's sent: one that would pass a bound is refused before it's sent with
230
+ * the defect `CallsSpent`, as a store call is. A retry wrapped around the charged client is
231
+ * charged each try, as a platform counts each, so `http` is a host's client with no retry
232
+ * middleware of its own: one beneath the charge would send uncounted. A redirect the client
233
+ * follows itself, as `fetch` does by default, is charged once with the request it answers, up to
234
+ * the 20 hops `fetch` follows; one asked for with `redirect: 'manual'` and followed by its caller
235
+ * is charged each hop. With nothing in scope, as a host's own call outside a job, it charges
236
+ * nothing.
237
+ */
238
+ static charged = (http) => HttpClient.transform(http, (effect) => Effect.andThen(chargeCall("fetch"), effect));
239
+ /**
184
240
  * Whether the budget in scope, or one it nests in, has spent a kind of call it limits, so the
185
241
  * next call of that kind is refused: a host's call answers `RESOURCE_EXHAUSTED`,
186
242
  * `reason: 'call-budget'`.
@@ -188,6 +244,64 @@ var CallBudget = class CallBudget extends (/* @__PURE__ */ Context.Service()("@r
188
244
  */
189
245
  static isSpent = Effect.map(inScope, (budget) => chainOf(budget).some((at) => spentOf(madeOf(at), at.limits, "bucket") !== void 0));
190
246
  };
247
+ /**
248
+ * A request's budget of `limits`, as `CallBudget.make` makes one named `'request'`, that the
249
+ * request's deciding commit marks, as `afterCommit` marks a `RequestCalls`: no bound refuses a
250
+ * call in it after that, each Git call its answer makes later in a run of its own included (Q855).
251
+ * Internal: a joined package's request is the one that has it.
252
+ */
253
+ const requestBudget = (limits) => Effect.map(inScope, (parent) => budgetOf(checkedLimits(limits), parent, "request", true));
254
+ /** Whether `inner` is `outer`, or nests in it, however deep. */
255
+ const nestsIn = (inner, outer) => chainOf(inner).includes(outer);
256
+ /** `budget`'s calls so far. */
257
+ const budgetMade = (budget) => ({ ...madeOf(budget) });
258
+ /** `budget`'s limits as a count: a kind it leaves unbounded, `Infinity`. */
259
+ const budgetMost = (budget) => ({
260
+ bucket: budget.limits.bucket ?? Number.POSITIVE_INFINITY,
261
+ subrequests: budget.limits.subrequests ?? Number.POSITIVE_INFINITY
262
+ });
263
+ /** `most` of `kind`, no more than what each budget of `chain` has left of it. */
264
+ const leftOf = (most, chain, kind) => chain.reduce((least, at) => {
265
+ const limit = at.limits[kind];
266
+ return limit === void 0 ? least : Math.min(least, Math.max(0, limit - madeOf(at)[kind]));
267
+ }, most);
268
+ /**
269
+ * A step's own budget, named `name`, nested in the budget in scope, a job's try's: of `most`, or
270
+ * of what that one and each it nests in have left, if less, so a step that cuts its work at its
271
+ * bound cuts it where its calls really stop.
272
+ */
273
+ const stepBudget = (most, name) => Effect.map(inScope, (parent) => {
274
+ const chain = chainOf(parent);
275
+ const limits = {
276
+ bucket: leftOf(most.bucket, chain, "bucket"),
277
+ subrequests: leftOf(most.subrequests, chain, "subrequests")
278
+ };
279
+ return budgetOf(checkedLimits(limits), parent, name);
280
+ });
281
+ /**
282
+ * A budget nested in `budget`, under its name, that keeps `budget`'s count and stops where it
283
+ * reaches `bound`: for a step's part that leaves room under its bound for what follows it, as a
284
+ * save's calls. A call made through `budget` alone counts against `bound` too, so the room the
285
+ * part leaves holds wherever the step makes its other calls.
286
+ */
287
+ const budgetWithin = (budget, bound) => {
288
+ const limits = {
289
+ bucket: Math.max(0, bound.bucket),
290
+ subrequests: Math.max(0, bound.subrequests)
291
+ };
292
+ return budgetOf(checkedLimits(limits), budget, budget.name, false, budget);
293
+ };
294
+ /**
295
+ * `calls` of `kind` counted into `budget` alone, never refused: calls the budgets it nests in
296
+ * counted already, made for its step outside its scope, as a recheck's reread.
297
+ */
298
+ const countInto = (budget, kind, calls) => Effect.sync(() => add(madeOf(budget), kind, calls));
299
+ /**
300
+ * `input` with the budget in scope on it, as `budgetedOn` puts one, or as it is with none: for a
301
+ * call across a Promise a host may wrap, as `git.index`'s step, so the call counts into the
302
+ * budget of the try that made it.
303
+ */
304
+ const budgetedInput = (input) => Effect.map(inScope, (budget) => budget === void 0 ? input : budgetedOn(input, budget));
191
305
  /** `effect`, run with `calls` as its request's count, or as it is with none. */
192
306
  const countedAs = (effect, calls) => calls === void 0 ? effect : Effect.provideService(effect, RequestCount, calls);
193
307
  /**
@@ -219,34 +333,33 @@ const withRequestHold = (effect) => Effect.suspend(() => {
219
333
  const hold = new RequestHold();
220
334
  return effect.pipe(Effect.provideService(RequestHolding, hold), Effect.ensuring(hold.close));
221
335
  });
222
- /**
223
- * `scope`, counting into `calls` too when it holds no request's count of its own: a call a host's
224
- * code makes for one request, as a package built on Git makes each of its routes' (#725).
225
- */
226
- const countedScope = (scope, calls) => calls === void 0 || scope.calls !== void 0 ? scope : {
227
- ...scope,
228
- calls
229
- };
230
336
  /** A scope with neither part: what a call taken with nothing in scope counts into. */
231
337
  const noScope = {
232
338
  calls: void 0,
233
339
  budget: void 0
234
340
  };
235
- /** The call scope in context: its parts `undefined` with neither a request's count nor a budget. */
341
+ /**
342
+ * The call scope in context: its parts `undefined` with neither a request's count nor a budget,
343
+ * and the runtime's loggers, so a run across a Promise logs where the call began.
344
+ */
236
345
  const callScope = Effect.map(Effect.all([
237
346
  requestCount,
238
347
  Effect.serviceOption(CallBudget),
239
348
  Effect.serviceOption(RequestHolding),
240
- AfterCommit
241
- ]), ([calls, budget, hold, after]) => calls === void 0 && Option.isNone(budget) && Option.isNone(hold) && !after ? noScope : {
349
+ AfterCommit,
350
+ References.CurrentLoggers,
351
+ References.MinimumLogLevel
352
+ ]), ([calls, budget, hold, after, loggers, minimum]) => ({
242
353
  calls,
243
354
  budget: Option.getOrUndefined(budget),
244
355
  hold: Option.getOrUndefined(hold),
245
- afterCommit: after
246
- });
356
+ afterCommit: after,
357
+ logging: Context.make(References.CurrentLoggers, loggers).pipe(Context.add(References.MinimumLogLevel, minimum))
358
+ }));
247
359
  /**
248
360
  * `effect`, run in `scope` and no other: with the request's count, the budget, the hold and
249
- * the `afterCommit` mark it holds, and with none it doesn't hold, whatever the context had. So a reader or a walk opened with no
361
+ * the `afterCommit` mark it holds, and with none it doesn't hold, whatever the context had, and
362
+ * with the loggers it carries, when it carries them. So a reader or a walk opened with no
250
363
  * budget never takes one provided around a later call, and a run handed no scope counts nothing.
251
364
  */
252
365
  const inCallScope = (effect, scope) => Effect.updateContext(effect, scopedContext(scope));
@@ -255,7 +368,8 @@ const scopedContext = (scope) => (context) => {
255
368
  const counted = scope.calls === void 0 ? Context.omit(RequestCount)(context) : Context.add(context, RequestCount, scope.calls);
256
369
  const budgeted = scope.budget === void 0 ? Context.omit(CallBudget)(counted) : Context.add(counted, CallBudget, scope.budget);
257
370
  const held = scope.hold === void 0 ? Context.omit(RequestHolding)(budgeted) : Context.add(budgeted, RequestHolding, scope.hold);
258
- return Context.add(held, AfterCommit, scope.afterCommit === true);
371
+ const marked = Context.add(held, AfterCommit, scope.afterCommit === true);
372
+ return scope.logging === void 0 ? marked : Context.merge(marked, scope.logging);
259
373
  };
260
374
  /**
261
375
  * One call of `kind`, counted into the request in scope and every `CallBudget` in scope, or
@@ -273,7 +387,7 @@ const chargeCalls = (kind, calls) => Effect.flatMap(Effect.all([
273
387
  inScope,
274
388
  AfterCommit
275
389
  ]), ([request, budget, marked]) => {
276
- const after = marked || request?.committed === true;
390
+ const after = marked || request?.committed === true || committedIn(budget);
277
391
  const spent = request === void 0 || after ? void 0 : spentOf(request, request.most, kind, calls);
278
392
  if (spent !== void 0) return Effect.die(spent);
279
393
  const chain = chainOf(budget);
@@ -284,7 +398,7 @@ const chargeCalls = (kind, calls) => Effect.flatMap(Effect.all([
284
398
  return Effect.die(over);
285
399
  }
286
400
  if (request !== void 0) add(request, kind, calls);
287
- for (const at of chain) add(madeOf(at), kind, calls);
401
+ for (const made of countsOf(chain)) add(made, kind, calls);
288
402
  return Effect.void;
289
403
  });
290
404
  /**
@@ -298,7 +412,7 @@ const heldCall = (kind) => Effect.flatMap(Effect.all([requestCount, inScope]), (
298
412
  if (!held) return;
299
413
  held = false;
300
414
  if (request !== void 0) add(request, kind, -1);
301
- for (const at of chainOf(budget)) add(madeOf(at), kind, -1);
415
+ for (const made of countsOf(chainOf(budget))) add(made, kind, -1);
302
416
  });
303
417
  return Effect.as(chargeCall(kind), given);
304
418
  });
@@ -346,4 +460,4 @@ const withBound = (objects, most) => {
346
460
  };
347
461
  /** The bound `withBound` kept for `objects`, or `undefined` for objects with none, a host's own. */
348
462
  const countedMost = (objects) => objectsBounds.get(objects);
349
- export { CallAllowance, CallBudget, RequestCalls, RequestCount, RequestHold, RequestHolding, afterCommit, budgetedOn, callScope, chargeCall, chargeCalls, chargeResends, checkedLimits, committedNow, countedAs, countedMost, countedScope, heldCall, inCallScope, lessBefore, lessCallsBefore, noScope, readScope, requestCallsBefore, requestCount, scopedContext, spentBudget, withBound, withRequestHold };
463
+ export { CallAllowance, CallBudget, RequestCalls, RequestCount, RequestHold, RequestHolding, afterCommit, budgetMade, budgetMost, budgetWithin, budgetedInput, budgetedOn, callScope, chargeCall, chargeCalls, chargeResends, checkedLimits, committedNow, countInto, countedAs, countedMost, heldCall, hookCallsBefore, inCallScope, jobCallsAround, lessBefore, nestsIn, noScope, readScope, requestBudget, requestCallsBefore, requestCount, scopedContext, spentBudget, stepBudget, withBound, withRequestHold };
@@ -4,8 +4,8 @@ import "../contracts/repos.mjs";
4
4
  import "../contracts/result.mjs";
5
5
  import { SettledName } from "./outbox.mjs";
6
6
  import { CatalogueEntry, StoredRepo } from "./records.mjs";
7
- import { Key, Listing, Page, Read, Row, Snapshot } from "@ref0/infra";
8
7
  import "effect/Effect";
8
+ import { Key, Listing, Page, Read, Row, Snapshot } from "@ref0/infra";
9
9
  import "effect/Types";
10
10
  /**
11
11
  * A repo found by name: its entry, its record, and its scope's snapshot, self first. Its `name` is
@@ -3,8 +3,8 @@ import { fail } from "../contracts/result.mjs";
3
3
  import { decodeDerivedRow, decodeRow, storeCall } from "./errors.mjs";
4
4
  import { CatalogueEntry, CreatedRow, ForkRow, StoredRepo, keyKept, takenBack } from "./records.mjs";
5
5
  import { catalogueScope, collections, forkId, newChangeId, repoScope, selfKey } from "./scopes.mjs";
6
- import { limits } from "@ref0/infra";
7
6
  import * as Effect from "effect/Effect";
7
+ import { limits } from "@ref0/infra";
8
8
  // src/store/catalogue.ts
9
9
  /** How many times a projection reads and commits again when another name's write moved first. */
10
10
  const projectTries = 8;
@@ -474,7 +474,7 @@ const heldNameAt = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalI
474
474
  /** How many times `hostRecordOf` reads again when a write moved the repo between its reads. */
475
475
  const hostReadTries = 5;
476
476
  /**
477
- * A repo's record as host code reads it, by internal ID: `ExtendedGit.repo`'s answer, `undefined`
477
+ * A repo's record as host code reads it, by internal ID: `RepoRecords.record`'s answer, `undefined`
478
478
  * once it's deleted. Its name is the one the catalogue gives it, read between two reads of its
479
479
  * record at one version, so it's never a name another repo holds. When the catalogue gives it
480
480
  * neither name, its projection is finished as `git.list` would, and it's read again; still none at
@@ -1,12 +1,10 @@
1
1
  import { inCallScope } from "./call-count.mjs";
2
2
  import { answerOf } from "../contracts/calls-spent.mjs";
3
- import { thrownError } from "./errors.mjs";
4
3
  import * as Effect from "effect/Effect";
5
4
  import * as Stream from "effect/Stream";
6
5
  // src/store/crossing.ts
7
6
  /**
8
- * Why a run takes no call scope: a job's try is no request's, so only the platform's cap bounds
9
- * it, host code and a client make no call through Git's doors, and a timer or an interrupt makes
7
+ * Why a run takes no call scope: host code and a client make no call through Git's doors, and a timer or an interrupt makes
10
8
  * no call at all. Read by review, so short and true.
11
9
  */
12
10
  var Uncounted = class {
@@ -47,8 +45,6 @@ const runnerIn = (context) => (effect, signal) => Effect.runPromiseWith(context)
47
45
  * waits for a read, so a body no one reads yet holds no chunk of the bucket's.
48
46
  */
49
47
  const readableIn = (stream, context) => Stream.toReadableStreamWith(stream, context, { strategy: { highWaterMark: 0 } });
50
- /** A job's try as a Promise: Git's error, thrown with it as the cause, so the queue retries. */
51
- const runJobTry = (effect) => runIn(Effect.mapError(effect, thrownError), uncounted("a job's try: no request's, so only the platform's cap bounds it"));
52
48
  /**
53
49
  * `effect`, interrupted when `signal` aborts: it then dies with the signal's reason. For a job's
54
50
  * part that holds no signal of its own, as a repack's upkeep, so its calls stop at the try's
@@ -64,4 +60,4 @@ const untilAborted = (effect, signal) => {
64
60
  });
65
61
  return Effect.raceFirst(effect, aborted);
66
62
  };
67
- export { Uncounted, exitIn, exitOn, forkIn, noCall, readableIn, resultIn, runIn, runJobTry, runnerIn, syncIn, uncounted, untilAborted };
63
+ export { Uncounted, exitIn, exitOn, forkIn, noCall, readableIn, resultIn, runIn, runnerIn, syncIn, uncounted, untilAborted };
@@ -2,8 +2,8 @@ import { fail } from "../contracts/result.mjs";
2
2
  import { decodeRow, storeCall } from "./errors.mjs";
3
3
  import { bytesFromBase64Url, randomText, toBase64Url, utf8Of } from "./random.mjs";
4
4
  import { catalogueScope, collections } from "./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
  import * as Semaphore from "effect/Semaphore";
8
8
  // src/store/cursor-seal.ts
9
9
  /** The row in `git/repos` that holds the key every list cursor is sealed with. */
@@ -1,7 +1,8 @@
1
1
  import { GitError } from "../contracts/result.mjs";
2
- import { Committed, Row } from "@ref0/infra";
3
- import "effect/Schema";
4
2
  import * as Effect from "effect/Effect";
3
+ import "effect/Schema";
4
+ import { Committed, Row } from "@ref0/infra";
5
+ import "effect/Stream";
5
6
  /**
6
7
  * A store call, its refusal as Git's error: one of the two doors every call Git makes goes
7
8
  * through, with `bucketCall`, and every call a package built on Git makes, as `@ref0/github`'s
@@ -9,4 +10,7 @@ import * as Effect from "effect/Effect";
9
10
  * either's bound (Q799): past one, it dies with `CallsSpent`, which an edge answers, as
10
11
  * `spentRefusalOf` does.
11
12
  */
12
- export declare const storeCall: <A>(run: () => Promise<A>) => Effect.Effect<A, GitError>;
13
+ export declare function storeCall<A>(run: () => Promise<A>): Effect.Effect<A, GitError>;
14
+ export declare function storeCall<A, E, R>(run: Effect.Effect<A, E, R>, options?: {
15
+ readonly resend?: boolean;
16
+ }): Effect.Effect<A, GitError, R>;
@@ -1,12 +1,15 @@
1
1
  import { fail, gitError, gitErrorFrom } from "../contracts/result.mjs";
2
- import { callLimitIn, callLimitTry, catchSpent, fromAnswer, spentRefusal } from "../contracts/calls-spent.mjs";
2
+ import { callLimitIn, callLimitTry, catchSpent, fromAnswer, spentAt, spentRefusal } from "../contracts/calls-spent.mjs";
3
3
  import { chargeCall, chargeResends, committedNow } from "./call-count.mjs";
4
4
  import { isServerClosed, tryClosing } from "./closed.mjs";
5
- import { isInfraError } from "@ref0/infra";
6
- import * as Schema from "effect/Schema";
7
5
  import * as Effect from "effect/Effect";
8
- import * as Predicate from "effect/Predicate";
9
6
  import * as Option from "effect/Option";
7
+ import * as Schema from "effect/Schema";
8
+ import * as Cause from "effect/Cause";
9
+ import * as Exit from "effect/Exit";
10
+ import { isInfraError } from "@ref0/infra";
11
+ import * as Predicate from "effect/Predicate";
12
+ import * as Stream from "effect/Stream";
10
13
  import * as Data from "effect/Data";
11
14
  // src/store/errors.ts
12
15
  const savedHint = "Read it back before you try again";
@@ -100,14 +103,39 @@ const routeEdge = (effect, refused) => Effect.catch(answerSpent(effect), (error)
100
103
  * `spentRefusal`'s, and any other defect a defect still.
101
104
  */
102
105
  const answerSpent = (effect) => catchSpent(effect, (spent) => Effect.fail(spentRefusal(spent)));
103
- /**
104
- * A store call, its refusal as Git's error: one of the two doors every call Git makes goes
105
- * through, with `bucketCall`, and every call a package built on Git makes, as `@ref0/github`'s
106
- * records (Q826). It counts into the request and the `CallBudget` in scope, and never starts past
107
- * either's bound (Q799): past one, it dies with `CallsSpent`, which an edge answers, as
108
- * `spentRefusalOf` does.
109
- */
110
- const storeCall = (run) => Effect.andThen(chargeCall("store"), Effect.flatMap(committedNow, (after) => tryClosing(run, (cause) => fromInfra(cause, after)).pipe(Effect.tap((answer) => chargeResends(Predicate.isObject(answer) ? resent.get(answer) ?? 0 : 0)), Effect.tapError(({ cause }) => chargeResends(cause instanceof Unsettled ? 1 : 0)))));
106
+ function storeCall(run, options) {
107
+ if (Effect.isEffect(run)) return effectStoreCall(run, options?.resend === true);
108
+ return Effect.andThen(chargeCall("store"), Effect.flatMap(committedNow, (after) => tryClosing(run, (cause) => fromInfra(cause, after)).pipe(Effect.tap((answer) => chargeResends(Predicate.isObject(answer) ? resent.get(answer) ?? 0 : 0)), Effect.tapError(({ cause }) => chargeResends(cause instanceof Unsettled ? 1 : 0)))));
109
+ }
110
+ /** A store failure: preserve interruption, spent bounds, closed servers and code defects. */
111
+ const effectStoreFailure = (cause, after) => {
112
+ if (Cause.hasInterrupts(cause)) return Effect.failCause(Cause.map(cause, (error) => fromInfra(error, after)));
113
+ const error = Cause.squash(cause);
114
+ const spent = spentAt(error);
115
+ if (spent !== void 0) return Effect.die(spent);
116
+ if (isServerClosed(error) || codeErrors.some((code) => error instanceof code)) return Effect.die(error);
117
+ return Effect.fail(fromInfra(error, after));
118
+ };
119
+ /** A watch, charged once at subscription, with the same failure classification as a store call. */
120
+ const storeWatch = (run) => Stream.unwrap(storeCall(Effect.map(committedNow, (after) => run().pipe(Stream.catchCause((cause) => Stream.fromEffect(effectStoreFailure(cause, after)))))));
121
+ /** An Effect store call, with a commit's resends under the same ID when requested. */
122
+ const effectStoreCall = /* @__PURE__ */ Effect.fnUntraced(function* (run, resend) {
123
+ yield* chargeCall("store");
124
+ const after = yield* committedNow;
125
+ let lost;
126
+ for (let resends = 0;; resends += 1) {
127
+ const exit = yield* Effect.exit(run);
128
+ if (Exit.isSuccess(exit)) return exit.value;
129
+ if (Cause.hasInterrupts(exit.cause)) return yield* effectStoreFailure(exit.cause, after);
130
+ const cause = Cause.squash(exit.cause);
131
+ if (spentAt(cause) !== void 0 && lost === void 0) return yield* effectStoreFailure(exit.cause, after);
132
+ if (isServerClosed(cause)) return yield* effectStoreFailure(exit.cause, after);
133
+ if (!resend || (resends === 0 ? !isLostReply(cause) : isAnswered(cause))) return yield* effectStoreFailure(exit.cause, after);
134
+ lost ??= cause;
135
+ if (resends === 1 || !isLostReply(cause)) return yield* Effect.fail(fromInfra(new Unsettled("No reply came to a commit", { cause: lost }), after));
136
+ yield* chargeResends(1);
137
+ }
138
+ });
111
139
  /** What a commit sent `commitResendsMost` times again, with no reply, throws: it may have landed. */
112
140
  var Unsettled = class extends Error {
113
141
  name = "Unsettled";
@@ -220,4 +248,4 @@ const endedEarly = (cause) => {
220
248
  cause
221
249
  });
222
250
  };
223
- export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody, resending, resultCall, routeEdge, storeCall, thrownError };
251
+ export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody, resending, resultCall, routeEdge, storeCall, storeWatch, thrownError };