@ref0/git 0.2.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 (615) 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 +23 -3
  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 +36 -9
  16. package/dist/auth/identify.d.mts +4 -1
  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 +4 -1
  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 +5 -6
  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 +97 -92
  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 +60 -19
  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/handlers.d.mts +2 -1
  75. package/dist/contracts/ids.d.mts +23 -8
  76. package/dist/contracts/ids.mjs +40 -5
  77. package/dist/contracts/lfs.d.mts +9 -4
  78. package/dist/contracts/merges.d.mts +68 -16
  79. package/dist/contracts/merges.mjs +27 -0
  80. package/dist/contracts/namespaces.d.mts +14 -0
  81. package/dist/contracts/object-values.d.mts +96 -0
  82. package/dist/contracts/object-values.mjs +104 -0
  83. package/dist/contracts/objects.d.mts +324 -88
  84. package/dist/contracts/operations.d.mts +24 -16
  85. package/dist/contracts/promises.d.mts +17 -31
  86. package/dist/contracts/promises.mjs +13 -0
  87. package/dist/contracts/push-uploads.d.mts +39 -24
  88. package/dist/contracts/push-uploads.mjs +54 -0
  89. package/dist/contracts/queue.d.mts +445 -139
  90. package/dist/contracts/queue.mjs +197 -0
  91. package/dist/contracts/refs.d.mts +248 -45
  92. package/dist/contracts/refs.mjs +117 -0
  93. package/dist/contracts/repo-records.d.mts +34 -0
  94. package/dist/contracts/repo-records.mjs +18 -0
  95. package/dist/contracts/repos.d.mts +411 -58
  96. package/dist/contracts/repos.mjs +136 -0
  97. package/dist/contracts/result.d.mts +342 -69
  98. package/dist/contracts/result.mjs +350 -5
  99. package/dist/contracts/rules.d.mts +60 -48
  100. package/dist/contracts/rules.mjs +9 -0
  101. package/dist/contracts/server.d.mts +173 -80
  102. package/dist/contracts/services.d.mts +15 -24
  103. package/dist/contracts/services.mjs +5 -9
  104. package/dist/contracts/signin.d.mts +64 -31
  105. package/dist/contracts/signin.mjs +18 -0
  106. package/dist/contracts/store.d.mts +45 -5
  107. package/dist/contracts/store.mjs +31 -0
  108. package/dist/contracts/sync.d.mts +82 -47
  109. package/dist/contracts/sync.mjs +41 -2
  110. package/dist/contracts/tags.d.mts +204 -22
  111. package/dist/contracts/tags.mjs +51 -1
  112. package/dist/contracts/tokens.d.mts +32 -7
  113. package/dist/contracts/tokens.mjs +31 -1
  114. package/dist/contracts/topics.d.mts +128 -66
  115. package/dist/contracts/topics.mjs +109 -0
  116. package/dist/contracts/trees.d.mts +132 -52
  117. package/dist/contracts/trees.mjs +105 -0
  118. package/dist/contracts/work.d.mts +127 -20
  119. package/dist/contracts/work.mjs +69 -0
  120. package/dist/core/access.d.mts +26 -15
  121. package/dist/core/access.mjs +77 -108
  122. package/dist/core/ancestry.mjs +86 -18
  123. package/dist/core/call-names.d.mts +1 -0
  124. package/dist/core/call-names.mjs +94 -0
  125. package/dist/core/call-services.mjs +73 -0
  126. package/dist/core/changes.d.mts +31 -0
  127. package/dist/core/changes.mjs +5 -0
  128. package/dist/core/clock.mjs +3 -3
  129. package/dist/core/events/deliver.mjs +130 -37
  130. package/dist/core/events/seen.mjs +124 -0
  131. package/dist/core/forks.mjs +371 -159
  132. package/dist/core/hooks/order.d.mts +9 -0
  133. package/dist/core/hooks/order.mjs +25 -0
  134. package/dist/core/hooks/post-receive.mjs +25 -16
  135. package/dist/core/hooks/pre-receive.d.mts +8 -1
  136. package/dist/core/hooks/pre-receive.mjs +8 -6
  137. package/dist/core/imports.mjs +212 -0
  138. package/dist/core/index-job.mjs +131 -38
  139. package/dist/core/merge-parts.d.mts +30 -0
  140. package/dist/core/merge-parts.mjs +31 -0
  141. package/dist/core/names.mjs +4 -16
  142. package/dist/core/namespaces.d.mts +2 -0
  143. package/dist/core/objects/blobs.mjs +4 -4
  144. package/dist/core/objects/commit-writes.mjs +19 -17
  145. package/dist/core/objects/commits.mjs +12 -12
  146. package/dist/core/objects/files.mjs +10 -11
  147. package/dist/core/objects/lines.mjs +15 -32
  148. package/dist/core/objects/merges.mjs +4 -4
  149. package/dist/core/objects/objects-layer.d.mts +21 -0
  150. package/dist/core/objects/objects-layer.mjs +47 -0
  151. package/dist/core/objects/objects-namespace.d.mts +6 -0
  152. package/dist/core/objects/objects-namespace.mjs +13 -0
  153. package/dist/core/objects/objects.d.mts +49 -0
  154. package/dist/core/objects/objects.mjs +18 -0
  155. package/dist/core/objects/peel.mjs +3 -3
  156. package/dist/core/objects/reading.mjs +135 -40
  157. package/dist/core/objects/tags.mjs +7 -7
  158. package/dist/core/objects/tree-edits.mjs +40 -27
  159. package/dist/core/objects/trees.mjs +23 -18
  160. package/dist/core/objects/writing.mjs +43 -44
  161. package/dist/core/own-writes.mjs +3 -3
  162. package/dist/core/parts.d.mts +125 -0
  163. package/dist/core/parts.mjs +59 -0
  164. package/dist/core/promise.mjs +39 -17
  165. package/dist/core/publish.mjs +27 -17
  166. package/dist/core/purge.mjs +242 -0
  167. package/dist/core/push-decide.mjs +93 -28
  168. package/dist/core/push.mjs +301 -156
  169. package/dist/core/receipts.d.mts +4 -3
  170. package/dist/core/receipts.mjs +20 -12
  171. package/dist/core/ref-conflicts.mjs +70 -4
  172. package/dist/core/ref-index-job.mjs +181 -0
  173. package/dist/core/ref-index.d.mts +25 -0
  174. package/dist/core/ref-index.mjs +136 -0
  175. package/dist/core/ref-view.mjs +166 -0
  176. package/dist/core/refs.mjs +313 -95
  177. package/dist/core/repack.d.mts +10 -0
  178. package/dist/core/repack.mjs +261 -81
  179. package/dist/core/repo-info.mjs +99 -0
  180. package/dist/core/repos.mjs +114 -80
  181. package/dist/core/rules/changes.mjs +48 -20
  182. package/dist/core/rules/check.mjs +29 -22
  183. package/dist/core/rules/commit-changes.d.mts +13 -0
  184. package/dist/core/rules/commit-changes.mjs +100 -91
  185. package/dist/core/rules/context.d.mts +67 -8
  186. package/dist/core/rules/context.mjs +88 -51
  187. package/dist/core/rules/facts.mjs +1 -1
  188. package/dist/core/rules/fetch.mjs +24 -26
  189. package/dist/core/rules/files.d.mts +13 -0
  190. package/dist/core/rules/files.mjs +27 -28
  191. package/dist/core/rules/namespace.d.mts +2 -0
  192. package/dist/core/rules/patterns.mjs +29 -5
  193. package/dist/core/rules/protect.d.mts +12 -6
  194. package/dist/core/rules/protect.mjs +22 -20
  195. package/dist/core/rules/rules-layer.d.mts +17 -0
  196. package/dist/core/rules/rules-layer.mjs +26 -0
  197. package/dist/core/rules/rules.d.mts +8 -0
  198. package/dist/core/rules/rules.mjs +16 -0
  199. package/dist/core/rules/service.mjs +18 -0
  200. package/dist/core/seam.d.mts +10 -5
  201. package/dist/core/seam.mjs +36 -19
  202. package/dist/core/tokens.mjs +29 -23
  203. package/dist/core/view.d.mts +105 -6
  204. package/dist/core/view.mjs +211 -109
  205. package/dist/core/work.mjs +40 -14
  206. package/dist/effect.d.mts +3 -4
  207. package/dist/effect.mjs +2 -3
  208. package/dist/engine/allotted-xdiff.d.mts +1 -0
  209. package/dist/engine/allotted-xdiff.mjs +1 -1
  210. package/dist/engine/attributes.mjs +1 -1
  211. package/dist/engine/combined.d.mts +18 -0
  212. package/dist/engine/combined.mjs +39 -44
  213. package/dist/engine/commits.mjs +5 -4
  214. package/dist/engine/content.d.mts +3 -2
  215. package/dist/engine/content.mjs +2 -2
  216. package/dist/engine/failures.d.mts +2 -2
  217. package/dist/engine/failures.mjs +2 -9
  218. package/dist/engine/merge-base-walk.d.mts +3 -2
  219. package/dist/engine/merge-base-walk.mjs +1 -1
  220. package/dist/engine/merge-bases.mjs +3 -2
  221. package/dist/engine/merge.mjs +568 -566
  222. package/dist/engine/parts.d.mts +3 -2
  223. package/dist/engine/parts.mjs +40 -7
  224. package/dist/engine/reads.d.mts +1 -0
  225. package/dist/engine/reads.mjs +5 -5
  226. package/dist/engine/walk.mjs +23 -24
  227. package/dist/engine/xdiff.d.mts +2 -33
  228. package/dist/engine/xdiff.mjs +6 -3
  229. package/dist/event-streams/event-streams.d.mts +25 -0
  230. package/dist/event-streams/event-streams.mjs +22 -0
  231. package/dist/event-streams/namespace.d.mts +2 -0
  232. package/dist/event-streams/stream.d.mts +42 -0
  233. package/dist/{core/events → event-streams}/stream.mjs +112 -48
  234. package/dist/extend.d.mts +5 -2
  235. package/dist/extend.mjs +3 -1
  236. package/dist/http/answers.mjs +8 -4
  237. package/dist/http/bodies.mjs +84 -56
  238. package/dist/http/core-parts.mjs +206 -60
  239. package/dist/http/handler.d.mts +2 -0
  240. package/dist/http/handler.mjs +17 -11
  241. package/dist/http/node.mjs +10 -6
  242. package/dist/http/parts.d.mts +12 -0
  243. package/dist/http/push-uploads.d.mts +9 -0
  244. package/dist/http/push-uploads.mjs +76 -66
  245. package/dist/http/receive-pack.mjs +162 -28
  246. package/dist/http/upload-pack.mjs +106 -81
  247. package/dist/index.d.mts +48 -28
  248. package/dist/index.mjs +29 -7
  249. package/dist/lfs/calls.mjs +2 -2
  250. package/dist/lfs/locks.mjs +24 -20
  251. package/dist/lfs/objects.d.mts +7 -0
  252. package/dist/lfs/objects.mjs +32 -27
  253. package/dist/lfs/pointers.mjs +7 -7
  254. package/dist/lfs/purge.mjs +50 -0
  255. package/dist/lfs/repo.mjs +5 -5
  256. package/dist/lfs/rows.mjs +9 -9
  257. package/dist/lfs/service.d.mts +9 -0
  258. package/dist/lfs/service.mjs +32 -25
  259. package/dist/lfs/upkeep.mjs +5 -5
  260. package/dist/lfs/wire.mjs +80 -38
  261. package/dist/merges/merges.d.mts +20 -0
  262. package/dist/merges/merges.mjs +32 -0
  263. package/dist/merges/namespace.d.mts +2 -0
  264. package/dist/merges/public.d.mts +6 -0
  265. package/dist/merges/public.mjs +10 -0
  266. package/dist/node.d.mts +1 -2
  267. package/dist/node.mjs +1 -3
  268. package/dist/protocol/bytes/buffers.d.mts +9 -3
  269. package/dist/protocol/bytes/buffers.mjs +11 -5
  270. package/dist/protocol/bytes/deflate.d.mts +7 -5
  271. package/dist/protocol/bytes/deflate.mjs +59 -23
  272. package/dist/protocol/bytes/inflate.d.mts +4 -3
  273. package/dist/protocol/bytes/inflate.mjs +61 -26
  274. package/dist/protocol/bytes/reader.mjs +61 -0
  275. package/dist/protocol/bytes/sha1-hasher.d.mts +3 -1
  276. package/dist/protocol/bytes/sha1-hasher.mjs +13 -3
  277. package/dist/protocol/bytes/sha1.d.mts +1 -1
  278. package/dist/protocol/bytes/sha1.mjs +5 -5
  279. package/dist/protocol/bytes/streams.mjs +16 -6
  280. package/dist/protocol/diff/patch.d.mts +4 -0
  281. package/dist/protocol/diff/patch.mjs +1 -1
  282. package/dist/protocol/diff/paths.mjs +1 -1
  283. package/dist/protocol/diff/read.d.mts +1 -1
  284. package/dist/protocol/diff/read.mjs +102 -90
  285. package/dist/protocol/framing/pkt-line.d.mts +1 -0
  286. package/dist/protocol/framing/pkt-line.mjs +40 -6
  287. package/dist/protocol/objects/checked-blobs.d.mts +1 -0
  288. package/dist/protocol/objects/fsck.mjs +7 -1
  289. package/dist/protocol/objects/held.mjs +5 -11
  290. package/dist/protocol/objects/ident.mjs +1 -1
  291. package/dist/protocol/objects/object-rules.mjs +15 -7
  292. package/dist/protocol/objects/object.d.mts +6 -2
  293. package/dist/protocol/objects/object.mjs +5 -2
  294. package/dist/protocol/objects/tag.d.mts +3 -1
  295. package/dist/protocol/objects/tag.mjs +27 -1
  296. package/dist/protocol/objects/tree.mjs +1 -1
  297. package/dist/protocol/packs/delta.d.mts +1 -1
  298. package/dist/protocol/packs/delta.mjs +2 -2
  299. package/dist/protocol/packs/graph.mjs +55 -56
  300. package/dist/protocol/packs/idx.d.mts +4 -2
  301. package/dist/protocol/packs/idx.mjs +156 -63
  302. package/dist/protocol/packs/indexer.d.mts +22 -4
  303. package/dist/protocol/packs/indexer.mjs +14 -35
  304. package/dist/protocol/packs/parts.mjs +5 -5
  305. package/dist/protocol/packs/pos.mjs +12 -5
  306. package/dist/protocol/packs/reader.d.mts +19 -12
  307. package/dist/protocol/packs/reader.mjs +252 -25
  308. package/dist/protocol/packs/rev.d.mts +1 -1
  309. package/dist/protocol/packs/rev.mjs +42 -24
  310. package/dist/protocol/packs/types-file.mjs +85 -0
  311. package/dist/protocol/packs/write-error.d.mts +1 -1
  312. package/dist/protocol/packs/write-error.mjs +2 -2
  313. package/dist/protocol/packs/writer.d.mts +40 -15
  314. package/dist/protocol/packs/writer.mjs +142 -49
  315. package/dist/protocol/wire/advertisement.d.mts +39 -14
  316. package/dist/protocol/wire/advertisement.mjs +127 -31
  317. package/dist/protocol/wire/fetch.d.mts +57 -19
  318. package/dist/protocol/wire/fetch.mjs +57 -26
  319. package/dist/protocol/wire/json.mjs +25 -0
  320. package/dist/protocol/wire/lines.d.mts +10 -0
  321. package/dist/protocol/wire/lines.mjs +20 -6
  322. package/dist/protocol/wire/push-limits.d.mts +6 -0
  323. package/dist/protocol/wire/push-limits.mjs +88 -0
  324. package/dist/protocol/wire/push-uploads.mjs +3 -28
  325. package/dist/protocol/wire/receive-pack.d.mts +30 -14
  326. package/dist/protocol/wire/receive-pack.mjs +29 -2
  327. package/dist/protocol/wire/report-status.d.mts +30 -11
  328. package/dist/protocol/wire/report-status.mjs +21 -2
  329. package/dist/protocol/wire/v2.d.mts +56 -29
  330. package/dist/protocol/wire/v2.mjs +91 -16
  331. package/dist/protocol.d.mts +4 -3
  332. package/dist/protocol.mjs +7 -6
  333. package/dist/queue/advance.mjs +191 -121
  334. package/dist/queue/callers.mjs +12 -9
  335. package/dist/queue/calls.mjs +311 -155
  336. package/dist/queue/commit.mjs +70 -26
  337. package/dist/queue/host.d.mts +40 -13
  338. package/dist/queue/host.mjs +37 -39
  339. package/dist/queue/lanes.mjs +1 -1
  340. package/dist/queue/layer.d.mts +14 -0
  341. package/dist/queue/layer.mjs +55 -0
  342. package/dist/queue/limits.mjs +13 -2
  343. package/dist/queue/namespace.d.mts +2 -0
  344. package/dist/queue/pages.mjs +1 -1
  345. package/dist/queue/public.d.mts +6 -0
  346. package/dist/queue/public.mjs +21 -0
  347. package/dist/queue/push-option.mjs +49 -30
  348. package/dist/queue/rows.mjs +24 -16
  349. package/dist/queue/schedule.mjs +23 -23
  350. package/dist/queue/search.mjs +8 -7
  351. package/dist/queue/state.mjs +49 -13
  352. package/dist/queue/steps.mjs +6 -3
  353. package/dist/remote-helper.d.mts +5 -2
  354. package/dist/remote-helper.mjs +5 -2
  355. package/dist/rest/api.d.mts +1 -1
  356. package/dist/rest/blobs.d.mts +799 -32
  357. package/dist/rest/blobs.mjs +4 -4
  358. package/dist/rest/caller.d.mts +4163 -36
  359. package/dist/rest/caller.mjs +2 -2
  360. package/dist/rest/client.mjs +82 -72
  361. package/dist/rest/commits.d.mts +3253 -182
  362. package/dist/rest/commits.mjs +18 -64
  363. package/dist/rest/errors.d.mts +2082 -22
  364. package/dist/rest/errors.mjs +46 -89
  365. package/dist/rest/events.d.mts +394 -11
  366. package/dist/rest/events.mjs +13 -9
  367. package/dist/rest/files.d.mts +1239 -88
  368. package/dist/rest/files.mjs +11 -42
  369. package/dist/rest/forks.d.mts +2005 -62
  370. package/dist/rest/forks.mjs +10 -13
  371. package/dist/rest/handler.d.mts +4 -0
  372. package/dist/rest/handler.mjs +57 -26
  373. package/dist/rest/handlers.mjs +55 -62
  374. package/dist/rest/listen.d.mts +5 -8
  375. package/dist/rest/listen.mjs +23 -29
  376. package/dist/rest/me.d.mts +393 -10
  377. package/dist/rest/me.mjs +2 -2
  378. package/dist/rest/merges.d.mts +399 -16
  379. package/dist/rest/merges.mjs +3 -17
  380. package/dist/rest/paths.mjs +1 -0
  381. package/dist/rest/queue.d.mts +5615 -240
  382. package/dist/rest/queue.mjs +15 -130
  383. package/dist/rest/refs.d.mts +2859 -132
  384. package/dist/rest/refs.mjs +19 -39
  385. package/dist/rest/repos.d.mts +2392 -64
  386. package/dist/rest/repos.mjs +10 -33
  387. package/dist/rest/tags.d.mts +1211 -60
  388. package/dist/rest/tags.mjs +6 -34
  389. package/dist/rest/tokens.d.mts +2473 -170
  390. package/dist/rest/tokens.mjs +7 -4
  391. package/dist/rest/topics.d.mts +2060 -113
  392. package/dist/rest/topics.mjs +23 -71
  393. package/dist/rest/trees.d.mts +1610 -75
  394. package/dist/rest/trees.mjs +16 -57
  395. package/dist/rest/wire.d.mts +402 -0
  396. package/dist/rest/wire.mjs +32 -46
  397. package/dist/rest/work.d.mts +1179 -38
  398. package/dist/rest/work.mjs +7 -51
  399. package/dist/rest.d.mts +3 -3
  400. package/dist/server/extension.d.mts +11 -4
  401. package/dist/server/extension.mjs +85 -53
  402. package/dist/server/git-layer.d.mts +23 -0
  403. package/dist/server/git-layer.mjs +107 -0
  404. package/dist/server/git-namespace.d.mts +6 -0
  405. package/dist/server/git-namespace.mjs +15 -0
  406. package/dist/server/lifecycle.d.mts +2 -0
  407. package/dist/server/lifecycle.mjs +82 -0
  408. package/dist/server/namespaces.d.mts +2 -0
  409. package/dist/server/registry.d.mts +9 -0
  410. package/dist/server/registry.mjs +167 -0
  411. package/dist/server/route-match.mjs +88 -0
  412. package/dist/server/routes.d.mts +15 -8
  413. package/dist/server/routes.mjs +35 -33
  414. package/dist/server/server.d.mts +27 -2
  415. package/dist/server/server.mjs +493 -234
  416. package/dist/signin/codes.mjs +9 -6
  417. package/dist/signin/context.d.mts +2 -1
  418. package/dist/signin/context.mjs +4 -4
  419. package/dist/signin/device.mjs +8 -8
  420. package/dist/signin/forms.mjs +11 -29
  421. package/dist/signin/grants.d.mts +5 -3
  422. package/dist/signin/grants.mjs +20 -19
  423. package/dist/signin/route.mjs +2 -2
  424. package/dist/signin/web.mjs +7 -7
  425. package/dist/signin/wire.mjs +6 -6
  426. package/dist/storage/bits.mjs +41 -0
  427. package/dist/storage/budget.mjs +51 -18
  428. package/dist/storage/calls.d.mts +22 -4
  429. package/dist/storage/calls.mjs +347 -110
  430. package/dist/storage/clean-up.mjs +80 -35
  431. package/dist/storage/counted-bucket.mjs +115 -0
  432. package/dist/storage/fetch.d.mts +5 -1
  433. package/dist/storage/fetch.mjs +428 -79
  434. package/dist/storage/fsck.mjs +56 -7
  435. package/dist/storage/held-types.d.mts +7 -0
  436. package/dist/storage/held-types.mjs +263 -0
  437. package/dist/storage/host-bucket.mjs +28 -0
  438. package/dist/storage/id-mix.d.mts +1 -0
  439. package/dist/storage/id-mix.mjs +55 -0
  440. package/dist/storage/index-bitmaps.d.mts +2 -1
  441. package/dist/storage/index-bitmaps.mjs +233 -101
  442. package/dist/storage/index-build.d.mts +7 -3
  443. package/dist/storage/index-build.mjs +674 -174
  444. package/dist/storage/index-fetch.d.mts +4 -1
  445. package/dist/storage/index-fetch.mjs +365 -342
  446. package/dist/storage/index-files.mjs +25 -27
  447. package/dist/storage/index-graph.d.mts +2 -1
  448. package/dist/storage/index-graph.mjs +127 -91
  449. package/dist/storage/index-layers.d.mts +11 -0
  450. package/dist/storage/index-layers.mjs +258 -78
  451. package/dist/storage/index-reach.mjs +181 -75
  452. package/dist/storage/index-remap.mjs +74 -32
  453. package/dist/storage/index-shallow.mjs +311 -0
  454. package/dist/storage/index-visible.mjs +168 -0
  455. package/dist/storage/layout.d.mts +1 -0
  456. package/dist/storage/layout.mjs +39 -8
  457. package/dist/storage/lfs-pointers.d.mts +3 -1
  458. package/dist/storage/lfs-pointers.mjs +25 -9
  459. package/dist/storage/link-join.d.mts +4 -0
  460. package/dist/storage/link-join.mjs +50 -12
  461. package/dist/storage/links.mjs +89 -4
  462. package/dist/storage/listed-ids.mjs +10 -0
  463. package/dist/storage/loose.d.mts +11 -4
  464. package/dist/storage/loose.mjs +103 -69
  465. package/dist/storage/memory-budget.d.mts +5 -0
  466. package/dist/storage/memory-budget.mjs +530 -102
  467. package/dist/storage/merge-choose.mjs +258 -0
  468. package/dist/storage/merge-cut.mjs +47 -0
  469. package/dist/storage/merge-fence.mjs +89 -0
  470. package/dist/storage/merge-index.mjs +347 -0
  471. package/dist/storage/merge-most.mjs +202 -0
  472. package/dist/storage/merge-plan.mjs +171 -0
  473. package/dist/storage/merge-row.mjs +258 -0
  474. package/dist/storage/merge-stream.mjs +497 -0
  475. package/dist/storage/merge-walk.mjs +199 -0
  476. package/dist/storage/merge-write.mjs +129 -0
  477. package/dist/storage/merge.d.mts +10 -0
  478. package/dist/storage/merge.mjs +82 -306
  479. package/dist/storage/object-rows.d.mts +4 -2
  480. package/dist/storage/object-rows.mjs +101 -17
  481. package/dist/storage/pack-order.d.mts +1 -1
  482. package/dist/storage/pack-order.mjs +71 -54
  483. package/dist/storage/pack-ranges.d.mts +1 -1
  484. package/dist/storage/pack-ranges.mjs +396 -60
  485. package/dist/storage/pack-reads.d.mts +6 -2
  486. package/dist/storage/pack-reads.mjs +613 -124
  487. package/dist/storage/pack-receive.d.mts +7 -2
  488. package/dist/storage/pack-receive.mjs +820 -237
  489. package/dist/storage/packs-memory.d.mts +25 -0
  490. package/dist/storage/packs-memory.mjs +49 -0
  491. package/dist/storage/packs.d.mts +9 -7
  492. package/dist/storage/packs.mjs +562 -218
  493. package/dist/storage/placed-reads.mjs +205 -0
  494. package/dist/storage/promise-calls.mjs +29 -0
  495. package/dist/storage/prune-keep.mjs +164 -0
  496. package/dist/storage/prune-walk.mjs +578 -0
  497. package/dist/storage/prune.mjs +739 -332
  498. package/dist/storage/push-allotment.mjs +3 -3
  499. package/dist/storage/push-uploads.mjs +24 -14
  500. package/dist/storage/pushed-commits.mjs +8 -9
  501. package/dist/storage/quarantine.d.mts +10 -0
  502. package/dist/storage/quarantine.mjs +28 -25
  503. package/dist/storage/range-cache.mjs +71 -0
  504. package/dist/storage/raw-ids.mjs +20 -1
  505. package/dist/storage/ready.d.mts +6 -4
  506. package/dist/storage/ready.mjs +109 -48
  507. package/dist/storage/receive-admission.mjs +67 -0
  508. package/dist/storage/receive-bounds.d.mts +1 -0
  509. package/dist/storage/receive-bounds.mjs +202 -0
  510. package/dist/storage/receive-files.mjs +248 -0
  511. package/dist/storage/receive-links.mjs +281 -244
  512. package/dist/storage/receive-state.d.mts +9 -0
  513. package/dist/storage/receive-state.mjs +150 -0
  514. package/dist/storage/receive-steps.mjs +344 -0
  515. package/dist/storage/receive-sweep.mjs +160 -0
  516. package/dist/storage/receive-table.d.mts +3 -0
  517. package/dist/storage/receive-table.mjs +197 -0
  518. package/dist/storage/repack-backlog.mjs +70 -0
  519. package/dist/storage/repack-contained.mjs +269 -0
  520. package/dist/storage/repack-job.d.mts +3 -0
  521. package/dist/storage/repack-job.mjs +24 -7
  522. package/dist/storage/repack.d.mts +6 -6
  523. package/dist/storage/repack.mjs +156 -77
  524. package/dist/storage/roots.mjs +23 -7
  525. package/dist/storage/rows.d.mts +6 -3
  526. package/dist/storage/rows.mjs +41 -8
  527. package/dist/storage/runs.d.mts +8 -0
  528. package/dist/storage/runs.mjs +731 -0
  529. package/dist/storage/send-list.d.mts +9 -0
  530. package/dist/storage/send-list.mjs +504 -0
  531. package/dist/storage/shallow.d.mts +3 -3
  532. package/dist/storage/shallow.mjs +7 -7
  533. package/dist/storage/single-flight.mjs +47 -0
  534. package/dist/storage/stream-whole.mjs +121 -54
  535. package/dist/storage/swap-walk.mjs +188 -0
  536. package/dist/storage/unpack.mjs +54 -23
  537. package/dist/storage/visible.mjs +58 -39
  538. package/dist/storage/walk.d.mts +4 -1
  539. package/dist/storage/walk.mjs +33 -14
  540. package/dist/storage/wants.mjs +185 -33
  541. package/dist/storage/written-bases.mjs +172 -0
  542. package/dist/store/call-count.d.mts +69 -4
  543. package/dist/store/call-count.mjs +193 -51
  544. package/dist/store/catalogue.d.mts +18 -4
  545. package/dist/store/catalogue.mjs +135 -48
  546. package/dist/store/closed.d.mts +21 -0
  547. package/dist/store/closed.mjs +34 -0
  548. package/dist/store/crossing.mjs +10 -9
  549. package/dist/store/cursor-seal.d.mts +12 -1
  550. package/dist/store/cursor-seal.mjs +11 -7
  551. package/dist/store/errors.d.mts +2 -2
  552. package/dist/store/errors.mjs +120 -26
  553. package/dist/store/git-store.mjs +21 -2
  554. package/dist/store/list-job.mjs +5 -5
  555. package/dist/store/outbox.d.mts +15 -5
  556. package/dist/store/outbox.mjs +110 -30
  557. package/dist/store/promises.d.mts +6 -0
  558. package/dist/store/promises.mjs +317 -0
  559. package/dist/store/queue-jobs.mjs +12 -12
  560. package/dist/store/records.d.mts +64 -1
  561. package/dist/store/records.mjs +101 -32
  562. package/dist/store/ref-rows.d.mts +18 -2
  563. package/dist/store/ref-rows.mjs +62 -5
  564. package/dist/store/repo-record.mjs +11 -9
  565. package/dist/store/reservations.mjs +9 -8
  566. package/dist/store/scopes.mjs +13 -1
  567. package/dist/store/settle.mjs +1 -1
  568. package/dist/store/topic-jobs.mjs +4 -4
  569. package/dist/sync/bound.d.mts +5 -3
  570. package/dist/sync/bound.mjs +41 -7
  571. package/dist/sync/github.mjs +7 -7
  572. package/dist/sync/import.d.mts +2 -0
  573. package/dist/sync/import.mjs +46 -50
  574. package/dist/sync/jobs.d.mts +3 -3
  575. package/dist/sync/jobs.mjs +36 -41
  576. package/dist/sync/mirror.d.mts +5 -1
  577. package/dist/sync/mirror.mjs +121 -44
  578. package/dist/sync/publish.d.mts +1 -0
  579. package/dist/sync/publish.mjs +10 -12
  580. package/dist/sync/step.mjs +439 -71
  581. package/dist/sync/tries.mjs +52 -34
  582. package/dist/sync.d.mts +3 -3
  583. package/dist/sync.mjs +2 -2
  584. package/dist/topics/advance.mjs +105 -87
  585. package/dist/topics/calls.mjs +99 -69
  586. package/dist/topics/directory.mjs +31 -11
  587. package/dist/topics/host.d.mts +1 -2
  588. package/dist/topics/host.mjs +3 -13
  589. package/dist/topics/members.mjs +30 -24
  590. package/dist/topics/rows.mjs +10 -9
  591. package/dist/topics/topic.mjs +42 -16
  592. package/package.json +8 -15
  593. package/dist/auth/authorize.d.mts +0 -5
  594. package/dist/contracts/objects.mjs +0 -54
  595. package/dist/core/events/stream.d.mts +0 -19
  596. package/dist/core/rules/define.d.mts +0 -5
  597. package/dist/core/rules/define.mjs +0 -13
  598. package/dist/core/rules/fetch.d.mts +0 -5
  599. package/dist/core/sight.mjs +0 -99
  600. package/dist/engine/engine.d.mts +0 -25
  601. package/dist/engine/engine.mjs +0 -49
  602. package/dist/engine/xdiff/NOTICE.md +0 -63
  603. package/dist/engine/xdiff/compiled.d.mts +0 -7
  604. package/dist/engine/xdiff/compiled.mjs +0 -9
  605. package/dist/engine/xdiff/embedded.mjs +0 -4
  606. package/dist/engine/xdiff/node.d.mts +0 -7
  607. package/dist/engine/xdiff/node.mjs +0 -10
  608. package/dist/engine/xdiff/upstream/LGPL-2.1 +0 -511
  609. package/dist/engine/xdiff/xdiff.wasm +0 -0
  610. package/dist/engine.d.mts +0 -3
  611. package/dist/engine.mjs +0 -3
  612. package/dist/storage/distinct-ids.mjs +0 -39
  613. package/dist/storage/held-memo.mjs +0 -188
  614. package/dist/storage/index-remap.d.mts +0 -8
  615. 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,
