@ref0/git 0.3.0 → 0.6.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 (631) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +12 -0
  2. package/dist/access/private-refs.d.mts +12 -9
  3. package/dist/access/private-refs.mjs +70 -48
  4. package/dist/auth/access-jwt.mjs +7 -7
  5. package/dist/auth/auth.d.mts +41 -0
  6. package/dist/auth/auth.mjs +39 -0
  7. package/dist/auth/authorize.mjs +65 -83
  8. package/dist/auth/bridge.mjs +30 -0
  9. package/dist/auth/fences.d.mts +22 -2
  10. package/dist/auth/fences.mjs +3 -3
  11. package/dist/auth/grants.d.mts +25 -0
  12. package/dist/auth/grants.mjs +29 -34
  13. package/dist/auth/helpers.mjs +4 -4
  14. package/dist/auth/host-function.d.mts +9 -2
  15. package/dist/auth/host-function.mjs +35 -8
  16. package/dist/auth/identify.d.mts +7 -2
  17. package/dist/auth/identify.mjs +9 -11
  18. package/dist/auth/namespaces.d.mts +3 -0
  19. package/dist/auth/policy.d.mts +57 -0
  20. package/dist/auth/policy.mjs +56 -0
  21. package/dist/auth/token-rows.mjs +6 -6
  22. package/dist/auth/token-text.mjs +16 -4
  23. package/dist/auth/tokens.d.mts +3 -0
  24. package/dist/auth/tokens.mjs +63 -24
  25. package/dist/auth.d.mts +2 -1
  26. package/dist/auth.mjs +2 -1
  27. package/dist/client/answer.mjs +49 -11
  28. package/dist/client/client.d.mts +2 -2
  29. package/dist/client/client.mjs +3 -3
  30. package/dist/client/git-http.d.mts +6 -0
  31. package/dist/client/git-http.mjs +23 -36
  32. package/dist/client/helper-node.d.mts +12 -0
  33. package/dist/client/helper-node.mjs +108 -5
  34. package/dist/client/local.mjs +96 -99
  35. package/dist/client/negotiate.mjs +10 -8
  36. package/dist/client/push-upload.d.mts +14 -0
  37. package/dist/client/push-upload.mjs +12 -12
  38. package/dist/client/remote-helper.mjs +22 -20
  39. package/dist/client/remote.mjs +28 -22
  40. package/dist/client/run-remote-helper.d.mts +40 -16
  41. package/dist/client/run-remote-helper.mjs +147 -154
  42. package/dist/client/scrub.d.mts +8 -2
  43. package/dist/client/scrub.mjs +76 -4
  44. package/dist/client/slice-push.d.mts +77 -0
  45. package/dist/client/slice-push.mjs +169 -0
  46. package/dist/client/slice-report.mjs +188 -0
  47. package/dist/client/slices.d.mts +44 -0
  48. package/dist/client/slices.mjs +131 -0
  49. package/dist/client/transport.d.mts +1 -0
  50. package/dist/client/transport.mjs +30 -26
  51. package/dist/contracts/access.d.mts +41 -10
  52. package/dist/contracts/actors.d.mts +28 -10
  53. package/dist/contracts/actors.mjs +17 -0
  54. package/dist/contracts/authorize.d.mts +81 -0
  55. package/dist/contracts/authorize.mjs +25 -0
  56. package/dist/contracts/blobs.d.mts +48 -15
  57. package/dist/contracts/blobs.mjs +30 -0
  58. package/dist/contracts/calls-spent.d.mts +1 -0
  59. package/dist/contracts/calls-spent.mjs +58 -18
  60. package/dist/contracts/client.d.mts +14 -16
  61. package/dist/contracts/commits.d.mts +558 -76
  62. package/dist/contracts/commits.mjs +147 -0
  63. package/dist/contracts/engine.d.mts +91 -55
  64. package/dist/contracts/engine.mjs +103 -0
  65. package/dist/contracts/events.d.mts +1410 -206
  66. package/dist/contracts/events.mjs +496 -0
  67. package/dist/contracts/files.d.mts +295 -50
  68. package/dist/contracts/files.mjs +100 -0
  69. package/dist/contracts/forks.d.mts +306 -25
  70. package/dist/contracts/forks.mjs +39 -0
  71. package/dist/contracts/git.d.mts +172 -0
  72. package/dist/contracts/git.mjs +23 -0
  73. package/dist/contracts/grants.d.mts +7 -2
  74. package/dist/contracts/ids.d.mts +23 -8
  75. package/dist/contracts/ids.mjs +40 -5
  76. package/dist/contracts/lfs.d.mts +12 -4
  77. package/dist/contracts/merges.d.mts +68 -16
  78. package/dist/contracts/merges.mjs +27 -0
  79. package/dist/contracts/namespaces.d.mts +14 -0
  80. package/dist/contracts/object-values.d.mts +96 -0
  81. package/dist/contracts/object-values.mjs +104 -0
  82. package/dist/contracts/objects.d.mts +329 -88
  83. package/dist/contracts/operations.d.mts +24 -16
  84. package/dist/contracts/promises.d.mts +10 -11
  85. package/dist/contracts/push-uploads.d.mts +40 -25
  86. package/dist/contracts/push-uploads.mjs +54 -0
  87. package/dist/contracts/queue.d.mts +454 -141
  88. package/dist/contracts/queue.mjs +197 -0
  89. package/dist/contracts/refs.d.mts +248 -45
  90. package/dist/contracts/refs.mjs +117 -0
  91. package/dist/contracts/repo-records.d.mts +34 -0
  92. package/dist/contracts/repo-records.mjs +18 -0
  93. package/dist/contracts/repos.d.mts +411 -58
  94. package/dist/contracts/repos.mjs +136 -0
  95. package/dist/contracts/result.d.mts +339 -69
  96. package/dist/contracts/result.mjs +355 -5
  97. package/dist/contracts/rules.d.mts +60 -48
  98. package/dist/contracts/rules.mjs +9 -0
  99. package/dist/contracts/server.d.mts +124 -51
  100. package/dist/contracts/services.d.mts +15 -24
  101. package/dist/contracts/services.mjs +5 -9
  102. package/dist/contracts/signin.d.mts +64 -31
  103. package/dist/contracts/signin.mjs +18 -0
  104. package/dist/contracts/store.d.mts +45 -5
  105. package/dist/contracts/store.mjs +31 -0
  106. package/dist/contracts/sync.d.mts +81 -46
  107. package/dist/contracts/sync.mjs +41 -2
  108. package/dist/contracts/tags.d.mts +204 -22
  109. package/dist/contracts/tags.mjs +51 -1
  110. package/dist/contracts/tokens.d.mts +32 -7
  111. package/dist/contracts/tokens.mjs +31 -1
  112. package/dist/contracts/topics.d.mts +123 -67
  113. package/dist/contracts/topics.mjs +109 -0
  114. package/dist/contracts/trees.d.mts +132 -52
  115. package/dist/contracts/trees.mjs +105 -0
  116. package/dist/contracts/work.d.mts +128 -21
  117. package/dist/contracts/work.mjs +69 -0
  118. package/dist/core/access.d.mts +25 -14
  119. package/dist/core/access.mjs +93 -108
  120. package/dist/core/ancestry.mjs +86 -18
  121. package/dist/core/call-names.d.mts +3 -1
  122. package/dist/core/call-names.mjs +1 -0
  123. package/dist/core/call-services.mjs +73 -0
  124. package/dist/core/changes.d.mts +31 -0
  125. package/dist/core/changes.mjs +5 -0
  126. package/dist/core/claim-rows.d.mts +4 -0
  127. package/dist/core/claim-rows.mjs +53 -0
  128. package/dist/core/clock.mjs +3 -3
  129. package/dist/core/events/deliver.d.mts +12 -0
  130. package/dist/core/events/deliver.mjs +454 -146
  131. package/dist/core/events/seen.mjs +138 -0
  132. package/dist/core/forks.mjs +435 -161
  133. package/dist/core/hooks/order.d.mts +9 -0
  134. package/dist/core/hooks/order.mjs +25 -0
  135. package/dist/core/hooks/post-receive.mjs +33 -29
  136. package/dist/core/hooks/pre-receive.d.mts +8 -1
  137. package/dist/core/hooks/pre-receive.mjs +8 -6
  138. package/dist/core/imports.mjs +212 -0
  139. package/dist/core/index-job.mjs +152 -53
  140. package/dist/core/merge-parts.d.mts +30 -0
  141. package/dist/core/merge-parts.mjs +31 -0
  142. package/dist/core/names.mjs +4 -16
  143. package/dist/core/namespaces.d.mts +2 -0
  144. package/dist/core/objects/blobs.mjs +4 -4
  145. package/dist/core/objects/commit-writes.mjs +19 -17
  146. package/dist/core/objects/commits.mjs +12 -12
  147. package/dist/core/objects/files.mjs +10 -11
  148. package/dist/core/objects/lines.mjs +15 -32
  149. package/dist/core/objects/merges.mjs +4 -4
  150. package/dist/core/objects/objects-layer.d.mts +21 -0
  151. package/dist/core/objects/objects-layer.mjs +47 -0
  152. package/dist/core/objects/objects-namespace.d.mts +6 -0
  153. package/dist/core/objects/objects-namespace.mjs +13 -0
  154. package/dist/core/objects/objects.d.mts +49 -0
  155. package/dist/core/objects/objects.mjs +18 -0
  156. package/dist/core/objects/peel.mjs +3 -3
  157. package/dist/core/objects/reading.mjs +135 -40
  158. package/dist/core/objects/tags.mjs +7 -7
  159. package/dist/core/objects/tree-edits.mjs +40 -27
  160. package/dist/core/objects/trees.mjs +23 -18
  161. package/dist/core/objects/writing.mjs +43 -44
  162. package/dist/core/own-writes.mjs +3 -3
  163. package/dist/core/parts.d.mts +131 -0
  164. package/dist/core/parts.mjs +59 -0
  165. package/dist/core/promise.mjs +13 -9
  166. package/dist/core/publish.mjs +27 -17
  167. package/dist/core/purge.d.mts +8 -0
  168. package/dist/core/purge.mjs +237 -0
  169. package/dist/core/push-decide.mjs +116 -29
  170. package/dist/core/push.mjs +352 -171
  171. package/dist/core/receipts.d.mts +4 -3
  172. package/dist/core/receipts.mjs +20 -12
  173. package/dist/core/ref-conflicts.mjs +70 -4
  174. package/dist/core/ref-index-job.mjs +176 -0
  175. package/dist/core/ref-index.d.mts +26 -0
  176. package/dist/core/ref-index.mjs +156 -0
  177. package/dist/core/ref-view.mjs +171 -0
  178. package/dist/core/refs.mjs +318 -98
  179. package/dist/core/repack.d.mts +11 -0
  180. package/dist/core/repack.mjs +264 -136
  181. package/dist/core/repo-info.mjs +99 -0
  182. package/dist/core/repos.mjs +114 -80
  183. package/dist/core/rules/changes.mjs +48 -20
  184. package/dist/core/rules/check.mjs +36 -28
  185. package/dist/core/rules/commit-changes.d.mts +13 -0
  186. package/dist/core/rules/commit-changes.mjs +100 -91
  187. package/dist/core/rules/context.d.mts +67 -8
  188. package/dist/core/rules/context.mjs +88 -51
  189. package/dist/core/rules/facts.mjs +1 -1
  190. package/dist/core/rules/fetch.mjs +24 -26
  191. package/dist/core/rules/files.d.mts +13 -0
  192. package/dist/core/rules/files.mjs +27 -28
  193. package/dist/core/rules/namespace.d.mts +2 -0
  194. package/dist/core/rules/patterns.mjs +29 -5
  195. package/dist/core/rules/protect.d.mts +12 -6
  196. package/dist/core/rules/protect.mjs +22 -20
  197. package/dist/core/rules/rules-layer.d.mts +17 -0
  198. package/dist/core/rules/rules-layer.mjs +26 -0
  199. package/dist/core/rules/rules.d.mts +8 -0
  200. package/dist/core/rules/rules.mjs +16 -0
  201. package/dist/core/rules/service.mjs +18 -0
  202. package/dist/core/seam.d.mts +60 -10
  203. package/dist/core/seam.mjs +25 -15
  204. package/dist/core/still-takes.mjs +75 -0
  205. package/dist/core/tokens.mjs +29 -23
  206. package/dist/core/view.d.mts +106 -6
  207. package/dist/core/view.mjs +215 -114
  208. package/dist/core/work.mjs +40 -14
  209. package/dist/effect.d.mts +3 -4
  210. package/dist/effect.mjs +2 -3
  211. package/dist/engine/allotted-xdiff.d.mts +1 -0
  212. package/dist/engine/allotted-xdiff.mjs +1 -1
  213. package/dist/engine/attributes.mjs +1 -1
  214. package/dist/engine/combined.d.mts +18 -0
  215. package/dist/engine/combined.mjs +39 -44
  216. package/dist/engine/commits.mjs +5 -4
  217. package/dist/engine/content.d.mts +3 -2
  218. package/dist/engine/content.mjs +2 -2
  219. package/dist/engine/failures.d.mts +2 -2
  220. package/dist/engine/failures.mjs +2 -9
  221. package/dist/engine/merge-base-walk.d.mts +3 -2
  222. package/dist/engine/merge-base-walk.mjs +1 -1
  223. package/dist/engine/merge-bases.mjs +3 -2
  224. package/dist/engine/merge.mjs +568 -566
  225. package/dist/engine/parts.d.mts +3 -2
  226. package/dist/engine/parts.mjs +40 -7
  227. package/dist/engine/reads.d.mts +1 -0
  228. package/dist/engine/reads.mjs +5 -5
  229. package/dist/engine/walk.mjs +23 -24
  230. package/dist/engine/xdiff.d.mts +2 -33
  231. package/dist/engine/xdiff.mjs +6 -3
  232. package/dist/event-streams/event-streams.d.mts +25 -0
  233. package/dist/event-streams/event-streams.mjs +22 -0
  234. package/dist/event-streams/namespace.d.mts +2 -0
  235. package/dist/event-streams/stream.d.mts +42 -0
  236. package/dist/{core/events → event-streams}/stream.mjs +106 -49
  237. package/dist/extend.d.mts +5 -2
  238. package/dist/http/answers.mjs +8 -4
  239. package/dist/http/bodies.mjs +84 -56
  240. package/dist/http/core-parts.mjs +222 -68
  241. package/dist/http/handler.d.mts +2 -0
  242. package/dist/http/handler.mjs +19 -13
  243. package/dist/http/node.d.mts +2 -23
  244. package/dist/http/node.mjs +10 -6
  245. package/dist/http/parts.d.mts +13 -0
  246. package/dist/http/push-uploads.d.mts +17 -0
  247. package/dist/http/push-uploads.mjs +94 -87
  248. package/dist/http/receive-pack.mjs +165 -29
  249. package/dist/http/upload-pack.mjs +106 -81
  250. package/dist/index.d.mts +52 -28
  251. package/dist/index.mjs +31 -7
  252. package/dist/lfs/base.d.mts +32 -0
  253. package/dist/lfs/base.mjs +8 -0
  254. package/dist/lfs/calls.mjs +21 -12
  255. package/dist/lfs/layer.d.mts +27 -0
  256. package/dist/lfs/layer.mjs +64 -0
  257. package/dist/lfs/locks.mjs +36 -46
  258. package/dist/lfs/namespace.d.mts +2 -0
  259. package/dist/lfs/objects.d.mts +26 -0
  260. package/dist/lfs/objects.mjs +83 -94
  261. package/dist/lfs/pointers.mjs +13 -11
  262. package/dist/lfs/public.d.mts +5 -0
  263. package/dist/lfs/public.mjs +8 -0
  264. package/dist/lfs/purge.mjs +44 -0
  265. package/dist/lfs/rows.mjs +30 -18
  266. package/dist/lfs/service.d.mts +14 -0
  267. package/dist/lfs/service.mjs +26 -28
  268. package/dist/lfs/upkeep.mjs +39 -54
  269. package/dist/lfs/wire.mjs +80 -38
  270. package/dist/merges/merges.d.mts +20 -0
  271. package/dist/merges/merges.mjs +32 -0
  272. package/dist/merges/namespace.d.mts +2 -0
  273. package/dist/merges/public.d.mts +6 -0
  274. package/dist/merges/public.mjs +10 -0
  275. package/dist/node.d.mts +3 -3
  276. package/dist/node.mjs +1 -3
  277. package/dist/protocol/bytes/buffers.d.mts +9 -3
  278. package/dist/protocol/bytes/buffers.mjs +11 -5
  279. package/dist/protocol/bytes/deflate.d.mts +7 -5
  280. package/dist/protocol/bytes/deflate.mjs +59 -23
  281. package/dist/protocol/bytes/inflate.d.mts +4 -3
  282. package/dist/protocol/bytes/inflate.mjs +61 -26
  283. package/dist/protocol/bytes/reader.mjs +61 -0
  284. package/dist/protocol/bytes/sha1-hasher.d.mts +3 -1
  285. package/dist/protocol/bytes/sha1-hasher.mjs +13 -3
  286. package/dist/protocol/bytes/sha1.d.mts +1 -1
  287. package/dist/protocol/bytes/sha1.mjs +5 -5
  288. package/dist/protocol/bytes/streams.mjs +16 -6
  289. package/dist/protocol/diff/patch.d.mts +4 -0
  290. package/dist/protocol/diff/patch.mjs +1 -1
  291. package/dist/protocol/diff/paths.mjs +1 -1
  292. package/dist/protocol/diff/read.d.mts +1 -1
  293. package/dist/protocol/diff/read.mjs +102 -90
  294. package/dist/protocol/framing/pkt-line.d.mts +1 -0
  295. package/dist/protocol/framing/pkt-line.mjs +40 -6
  296. package/dist/protocol/objects/checked-blobs.d.mts +1 -0
  297. package/dist/protocol/objects/fsck.mjs +7 -1
  298. package/dist/protocol/objects/held.mjs +5 -11
  299. package/dist/protocol/objects/ident.mjs +1 -1
  300. package/dist/protocol/objects/object-rules.mjs +15 -7
  301. package/dist/protocol/objects/object.d.mts +6 -2
  302. package/dist/protocol/objects/object.mjs +5 -2
  303. package/dist/protocol/objects/tag.d.mts +3 -1
  304. package/dist/protocol/objects/tag.mjs +27 -1
  305. package/dist/protocol/objects/tree.mjs +1 -1
  306. package/dist/protocol/packs/delta.d.mts +1 -1
  307. package/dist/protocol/packs/delta.mjs +2 -2
  308. package/dist/protocol/packs/graph.mjs +55 -56
  309. package/dist/protocol/packs/idx.d.mts +4 -2
  310. package/dist/protocol/packs/idx.mjs +156 -63
  311. package/dist/protocol/packs/indexer.d.mts +22 -4
  312. package/dist/protocol/packs/indexer.mjs +14 -35
  313. package/dist/protocol/packs/parts.mjs +5 -5
  314. package/dist/protocol/packs/pos.mjs +12 -5
  315. package/dist/protocol/packs/reader.d.mts +19 -12
  316. package/dist/protocol/packs/reader.mjs +252 -25
  317. package/dist/protocol/packs/rev.d.mts +1 -1
  318. package/dist/protocol/packs/rev.mjs +42 -24
  319. package/dist/protocol/packs/types-file.mjs +85 -0
  320. package/dist/protocol/packs/write-error.d.mts +1 -1
  321. package/dist/protocol/packs/write-error.mjs +2 -2
  322. package/dist/protocol/packs/writer.d.mts +40 -15
  323. package/dist/protocol/packs/writer.mjs +142 -49
  324. package/dist/protocol/wire/advertisement.d.mts +34 -15
  325. package/dist/protocol/wire/advertisement.mjs +135 -35
  326. package/dist/protocol/wire/fetch.d.mts +57 -19
  327. package/dist/protocol/wire/fetch.mjs +57 -26
  328. package/dist/protocol/wire/json.mjs +25 -0
  329. package/dist/protocol/wire/lines.d.mts +22 -0
  330. package/dist/protocol/wire/lines.mjs +51 -26
  331. package/dist/protocol/wire/push-limits.d.mts +6 -0
  332. package/dist/protocol/wire/push-limits.mjs +88 -0
  333. package/dist/protocol/wire/push-uploads.mjs +3 -28
  334. package/dist/protocol/wire/receive-pack.d.mts +30 -14
  335. package/dist/protocol/wire/receive-pack.mjs +29 -2
  336. package/dist/protocol/wire/report-status.d.mts +30 -11
  337. package/dist/protocol/wire/report-status.mjs +21 -2
  338. package/dist/protocol/wire/v2.d.mts +45 -29
  339. package/dist/protocol/wire/v2.mjs +95 -18
  340. package/dist/protocol.d.mts +4 -3
  341. package/dist/protocol.mjs +7 -6
  342. package/dist/queue/advance.mjs +240 -148
  343. package/dist/queue/callers.mjs +12 -9
  344. package/dist/queue/calls.mjs +315 -157
  345. package/dist/queue/commit.mjs +86 -35
  346. package/dist/queue/host.d.mts +39 -12
  347. package/dist/queue/host.mjs +36 -38
  348. package/dist/queue/lanes.mjs +1 -1
  349. package/dist/queue/layer.d.mts +16 -0
  350. package/dist/queue/layer.mjs +60 -0
  351. package/dist/queue/limits.mjs +43 -2
  352. package/dist/queue/namespace.d.mts +2 -0
  353. package/dist/queue/pages.mjs +1 -1
  354. package/dist/queue/public.d.mts +6 -0
  355. package/dist/queue/public.mjs +21 -0
  356. package/dist/queue/push-option.mjs +49 -30
  357. package/dist/queue/rows.mjs +38 -21
  358. package/dist/queue/schedule.mjs +22 -22
  359. package/dist/queue/search.mjs +8 -7
  360. package/dist/queue/state.mjs +68 -18
  361. package/dist/queue/steps.mjs +16 -7
  362. package/dist/queue/trim.mjs +284 -0
  363. package/dist/remote-helper.d.mts +5 -2
  364. package/dist/remote-helper.mjs +5 -2
  365. package/dist/rest/api.d.mts +1 -1
  366. package/dist/rest/blobs.d.mts +799 -32
  367. package/dist/rest/blobs.mjs +4 -4
  368. package/dist/rest/caller.d.mts +4163 -36
  369. package/dist/rest/caller.mjs +2 -2
  370. package/dist/rest/client.mjs +80 -70
  371. package/dist/rest/commits.d.mts +3261 -190
  372. package/dist/rest/commits.mjs +18 -64
  373. package/dist/rest/errors.d.mts +2082 -22
  374. package/dist/rest/errors.mjs +46 -89
  375. package/dist/rest/events.d.mts +394 -11
  376. package/dist/rest/events.mjs +13 -9
  377. package/dist/rest/files.d.mts +1265 -114
  378. package/dist/rest/files.mjs +11 -42
  379. package/dist/rest/forks.d.mts +2045 -102
  380. package/dist/rest/forks.mjs +10 -13
  381. package/dist/rest/handler.d.mts +3 -0
  382. package/dist/rest/handler.mjs +35 -19
  383. package/dist/rest/handlers.mjs +53 -60
  384. package/dist/rest/layer.d.mts +14 -0
  385. package/dist/rest/layer.mjs +52 -0
  386. package/dist/rest/listen.d.mts +5 -8
  387. package/dist/rest/listen.mjs +23 -29
  388. package/dist/rest/me.d.mts +393 -10
  389. package/dist/rest/me.mjs +2 -2
  390. package/dist/rest/merges.d.mts +399 -16
  391. package/dist/rest/merges.mjs +3 -17
  392. package/dist/rest/namespace.d.mts +2 -0
  393. package/dist/rest/paths.mjs +1 -0
  394. package/dist/rest/queue.d.mts +5658 -283
  395. package/dist/rest/queue.mjs +15 -130
  396. package/dist/rest/refs.d.mts +2869 -142
  397. package/dist/rest/refs.mjs +19 -39
  398. package/dist/rest/repos.d.mts +2421 -93
  399. package/dist/rest/repos.mjs +10 -33
  400. package/dist/rest/tags.d.mts +1220 -69
  401. package/dist/rest/tags.mjs +6 -34
  402. package/dist/rest/tokens.d.mts +2358 -55
  403. package/dist/rest/tokens.mjs +7 -4
  404. package/dist/rest/topics.d.mts +2053 -106
  405. package/dist/rest/topics.mjs +23 -71
  406. package/dist/rest/trees.d.mts +1616 -81
  407. package/dist/rest/trees.mjs +16 -57
  408. package/dist/rest/wire.d.mts +404 -0
  409. package/dist/rest/wire.mjs +32 -46
  410. package/dist/rest/work.d.mts +1204 -63
  411. package/dist/rest/work.mjs +7 -51
  412. package/dist/rest.d.mts +3 -3
  413. package/dist/server/edge-node.d.mts +20 -0
  414. package/dist/server/edge-node.mjs +20 -0
  415. package/dist/server/edge.d.mts +10 -0
  416. package/dist/server/edge.mjs +23 -0
  417. package/dist/server/extension.d.mts +6 -2
  418. package/dist/server/extension.mjs +54 -30
  419. package/dist/server/git-layer.d.mts +34 -0
  420. package/dist/server/git-layer.mjs +118 -0
  421. package/dist/server/git-namespace.d.mts +7 -0
  422. package/dist/server/git-namespace.mjs +18 -0
  423. package/dist/server/lifecycle.d.mts +1 -2
  424. package/dist/server/lifecycle.mjs +8 -15
  425. package/dist/server/namespaces.d.mts +2 -0
  426. package/dist/server/registry.d.mts +12 -0
  427. package/dist/server/registry.mjs +218 -0
  428. package/dist/server/route-match.mjs +88 -0
  429. package/dist/server/routes.d.mts +12 -8
  430. package/dist/server/routes.mjs +27 -18
  431. package/dist/server/server.d.mts +22 -0
  432. package/dist/server/server.mjs +335 -210
  433. package/dist/server/uploads.d.mts +14 -0
  434. package/dist/server/uploads.mjs +15 -0
  435. package/dist/signin/codes.mjs +9 -6
  436. package/dist/signin/context.d.mts +1 -0
  437. package/dist/signin/context.mjs +4 -4
  438. package/dist/signin/device.mjs +8 -8
  439. package/dist/signin/forms.mjs +11 -29
  440. package/dist/signin/grants.d.mts +4 -2
  441. package/dist/signin/grants.mjs +20 -19
  442. package/dist/signin/route.mjs +2 -2
  443. package/dist/signin/web.mjs +7 -7
  444. package/dist/signin/wire.mjs +6 -6
  445. package/dist/storage/budget.mjs +51 -18
  446. package/dist/storage/calls.d.mts +28 -11
  447. package/dist/storage/calls.mjs +354 -117
  448. package/dist/storage/clean-up.mjs +121 -46
  449. package/dist/storage/counted-bucket.mjs +115 -0
  450. package/dist/storage/fetch.d.mts +2 -0
  451. package/dist/storage/fetch.mjs +243 -100
  452. package/dist/storage/fsck.mjs +56 -7
  453. package/dist/storage/held-types.d.mts +7 -0
  454. package/dist/storage/held-types.mjs +263 -0
  455. package/dist/storage/host-bucket.mjs +43 -0
  456. package/dist/storage/id-mix.d.mts +1 -0
  457. package/dist/storage/id-mix.mjs +55 -0
  458. package/dist/storage/index-bitmaps.d.mts +2 -1
  459. package/dist/storage/index-bitmaps.mjs +233 -101
  460. package/dist/storage/index-build.d.mts +6 -2
  461. package/dist/storage/index-build.mjs +650 -164
  462. package/dist/storage/index-fetch.d.mts +3 -1
  463. package/dist/storage/index-fetch.mjs +297 -195
  464. package/dist/storage/index-files.mjs +25 -27
  465. package/dist/storage/index-graph.d.mts +2 -1
  466. package/dist/storage/index-graph.mjs +127 -91
  467. package/dist/storage/index-layers.d.mts +11 -0
  468. package/dist/storage/index-layers.mjs +258 -78
  469. package/dist/storage/index-reach.mjs +181 -75
  470. package/dist/storage/index-remap.mjs +74 -32
  471. package/dist/storage/index-shallow.mjs +311 -0
  472. package/dist/storage/index-visible.mjs +168 -0
  473. package/dist/storage/layout.d.mts +1 -0
  474. package/dist/storage/layout.mjs +44 -8
  475. package/dist/storage/lfs-pointers.d.mts +3 -1
  476. package/dist/storage/lfs-pointers.mjs +25 -9
  477. package/dist/storage/link-join.d.mts +4 -0
  478. package/dist/storage/link-join.mjs +50 -12
  479. package/dist/storage/links.mjs +89 -4
  480. package/dist/storage/listed-ids.mjs +10 -0
  481. package/dist/storage/loose.d.mts +11 -4
  482. package/dist/storage/loose.mjs +102 -69
  483. package/dist/storage/memory-budget.d.mts +5 -0
  484. package/dist/storage/memory-budget.mjs +530 -102
  485. package/dist/storage/merge-choose.mjs +258 -0
  486. package/dist/storage/merge-cut.mjs +47 -0
  487. package/dist/storage/merge-fence.mjs +89 -0
  488. package/dist/storage/merge-index.mjs +347 -0
  489. package/dist/storage/merge-most.mjs +202 -0
  490. package/dist/storage/merge-plan.mjs +171 -0
  491. package/dist/storage/merge-row.mjs +258 -0
  492. package/dist/storage/merge-stream.mjs +497 -0
  493. package/dist/storage/merge-walk.mjs +199 -0
  494. package/dist/storage/merge-write.mjs +129 -0
  495. package/dist/storage/merge.d.mts +10 -0
  496. package/dist/storage/merge.mjs +82 -306
  497. package/dist/storage/object-rows.d.mts +4 -2
  498. package/dist/storage/object-rows.mjs +101 -17
  499. package/dist/storage/pack-order.d.mts +1 -1
  500. package/dist/storage/pack-order.mjs +69 -54
  501. package/dist/storage/pack-ranges.d.mts +1 -1
  502. package/dist/storage/pack-ranges.mjs +396 -60
  503. package/dist/storage/pack-reads.d.mts +6 -2
  504. package/dist/storage/pack-reads.mjs +598 -126
  505. package/dist/storage/pack-receive.d.mts +5 -0
  506. package/dist/storage/pack-receive.mjs +820 -237
  507. package/dist/storage/packs-memory.d.mts +25 -0
  508. package/dist/storage/packs-memory.mjs +49 -0
  509. package/dist/storage/packs.d.mts +7 -5
  510. package/dist/storage/packs.mjs +554 -213
  511. package/dist/storage/placed-reads.mjs +205 -0
  512. package/dist/storage/prune-keep.mjs +164 -0
  513. package/dist/storage/prune-walk.mjs +578 -0
  514. package/dist/storage/prune.mjs +739 -332
  515. package/dist/storage/push-allotment.mjs +3 -3
  516. package/dist/storage/push-uploads.mjs +31 -26
  517. package/dist/storage/pushed-commits.mjs +8 -9
  518. package/dist/storage/quarantine.d.mts +10 -0
  519. package/dist/storage/quarantine.mjs +71 -29
  520. package/dist/storage/range-cache.mjs +71 -0
  521. package/dist/storage/raw-ids.mjs +20 -1
  522. package/dist/storage/ready.d.mts +4 -2
  523. package/dist/storage/ready.mjs +109 -48
  524. package/dist/storage/receive-admission.mjs +67 -0
  525. package/dist/storage/receive-bounds.d.mts +1 -0
  526. package/dist/storage/receive-bounds.mjs +202 -0
  527. package/dist/storage/receive-files.mjs +248 -0
  528. package/dist/storage/receive-links.mjs +281 -244
  529. package/dist/storage/receive-state.d.mts +9 -0
  530. package/dist/storage/receive-state.mjs +150 -0
  531. package/dist/storage/receive-steps.mjs +344 -0
  532. package/dist/storage/receive-sweep.mjs +160 -0
  533. package/dist/storage/receive-table.d.mts +3 -0
  534. package/dist/storage/receive-table.mjs +197 -0
  535. package/dist/storage/repack-backlog.mjs +70 -0
  536. package/dist/storage/repack-contained.mjs +269 -0
  537. package/dist/storage/repack-job.d.mts +3 -0
  538. package/dist/storage/repack-job.mjs +27 -17
  539. package/dist/storage/repack.d.mts +4 -4
  540. package/dist/storage/repack.mjs +156 -77
  541. package/dist/storage/roots.mjs +23 -7
  542. package/dist/storage/rows.d.mts +4 -2
  543. package/dist/storage/rows.mjs +81 -9
  544. package/dist/storage/runs.d.mts +8 -0
  545. package/dist/storage/runs.mjs +731 -0
  546. package/dist/storage/send-list.d.mts +2 -1
  547. package/dist/storage/send-list.mjs +261 -76
  548. package/dist/storage/shallow.d.mts +3 -2
  549. package/dist/storage/shallow.mjs +7 -7
  550. package/dist/storage/single-flight.mjs +47 -0
  551. package/dist/storage/stream-whole.mjs +121 -54
  552. package/dist/storage/swap-walk.mjs +188 -0
  553. package/dist/storage/unpack.mjs +52 -23
  554. package/dist/storage/visible.mjs +58 -39
  555. package/dist/storage/walk.d.mts +2 -0
  556. package/dist/storage/walk.mjs +20 -7
  557. package/dist/storage/wants.mjs +185 -33
  558. package/dist/storage/written-bases.mjs +172 -0
  559. package/dist/store/call-count.d.mts +69 -4
  560. package/dist/store/call-count.mjs +193 -51
  561. package/dist/store/catalogue.d.mts +17 -3
  562. package/dist/store/catalogue.mjs +135 -48
  563. package/dist/store/crossing.mjs +2 -4
  564. package/dist/store/cursor-seal.d.mts +12 -1
  565. package/dist/store/cursor-seal.mjs +7 -6
  566. package/dist/store/errors.d.mts +2 -2
  567. package/dist/store/errors.mjs +112 -24
  568. package/dist/store/git-store.mjs +21 -2
  569. package/dist/store/job-try.mjs +26 -0
  570. package/dist/store/list-job.mjs +23 -17
  571. package/dist/store/outbox.d.mts +15 -5
  572. package/dist/store/outbox.mjs +143 -39
  573. package/dist/store/promises.d.mts +8 -2
  574. package/dist/store/promises.mjs +129 -85
  575. package/dist/store/queue-jobs.mjs +34 -13
  576. package/dist/store/records.d.mts +64 -1
  577. package/dist/store/records.mjs +101 -32
  578. package/dist/store/ref-rows.d.mts +18 -2
  579. package/dist/store/ref-rows.mjs +62 -5
  580. package/dist/store/repo-record.mjs +11 -9
  581. package/dist/store/reservations.mjs +9 -8
  582. package/dist/store/scopes.mjs +13 -11
  583. package/dist/store/settle.mjs +1 -1
  584. package/dist/store/topic-jobs.mjs +4 -4
  585. package/dist/sync/bound.d.mts +5 -3
  586. package/dist/sync/bound.mjs +32 -3
  587. package/dist/sync/github.mjs +7 -7
  588. package/dist/sync/import.d.mts +2 -0
  589. package/dist/sync/import.mjs +46 -50
  590. package/dist/sync/jobs.mjs +15 -23
  591. package/dist/sync/mirror.d.mts +6 -2
  592. package/dist/sync/mirror.mjs +122 -45
  593. package/dist/sync/publish.d.mts +1 -0
  594. package/dist/sync/publish.mjs +22 -19
  595. package/dist/sync/step.mjs +443 -71
  596. package/dist/sync/tries.mjs +50 -32
  597. package/dist/sync.d.mts +3 -3
  598. package/dist/sync.mjs +2 -2
  599. package/dist/topics/advance.mjs +103 -86
  600. package/dist/topics/calls.mjs +97 -67
  601. package/dist/topics/directory.mjs +31 -11
  602. package/dist/topics/host.d.mts +0 -1
  603. package/dist/topics/host.mjs +2 -12
  604. package/dist/topics/members.mjs +30 -24
  605. package/dist/topics/rows.mjs +10 -9
  606. package/dist/topics/topic.mjs +20 -9
  607. package/package.json +8 -15
  608. package/dist/auth/authorize.d.mts +0 -5
  609. package/dist/contracts/objects.mjs +0 -54
  610. package/dist/core/events/stream.d.mts +0 -19
  611. package/dist/core/rules/define.d.mts +0 -5
  612. package/dist/core/rules/define.mjs +0 -13
  613. package/dist/core/rules/fetch.d.mts +0 -5
  614. package/dist/core/sight.mjs +0 -99
  615. package/dist/engine/engine.d.mts +0 -25
  616. package/dist/engine/engine.mjs +0 -49
  617. package/dist/engine/xdiff/NOTICE.md +0 -63
  618. package/dist/engine/xdiff/compiled.d.mts +0 -7
  619. package/dist/engine/xdiff/compiled.mjs +0 -9
  620. package/dist/engine/xdiff/embedded.mjs +0 -4
  621. package/dist/engine/xdiff/node.d.mts +0 -7
  622. package/dist/engine/xdiff/node.mjs +0 -10
  623. package/dist/engine/xdiff/upstream/LGPL-2.1 +0 -511
  624. package/dist/engine/xdiff/xdiff.wasm +0 -0
  625. package/dist/engine.d.mts +0 -3
  626. package/dist/engine.mjs +0 -3
  627. package/dist/lfs/repo.mjs +0 -42
  628. package/dist/storage/distinct-ids.mjs +0 -39
  629. package/dist/storage/held-memo.mjs +0 -188
  630. package/dist/storage/index-remap.d.mts +0 -8
  631. package/dist/sync/records.mjs +0 -73
