@ref0/git 0.12.0 → 0.20.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 (436) hide show
  1. package/dist/access/private-refs.mjs +3 -3
  2. package/dist/auth/access-jwt.mjs +2 -2
  3. package/dist/auth/auth.d.mts +2 -2
  4. package/dist/auth/auth.mjs +3 -6
  5. package/dist/auth/authorize.mjs +4 -20
  6. package/dist/auth/fences.d.mts +1 -2
  7. package/dist/auth/fences.mjs +3 -3
  8. package/dist/auth/grants.mjs +4 -4
  9. package/dist/auth/helpers.mjs +3 -11
  10. package/dist/auth/host-function.mjs +18 -1
  11. package/dist/auth/host-services.mjs +11 -0
  12. package/dist/auth/identify.d.mts +1 -1
  13. package/dist/auth/identify.mjs +3 -3
  14. package/dist/auth/policy.d.mts +27 -7
  15. package/dist/auth/policy.mjs +8 -4
  16. package/dist/auth/token-cleanup.mjs +67 -0
  17. package/dist/auth/token-rows.mjs +1 -1
  18. package/dist/auth/token-text.mjs +9 -1
  19. package/dist/auth/tokens-base.d.mts +35 -0
  20. package/dist/auth/tokens-base.mjs +13 -0
  21. package/dist/auth/tokens-layer.d.mts +2 -28
  22. package/dist/auth/tokens-layer.mjs +6 -12
  23. package/dist/auth/tokens-public.d.mts +3 -3
  24. package/dist/auth/tokens.d.mts +7 -17
  25. package/dist/auth/tokens.mjs +9 -87
  26. package/dist/auth.d.mts +1 -4
  27. package/dist/auth.mjs +1 -3
  28. package/dist/client/answer.mjs +21 -42
  29. package/dist/client/client.d.mts +2 -4
  30. package/dist/client/git-http.mjs +35 -11
  31. package/dist/client/local.mjs +14 -13
  32. package/dist/client/push-upload.mjs +39 -12
  33. package/dist/client/remote.mjs +95 -31
  34. package/dist/client/run-remote-helper.d.mts +1 -0
  35. package/dist/client/run-remote-helper.mjs +58 -24
  36. package/dist/client/slice-push.d.mts +1 -1
  37. package/dist/client/transport.mjs +105 -46
  38. package/dist/contracts/access.d.mts +8 -8
  39. package/dist/contracts/actors.d.mts +2 -34
  40. package/dist/contracts/blobs.d.mts +57 -10
  41. package/dist/contracts/blobs.mjs +16 -2
  42. package/dist/contracts/call-allowance.d.mts +13 -0
  43. package/dist/contracts/call-allowance.mjs +44 -0
  44. package/dist/contracts/calls-spent.mjs +8 -3
  45. package/dist/contracts/client.d.mts +23 -19
  46. package/dist/contracts/commits.d.mts +34 -26
  47. package/dist/contracts/commits.mjs +9 -1
  48. package/dist/contracts/engine.d.mts +6 -1
  49. package/dist/contracts/engine.mjs +10 -1
  50. package/dist/contracts/files.d.mts +12 -12
  51. package/dist/contracts/forks.d.mts +27 -17
  52. package/dist/contracts/git-events.d.mts +29 -1
  53. package/dist/contracts/git-hooks.d.mts +1 -1
  54. package/dist/contracts/git.d.mts +39 -7
  55. package/dist/contracts/git.mjs +3 -2
  56. package/dist/contracts/grants.d.mts +24 -4
  57. package/dist/contracts/handlers.d.mts +1 -1
  58. package/dist/contracts/lfs.d.mts +28 -9
  59. package/dist/contracts/merges.d.mts +3 -2
  60. package/dist/contracts/objects.d.mts +103 -35
  61. package/dist/contracts/operations.d.mts +3 -0
  62. package/dist/contracts/operations.mjs +12 -2
  63. package/dist/contracts/push-uploads.d.mts +44 -5
  64. package/dist/contracts/push-uploads.mjs +7 -3
  65. package/dist/contracts/queue.d.mts +40 -12
  66. package/dist/contracts/queue.mjs +3 -4
  67. package/dist/contracts/refs.d.mts +50 -25
  68. package/dist/contracts/remote.d.mts +6 -7
  69. package/dist/contracts/remote.mjs +5 -4
  70. package/dist/contracts/repo-records.d.mts +1 -0
  71. package/dist/contracts/repos.d.mts +106 -127
  72. package/dist/contracts/repos.mjs +33 -4
  73. package/dist/contracts/result.d.mts +49 -25
  74. package/dist/contracts/result.mjs +52 -11
  75. package/dist/contracts/rules.d.mts +22 -22
  76. package/dist/contracts/server.d.mts +37 -111
  77. package/dist/contracts/services.d.mts +1 -1
  78. package/dist/contracts/signin.d.mts +1 -1
  79. package/dist/contracts/store.d.mts +6 -5
  80. package/dist/contracts/sync.d.mts +90 -26
  81. package/dist/contracts/sync.mjs +45 -11
  82. package/dist/contracts/tags.d.mts +10 -10
  83. package/dist/contracts/time.d.mts +3 -0
  84. package/dist/contracts/{promises.mjs → time.mjs} +1 -1
  85. package/dist/contracts/tokens.d.mts +15 -22
  86. package/dist/contracts/tokens.mjs +3 -3
  87. package/dist/contracts/topics.d.mts +1 -6
  88. package/dist/contracts/trees.d.mts +12 -12
  89. package/dist/contracts/work.d.mts +87 -12
  90. package/dist/contracts/work.mjs +8 -1
  91. package/dist/core/access.d.mts +1 -2
  92. package/dist/core/access.mjs +46 -13
  93. package/dist/core/ancestry.d.mts +10 -0
  94. package/dist/core/ancestry.mjs +6 -6
  95. package/dist/core/asked.mjs +43 -5
  96. package/dist/core/call-names.mjs +7 -1
  97. package/dist/core/call-services.mjs +13 -4
  98. package/dist/core/events/deliver.d.mts +1 -2
  99. package/dist/core/events/deliver.mjs +48 -33
  100. package/dist/core/events/retired.mjs +119 -0
  101. package/dist/core/forks.mjs +931 -435
  102. package/dist/core/hooks/groups.mjs +1 -1
  103. package/dist/core/imports.mjs +159 -15
  104. package/dist/core/index-job.mjs +128 -37
  105. package/dist/core/index-lost.d.mts +1 -2
  106. package/dist/core/index-lost.mjs +2 -2
  107. package/dist/core/job-view.mjs +8 -9
  108. package/dist/core/loose-tally.mjs +1 -1
  109. package/dist/core/mirror-rows.mjs +19 -4
  110. package/dist/core/objects/blobs.mjs +129 -3
  111. package/dist/core/objects/commits.mjs +16 -6
  112. package/dist/core/objects/lines.mjs +2 -2
  113. package/dist/core/objects/merges.mjs +4 -1
  114. package/dist/core/objects/objects-layer.d.mts +1 -1
  115. package/dist/core/objects/objects-layer.mjs +3 -3
  116. package/dist/core/objects/reading.mjs +24 -13
  117. package/dist/core/objects/tags.mjs +4 -1
  118. package/dist/core/objects/trees.mjs +2 -2
  119. package/dist/core/objects/writing.mjs +2 -2
  120. package/dist/core/own-writes.mjs +1 -1
  121. package/dist/core/parts.d.mts +10 -6
  122. package/dist/core/parts.mjs +3 -11
  123. package/dist/core/promise.mjs +9 -12
  124. package/dist/core/purge.mjs +316 -42
  125. package/dist/core/push-decide.mjs +3 -1
  126. package/dist/core/push-files.d.mts +12 -0
  127. package/dist/core/push-files.mjs +225 -0
  128. package/dist/core/push-repo.d.mts +8 -0
  129. package/dist/core/push-repo.mjs +56 -0
  130. package/dist/core/push.d.mts +17 -0
  131. package/dist/core/push.mjs +153 -70
  132. package/dist/core/receipts.mjs +34 -13
  133. package/dist/core/ref-index-job.mjs +4 -4
  134. package/dist/core/ref-view.mjs +61 -7
  135. package/dist/core/refs.mjs +18 -13
  136. package/dist/core/registered-rows.mjs +2 -2
  137. package/dist/core/repack.mjs +46 -28
  138. package/dist/core/repo-info.mjs +19 -12
  139. package/dist/core/repos.mjs +50 -22
  140. package/dist/core/rules/commit-changes.d.mts +0 -1
  141. package/dist/core/saved-caller-views.d.mts +7 -2
  142. package/dist/core/saved-caller-views.mjs +2 -2
  143. package/dist/core/saved-callers.d.mts +19 -2
  144. package/dist/core/seam.d.mts +16 -26
  145. package/dist/core/seam.mjs +7 -28
  146. package/dist/core/tokens.mjs +1 -1
  147. package/dist/core/view.d.mts +6 -0
  148. package/dist/core/view.mjs +51 -26
  149. package/dist/core/work.mjs +105 -35
  150. package/dist/effect.d.mts +5 -12
  151. package/dist/effect.mjs +3 -10
  152. package/dist/engine/failures.mjs +2 -1
  153. package/dist/engine/reads.mjs +17 -10
  154. package/dist/engine/walk.mjs +4 -4
  155. package/dist/event-streams/event-streams.d.mts +1 -1
  156. package/dist/event-streams/event-streams.mjs +1 -1
  157. package/dist/event-streams/stream.d.mts +3 -3
  158. package/dist/event-streams/stream.mjs +38 -15
  159. package/dist/extend.d.mts +4 -5
  160. package/dist/extend.mjs +3 -2
  161. package/dist/http/answers.mjs +12 -7
  162. package/dist/http/core-parts.mjs +129 -64
  163. package/dist/http/handler.mjs +36 -9
  164. package/dist/http/node.d.mts +14 -1
  165. package/dist/http/node.mjs +61 -31
  166. package/dist/http/parts.d.mts +2 -0
  167. package/dist/http/push-upload-job.mjs +507 -0
  168. package/dist/http/push-uploads.d.mts +1 -0
  169. package/dist/http/push-uploads.mjs +142 -69
  170. package/dist/http/upload-pack.mjs +10 -9
  171. package/dist/index.d.mts +27 -28
  172. package/dist/index.mjs +5 -8
  173. package/dist/lfs/answer.mjs +37 -0
  174. package/dist/lfs/base.d.mts +9 -3
  175. package/dist/lfs/base.mjs +27 -2
  176. package/dist/lfs/copy.d.mts +60 -0
  177. package/dist/lfs/copy.mjs +109 -0
  178. package/dist/lfs/layer.d.mts +15 -1
  179. package/dist/lfs/layer.mjs +28 -13
  180. package/dist/lfs/locks.mjs +2 -2
  181. package/dist/lfs/objects.d.mts +7 -0
  182. package/dist/lfs/objects.mjs +152 -55
  183. package/dist/lfs/pointers.mjs +2 -2
  184. package/dist/lfs/rows.d.mts +13 -0
  185. package/dist/lfs/rows.mjs +42 -8
  186. package/dist/lfs/service.d.mts +1 -7
  187. package/dist/lfs/service.mjs +1 -9
  188. package/dist/lfs/upkeep.mjs +48 -14
  189. package/dist/lfs/upload-most.mjs +5 -5
  190. package/dist/lfs/wire.mjs +6 -31
  191. package/dist/merges/merges.mjs +2 -2
  192. package/dist/node.d.mts +3 -3
  193. package/dist/protocol/bytes/buffers.mjs +13 -5
  194. package/dist/protocol/bytes/reader.mjs +6 -1
  195. package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
  196. package/dist/protocol/bytes/sha256.d.mts +32 -0
  197. package/dist/protocol/bytes/sha256.mjs +105 -49
  198. package/dist/protocol/bytes/streams.mjs +27 -1
  199. package/dist/protocol/diff/read.d.mts +4 -3
  200. package/dist/protocol/diff/read.mjs +8 -3
  201. package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
  202. package/dist/protocol/objects/lfs-pointer.mjs +1 -3
  203. package/dist/protocol/objects/links-raw.mjs +24 -10
  204. package/dist/protocol/objects/tag.d.mts +1 -1
  205. package/dist/protocol/objects/tree.mjs +23 -6
  206. package/dist/protocol/packs/delta.d.mts +6 -3
  207. package/dist/protocol/packs/delta.mjs +96 -32
  208. package/dist/protocol/packs/idx.d.mts +2 -1
  209. package/dist/protocol/packs/idx.mjs +22 -3
  210. package/dist/protocol/packs/parts.d.mts +4 -1
  211. package/dist/protocol/packs/parts.mjs +10 -7
  212. package/dist/protocol/packs/reader.d.mts +5 -0
  213. package/dist/protocol/packs/reader.mjs +3 -2
  214. package/dist/protocol/packs/writer.mjs +26 -8
  215. package/dist/protocol/wire/advertisement.mjs +9 -4
  216. package/dist/protocol/wire/lines.d.mts +4 -2
  217. package/dist/protocol/wire/lines.mjs +11 -5
  218. package/dist/protocol/wire/push-uploads.mjs +13 -1
  219. package/dist/protocol/wire/v2.mjs +2 -2
  220. package/dist/protocol.d.mts +3 -1
  221. package/dist/protocol.mjs +3 -1
  222. package/dist/queue/advance.mjs +22 -25
  223. package/dist/queue/base.d.mts +55 -0
  224. package/dist/queue/base.mjs +44 -0
  225. package/dist/queue/calls.mjs +51 -54
  226. package/dist/queue/commit.mjs +1 -1
  227. package/dist/queue/host.d.mts +2 -22
  228. package/dist/queue/host.mjs +2 -13
  229. package/dist/queue/layer.d.mts +2 -1
  230. package/dist/queue/layer.mjs +11 -4
  231. package/dist/queue/limits.mjs +2 -0
  232. package/dist/queue/push-option.mjs +9 -24
  233. package/dist/queue/schedule.mjs +1 -1
  234. package/dist/queue/state.mjs +2 -10
  235. package/dist/queue/trim.mjs +6 -4
  236. package/dist/rest/blobs.mjs +29 -5
  237. package/dist/rest/caller.d.mts +4 -4231
  238. package/dist/rest/caller.mjs +5 -1
  239. package/dist/rest/client.d.mts +15 -5
  240. package/dist/rest/client.mjs +23 -2
  241. package/dist/rest/events.mjs +1 -2
  242. package/dist/rest/handler.mjs +4 -57
  243. package/dist/rest/handlers.mjs +68 -9
  244. package/dist/rest/layer.d.mts +2 -2
  245. package/dist/rest/layer.mjs +7 -13
  246. package/dist/rest/me.d.mts +3 -428
  247. package/dist/rest/paths.mjs +1 -0
  248. package/dist/rest/work.mjs +8 -0
  249. package/dist/server/check-fetch.mjs +3 -3
  250. package/dist/server/edge-node.d.mts +14 -15
  251. package/dist/server/edge-node.mjs +12 -12
  252. package/dist/server/edge.d.mts +21 -7
  253. package/dist/server/edge.mjs +32 -11
  254. package/dist/server/extension.mjs +1 -1
  255. package/dist/server/git-layer.d.mts +6 -11
  256. package/dist/server/git-layer.mjs +29 -23
  257. package/dist/server/git-namespace.d.mts +5 -4
  258. package/dist/server/git-namespace.mjs +3 -2
  259. package/dist/server/joined.d.mts +21 -40
  260. package/dist/server/joined.mjs +11 -62
  261. package/dist/server/lifecycle.mjs +65 -69
  262. package/dist/server/registry.mjs +28 -3
  263. package/dist/server/server.mjs +245 -465
  264. package/dist/signin/context.d.mts +1 -2
  265. package/dist/signin/layer.d.mts +1 -1
  266. package/dist/signin/layer.mjs +1 -1
  267. package/dist/storage/allotted.mjs +18 -3
  268. package/dist/storage/batch-upkeep.mjs +274 -0
  269. package/dist/{core/purge.d.mts → storage/batches.d.mts} +4 -4
  270. package/dist/storage/batches.mjs +344 -0
  271. package/dist/storage/budget.mjs +2 -2
  272. package/dist/storage/calls.d.mts +1 -2
  273. package/dist/storage/calls.mjs +144 -158
  274. package/dist/storage/chunks.d.mts +9 -0
  275. package/dist/storage/chunks.mjs +297 -0
  276. package/dist/storage/clean-up.mjs +85 -19
  277. package/dist/storage/counted-bucket.mjs +4 -4
  278. package/dist/storage/fetch.d.mts +1 -0
  279. package/dist/storage/fetch.mjs +298 -216
  280. package/dist/storage/file-limits.mjs +24 -0
  281. package/dist/storage/host-bucket.mjs +1 -2
  282. package/dist/storage/id-mix.mjs +19 -5
  283. package/dist/storage/index-bitmaps.mjs +9 -2
  284. package/dist/storage/index-build.d.mts +1 -1
  285. package/dist/storage/index-build.mjs +185 -84
  286. package/dist/storage/index-fetch.mjs +128 -74
  287. package/dist/storage/index-files.d.mts +3 -0
  288. package/dist/storage/index-files.mjs +10 -5
  289. package/dist/storage/index-graph.mjs +72 -22
  290. package/dist/storage/index-reach.mjs +33 -5
  291. package/dist/storage/index-remap.mjs +208 -65
  292. package/dist/storage/index-shallow.mjs +5 -3
  293. package/dist/storage/index-whole.mjs +127 -0
  294. package/dist/storage/largest-files.mjs +48 -0
  295. package/dist/storage/layout.mjs +23 -0
  296. package/dist/storage/lfs-pointers.mjs +10 -1
  297. package/dist/storage/loose.d.mts +7 -4
  298. package/dist/storage/loose.mjs +214 -67
  299. package/dist/storage/memory-budget.mjs +44 -8
  300. package/dist/storage/merge-plan.mjs +3 -2
  301. package/dist/storage/merge-row.mjs +7 -1
  302. package/dist/storage/merge-stream.mjs +164 -25
  303. package/dist/storage/merge-walk.mjs +8 -4
  304. package/dist/storage/merge-write.mjs +1 -1
  305. package/dist/storage/merge.d.mts +1 -1
  306. package/dist/storage/merge.mjs +1 -1
  307. package/dist/storage/object-rows.d.mts +1 -0
  308. package/dist/storage/object-rows.mjs +385 -65
  309. package/dist/storage/oid-table.mjs +171 -0
  310. package/dist/storage/pack-order.mjs +8 -4
  311. package/dist/storage/pack-ranges.d.mts +1 -2
  312. package/dist/storage/pack-ranges.mjs +4 -5
  313. package/dist/storage/pack-reads.d.mts +2 -1
  314. package/dist/storage/pack-reads.mjs +165 -49
  315. package/dist/storage/pack-receive.d.mts +1 -1
  316. package/dist/storage/pack-receive.mjs +85 -27
  317. package/dist/storage/packs.d.mts +1 -1
  318. package/dist/storage/packs.mjs +172 -86
  319. package/dist/storage/placed-reads.mjs +1 -1
  320. package/dist/storage/plan-columns.d.mts +4 -0
  321. package/dist/storage/plan-columns.mjs +238 -0
  322. package/dist/storage/prune-keep.mjs +299 -37
  323. package/dist/storage/prune-walk.mjs +240 -62
  324. package/dist/storage/prune.mjs +749 -213
  325. package/dist/storage/push-allotment.mjs +91 -12
  326. package/dist/storage/push-uploads.mjs +40 -16
  327. package/dist/storage/pushed-commits.mjs +4 -2
  328. package/dist/storage/quarantine.d.mts +1 -1
  329. package/dist/storage/quarantine.mjs +9 -9
  330. package/dist/storage/range-cache.mjs +125 -8
  331. package/dist/storage/ready.d.mts +1 -1
  332. package/dist/storage/ready.mjs +55 -25
  333. package/dist/storage/receive-bounds.mjs +51 -15
  334. package/dist/storage/receive-state.mjs +8 -0
  335. package/dist/storage/receive-steps.mjs +71 -18
  336. package/dist/storage/repack-backlog.mjs +6 -3
  337. package/dist/storage/repack.d.mts +2 -2
  338. package/dist/storage/repack.mjs +1 -8
  339. package/dist/storage/rows.d.mts +1 -1
  340. package/dist/storage/rows.mjs +13 -2
  341. package/dist/storage/runs.mjs +195 -43
  342. package/dist/storage/send-list.d.mts +1 -0
  343. package/dist/storage/send-list.mjs +54 -10
  344. package/dist/storage/shallow.d.mts +1 -0
  345. package/dist/storage/shallow.mjs +26 -4
  346. package/dist/storage/single-flight.mjs +13 -7
  347. package/dist/storage/stream-whole.mjs +132 -28
  348. package/dist/storage/unpack.mjs +371 -79
  349. package/dist/storage/visible.mjs +31 -3
  350. package/dist/storage/walk.mjs +194 -39
  351. package/dist/storage/wants.mjs +5 -5
  352. package/dist/store/bodies.mjs +38 -0
  353. package/dist/store/call-count.d.mts +8 -12
  354. package/dist/store/call-count.mjs +34 -46
  355. package/dist/store/catalogue.d.mts +2 -2
  356. package/dist/store/catalogue.mjs +146 -35
  357. package/dist/store/crossing.mjs +1 -3
  358. package/dist/store/cursor-seal-namespace.d.mts +2 -0
  359. package/dist/store/cursor-seal-public.d.mts +5 -0
  360. package/dist/store/cursor-seal-public.mjs +5 -0
  361. package/dist/store/cursor-seal.d.mts +16 -3
  362. package/dist/store/cursor-seal.mjs +40 -18
  363. package/dist/store/door.mjs +183 -0
  364. package/dist/store/errors.d.mts +3 -4
  365. package/dist/store/errors.mjs +24 -34
  366. package/dist/store/git-store.mjs +25 -7
  367. package/dist/store/job-try.mjs +9 -32
  368. package/dist/store/list-job.mjs +44 -8
  369. package/dist/store/records.d.mts +5 -0
  370. package/dist/store/records.mjs +12 -6
  371. package/dist/store/repo-record.d.mts +10 -9
  372. package/dist/store/repo-record.mjs +123 -28
  373. package/dist/store/reservations.mjs +1 -1
  374. package/dist/store/scopes.mjs +21 -2
  375. package/dist/store/settle.mjs +4 -4
  376. package/dist/sync/bound.d.mts +2 -0
  377. package/dist/sync/bound.mjs +11 -2
  378. package/dist/sync/github.d.mts +6 -1
  379. package/dist/sync/github.mjs +56 -44
  380. package/dist/sync/http.mjs +36 -1
  381. package/dist/sync/import.mjs +32 -18
  382. package/dist/sync/layer.mjs +6 -2
  383. package/dist/sync/lfs-batch.mjs +118 -0
  384. package/dist/sync/lfs-copy.mjs +262 -0
  385. package/dist/sync/mirror.mjs +227 -151
  386. package/dist/sync/said.mjs +16 -37
  387. package/dist/sync/smart-http.mjs +4 -2
  388. package/dist/sync/step.mjs +58 -30
  389. package/dist/sync/tries.mjs +52 -21
  390. package/dist/sync.d.mts +2 -2
  391. package/dist/topics/advance.mjs +10 -11
  392. package/dist/topics/base.d.mts +15 -0
  393. package/dist/topics/base.mjs +8 -0
  394. package/dist/topics/host.mjs +2 -20
  395. package/dist/topics/layer.d.mts +4 -9
  396. package/dist/topics/layer.mjs +3 -4
  397. package/dist/topics/members.mjs +4 -4
  398. package/dist/topics/public.d.mts +2 -1
  399. package/dist/topics/topic.mjs +2 -2
  400. package/package.json +5 -9
  401. package/dist/auth/bridge.mjs +0 -30
  402. package/dist/auth/helpers.d.mts +0 -17
  403. package/dist/contracts/promises.d.mts +0 -39
  404. package/dist/core/call-names.d.mts +0 -3
  405. package/dist/core/clock.mjs +0 -18
  406. package/dist/core/registered-rows.d.mts +0 -5
  407. package/dist/core/repack.d.mts +0 -11
  408. package/dist/http/handler.d.mts +0 -2
  409. package/dist/lfs/calls.mjs +0 -26
  410. package/dist/rest/api.d.mts +0 -23
  411. package/dist/rest/blobs.d.mts +0 -825
  412. package/dist/rest/commits.d.mts +0 -3510
  413. package/dist/rest/errors.d.mts +0 -2104
  414. package/dist/rest/events.d.mts +0 -423
  415. package/dist/rest/files.d.mts +0 -1330
  416. package/dist/rest/forks.d.mts +0 -2136
  417. package/dist/rest/handler.d.mts +0 -21
  418. package/dist/rest/handlers.d.mts +0 -8
  419. package/dist/rest/merges.d.mts +0 -473
  420. package/dist/rest/queue.d.mts +0 -5861
  421. package/dist/rest/refs.d.mts +0 -2959
  422. package/dist/rest/repos.d.mts +0 -2539
  423. package/dist/rest/tags.d.mts +0 -1304
  424. package/dist/rest/tokens.d.mts +0 -2590
  425. package/dist/rest/topics.d.mts +0 -2204
  426. package/dist/rest/trees.d.mts +0 -1693
  427. package/dist/rest/work.d.mts +0 -1248
  428. package/dist/rest.d.mts +0 -2
  429. package/dist/rest.mjs +0 -1
  430. package/dist/server/lifecycle.d.mts +0 -2
  431. package/dist/server/registry.d.mts +0 -16
  432. package/dist/server/server.d.mts +0 -36
  433. package/dist/storage/repack-job.d.mts +0 -3
  434. package/dist/store/promises.d.mts +0 -11
  435. package/dist/store/promises.mjs +0 -327
  436. package/dist/topics/host.d.mts +0 -7