@@ -635,7 +718,8 @@ const commitTooLarge = (received, body) => (error) => {
635
718
  })) return error;
636
719
  return gitError("RESOURCE_EXHAUSTED", `push's objects don't fit one commit: ${error.message}`, {
637
720
  cause: error,
638
- hint: "Use packs() storage, or push fewer objects at a time",
721
+ hint: "Push fewer objects at a time",
722
+ hostHint: "Use Objects.layer() storage, which keeps a push's objects in the bucket",
639
723
  context: { reason: "too-large" }
640
724
  });
641
725
  };
@@ -648,6 +732,13 @@ const fits = (change) => {
648
732
  return false;
649
733
  }
650
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;
651
742
  /** The request's pack into its quarantine, or `undefined` for a push with none. */
652
743
  const receive = (objects, listed, request) => {
653
744
  const { pack, shallow, signal } = request;
@@ -655,6 +746,10 @@ const receive = (objects, listed, request) => {
655
746
  received: void 0,
656
747
  rooted: void 0
657
748
  });
749
+ if ("received" in pack) return Effect.succeed({
750
+ received: pack.received,
751
+ rooted: void 0
752
+ });
658
753
  const input = {
659
754
  pack: pack.bytes,
660
755
  objects: pack.objects
@@ -664,6 +759,9 @@ const receive = (objects, listed, request) => {
664
759
  if (shallow !== void 0 && shallow.length > 0) input.shallow = shallow;
665
760
  if (signal !== void 0) input.signal = signal;
666
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;
667
765
  return scopedReceive(objects, listed, input).pipe(Effect.map((received) => ({
668
766
  received,
669
767
  rooted: void 0
@@ -672,15 +770,20 @@ const receive = (objects, listed, request) => {
672
770
  rooted
673
771
  })));
674
772
  };
675
- /** `ref.updated`'s `push`: the write, how many branches and tags it moved (Q222), and its source. */
676
- const pushOf = (id, moved, source) => {
677
- const under = (prefix) => moved.filter((move) => move.ref.startsWith(prefix)).length;
678
- 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 = {
679
780
  id,
680
- branches: under("refs/heads/"),
681
- tags: under("refs/tags/"),
682
- source
781
+ ...pushCounts(access, moved),
782
+ source: request.source
683
783
  };
784
+ const slice = sliceOf(request.pushOptions ?? []);
785
+ if (slice !== void 0) push.slice = slice;
786
+ return push;
684
787
  };
685
788
  /**
686
789
  * What a push's commit saves for `hooks.postReceive`, when the host passed one: the push, with
@@ -720,17 +823,26 @@ const savedPush = (checks, push) => {
720
823
  * version, with the ref moves, the receipt, the events and the push `hooks.postReceive` owes.
721
824
  * `answers` says what the call answers and keeps.
722
825
  */
723
- 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;
724
830
  const { store } = core;
725
831
  const { caller, repo, signal } = request;
726
832
  const call = signal === void 0 ? {} : { signal };
727
- const seen = yield* seenRefsOf(core, view, listed);
728
- 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));
729
838
  const viewed = received === void 0 ? seen : {
730
839
  ...seen,
731
840
  pushed: received
732
841
  };