@@ -1,5 +1,6 @@
1
1
  import { isInternalId } from "../contracts/ids.mjs";
2
- import { decodeRow, fail, storeCall } from "./errors.mjs";
2
+ import { fail } from "../contracts/result.mjs";
3
+ import { decodeDerivedRow, decodeRow, storeCall } from "./errors.mjs";
3
4
  import { CatalogueEntry, CreatedRow, ForkRow, StoredRepo, keyKept, takenBack } from "./records.mjs";
4
5
  import { catalogueScope, collections, forkId, newChangeId, repoScope, selfKey } from "./scopes.mjs";
5
6
  import { limits } from "@ref0/infra";
@@ -15,7 +16,7 @@ const decodeEntry = (row) => row === void 0 ? Effect.succeed(void 0) : decodeRow
15
16
  const decodeRecord = (row) => row === void 0 ? Effect.succeed(void 0) : decodeRow(StoredRepo, row, "A repo's record");
16
17
  const decodeForkRow = (row) => row === void 0 ? Effect.succeed(void 0) : decodeRow(ForkRow, row, "A fork's row");
17
18
  /** The catalogue's entries for `names`, and the fork row `fork` when there is one, at one version. */
18
- const readCatalogue = Effect.fnUntraced(function* (store, names, fork) {
19
+ const readCatalogue = /* @__PURE__ */ Effect.fnUntraced(function* (store, names, fork) {
19
20
  const reads = fork === void 0 ? names.map(entryRead) : [...names.map(entryRead), fork];
20
21
  const snapshot = yield* storeCall(() => store.read(catalogueScope, reads));
21
22
  const entries = yield* Effect.forEach(names, (name, index) => Effect.map(decodeEntry(snapshot.results[index]?.[0]), (entry) => ({
@@ -37,10 +38,40 @@ const forkKey = (source, holder) => ({
37
38
  id: forkId(source, holder)
38
39
  });
39
40
  /** The holder's fork of `source`, by its row: `undefined` when it has none. */
40
- const forkOf = Effect.fnUntraced(function* (store, source, holder) {
41
+ const forkOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, source, holder) {
41
42
  const { row } = yield* readCatalogue(store, [], forkKey(source, holder));
42
43
  return row?.internalId;
43
44
  });
45
+ /** A fork's hold on its source, in `git/repos`' `fork-holds`, by both internal IDs. */
46
+ const holdKey = (source, fork) => ({
47
+ collection: collections.forkHolds,
48
+ id: `${source}:${fork}`
49
+ });
50
+ /**
51
+ * Whether a fork, deleted or not, still holds `source`: while one does, the source's purge waits,
52
+ * since a fork's LFS reads through its source's record and rows.
53
+ */
54
+ const forkedFrom = (store, source) => Effect.map(storeCall(() => store.read(catalogueScope, [{
55
+ collection: collections.forkHolds,
56
+ prefix: `${source}:`,
57
+ limit: 1
58
+ }])), (snapshot) => (snapshot.results[0]?.length ?? 0) > 0);
59
+ /**
60
+ * A purged fork's hold on its source, deleted: `false` when the catalogue moved, and the step
61
+ * tries again. A repo that is no fork, or whose hold is gone, has none.
62
+ */
63
+ const releaseHold = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, record) {
64
+ if (record.fork === void 0) return true;
65
+ const key = holdKey(record.fork.upstreamInternalId, internalId);
66
+ const snapshot = yield* storeCall(() => store.read(catalogueScope, [key]));
67
+ if ((snapshot.results[0]?.length ?? 0) === 0) return true;
68
+ const change = {
69
+ id: newChangeId(),
70
+ expect: snapshot.version,
71
+ delete: [key]
72
+ };
73
+ return (yield* storeCall(() => store.commit(catalogueScope, change))).ok;
74
+ });
44
75
  /** Whether a live repo other than `internalId` holds a fork's row: a deleted one's is stale. */
45
76
  const heldByOther = (store, internalId, row) => row === void 0 || row.internalId === internalId ? Effect.succeed(false) : Effect.map(recordAt(store, row.internalId), (held) => held !== void 0 && held.record.deleted !== true);
46
77
  /**
@@ -161,7 +192,7 @@ const foldersOf = (name) => {
161
192
  return ["", ...parts.map((_, index) => `${parts.slice(0, index + 1).join("/")}/`)];
162
193
  };
163
194
  /**
164
- * A folder's created rows' ID prefix: the folder and a `:`, which no repo ID holds, so a read of
195
+ * A folder's created rows' ID prefix: the folder and a `:`, which no repo name holds, so a read of
165
196
  * one folder takes none of the folders under it.
166
197
  */
167
198
  const folderPrefix = (folder) => `${folder}:`;
@@ -263,11 +294,12 @@ const holdsName = (internalId, record, entry) => entry.internalId === internalId
263
294
  *
264
295
  * A fork's holder's row commits with the entry that wins its name, so a holder's two creates at
265
296
  * once make one fork: one whose row another live fork holds is `taken`, and writes nothing. Its
297
+ * first row commits with its hold on its source, which outlives its delete till its purge. Its
266
298
  * dated rows are among its created rows, and a deleted fork's projection deletes them all. A
267
299
  * commit that wins the name writes the public index too, so the index holds a repo exactly while
268
300
  * its winning projection said it was live and public.
269
301
  */
270
- const project = Effect.fnUntraced(function* (store, internalId, record) {
302
+ const project = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, record) {
271
303
  const projected = projectionOf(internalId, record);
272
304
  const names = projected.map(({ name }) => name);
273
305
  const fork = holderKey(record);
@@ -283,7 +315,9 @@ const project = Effect.fnUntraced(function* (store, internalId, record) {
283
315
  if (live && !holds && (yield* heldByOther(store, internalId, row))) return "taken";
284
316
  const wins = holds || newer.some((one) => one.id === record.name);
285
317
  const writes = wins ? newer : [];
286
- const put = (live && wins && !ownRow ? forkRows : []).map((key) => ({
318
+ const owned = live && wins && !ownRow ? forkRows : [];
319
+ const hold = record.fork === void 0 ? [] : [holdKey(record.fork.upstreamInternalId, internalId)];
320
+ const put = [...owned, ...owned.length > 0 ? hold : []].map((key) => ({
287
321
  ...key,
288
322
  value: { internalId }
289
323
  }));
@@ -320,7 +354,7 @@ const project = Effect.fnUntraced(function* (store, internalId, record) {
320
354
  * while its old name's entry is still its own live one. A rename that won left that name already,
321
355
  * so a newer write that took the new name later doesn't send it back to a name it gave up.
322
356
  */
323
- const reconcile = Effect.fnUntraced(function* (store, internalId) {
357
+ const reconcile = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId) {
324
358
  const snapshot = yield* storeCall(() => store.read(repoScope(internalId), [selfKey]));
325
359
  const record = yield* decodeRecord(snapshot.results[0]?.[0]);
326
360
  if (record === void 0) return void 0;
@@ -343,7 +377,7 @@ const reconcile = Effect.fnUntraced(function* (store, internalId) {
343
377
  return yield* project(store, internalId, back.record);
344
378
  });
345
379
  /** A name's entry, live or a tombstone, or `undefined` for a name never used. */
346
- const entryOf = Effect.fnUntraced(function* (store, name) {
380
+ const entryOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, name) {
347
381
  const { entries } = yield* readEntries(store, [name]);
348
382
  return entries[0]?.entry;
349
383
  });
@@ -364,7 +398,7 @@ const settledName = (name) => name;
364
398
  * name to another repo: a rename away and back between the two reads may have lost it, and the
365
399
  * entry first read doesn't say so (#416). A renamed name's error carries `renamedTo`.
366
400
  */
367
- const resolveRepo = Effect.fnUntraced(function* (store, name, reads = []) {
401
+ const resolveRepo = /* @__PURE__ */ Effect.fnUntraced(function* (store, name, reads = []) {
368
402
  for (let attempt = 0; attempt < resolveTries; attempt += 1) {
369
403
  const entry = yield* entryOf(store, name);
370
404
  if (entry === void 0 || entry.deleted === true) return yield* notFound(name, entry);
@@ -384,18 +418,27 @@ const resolveRepo = Effect.fnUntraced(function* (store, name, reads = []) {
384
418
  return yield* fail("UNAVAILABLE", "The catalogue is busy", { hint: "Try again" });
385
419
  });
386
420
  /** The name a tombstone redirects to, while no repo has been made under it again. */
387
- const redirectOf = Effect.fnUntraced(function* (store, name) {
421
+ const redirectOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, name) {
388
422
  const entry = yield* entryOf(store, name);
389
423
  return entry?.deleted === true ? entry.renamedTo : void 0;
390
424
  });
391
425
  /** A repo's internal ID by name, for an extension's own scopes. */
392
- const internalIdOf = Effect.fnUntraced(function* (store, name) {
426
+ const internalIdOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, name) {
393
427
  const entry = yield* entryOf(store, name);
394
428
  if (entry === void 0 || entry.deleted === true) return yield* notFound(name, entry);
395
429
  return entry.internalId;
396
430
  });
431
+ /** The repo `name` holds now, pinned to its internal ID: `undefined` for none, or a tombstone. */
432
+ const pinOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, name) {
433
+ const entry = yield* entryOf(store, name);
434
+ if (entry === void 0 || entry.deleted === true) return void 0;
435
+ return {
436
+ name,
437
+ internalId: entry.internalId
438
+ };
439
+ });
397
440
  /** A repo's record now, from its scope, and the scope's version: `undefined` for an ID of none. */
398
- const recordAt = Effect.fnUntraced(function* (store, internalId) {
441
+ const recordAt = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId) {
399
442
  if (!isInternalId(internalId)) return void 0;
400
443
  const snapshot = yield* storeCall(() => store.read(repoScope(internalId), [selfKey]));
401
444
  const record = yield* decodeRecord(snapshot.results[0]?.[0]);
@@ -411,7 +454,7 @@ const nameOf = (store, internalId) => Effect.map(recordAt(store, internalId), (r
411
454
  * rename that lost its new name, the old one while its entry is still the repo's live one.
412
455
  * `undefined` when neither is, as while a write's projection hasn't happened yet.
413
456
  */
414
- const heldName = Effect.fnUntraced(function* (store, internalId, record) {
457
+ const heldName = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, record) {
415
458
  const back = takenBack(record);
416
459
  const names = back === void 0 ? [record.name] : [record.name, back.record.name];
417
460
  const { entries } = yield* readEntries(store, names);
@@ -424,7 +467,7 @@ const heldName = Effect.fnUntraced(function* (store, internalId, record) {
424
467
  * write changed the repo between, so the name answered is the one the catalogue gives that very
425
468
  * record, never a later one's beside the earlier one's visibility.
426
469
  */
427
- const heldNameAt = Effect.fnUntraced(function* (store, internalId, record, version) {
470
+ const heldNameAt = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, record, version) {
428
471
  const name = yield* heldName(store, internalId, record);
429
472
  return (yield* recordAt(store, internalId))?.version === version ? name : "moved";
430
473
  });
@@ -438,12 +481,12 @@ const hostReadTries = 5;
438
481
  * the version it reconciled, and it's `undefined`, as for a repo no name reaches. A newer record
439
482
  * is reconciled again, within the tries.
440
483
  */
441
- const hostRecordOf = Effect.fnUntraced(function* (store, internalId) {
484
+ const hostRecordOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId) {
442
485
  const named = yield* namedRecordOf(store, internalId);
443
486
  if (named === void 0) return void 0;
444
487
  const { name, record } = named;
445
488
  const read = {
446
- id: name,
489
+ name,
447
490
  internalId,
448
491
  defaultBranch: record.defaultBranch,
449
492
  public: record.public,
@@ -459,7 +502,7 @@ const hostRecordOf = Effect.fnUntraced(function* (store, internalId) {
459
502
  * so a rename follows it and a repo that takes its old name never stands in for it: `undefined`
460
503
  * for a repo that isn't a fork, and once its source is deleted.
461
504
  */
462
- const upstreamOf = Effect.fnUntraced(function* (store, record) {
505
+ const upstreamOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, record) {
463
506
  if (record.fork === void 0) return void 0;
464
507
  return (yield* namedRecordOf(store, record.fork.upstreamInternalId))?.name;
465
508
  });
@@ -468,7 +511,7 @@ const upstreamOf = Effect.fnUntraced(function* (store, record) {
468
511
  * and a fork's as its source lists it, so a rename that lost its new name, with events or
469
512
  * without, never answers that name.
470
513
  */
471
- const namedRecordOf = Effect.fnUntraced(function* (store, internalId) {
514
+ const namedRecordOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId) {
472
515
  let reconciledAt;
473
516
  for (let attempt = 0; attempt < hostReadTries; attempt += 1) {
474
517
  const first = yield* recordAt(store, internalId);
@@ -493,12 +536,17 @@ const namedRecordOf = Effect.fnUntraced(function* (store, internalId) {
493
536
  const listLimit = (page = {}) => Math.min(Math.max(page.limit ?? 50, 1), 200);
494
537
  /** Reads of the catalogue one list makes at most, skipping tombstones and names outside its prefix. */
495
538
  const listReads = 4;
539
+ /** A page that read nothing, its budget spent: none, with a `next` from where it was sent, if anywhere. */
540
+ const pageAfter = (after) => after === void 0 ? { items: [] } : {
541
+ items: [],
542
+ next: after
543
+ };
496
544
  /**
497
545
  * Live names under `prefix`, in order, or from the last when `descending`: a page can be short
498
546
  * where tombstones were skipped. Each row it reads, a tombstone's too, adds to `tally`, and once
499
547
  * it has read `tally.most` rows it ends there, with a `next`.
500
548
  */
501
- const listNames = Effect.fnUntraced(function* (store, prefix, page = {}, descending = false, tally = { read: 0 }) {
549
+ const listNames = /* @__PURE__ */ Effect.fnUntraced(function* (store, prefix, page = {}, descending = false, tally = { read: 0 }) {
502
550
  const limit = listLimit(page);
503
551
  const items = [];
504
552
  let after = page.after;
@@ -533,62 +581,96 @@ const listNames = Effect.fnUntraced(function* (store, prefix, page = {}, descend
533
581
  * those repos and never on one outside it. Reads one row past the page, so `next` comes only while
534
582
  * a row follows, and keeps each name while its entry is its repo's live one. Rows and entries are
535
583
  * two reads, so a repo renamed between them is left out of that page, which is then short. Each
536
- * row of the page it reads, a dropped one's too, adds to `tally`.
584
+ * row it reads adds to `tally`, a dropped one's and the one past the page too. Where `tally.most`
585
+ * leaves no more room than the page, it reads that many rows and no row past them, and ends with
586
+ * a `next` when it read them all.
537
587
  */
538
- const listCreated = Effect.fnUntraced(function* (store, reach, newest, page = {}, tally = { read: 0 }) {
588
+ const listCreated = /* @__PURE__ */ Effect.fnUntraced(function* (store, reach, newest, page = {}, tally = { read: 0 }) {
539
589
  const limit = listLimit(page);
590
+ const left = (tally.most ?? Infinity) - tally.read;
591
+ if (left <= 0) return pageAfter(page.after);
540
592
  const prefix = folderPrefix(reach);
593
+ const spent = left <= limit;
541
594
  const read = {
542
595
  collection: collections.folderCreated,
543
596
  prefix,
544
- limit: limit + 1
597
+ limit: spent ? left : limit + 1
545
598
  };
546
599
  if (page.after !== void 0) read.after = prefix + page.after;
547
600
  if (newest) read.reverse = true;
548
- const snapshot = yield* storeCall(() => store.read(catalogueScope, [read]));
549
- const rows = (snapshot.results[0] ?? []).slice(0, limit);
550
- tally.read += rows.length;
551
- const named = yield* Effect.forEach(rows, (row) => decodeRow(CreatedRow, row, `The created row '${row.id}'`));
552
- const { entries } = yield* readEntries(store, named.map(({ name }) => name));
601
+ const fetched = (yield* storeCall(() => store.read("git/repos", [read]))).results[0] ?? [];
602
+ tally.read += fetched.length;
603
+ const rows = fetched.slice(0, limit);
604
+ const named = yield* Effect.forEach(rows, (row) => createdName(store, row), { concurrency: readsAtOnce });
605
+ const listed = rows.flatMap((row, index) => {
606
+ const name = named[index];
607
+ return name === void 0 ? [] : [{
608
+ row,
609
+ name
610
+ }];
611
+ });
612
+ const { entries } = yield* readEntries(store, listed.map(({ name }) => name));
553
613
  const items = entries.flatMap(({ name, entry }, index) => {
554
- return entry !== void 0 && (rows[index]?.id ?? "").endsWith(`.${entry.internalId}`) && entry.deleted !== true ? [name] : [];
614
+ return entry !== void 0 && (listed[index]?.row.id ?? "").endsWith(`.${entry.internalId}`) && entry.deleted !== true ? [name] : [];
555
615
  });
556
616
  const last = rows.at(-1);
557
- return (snapshot.results[0]?.length ?? 0) > limit && last !== void 0 ? {
617
+ return last !== void 0 && (spent ? fetched.length === left : fetched.length > limit) ? {
558
618
  items,
559
619
  next: last.id.slice(prefix.length)
560
620
  } : { items };
561
621
  });
562
622
  /** How many of a page's records a signed-out list reads at once, in the page's order. */
563
623
  const readsAtOnce = 16;
624
+ /** The repo a created or dated row stands for: its ID ends in its `createdKey`, and so its internal ID. */
625
+ const createdRepo = (row) => {
626
+ const internalId = row.id.slice(row.id.lastIndexOf(".") + 1);
627
+ return isInternalId(internalId) ? internalId : void 0;
628
+ };
629
+ /** Whether `name` is under the folder a created row's ID begins with, before its last `:`. */
630
+ const inRowFolder = (row, name) => foldersOf(name).includes(row.id.slice(0, row.id.lastIndexOf(":")));
631
+ /**
632
+ * A created row's name, or, where the row is unreadable, its record's name while it's live and
633
+ * still under the row's folder, so a repo renamed out of the folder isn't listed in it.
634
+ */
635
+ const createdName = (store, row) => Effect.flatMap(decodeDerivedRow(CreatedRow, row), (created) => {
636
+ const internalId = createdRepo(row);
637
+ if (created !== void 0) return Effect.succeed(created.name);
638
+ if (internalId === void 0) return Effect.succeed(void 0);
639
+ return Effect.map(nameOf(store, internalId), (name) => name !== void 0 && inRowFolder(row, name) ? name : void 0);
640
+ });
564
641
  /**
565
642
  * The name a public index row stands for while its record agrees: live, public, and holding the
566
643
  * row's name. A flip to private, a rename and a delete each hide the row from their record's own
567
644
  * commit, before the projection that deletes it, and so does a stale row a lost projection left.
568
645
  */
569
- const publicName = Effect.fnUntraced(function* (store, row, created) {
570
- const name = created ? (yield* decodeRow(CreatedRow, row, `The public created row '${row.id}'`)).name : row.id;
571
- const internalId = created ? row.id.slice(row.id.lastIndexOf(".") + 1) : (yield* decodeRow(ForkRow, row, `The public row '${row.id}'`)).internalId;
572
- if (!isInternalId(internalId)) return [];
646
+ const publicName = /* @__PURE__ */ Effect.fnUntraced(function* (store, row, created) {
647
+ const name = created ? (yield* decodeDerivedRow(CreatedRow, row))?.name : row.id;
648
+ const internalId = created ? createdRepo(row) : (yield* decodeDerivedRow(ForkRow, row))?.internalId ?? (yield* entryOf(store, row.id))?.internalId;
649
+ if (internalId === void 0 || !isInternalId(internalId)) return [];
573
650
  const record = (yield* recordAt(store, internalId))?.record;
574
- return record !== void 0 && record.deleted !== true && record.public && record.name === name ? [name] : [];
651
+ if (record === void 0 || record.deleted === true || !record.public) return [];
652
+ return (name === void 0 ? inRowFolder(row, record.name) : record.name === name) ? [record.name] : [];
575
653
  });
576
654
  /**
577
655
  * Public repos under `prefix` for a signed-out list (#209), by name or in create order, from the
578
656
  * public index alone, so a page reads no private repo's row however many there are: the page's
579
657
  * rows and one past it, then each row's record, which `publicName` checks. A row the check leaves
580
658
  * out takes no place: the page reads on past it, so its items and `next` are those of an index
581
- * without it. In create order `prefix` is `''` or an owner's.
659
+ * without it. In create order `prefix` is `''` or an owner's. Each index row it reads adds to
660
+ * `tally`, and once it has read `tally.most` it ends there, with a `next` past the last row read.
582
661
  */
583
- const listPublic = Effect.fnUntraced(function* (store, prefix, order, page = {}) {
662
+ const listPublic = /* @__PURE__ */ Effect.fnUntraced(function* (store, prefix, order, page = {}, tally = { read: 0 }) {
584
663
  const limit = listLimit(page);
585
664
  const created = order === "oldest" || order === "newest";
586
665
  const kept = created ? folderPrefix(prefix) : "";
587
666
  const shown = [];
588
667
  const shownOf = (row) => publicName(store, row, created);
589
668
  let after = page.after === void 0 ? void 0 : kept + page.after;
669
+ let ended = false;
590
670
  while (shown.length <= limit) {
591
- const wanted = limit + 1 - shown.length;
671
+ const room = (tally.most ?? Infinity) - tally.read;
672
+ if (room <= 0) break;
673
+ const wanted = Math.min(limit + 1 - shown.length, room);
592
674
  const read = {
593
675
  collection: created ? collections.publicCreated : collections.publicNames,
594
676
  prefix: created ? kept : prefix,
@@ -597,17 +679,20 @@ const listPublic = Effect.fnUntraced(function* (store, prefix, order, page = {})
597
679
  if (after !== void 0) read.after = after;
598
680
  if (order === "newest" || order === "nameDescending") read.reverse = true;
599
681
  const rows = (yield* storeCall(() => store.read("git/repos", [read]))).results[0] ?? [];
682
+ tally.read += rows.length;
600
683
  const names = yield* Effect.forEach(rows, shownOf, { concurrency: readsAtOnce });
601
684
  for (const [index, row] of rows.entries()) for (const name of names[index] ?? []) shown.push({
602
685
  name,
603
686
  next: row.id.slice(kept.length)
604
687
  });
605
688
  const last = rows.at(-1);
606
- if (rows.length < wanted || last === void 0) break;
689
+ ended = rows.length < wanted || last === void 0;
690
+ if (ended || last === void 0) break;
607
691
  after = last.id;
608
692
  }
609
693
  const items = shown.slice(0, limit);
610
- const next = shown.length > limit ? items.at(-1)?.next : void 0;
694
+ const spent = !ended && after !== void 0 ? after.slice(kept.length) : void 0;
695
+ const next = shown.length > limit ? items.at(-1)?.next : spent;
611
696
  const names = items.map((one) => one.name);
612
697
  return next === void 0 ? { items: names } : {
613
698
  items: names,
@@ -619,7 +704,7 @@ const listPublic = Effect.fnUntraced(function* (store, prefix, order, page = {})
619
704
  * rows alone: `''` reads every fork, and a folder only those whose names it holds. The caller
620
705
  * reads each one's record, and leaves out those it may not read.
621
706
  */
622
- const forksCreated = Effect.fnUntraced(function* (store, source, folder, limit, after) {
707
+ const forksCreated = /* @__PURE__ */ Effect.fnUntraced(function* (store, source, folder, limit, after) {
623
708
  const prefix = forkFolderPrefix(source, folder);
624
709
  const read = {
625
710
  collection: collections.forksCreated,
@@ -629,15 +714,17 @@ const forksCreated = Effect.fnUntraced(function* (store, source, folder, limit,
629
714
  };
630
715
  if (after !== void 0) read.after = prefix + after;
631
716
  const rows = (yield* storeCall(() => store.read("git/repos", [read]))).results[0] ?? [];
632
- const forks = yield* Effect.forEach(rows, (row) => Effect.map(decodeRow(ForkRow, row, `The fork's dated row '${row.id}'`), ({ internalId }) => ({
633
- internalId,
634
- key: row.id.slice(prefix.length)
635
- })));
636
- const result = { forks };
637
- const last = forks.at(-1);
638
- if (rows.length >= limit && last !== void 0) result.next = last.key;
717
+ const result = { forks: (yield* Effect.forEach(rows, (row) => Effect.map(decodeDerivedRow(ForkRow, row), (fork) => {
718
+ const internalId = fork?.internalId ?? createdRepo(row);
719
+ return internalId === void 0 ? [] : [{
720
+ internalId,
721
+ key: row.id.slice(prefix.length)
722
+ }];
723
+ }))).flat() };
724
+ const last = rows.at(-1);
725
+ if (rows.length >= limit && last !== void 0) result.next = last.id.slice(prefix.length);
639
726
  return result;
640
727
  });
641
728
  /** A repo's `createdKey`, from its record now: `undefined` for an ID of none. */
642
729
  const createdKeyOf = (store, internalId) => Effect.map(recordAt(store, internalId), (read) => read === void 0 ? void 0 : createdKey(internalId, read.record.createdAt));
643
- export { checkChurn, createdKey, createdKeyOf, decodeRecord, entryOf, folderPrefix, foldersOf, forkFolderPrefix, forkKey, forkOf, forksCreated, heldName, heldNameAt, hostRecordOf, internalIdOf, isCreatedKey, lands, listCreated, listLimit, listNames, listPublic, nameOf, namedRecordOf, project, projectionOf, readEntries, reconcile, recordAt, redirectOf, resolveRepo, upstreamOf };
730
+ export { checkChurn, createdKey, createdKeyOf, decodeRecord, entryOf, folderPrefix, foldersOf, forkFolderPrefix, forkKey, forkOf, forkedFrom, forksCreated, heldName, heldNameAt, hostRecordOf, internalIdOf, isCreatedKey, lands, listCreated, listLimit, listNames, listPublic, nameOf, namedRecordOf, pinOf, project, projectionOf, readEntries, reconcile, recordAt, redirectOf, releaseHold, resolveRepo, upstreamOf };
@@ -18,7 +18,7 @@ var Uncounted = class {
18
18
  /** A run with no call scope, for `reason`. */
19
19
  const uncounted = (reason) => new Uncounted(reason);
20
20
  /** A run that makes no store or bucket call at all: an interrupt, a scope's close, a timer, a log. */
21
- const noCall = uncounted("makes no store or bucket call");
21
+ const noCall = /* @__PURE__ */ uncounted("makes no store or bucket call");
22
22
  const scoped = (effect, crossing) => crossing instanceof Uncounted ? effect : inCallScope(effect, crossing);
23
23
  const optionsOf = (signal) => signal === void 0 ? {} : { signal };
24
24
  /** `effect` as a Promise, run in `crossing`. */
@@ -36,8 +36,6 @@ const exitOn = (runtime, effect, crossing, signal) => runtime.runPromiseExit(sco
36
36
  const forkIn = (effect, crossing) => Effect.runFork(scoped(effect, crossing));
37
37
  /** `effect`, which must not wait, run now in `crossing`. */
38
38
  const syncIn = (effect, crossing) => Effect.runSync(scoped(effect, crossing));
39
- /** `effect`'s `Exit`, which must not wait, run now in `crossing`. */
40
- const syncExitIn = (effect, crossing) => Effect.runSyncExit(scoped(effect, crossing));
41
39
  /**
42
40
  * A runner of Effects as Promises in `context`, the whole of it, a call's scope among it: for a
43
41
  * caller that hands its own context on, such as a memory budget's or an allotment's waits.
@@ -66,4 +64,4 @@ const untilAborted = (effect, signal) => {
66
64
  });
67
65
  return Effect.raceFirst(effect, aborted);
68
66
  };
69
- export { Uncounted, exitIn, exitOn, forkIn, noCall, readableIn, resultIn, runIn, runJobTry, runnerIn, syncExitIn, syncIn, uncounted, untilAborted };
67
+ export { Uncounted, exitIn, exitOn, forkIn, noCall, readableIn, resultIn, runIn, runJobTry, runnerIn, syncIn, uncounted, untilAborted };
@@ -1,2 +1,13 @@
1
1
  import "../contracts/promises.mjs";
2
- import "effect/Effect";
2
+ import { GitError } from "../contracts/result.mjs";
3
+ import * as Effect from "effect/Effect";
4
+ /**
5
+ * Seals list cursors, so a cursor names nothing its caller may not read, such as a row the list
6
+ * skipped: AES-GCM under the server's key in `git/repos`, with a fresh nonce for each cursor and the
7
+ * list's `bound` as its additional data. A cursor opens only on the list it was sealed for.
8
+ */
9
+ export interface CursorSeal {
10
+ readonly seal: (bound: string, text: string) => Effect.Effect<string, GitError>;
11
+ /** The text `cursor` was sealed over for `bound`, or `undefined` for any other text. */
12
+ readonly open: (bound: string, cursor: string) => Effect.Effect<string | undefined, GitError>;
13
+ }
@@ -1,8 +1,9 @@
1
- import { decodeRow, fail, storeCall } from "./errors.mjs";
1
+ import { fail } from "../contracts/result.mjs";
2
+ import { decodeRow, storeCall } from "./errors.mjs";
2
3
  import { bytesFromBase64Url, randomText, toBase64Url, utf8Of } from "./random.mjs";
3
4
  import { catalogueScope, collections } from "./scopes.mjs";
4
- import * as Effect from "effect/Effect";
5
5
  import * as Schema from "effect/Schema";
6
+ import * as Effect from "effect/Effect";
6
7
  import * as Semaphore from "effect/Semaphore";
7
8
  // src/store/cursor-seal.ts
8
9
  /** The row in `git/repos` that holds the key every list cursor is sealed with. */
@@ -10,17 +11,17 @@ const cursorKeyRow = {
10
11
  collection: collections.keys,
11
12
  id: "cursor"
12
13
  };
13
- const CursorKeyRow = Schema.Struct({ key: Schema.String });
14
+ const CursorKeyRow = /* @__PURE__ */ Schema.Struct({ key: Schema.String });
14
15
  /** AES-GCM's nonce, fresh for each cursor, and its tag, in bytes. */
15
16
  const nonceBytes = 12;
16
17
  /** The key's 32 bytes as the row holds them, or `DATA_LOSS` for a row that holds none. */
17
- const keyOf = Effect.fnUntraced(function* (row) {
18
+ const keyOf = /* @__PURE__ */ Effect.fnUntraced(function* (row) {
18
19
  const held = yield* decodeRow(CursorKeyRow, row, "The server's cursor key");
19
20
  const bytes = bytesFromBase64Url(held.key);
20
21
  if (bytes?.length !== 32) return yield* fail("DATA_LOSS", "The server's cursor key is unreadable");
21
22
  return bytes;
22
23
  });
23
- const readKey = Effect.fnUntraced(function* (store) {
24
+ const readKey = /* @__PURE__ */ Effect.fnUntraced(function* (store) {
24
25
  const row = (yield* storeCall(() => store.read(catalogueScope, [{ ...cursorKeyRow }]))).results[0]?.[0];
25
26
  return row === void 0 ? void 0 : yield* keyOf(row);
26
27
  });
@@ -28,7 +29,7 @@ const readKey = Effect.fnUntraced(function* (store) {
28
29
  * The server's cursor key: the row's, or one it makes and adds. Two servers that make one at once
29
30
  * both end with the key that was added first, since the second's add is refused and it reads again.
30
31
  */
31
- const loadKey = Effect.fnUntraced(function* (store) {
32
+ const loadKey = /* @__PURE__ */ Effect.fnUntraced(function* (store) {
32
33
  const held = yield* readKey(store);
33
34
  if (held !== void 0) return held;
34
35
  const made = randomText(32);
@@ -1,7 +1,7 @@
1
1
  import { GitError } from "../contracts/result.mjs";
2
- import { Row } from "@ref0/infra";
3
- import * as Effect from "effect/Effect";
2
+ import { Committed, Row } from "@ref0/infra";
4
3
  import "effect/Schema";
4
+ import * as Effect from "effect/Effect";
5
5
  /**
6
6
  * A store call, its refusal as Git's error: one of the two doors every call Git makes goes
7
7
  * through, with `bucketCall`, and every call a package built on Git makes, as `@ref0/github`'s