@@ -0,0 +1,183 @@
1
+ import { bodyUntilAborted } from "./bodies.mjs";
2
+ import { closedError, isServerClosed } from "./closed.mjs";
3
+ import { JobLanded } from "./job-try.mjs";
4
+ import { forkIn, noCall } from "./crossing.mjs";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Exit from "effect/Exit";
7
+ import { JobGate } from "@ref0/infra";
8
+ import * as Context from "effect/Context";
9
+ import * as Stream from "effect/Stream";
10
+ import * as Scope$1 from "effect/Scope";
11
+ import * as Scheduler from "effect/Scheduler";
12
+ // src/store/door.ts
13
+ /** The door of a service with no server to close, as a client's own store: it always runs. */
14
+ const openDoor = {
15
+ refusal: () => void 0,
16
+ closing: new AbortController().signal
17
+ };
18
+ /**
19
+ * `effect` through `door`, for a run outside the server's runtime, which `close()` doesn't stop:
20
+ * sync's door, over a seam's, and the server's own, over its closing. It asks first, then
21
+ * races the closing, so a run still going as the server closes dies with the closed error whatever
22
+ * it would have answered, its writes included: each store commit lands whole or not at all. No ask
23
+ * after: the race already listens before the run can end, so a close before its answer always
24
+ * wins. Only a closed refusal counts at the ask, so a failed build answers its own `UNAVAILABLE`,
25
+ * as the run reads it.
26
+ */
27
+ const throughBridge = (door) => (effect) => Effect.andThen(askClosed(door), Effect.raceFirst(closesOf(door), effect));
28
+ /** `door`'s refusal at the ask, as a defect: only a closed one, as `throughBridge` says. */
29
+ const askClosed = (door) => Effect.suspend(() => {
30
+ const refused = door.refusal();
31
+ return refused !== void 0 && isServerClosed(refused) ? Effect.die(refused) : Effect.void;
32
+ });
33
+ /**
34
+ * `door`'s refusal at the ask, any of them, as a defect: a failed build's too. A host's bucket can't
35
+ * read the server's build, as a run in it does, so a call a package holds from `bind` refuses here.
36
+ */
37
+ const askRefused = (door) => Effect.suspend(() => {
38
+ const refused = door.refusal();
39
+ return refused === void 0 ? Effect.void : Effect.die(refused);
40
+ });
41
+ /** Dies with the closed error as `door` closes. Its listener goes with the run that waits on it. */
42
+ const closesOf = (door) => Effect.callback((resume) => {
43
+ const onAbort = () => resume(Effect.die(closedError()));
44
+ if (door.closing.aborted) return onAbort();
45
+ door.closing.addEventListener("abort", onAbort, { once: true });
46
+ return Effect.sync(() => door.closing.removeEventListener("abort", onAbort));
47
+ });
48
+ /**
49
+ * `stream`, released as `door` closes, even while its reader holds it unread. A pull in flight dies
50
+ * with the closed error, as `closesOf` says. With none in flight, the close ends the stream's own
51
+ * scope at once, so what it holds goes with it, and its next pull dies with the closed error: a
52
+ * web stream's reader outside Effect, as a response's body has, holds it so. Its listener goes
53
+ * with the stream.
54
+ */
55
+ const releasedOnClose = (stream, door) => Stream.unwrap(Effect.gen(function* () {
56
+ const own = Scope$1.makeUnsafe();
57
+ const state = { pulling: false };
58
+ const onClose = () => {
59
+ if (state.pulling) return;
60
+ forkIn(Scope$1.close(own, Exit.die(closedError())), noCall);
61
+ };
62
+ door.closing.addEventListener("abort", onClose, { once: true });
63
+ const stop = Effect.sync(() => door.closing.removeEventListener("abort", onClose));
64
+ yield* Effect.addFinalizer((exit) => Effect.andThen(stop, Scope$1.close(own, exit)));
65
+ const pull = yield* Scope$1.provide(Stream.toPull(stream), own);
66
+ const pulled = Effect.suspend(() => {
67
+ state.pulling = true;
68
+ return Effect.raceFirst(closesOf(door), pull);
69
+ }).pipe(Effect.ensuring(Effect.sync(() => state.pulling = false)));
70
+ return Stream.fromPull(Effect.succeed(pulled));
71
+ }));
72
+ /** Records called by features in their own fibers, retaining the try's fence through the server door. */
73
+ const doorRecords = (records, context, door) => {
74
+ const { over, call } = doorOf(context, door);
75
+ const markLanded = () => Effect.map(Effect.service(JobLanded), (saved) => {
76
+ if (saved !== void 0) saved.landed = true;
77
+ });
78
+ const run = (effect) => call(Effect.suspend(effect));
79
+ const landed = (effect) => Effect.tap(run(effect), markLanded);
80
+ return {
81
+ read: (scope, reads, counts) => run(() => records.read(scope, reads, counts)),
82
+ commit: (scope, change) => Effect.tap(run(() => records.commit(scope, change)), (committed) => committed.ok ? markLanded() : Effect.void),
83
+ add: (scope, addition) => landed(() => records.add(scope, addition)),
84
+ drop: (scope) => run(() => records.drop(scope)),
85
+ watch: (scope, watch) => Stream.unwrap(Effect.as(askRefused(door), releasedOnClose(Stream.suspend(() => records.watch(scope, watch)).pipe(Stream.updateContext(over)), door))),
86
+ jobs: {
87
+ claim: (scope, request) => run(() => records.jobs.claim(scope, request)),
88
+ settle: (claim, outcome) => run(() => records.jobs.settle(claim, outcome)),
89
+ progress: (scope, write) => run(() => records.jobs.progress(scope, write)),
90
+ count: (scope) => run(() => records.jobs.count(scope)),
91
+ list: (scope, request) => run(() => records.jobs.list(scope, request)),
92
+ retry: (scope, job, input) => landed(() => records.jobs.retry(scope, job, input)),
93
+ discard: (scope, job) => landed(() => records.jobs.discard(scope, job))
94
+ }
95
+ };
96
+ };
97
+ /**
98
+ * `bucket`, built on `context`, as Git's objects call it from their own fibers: each call reads the
99
+ * caller's context over the built one's services, so the bucket finds its host's and the call still
100
+ * counts into the caller's request, and goes through `door`, so a call or a read still going as the
101
+ * server closes dies with the closed error. Each asks the door's whole refusal first, as
102
+ * `askRefused` says. A put's body runs in the same context, so what it reads
103
+ * counts as the caller's. `context` keeps no `Scheduler`, as `ownScheduler` says.
104
+ */
105
+ const doorBucket = (bucket, context, door) => {
106
+ const { call } = doorOf(context, door);
107
+ return {
108
+ ...bucket,
109
+ put: (key, body, options) => call(bucket.put(key, body, options)),
110
+ read: (key, range) => Effect.suspend(() => {
111
+ let held;
112
+ const opened = Effect.uninterruptible(Effect.tap(bucket.read(key, range), (body) => Effect.sync(() => held = body)));
113
+ return Effect.interruptible(call(opened)).pipe(Effect.onExit((exit) => Exit.isSuccess(exit) ? Effect.void : Effect.sync(() => void held?.cancel().catch(() => void 0))), Effect.map((body) => untilClosed(body, door)), Effect.uninterruptible);
114
+ }),
115
+ remove: (key) => call(bucket.remove(key)),
116
+ removeMany: (keys, options) => call(bucket.removeMany(keys, options)),
117
+ list: (prefix, page) => call(bucket.list(prefix, page))
118
+ };
119
+ };
120
+ /** `body`, which errors with the close's error once `door` closes, as `bodyUntilAborted` says. */
121
+ const untilClosed = (body, door) => bodyUntilAborted(body, door.closing, closedError);
122
+ /** `links`, built on `context`, each call through `door` on the caller's context, as `doorBucket`'s. */
123
+ const doorLinks = (links, context, door) => {
124
+ const { call } = doorOf(context, door);
125
+ return {
126
+ url: (key, options) => call(links.url(key, options)),
127
+ putUrl: (key, options) => call(links.putUrl(key, options)),
128
+ head: (key) => call(links.head(key))
129
+ };
130
+ };
131
+ /** `uploads`, built on `context`, each call through `door` on the caller's context, as `doorBucket`'s. */
132
+ const doorUploads = (uploads, context, door) => {
133
+ const { call } = doorOf(context, door);
134
+ return {
135
+ maxParts: uploads.maxParts,
136
+ beginUpload: (key) => call(uploads.beginUpload(key)),
137
+ uploadUrl: (key, options) => call(uploads.uploadUrl(key, options)),
138
+ listParts: (key, upload) => call(uploads.listParts(key, upload)),
139
+ completeUpload: (key, input) => call(uploads.completeUpload(key, input)),
140
+ abortUpload: (key, upload) => call(uploads.abortUpload(key, upload))
141
+ };
142
+ };
143
+ /**
144
+ * How a door's service runs a call: on the caller's context over `context`'s services, through
145
+ * `door`, as `doorBucket` says.
146
+ */
147
+ const doorOf = (context, door) => {
148
+ const host = ownScheduler(context);
149
+ const through = throughBridge(door);
150
+ const over = (caller) => Context.merge(caller, host);
151
+ const call = (effect) => Effect.andThen(askRefused(door), through(Effect.updateContext(effect, over)));
152
+ return {
153
+ over,
154
+ call
155
+ };
156
+ };
157
+ /**
158
+ * `context` without its `Scheduler`, so each run keeps the one it started on. A runtime builds on
159
+ * the scheduler of the fiber that started it, so the built context holds an async one: a run at
160
+ * once on it hands its yields to that scheduler, and runSync's one flush leaves the yield after
161
+ * `provideContext` ends, which dies with `AsyncFiberError`.
162
+ */
163
+ const ownScheduler = (context) => Context.omit(Scheduler.Scheduler)(context);
164
+ /** How long a job's try a closed server holds off waits before the host's queue claims it again. */
165
+ const closedRetry = 6e4;
166
+ /**
167
+ * `queue`, built on `context`, each call through `door` on the caller's context: `addJobs` gates
168
+ * each definition on `door` via `JobGate.later` so a closed server holds off tries and spends no
169
+ * attempt.
170
+ */
171
+ const doorQueue = (queue, context, door, now) => {
172
+ const { call } = doorOf(context, door);
173
+ const gate = { later: () => door.refusal() === void 0 ? void 0 : now() + closedRetry };
174
+ return {
175
+ addJobs: (...definitions) => call(queue.addJobs(...definitions).pipe(Effect.provideService(JobGate, gate))),
176
+ run: (scope) => call(queue.run(scope)),
177
+ count: (scope) => call(queue.count(scope)),
178
+ list: (scope, request) => call(queue.list(scope, request)),
179
+ retry: (scope, job) => call(queue.retry(scope, job)),
180
+ discard: (scope, job) => call(queue.discard(scope, job))
181
+ };
182
+ };
183
+ export { doorBucket, doorLinks, doorQueue, doorRecords, doorUploads, openDoor, throughBridge };
@@ -1,7 +1,7 @@
1
1
  import { GitError } from "../contracts/result.mjs";
