@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,52 +1,67 @@
1
+ import { fail, gitError } from "../contracts/result.mjs";
1
2
  import { openTreeBytes } from "../storage/budget.mjs";
2
- import { effectObjects, scopedReceive, walkObjects } from "../storage/calls.mjs";
3
+ import { objectsFace, scopedReceive, walkObjects } from "../storage/calls.mjs";
4
+ import { isUnindexedRead } from "../storage/index-visible.mjs";
3
5
  import { openTreesRefusal } from "../storage/push-allotment.mjs";
4
6
  import { isLoose } from "../storage/loose.mjs";
5
- import { indexRowKey, objectCollections } from "../storage/layout.mjs";
7
+ import { listedIds } from "../storage/listed-ids.mjs";
8
+ import { indexRowKey, isPackId, objectCollections } from "../storage/layout.mjs";
6
9
  import { noLfsPointers } from "../storage/lfs-pointers.mjs";
7
10
  import { isShallowRoot } from "../storage/links.mjs";
11
+ import { isAwaitingRepack } from "../storage/repack-backlog.mjs";
8
12
  import { allottedRows } from "../storage/allotted.mjs";
9
13
  import { gitObjectOf, objectOfRow, receivedRows } from "../storage/object-rows.mjs";
14
+ import { pruneClearedKey } from "../storage/prune.mjs";
15
+ import { abandonOwn } from "../storage/quarantine.mjs";
10
16
  import { QuarantineRow, decodeHeld } from "../storage/rows.mjs";
11
- import { decodeRow, fail, gitError, storeCall, thrownError } from "../store/errors.mjs";
17
+ import { bestEffort, decodeRow, storeCall } from "../store/errors.mjs";
12
18
  import { callScope } from "../store/call-count.mjs";
13
- import { runIn } from "../store/crossing.mjs";
14
- import { decodePacks } from "../store/git-store.mjs";
15
- import { WholeRepo, wholeRefs } from "../store/ref-rows.mjs";
19
+ import { decodePacks, gitStore } from "../store/git-store.mjs";
20
+ import { WholeRepo, refBytesOf, storesPeel, wholeRefs } from "../store/ref-rows.mjs";
16
21
  import { gitsOwnMove, hiddenUnder } from "../protocol/wire/lines.mjs";
17
- import { sightIn } from "./sight.mjs";
22
+ import { sliceOf } from "../protocol/wire/push-limits.mjs";
23
+ import { pushCounts } from "./events/seen.mjs";
24
+ import { refViewIn } from "./ref-view.mjs";
18
25
  import { appendEvents, decodeOutbox, firstSeq, outboxReads, repoEnvelope } from "../store/outbox.mjs";
19
26
  import { MirrorRow, PrunedMark, mirrorJobName } from "../store/records.mjs";
