@ref0/git 0.3.0 → 0.4.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 (607) 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 +69 -46
  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 +57 -80
  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 +3 -0
  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 +51 -13
  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 +94 -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 +36 -9
  52. package/dist/contracts/actors.d.mts +28 -10
  53. package/dist/contracts/actors.mjs +17 -0
  54. package/dist/contracts/authorize.d.mts +77 -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 +1382 -205
  66. package/dist/contracts/events.mjs +485 -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 +107 -0
  72. package/dist/contracts/git.mjs +23 -0
  73. package/dist/contracts/grants.d.mts +2 -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 +9 -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 +323 -87
  83. package/dist/contracts/operations.d.mts +24 -16
  84. package/dist/contracts/promises.d.mts +13 -2
  85. package/dist/contracts/push-uploads.d.mts +39 -24
  86. package/dist/contracts/push-uploads.mjs +54 -0
  87. package/dist/contracts/queue.d.mts +444 -139
  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 +335 -69
  96. package/dist/contracts/result.mjs +350 -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 +113 -47
  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 +127 -20
  117. package/dist/contracts/work.mjs +69 -0
  118. package/dist/core/access.d.mts +25 -14
  119. package/dist/core/access.mjs +77 -108
  120. package/dist/core/ancestry.mjs +86 -18
  121. package/dist/core/call-names.mjs +1 -0
  122. package/dist/core/call-services.mjs +73 -0
  123. package/dist/core/changes.d.mts +31 -0
  124. package/dist/core/changes.mjs +5 -0
  125. package/dist/core/clock.mjs +3 -3
  126. package/dist/core/events/deliver.mjs +119 -33
  127. package/dist/core/events/seen.mjs +124 -0
  128. package/dist/core/forks.mjs +371 -159
  129. package/dist/core/hooks/order.d.mts +9 -0
  130. package/dist/core/hooks/order.mjs +25 -0
  131. package/dist/core/hooks/post-receive.mjs +13 -12
  132. package/dist/core/hooks/pre-receive.d.mts +8 -1
  133. package/dist/core/hooks/pre-receive.mjs +8 -6
  134. package/dist/core/imports.mjs +212 -0
  135. package/dist/core/index-job.mjs +131 -38
  136. package/dist/core/merge-parts.d.mts +30 -0
  137. package/dist/core/merge-parts.mjs +31 -0
  138. package/dist/core/names.mjs +4 -16
  139. package/dist/core/namespaces.d.mts +2 -0
  140. package/dist/core/objects/blobs.mjs +4 -4
  141. package/dist/core/objects/commit-writes.mjs +19 -17
  142. package/dist/core/objects/commits.mjs +12 -12
  143. package/dist/core/objects/files.mjs +10 -11
  144. package/dist/core/objects/lines.mjs +15 -32
  145. package/dist/core/objects/merges.mjs +4 -4
  146. package/dist/core/objects/objects-layer.d.mts +21 -0
  147. package/dist/core/objects/objects-layer.mjs +47 -0
  148. package/dist/core/objects/objects-namespace.d.mts +6 -0
  149. package/dist/core/objects/objects-namespace.mjs +13 -0
  150. package/dist/core/objects/objects.d.mts +49 -0
  151. package/dist/core/objects/objects.mjs +18 -0
  152. package/dist/core/objects/peel.mjs +3 -3
  153. package/dist/core/objects/reading.mjs +135 -40
  154. package/dist/core/objects/tags.mjs +7 -7
  155. package/dist/core/objects/tree-edits.mjs +40 -27
  156. package/dist/core/objects/trees.mjs +23 -18
  157. package/dist/core/objects/writing.mjs +43 -44
  158. package/dist/core/own-writes.mjs +3 -3
  159. package/dist/core/parts.d.mts +125 -0
  160. package/dist/core/parts.mjs +59 -0
  161. package/dist/core/promise.mjs +13 -9
  162. package/dist/core/publish.mjs +27 -17
  163. package/dist/core/purge.mjs +242 -0
  164. package/dist/core/push-decide.mjs +93 -28
  165. package/dist/core/push.mjs +300 -156
  166. package/dist/core/receipts.d.mts +4 -3
  167. package/dist/core/receipts.mjs +20 -12
  168. package/dist/core/ref-conflicts.mjs +70 -4
  169. package/dist/core/ref-index-job.mjs +181 -0
  170. package/dist/core/ref-index.d.mts +25 -0
  171. package/dist/core/ref-index.mjs +136 -0
  172. package/dist/core/ref-view.mjs +166 -0
  173. package/dist/core/refs.mjs +313 -95
  174. package/dist/core/repack.d.mts +10 -0
  175. package/dist/core/repack.mjs +261 -81
  176. package/dist/core/repo-info.mjs +99 -0
  177. package/dist/core/repos.mjs +114 -80
  178. package/dist/core/rules/changes.mjs +48 -20
  179. package/dist/core/rules/check.mjs +29 -22
  180. package/dist/core/rules/commit-changes.d.mts +13 -0
  181. package/dist/core/rules/commit-changes.mjs +100 -91
  182. package/dist/core/rules/context.d.mts +67 -8
  183. package/dist/core/rules/context.mjs +88 -51
  184. package/dist/core/rules/facts.mjs +1 -1
  185. package/dist/core/rules/fetch.mjs +24 -26
  186. package/dist/core/rules/files.d.mts +13 -0
  187. package/dist/core/rules/files.mjs +27 -28
  188. package/dist/core/rules/namespace.d.mts +2 -0
  189. package/dist/core/rules/patterns.mjs +29 -5
  190. package/dist/core/rules/protect.d.mts +12 -6
  191. package/dist/core/rules/protect.mjs +22 -20
  192. package/dist/core/rules/rules-layer.d.mts +17 -0
  193. package/dist/core/rules/rules-layer.mjs +26 -0
  194. package/dist/core/rules/rules.d.mts +8 -0
  195. package/dist/core/rules/rules.mjs +16 -0
  196. package/dist/core/rules/service.mjs +18 -0
  197. package/dist/core/seam.d.mts +8 -5
  198. package/dist/core/seam.mjs +19 -15
  199. package/dist/core/tokens.mjs +29 -23
  200. package/dist/core/view.d.mts +105 -6
  201. package/dist/core/view.mjs +211 -109
  202. package/dist/core/work.mjs +40 -14
  203. package/dist/effect.d.mts +3 -4
  204. package/dist/effect.mjs +2 -3
  205. package/dist/engine/allotted-xdiff.d.mts +1 -0
  206. package/dist/engine/allotted-xdiff.mjs +1 -1
  207. package/dist/engine/attributes.mjs +1 -1
  208. package/dist/engine/combined.d.mts +18 -0
  209. package/dist/engine/combined.mjs +39 -44
  210. package/dist/engine/commits.mjs +5 -4
  211. package/dist/engine/content.d.mts +3 -2
  212. package/dist/engine/content.mjs +2 -2
  213. package/dist/engine/failures.d.mts +2 -2
  214. package/dist/engine/failures.mjs +2 -9
  215. package/dist/engine/merge-base-walk.d.mts +3 -2
  216. package/dist/engine/merge-base-walk.mjs +1 -1
  217. package/dist/engine/merge-bases.mjs +3 -2
  218. package/dist/engine/merge.mjs +568 -566
  219. package/dist/engine/parts.d.mts +3 -2
  220. package/dist/engine/parts.mjs +40 -7
  221. package/dist/engine/reads.d.mts +1 -0
  222. package/dist/engine/reads.mjs +5 -5
  223. package/dist/engine/walk.mjs +23 -24
  224. package/dist/engine/xdiff.d.mts +2 -33
  225. package/dist/engine/xdiff.mjs +6 -3
  226. package/dist/event-streams/event-streams.d.mts +25 -0
  227. package/dist/event-streams/event-streams.mjs +22 -0
  228. package/dist/event-streams/namespace.d.mts +2 -0
  229. package/dist/event-streams/stream.d.mts +42 -0
  230. package/dist/{core/events → event-streams}/stream.mjs +106 -49
  231. package/dist/extend.d.mts +4 -2
  232. package/dist/http/answers.mjs +8 -4
  233. package/dist/http/bodies.mjs +84 -56
  234. package/dist/http/core-parts.mjs +206 -60
  235. package/dist/http/handler.d.mts +2 -0
  236. package/dist/http/handler.mjs +17 -11
  237. package/dist/http/node.mjs +10 -6
  238. package/dist/http/parts.d.mts +12 -0
  239. package/dist/http/push-uploads.d.mts +9 -0
  240. package/dist/http/push-uploads.mjs +76 -66
  241. package/dist/http/receive-pack.mjs +162 -28
  242. package/dist/http/upload-pack.mjs +106 -81
  243. package/dist/index.d.mts +48 -28
  244. package/dist/index.mjs +29 -7
  245. package/dist/lfs/calls.mjs +2 -2
  246. package/dist/lfs/locks.mjs +24 -20
  247. package/dist/lfs/objects.d.mts +7 -0
  248. package/dist/lfs/objects.mjs +31 -26
  249. package/dist/lfs/pointers.mjs +7 -7
  250. package/dist/lfs/purge.mjs +50 -0
  251. package/dist/lfs/repo.mjs +5 -5
  252. package/dist/lfs/rows.mjs +8 -8
  253. package/dist/lfs/service.d.mts +9 -0
  254. package/dist/lfs/service.mjs +32 -25
  255. package/dist/lfs/upkeep.mjs +5 -5
  256. package/dist/lfs/wire.mjs +80 -38
  257. package/dist/merges/merges.d.mts +20 -0
  258. package/dist/merges/merges.mjs +32 -0
  259. package/dist/merges/namespace.d.mts +2 -0
  260. package/dist/merges/public.d.mts +6 -0
  261. package/dist/merges/public.mjs +10 -0
  262. package/dist/node.d.mts +1 -2
  263. package/dist/node.mjs +1 -3
  264. package/dist/protocol/bytes/buffers.d.mts +9 -3
  265. package/dist/protocol/bytes/buffers.mjs +11 -5
  266. package/dist/protocol/bytes/deflate.d.mts +7 -5
  267. package/dist/protocol/bytes/deflate.mjs +59 -23
  268. package/dist/protocol/bytes/inflate.d.mts +4 -3
  269. package/dist/protocol/bytes/inflate.mjs +61 -26
  270. package/dist/protocol/bytes/reader.mjs +61 -0
  271. package/dist/protocol/bytes/sha1-hasher.d.mts +3 -1
  272. package/dist/protocol/bytes/sha1-hasher.mjs +13 -3
  273. package/dist/protocol/bytes/sha1.d.mts +1 -1
  274. package/dist/protocol/bytes/sha1.mjs +5 -5
  275. package/dist/protocol/bytes/streams.mjs +16 -6
  276. package/dist/protocol/diff/patch.d.mts +4 -0
  277. package/dist/protocol/diff/patch.mjs +1 -1
  278. package/dist/protocol/diff/paths.mjs +1 -1
  279. package/dist/protocol/diff/read.d.mts +1 -1
  280. package/dist/protocol/diff/read.mjs +102 -90
  281. package/dist/protocol/framing/pkt-line.d.mts +1 -0
  282. package/dist/protocol/framing/pkt-line.mjs +40 -6
  283. package/dist/protocol/objects/checked-blobs.d.mts +1 -0
  284. package/dist/protocol/objects/fsck.mjs +7 -1
  285. package/dist/protocol/objects/held.mjs +5 -11
  286. package/dist/protocol/objects/ident.mjs +1 -1
  287. package/dist/protocol/objects/object-rules.mjs +15 -7
  288. package/dist/protocol/objects/object.d.mts +6 -2
  289. package/dist/protocol/objects/object.mjs +5 -2
  290. package/dist/protocol/objects/tag.d.mts +3 -1
  291. package/dist/protocol/objects/tag.mjs +27 -1
  292. package/dist/protocol/objects/tree.mjs +1 -1
  293. package/dist/protocol/packs/delta.d.mts +1 -1
  294. package/dist/protocol/packs/delta.mjs +2 -2
  295. package/dist/protocol/packs/graph.mjs +55 -56
  296. package/dist/protocol/packs/idx.d.mts +4 -2
  297. package/dist/protocol/packs/idx.mjs +156 -63
  298. package/dist/protocol/packs/indexer.d.mts +22 -4
  299. package/dist/protocol/packs/indexer.mjs +14 -35
  300. package/dist/protocol/packs/parts.mjs +5 -5
  301. package/dist/protocol/packs/pos.mjs +12 -5
  302. package/dist/protocol/packs/reader.d.mts +19 -12
  303. package/dist/protocol/packs/reader.mjs +252 -25
  304. package/dist/protocol/packs/rev.d.mts +1 -1
  305. package/dist/protocol/packs/rev.mjs +42 -24
  306. package/dist/protocol/packs/types-file.mjs +85 -0
  307. package/dist/protocol/packs/write-error.d.mts +1 -1
  308. package/dist/protocol/packs/write-error.mjs +2 -2
  309. package/dist/protocol/packs/writer.d.mts +40 -15
  310. package/dist/protocol/packs/writer.mjs +142 -49
  311. package/dist/protocol/wire/advertisement.d.mts +39 -14
  312. package/dist/protocol/wire/advertisement.mjs +127 -31
  313. package/dist/protocol/wire/fetch.d.mts +57 -19
  314. package/dist/protocol/wire/fetch.mjs +57 -26
  315. package/dist/protocol/wire/json.mjs +25 -0
  316. package/dist/protocol/wire/lines.d.mts +10 -0
  317. package/dist/protocol/wire/lines.mjs +20 -6
  318. package/dist/protocol/wire/push-limits.d.mts +6 -0
  319. package/dist/protocol/wire/push-limits.mjs +88 -0
  320. package/dist/protocol/wire/push-uploads.mjs +3 -28
  321. package/dist/protocol/wire/receive-pack.d.mts +30 -14
  322. package/dist/protocol/wire/receive-pack.mjs +29 -2
  323. package/dist/protocol/wire/report-status.d.mts +30 -11
  324. package/dist/protocol/wire/report-status.mjs +21 -2
  325. package/dist/protocol/wire/v2.d.mts +56 -29
  326. package/dist/protocol/wire/v2.mjs +91 -16
  327. package/dist/protocol.d.mts +4 -3
  328. package/dist/protocol.mjs +7 -6
  329. package/dist/queue/advance.mjs +189 -120
  330. package/dist/queue/callers.mjs +12 -9
  331. package/dist/queue/calls.mjs +311 -155
  332. package/dist/queue/commit.mjs +70 -26
  333. package/dist/queue/host.d.mts +39 -12
  334. package/dist/queue/host.mjs +36 -38
  335. package/dist/queue/lanes.mjs +1 -1
  336. package/dist/queue/layer.d.mts +14 -0
  337. package/dist/queue/layer.mjs +55 -0
  338. package/dist/queue/limits.mjs +13 -2
  339. package/dist/queue/namespace.d.mts +2 -0
  340. package/dist/queue/pages.mjs +1 -1
  341. package/dist/queue/public.d.mts +6 -0
  342. package/dist/queue/public.mjs +21 -0
  343. package/dist/queue/push-option.mjs +49 -30
  344. package/dist/queue/rows.mjs +24 -16
  345. package/dist/queue/schedule.mjs +22 -22
  346. package/dist/queue/search.mjs +8 -7
  347. package/dist/queue/state.mjs +49 -13
  348. package/dist/queue/steps.mjs +6 -3
  349. package/dist/remote-helper.d.mts +5 -2
  350. package/dist/remote-helper.mjs +5 -2
  351. package/dist/rest/api.d.mts +1 -1
  352. package/dist/rest/blobs.d.mts +790 -23
  353. package/dist/rest/blobs.mjs +4 -4
  354. package/dist/rest/caller.d.mts +4163 -36
  355. package/dist/rest/caller.mjs +2 -2
  356. package/dist/rest/client.mjs +80 -70
  357. package/dist/rest/commits.d.mts +3315 -244
  358. package/dist/rest/commits.mjs +18 -64
  359. package/dist/rest/errors.d.mts +2082 -22
  360. package/dist/rest/errors.mjs +46 -89
  361. package/dist/rest/events.d.mts +394 -11
  362. package/dist/rest/events.mjs +13 -9
  363. package/dist/rest/files.d.mts +1265 -114
  364. package/dist/rest/files.mjs +11 -42
  365. package/dist/rest/forks.d.mts +2005 -62
  366. package/dist/rest/forks.mjs +10 -13
  367. package/dist/rest/handler.d.mts +3 -0
  368. package/dist/rest/handler.mjs +22 -14
  369. package/dist/rest/handlers.mjs +53 -60
  370. package/dist/rest/listen.d.mts +5 -8
  371. package/dist/rest/listen.mjs +23 -29
  372. package/dist/rest/me.d.mts +393 -10
  373. package/dist/rest/me.mjs +2 -2
  374. package/dist/rest/merges.d.mts +399 -16
  375. package/dist/rest/merges.mjs +3 -17
  376. package/dist/rest/paths.mjs +1 -0
  377. package/dist/rest/queue.d.mts +5615 -240
  378. package/dist/rest/queue.mjs +15 -130
  379. package/dist/rest/refs.d.mts +2859 -132
  380. package/dist/rest/refs.mjs +19 -39
  381. package/dist/rest/repos.d.mts +2421 -93
  382. package/dist/rest/repos.mjs +10 -33
  383. package/dist/rest/tags.d.mts +1205 -54
  384. package/dist/rest/tags.mjs +6 -34
  385. package/dist/rest/tokens.d.mts +2369 -66
  386. package/dist/rest/tokens.mjs +7 -4
  387. package/dist/rest/topics.d.mts +2060 -113
  388. package/dist/rest/topics.mjs +23 -71
  389. package/dist/rest/trees.d.mts +1610 -75
  390. package/dist/rest/trees.mjs +16 -57
  391. package/dist/rest/wire.d.mts +402 -0
  392. package/dist/rest/wire.mjs +32 -46
  393. package/dist/rest/work.d.mts +1204 -63
  394. package/dist/rest/work.mjs +7 -51
  395. package/dist/rest.d.mts +3 -3
  396. package/dist/server/extension.d.mts +6 -2
  397. package/dist/server/extension.mjs +54 -30
  398. package/dist/server/git-layer.d.mts +23 -0
  399. package/dist/server/git-layer.mjs +107 -0
  400. package/dist/server/git-namespace.d.mts +6 -0
  401. package/dist/server/git-namespace.mjs +15 -0
  402. package/dist/server/lifecycle.d.mts +1 -2
  403. package/dist/server/lifecycle.mjs +8 -15
  404. package/dist/server/namespaces.d.mts +2 -0
  405. package/dist/server/registry.d.mts +9 -0
  406. package/dist/server/registry.mjs +167 -0
  407. package/dist/server/route-match.mjs +88 -0
  408. package/dist/server/routes.d.mts +12 -8
  409. package/dist/server/routes.mjs +27 -18
  410. package/dist/server/server.d.mts +19 -0
  411. package/dist/server/server.mjs +281 -198
  412. package/dist/signin/codes.mjs +9 -6
  413. package/dist/signin/context.d.mts +1 -0
  414. package/dist/signin/context.mjs +4 -4
  415. package/dist/signin/device.mjs +8 -8
  416. package/dist/signin/forms.mjs +11 -29
  417. package/dist/signin/grants.d.mts +4 -2
  418. package/dist/signin/grants.mjs +20 -19
  419. package/dist/signin/route.mjs +2 -2
  420. package/dist/signin/web.mjs +7 -7
  421. package/dist/signin/wire.mjs +6 -6
  422. package/dist/storage/budget.mjs +51 -18
  423. package/dist/storage/calls.d.mts +22 -4
  424. package/dist/storage/calls.mjs +347 -110
  425. package/dist/storage/clean-up.mjs +80 -35
  426. package/dist/storage/counted-bucket.mjs +115 -0
  427. package/dist/storage/fetch.d.mts +2 -0
  428. package/dist/storage/fetch.mjs +243 -100
  429. package/dist/storage/fsck.mjs +56 -7
  430. package/dist/storage/held-types.d.mts +7 -0
  431. package/dist/storage/held-types.mjs +263 -0
  432. package/dist/storage/host-bucket.mjs +28 -0
  433. package/dist/storage/id-mix.d.mts +1 -0
  434. package/dist/storage/id-mix.mjs +55 -0
  435. package/dist/storage/index-bitmaps.d.mts +2 -1
  436. package/dist/storage/index-bitmaps.mjs +233 -101
  437. package/dist/storage/index-build.d.mts +7 -3
  438. package/dist/storage/index-build.mjs +650 -164
  439. package/dist/storage/index-fetch.d.mts +3 -1
  440. package/dist/storage/index-fetch.mjs +297 -195
  441. package/dist/storage/index-files.mjs +25 -27
  442. package/dist/storage/index-graph.d.mts +2 -1
  443. package/dist/storage/index-graph.mjs +127 -91
  444. package/dist/storage/index-layers.d.mts +11 -0
  445. package/dist/storage/index-layers.mjs +258 -78
  446. package/dist/storage/index-reach.mjs +181 -75
  447. package/dist/storage/index-remap.mjs +74 -32
  448. package/dist/storage/index-shallow.mjs +311 -0
  449. package/dist/storage/index-visible.mjs +168 -0
  450. package/dist/storage/layout.d.mts +1 -0
  451. package/dist/storage/layout.mjs +39 -8
  452. package/dist/storage/lfs-pointers.d.mts +3 -1
  453. package/dist/storage/lfs-pointers.mjs +25 -9
  454. package/dist/storage/link-join.d.mts +4 -0
  455. package/dist/storage/link-join.mjs +50 -12
  456. package/dist/storage/links.mjs +89 -4
  457. package/dist/storage/listed-ids.mjs +10 -0
  458. package/dist/storage/loose.d.mts +11 -4
  459. package/dist/storage/loose.mjs +102 -69
  460. package/dist/storage/memory-budget.d.mts +5 -0
  461. package/dist/storage/memory-budget.mjs +530 -102
  462. package/dist/storage/merge-choose.mjs +258 -0
  463. package/dist/storage/merge-cut.mjs +47 -0
  464. package/dist/storage/merge-fence.mjs +89 -0
  465. package/dist/storage/merge-index.mjs +347 -0
  466. package/dist/storage/merge-most.mjs +202 -0
  467. package/dist/storage/merge-plan.mjs +171 -0
  468. package/dist/storage/merge-row.mjs +258 -0
  469. package/dist/storage/merge-stream.mjs +497 -0
  470. package/dist/storage/merge-walk.mjs +199 -0
  471. package/dist/storage/merge-write.mjs +129 -0
  472. package/dist/storage/merge.d.mts +10 -0
  473. package/dist/storage/merge.mjs +82 -306
  474. package/dist/storage/object-rows.d.mts +4 -2
  475. package/dist/storage/object-rows.mjs +101 -17
  476. package/dist/storage/pack-order.d.mts +1 -1
  477. package/dist/storage/pack-order.mjs +69 -54
  478. package/dist/storage/pack-ranges.d.mts +1 -1
  479. package/dist/storage/pack-ranges.mjs +396 -60
  480. package/dist/storage/pack-reads.d.mts +6 -2
  481. package/dist/storage/pack-reads.mjs +598 -126
  482. package/dist/storage/pack-receive.d.mts +5 -0
  483. package/dist/storage/pack-receive.mjs +820 -237
  484. package/dist/storage/packs-memory.d.mts +25 -0
  485. package/dist/storage/packs-memory.mjs +49 -0
  486. package/dist/storage/packs.d.mts +7 -5
  487. package/dist/storage/packs.mjs +554 -213
  488. package/dist/storage/placed-reads.mjs +205 -0
  489. package/dist/storage/promise-calls.mjs +29 -0
  490. package/dist/storage/prune-keep.mjs +164 -0
  491. package/dist/storage/prune-walk.mjs +578 -0
  492. package/dist/storage/prune.mjs +739 -332
  493. package/dist/storage/push-allotment.mjs +3 -3
  494. package/dist/storage/push-uploads.mjs +22 -13
  495. package/dist/storage/pushed-commits.mjs +8 -9
  496. package/dist/storage/quarantine.d.mts +10 -0
  497. package/dist/storage/quarantine.mjs +28 -25
  498. package/dist/storage/range-cache.mjs +71 -0
  499. package/dist/storage/raw-ids.mjs +20 -1
  500. package/dist/storage/ready.d.mts +4 -2
  501. package/dist/storage/ready.mjs +109 -48
  502. package/dist/storage/receive-admission.mjs +67 -0
  503. package/dist/storage/receive-bounds.d.mts +1 -0
  504. package/dist/storage/receive-bounds.mjs +202 -0
  505. package/dist/storage/receive-files.mjs +248 -0
  506. package/dist/storage/receive-links.mjs +281 -244
  507. package/dist/storage/receive-state.d.mts +9 -0
  508. package/dist/storage/receive-state.mjs +150 -0
  509. package/dist/storage/receive-steps.mjs +344 -0
  510. package/dist/storage/receive-sweep.mjs +160 -0
  511. package/dist/storage/receive-table.d.mts +3 -0
  512. package/dist/storage/receive-table.mjs +197 -0
  513. package/dist/storage/repack-backlog.mjs +70 -0
  514. package/dist/storage/repack-contained.mjs +269 -0
  515. package/dist/storage/repack-job.d.mts +3 -0
  516. package/dist/storage/repack-job.mjs +24 -7
  517. package/dist/storage/repack.d.mts +4 -4
  518. package/dist/storage/repack.mjs +156 -77
  519. package/dist/storage/roots.mjs +23 -7
  520. package/dist/storage/rows.d.mts +4 -2
  521. package/dist/storage/rows.mjs +40 -7
  522. package/dist/storage/runs.d.mts +8 -0
  523. package/dist/storage/runs.mjs +731 -0
  524. package/dist/storage/send-list.d.mts +2 -1
  525. package/dist/storage/send-list.mjs +261 -76
  526. package/dist/storage/shallow.d.mts +3 -2
  527. package/dist/storage/shallow.mjs +7 -7
  528. package/dist/storage/single-flight.mjs +47 -0
  529. package/dist/storage/stream-whole.mjs +121 -54
  530. package/dist/storage/swap-walk.mjs +188 -0
  531. package/dist/storage/unpack.mjs +52 -23
  532. package/dist/storage/visible.mjs +58 -39
  533. package/dist/storage/walk.d.mts +2 -0
  534. package/dist/storage/walk.mjs +20 -7
  535. package/dist/storage/wants.mjs +185 -33
  536. package/dist/storage/written-bases.mjs +172 -0
  537. package/dist/store/call-count.d.mts +69 -4
  538. package/dist/store/call-count.mjs +193 -51
  539. package/dist/store/catalogue.d.mts +17 -3
  540. package/dist/store/catalogue.mjs +135 -48
  541. package/dist/store/crossing.mjs +2 -4
  542. package/dist/store/cursor-seal.d.mts +12 -1
  543. package/dist/store/cursor-seal.mjs +7 -6
  544. package/dist/store/errors.d.mts +2 -2
  545. package/dist/store/errors.mjs +112 -24
  546. package/dist/store/git-store.mjs +21 -2
  547. package/dist/store/list-job.mjs +5 -5
  548. package/dist/store/outbox.d.mts +15 -5
  549. package/dist/store/outbox.mjs +106 -28
  550. package/dist/store/promises.d.mts +3 -2
  551. package/dist/store/promises.mjs +94 -35
  552. package/dist/store/queue-jobs.mjs +12 -12
  553. package/dist/store/records.d.mts +64 -1
  554. package/dist/store/records.mjs +101 -32
  555. package/dist/store/ref-rows.d.mts +18 -2
  556. package/dist/store/ref-rows.mjs +62 -5
  557. package/dist/store/repo-record.mjs +11 -9
  558. package/dist/store/reservations.mjs +9 -8
  559. package/dist/store/scopes.mjs +13 -1
  560. package/dist/store/settle.mjs +1 -1
  561. package/dist/store/topic-jobs.mjs +4 -4
  562. package/dist/sync/bound.d.mts +5 -3
  563. package/dist/sync/bound.mjs +32 -3
  564. package/dist/sync/github.mjs +7 -7
  565. package/dist/sync/import.d.mts +2 -0
  566. package/dist/sync/import.mjs +46 -50
  567. package/dist/sync/jobs.mjs +15 -23
  568. package/dist/sync/mirror.d.mts +5 -1
  569. package/dist/sync/mirror.mjs +121 -44
  570. package/dist/sync/publish.d.mts +1 -0
  571. package/dist/sync/publish.mjs +10 -12
  572. package/dist/sync/step.mjs +439 -71
  573. package/dist/sync/tries.mjs +50 -32
  574. package/dist/sync.d.mts +3 -3
  575. package/dist/sync.mjs +2 -2
  576. package/dist/topics/advance.mjs +103 -86
  577. package/dist/topics/calls.mjs +97 -67
  578. package/dist/topics/directory.mjs +31 -11
  579. package/dist/topics/host.d.mts +0 -1
  580. package/dist/topics/host.mjs +2 -12
  581. package/dist/topics/members.mjs +30 -24
  582. package/dist/topics/rows.mjs +10 -9
  583. package/dist/topics/topic.mjs +20 -9
  584. package/package.json +8 -15
  585. package/dist/auth/authorize.d.mts +0 -5
  586. package/dist/contracts/objects.mjs +0 -54
  587. package/dist/core/events/stream.d.mts +0 -19
  588. package/dist/core/rules/define.d.mts +0 -5
  589. package/dist/core/rules/define.mjs +0 -13
  590. package/dist/core/rules/fetch.d.mts +0 -5
  591. package/dist/core/sight.mjs +0 -99
  592. package/dist/engine/engine.d.mts +0 -25
  593. package/dist/engine/engine.mjs +0 -49
  594. package/dist/engine/xdiff/NOTICE.md +0 -63
  595. package/dist/engine/xdiff/compiled.d.mts +0 -7
  596. package/dist/engine/xdiff/compiled.mjs +0 -9
  597. package/dist/engine/xdiff/embedded.mjs +0 -4
  598. package/dist/engine/xdiff/node.d.mts +0 -7
  599. package/dist/engine/xdiff/node.mjs +0 -10
  600. package/dist/engine/xdiff/upstream/LGPL-2.1 +0 -511
  601. package/dist/engine/xdiff/xdiff.wasm +0 -0
  602. package/dist/engine.d.mts +0 -3
  603. package/dist/engine.mjs +0 -3
  604. package/dist/storage/distinct-ids.mjs +0 -39
  605. package/dist/storage/held-memo.mjs +0 -188
  606. package/dist/storage/index-remap.d.mts +0 -8
  607. package/dist/sync/records.mjs +0 -73