733
- 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);
734
846
  const pushedObjects = withReceivedRows(objects, received);
735
847
  const pushedListed = withReceived(listed, received);
736
848
  const pushed = pushedOf(objects, listed, received);
@@ -742,7 +854,7 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
742
854
  ...call
743
855
  };
744
856
  if (rooted !== void 0) kindsInput.missing = rooted;
745
- const kinds = yield* kindsOf(kindsInput);
857
+ const kinds = yield* kindsOf(kindsInput).pipe(Effect.mapError(asPushCheck));
746
858
  const fetchedOff = yield* fetchedRefused(kinds, request);
747
859
  const { forced } = fetchedOff;
748
860
  const refused = new Map(fetchedOff.refused);
@@ -750,17 +862,17 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
750
862
  const own = gitsOwnRef(update.ref, request.source);
751
863
  if (own !== void 0 && !refused.has(update.ref)) refused.set(update.ref, own);
752
864
  }
753
- const sights = yield* Effect.forEach(views, (one) => one.sight);
754
- 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));
755
867
  yield* refuseQueued(request, unseens.map((one) => one.values().next().value), "access");
756
868
  const unseen = unseens[0] ?? /* @__PURE__ */ new Map();
757
869
  const { updates } = kinds;
758
870
  for (const [ref, error] of unseen) refused.set(ref, error);