2
2
  import * as Effect from "effect/Effect";
3
3
  import "effect/Schema";
4
- import { Committed, Row } from "@ref0/infra";
4
+ import { Row } from "@ref0/infra";
5
5
  import "effect/Stream";
6
6
  /**
7
7
  * A store call, its refusal as Git's error: one of the two doors every call Git makes goes
@@ -10,10 +10,9 @@ import "effect/Stream";
10
10
  * either's bound (Q799): past one, it dies with `CallsSpent`, which an edge answers, as
11
11
  * `spentRefusalOf` does.
12
12
  */
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?: {
13
+ export declare const storeCall: <A, E, R>(run: Effect.Effect<A, E, R>, options?: {
15
14
  readonly resend?: boolean;
16
- }): Effect.Effect<A, GitError, R>;
15
+ }) => Effect.Effect<A, GitError, R>;
17
16
  /**
18
17
  * The most store calls one try at a write makes through `storeCall`: its read, the commit it
19
18
  * decides, and that commit sent again as often as a lost reply may send it. A caller that must
@@ -1,7 +1,7 @@
1
1
  import { fail, gitError, gitErrorFrom } from "../contracts/result.mjs";
2
2
  import { callLimitIn, callLimitTry, catchSpent, fromAnswer, spentAt, spentRefusal } from "../contracts/calls-spent.mjs";
3
3
  import { chargeCall, chargeResends, committedNow } from "./call-count.mjs";
4
- import { isServerClosed, tryClosing } from "./closed.mjs";
4
+ import { isServerClosed } from "./closed.mjs";
5
5
  import * as Effect from "effect/Effect";
6
6
  import * as Option from "effect/Option";
7
7
  import * as Schema from "effect/Schema";
@@ -9,11 +9,13 @@ import * as Cause from "effect/Cause";
9
9
  import * as Exit from "effect/Exit";
10
10
  import { isInfraError } from "@ref0/infra";
11
11
  import * as Predicate from "effect/Predicate";
12
- import * as Stream from "effect/Stream";
13
12
  import * as Data from "effect/Data";
13
+ import * as Stream from "effect/Stream";
14
14
  // src/store/errors.ts
15
15
  const savedHint = "Read it back before you try again";
16
16
  const savedContext = { reason: "may-have-saved" };
17
+ /** What a caller does with a write that landed past its `by`: it wrote nothing, so read again. */
18
+ const lateHint = "Try again";
17
19
  /**
18
20
  * `error`, met once a write of the call's own has landed: any `UNAVAILABLE` is `may-have-saved`,
19
21
  * since what another reason says about sending the same call again holds only for a call that
@@ -42,7 +44,9 @@ const afterWrites = (error) => {
42
44
  * infra's refusal kept as its cause, which `pastCallLimit` reads, and a hint any caller can follow:
43
45
  * a door fails with it as the defect `CallsSpent` instead, which an edge answers with this. A commit
44
46
  * that never got a reply, and the platform failing `after` the request's deciding commit, may have
45
- * saved the write, so a caller reads it back before it tries again (#1308).
47
+ * saved the write, so a caller reads it back before it tries again (#1308). A write that landed
48
+ * past its `by` is `UNAVAILABLE` too, having written nothing: the read it was held to is old, so a
49
+ * caller reads again (#2331).
46
50
  */