@@ -1,52 +1,65 @@
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";
7
+ import { listedIds } from "../storage/listed-ids.mjs";
5
8
  import { indexRowKey, 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";
10
15
  import { QuarantineRow, decodeHeld } from "../storage/rows.mjs";
11
- import { decodeRow, fail, gitError, storeCall, thrownError } from "../store/errors.mjs";
16
+ import { bestEffort, decodeRow, storeCall } from "../store/errors.mjs";
12
17
  import { callScope } from "../store/call-count.mjs";
13
- import { runIn } from "../store/crossing.mjs";
14
18
  import { decodePacks } from "../store/git-store.mjs";
15
- import { WholeRepo, wholeRefs } from "../store/ref-rows.mjs";
19
+ import { WholeRepo, refBytesOf, storesPeel, wholeRefs } from "../store/ref-rows.mjs";
16
20
  import { gitsOwnMove, hiddenUnder } from "../protocol/wire/lines.mjs";
17
- import { sightIn } from "./sight.mjs";
21
+ import { sliceOf } from "../protocol/wire/push-limits.mjs";
22
+ import { pushCounts } from "./events/seen.mjs";
23
+ import { refViewIn } from "./ref-view.mjs";
18
24
  import { appendEvents, decodeOutbox, firstSeq, outboxReads, repoEnvelope } from "../store/outbox.mjs";
19
25
  import { MirrorRow, PrunedMark, mirrorJobName } from "../store/records.mjs";
20
26
  import { decodeTimes, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
21
27
  import { advanceRow } from "../store/queue-jobs.mjs";
22
28
  import { liveReservations, reservedTarget } from "../store/reservations.mjs";
23
29
  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";
30
+ import { collections, newChangeId, prunedKey, pushedKey, pushedUnder, reachedKey, repoScope } from "../store/scopes.mjs";
31
+ import { headOf, indexJobs, openKeyed, openRepo, refIndexJobs, repoAccess } from "./access.mjs";
26
32
  import { kindsOf } from "./ancestry.mjs";
27
33
  import { savedPushRow } from "./hooks/post-receive.mjs";
28
34
  import { runPreReceive } from "./hooks/pre-receive.mjs";
29
- import { changesOf } from "./rules/changes.mjs";
35
+ import { Changes } from "./changes.mjs";
36
+ import { batchOf, readerOf } from "./rules/changes.mjs";
30
37
  import { commitChangesOf, coveredTips } from "./rules/commit-changes.mjs";
31
- import { gitsOwnRef, runPushRules, unseenRef } from "./rules/check.mjs";
38
+ import { gitsOwnRef, pushRulesFor, runPushRules, unseenRef } from "./rules/check.mjs";
32
39
  import { checking } from "./rules/context.mjs";
33
40
  import { changedWhileChecked, factsHeld, tipsOf } from "./rules/facts.mjs";
34
- import { decidePush } from "./push-decide.mjs";
41
+ import { clearsMark, decidePush, otherWritesProblem } from "./push-decide.mjs";
35
42
  import { heldReceipt, receiptReads, receiptWrites, refsAnswer, refsKept, withJobs } from "./receipts.mjs";
36
43
  import { SealedObjects, viewOf } from "./view.mjs";
37
44
  import { ownWriter, ownWritesOf } from "./own-writes.mjs";
45
+ import { ensureRepack } from "./repack.mjs";
38
46
  import { publishable, unpublished } from "./publish.mjs";
39
- import { peeledOf } from "../storage/wants.mjs";
47
+ import { peeledAll, peeledOf } from "../storage/wants.mjs";
48
+ import { CoreParts, ObjectsParts } from "./parts.mjs";
49
+ import { Authorize, check } from "../contracts/authorize.mjs";
50
+ import { read } from "./objects/objects.mjs";
40
51
  import { checkWrites } from "@ref0/infra";
41
52
  import * as Effect from "effect/Effect";
53
+ import * as Clock$1 from "effect/Clock";
42
54
  import * as Result from "effect/Result";
55
+ import * as Equal from "effect/Equal";
43
56
  // src/core/push.ts
44
57
  /**
45
58
  * The push decide reads every ref, private or not: a move's `from`, a folder conflict and a
46
59
  * topic's reservation are checked against the repo as it is. What it answers the caller about a
47
60
  * name it can't write is `unseenRef`'s, the same whatever is there.
48
61
  */
49
- const pushWhole = WholeRepo.mint();
62
+ const pushWhole = /* @__PURE__ */ WholeRepo.mint();
50
63
  const packsRead = { collection: collections.packs };
51
64
  const refsRead = { collection: collections.refs };
52
65
  const timesRead = { collection: collections.stats };
@@ -55,7 +68,6 @@ const cruftRead = {
55
68
  collection: objectCollections.cruft,
56
69
  limit: 65
57
70
  };
58
- const mirrorsRead = { collection: collections.mirrors };
59
71
  /**
60
72
  * A queue publish refused for `entries`, whose heads would publish commits their own callers may
61
73
  * not: each fails alone, and the queue builds the rest again.
@@ -88,8 +100,8 @@ const refuseQueued = (request, refusals, by) => {
88
100
  const first = refusals.find((error) => error !== void 0);
89
101
  return first === void 0 ? Effect.void : Effect.fail(first);
90
102
  };
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)]]));
103
+ /** The edits `refView` refuses: each name its caller can't write, as for a name with no ref there. */
104
+ 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
105
  /**
94
106
  * One fence over `fences`, each caller's, in the push's final read: their reads together, and each
95
107
  * check on its own results. A queue's publish hears every credential that ended, by its place.
@@ -115,16 +127,18 @@ const fenceAll = (request, fences) => {
115
127
  };
116
128
  };
117
129
  const moved = { queueMoved: true };
118
- /** A queue's push whose repo moved past the version it planned at: `UNAVAILABLE`. */
130
+ /**
131
+ * A queue's push whose repo moved past the version it planned at, or a build's whose fenced row
132
+ * changed: `UNAVAILABLE`.
133
+ */
119
134
  const queueMoved = (repo) => gitError("UNAVAILABLE", `'${repo}' moved while its merge queue wrote`, {
120
135
  hint: "Try again",
121
136
  cause: moved
122
137
  });
123
- const atomicHint = "Another ref in this atomic push was refused";
124
138
  /** A queue push's refused ref, the cause's before the rest's, so its writes commit with none. */
125
139
  const refusalOf = (updated) => {
126
140
  const refused = updated.updates.flatMap((update) => update.kind === "rejected" ? [update.error] : []);
127
- return refused.find((error) => error.hint !== atomicHint) ?? refused[0];
141
+ return refused.find((error) => error.context?.reason !== "atomic-partner") ?? refused[0];
128
142
  };
129
143
  /** Whether a push failed only since its repo moved past the queue's plan. */
130
144
  const isQueueMoved = (error) => error.cause === moved;
@@ -175,12 +189,12 @@ const markOf = (rows) => {
175
189
  * caller who can't read the repo gets the read's answer, as for a name with no repo, before a byte
176
190
  * of the pack is read: only a caller who can read it is told a push is refused.
177
191
  */
178
- const firstRead = (core, caller, operation, internalId) => openRepo(core, caller, {
192
+ const firstRead = (caller, operation, internalId) => openRepo(caller, {
179
193
  kind: "read",
180
194
  repo: operation.repo
181
195
  }, [packsRead, prunedKey], internalId);
182
196
  /** `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, {
197
+ const keyedRead = (caller, operation, missed, internalId) => openKeyed(caller, {
184
198
  kind: "read",
185
199
  repo: operation.repo
186
200
  }, [packsRead, prunedKey], missed, internalId);
@@ -189,14 +203,10 @@ const keyedRead = (core, caller, operation, missed, internalId) => openKeyed(cor
189
203
  * received against, its default branch, whose move rebuilds the ready shallow pack, and its
190
204
  * `pruned` mark.
191
205
  */
192
- const listedFor = Effect.fnUntraced(function* (core, request, operation, resolved) {
206
+ const listedFor = /* @__PURE__ */ Effect.fnUntraced(function* (request, operation, resolved) {
193
207
  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 repo = repoAccess(resolved);
209
+ if (request.queued === void 0) yield* check({
200
210
  caller,
201
211
  operation,
202
212
  repo
@@ -208,8 +218,8 @@ const listedFor = Effect.fnUntraced(function* (core, request, operation, resolve
208
218
  packs
209
219
  };
210
220
  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;
221
+ const views = yield* Effect.forEach(decidingFor(request), (one) => viewOf(one, resolved, source));
222
+ const [view = yield* viewOf(caller, resolved, source)] = views;
213
223
  return {
214
224
  listed,
215
225
  defaultBranch: headOf(resolved.record.defaultBranch),
@@ -225,21 +235,28 @@ const listedFor = Effect.fnUntraced(function* (core, request, operation, resolve
225
235
  * caller sees, read after `authorize` let the caller in, at a version of their own, which the
226
236
  * push's objects read at too.
227
237
  */
228
- const seenRefsOf = Effect.fnUntraced(function* (core, view, listed) {
238
+ const seenRefsOf = /* @__PURE__ */ Effect.fnUntraced(function* (view, listed) {
239
+ const core = yield* CoreParts;
229
240
  if (!(yield* view.narrowed)) return {
230
241
  listed,
231
242
  refs: /* @__PURE__ */ new Map()
232
243
  };
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] ?? []);
244
+ const { snapshot } = yield* readRecord(core.store, listed.repo, [
245
+ refsRead,
246
+ packsRead,
247
+ indexRowKey
248
+ ]);
249
+ const [, refRows = [], packRows = [], indexRows = []] = snapshot.results;
250
+ const packs = yield* decodePacks(packRows);
251
+ const refs = yield* view.refs(refRows);
236
252
  return {
237
253
  listed: {
238
254
  ...listed,
239
255
  version: snapshot.version,
240
256
  packs
241
257
  },
242
- refs
258
+ refs,
259
+ index: indexRows[0]?.value
243
260
  };
244
261
  });
245
262
  /**
@@ -267,13 +284,9 @@ const pushedOf = (objects, listed, received) => {
267
284
  * Whether the push brings commit `oid`, for the file rules' walk: its own object, read as `pushed`
268
285
  * reads one, its bytes let go unread. A read that fails throws, so the walk trusts nothing.
269
286
  */
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
- };
287
+ 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
288
  /** The refs the repo mirrors, among `rows` of `mirrors`: each one an active mirror names. */
276
- const activeMirrors = Effect.fnUntraced(function* (rows) {
289
+ const activeMirrors = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
277
290
  const active = /* @__PURE__ */ new Set();
278
291
  for (const row of rows) if ((yield* decodeRow(MirrorRow, row, `Mirror '${row.id}'`)).state === "active") active.add(row.id);
279
292
  return active;
@@ -309,7 +322,25 @@ const withReceivedRows = (objects, received) => {
309
322
  const row = rows.get(input.oid);
310
323
  return row === void 0 ? objects.read(listed, input) : Effect.map(objectOfRow(row), gitObjectOf);
311
324
  },
312
- objects: (listed, input) => Effect.gen(function* () {
325
+ headers: Effect.fnUntraced(function* (listed, input) {
326
+ const answer = /* @__PURE__ */ new Map();
327
+ const stored = input.oids.filter((oid) => !rows.has(oid));
328
+ for (const oid of input.oids) {
329
+ const row = rows.get(oid);
330
+ if (row === void 0) continue;
331
+ const object = yield* objectOfRow(row);
332
+ answer.set(oid, {
333
+ type: object.type,
334
+ size: object.bytes.byteLength
335
+ });
336
+ }
337
+ if (stored.length > 0) for (const [oid, header] of yield* objects.headers(listed, {
338
+ ...input,
339
+ oids: stored
340
+ })) answer.set(oid, header);
341
+ return answer;
342
+ }),
343
+ objects: Effect.fnUntraced(function* (listed, input) {
313
344
  const asked = [...new Set(input.oids)];
314
345
  const [first] = asked;
315
346
  if (first === void 0 || !asked.some((oid) => rows.has(oid))) return yield* objects.objects(listed, {
@@ -331,14 +362,50 @@ const withReceivedRows = (objects, received) => {
331
362
  };
332
363
  };
333
364
  /**
365
+ * The rows a build's write is fenced on, the one list of them (Q885): the repo's `pruned` mark, as
366
+ * its links read objects a prune may drop; its target's queue row, which names its open holds, and
367
+ * each of their rows, `holds`, which its lift reads; the target's ref, its tip, which a land links
368
+ * onto and a merge at the build compares; its candidate's row; and each entry it links, found or
369
+ * not. An entry's notes are fixed by its row: its `meta` and its report are each written only with
370
+ * a put of an entry's row that names them, which `pushPlan` holds. A key row (`latest`, `merged`)
371
+ * isn't one: a build reads none. The build takes each one's value from the read its plan made, and
372
+ * `finalRead` reads them again, so the write commits only while every one holds it, whatever else
373
+ * the repo's other writes moved.
374
+ */
375
+ const buildFence = (build) => [
376
+ prunedKey,
377
+ {
378
+ collection: collections.queueTargets,
379
+ id: build.target
380
+ },
381
+ ...build.holds.map((id) => ({
382
+ collection: collections.queueHolds,
383
+ id
384
+ })),
385
+ {
386
+ collection: collections.refs,
387
+ id: build.target
388
+ },
389
+ {
390
+ collection: collections.queueCandidates,
391
+ id: build.candidate
392
+ },
393
+ ...build.entries.map((id) => ({
394
+ collection: collections.queueEntries,
395
+ id
396
+ }))
397
+ ];
398
+ /**
334
399
  * 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`,
400
+ * if it has one, its key's receipt if it has a key, the mirror of each ref in `touched`, the
401
+ * queue's row of each branch in `branches`,
336
402
  * 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
403
  * does a write with the same key that commits first. A prune that dropped objects since the first
338
404
  * 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).
405
+ * answers, it fails, to be sent again (Q270). `changed`: whether a row of a build's fence,
406
+ * `unchanged`, holds another value than its plan read.
340
407
  */
341
- const finalRead = Effect.fnUntraced(function* (store, repo, fence, received, kept, mark, branches) {
408
+ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fence, received, kept, mark, branches, touched, guard, unchanged = []) {
342
409
  const own = received?.quarantine === void 0 ? [] : [received.quarantine];
343
410
  const keyed = receiptReads(kept);
344
411
  const targets = branches.map((id) => ({
@@ -352,21 +419,30 @@ const finalRead = Effect.fnUntraced(function* (store, repo, fence, received, kep
352
419
  }));
353
420
  const { record, snapshot } = yield* readRecord(store, repo.internalId, [
354
421
  refsRead,
355
- mirrorsRead,
356
422
  ...outboxReads,
357
423
  packsRead,
358
424
  prunedKey,
359
425
  timesRead,
360
426
  cruftRead,
361
427
  indexRowKey,
428
+ reachedKey,
362
429
  ...own,
363
430
  ...keyed,
364
431
  ...targets,
365
- ...fence.reads
432
+ ...fence.reads,
433
+ ...guard?.reads ?? [],
434
+ ...unchanged.map(({ collection, id }) => ({
435
+ collection,
436
+ id
437
+ })),
438
+ ...touched.map((id) => ({
439
+ collection: collections.mirrors,
440
+ id
441
+ }))
366
442
  ], rowCounts);
367
443
  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;
444
+ const [, refRows = [], headRows = [], cursorRows = [], packRows = [], ...more] = snapshot.results;
445
+ const [markRows = [], timeRows = [], cruftRows = [], indexRows = [], reachedRows = [], ...rest] = more;
370
446
  const receipt = yield* heldReceipt(rest.slice(own.length, own.length + keyed.length), kept);
371
447
  if (receipt === void 0 && (yield* markOf(markRows)) !== mark) return yield* fail("UNAVAILABLE", "The repo was pruned during the push", { hint: "Push again" });
372
448
  const targeted = rest.slice(own.length + keyed.length, own.length + keyed.length + targets.length);
@@ -376,7 +452,14 @@ const finalRead = Effect.fnUntraced(function* (store, repo, fence, received, kep
376
452
  const reservation = live[index];
377
453
  return reservation === void 0 ? [] : [[branch, reservedTarget(branch, reservation)]];
378
454
  }));
379
- const fenced = rest.slice(own.length + keyed.length + targets.length);
455
+ const fencedAt = own.length + keyed.length + targets.length;
456
+ const fenced = rest.slice(fencedAt, fencedAt + fence.reads.length);
457
+ const guardAt = fencedAt + fence.reads.length;
458
+ const guardedAt = guardAt + (guard?.reads.length ?? 0);
459
+ if (guard !== void 0) yield* guard.check(rest.slice(guardAt, guardedAt));
460
+ const now = rest.slice(guardedAt, guardedAt + unchanged.length);
461
+ const mirrorRows = rest.slice(guardedAt + unchanged.length).flat();
462
+ const changed = unchanged.some((row, at) => !Equal.equals(row.value, now[at]?.[0]?.value));
380
463
  const packs = yield* decodePacks(packRows);
381
464
  const times = yield* decodeTimes(timeRows);
382
465
  const [ownRow] = own.length === 0 ? [] : rest[0] ?? [];
@@ -391,7 +474,10 @@ const finalRead = Effect.fnUntraced(function* (store, repo, fence, received, kep
391
474
  const read = {
392
475
  version: snapshot.version,
393
476
  refs,
394
- head: headOf(record.defaultBranch)
477
+ refBytes: refBytesOf(refRows),
478
+ head: headOf(record.defaultBranch),
479
+ record,
480
+ marked: reachedRows.length > 0
395
481
  };
396
482
  const at = {
397
483
  repo: repo.internalId,
@@ -424,7 +510,8 @@ const finalRead = Effect.fnUntraced(function* (store, repo, fence, received, kep
424
510
  times,
425
511
  queued,
426
512
  reserved,
427
- indexRow
513
+ indexRow,
514
+ changed
428
515
  };
429
516
  });
430
517
  const settingsOf = (record) => ({
@@ -432,32 +519,10 @@ const settingsOf = (record) => ({
432
519
  public: record.public,
433
520
  defaultBranch: record.defaultBranch
434
521
  });
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
522
  /** The rules, then `hooks.preReceive`, once, at the first read the push decides on. */
458
- const runChecks = Effect.fnUntraced(function* (checks, input, facts) {
523
+ const runChecks = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, facts) {
459
524
  const context = checking(input);
460
- const ruled = yield* builtInAfter(checks, input, yield* runPushRules(checks, input, context));
525
+ const ruled = yield* claimedAfter(checks, input, yield* runPushRules(checks, input, context));
461
526
  const whole = yield* runPreReceive(checks.reports, checks.preReceive, context, {
462
527
  atomic: input.atomic,
463
528
  updates: ruled.updates,
@@ -479,17 +544,21 @@ const runChecks = Effect.fnUntraced(function* (checks, input, facts) {
479
544
  * hook refuses, on a ref none refused before, is told by its place, and the push fails. Passed, the
480
545
  * answer is the first caller's, with the files allowed and the rules lifted for any of them.
481
546
  */
482
- const checkAll = Effect.fnUntraced(function* (checks, request, input, facts, authorizeAs) {
547
+ const checkAll = /* @__PURE__ */ Effect.fnUntraced(function* (checks, request, input, facts, authorizeAs) {
483
548
  if (request.queued === void 0) return yield* runChecks(checks, input, facts);
484
549
  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);
550
+ const refusals = [];
551
+ for (const caller of request.queued.callers) {
552
+ const one = yield* runChecks(checks, {
553
+ ...input,
554
+ caller,
555
+ authorize: authorizeAs(caller)
556
+ }, facts);
557
+ const refusal = one.whole ?? [...one.refused].find(([ref]) => !input.refused.has(ref))?.[1];
558
+ if (refusal !== void 0 && retriedCodes.has(refusal.code)) return yield* Effect.fail(refusal);
559
+ each.push(one);
560
+ refusals.push(refusal);
561
+ }
493
562
  yield* refuseQueued(request, refusals, "rules");
494
563
  const union = (pick) => {
495
564
  const merged = /* @__PURE__ */ new Map();
@@ -508,25 +577,28 @@ const checkAll = Effect.fnUntraced(function* (checks, request, input, facts, aut
508
577
  bypassed: union((one) => one.bypassed)
509
578
  };
510
579
  });
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
- });
580
+ /**
581
+ * The rules' answer, with the refs the claimed checks refuse among the rest: each in turn, by band
582
+ * then claim name, on the refs none before it refused, so a ref's first refusal is its answer.
583
+ */
584
+ const claimedAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, ruled) {
585
+ const refused = new Map(ruled.refused);
586
+ for (const { handler } of checks.claimed?.() ?? []) {
587
+ const updates = ruled.updates.filter((update) => !refused.has(update.ref));
588
+ if (updates.length === 0) break;
589
+ for (const [ref, error] of yield* handler(input, updates)) if (!refused.has(ref)) refused.set(ref, error);
590
+ }
519
591
  return {
520
592
  ...ruled,
521
- refused: new Map([...ruled.refused, ...refused])
593
+ refused
522
594
  };
523
595
  });
524
- /** Whether a push has anything to check: a rule, the built-in check, or `hooks.preReceive`. */
525
- const checksOf = (core) => {
596
+ /** Whether a push has anything to check: a rule, a claimed check, or `hooks.preReceive`. */
597
+ const checksOf = /* @__PURE__ */ Effect.fnUntraced(function* (core) {
526
598
  const { checks } = core;
527
599
  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
- };
600
+ return (yield* pushRulesFor(checks)).length > 0 || checks.preReceive !== void 0 || (checks.claimed?.().length ?? 0) > 0 ? checks : void 0;
601
+ });
530
602
  /**
531
603
  * The repo's objects with the push's own, for the built-in check: `objects` and `listed` read
532
604
  * both, and `received` is the push's alone.
@@ -540,6 +612,17 @@ const pushedObjectsOf = (objects, listed, received, own) => {
540
612
  lfsPointers: received?.lfsPointers ?? noLfsPointers
541
613
  };
542
614
  };
615
+ /** `decision`, a commit that clears the mark, with the clear's row at `at` among its puts. */
616
+ const clearedAt = (decision, at) => decision.kind === "commit" ? {
617
+ ...decision,
618
+ change: {
619
+ ...decision.change,
620
+ put: [...decision.change.put, {
621
+ ...pruneClearedKey,
622
+ value: { at }
623
+ }]
624
+ }
625
+ } : decision;
543
626
  /**
544
627
  * What a decision commits: its writes and jobs at `expect`, or, for an answer that moves no ref,
545
628
  * nothing, which a keyed write's receipt still commits at the read's version. A refusal fails.
@@ -568,7 +651,7 @@ const planOf = (decision, version, jobs) => {
568
651
  * Each force among `kinds.updates` that its exact walk agrees is one, as a `diverged` refusal in
569
652
  * `diverged`, or the walk's own error past its bound in `refused`.
570
653
  */
571
- const divergedOf = Effect.fnUntraced(function* (kinds) {
654
+ const divergedOf = /* @__PURE__ */ Effect.fnUntraced(function* (kinds) {
572
655
  const refused = /* @__PURE__ */ new Map();
573
656
  const diverged = /* @__PURE__ */ new Map();
574
657
  for (const update of kinds.updates) {
@@ -597,7 +680,7 @@ const divergedOf = Effect.fnUntraced(function* (kinds) {
597
680
  * What the checks refused, and for a fetch, each diverged ref: refused, or with `force`, among
598
681
  * `forced`.
599
682
  */
600
- const fetchedRefused = Effect.fnUntraced(function* (kinds, request) {
683
+ const fetchedRefused = /* @__PURE__ */ Effect.fnUntraced(function* (kinds, request) {
601
684
  const { fetched } = request;
602
685
  if (fetched === void 0) return {
603
686
  refused: kinds.refused,
@@ -636,7 +719,7 @@ const commitTooLarge = (received, body) => (error) => {
636
719
  return gitError("RESOURCE_EXHAUSTED", `push's objects don't fit one commit: ${error.message}`, {
637
720
  cause: error,
638
721
  hint: "Push fewer objects at a time",
639
- hostHint: "Use packs() storage, which keeps a push's objects in the bucket",
722
+ hostHint: "Use Objects.layer() storage, which keeps a push's objects in the bucket",
640
723
  context: { reason: "too-large" }
641
724
  });
642
725
  };
@@ -649,6 +732,13 @@ const fits = (change) => {
649
732
  return false;
650
733
  }
651
734
  };
735
+ /** A push whose links or old tips the caller's set can't close yet, as between a large push and its update. */
736
+ const unindexedPush = () => gitError("RESOURCE_EXHAUSTED", "This push can't be checked until the repo's index is updated", {
737
+ hint: "Push again once the index is updated",
738
+ context: { reason: "walk-limit" }
739
+ });
740
+ /** `error`, a read by ID the index can't close yet told as the push's own. */
741
+ const asPushCheck = (error) => isUnindexedRead(error) ? unindexedPush() : error;
652
742
  /** The request's pack into its quarantine, or `undefined` for a push with none. */
653
743
  const receive = (objects, listed, request) => {
654
744
  const { pack, shallow, signal } = request;
@@ -656,6 +746,10 @@ const receive = (objects, listed, request) => {
656
746
  received: void 0,
657
747
  rooted: void 0
658
748
  });
749
+ if ("received" in pack) return Effect.succeed({
750
+ received: pack.received,
751
+ rooted: void 0
752
+ });
659
753
  const input = {
660
754
  pack: pack.bytes,
661
755
  objects: pack.objects
@@ -665,6 +759,9 @@ const receive = (objects, listed, request) => {
665
759
  if (shallow !== void 0 && shallow.length > 0) input.shallow = shallow;
666
760
  if (signal !== void 0) input.signal = signal;
667
761
  if (pack.partial === true) input.partial = true;
762
+ if (pack.boundary !== void 0 && pack.boundary.length > 0) input.boundary = pack.boundary;
763
+ if (pack.needs !== void 0 && pack.needs.length > 0) input.needs = pack.needs;
764
+ if (pack.cutMost !== void 0) input.cutMost = pack.cutMost;
668
765
  return scopedReceive(objects, listed, input).pipe(Effect.map((received) => ({
669
766
  received,
670
767
  rooted: void 0
@@ -673,15 +770,20 @@ const receive = (objects, listed, request) => {
673
770
  rooted
674
771
  })));
675
772
  };
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 {
773
+ /**
774
+ * `ref.updated`'s `push`: the write, how many branches and tags it moved and each private
775
+ * pattern's part of them (`pushCounts`), its source, and the slice its push options name, if they
776
+ * do (Q901).
777
+ */
778
+ const pushOf = (access, id, moved, request) => {
779
+ const push = {
680
780
  id,
681
- branches: under("refs/heads/"),
682
- tags: under("refs/tags/"),
683
- source
781
+ ...pushCounts(access, moved),
782
+ source: request.source
684
783
  };
784
+ const slice = sliceOf(request.pushOptions ?? []);
785
+ if (slice !== void 0) push.slice = slice;
786
+ return push;
685
787
  };
686
788
  /**
687
789
  * What a push's commit saves for `hooks.postReceive`, when the host passed one: the push, with
@@ -721,17 +823,26 @@ const savedPush = (checks, push) => {
721
823
  * version, with the ref moves, the receipt, the events and the push `hooks.postReceive` owes.
722
824
  * `answers` says what the call answers and keeps.
723
825
  */
724
- const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRepo, view, views }, key, answers) => Effect.scoped(Effect.gen(function* () {
826
+ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, view, views }, key, answers) => Effect.scoped(Effect.gen(function* () {
827
+ const core = yield* CoreParts;
828
+ const { objects: sealed } = yield* ObjectsParts;
829
+ const authorize = yield* Authorize;
725
830
  const { store } = core;
726
831
  const { caller, repo, signal } = request;
727
832
  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);
833
+ const seen = yield* seenRefsOf(view, listed);
834
+ const { received, rooted } = yield* receive(yield* read({
835
+ view,
836
+ at: seen
837
+ }), listed, request).pipe(Effect.tapError((error) => isAwaitingRepack(error) ? bestEffort(ensureRepack(core, core.jobs, repoScope(listed.repo))) : Effect.void), Effect.mapError(asPushCheck));
730
838
  const viewed = received === void 0 ? seen : {
731
839
  ...seen,
732
840
  pushed: received
733
841
  };
734
- const objects = yield* walkObjects(effectObjects(yield* view.objectsAt(viewed)), received?.allotment);
842
+ const objects = yield* walkObjects(objectsFace(yield* read({
843
+ view,
844
+ at: viewed
845
+ })), received?.allotment);
735
846
  const pushedObjects = withReceivedRows(objects, received);
736
847
  const pushedListed = withReceived(listed, received);
737
848
  const pushed = pushedOf(objects, listed, received);
@@ -743,7 +854,7 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
743
854
  ...call
744
855
  };
745
856
  if (rooted !== void 0) kindsInput.missing = rooted;
746
- const kinds = yield* kindsOf(kindsInput);
857
+ const kinds = yield* kindsOf(kindsInput).pipe(Effect.mapError(asPushCheck));
747
858
  const fetchedOff = yield* fetchedRefused(kinds, request);
748
859
  const { forced } = fetchedOff;
749
860
  const refused = new Map(fetchedOff.refused);
@@ -751,17 +862,17 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
751
862
  const own = gitsOwnRef(update.ref, request.source);
752
863
  if (own !== void 0 && !refused.has(update.ref)) refused.set(update.ref, own);
753
864
  }
754
- const sights = yield* Effect.forEach(views, (one) => one.sight);
755
- const unseens = sights.map((sight) => unseenOf(sight, request.edits));
865
+ const refViews = yield* Effect.forEach(views, (one) => one.refView);
866
+ const unseens = refViews.map((refView) => unseenOf(refView, request.edits));
756
867
  yield* refuseQueued(request, unseens.map((one) => one.values().next().value), "access");
757
868
  const unseen = unseens[0] ?? /* @__PURE__ */ new Map();
758
869
  const { updates } = kinds;
759
870
  for (const [ref, error] of unseen) refused.set(ref, error);
760
871
  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));
872
+ const barred = access?.patterns.some((pattern) => refViews.some((refView) => !publishable(refView, pattern))) === true;
873
+ const whole = objectsFace(SealedObjects.whole(sealed, pushWhole));
763
874
  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);
875
+ const refView = refViews[0] ?? (yield* view.refView);
765
876
  const publishedRefs = (refs) => new Map([...refs].filter(([ref]) => hiddenUnder(ref) === void 0));
766
877
  const writer = access === void 0 ? void 0 : yield* ownWriter(caller);
767
878
  const made = new Set(request.own);
@@ -769,14 +880,18 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
769
880
  const here = oids.filter((oid) => made.has(oid));
770
881
  const stored = oids.filter((oid) => !made.has(oid));
771
882
  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]));
883
+ return Effect.map(Effect.flatMap(Clock$1.currentTimeMillis, (now) => ownWritesOf(core.store, listed.repo, writer, stored, now)), (kept) => /* @__PURE__ */ new Set([...here, ...kept]));
773
884
  };
774
- const unpublishedAt = (refs, at, judging, edits, own) => access === void 0 || wholePushed === void 0 ? Effect.succeed(/* @__PURE__ */ new Map()) : unpublished({
885
+ const unpublishedAt = (refs, at, index, judging, edits, own) => access === void 0 || wholePushed === void 0 ? Effect.succeed(/* @__PURE__ */ new Map()) : unpublished({
775
886
  access,
776
- sight: judging,
887
+ refView: judging,
777
888
  refs: publishedRefs(refs),
778
889
  objects: whole,
779
890
  listed: at,
891
+ visible: (tips, fallback) => SealedObjects.visibleWhole(sealed, pushWhole, at, {
892
+ tips,
893
+ row: index?.value
894
+ }, fallback),
780
895
  pushed: wholePushed,
781
896
  pushedListed: withReceived(at, received),
782
897
  edits,
@@ -784,9 +899,9 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
784
899
  ...call
785
900
  });
786
901
  const headsOf = (edit) => edit.to === null ? void 0 : request.publishes?.get(edit.ref);
787
- const publishedAt = (refs, at) => Effect.gen(function* () {
902
+ const publishedAt = Effect.fnUntraced(function* (refs, at, index) {
788
903
  const plain = request.edits.filter((edit) => headsOf(edit) === void 0);
789
- const refused = new Map(yield* unpublishedAt(refs, at, sight, plain, ownOf));
904
+ const refused = new Map(yield* unpublishedAt(refs, at, index, refView, plain, ownOf));
790
905
  for (const edit of request.edits) {
791
906
  const heads = headsOf(edit);
792
907
  if (heads === void 0) continue;
@@ -796,8 +911,8 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
796
911
  }
797
912
  const failed = [];
798
913
  for (const { entry, head, caller: its } of heads) {
799
- const judging = yield* sightIn(core, its, checkedRepo);
800
- if ((yield* unpublishedAt(refs, at, judging, [{
914
+ const judging = yield* refViewIn(its, checkedRepo);
915
+ if ((yield* unpublishedAt(refs, at, index, judging, [{
801
916
  ...edit,
802
917
  to: head
803
918
  }])).has(edit.ref)) failed.push(entry);
@@ -806,11 +921,19 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
806
921
  }
807
922
  return refused;
808
923
  });
924
+ const tagTips = updates.flatMap((update) => update.to !== null && storesPeel(update.ref) ? [update.to] : []);
925
+ const peeling = yield* peeledAll(pushedObjects, pushedListed, tagTips);
926
+ const peels = new Map(tagTips.map((tip) => [tip, peeling.peeled.get(tip) ?? null]));
927
+ for (const update of updates) {
928
+ const error = update.to === null ? void 0 : peeling.refused.get(update.to);
929
+ if (error !== void 0 && storesPeel(update.ref) && !refused.has(update.ref)) refused.set(update.ref, error);
930
+ }
809
931
  const command = {
810
932
  source: request.source,
811
933
  updates,
812
934
  atomic: request.atomic,
813
- refused
935
+ refused,
936
+ peels
814
937
  };
815
938
  if (received !== void 0) command.received = received;
816
939
  const target = {
@@ -822,11 +945,12 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
822
945
  const jobs = (received?.change.add?.length ?? 0) > 0 || ready ? [core.repackJobRow()] : [];
823
946
  const own = updates.filter((update) => gitsOwnMove(request.source, update.ref));
824
947
  const outside = updates.filter((update) => !gitsOwnMove(request.source, update.ref));
825
- const checks = outside.length === 0 ? void 0 : checksOf(core);
948
+ const checks = outside.length === 0 ? void 0 : yield* checksOf(core);
826
949
  const branches = request.source === "queue" ? [] : outside.map((update) => update.ref).filter((ref) => ref.startsWith("refs/heads/"));
827
950
  const scope = yield* callScope;
828
951
  const reader = readerOf(pushedObjects, pushedListed, scope);
829
952
  const batch = batchOf(pushedObjects, pushedListed, scope);
953
+ const { between } = yield* Changes;
830
954
  const unaborted = signal ?? new AbortController().signal;
831
955
  const base = {
832
956
  caller,
@@ -840,9 +964,14 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
840
964
  },
841
965
  exact: kinds.exact,
842
966
  scope,
843
- changes: (updates) => changesOf(reader, updates, unaborted, batch),
967
+ changes: (updates) => Effect.map(Effect.forEach(updates, ({ from, to }) => between({
968
+ objects: pushedObjects,
969
+ listed: pushedListed,
970
+ from: from ?? void 0,
971
+ to: to ?? void 0
972
+ })), (each) => each.flat()),
844
973
  objects: pushedObjectsOf(pushedObjects, pushedListed, received, pushed),
845
- authorize: (operation) => core.authorize({
974
+ authorize: (operation) => authorize.check({
846
975
  caller,
847
976
  operation,
848
977
  repo: checkedRepo
@@ -857,21 +986,20 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
857
986
  source: request.source,
858
987
  allotment: received?.allotment,
859
988
  readerAllotment: pushedObjects.allotment(pushedListed, openTreeBytes, openTreesRefusal),
860
- brought: broughtCommit(pushed, scope),
861
- scope
989
+ brought: broughtCommit(pushed)
862
990
  };
863
991
  if (request.pushOptions !== void 0) base.pushOptions = request.pushOptions;
864
992
  if (request.request !== void 0) base.request = request.request;
865
993
  let checked;
866
994
  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);
995
+ const at = yield* Clock$1.currentTimeMillis;
996
+ const decide = yield* finalRead(store, target, fence, received, key, mark, branches, updates.map(({ ref }) => ref), request.guard, request.writes?.unchanged);
869
997
  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);
998
+ const indexed = SealedObjects.whole(sealed, pushWhole).index?.status(indexRow, at, listedIds(decide.at, received?.change));
871
999
  if (receipt !== void 0) return yield* answers.held(receipt);
872
- const published = yield* publishedAt(read.refs, decide.at);
1000
+ const published = yield* publishedAt(read.refs, decide.at, indexRow);
873
1001
  const { writes } = request;
874
- if (writes !== void 0 && read.version !== writes.version) return yield* Effect.fail(queueMoved(repo));
1002
+ if (writes !== void 0 && (writes.unchanged === void 0 ? read.version !== writes.version : decide.changed)) return yield* Effect.fail(queueMoved(repo));
875
1003
  const seen = {
876
1004
  ...facts,
877
1005
  tips: tipsOf(read.refs, outside)
@@ -898,7 +1026,7 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
898
1026
  return commitChangesOf(judging, updates);
899
1027
  }
900
1028
  };
901
- checked = yield* checkAll(checks, request, input, seen, (one) => (operation) => core.authorize({
1029
+ checked = yield* checkAll(checks, request, input, seen, (one) => (operation) => authorize.check({
902
1030
  caller: one,
903
1031
  operation,
904
1032
  repo: checkedRepo
@@ -923,18 +1051,24 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
923
1051
  ...unseen
924
1052
  ])
925
1053
  };
926
- const planned = yield* planOf(decidePush({
1054
+ const chosen = decidePush({
927
1055
  read,
928
- command: decided
929
- }), read.version, jobs);
1056
+ command: decided,
1057
+ index: core.refIndex
1058
+ });
1059
+ const clears = read.marked === true && clearsMark(chosen);
1060
+ const decision = clears ? clearedAt(chosen, at) : chosen;
1061
+ const upkept = clears && jobs.length === 0 ? [core.repackJobRow()] : jobs;
1062
+ const planned = yield* planOf(decision, read.version, upkept);
930
1063
  const { change } = planned;
931
1064
  const refusal = writes === void 0 ? void 0 : refusalOf(planned.answer);
932
1065
  if (refusal !== void 0) return yield* Effect.fail(refusal);
933
1066
  const movedRefs = new Set(planned.moved.map((move) => move.ref));
934
1067
  const liftedOnMoves = [...checked?.bypassed ?? none].filter(([ref]) => movedRefs.has(ref));
935
1068
  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;
1069
+ const also = planned.answer.updates.some((update) => update.kind === "rejected") || request.also === void 0 ? void 0 : request.also(yield* Clock$1.currentTimeMillis, received);
1070
+ const alsoWrites = (also?.put.length ?? 0) + (also?.delete?.length ?? 0);
1071
+ const quiet = key === void 0 && alsoWrites === 0 && writes === void 0;
938
1072
  if (!planned.moves && quiet) return answer;
939
1073
  const scope = repoScope(listed.repo);
940
1074
  const { name } = record;
@@ -947,7 +1081,7 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
947
1081
  const envelope = repoEnvelope(caller, name);
948
1082
  const id = newChangeId();
949
1083
  const shown = planned.moved.filter((move) => !gitsOwnMove(request.source, move.ref));
950
- const push = pushOf(id, shown, request.source);
1084
+ const push = pushOf(core.access, id, shown, request);
951
1085
  const events = shown.map((move) => {
952
1086
  const updated = {
953
1087
  type: "ref.updated",
@@ -995,6 +1129,7 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
995
1129
  delete: [
996
1130
  ...change.delete,
997
1131
  ...appended.delete,
1132
+ ...also?.delete ?? [],
998
1133
  ...writes?.delete ?? []
999
1134
  ],
1000
1135
  jobs: withJobs([
@@ -1004,9 +1139,18 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
1004
1139
  ...mirrorJobs(core, planned.moved, mirrored),
1005
1140
  ...writes?.jobs ?? [],
1006
1141
  ...woken,
1007
- ...shown.length > 0 ? indexJobs(core, indexed) : []
1142
+ ...shown.length > 0 ? indexJobs(core, indexed) : [],
1143
+ ...planned.moves ? refIndexJobs(core, record) : []
1008
1144
  ], [...kept.jobs, ...also?.jobs ?? []])
1009
1145
  };
1146
+ const objects = (received?.change.put?.length ?? 0) + (received?.change.delete?.length ?? 0);
1147
+ const written = body.put.length + body.delete.length + body.jobs.length;
1148
+ const past = otherWritesProblem({
1149
+ writes: written,
1150
+ objects,
1151
+ moved: planned.moved.length
1152
+ }, core.refIndex);
1153
+ if (past !== void 0) return yield* Effect.fail(past);
1010
1154
  if ((yield* storeCall(() => store.commit(scope, body)).pipe(Effect.mapError(commitTooLarge(received, body)))).ok) return final;
1011
1155
  }
1012
1156
  return yield* fail("UNAVAILABLE", `Other writes kept moving '${repo}' through 10 tries`, { hint: "Push again" });
@@ -1025,16 +1169,16 @@ const operationOf = ({ repo, edits }) => edits.length === 0 ? {
1025
1169
  * reads and decides again. A push cut before its commit leaves an unlisted pack for clean-up, and
1026
1170
  * no ref moved.
1027
1171
  */
1028
- const pushWith = (core, request, answers, key) => Effect.gen(function* () {
1172
+ const pushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, key) {
1029
1173
  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);
1174
+ const resolved = yield* firstRead(request.caller, operation, request.internalId).pipe(Effect.tapError((error) => retriedCodes.has(error.code) ? Effect.void : refuseQueued(request, [error], "access")));
1175
+ const opened = yield* listedFor(request, operation, resolved);
1176
+ return yield* pushOnto(request, opened, key, answers);
1033
1177
  });
1034
1178
  /** A push or an unkeyed `refs.update`, answering the decide's ref answer. */
1035
- const push = (core, request) => pushWith(core, request, refsAnswers);
1179
+ const push = (request) => pushWith(request, refsAnswers);
1036
1180
  /** A `git push`, as `push`, with the lines Git prints for the rules `authorize` lifted. */
1037
- const gitPush = (core, request) => pushWith(core, request, gitAnswers);
1181
+ const gitPush = (request) => pushWith(request, gitAnswers);
1038
1182
  /** A ref a forced fetch moved past its diverged tip, answered `force`; the rest as they are. */
1039
1183
  const forcedOf = (forced) => (update) => update.kind === "applied" && forced.has(update.ref) ? {
1040
1184
  kind: "force",
@@ -1049,7 +1193,7 @@ const appliedOf = (update) => update.kind === "force" ? {
1049
1193
  * A client's fetch into its own refs, as `push`, each diverged ref a forced fetch moved answered
1050
1194
  * `force`. Its refs move in one commit, so a fetch stopped before it moves none.
1051
1195
  */
1052
- const pushFetched = (core, request) => pushWith(core, request, {
1196
+ const pushFetched = (request) => pushWith(request, {
1053
1197
  answer: (updated, forced) => Effect.succeed(updated.updates.map(forcedOf(forced))),
1054
1198
  kept: (updates) => refsKept({ updates: updates.map(appliedOf) }),
1055
1199
  held: (receipt) => Effect.map(refsAnswer(receipt), (held) => held.updates)
@@ -1058,13 +1202,13 @@ const pushFetched = (core, request) => pushWith(core, request, {
1058
1202
  * `pushWith` for a write's key, which keeps its answer. `undefined`, with nothing written or
1059
1203
  * asked of `authorize`, when the name holds a repo other than the one its key's lookup saw.
1060
1204
  */
1061
- const keyedPushWith = (core, request, answers, keyed) => Effect.gen(function* () {
1205
+ const keyedPushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, keyed) {
1062
1206
  const operation = operationOf(request);
1063
- const resolved = yield* keyedRead(core, request.caller, operation, keyed.missed, request.internalId);
1207
+ const resolved = yield* keyedRead(request.caller, operation, keyed.missed, request.internalId);
1064
1208
  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);
1209
+ const opened = yield* listedFor(request, operation, resolved);
1210
+ return yield* pushOnto(request, opened, keyed.key, answers);
1067
1211
  });
1068
1212
  /** `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 };
1213
+ const keyedPush = (request, keyed) => keyedPushWith(request, refsAnswers, keyed);
1214
+ export { buildFence, gitPush, isQueueMoved, keyedPush, keyedPushWith, push, pushFetched, pushWith, retriedCodes };