759
871
  const { access } = core;
760
- const barred = access?.patterns.some((pattern) => sights.some((sight) => !publishable(sight, pattern))) === true;
761
- 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));
762
874
  const wholePushed = access === void 0 || !barred && request.publishes === void 0 ? void 0 : withReceivedRows(yield* walkObjects(whole, received?.allotment), received);
763
- const sight = sights[0] ?? (yield* view.sight);
875
+ const refView = refViews[0] ?? (yield* view.refView);
764
876
  const publishedRefs = (refs) => new Map([...refs].filter(([ref]) => hiddenUnder(ref) === void 0));
765
877
  const writer = access === void 0 ? void 0 : yield* ownWriter(caller);
766
878
  const made = new Set(request.own);
@@ -768,14 +880,18 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
768
880
  const here = oids.filter((oid) => made.has(oid));
769
881
  const stored = oids.filter((oid) => !made.has(oid));
770
882
  if (stored.length === 0) return Effect.succeed(new Set(here));
771
- 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]));
772
884
  };
773
- 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({
774
886
  access,
775
- sight: judging,
887
+ refView: judging,
776
888
  refs: publishedRefs(refs),
777
889
  objects: whole,
778
890
  listed: at,
891
+ visible: (tips, fallback) => SealedObjects.visibleWhole(sealed, pushWhole, at, {
892
+ tips,
893
+ row: index?.value
894
+ }, fallback),
779
895
  pushed: wholePushed,
780
896
  pushedListed: withReceived(at, received),
781
897
  edits,
@@ -783,9 +899,9 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
783
899
  ...call
784
900
  });