47
51
  const fromInfra = (cause, after = false) => {
48
52
  const failed = !isInfraError(cause) || Predicate.isTagged(cause, "Unavailable");
@@ -64,6 +68,10 @@ const fromInfra = (cause, after = false) => {
64
68
  hint: callLimitTry
65
69
  });
66
70
  if (cause.code === "INTERNAL") return gitError("INTERNAL", "The server can't reach its store", { cause });
71
+ if (cause.reason === "late") return gitError("UNAVAILABLE", cause.message, {
72
+ cause,
73
+ hint: lateHint
74
+ });
67
75
  return gitError(cause.code, cause.message, { cause });
68
76
  };
69
77
  /** The smaller fetch a client is told to try, when its fetch was too much for one response. */
@@ -103,19 +111,25 @@ const routeEdge = (effect, refused) => Effect.catch(answerSpent(effect), (error)
103
111
  * `spentRefusal`'s, and any other defect a defect still.
104
112
  */
105
113
  const answerSpent = (effect) => catchSpent(effect, (spent) => Effect.fail(spentRefusal(spent)));
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. */
114
+ /**
115
+ * A store call, its refusal as Git's error: one of the two doors every call Git makes goes
116
+ * through, with `bucketCall`, and every call a package built on Git makes, as `@ref0/github`'s
117
+ * records (Q826). It counts into the request and the `CallBudget` in scope, and never starts past
118
+ * either's bound (Q799): past one, it dies with `CallsSpent`, which an edge answers, as
119
+ * `spentRefusalOf` does.
120
+ */
121
+ const storeCall = (run, options) => effectStoreCall(run, options?.resend === true);
122
+ /** A store failure: preserve interruption, spent bounds and closed servers; map adapter throws via `fromInfra`. */
111
123
  const effectStoreFailure = (cause, after) => {
112
124
  if (Cause.hasInterrupts(cause)) return Effect.failCause(Cause.map(cause, (error) => fromInfra(error, after)));
113
125
  const error = Cause.squash(cause);
114
126
  const spent = spentAt(error);
115
127
  if (spent !== void 0) return Effect.die(spent);
116
- if (isServerClosed(error) || codeErrors.some((code) => error instanceof code)) return Effect.die(error);
128
+ if (isServerClosed(error)) return Effect.die(error);
117
129
  return Effect.fail(fromInfra(error, after));
118
130
  };
131
+ /** A commit through `storeCall`, resending under its own ID when its reply is lost. */
132
+ const storeCommit = (run) => storeCall(run, { resend: true });
119
133
  /** A watch, charged once at subscription, with the same failure classification as a store call. */
120
134
  const storeWatch = (run) => Stream.unwrap(storeCall(Effect.map(committedNow, (after) => run().pipe(Stream.catchCause((cause) => Stream.fromEffect(effectStoreFailure(cause, after)))))));
121
135
  /** An Effect store call, with a commit's resends under the same ID when requested. */
@@ -159,35 +173,11 @@ const codeErrors = [
159
173
  * guess costs one resend under the same ID, which the store's receipt answers as the first.
160
174
  */
161
175
  const isLostReply = (cause) => Predicate.isTagged(cause, "Unavailable") || !isInfraError(cause) && !codeErrors.some((code) => cause instanceof code);
162
- /** Each answer a commit's resend gave, with the resends it took, which `storeCall` charges. */
163
- const resent = /* @__PURE__ */ new WeakMap();
164
176
  /**
165
177
  * Whether a resend's `cause` is the store's own answer, made past its receipt: an infra refusal
166
178
  * other than `Unavailable` or the platform's cap, which refuses a call before it reaches the store.
167
179
  */
168
180
  const isAnswered = (cause) => isInfraError(cause) && !Predicate.isTagged(cause, "Unavailable") && !pastCallLimit(cause);
169
- /**
170
- * `send`, a commit where infra calls the adapter, sent again under its own ID while the platform
171
- * fails, up to `commitResendsMost` times: the store's receipt answers as the first send ended, so a
172
- * commit that landed is never made twice. A defect of code, or a closed server, is never resent.
173
- * Once a reply is lost, a resend ends as the store answered it or `Unsettled`, whose cause is that
174
- * first loss alone, so no later refusal, the platform's cap among them, answers a write that may
175
- * have landed as one that didn't.
176
- */
177
- const resending = async (send) => {
178
- let lost;
179
- for (let resends = 0;; resends += 1) try {
180
- const committed = await send();
181
- if (resends === 0) return committed;
182
- const again = { ...committed };
183
- resent.set(again, resends);
184
- return again;
185
- } catch (cause) {
186
- if (isServerClosed(cause) || (resends === 0 ? !isLostReply(cause) : isAnswered(cause))) throw cause;
187
- lost ??= cause;
188
- if (resends === 1 || !isLostReply(cause)) throw new Unsettled("No reply came to a commit", { cause: lost });
189
- }
190
- };
191
181
  /** A stored row whose value should match `schema`; one that doesn't is `DATA_LOSS`. */
192
182
  const decodeRow = (schema, row, what) => {
193
183
  const decoded = Schema.decodeUnknownOption(schema)(row.value);
@@ -254,4 +244,4 @@ const endedEarly = (cause) => {
254
244
  cause
255
245
  });
256
246
  };
257
- export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, commitCallsMost, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody, resending, resultCall, routeEdge, storeCall, storeWatch, thrownError };
247
+ export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, commitCallsMost, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody, resultCall, routeEdge, storeCall, storeCommit, storeWatch, thrownError };
@@ -1,11 +1,14 @@
1
1
  import { isInternalId } from "../contracts/ids.mjs";