20
27
  import { decodeTimes, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
21
28
  import { advanceRow } from "../store/queue-jobs.mjs";
22
29
  import { liveReservations, reservedTarget } from "../store/reservations.mjs";
23
30
  import { settleName } from "../store/settle.mjs";
24
- import { collections, newChangeId, prunedKey, pushedKey, pushedUnder, repoScope } from "../store/scopes.mjs";
25
- import { headOf, indexJobs, openKeyed, openRepo } from "./access.mjs";
31
+ import { collections, newChangeId, prunedKey, pushedKey, pushedUnder, reachedKey, repoScope } from "../store/scopes.mjs";
32
+ import { headOf, indexJobs, openKeyed, openRepo, refIndexJobs, repoAccess } from "./access.mjs";
26
33
  import { kindsOf } from "./ancestry.mjs";
27
34
  import { savedPushRow } from "./hooks/post-receive.mjs";
28
35
  import { runPreReceive } from "./hooks/pre-receive.mjs";
29
- import { changesOf } from "./rules/changes.mjs";
36
+ import { Changes } from "./changes.mjs";
37
+ import { batchOf, readerOf } from "./rules/changes.mjs";
30
38
  import { commitChangesOf, coveredTips } from "./rules/commit-changes.mjs";
31
- import { gitsOwnRef, runPushRules, unseenRef } from "./rules/check.mjs";
39
+ import { gitsOwnRef, pushRulesFor, runPushRules, unseenRef } from "./rules/check.mjs";
32
40
  import { checking } from "./rules/context.mjs";
33
41
  import { changedWhileChecked, factsHeld, tipsOf } from "./rules/facts.mjs";
34
- import { decidePush } from "./push-decide.mjs";
42
+ import { clearsMark, decidePush, otherWritesProblem, pushOptionsProblem } from "./push-decide.mjs";
35
43
  import { heldReceipt, receiptReads, receiptWrites, refsAnswer, refsKept, withJobs } from "./receipts.mjs";
36
44
  import { SealedObjects, viewOf } from "./view.mjs";
37
45
  import { ownWriter, ownWritesOf } from "./own-writes.mjs";
46
+ import { ensureRepack } from "./repack.mjs";
38
47
  import { publishable, unpublished } from "./publish.mjs";
39
- import { peeledOf } from "../storage/wants.mjs";
48
+ import { peeledAll, peeledOf } from "../storage/wants.mjs";
49
+ import { CoreParts, ObjectsParts } from "./parts.mjs";
50
+ import { Authorize, check } from "../contracts/authorize.mjs";
51
+ import { read } from "./objects/objects.mjs";
40
52
  import { checkWrites } from "@ref0/infra";
41
53
  import * as Effect from "effect/Effect";
54
+ import * as Clock$1 from "effect/Clock";
42
55
  import * as Result from "effect/Result";
56
+ import * as Exit from "effect/Exit";
57
+ import * as Equal from "effect/Equal";
43
58
  // src/core/push.ts
44
59
  /**
45
60
  * The push decide reads every ref, private or not: a move's `from`, a folder conflict and a
46
61
  * topic's reservation are checked against the repo as it is. What it answers the caller about a
47
62
  * name it can't write is `unseenRef`'s, the same whatever is there.
48
63
  */
49
- const pushWhole = WholeRepo.mint();
64
+ const pushWhole = /* @__PURE__ */ WholeRepo.mint();
50
65
  const packsRead = { collection: collections.packs };
51
66
  const refsRead = { collection: collections.refs };
52
67
  const timesRead = { collection: collections.stats };
@@ -55,7 +70,6 @@ const cruftRead = {
55
70
  collection: objectCollections.cruft,
56
71
  limit: 65
57
72
  };
58
- const mirrorsRead = { collection: collections.mirrors };
59
73
  /**
60
74
  * A queue publish refused for `entries`, whose heads would publish commits their own callers may
61
75
  * not: each fails alone, and the queue builds the rest again.
@@ -88,8 +102,8 @@ const refuseQueued = (request, refusals, by) => {
88
102
  const first = refusals.find((error) => error !== void 0);
89
103
  return first === void 0 ? Effect.void : Effect.fail(first);
90
104
  };
91
- /** The edits `sight` refuses: each name its caller can't write, as for a name with no ref there. */
92
- const unseenOf = (sight, edits) => new Map(sight.whole ? [] : edits.flatMap((edit) => (edit.from === null ? sight.creates(edit.ref) : sight.sees(edit.ref)) ? [] : [[edit.ref, unseenRef(edit.ref)]]));
105
+ /** The edits `refView` refuses: each name its caller can't write, as for a name with no ref there. */
106
+ const unseenOf = (refView, edits) => new Map(refView.whole ? [] : edits.flatMap((edit) => (edit.from === null ? refView.creates(edit.ref) : refView.sees(edit.ref)) ? [] : [[edit.ref, unseenRef(edit.ref)]]));
93
107
  /**
94
108
  * One fence over `fences`, each caller's, in the push's final read: their reads together, and each
95
109
  * check on its own results. A queue's publish hears every credential that ended, by its place.
@@ -115,16 +129,18 @@ const fenceAll = (request, fences) => {
115
129
  };
116
130
  };
117
131
  const moved = { queueMoved: true };
118
- /** A queue's push whose repo moved past the version it planned at: `UNAVAILABLE`. */
132
+ /**
133
+ * A queue's push whose repo moved past the version it planned at, or a build's whose fenced row
134
+ * changed: `UNAVAILABLE`.
135
+ */
119
136
  const queueMoved = (repo) => gitError("UNAVAILABLE", `'${repo}' moved while its merge queue wrote`, {
120
137
  hint: "Try again",
121
138
  cause: moved
122
139
  });
123
- const atomicHint = "Another ref in this atomic push was refused";
124
140
  /** A queue push's refused ref, the cause's before the rest's, so its writes commit with none. */
125
141
  const refusalOf = (updated) => {
126
142
  const refused = updated.updates.flatMap((update) => update.kind === "rejected" ? [update.error] : []);
127
- return refused.find((error) => error.hint !== atomicHint) ?? refused[0];
143
+ return refused.find((error) => error.context?.reason !== "atomic-partner") ?? refused[0];
128
144
  };
129
145
  /** Whether a push failed only since its repo moved past the queue's plan. */
130
146
  const isQueueMoved = (error) => error.cause === moved;
@@ -175,12 +191,12 @@ const markOf = (rows) => {
175
191
  * caller who can't read the repo gets the read's answer, as for a name with no repo, before a byte
176
192
  * of the pack is read: only a caller who can read it is told a push is refused.
177
193
  */
178
- const firstRead = (core, caller, operation, internalId) => openRepo(core, caller, {
194
+ const firstRead = (caller, operation, internalId) => openRepo(caller, {
179
195
  kind: "read",
180
196
  repo: operation.repo
181
197
  }, [packsRead, prunedKey], internalId);
182
198
  /** `firstRead` for a keyed push: `undefined` once `missed`'s repo moved, as `openKeyed` says. */
183
- const keyedRead = (core, caller, operation, missed, internalId) => openKeyed(core, caller, {
199
+ const keyedRead = (caller, operation, missed, internalId) => openKeyed(caller, {
184
200
  kind: "read",
185
201
  repo: operation.repo
186
202
  }, [packsRead, prunedKey], missed, internalId);
@@ -189,14 +205,10 @@ const keyedRead = (core, caller, operation, missed, internalId) => openKeyed(cor
189
205
  * received against, its default branch, whose move rebuilds the ready shallow pack, and its
190
206
  * `pruned` mark.
191
207
  */
192
- const listedFor = Effect.fnUntraced(function* (core, request, operation, resolved) {
193
- const { caller, source } = request;
194
- const repo = {
195
- id: resolved.name,
196
- public: resolved.record.public,
197
- internalId: resolved.internalId
198
- };
199
- if (request.queued === void 0) yield* core.authorize({
208
+ const listedFor = /* @__PURE__ */ Effect.fnUntraced(function* (request, operation, resolved) {
209
+ const { caller } = request;
210
+ const repo = repoAccess(resolved);
211
+ if (request.queued === void 0) yield* check({
200
212
  caller,
201
213
  operation,
202
214
  repo
@@ -208,8 +220,8 @@ const listedFor = Effect.fnUntraced(function* (core, request, operation, resolve
208
220
  packs
209
221
  };
210
222
  const mark = yield* markOf(resolved.snapshot.results[2] ?? []);
211
- const views = decidingFor(request).map((one) => viewOf(core, one, resolved, source));
212
- const [view = viewOf(core, caller, resolved, source)] = views;
223
+ const views = yield* Effect.forEach(decidingFor(request), (one) => viewOf(one, resolved, request.as));
224
+ const [view = yield* viewOf(caller, resolved, request.as)] = views;
213
225
  return {
214
226
  listed,
215
227
  defaultBranch: headOf(resolved.record.defaultBranch),
@@ -225,21 +237,28 @@ const listedFor = Effect.fnUntraced(function* (core, request, operation, resolve
225
237
  * caller sees, read after `authorize` let the caller in, at a version of their own, which the
226
238
  * push's objects read at too.
227
239
  */
228
- const seenRefsOf = Effect.fnUntraced(function* (core, view, listed) {
240
+ const seenRefsOf = /* @__PURE__ */ Effect.fnUntraced(function* (view, listed) {
241
+ const core = yield* CoreParts;
229
242
  if (!(yield* view.narrowed)) return {
230
243
  listed,
231
244
  refs: /* @__PURE__ */ new Map()
232
245
  };
233
- const { snapshot } = yield* readRecord(core.store, listed.repo, [refsRead, packsRead]);
234
- const packs = yield* decodePacks(snapshot.results[2] ?? []);
235
- const refs = yield* view.refs(snapshot.results[1] ?? []);
246
+ const { snapshot } = yield* readRecord(core.store, listed.repo, [
247
+ refsRead,
248
+ packsRead,
249
+ indexRowKey
250
+ ]);
251
+ const [, refRows = [], packRows = [], indexRows = []] = snapshot.results;
252
+ const packs = yield* decodePacks(packRows);
253
+ const refs = yield* view.refs(refRows);
236
254
  return {
237
255
  listed: {
238
256
  ...listed,
239
257
  version: snapshot.version,
240
258
  packs
241
259
  },
242
- refs
260
+ refs,
261
+ index: indexRows[0]?.value
243
262
  };
244
263
  });
245
264
  /**
@@ -267,13 +286,9 @@ const pushedOf = (objects, listed, received) => {
267
286
  * Whether the push brings commit `oid`, for the file rules' walk: its own object, read as `pushed`
268
287
  * reads one, its bytes let go unread. A read that fails throws, so the walk trusts nothing.
269
288
  */
270
- const broughtCommit = (pushed, scope) => async (oid) => {
271
- const object = await runIn(Effect.mapError(pushed({ oid }), thrownError), scope);
272
- await object?.bytes.cancel().catch(() => void 0);
273
- return object?.type === "commit";
274
- };
289
+ const broughtCommit = (pushed) => (oid) => Effect.flatMap(pushed({ oid }), (object) => Effect.as(Effect.promise(() => object?.bytes.cancel().catch(() => void 0) ?? Promise.resolve()), object?.type === "commit"));
275
290
  /** The refs the repo mirrors, among `rows` of `mirrors`: each one an active mirror names. */
276
- const activeMirrors = Effect.fnUntraced(function* (rows) {
291
+ const activeMirrors = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
277
292
  const active = /* @__PURE__ */ new Set();
278
293
  for (const row of rows) if ((yield* decodeRow(MirrorRow, row, `Mirror '${row.id}'`)).state === "active") active.add(row.id);
279
294
  return active;
@@ -309,7 +324,25 @@ const withReceivedRows = (objects, received) => {
309
324
  const row = rows.get(input.oid);
310
325
  return row === void 0 ? objects.read(listed, input) : Effect.map(objectOfRow(row), gitObjectOf);
311
326
  },
312
- objects: (listed, input) => Effect.gen(function* () {
327
+ headers: Effect.fnUntraced(function* (listed, input) {
328
+ const answer = /* @__PURE__ */ new Map();
329
+ const stored = input.oids.filter((oid) => !rows.has(oid));
330
+ for (const oid of input.oids) {
331
+ const row = rows.get(oid);
332
+ if (row === void 0) continue;
333
+ const object = yield* objectOfRow(row);
334
+ answer.set(oid, {
335
+ type: object.type,
336
+ size: object.bytes.byteLength
337
+ });
338
+ }
339
+ if (stored.length > 0) for (const [oid, header] of yield* objects.headers(listed, {
340
+ ...input,
341
+ oids: stored
342
+ })) answer.set(oid, header);
343
+ return answer;
344
+ }),
345
+ objects: Effect.fnUntraced(function* (listed, input) {
313
346
  const asked = [...new Set(input.oids)];
314
347
  const [first] = asked;
315
348
  if (first === void 0 || !asked.some((oid) => rows.has(oid))) return yield* objects.objects(listed, {
@@ -331,14 +364,50 @@ const withReceivedRows = (objects, received) => {
331
364
  };
332
365
  };
333
366
  /**
367
+ * The rows a build's write is fenced on, the one list of them (Q885): the repo's `pruned` mark, as
368
+ * its links read objects a prune may drop; its target's queue row, which names its open holds, and
369
+ * each of their rows, `holds`, which its lift reads; the target's ref, its tip, which a land links
370
+ * onto and a merge at the build compares; its candidate's row; and each entry it links, found or
371
+ * not. An entry's notes are fixed by its row: its `meta` and its report are each written only with
372
+ * a put of an entry's row that names them, which `pushPlan` holds. A key row (`latest`, `merged`)
373
+ * isn't one: a build reads none. The build takes each one's value from the read its plan made, and
374
+ * `finalRead` reads them again, so the write commits only while every one holds it, whatever else
375
+ * the repo's other writes moved.
376
+ */
377
+ const buildFence = (build) => [
378
+ prunedKey,
379
+ {
380
+ collection: collections.queueTargets,
381
+ id: build.target
382
+ },
383
+ ...build.holds.map((id) => ({
384
+ collection: collections.queueHolds,
385
+ id
386
+ })),
387
+ {
388
+ collection: collections.refs,
389
+ id: build.target
390
+ },
391
+ {
392
+ collection: collections.queueCandidates,
393
+ id: build.candidate
394
+ },
395
+ ...build.entries.map((id) => ({
396
+ collection: collections.queueEntries,
397
+ id
398
+ }))
399
+ ];
400
+ /**
334
401
  * The decide's read, one of the repo's scope: its refs, its outbox, the push's own `quarantine` row
335
- * if it has one, its key's receipt if it has a key, the queue's row of each branch in `branches`,
402
+ * if it has one, its key's receipt if it has a key, the mirror of each ref in `touched`, the
403
+ * queue's row of each branch in `branches`,
336
404
  * with the live reservation each holds, and the caller's grant fence, checked on what it read. A revoke after it moves the version, as
337
405
  * does a write with the same key that commits first. A prune that dropped objects since the first
338
406
  * read moved the `pruned` mark: the push may name one it dropped, so unless its key's receipt
339
- * answers, it fails, to be sent again (Q270).
407
+ * answers, it fails, to be sent again (Q270). `changed`: whether a row of a build's fence,
408
+ * `unchanged`, holds another value than its plan read.
340
409
  */
341
- const finalRead = Effect.fnUntraced(function* (store, repo, fence, received, kept, mark, branches) {
410
+ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fence, received, kept, mark, branches, touched, guard, unchanged = []) {
342
411
  const own = received?.quarantine === void 0 ? [] : [received.quarantine];
343
412
  const keyed = receiptReads(kept);
344
413
  const targets = branches.map((id) => ({
@@ -352,21 +421,30 @@ const finalRead = Effect.fnUntraced(function* (store, repo, fence, received, kep
352
421
  }));
353
422
  const { record, snapshot } = yield* readRecord(store, repo.internalId, [
354
423
  refsRead,
355
- mirrorsRead,
356
424
  ...outboxReads,
357
425
  packsRead,
358
426
  prunedKey,
359
427
  timesRead,
360
428
  cruftRead,
361
429
  indexRowKey,
430
+ reachedKey,
362
431
  ...own,
363
432
  ...keyed,
364
433
  ...targets,
365
- ...fence.reads
434
+ ...fence.reads,
435
+ ...guard?.reads ?? [],
436
+ ...unchanged.map(({ collection, id }) => ({
437
+ collection,
438
+ id
439
+ })),
440
+ ...touched.map((id) => ({
441
+ collection: collections.mirrors,
442
+ id
443
+ }))
366
444
  ], rowCounts);
367
445
  if (record === void 0 || record.deleted === true) return yield* fail("NOT_FOUND", `No repo '${repo.name}'`);
368
- const [, refRows = [], mirrorRows = [], headRows = [], cursorRows = [], packRows = [], ...more] = snapshot.results;
369
- const [markRows = [], timeRows = [], cruftRows = [], indexRows = [], ...rest] = more;
446
+ const [, refRows = [], headRows = [], cursorRows = [], packRows = [], ...more] = snapshot.results;
447
+ const [markRows = [], timeRows = [], cruftRows = [], indexRows = [], reachedRows = [], ...rest] = more;
370
448
  const receipt = yield* heldReceipt(rest.slice(own.length, own.length + keyed.length), kept);
371
449
  if (receipt === void 0 && (yield* markOf(markRows)) !== mark) return yield* fail("UNAVAILABLE", "The repo was pruned during the push", { hint: "Push again" });
372
450
  const targeted = rest.slice(own.length + keyed.length, own.length + keyed.length + targets.length);
@@ -376,7 +454,14 @@ const finalRead = Effect.fnUntraced(function* (store, repo, fence, received, kep
376
454
  const reservation = live[index];
377
455
  return reservation === void 0 ? [] : [[branch, reservedTarget(branch, reservation)]];
378
456
  }));
379
- const fenced = rest.slice(own.length + keyed.length + targets.length);
457
+ const fencedAt = own.length + keyed.length + targets.length;
458
+ const fenced = rest.slice(fencedAt, fencedAt + fence.reads.length);
459
+ const guardAt = fencedAt + fence.reads.length;
460
+ const guardedAt = guardAt + (guard?.reads.length ?? 0);
461
+ if (guard !== void 0) yield* guard.check(rest.slice(guardAt, guardedAt));
462
+ const now = rest.slice(guardedAt, guardedAt + unchanged.length);
463
+ const mirrorRows = rest.slice(guardedAt + unchanged.length).flat();
464
+ const changed = unchanged.some((row, at) => !Equal.equals(row.value, now[at]?.[0]?.value));
380
465
  const packs = yield* decodePacks(packRows);
381
466
  const times = yield* decodeTimes(timeRows);
382
467
  const [ownRow] = own.length === 0 ? [] : rest[0] ?? [];
@@ -391,7 +476,10 @@ const finalRead = Effect.fnUntraced(function* (store, repo, fence, received, kep
391
476
  const read = {
392
477
  version: snapshot.version,
393
478
  refs,
394
- head: headOf(record.defaultBranch)
479
+ refBytes: refBytesOf(refRows),
480
+ head: headOf(record.defaultBranch),
481
+ record,
482
+ marked: reachedRows.length > 0
395
483
  };
396
484
  const at = {
397
485
  repo: repo.internalId,
@@ -424,7 +512,8 @@ const finalRead = Effect.fnUntraced(function* (store, repo, fence, received, kep
424
512
  times,
425
513
  queued,
426
514
  reserved,
427
- indexRow
515
+ indexRow,
516
+ changed
428
517
  };
429
518
  });
430
519
  const settingsOf = (record) => ({
@@ -432,32 +521,10 @@ const settingsOf = (record) => ({
432
521
  public: record.public,
433
522
  defaultBranch: record.defaultBranch
434
523
  });
435
- /** `objects`' batches as the engine's `ReadObjects`, over `listed`, each run in `scope`. */
436
- const batchOf = (objects, listed, scope) => (input) => runIn(Effect.match(objects.objects(listed, input), {
437
- onSuccess: (value) => ({
438
- kind: "success",
439
- value
440
- }),
441
- onFailure: (error) => ({
442
- kind: "error",
443
- error
444
- })
445
- }), scope);
446
- /** `objects`' reads as the engine's `ReadObject`, over `listed`, each run in `scope`. */
447
- const readerOf = (objects, listed, scope) => (input) => runIn(Effect.match(objects.read(listed, input), {
448
- onSuccess: (value) => ({
449
- kind: "success",
450
- value
451
- }),
452
- onFailure: (error) => ({
453
- kind: "error",
454
- error
455
- })
456
- }), scope);
457
524
  /** The rules, then `hooks.preReceive`, once, at the first read the push decides on. */
458
- const runChecks = Effect.fnUntraced(function* (checks, input, facts) {
525
+ const runChecks = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, facts) {
459
526
  const context = checking(input);
460
- const ruled = yield* builtInAfter(checks, input, yield* runPushRules(checks, input, context));
527
+ const ruled = yield* claimedAfter(checks, input, yield* runPushRules(checks, input, context));
461
528
  const whole = yield* runPreReceive(checks.reports, checks.preReceive, context, {
462
529
  atomic: input.atomic,
463
530
  updates: ruled.updates,
@@ -479,17 +546,21 @@ const runChecks = Effect.fnUntraced(function* (checks, input, facts) {
479
546
  * hook refuses, on a ref none refused before, is told by its place, and the push fails. Passed, the
480
547
  * answer is the first caller's, with the files allowed and the rules lifted for any of them.
481
548
  */
482
- const checkAll = Effect.fnUntraced(function* (checks, request, input, facts, authorizeAs) {
549
+ const checkAll = /* @__PURE__ */ Effect.fnUntraced(function* (checks, request, input, facts, authorizeAs) {
483
550
  if (request.queued === void 0) return yield* runChecks(checks, input, facts);
484
551
  const each = [];
485
- for (const caller of request.queued.callers) each.push(yield* runChecks(checks, {
486
- ...input,
487
- caller,
488
- authorize: authorizeAs(caller)
489
- }, facts));
490
- const refusals = each.map((one) => one.whole ?? [...one.refused].find(([ref]) => !input.refused.has(ref))?.[1]);
491
- const retried = refusals.find((error) => error !== void 0 && retriedCodes.has(error.code));
492
- if (retried !== void 0) return yield* Effect.fail(retried);
552
+ const refusals = [];
553
+ for (const caller of request.queued.callers) {
554
+ const one = yield* runChecks(checks, {
555
+ ...input,
556
+ caller,
557
+ authorize: authorizeAs(caller)
558
+ }, facts);
559
+ const refusal = one.whole ?? [...one.refused].find(([ref]) => !input.refused.has(ref))?.[1];
560
+ if (refusal !== void 0 && retriedCodes.has(refusal.code)) return yield* Effect.fail(refusal);
561
+ each.push(one);
562
+ refusals.push(refusal);
563
+ }
493
564
  yield* refuseQueued(request, refusals, "rules");
494
565
  const union = (pick) => {
495
566
  const merged = /* @__PURE__ */ new Map();
@@ -508,25 +579,28 @@ const checkAll = Effect.fnUntraced(function* (checks, request, input, facts, aut
508
579
  bypassed: union((one) => one.bypassed)
509
580
  };
510
581
  });
511
- /** The rules' answer, with each ref the server's built-in check refuses among the rest. */
512
- const builtInAfter = Effect.fnUntraced(function* (checks, input, ruled) {
513
- const { builtIn } = checks;
514
- if (builtIn === void 0) return ruled;
515
- const refused = yield* builtIn({
516
- updates: ruled.updates.filter((update) => !ruled.refused.has(update.ref)),
517
- objects: input.objects
518
- });
582
+ /**
583
+ * The rules' answer, with the refs the claimed checks refuse among the rest: each in turn, by band
584
+ * then claim name, on the refs none before it refused, so a ref's first refusal is its answer.
585
+ */
586
+ const claimedAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, ruled) {
587
+ const refused = new Map(ruled.refused);
588
+ for (const { handler } of checks.claimed?.() ?? []) {
589
+ const updates = ruled.updates.filter((update) => !refused.has(update.ref));
590
+ if (updates.length === 0) break;
591
+ for (const [ref, error] of yield* handler(input, updates)) if (!refused.has(ref)) refused.set(ref, error);
592
+ }
519
593
  return {
520
594
  ...ruled,
521
- refused: new Map([...ruled.refused, ...refused])
595
+ refused
522
596
  };
523
597
  });
524
- /** Whether a push has anything to check: a rule, the built-in check, or `hooks.preReceive`. */
525
- const checksOf = (core) => {
598
+ /** Whether a push has anything to check: a rule, a claimed check, or `hooks.preReceive`. */
599
+ const checksOf = /* @__PURE__ */ Effect.fnUntraced(function* (core) {
526
600
  const { checks } = core;
527
601
  if (checks === void 0) return void 0;
528
- return checks.rules().length > 0 || checks.preReceive !== void 0 || checks.builtIn !== void 0 ? checks : void 0;
529
- };
602
+ return (yield* pushRulesFor(checks)).length > 0 || checks.preReceive !== void 0 || (checks.claimed?.().length ?? 0) > 0 ? checks : void 0;
603
+ });
530
604
  /**
531
605
  * The repo's objects with the push's own, for the built-in check: `objects` and `listed` read
532
606
  * both, and `received` is the push's alone.
@@ -540,6 +614,17 @@ const pushedObjectsOf = (objects, listed, received, own) => {
540
614
  lfsPointers: received?.lfsPointers ?? noLfsPointers
541
615
  };
542
616
  };
617
+ /** `decision`, a commit that clears the mark, with the clear's row at `at` among its puts. */
618
+ const clearedAt = (decision, at) => decision.kind === "commit" ? {
619
+ ...decision,
620
+ change: {
621
+ ...decision.change,
622
+ put: [...decision.change.put, {
623
+ ...pruneClearedKey,
624
+ value: { at }
625
+ }]
626
+ }
627
+ } : decision;
543
628
  /**
544
629
  * What a decision commits: its writes and jobs at `expect`, or, for an answer that moves no ref,
545
630
  * nothing, which a keyed write's receipt still commits at the read's version. A refusal fails.
@@ -568,7 +653,7 @@ const planOf = (decision, version, jobs) => {
568
653
  * Each force among `kinds.updates` that its exact walk agrees is one, as a `diverged` refusal in
569
654
  * `diverged`, or the walk's own error past its bound in `refused`.
570
655
  */
571
- const divergedOf = Effect.fnUntraced(function* (kinds) {
656
+ const divergedOf = /* @__PURE__ */ Effect.fnUntraced(function* (kinds) {
572
657
  const refused = /* @__PURE__ */ new Map();
573
658
  const diverged = /* @__PURE__ */ new Map();
574
659
  for (const update of kinds.updates) {
@@ -597,7 +682,7 @@ const divergedOf = Effect.fnUntraced(function* (kinds) {
597
682
  * What the checks refused, and for a fetch, each diverged ref: refused, or with `force`, among
598
683
  * `forced`.
599
684
  */
600
- const fetchedRefused = Effect.fnUntraced(function* (kinds, request) {
685
+ const fetchedRefused = /* @__PURE__ */ Effect.fnUntraced(function* (kinds, request) {
601
686
  const { fetched } = request;
602
687
  if (fetched === void 0) return {
603
688
  refused: kinds.refused,
@@ -636,7 +721,7 @@ const commitTooLarge = (received, body) => (error) => {
636
721
  return gitError("RESOURCE_EXHAUSTED", `push's objects don't fit one commit: ${error.message}`, {
637
722
  cause: error,
638
723
  hint: "Push fewer objects at a time",
639
- hostHint: "Use packs() storage, which keeps a push's objects in the bucket",
724
+ hostHint: "Use Objects.layer() storage, which keeps a push's objects in the bucket",
640
725
  context: { reason: "too-large" }
641
726
  });
642
727
  };
@@ -649,6 +734,13 @@ const fits = (change) => {
649
734
  return false;
650
735
  }
651
736
  };
737
+ /** A push whose links or old tips the caller's set can't close yet, as between a large push and its update. */
738
+ const unindexedPush = () => gitError("RESOURCE_EXHAUSTED", "This push can't be checked until the repo's index is updated", {
739
+ hint: "Push again once the index is updated",
740
+ context: { reason: "walk-limit" }
741
+ });
742
+ /** `error`, a read by ID the index can't close yet told as the push's own. */
743
+ const asPushCheck = (error) => isUnindexedRead(error) ? unindexedPush() : error;
652
744
  /** The request's pack into its quarantine, or `undefined` for a push with none. */
653
745
  const receive = (objects, listed, request) => {
654
746
  const { pack, shallow, signal } = request;
@@ -656,6 +748,10 @@ const receive = (objects, listed, request) => {
656
748
  received: void 0,
657
749
  rooted: void 0
658
750
  });
751
+ if ("received" in pack) return Effect.succeed({
752
+ received: pack.received,
753
+ rooted: void 0
754
+ });
659
755
  const input = {
660
756
  pack: pack.bytes,
661
757
  objects: pack.objects
@@ -665,6 +761,9 @@ const receive = (objects, listed, request) => {
665
761
  if (shallow !== void 0 && shallow.length > 0) input.shallow = shallow;
666
762
  if (signal !== void 0) input.signal = signal;
667
763
  if (pack.partial === true) input.partial = true;
764
+ if (pack.boundary !== void 0 && pack.boundary.length > 0) input.boundary = pack.boundary;
765
+ if (pack.needs !== void 0 && pack.needs.length > 0) input.needs = pack.needs;
766
+ if (pack.cutMost !== void 0) input.cutMost = pack.cutMost;
668
767
  return scopedReceive(objects, listed, input).pipe(Effect.map((received) => ({
669
768
  received,
670
769
  rooted: void 0
@@ -673,15 +772,33 @@ const receive = (objects, listed, request) => {
673
772
  rooted
674
773
  })));
675
774
  };
676
- /** `ref.updated`'s `push`: the write, how many branches and tags it moved (Q222), and its source. */
677
- const pushOf = (id, moved, source) => {
678
- const under = (prefix) => moved.filter((move) => move.ref.startsWith(prefix)).length;
679
- return {
775
+ /**
776
+ * `ref.updated`'s `push`: the write, how many branches and tags it moved and each private
777
+ * pattern's part of them (`pushCounts`), its source, the slice its push options name, if they do
778
+ * (Q901), and those options, if it sent any.
779
+ */
780
+ const pushOf = (access, id, moved, request) => {
781
+ const push = {
680
782
  id,
681
- branches: under("refs/heads/"),
682
- tags: under("refs/tags/"),
683
- source
783
+ ...pushCounts(access, moved),
784
+ source: request.source
684
785
  };
786
+ const slice = sliceOf(request.pushOptions ?? []);
787
+ if (slice !== void 0) push.slice = slice;
788
+ const options = request.pushOptions ?? [];
789
+ if (options.length > 0) push.options = options;
790
+ return push;
791
+ };
792
+ /**
793
+ * Each of `moved` with its kind from `updates`, the push's decided updates. Every moved ref is
794
+ * among them, so the `force` fallback, the kind that claims least, is never taken.
795
+ */
796
+ const movedKinds = (updates, moved) => {
797
+ const kinds = new Map(updates.map((update) => [update.ref, update.kind]));
798
+ return moved.map((move) => ({
799
+ ...move,
800
+ kind: kinds.get(move.ref) ?? "force"
801
+ }));
685
802
  };
686
803
  /**
687
804
  * What a push's commit saves for `hooks.postReceive`, when the host passed one: the push, with
@@ -694,11 +811,7 @@ const savedPush = (checks, push) => {
694
811
  put: [],
695
812
  jobs: []
696
813
  };
697
- const kinds = new Map(push.updates.map((update) => [update.ref, update.kind]));
698
- const updates = push.moved.map((move) => ({
699
- ...move,
700
- kind: kinds.get(move.ref) ?? "force"
701
- }));
814
+ const updates = movedKinds(push.updates, push.moved);
702
815
  const { pushOptions, source } = push.request;
703
816
  const saved = {
704
817
  pushId: push.id,
@@ -714,6 +827,17 @@ const savedPush = (checks, push) => {
714
827
  };
715
828
  };
716
829
  /**
830
+ * The pack a push's own receive put under its `quarantine` row: none for a push with no pack, one
831
+ * of rows alone, or a caller's `received`, which stays its caller's to end.
832
+ */
833
+ const ownPack = (request, received) => {
834
+ const id = received?.quarantine?.id;
835
+ if (request.pack === void 0 || "received" in request.pack || id === void 0) return void 0;
836
+ return isPackId(id) ? id : void 0;
837
+ };
838
+ /** Whether a commit lists `pack`: its change deletes the pack's own `quarantine` row. */
839
+ const lists = (body, pack) => body.delete.some((key) => key.collection === objectCollections.quarantine && key.id === pack);
840
+ /**
717
841
  * The push decide's loop past its first read, onto `listed`, keeping its answer under `key`:
718
842
  * the pack received into its quarantine; each edit's kind from the objects; then a read of the
719
843
  * refs, the push's `quarantine` row and the caller's fence; a held receipt's answer; the rules and
@@ -721,17 +845,35 @@ const savedPush = (checks, push) => {
721
845
  * version, with the ref moves, the receipt, the events and the push `hooks.postReceive` owes.
722
846
  * `answers` says what the call answers and keeps.
723
847
  */
724
- const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRepo, view, views }, key, answers) => Effect.scoped(Effect.gen(function* () {
848
+ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, view, views }, key, answers) => Effect.scoped(Effect.gen(function* () {
849
+ const core = yield* CoreParts;
850
+ const { objects: sealed } = yield* ObjectsParts;
851
+ const authorize = yield* Authorize;
725
852
  const { store } = core;
726
853
  const { caller, repo, signal } = request;
727
854
  const call = signal === void 0 ? {} : { signal };
728
- const seen = yield* seenRefsOf(core, view, listed);
729
- const { received, rooted } = yield* receive(yield* view.objectsAt(seen), listed, request);
855
+ const seen = yield* seenRefsOf(view, listed);
856
+ const { received, rooted } = yield* receive(yield* read({
857
+ view,
858
+ at: seen
859
+ }), listed, request).pipe(Effect.tapError((error) => isAwaitingRepack(error) ? bestEffort(ensureRepack(core, core.jobs, repoScope(listed.repo))) : Effect.void), Effect.mapError(asPushCheck));
860
+ const ownedPack = ownPack(request, received);
861
+ let listing = false;
862
+ if (ownedPack !== void 0) yield* Effect.addFinalizer((exit) => listing || Exit.hasInterrupts(exit) ? Effect.void : Effect.flatMap(Clock$1.currentTimeMillis, (at) => abandonOwn({
863
+ store: gitStore(store),
864
+ repo: listed.repo,
865
+ pack: ownedPack,
866
+ at,
867
+ repackJobRow: core.repackJobRow
868
+ })));
730
869
  const viewed = received === void 0 ? seen : {
731
870
  ...seen,
732
871
  pushed: received
733
872
  };
734
- const objects = yield* walkObjects(effectObjects(yield* view.objectsAt(viewed)), received?.allotment);
873
+ const objects = yield* walkObjects(objectsFace(yield* read({
874
+ view,
875
+ at: viewed
876
+ })), received?.allotment);
735
877
  const pushedObjects = withReceivedRows(objects, received);
736
878
  const pushedListed = withReceived(listed, received);
737
879
  const pushed = pushedOf(objects, listed, received);
@@ -743,40 +885,45 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
743
885
  ...call
744
886
  };
745
887
  if (rooted !== void 0) kindsInput.missing = rooted;
746
- const kinds = yield* kindsOf(kindsInput);
888
+ const kinds = yield* kindsOf(kindsInput).pipe(Effect.mapError(asPushCheck));
747
889
  const fetchedOff = yield* fetchedRefused(kinds, request);
748
890
  const { forced } = fetchedOff;
749
891
  const refused = new Map(fetchedOff.refused);
892
+ const hidden = core.hiddenRefs();
750
893
  for (const update of kinds.updates) {
751
- const own = gitsOwnRef(update.ref, request.source);
894
+ const own = gitsOwnRef(hidden, update.ref, request.as);
752
895
  if (own !== void 0 && !refused.has(update.ref)) refused.set(update.ref, own);
753
896
  }
754
- const sights = yield* Effect.forEach(views, (one) => one.sight);
755
- const unseens = sights.map((sight) => unseenOf(sight, request.edits));
897
+ const refViews = yield* Effect.forEach(views, (one) => one.refView);
898
+ const unseens = refViews.map((refView) => unseenOf(refView, request.edits));
756
899
  yield* refuseQueued(request, unseens.map((one) => one.values().next().value), "access");
757
900
  const unseen = unseens[0] ?? /* @__PURE__ */ new Map();
758
901
  const { updates } = kinds;
759
902
  for (const [ref, error] of unseen) refused.set(ref, error);
760
903
  const { access } = core;
761
- const barred = access?.patterns.some((pattern) => sights.some((sight) => !publishable(sight, pattern))) === true;
762
- const whole = effectObjects(SealedObjects.whole(core.objects, pushWhole));
904
+ const barred = access?.patterns.some((pattern) => refViews.some((refView) => !publishable(refView, pattern))) === true;
905
+ const whole = objectsFace(SealedObjects.whole(sealed, pushWhole));
763
906
  const wholePushed = access === void 0 || !barred && request.publishes === void 0 ? void 0 : withReceivedRows(yield* walkObjects(whole, received?.allotment), received);
764
- const sight = sights[0] ?? (yield* view.sight);
765
- const publishedRefs = (refs) => new Map([...refs].filter(([ref]) => hiddenUnder(ref) === void 0));
907
+ const refView = refViews[0] ?? (yield* view.refView);
908
+ const publishedRefs = (refs) => new Map([...refs].filter(([ref]) => hiddenUnder(hidden, ref) === void 0));
766
909
  const writer = access === void 0 ? void 0 : yield* ownWriter(caller);
767
910
  const made = new Set(request.own);
768
911
  const ownOf = writer === void 0 ? void 0 : (oids) => {
769
912
  const here = oids.filter((oid) => made.has(oid));
770
913
  const stored = oids.filter((oid) => !made.has(oid));
771
914
  if (stored.length === 0) return Effect.succeed(new Set(here));
772
- return Effect.map(Effect.flatMap(core.now, (now) => ownWritesOf(core.store, listed.repo, writer, stored, now)), (kept) => /* @__PURE__ */ new Set([...here, ...kept]));
915
+ return Effect.map(Effect.flatMap(Clock$1.currentTimeMillis, (now) => ownWritesOf(core.store, listed.repo, writer, stored, now)), (kept) => /* @__PURE__ */ new Set([...here, ...kept]));
773
916
  };
774
- const unpublishedAt = (refs, at, judging, edits, own) => access === void 0 || wholePushed === void 0 ? Effect.succeed(/* @__PURE__ */ new Map()) : unpublished({
917
+ const unpublishedAt = (refs, at, index, judging, edits, own) => access === void 0 || wholePushed === void 0 ? Effect.succeed(/* @__PURE__ */ new Map()) : unpublished({
775
918
  access,
776
- sight: judging,
919
+ refView: judging,
777
920
  refs: publishedRefs(refs),
778
921
  objects: whole,
779
922
  listed: at,
923
+ visible: (tips, fallback) => SealedObjects.visibleWhole(sealed, pushWhole, at, {
924
+ tips,
925
+ row: index?.value
926
+ }, fallback),
780
927
  pushed: wholePushed,
781
928
  pushedListed: withReceived(at, received),
782
929
  edits,
@@ -784,9 +931,9 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
784
931
  ...call
785
932
  });
786
933
  const headsOf = (edit) => edit.to === null ? void 0 : request.publishes?.get(edit.ref);
787
- const publishedAt = (refs, at) => Effect.gen(function* () {
934
+ const publishedAt = Effect.fnUntraced(function* (refs, at, index) {
788
935
  const plain = request.edits.filter((edit) => headsOf(edit) === void 0);
789
- const refused = new Map(yield* unpublishedAt(refs, at, sight, plain, ownOf));
936
+ const refused = new Map(yield* unpublishedAt(refs, at, index, refView, plain, ownOf));
790
937
  for (const edit of request.edits) {
791
938
  const heads = headsOf(edit);
792
939
  if (heads === void 0) continue;
@@ -796,8 +943,8 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
796
943
  }
797
944
  const failed = [];
798
945
  for (const { entry, head, caller: its } of heads) {
799
- const judging = yield* sightIn(core, its, checkedRepo);
800
- if ((yield* unpublishedAt(refs, at, judging, [{
946
+ const judging = yield* refViewIn(its, checkedRepo);
947
+ if ((yield* unpublishedAt(refs, at, index, judging, [{
801
948
  ...edit,
802
949
  to: head
803
950
  }])).has(edit.ref)) failed.push(entry);
@@ -806,11 +953,19 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
806
953
  }
807
954
  return refused;
808
955
  });
956
+ const tagTips = updates.flatMap((update) => update.to !== null && storesPeel(update.ref) ? [update.to] : []);
957
+ const peeling = yield* peeledAll(pushedObjects, pushedListed, tagTips);
958
+ const peels = new Map(tagTips.map((tip) => [tip, peeling.peeled.get(tip) ?? null]));
959
+ for (const update of updates) {
960
+ const error = update.to === null ? void 0 : peeling.refused.get(update.to);
961
+ if (error !== void 0 && storesPeel(update.ref) && !refused.has(update.ref)) refused.set(update.ref, error);
962
+ }
809
963
  const command = {
810
964
  source: request.source,
811
965
  updates,
812
966
  atomic: request.atomic,
813
- refused
967
+ refused,
968
+ peels
814
969
  };
815
970
  if (received !== void 0) command.received = received;
816
971
  const target = {
@@ -820,13 +975,14 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
820
975
  const fence = fenceAll(request, decidingFor(request).map((one) => core.fences(one, target)));
821
976
  const ready = objects.readyShallow && request.edits.some((edit) => edit.ref === defaultBranch || edit.ref.startsWith("refs/tags/"));
822
977
  const jobs = (received?.change.add?.length ?? 0) > 0 || ready ? [core.repackJobRow()] : [];
823
- const own = updates.filter((update) => gitsOwnMove(request.source, update.ref));
824
- const outside = updates.filter((update) => !gitsOwnMove(request.source, update.ref));
825
- const checks = outside.length === 0 ? void 0 : checksOf(core);
978
+ const own = updates.filter((update) => gitsOwnMove(hidden, request.as, update.ref));
979
+ const outside = updates.filter((update) => !gitsOwnMove(hidden, request.as, update.ref));
980
+ const checks = outside.length === 0 ? void 0 : yield* checksOf(core);
826
981
  const branches = request.source === "queue" ? [] : outside.map((update) => update.ref).filter((ref) => ref.startsWith("refs/heads/"));
827
982
  const scope = yield* callScope;
828
983
  const reader = readerOf(pushedObjects, pushedListed, scope);
829
984
  const batch = batchOf(pushedObjects, pushedListed, scope);
985
+ const { between } = yield* Changes;
830
986
  const unaborted = signal ?? new AbortController().signal;
831
987
  const base = {
832
988
  caller,
@@ -840,9 +996,14 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
840
996
  },
841
997
  exact: kinds.exact,
842
998
  scope,
843
- changes: (updates) => changesOf(reader, updates, unaborted, batch),
999
+ changes: (updates) => Effect.map(Effect.forEach(updates, ({ from, to }) => between({
1000
+ objects: pushedObjects,
1001
+ listed: pushedListed,
1002
+ from: from ?? void 0,
1003
+ to: to ?? void 0
1004
+ })), (each) => each.flat()),
844
1005
  objects: pushedObjectsOf(pushedObjects, pushedListed, received, pushed),
845
- authorize: (operation) => core.authorize({
1006
+ authorize: (operation) => authorize.check({
846
1007
  caller,
847
1008
  operation,
848
1009
  repo: checkedRepo
@@ -857,21 +1018,20 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
857
1018
  source: request.source,
858
1019
  allotment: received?.allotment,
859
1020
  readerAllotment: pushedObjects.allotment(pushedListed, openTreeBytes, openTreesRefusal),
860
- brought: broughtCommit(pushed, scope),
861
- scope
1021
+ brought: broughtCommit(pushed)
862
1022
  };
863
1023
  if (request.pushOptions !== void 0) base.pushOptions = request.pushOptions;
864
1024
  if (request.request !== void 0) base.request = request.request;
865
1025
  let checked;
866
1026
  for (let tries = 0; tries < 10; tries += 1) {
867
- const at = yield* core.now;
868
- const decide = yield* finalRead(store, target, fence, received, key, mark, branches);
1027
+ const at = yield* Clock$1.currentTimeMillis;
1028
+ const decide = yield* finalRead(store, target, fence, received, key, mark, branches, updates.map(({ ref }) => ref), request.guard, request.writes?.unchanged);
869
1029
  const { read, receipt, outbox, record, mirrored, facts, stats, times, queued, reserved, indexRow } = decide;
870
- const indexed = SealedObjects.whole(core.objects, pushWhole).index?.status(indexRow, at);
1030
+ const indexed = SealedObjects.whole(sealed, pushWhole).index?.status(indexRow, at, listedIds(decide.at, received?.change));
871
1031
  if (receipt !== void 0) return yield* answers.held(receipt);
872
- const published = yield* publishedAt(read.refs, decide.at);
1032
+ const published = yield* publishedAt(read.refs, decide.at, indexRow);
873
1033
  const { writes } = request;
874
- if (writes !== void 0 && read.version !== writes.version) return yield* Effect.fail(queueMoved(repo));
1034
+ if (writes !== void 0 && (writes.unchanged === void 0 ? read.version !== writes.version : decide.changed)) return yield* Effect.fail(queueMoved(repo));
875
1035
  const seen = {
876
1036
  ...facts,
877
1037
  tips: tipsOf(read.refs, outside)
@@ -898,7 +1058,7 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
898
1058
  return commitChangesOf(judging, updates);
899
1059
  }
900
1060
  };
901
- checked = yield* checkAll(checks, request, input, seen, (one) => (operation) => core.authorize({
1061
+ checked = yield* checkAll(checks, request, input, seen, (one) => (operation) => authorize.check({
902
1062
  caller: one,
903
1063
  operation,
904
1064
  repo: checkedRepo
@@ -923,18 +1083,24 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
923
1083
  ...unseen
924
1084
  ])
925
1085
  };
926
- const planned = yield* planOf(decidePush({
1086
+ const chosen = decidePush({
927
1087
  read,
928
- command: decided
929
- }), read.version, jobs);
1088
+ command: decided,
1089
+ index: core.refIndex
1090
+ });
1091
+ const clears = read.marked === true && clearsMark(chosen);
1092
+ const decision = clears ? clearedAt(chosen, at) : chosen;
1093
+ const upkept = clears && jobs.length === 0 ? [core.repackJobRow()] : jobs;
1094
+ const planned = yield* planOf(decision, read.version, upkept);
930
1095
  const { change } = planned;
931
1096
  const refusal = writes === void 0 ? void 0 : refusalOf(planned.answer);
932
1097
  if (refusal !== void 0) return yield* Effect.fail(refusal);
933
1098
  const movedRefs = new Set(planned.moved.map((move) => move.ref));
934
1099
  const liftedOnMoves = [...checked?.bypassed ?? none].filter(([ref]) => movedRefs.has(ref));
935
1100
  const answer = yield* answers.answer(planned.answer, forced, new Map(liftedOnMoves));
936
- const also = planned.answer.updates.some((update) => update.kind === "rejected") || request.also === void 0 ? void 0 : request.also(yield* core.now);
937
- const quiet = key === void 0 && (also?.put.length ?? 0) === 0 && writes === void 0;
1101
+ const also = planned.answer.updates.some((update) => update.kind === "rejected") || request.also === void 0 ? void 0 : request.also(yield* Clock$1.currentTimeMillis, received);
1102
+ const alsoWrites = (also?.put.length ?? 0) + (also?.delete?.length ?? 0);
1103
+ const quiet = key === void 0 && alsoWrites === 0 && writes === void 0;
938
1104
  if (!planned.moves && quiet) return answer;
939
1105
  const scope = repoScope(listed.repo);
940
1106
  const { name } = record;
@@ -946,9 +1112,11 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
946
1112
  if (yield* settleName(store, scope, settling)) continue;
947
1113
  const envelope = repoEnvelope(caller, name);
948
1114
  const id = newChangeId();
949
- const shown = planned.moved.filter((move) => !gitsOwnMove(request.source, move.ref));
950
- const push = pushOf(id, shown, request.source);
951
- const events = shown.map((move) => {
1115
+ const shown = planned.moved.filter((move) => !gitsOwnMove(core.hiddenRefs(), request.as, move.ref));
1116
+ const optionsPast = pushOptionsProblem(request.pushOptions, shown.length);
1117
+ if (optionsPast !== void 0) return yield* Effect.fail(optionsPast);
1118
+ const push = pushOf(core.access, id, shown, request);
1119
+ const events = movedKinds(decided.updates, shown).map((move) => {
952
1120
  const updated = {
953
1121
  type: "ref.updated",
954
1122
  ...envelope,
@@ -995,6 +1163,7 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
995
1163
  delete: [
996
1164
  ...change.delete,
997
1165
  ...appended.delete,
1166
+ ...also?.delete ?? [],
998
1167
  ...writes?.delete ?? []
999
1168
  ],
1000
1169
  jobs: withJobs([
@@ -1004,10 +1173,22 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
1004
1173
  ...mirrorJobs(core, planned.moved, mirrored),
1005
1174
  ...writes?.jobs ?? [],
1006
1175
  ...woken,
1007
- ...shown.length > 0 ? indexJobs(core, indexed) : []
1176
+ ...shown.length > 0 ? indexJobs(core, indexed) : [],
1177
+ ...planned.moves ? refIndexJobs(core, record) : []
1008
1178
  ], [...kept.jobs, ...also?.jobs ?? []])
1009
1179
  };
1010
- if ((yield* storeCall(() => store.commit(scope, body)).pipe(Effect.mapError(commitTooLarge(received, body)))).ok) return final;
1180
+ const objects = (received?.change.put?.length ?? 0) + (received?.change.delete?.length ?? 0);
1181
+ const written = body.put.length + body.delete.length + body.jobs.length;
1182
+ const past = otherWritesProblem({
1183
+ writes: written,
1184
+ objects,
1185
+ moved: planned.moved.length
1186
+ }, core.refIndex);
1187
+ if (past !== void 0) return yield* Effect.fail(past);
1188
+ if ((yield* storeCall(() => store.commit(scope, body)).pipe(Effect.mapError(commitTooLarge(received, body)))).ok) {
1189
+ listing = ownedPack !== void 0 && lists(body, ownedPack);
1190
+ return final;
1191
+ }
1011
1192
  }
1012
1193
  return yield* fail("UNAVAILABLE", `Other writes kept moving '${repo}' through 10 tries`, { hint: "Push again" });
1013
1194
  }));
@@ -1025,16 +1206,16 @@ const operationOf = ({ repo, edits }) => edits.length === 0 ? {
1025
1206
  * reads and decides again. A push cut before its commit leaves an unlisted pack for clean-up, and
1026
1207
  * no ref moved.
1027
1208
  */
1028
- const pushWith = (core, request, answers, key) => Effect.gen(function* () {
1209
+ const pushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, key) {
1029
1210
  const operation = operationOf(request);
1030
- const resolved = yield* firstRead(core, request.caller, operation, request.internalId).pipe(Effect.tapError((error) => retriedCodes.has(error.code) ? Effect.void : refuseQueued(request, [error], "access")));
1031
- const opened = yield* listedFor(core, request, operation, resolved);
1032
- return yield* pushOnto(core, request, opened, key, answers);
1211
+ const resolved = yield* firstRead(request.caller, operation, request.internalId).pipe(Effect.tapError((error) => retriedCodes.has(error.code) ? Effect.void : refuseQueued(request, [error], "access")));
1212
+ const opened = yield* listedFor(request, operation, resolved);
1213
+ return yield* pushOnto(request, opened, key, answers);
1033
1214
  });
1034
1215
  /** A push or an unkeyed `refs.update`, answering the decide's ref answer. */
1035
- const push = (core, request) => pushWith(core, request, refsAnswers);
1216
+ const push = (request) => pushWith(request, refsAnswers);
1036
1217
  /** A `git push`, as `push`, with the lines Git prints for the rules `authorize` lifted. */
1037
- const gitPush = (core, request) => pushWith(core, request, gitAnswers);
1218
+ const gitPush = (request) => pushWith(request, gitAnswers);
1038
1219
  /** A ref a forced fetch moved past its diverged tip, answered `force`; the rest as they are. */
1039
1220
  const forcedOf = (forced) => (update) => update.kind === "applied" && forced.has(update.ref) ? {
1040
1221
  kind: "force",
@@ -1049,7 +1230,7 @@ const appliedOf = (update) => update.kind === "force" ? {
1049
1230
  * A client's fetch into its own refs, as `push`, each diverged ref a forced fetch moved answered
1050
1231
  * `force`. Its refs move in one commit, so a fetch stopped before it moves none.
1051
1232
  */
1052
- const pushFetched = (core, request) => pushWith(core, request, {
1233
+ const pushFetched = (request) => pushWith(request, {
1053
1234
  answer: (updated, forced) => Effect.succeed(updated.updates.map(forcedOf(forced))),
1054
1235
  kept: (updates) => refsKept({ updates: updates.map(appliedOf) }),
1055
1236
  held: (receipt) => Effect.map(refsAnswer(receipt), (held) => held.updates)
@@ -1058,13 +1239,13 @@ const pushFetched = (core, request) => pushWith(core, request, {
1058
1239
  * `pushWith` for a write's key, which keeps its answer. `undefined`, with nothing written or
1059
1240
  * asked of `authorize`, when the name holds a repo other than the one its key's lookup saw.
1060
1241
  */
1061
- const keyedPushWith = (core, request, answers, keyed) => Effect.gen(function* () {
1242
+ const keyedPushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, keyed) {
1062
1243
  const operation = operationOf(request);
1063
- const resolved = yield* keyedRead(core, request.caller, operation, keyed.missed, request.internalId);
1244
+ const resolved = yield* keyedRead(request.caller, operation, keyed.missed, request.internalId);
1064
1245
  if (resolved === void 0) return void 0;
1065
- const opened = yield* listedFor(core, request, operation, resolved);
1066
- return yield* pushOnto(core, request, opened, keyed.key, answers);
1246
+ const opened = yield* listedFor(request, operation, resolved);
1247
+ return yield* pushOnto(request, opened, keyed.key, answers);
1067
1248
  });
1068
1249
  /** `keyedPushWith` for `refs.update`, answering the decide's ref answer. */
1069
- const keyedPush = (core, request, keyed) => keyedPushWith(core, request, refsAnswers, keyed);
1070
- export { gitPush, isQueueMoved, keyedPush, keyedPushWith, push, pushFetched, pushWith, retriedCodes };
1250
+ const keyedPush = (request, keyed) => keyedPushWith(request, refsAnswers, keyed);
1251
+ export { buildFence, gitPush, isQueueMoved, keyedPush, keyedPushWith, push, pushFetched, pushWith, retriedCodes };