785
901
  const headsOf = (edit) => edit.to === null ? void 0 : request.publishes?.get(edit.ref);
786
- const publishedAt = (refs, at) => Effect.gen(function* () {
902
+ const publishedAt = Effect.fnUntraced(function* (refs, at, index) {
787
903
  const plain = request.edits.filter((edit) => headsOf(edit) === void 0);
788
- const refused = new Map(yield* unpublishedAt(refs, at, sight, plain, ownOf));
904
+ const refused = new Map(yield* unpublishedAt(refs, at, index, refView, plain, ownOf));
789
905
  for (const edit of request.edits) {
790
906
  const heads = headsOf(edit);
791
907
  if (heads === void 0) continue;
@@ -795,8 +911,8 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
795
911
  }
796
912
  const failed = [];
797
913
  for (const { entry, head, caller: its } of heads) {
798
- const judging = yield* sightIn(core, its, checkedRepo);
799
- if ((yield* unpublishedAt(refs, at, judging, [{
914
+ const judging = yield* refViewIn(its, checkedRepo);
915
+ if ((yield* unpublishedAt(refs, at, index, judging, [{
800
916
  ...edit,
801
917
  to: head
802
918
  }])).has(edit.ref)) failed.push(entry);
@@ -805,11 +921,19 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
805
921
  }
806
922
  return refused;
807
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
+ }
808
931
  const command = {
809
932
  source: request.source,
810
933
  updates,
811
934
  atomic: request.atomic,
812
- refused
935
+ refused,
936
+ peels
813
937
  };
814
938
  if (received !== void 0) command.received = received;
815
939
  const target = {
@@ -821,11 +945,12 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
821
945
  const jobs = (received?.change.add?.length ?? 0) > 0 || ready ? [core.repackJobRow()] : [];
822
946
  const own = updates.filter((update) => gitsOwnMove(request.source, update.ref));
823
947
  const outside = updates.filter((update) => !gitsOwnMove(request.source, update.ref));
824
- const checks = outside.length === 0 ? void 0 : checksOf(core);
948
+ const checks = outside.length === 0 ? void 0 : yield* checksOf(core);
825
949
  const branches = request.source === "queue" ? [] : outside.map((update) => update.ref).filter((ref) => ref.startsWith("refs/heads/"));
826
950
  const scope = yield* callScope;
827
951
  const reader = readerOf(pushedObjects, pushedListed, scope);
828
952
  const batch = batchOf(pushedObjects, pushedListed, scope);
953
+ const { between } = yield* Changes;
829
954
  const unaborted = signal ?? new AbortController().signal;
830
955
  const base = {
831
956
  caller,
@@ -839,9 +964,14 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
839
964
  },
840
965
  exact: kinds.exact,
841
966
  scope,
842
- 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()),
843
973
  objects: pushedObjectsOf(pushedObjects, pushedListed, received, pushed),
844
- authorize: (operation) => core.authorize({
974
+ authorize: (operation) => authorize.check({
845
975
  caller,
846
976
  operation,
847
977
  repo: checkedRepo
@@ -856,21 +986,20 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
856
986
  source: request.source,
857
987
  allotment: received?.allotment,
858
988
  readerAllotment: pushedObjects.allotment(pushedListed, openTreeBytes, openTreesRefusal),
859
- brought: broughtCommit(pushed, scope),
860
- scope
989
+ brought: broughtCommit(pushed)
861
990
  };
862
991
  if (request.pushOptions !== void 0) base.pushOptions = request.pushOptions;
863
992
  if (request.request !== void 0) base.request = request.request;
864
993
  let checked;
865
994
  for (let tries = 0; tries < 10; tries += 1) {
866
- const at = yield* core.now;
867
- 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);
868
997
  const { read, receipt, outbox, record, mirrored, facts, stats, times, queued, reserved, indexRow } = decide;
869
- 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));
870
999
  if (receipt !== void 0) return yield* answers.held(receipt);
871
- const published = yield* publishedAt(read.refs, decide.at);
1000
+ const published = yield* publishedAt(read.refs, decide.at, indexRow);
872
1001
  const { writes } = request;
873
- 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));
874
1003
  const seen = {
875
1004
  ...facts,
876
1005
  tips: tipsOf(read.refs, outside)
@@ -897,7 +1026,7 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
897
1026
  return commitChangesOf(judging, updates);
898
1027
  }
899
1028
  };
900
- checked = yield* checkAll(checks, request, input, seen, (one) => (operation) => core.authorize({
1029
+ checked = yield* checkAll(checks, request, input, seen, (one) => (operation) => authorize.check({
901
1030
  caller: one,
902
1031
  operation,
903
1032
  repo: checkedRepo
@@ -922,18 +1051,24 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
922
1051
  ...unseen
923
1052
  ])
924
1053
  };
925
- const planned = yield* planOf(decidePush({
1054
+ const chosen = decidePush({
926
1055
  read,
927
- command: decided
928
- }), 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);
929
1063
  const { change } = planned;
930
1064
  const refusal = writes === void 0 ? void 0 : refusalOf(planned.answer);
931
1065
  if (refusal !== void 0) return yield* Effect.fail(refusal);
932
1066
  const movedRefs = new Set(planned.moved.map((move) => move.ref));
933
1067
  const liftedOnMoves = [...checked?.bypassed ?? none].filter(([ref]) => movedRefs.has(ref));
934
1068
  const answer = yield* answers.answer(planned.answer, forced, new Map(liftedOnMoves));
935
- const also = planned.answer.updates.some((update) => update.kind === "rejected") || request.also === void 0 ? void 0 : request.also(yield* core.now);
936
- 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;
937
1072
  if (!planned.moves && quiet) return answer;
938
1073
  const scope = repoScope(listed.repo);
939
1074
  const { name } = record;
@@ -946,7 +1081,7 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
946
1081
  const envelope = repoEnvelope(caller, name);
947
1082
  const id = newChangeId();
948
1083
  const shown = planned.moved.filter((move) => !gitsOwnMove(request.source, move.ref));
949
- const push = pushOf(id, shown, request.source);
1084
+ const push = pushOf(core.access, id, shown, request);
950
1085
  const events = shown.map((move) => {
951
1086
  const updated = {
952
1087
  type: "ref.updated",
@@ -994,6 +1129,7 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
994
1129
  delete: [
995
1130
  ...change.delete,
996
1131
  ...appended.delete,
1132
+ ...also?.delete ?? [],
997
1133
  ...writes?.delete ?? []
998
1134
  ],
999
1135
  jobs: withJobs([
@@ -1003,9 +1139,18 @@ const pushOnto = (core, request, { listed, defaultBranch, mark, repo: checkedRep
1003
1139
  ...mirrorJobs(core, planned.moved, mirrored),
1004
1140
  ...writes?.jobs ?? [],
1005
1141
  ...woken,
1006
- ...shown.length > 0 ? indexJobs(core, indexed) : []
1142
+ ...shown.length > 0 ? indexJobs(core, indexed) : [],
1143
+ ...planned.moves ? refIndexJobs(core, record) : []
1007
1144
  ], [...kept.jobs, ...also?.jobs ?? []])
1008
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);
1009
1154
  if ((yield* storeCall(() => store.commit(scope, body)).pipe(Effect.mapError(commitTooLarge(received, body)))).ok) return final;
1010
1155
  }
1011
1156
  return yield* fail("UNAVAILABLE", `Other writes kept moving '${repo}' through 10 tries`, { hint: "Push again" });
@@ -1024,16 +1169,16 @@ const operationOf = ({ repo, edits }) => edits.length === 0 ? {
1024
1169
  * reads and decides again. A push cut before its commit leaves an unlisted pack for clean-up, and
1025
1170
  * no ref moved.
1026
1171
  */
1027
- const pushWith = (core, request, answers, key) => Effect.gen(function* () {
1172
+ const pushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, key) {
1028
1173
  const operation = operationOf(request);
1029
- const resolved = yield* firstRead(core, request.caller, operation, request.internalId).pipe(Effect.tapError((error) => retriedCodes.has(error.code) ? Effect.void : refuseQueued(request, [error], "access")));
1030
- const opened = yield* listedFor(core, request, operation, resolved);
1031
- 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);
1032
1177
  });
1033
1178
  /** A push or an unkeyed `refs.update`, answering the decide's ref answer. */
1034
- const push = (core, request) => pushWith(core, request, refsAnswers);
1179
+ const push = (request) => pushWith(request, refsAnswers);
1035
1180
  /** A `git push`, as `push`, with the lines Git prints for the rules `authorize` lifted. */
1036
- const gitPush = (core, request) => pushWith(core, request, gitAnswers);
1181
+ const gitPush = (request) => pushWith(request, gitAnswers);
1037
1182
  /** A ref a forced fetch moved past its diverged tip, answered `force`; the rest as they are. */
1038
1183
  const forcedOf = (forced) => (update) => update.kind === "applied" && forced.has(update.ref) ? {
1039
1184
  kind: "force",
@@ -1048,7 +1193,7 @@ const appliedOf = (update) => update.kind === "force" ? {
1048
1193
  * A client's fetch into its own refs, as `push`, each diverged ref a forced fetch moved answered
1049
1194
  * `force`. Its refs move in one commit, so a fetch stopped before it moves none.
1050
1195
  */
1051
- const pushFetched = (core, request) => pushWith(core, request, {
1196
+ const pushFetched = (request) => pushWith(request, {
1052
1197
  answer: (updated, forced) => Effect.succeed(updated.updates.map(forcedOf(forced))),
1053
1198
  kept: (updates) => refsKept({ updates: updates.map(appliedOf) }),
1054
1199
  held: (receipt) => Effect.map(refsAnswer(receipt), (held) => held.updates)
@@ -1057,13 +1202,13 @@ const pushFetched = (core, request) => pushWith(core, request, {
1057
1202
  * `pushWith` for a write's key, which keeps its answer. `undefined`, with nothing written or
1058
1203
  * asked of `authorize`, when the name holds a repo other than the one its key's lookup saw.
1059
1204
  */
1060
- const keyedPushWith = (core, request, answers, keyed) => Effect.gen(function* () {
1205
+ const keyedPushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, keyed) {
1061
1206
  const operation = operationOf(request);
1062
- const resolved = yield* keyedRead(core, request.caller, operation, keyed.missed, request.internalId);
1207
+ const resolved = yield* keyedRead(request.caller, operation, keyed.missed, request.internalId);
1063
1208
  if (resolved === void 0) return void 0;
1064
- const opened = yield* listedFor(core, request, operation, resolved);
1065
- 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);
1066
1211
  });
1067
1212
  /** `keyedPushWith` for `refs.update`, answering the decide's ref answer. */
1068
- const keyedPush = (core, request, keyed) => keyedPushWith(core, request, refsAnswers, keyed);
1069
- 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 };