2
2
  import { fail } from "../contracts/result.mjs";
3
3
  import { resolveRepo } from "./catalogue.mjs";
4
- import { decodeRow, storeCall } from "./errors.mjs";
4
+ import { decodeRow, storeCall, storeCommit } from "./errors.mjs";
5
+ import { JobLanded } from "./job-try.mjs";
5
6
  import { outboxCollections } from "./outbox.mjs";
6
7
  import { PackRow } from "./records.mjs";
7
8
  import { collections, prunedKey, pushedKey, selfKey } from "./scopes.mjs";
8
9
  import * as Effect from "effect/Effect";
10
+ import { Records } from "@ref0/infra";
11
+ import * as Context from "effect/Context";
9
12
  // src/store/git-store.ts
10
13
  const packsRead = { collection: collections.packs };
11
14
  /** A repo's listed packs, from its `packs` rows. */
@@ -65,21 +68,21 @@ const featureChange = (scope, change) => {
65
68
  return Effect.void;
66
69
  };
67
70
  /**
68
- * Git's records over infra's `RecordStore`, under Git's commit rules: only Git's scopes, a repo's
71
+ * Git's records over infra's `Records`, under Git's commit rules: only Git's scopes, a repo's
69
72
  * by its internal ID, and never the catalogue, a repo's own record or its outbox, which only the core
70
73
  * writes.
71
- * Made over a job's `context.store`, every commit is fenced by that try's claim.
74
+ * Inside a job try, every commit is fenced by the fiber's `Records.Fence`.
72
75
  */
73
76
  const gitStore = (store) => ({
74
77
  read: ({ scope, reads }) => {
75
78
  const problem = scopeProblem(scope);
76
- return problem === void 0 ? storeCall(() => store.read(scope, reads)) : fail("INVALID_ARGUMENT", problem);
79
+ return problem === void 0 ? storeCall(store.read(scope, reads)) : fail("INVALID_ARGUMENT", problem);
77
80
  },
78
- commit: ({ scope, change }) => Effect.andThen(featureChange(scope, change), storeCall(() => store.commit(scope, change))),
81
+ commit: ({ scope, change }) => Effect.andThen(featureChange(scope, change), storeCommit(store.commit(scope, change))),
79
82
  add: ({ scope, addition }) => {
80
83
  if (!scope.startsWith("git/repo/") || scopeProblem(scope) !== void 0) return fail("INVALID_ARGUMENT", "Only a repo's scope, by its internal ID, takes an addition");
81
84
  if (touchesOwn(scope, addition.put ?? [])) return ownRefusal();
82
- return storeCall(() => store.add(scope, addition));
85
+ return storeCall(store.add(scope, addition));
83
86
  },
84
87
  listed: Effect.fnUntraced(function* ({ repo }) {
85
88
  const { internalId, snapshot } = yield* resolveRepo(store, repo, [packsRead]);
@@ -91,4 +94,19 @@ const gitStore = (store) => ({
91
94
  };
92
95
  })
93
96
  });
94
- export { decodePacks, featureChange, gitStore, packRow };
97
+ /**
98
+ * `gitStore(store)` bound to the caller fiber's `Records.Fence` and `JobLanded`, so writes through
99
+ * a Promise `GitObjects` boundary (`receiveStep`, `maintain`) stay fenced and mark landed writes.
100
+ */
101
+ const tryGitStore = (store) => Effect.map(Effect.context(), (context) => {
102
+ const fence = Context.get(context, Records.Fence);
103
+ const landed = Context.get(context, JobLanded);
104
+ const base = gitStore(store);
105
+ const bind = (effect) => effect.pipe(Effect.provideService(Records.Fence, fence), Effect.provideService(JobLanded, landed));
106
+ return {
107
+ ...base,
108
+ commit: (input) => bind(base.commit(input)),
109
+ add: (input) => bind(base.add(input))
110
+ };
111
+ });
112
+ export { decodePacks, featureChange, gitStore, packRow, tryGitStore };
@@ -5,6 +5,7 @@ import { noCall, syncIn } from "./crossing.mjs";
5
5
  import { jobRepo } from "./scopes.mjs";
6
6
  import * as Effect from "effect/Effect";
7
7
  import { CurrentJob } from "@ref0/infra";
8
+ import * as Context from "effect/Context";
8
9
  // src/store/job-try.ts
9
10
  /** A try's `JobLimits` under the adapter's `limits`, checked as a request's are. */
10
11
  const jobLimitsOf = (limits) => lessBefore(checkedLimits(limits, "The adapter's callLimits."), jobCallsAround);
@@ -52,40 +53,18 @@ const stepYielded = (job, spent) => {
52
53
  return stepSpent("job-step-yielded", `${job}'s ${step} step spent a try's ${callsOf(spent)} after a write landed: the next try goes on from it`, job, step, spent);
53
54
  };
54
55
  /**
55
- * `store`, marking `saved` once a write through it lands: a commit that took, an add, a job's
56
- * discard or retry. A try's store is a plain object of calls, the claim's fence, so its spread
57
- * keeps them all.
56
+ * Mutable landing marker for the job try in scope: set by `doorRecords` once a write through the
57
+ * try lands, so spending the try's call budget after a landed write fails `job-step-yielded`
58
+ * instead of `job-step-calls`.
58
59
  */
59
- const marking = (store, saved) => ({
60
- ...store,
61
- commit: async (scope, change) => {
62
- const committed = await store.commit(scope, change);
63
- if (committed.ok) saved.landed = true;
64
- return committed;
65
- },
66
- add: async (scope, addition) => {
67
- await store.add(scope, addition);
68
- saved.landed = true;
69
- },
70
- discard: async (scope, job) => {
71
- await store.discard(scope, job);
72
- saved.landed = true;
73
- },
74
- retry: async (scope, job, input) => {
75
- await store.retry(scope, job, input);
76
- saved.landed = true;
77
- }
78
- });
60
+ const JobLanded = Context.Reference("@ref0/git/JobLanded", { defaultValue: () => void 0 });
79
61
  /**
80
- * `run` in a fresh budget of `limits`, named `'job'`, nested in nothing, with the try's store
81
- * marking what lands: so a request's budget and a job's never count each other's calls (#2015).
62
+ * `run` in a fresh budget of `limits`, named `'job'`, nested in nothing, with `JobLanded` marking
63
+ * what lands: so a request's budget and a job's never count each other's calls (#2015).
82
64
  */
83
65
  const inJobBudget = (limits, run, spent) => Effect.flatMap(inCallScope(CallBudget.make(limits, { name: "job" }), noScope), (budget) => {
84
66
  const saved = { landed: false };
85
- const marked = run(saved).pipe(Effect.updateService(CurrentJob.CurrentJob, (job) => ({
86
- ...job,
87
- store: marking(job.store, saved)
88
- })));
67
+ const marked = Effect.provideService(run(saved), JobLanded, saved);
89
68
  const owns = (each) => nestsIn(spentBudget(each), budget);
90
69
  return Effect.catchCause(inCallScope(marked, {
91
70
  calls: void 0,
@@ -127,6 +106,4 @@ const jobParts = (job, handler, options) => (take) => take(job, handler, options
127
106
  const jobsWithin = (limits, jobs) => jobs.map((job) => remakes.get(job)?.(limits) ?? job);
128
107
  /** The repo whose scope the try runs in: in any other scope, it's a defect, as `jobRepo` says. */
129
108
  const currentRepo = Effect.map(CurrentJob.current, jobRepo);
130
- /** `step` over the try's store, fenced by its claim and gated by the server's door, and its repo. */
131
- const repoTry = (step) => Effect.flatMap(Effect.all([CurrentJob.store, currentRepo]), ([store, repo]) => step(store, repo));
132
- export { currentRepo, gitJob, jobLimitsOf, jobParts, jobsWithin, repoTry, stepTooLarge };
109
+ export { JobLanded, currentRepo, gitJob, jobLimitsOf, jobParts, jobsWithin, stepTooLarge };
@@ -1,5 +1,5 @@
1
1
  import { reconcile } from "./catalogue.mjs";
2
- import { gitJob, repoTry } from "./job-try.mjs";
2
+ import { currentRepo, gitJob } from "./job-try.mjs";
3
3
  import * as Effect from "effect/Effect";
4
4
  import * as Schema from "effect/Schema";
5
5
  import { Job, defineJob } from "@ref0/infra";
@@ -8,12 +8,7 @@ const ListData = /* @__PURE__ */ Schema.Struct({});
8
8
  const listJobName = "git.list";
9
9
  /** The `git.list` job's one key in each repo's scope. */
10
10
  const listJobKey = "list";
11
- /**
12
- * `git.list`: projects a repo's record into `git/repos`, where its own write didn't get that far,
13
- * writing an entry only when its revision is newer. Every repo write saves it in the same commit.
14
- * Its try stops at its timeout, which interrupts it.
15
- */
16
- const listJob = /* @__PURE__ */ gitJob(/* @__PURE__ */ Job.make(listJobName, {
11
+ const ListJob = /* @__PURE__ */ Job.make(listJobName, {
17
12
  payload: ListData,
18
13
  retry: {
19
14
  limit: 10,
@@ -21,7 +16,48 @@ const listJob = /* @__PURE__ */ gitJob(/* @__PURE__ */ Job.make(listJobName, {
21
16
  backoff: "exponential",
22
17
  maxDelay: "5 minutes"
23
18
  }
24
- }), () => Effect.asVoid(repoTry(reconcile)));
19
+ });
20
+ const emptySchema = /* @__PURE__ */ Schema.toStandardSchemaV1(ListData);
21
+ /** `git.repack`'s rows, by `defineJob`, for a lost create `git.list` puts aside without importing `storage/`. */
22
+ const repackRows = /* @__PURE__ */ defineJob({
23
+ name: "git.repack",
24
+ schema: emptySchema,
25
+ handler: () => {
26
+ throw new TypeError("'git.repack' runs under repackJob");
27
+ }
28
+ });
29
+ /** `git.purge`'s row, by `defineJob`, for a lost create `git.list` puts aside without importing `core/`. */
30
+ const purgeRows = /* @__PURE__ */ defineJob({
31
+ name: "git.purge",
32
+ schema: emptySchema,
33
+ handler: () => {
34
+ throw new TypeError("'git.purge' runs under purgeJob");
35
+ }
36
+ });
37
+ /** Cleanup and purge jobs queued when `git.list` puts aside a create that crashed before standing aside (#1911). */
38
+ const lostCreateJobs = (record) => [
39
+ repackRows.job({
40
+ key: "repack",
41
+ data: {},
42
+ at: record.changedAt
43
+ }),
44
+ ...record.fork === void 0 ? [] : [repackRows.job({
45
+ key: "prune",
46
+ data: {},
47
+ at: record.changedAt
48
+ })],
49
+ purgeRows.job({
50
+ key: "purge",
51
+ data: {},
52
+ at: record.changedAt
53
+ })
54
+ ];
55
+ /**
56
+ * `git.list`: projects a repo's record into `git/repos`, where its own write didn't get that far,
57
+ * writing an entry only when its revision is newer. Every repo write saves it in the same commit.
58
+ * Its try stops at its timeout, which interrupts it.
59
+ */
60
+ const listJob = (store) => gitJob(ListJob, () => Effect.asVoid(Effect.flatMap(currentRepo, (internalId) => reconcile(store, internalId, lostCreateJobs))));
25
61
  /**
26
62
  * `git.list`'s rows, by `defineJob`, as `ListJob.encodedJob` makes them: a write saves one beside
27
63
  * its record without `Job.make`'s runtime, which only the server that runs `listJob` needs.
@@ -37,6 +37,9 @@ export type CatalogueEntry = typeof CatalogueEntry.Type;
37
37
  * what it was made from. `refIndex` is the stamp of the patterns its `refIndex` rows were written
38
38
  * under, as `core/ref-index.ts` says: a repo made on a server that keeps an index takes its stamp.
39
39
  * `refIndexBuilding` is the rebuild mark, `git.ref-index`'s, while it builds another stamp's rows.
40
+ * `renamedSeq` is the `seq` of the `repo.renamed` that gave the repo its name, when events are kept.
41
+ * `staged` marks a fork's create, deleted, that marked packs or staged rows before its record: no
42
+ * name's entry has heard of it, so its purge projects nothing.
40
43
  */
41
44
  export declare const StoredRepo: Schema.Struct<{
42
45
  readonly name: Schema.String;
@@ -50,12 +53,14 @@ export declare const StoredRepo: Schema.Struct<{
50
53
  readonly createdAt: Schema.Int;
51
54
  readonly changedAt: Schema.Int;
52
55
  readonly deleted: Schema.optionalKey<Schema.Literal<true>>;
56
+ readonly staged: Schema.optionalKey<Schema.Literal<true>>;
53
57
  readonly renamedFrom: Schema.optionalKey<Schema.Struct<{
54
58
  readonly name: Schema.String;
55
59
  readonly revision: Schema.Int;
56
60
  readonly nextSeq: Schema.optionalKey<Schema.Int>;
57
61
  readonly receipt: Schema.optionalKey<Schema.String>;
58
62
  }>>;
63
+ readonly renamedSeq: Schema.optionalKey<Schema.Int>;
59
64
  readonly nextSeq: Schema.optionalKey<Schema.Int>;
60
65
  readonly refIndex: Schema.optionalKey<Schema.String>;
61
66
  readonly refIndexBuilding: Schema.optionalKey<Schema.Struct<{
@@ -58,6 +58,7 @@ const KeptRepoInfo = /* @__PURE__ */ Schema.Struct({
58
58
  defaultBranch: Schema.optionalKey(Schema.String),
59
59
  public: Schema.Boolean,
60
60
  upstream: Schema.optionalKey(Schema.String),
61
+ shallow: Schema.Boolean,
61
62
  stats: Schema.Struct({
62
63
  repo: Schema.String,
63
64
  refs: Schema.Int,
@@ -151,6 +152,9 @@ const ForkRow = /* @__PURE__ */ Schema.Struct({ internalId: InternalRepoId });
151
152
  * what it was made from. `refIndex` is the stamp of the patterns its `refIndex` rows were written
152
153
  * under, as `core/ref-index.ts` says: a repo made on a server that keeps an index takes its stamp.
153
154
  * `refIndexBuilding` is the rebuild mark, `git.ref-index`'s, while it builds another stamp's rows.
155
+ * `renamedSeq` is the `seq` of the `repo.renamed` that gave the repo its name, when events are kept.
156
+ * `staged` marks a fork's create, deleted, that marked packs or staged rows before its record: no
157
+ * name's entry has heard of it, so its purge projects nothing.
154
158
  */
155
159
  const StoredRepo = /* @__PURE__ */ Schema.Struct({
156
160
  name: Schema.String,
@@ -161,23 +165,25 @@ const StoredRepo = /* @__PURE__ */ Schema.Struct({
161
165
  createdAt: Schema.Int,
162
166
  changedAt: Schema.Int,
163
167
  deleted: Schema.optionalKey(Schema.Literal(true)),
168
+ staged: Schema.optionalKey(Schema.Literal(true)),
164
169
  renamedFrom: Schema.optionalKey(RenamedFrom),
170
+ renamedSeq: Schema.optionalKey(Schema.Int),
165
171
  nextSeq: Schema.optionalKey(NextSeq),
166
172
  refIndex: Schema.optionalKey(Schema.String),
167
173
  refIndexBuilding: Schema.optionalKey(RefIndexBuilding)
168
174
  });
169
175
  /**
170
- * The most roots a repo keeps in its `repo/roots` row, 10,000: an import's last segment's boundary
171
- * is what becomes the repo's roots when it lands, the row's only writer, so `receiveBoundaryMost`
172
- * is this bound too. At 43 B an ID as JSON, its quotes and comma with it, the row is at most 430 KB.
176
+ * The most roots a repo keeps in its `repo/roots` row, 10,000, as `rootsMoved`, the row's one
177
+ * writer, holds them for a client's fetch and an import alike: an import's last segment's boundary
178
+ * becomes the repo's roots when it lands, so `receiveBoundaryMost` is this bound too. At 43 B an ID as JSON, its quotes and comma with it, the row is at most 430 KB.
173
179
  */
174
180
  const repoRootsMost = 1e4;
175
181
  /** A root's ID as the row keeps it: 40 lowercase hex digits. */
176
182
  const RootId = Oid.check(Schema.isPattern(/^[0-9a-f]{40}$/));
177
183
  /**
178
184
  * A repo's roots, `repo/roots` in its scope: the commits it holds without their parents, as Git's
179
- * `shallow` file names them, at most `repoRootsMost`, which their only writer, an import's landing,
180
- * holds them to. Every walk sees a root as having no parents (`RepoRoots`). A row of any other ID,
185
+ * `shallow` file names them, at most `repoRootsMost`, which their one writer, `rootsMoved`, holds
186
+ * them to. Every walk sees a root as having no parents (`RepoRoots`). A row of any other ID,
181
187
  * or past the bound, doesn't decode, so its read is `DATA_LOSS`.
182
188
  */
183
189
  const RepoRootsRow = /* @__PURE__ */ Schema.Struct({ roots: Schema.Array(RootId).check(Schema.isMaxLength(repoRootsMost)) });
@@ -245,7 +251,7 @@ const ReachedMark = /* @__PURE__ */ Schema.Struct({
245
251
  });
246
252
  /** Whether a mark's row holds both halves: there, and no proof under way. */
247
253
  const markHolds = (mark) => mark !== void 0 && mark.pending === void 0;
248
- /** The job a push saves for each ref an active mirror names, keyed by the ref. */
254
+ /** The job a push saves for each destination an active mirror of a ref it moves names. */
249
255
  const mirrorJobName = "sync.mirror";
250
256
  /** The job a repo's import runs as: one a repo, in its scope. */
251
257
  const importJobName = "sync.import";
@@ -1,4 +1,3 @@
1
- import "../contracts/promises.mjs";
2
1
  import "../contracts/access.mjs";
3
2
  import { EffectiveLimits } from "../contracts/objects.mjs";
4
3
  import "../contracts/ids.mjs";
@@ -9,17 +8,19 @@ import "../contracts/result.mjs";
9
8
  import "./records.mjs";
10
9
  import * as Effect from "effect/Effect";
11
10
  import "effect/Schema";
12
- import { Addition, Count, JobInput, Key, Moment, Read, Row, Scope, Snapshot } from "@ref0/infra";
11
+ import { Addition, JobInput, Key, Moment, Read, Records, Row, Scope, Snapshot } from "@ref0/infra";
13
12
  import "effect/Context";
14
13
  import "effect/Types";
15
14
  /**
16
- * When a write to a repo's scope must begin its store call by, after a read at `heldAt` found the
17
- * repo's record live: `heldAt` plus `fetchLimits.milliseconds`, less `jobLeaseMargin`. The repo
18
- * was live at that read, so its delete came later, and its purge drops its scopes no sooner than
19
- * `fetchLimits` past the delete, the record's `changedAt`: a call begun by then lands before the
20
- * drop, with the lease margin for the call itself, as `git.repack`'s `remapLate` keeps it (#1911).
21
- * It assumes the store call ends inside that margin: no store call is bounded below it yet (#2331).
15
+ * When a write to a repo's scope must land by, after a read at `heldAt` found the repo's record
16
+ * live: `heldAt` plus `fetchLimits.milliseconds`, less `jobLeaseMargin`. The repo was live at that
17
+ * read, so its delete committed later, and its purge drops its scopes no sooner than `fetchLimits`
18
+ * past the delete's stamp, the record's `changedAt`, which the delete commits within
19
+ * `deleteCommitWithin` of (#1911). The write sends it as its `by`, which the store checks on its
20
+ * own clock as the write lands, so one that stalls in the store lands nothing past it, however
21
+ * long the stall (#2331). The margin covers the delete's commit and the store's clock, as
22
+ * `deleteCommitWithin` splits it, and `HeldWrite.tla` checks that no held write lands after the drop.
22
23
  */
23
24
  export declare const heldUntil: (heldAt: Moment, fetchLimits: EffectiveLimits) => Moment;
24
- /** Whether a write may still begin its store call, by `heldUntil`'s `by`, at the clock's now. */
25
+ /** Whether a write may still send its store call, by `heldUntil`'s `by`, at the clock's now. */
25
26
  export declare const inTime: (by: Moment) => Effect.Effect<boolean>;