@ref0/git 0.20.0 → 0.26.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 (379) hide show
  1. package/dist/access/private-refs.mjs +1 -1
  2. package/dist/auth/access-jwt.mjs +3 -3
  3. package/dist/auth/auth-namespace.d.mts +3 -3
  4. package/dist/auth/auth-namespace.mjs +3 -2
  5. package/dist/auth/auth.d.mts +3 -3
  6. package/dist/auth/auth.mjs +9 -8
  7. package/dist/auth/authorize.mjs +1 -1
  8. package/dist/auth/fences.d.mts +1 -1
  9. package/dist/auth/host-function.mjs +1 -1
  10. package/dist/auth/host-services.mjs +4 -6
  11. package/dist/auth/identify.d.mts +1 -1
  12. package/dist/auth/identify.mjs +6 -0
  13. package/dist/auth/token-cleanup.mjs +2 -2
  14. package/dist/auth/token-rows.mjs +6 -1
  15. package/dist/auth/token-text.mjs +1 -1
  16. package/dist/auth/tokens-base.d.mts +1 -1
  17. package/dist/auth/tokens.d.mts +1 -1
  18. package/dist/auth/tokens.mjs +1 -1
  19. package/dist/client/client.d.mts +15 -7
  20. package/dist/client/client.mjs +21 -12
  21. package/dist/client/git-http.mjs +1 -1
  22. package/dist/client/local.mjs +60 -24
  23. package/dist/client/negotiate.mjs +3 -3
  24. package/dist/client/push-upload.mjs +26 -10
  25. package/dist/client/remote.mjs +4 -3
  26. package/dist/client/run-remote-helper.d.mts +2 -2
  27. package/dist/client/run-remote-helper.mjs +6 -6
  28. package/dist/client/slice-push.d.mts +1 -1
  29. package/dist/client/transport.mjs +3 -3
  30. package/dist/contracts/blobs.d.mts +3 -3
  31. package/dist/contracts/blobs.mjs +1 -1
  32. package/dist/contracts/calls-spent.mjs +5 -33
  33. package/dist/contracts/client.d.mts +15 -14
  34. package/dist/contracts/commits.d.mts +4 -4
  35. package/dist/contracts/commits.mjs +1 -1
  36. package/dist/contracts/engine.d.mts +2 -2
  37. package/dist/contracts/events.d.mts +1 -1
  38. package/dist/contracts/events.mjs +1 -1
  39. package/dist/contracts/files.d.mts +4 -4
  40. package/dist/contracts/files.mjs +1 -1
  41. package/dist/contracts/forks.d.mts +4 -4
  42. package/dist/contracts/forks.mjs +1 -1
  43. package/dist/contracts/git-hooks.d.mts +1 -1
  44. package/dist/contracts/git.d.mts +9 -5
  45. package/dist/contracts/grants.d.mts +1 -1
  46. package/dist/contracts/merges.d.mts +1 -1
  47. package/dist/contracts/object-values.d.mts +1 -0
  48. package/dist/contracts/object-values.mjs +16 -1
  49. package/dist/contracts/objects.d.mts +30 -18
  50. package/dist/contracts/opaque.mjs +1 -1
  51. package/dist/contracts/operations.mjs +1 -1
  52. package/dist/contracts/queue.d.mts +208 -44
  53. package/dist/contracts/queue.mjs +5 -5
  54. package/dist/contracts/refs.d.mts +5 -5
  55. package/dist/contracts/refs.mjs +1 -1
  56. package/dist/contracts/remote.d.mts +3 -6
  57. package/dist/contracts/repos.d.mts +3 -3
  58. package/dist/contracts/repos.mjs +1 -1
  59. package/dist/contracts/result.d.mts +10 -7
  60. package/dist/contracts/result.mjs +8 -3
  61. package/dist/contracts/rules.d.mts +13 -12
  62. package/dist/contracts/server.d.mts +8 -10
  63. package/dist/contracts/services.d.mts +6 -9
  64. package/dist/contracts/services.mjs +1 -2
  65. package/dist/contracts/signin.d.mts +1 -1
  66. package/dist/contracts/store.d.mts +2 -2
  67. package/dist/contracts/sync.d.mts +63 -6
  68. package/dist/contracts/sync.mjs +3 -2
  69. package/dist/contracts/tags.d.mts +3 -3
  70. package/dist/contracts/tags.mjs +1 -1
  71. package/dist/contracts/tokens.d.mts +2 -2
  72. package/dist/contracts/tokens.mjs +1 -1
  73. package/dist/contracts/topics.d.mts +9 -9
  74. package/dist/contracts/trees.d.mts +4 -4
  75. package/dist/contracts/trees.mjs +1 -1
  76. package/dist/contracts/work.d.mts +4 -4
  77. package/dist/contracts/work.mjs +2 -2
  78. package/dist/core/access.d.mts +1 -1
  79. package/dist/core/ancestry.mjs +30 -34
  80. package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
  81. package/dist/core/call-services.mjs +1 -1
  82. package/dist/core/events/deliver.d.mts +2 -2
  83. package/dist/core/events/deliver.mjs +3 -3
  84. package/dist/core/events/retired.mjs +1 -1
  85. package/dist/core/forks.mjs +5 -5
  86. package/dist/core/hooks/groups.mjs +2 -2
  87. package/dist/core/imports.mjs +101 -21
  88. package/dist/core/index-job.mjs +14 -9
  89. package/dist/core/index-lost.d.mts +1 -1
  90. package/dist/core/loose-tally.mjs +38 -15
  91. package/dist/core/merge-parts.d.mts +17 -4
  92. package/dist/core/merge-parts.mjs +7 -2
  93. package/dist/core/mirror-rows.mjs +31 -1
  94. package/dist/core/objects/blobs.mjs +8 -10
  95. package/dist/core/objects/files.mjs +20 -17
  96. package/dist/core/objects/objects-layer.mjs +1 -1
  97. package/dist/core/objects/peel.mjs +1 -7
  98. package/dist/core/objects/reading.mjs +19 -18
  99. package/dist/core/objects/tree-edits.mjs +1 -1
  100. package/dist/core/objects/trees.mjs +257 -58
  101. package/dist/core/objects/writing.mjs +3 -9
  102. package/dist/core/own-writes.mjs +1 -1
  103. package/dist/core/parts.d.mts +8 -1
  104. package/dist/core/parts.mjs +8 -4
  105. package/dist/core/purge.mjs +31 -18
  106. package/dist/core/push.d.mts +2 -2
  107. package/dist/core/push.mjs +145 -98
  108. package/dist/core/receipts.d.mts +2 -2
  109. package/dist/core/receipts.mjs +9 -2
  110. package/dist/core/ref-index-job.mjs +4 -4
  111. package/dist/core/ref-view.mjs +74 -31
  112. package/dist/core/refs.mjs +3 -3
  113. package/dist/core/repack.mjs +25 -30
  114. package/dist/core/repo-info.mjs +1 -1
  115. package/dist/core/repos.mjs +1 -1
  116. package/dist/core/rules/changes.mjs +18 -40
  117. package/dist/core/rules/check.mjs +6 -5
  118. package/dist/core/rules/commit-changes.mjs +114 -58
  119. package/dist/core/rules/context.d.mts +3 -3
  120. package/dist/core/rules/context.mjs +18 -14
  121. package/dist/core/rules/fetch.mjs +1 -1
  122. package/dist/core/rules/protect.mjs +30 -17
  123. package/dist/core/saved-caller-views.d.mts +1 -1
  124. package/dist/core/saved-caller-views.mjs +3 -3
  125. package/dist/core/saved-callers.d.mts +1 -1
  126. package/dist/core/saved-callers.mjs +1 -1
  127. package/dist/core/seam.d.mts +1 -2
  128. package/dist/core/view.d.mts +6 -3
  129. package/dist/core/view.mjs +11 -10
  130. package/dist/core/work.mjs +2 -2
  131. package/dist/engine/allotted-xdiff.mjs +3 -16
  132. package/dist/engine/combined.d.mts +3 -0
  133. package/dist/engine/combined.mjs +200 -185
  134. package/dist/engine/content.d.mts +2 -2
  135. package/dist/engine/content.mjs +1 -1
  136. package/dist/engine/merge.mjs +7 -9
  137. package/dist/engine/reads.d.mts +2 -2
  138. package/dist/engine/reads.mjs +22 -14
  139. package/dist/engine/xdiff.d.mts +1 -1
  140. package/dist/engine/xdiff.mjs +1 -1
  141. package/dist/event-streams/event-streams.d.mts +1 -1
  142. package/dist/event-streams/event-streams.mjs +1 -1
  143. package/dist/event-streams/stream.d.mts +2 -2
  144. package/dist/event-streams/stream.mjs +3 -3
  145. package/dist/extend.d.mts +2 -6
  146. package/dist/extend.mjs +1 -5
  147. package/dist/http/core-parts.mjs +83 -26
  148. package/dist/http/handler.mjs +54 -9
  149. package/dist/http/parts.d.mts +1 -0
  150. package/dist/http/push-upload-job.mjs +138 -24
  151. package/dist/http/push-uploads.mjs +2 -2
  152. package/dist/http/receive-pack.mjs +14 -53
  153. package/dist/http/request-snapshot.mjs +258 -0
  154. package/dist/http/upload-pack.mjs +23 -18
  155. package/dist/index.d.mts +29 -21
  156. package/dist/index.mjs +11 -2
  157. package/dist/lfs/base.d.mts +1 -1
  158. package/dist/lfs/copy.d.mts +49 -1
  159. package/dist/lfs/copy.mjs +135 -22
  160. package/dist/lfs/layer.d.mts +4 -3
  161. package/dist/lfs/layer.mjs +4 -5
  162. package/dist/lfs/locks.mjs +2 -2
  163. package/dist/lfs/objects.d.mts +1 -1
  164. package/dist/lfs/objects.mjs +3 -3
  165. package/dist/lfs/pointers.mjs +1 -1
  166. package/dist/lfs/rows.d.mts +1 -1
  167. package/dist/lfs/rows.mjs +11 -4
  168. package/dist/lfs/upkeep.mjs +40 -9
  169. package/dist/lfs/uploaded.mjs +1 -1
  170. package/dist/lfs/wire.mjs +1 -1
  171. package/dist/merges/merges.mjs +17 -2
  172. package/dist/protocol/bytes/buffers.d.mts +1 -1
  173. package/dist/protocol/bytes/buffers.mjs +1 -1
  174. package/dist/protocol/bytes/deflate.d.mts +1 -1
  175. package/dist/protocol/bytes/deflate.mjs +1 -1
  176. package/dist/protocol/bytes/inflate.d.mts +1 -1
  177. package/dist/protocol/bytes/inflate.mjs +1 -1
  178. package/dist/protocol/bytes/sha1.d.mts +1 -1
  179. package/dist/protocol/bytes/sha1.mjs +1 -1
  180. package/dist/protocol/diff/read.d.mts +2 -1
  181. package/dist/protocol/diff/read.mjs +102 -8
  182. package/dist/protocol/packs/graph.mjs +1 -1
  183. package/dist/protocol/packs/idx.d.mts +1 -1
  184. package/dist/protocol/packs/idx.mjs +1 -1
  185. package/dist/protocol/packs/parts.mjs +1 -1
  186. package/dist/protocol/packs/reader.d.mts +1 -1
  187. package/dist/protocol/packs/reader.mjs +1 -1
  188. package/dist/protocol/packs/write-error.d.mts +1 -1
  189. package/dist/protocol/packs/write-error.mjs +1 -1
  190. package/dist/protocol/packs/writer.mjs +3 -3
  191. package/dist/protocol/wire/advertisement.d.mts +1 -1
  192. package/dist/protocol/wire/advertisement.mjs +3 -2
  193. package/dist/protocol/wire/fetch.d.mts +1 -1
  194. package/dist/protocol/wire/fetch.mjs +1 -1
  195. package/dist/protocol/wire/lines.d.mts +9 -1
  196. package/dist/protocol/wire/lines.mjs +28 -1
  197. package/dist/protocol/wire/push-uploads.mjs +10 -7
  198. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  199. package/dist/protocol/wire/receive-pack.mjs +1 -1
  200. package/dist/protocol/wire/report-status.d.mts +1 -1
  201. package/dist/protocol/wire/report-status.mjs +1 -1
  202. package/dist/protocol/wire/v2.d.mts +1 -1
  203. package/dist/protocol/wire/v2.mjs +1 -1
  204. package/dist/queue/advance.mjs +31 -24
  205. package/dist/queue/base.d.mts +5 -3
  206. package/dist/queue/calls.mjs +5 -5
  207. package/dist/queue/commit.mjs +1 -1
  208. package/dist/queue/host.d.mts +1 -1
  209. package/dist/queue/layer.d.mts +0 -1
  210. package/dist/queue/layer.mjs +9 -5
  211. package/dist/queue/schedule.mjs +1 -1
  212. package/dist/queue/search.mjs +1 -1
  213. package/dist/queue/state.mjs +1 -1
  214. package/dist/queue/trim.mjs +2 -2
  215. package/dist/rest/client.d.mts +1 -1
  216. package/dist/rest/client.mjs +6 -6
  217. package/dist/rest/errors.mjs +1 -1
  218. package/dist/rest/handler.mjs +2 -2
  219. package/dist/rest/handlers.mjs +16 -6
  220. package/dist/rest/layer.mjs +1 -1
  221. package/dist/rest/listen.mjs +2 -2
  222. package/dist/rest/refs.mjs +1 -1
  223. package/dist/server/edge.mjs +27 -3
  224. package/dist/server/git-layer.d.mts +1 -2
  225. package/dist/server/git-layer.mjs +4 -5
  226. package/dist/server/lifecycle.mjs +1 -1
  227. package/dist/server/registry.mjs +2 -8
  228. package/dist/server/server.mjs +62 -43
  229. package/dist/signin/context.d.mts +1 -1
  230. package/dist/signin/context.mjs +1 -1
  231. package/dist/signin/forms.mjs +1 -1
  232. package/dist/signin/grants.d.mts +2 -2
  233. package/dist/signin/grants.mjs +1 -1
  234. package/dist/signin/wire.mjs +1 -1
  235. package/dist/storage/allotted.mjs +4 -9
  236. package/dist/storage/batch-upkeep.mjs +31 -12
  237. package/dist/storage/batches.d.mts +2 -3
  238. package/dist/storage/batches.mjs +52 -49
  239. package/dist/storage/budget.mjs +23 -1
  240. package/dist/storage/calls.d.mts +1 -1
  241. package/dist/storage/calls.mjs +41 -43
  242. package/dist/storage/charged-cache.mjs +180 -0
  243. package/dist/storage/chunks.d.mts +3 -3
  244. package/dist/storage/chunks.mjs +121 -8
  245. package/dist/storage/counted-bucket.mjs +32 -10
  246. package/dist/storage/fetch-row-cache.d.mts +6 -0
  247. package/dist/storage/fetch-row-cache.mjs +211 -0
  248. package/dist/storage/fetch.d.mts +1 -0
  249. package/dist/storage/fetch.mjs +54 -242
  250. package/dist/storage/held-types.d.mts +0 -1
  251. package/dist/storage/held-types.mjs +13 -4
  252. package/dist/storage/host-bucket.mjs +9 -4
  253. package/dist/storage/index-bitmaps.mjs +340 -65
  254. package/dist/storage/index-build.d.mts +2 -3
  255. package/dist/storage/index-build.mjs +274 -56
  256. package/dist/storage/index-fetch.d.mts +3 -1
  257. package/dist/storage/index-fetch.mjs +60 -21
  258. package/dist/storage/index-graph.mjs +1 -1
  259. package/dist/storage/index-layers.mjs +55 -25
  260. package/dist/storage/index-reach.mjs +15 -22
  261. package/dist/storage/index-whole.d.mts +7 -0
  262. package/dist/storage/index-whole.mjs +145 -37
  263. package/dist/storage/largest-files.mjs +1 -7
  264. package/dist/storage/layout.mjs +17 -1
  265. package/dist/storage/lfs-pointers.mjs +1 -6
  266. package/dist/storage/link-join.mjs +55 -16
  267. package/dist/storage/list-source.d.mts +7 -0
  268. package/dist/storage/list-source.mjs +288 -0
  269. package/dist/storage/loose.d.mts +8 -8
  270. package/dist/storage/loose.mjs +157 -91
  271. package/dist/storage/memory-budget.mjs +226 -22
  272. package/dist/storage/merge-cut.mjs +9 -6
  273. package/dist/storage/merge-fence.mjs +1 -1
  274. package/dist/storage/merge-row.mjs +1 -1
  275. package/dist/storage/merge.d.mts +2 -3
  276. package/dist/storage/merge.mjs +2 -2
  277. package/dist/storage/object-rows.d.mts +3 -3
  278. package/dist/storage/object-rows.mjs +179 -38
  279. package/dist/storage/pack-order.mjs +97 -44
  280. package/dist/storage/pack-ranges.mjs +44 -16
  281. package/dist/storage/pack-reads.d.mts +5 -3
  282. package/dist/storage/pack-reads.mjs +236 -72
  283. package/dist/storage/pack-receive.d.mts +1 -2
  284. package/dist/storage/pack-receive.mjs +24 -18
  285. package/dist/storage/packs.d.mts +1 -1
  286. package/dist/storage/packs.mjs +477 -116
  287. package/dist/storage/placed-reads.mjs +33 -16
  288. package/dist/storage/prune-seen.mjs +1 -1
  289. package/dist/storage/prune-walk.mjs +1 -1
  290. package/dist/storage/prune.mjs +4 -31
  291. package/dist/storage/push-allotment.mjs +26 -14
  292. package/dist/storage/push-uploads.mjs +195 -57
  293. package/dist/storage/pushed-commits.mjs +20 -1
  294. package/dist/storage/quarantine.d.mts +2 -3
  295. package/dist/storage/range-cache.mjs +175 -40
  296. package/dist/storage/raw-ids.mjs +39 -10
  297. package/dist/storage/ready.d.mts +2 -3
  298. package/dist/storage/ready.mjs +114 -38
  299. package/dist/storage/receive-bounds.mjs +31 -9
  300. package/dist/storage/receive-cache.d.mts +7 -0
  301. package/dist/storage/receive-cache.mjs +147 -0
  302. package/dist/storage/receive-files.mjs +1 -1
  303. package/dist/storage/receive-links.mjs +1 -1
  304. package/dist/storage/receive-state.d.mts +2 -2
  305. package/dist/storage/receive-state.mjs +6 -8
  306. package/dist/storage/receive-steps.d.mts +20 -0
  307. package/dist/storage/receive-steps.mjs +298 -13
  308. package/dist/storage/repack-backlog.mjs +1 -6
  309. package/dist/storage/repack-contained.mjs +2 -2
  310. package/dist/storage/repack-job.mjs +1 -1
  311. package/dist/storage/repack.d.mts +2 -3
  312. package/dist/storage/repack.mjs +54 -9
  313. package/dist/storage/request-cache.mjs +57 -0
  314. package/dist/storage/roots.mjs +1 -24
  315. package/dist/storage/rows.d.mts +2 -2
  316. package/dist/storage/rows.mjs +1 -1
  317. package/dist/storage/runs.d.mts +2 -2
  318. package/dist/storage/runs.mjs +1 -1
  319. package/dist/storage/send-list.mjs +62 -25
  320. package/dist/storage/stream-whole.mjs +84 -63
  321. package/dist/storage/swap-walk.mjs +1 -1
  322. package/dist/storage/unpack.mjs +878 -450
  323. package/dist/storage/visible.mjs +110 -32
  324. package/dist/storage/walk.mjs +1 -0
  325. package/dist/storage/wants.mjs +22 -58
  326. package/dist/store/call-count.d.mts +2 -2
  327. package/dist/store/call-count.mjs +24 -11
  328. package/dist/store/catalogue.d.mts +1 -1
  329. package/dist/store/catalogue.mjs +19 -7
  330. package/dist/store/crossing.mjs +1 -7
  331. package/dist/store/cursor-seal.d.mts +1 -1
  332. package/dist/store/cursor-seal.mjs +1 -1
  333. package/dist/store/door.mjs +9 -4
  334. package/dist/store/errors.d.mts +2 -2
  335. package/dist/store/errors.mjs +107 -19
  336. package/dist/store/git-store.mjs +7 -2
  337. package/dist/store/job-try.mjs +90 -9
  338. package/dist/store/list-job.mjs +10 -34
  339. package/dist/store/outbox.d.mts +2 -2
  340. package/dist/store/outbox.mjs +2 -2
  341. package/dist/store/queue-jobs.mjs +6 -12
  342. package/dist/store/records.d.mts +2 -2
  343. package/dist/store/records.mjs +2 -2
  344. package/dist/store/ref-rows.d.mts +2 -2
  345. package/dist/store/ref-rows.mjs +2 -2
  346. package/dist/store/repo-record.d.mts +2 -2
  347. package/dist/store/repo-record.mjs +3 -3
  348. package/dist/store/request-snapshot.mjs +5 -0
  349. package/dist/store/reservations.mjs +2 -2
  350. package/dist/store/topic-jobs.mjs +5 -11
  351. package/dist/sync/bound.d.mts +3 -3
  352. package/dist/sync/bound.mjs +10 -7
  353. package/dist/sync/github.mjs +65 -67
  354. package/dist/sync/http.mjs +1 -1
  355. package/dist/sync/import.mjs +201 -66
  356. package/dist/sync/layer.d.mts +1 -1
  357. package/dist/sync/layer.mjs +6 -6
  358. package/dist/sync/lfs-batch.mjs +1 -1
  359. package/dist/sync/lfs-copy.mjs +175 -15
  360. package/dist/sync/mirror.mjs +5 -10
  361. package/dist/sync/said.mjs +1 -1
  362. package/dist/sync/step.mjs +268 -86
  363. package/dist/sync/tries.mjs +25 -6
  364. package/dist/sync.d.mts +2 -2
  365. package/dist/sync.mjs +2 -2
  366. package/dist/topics/advance.mjs +3 -3
  367. package/dist/topics/calls.mjs +1 -1
  368. package/dist/topics/layer.d.mts +15 -14
  369. package/dist/topics/members.mjs +1 -1
  370. package/dist/topics/topic.mjs +1 -1
  371. package/package.json +3 -13
  372. package/dist/auth/helpers.mjs +0 -17
  373. package/dist/auth.d.mts +0 -5
  374. package/dist/auth.mjs +0 -5
  375. package/dist/core/rules/commit-changes.d.mts +0 -12
  376. package/dist/effect.d.mts +0 -9
  377. package/dist/effect.mjs +0 -7
  378. package/dist/server/joined.d.mts +0 -70
  379. package/dist/server/joined.mjs +0 -41
@@ -2,42 +2,41 @@ import { fail, gitError } from "../contracts/result.mjs";
2
2
  import { openTreeBytes } from "../storage/budget.mjs";
3
3
  import { scopedReceive, walkObjects } from "../storage/calls.mjs";
4
4
  import { isUnindexedRead } from "../storage/index-visible.mjs";
5
+ import { walkedVisible } from "../storage/visible.mjs";
5
6
  import { openTreesRefusal } from "../storage/push-allotment.mjs";
6
7
  import { isLoose } from "../storage/loose.mjs";
7
8
  import { listedIds } from "../storage/listed-ids.mjs";
8
- import { indexRowKey, isPackId, objectCollections } from "../storage/layout.mjs";
9
+ import { indexRowKey, isPackId, objectCollections, pruneClearedKey } from "../storage/layout.mjs";
9
10
  import { noLfsPointers } from "../storage/lfs-pointers.mjs";
10
11
  import { isShallowRoot } from "../storage/links.mjs";
11
- import { isAwaitingUpkeep } from "../storage/repack-backlog.mjs";
12
+ import { repackJobKey, repackJobName } from "../storage/repack-job.mjs";
12
13
  import { allottedRows } from "../storage/allotted.mjs";
13
14
  import { chunkedOf } from "../storage/chunks.mjs";
14
15
  import { gitObjectOf, headerOfRow, noRows, receivedObject, receivedRows } from "../storage/object-rows.mjs";
15
- import { pruneClearedKey } from "../storage/prune.mjs";
16
16
  import { abandonOwn } from "../storage/quarantine.mjs";
17
17
  import { readyBytesOf, readyKey } from "../storage/ready.mjs";
18
18
  import { QuarantineRow } from "../storage/rows.mjs";
19
19
  import { promoteOwn } from "../storage/batch-upkeep.mjs";
20
- import { abandonBatch, batchesRead, isStagedReceive, stagedBatchOf } from "../storage/batches.mjs";
21
- import { bestEffort, decodeRow, fromInfra, storeCommit } from "../store/errors.mjs";
20
+ import { abandonBatch, batchesRead, isStagedReceive, stagedBatchOf, stagedOwnOf } from "../storage/batches.mjs";
21
+ import { bestEffort, decodeRow, fromInfra, storeCall, storeCommit } from "../store/errors.mjs";
22
22
  import { callScope } from "../store/call-count.mjs";
23
23
  import { decodePacks, gitStore } from "../store/git-store.mjs";
24
24
  import { WholeRepo, refBytesOf, storesPeel, wholeRefs } from "../store/ref-rows.mjs";
25
25
  import { dropBody } from "../protocol/bytes/reader.mjs";
26
- import { gitsOwnMove, hiddenUnder } from "../protocol/wire/lines.mjs";
26
+ import { anyoneMoves, hiddenUnder, movesAsGitsOwn } from "../protocol/wire/lines.mjs";
27
27
  import { sliceOf } from "../protocol/wire/push-limits.mjs";
28
28
  import { pushCounts } from "./events/seen.mjs";
29
29
  import { refViewIn } from "./ref-view.mjs";
30
30
  import { appendEvents, decodeOutbox, firstSeq, outboxReads, repoEnvelope } from "../store/outbox.mjs";
31
31
  import { rowsAtCommit } from "./loose-tally.mjs";
32
- import { MirrorRow, mirrorJobKey } from "./mirror-rows.mjs";
33
- import { PrunedMark, mirrorJobName } from "../store/records.mjs";
34
- import { HeldBy, decodeStats, heldUntil, looseRows, movedRoots, readRecord, repoStats, rootsMoved, rootsOf, timeRow } from "../store/repo-record.mjs";
32
+ import { LooseTally, PrunedMark } from "../store/records.mjs";
33
+ import { HeldBy, decodeStats, heldAdd, heldStore, heldUntil, looseRows, movedRoots, readRecord, repoStats, rootsMoved, rootsOf, timeRow } from "../store/repo-record.mjs";
35
34
  import { advanceRow } from "../store/queue-jobs.mjs";
36
35
  import { liveReservations, reservedTarget } from "../store/reservations.mjs";
37
36
  import { settleName } from "../store/settle.mjs";
38
- import { collections, newChangeId, prunedKey, pushedKey, pushedUnder, reachedKey, repoRootsKey, repoScope } from "../store/scopes.mjs";
37
+ import { collections, looseKey, newChangeId, prunedKey, pushedKey, pushedUnder, reachedKey, repoRootsKey, repoScope } from "../store/scopes.mjs";
39
38
  import { headOf, indexJobs, openKeyed, openRepo, refIndexJobs, repoAccess } from "./access.mjs";
40
- import { kindsOf } from "./ancestry.mjs";
39
+ import { ancestryLimit, kindsOf } from "./ancestry.mjs";
41
40
  import { isRefName } from "./names.mjs";
42
41
  import { runHookGroups } from "./hooks/groups.mjs";
43
42
  import { Changes } from "./changes.mjs";
@@ -49,8 +48,8 @@ import { changedWhileChecked, factsHeld, tipsOf } from "./rules/facts.mjs";
49
48
  import { clearsMark, decidePush, otherWritesProblem, pushOptionsProblem } from "./push-decide.mjs";
50
49
  import { heldReceipt, receiptReads, receiptWrites, refsAnswer, refsKept, withJobs } from "./receipts.mjs";
51
50
  import { SealedObjects, viewOf } from "./view.mjs";
51
+ import { notFailed } from "./events/deliver.mjs";
52
52
  import { ownWriter, ownWritesOf } from "./own-writes.mjs";
53
- import { ensureRepack } from "./repack.mjs";
54
53
  import { publishable, unpublished } from "./publish.mjs";
55
54
  import { peeledAll, peeledOf } from "../storage/wants.mjs";
56
55
  import { CoreParts, ObjectsParts } from "./parts.mjs";
@@ -58,11 +57,11 @@ import { defaultPushFiles, filesChecked } from "./push-files.mjs";
58
57
  import { addedBytes, defaultPushRepo, repoChecked } from "./push-repo.mjs";
59
58
  import { Authorize, check } from "../contracts/authorize.mjs";
60
59
  import { read } from "./objects/objects.mjs";
61
- import * as Clock from "effect/Clock";
60
+ import { checkWrites, limits } from "@ref0/infra";
62
61
  import * as Effect from "effect/Effect";
63
62
  import * as Exit from "effect/Exit";
64
63
  import * as Result from "effect/Result";
65
- import { checkWrites } from "@ref0/infra";
64
+ import * as Clock from "effect/Clock";
66
65
  import * as Equal from "effect/Equal";
67
66
  // src/core/push.ts
68
67
  /**
@@ -71,6 +70,11 @@ import * as Equal from "effect/Equal";
71
70
  * name it can't write is `unseenRef`'s, the same whatever is there.
72
71
  */
73
72
  const pushWhole = /* @__PURE__ */ WholeRepo.mint();
73
+ /** How far a walk of what a ref's old tip reaches goes, past which a move's walk is refused. */
74
+ const judgedWalk = {
75
+ most: ancestryLimit,
76
+ commits: true
77
+ };
74
78
  const packsRead = { collection: collections.packs };
75
79
  const refsRead = { collection: collections.refs };
76
80
  const timesRead = { collection: collections.stats };
@@ -206,7 +210,8 @@ const firstRead = (caller, operation, internalId) => openRepo(caller, {
206
210
  }, [
207
211
  packsRead,
208
212
  prunedKey,
209
- repoRootsKey
213
+ repoRootsKey,
214
+ looseKey
210
215
  ], internalId, "skip");
211
216
  /** `firstRead` for a keyed push: `undefined` once `missed`'s repo moved, as `openKeyed` says. */
212
217
  const keyedRead = (caller, operation, missed, internalId) => openKeyed(caller, {
@@ -215,7 +220,8 @@ const keyedRead = (caller, operation, missed, internalId) => openKeyed(caller, {
215
220
  }, [
216
221
  packsRead,
217
222
  prunedKey,
218
- repoRootsKey
223
+ repoRootsKey,
224
+ looseKey
219
225
  ], missed, internalId, "skip");
220
226
  /**
221
227
  * The first read's repo once `authorize` lets the caller push to it: its list, for the pack to be
@@ -238,6 +244,8 @@ const listedFor = /* @__PURE__ */ Effect.fnUntraced(function* (request, operatio
238
244
  };
239
245
  const mark = yield* markOf(resolved.snapshot.results[2] ?? []);
240
246
  const roots = yield* rootsOf(resolved.snapshot.results[3]);
247
+ const [looseRow] = resolved.snapshot.results[4] ?? [];
248
+ const loose = looseRow === void 0 ? void 0 : yield* decodeRow(LooseTally, looseRow, "The repo's object rows' tally");
241
249
  const views = yield* Effect.forEach(decidingFor(request), (one) => viewOf(one, resolved, request.as));
242
250
  const [view = yield* viewOf(caller, resolved, request.as)] = views;
243
251
  return {
@@ -245,6 +253,7 @@ const listedFor = /* @__PURE__ */ Effect.fnUntraced(function* (request, operatio
245
253
  defaultBranch: headOf(resolved.record.defaultBranch),
246
254
  mark,
247
255
  roots,
256
+ hasLooseRows: (loose?.objects ?? 0) > 0,
248
257
  repo,
249
258
  view,
250
259
  views,
@@ -291,13 +300,21 @@ const seenRefsOf = /* @__PURE__ */ Effect.fnUntraced(function* (view, listed, ro
291
300
  */
292
301
  const pushedOf = (objects, listed, received) => {
293
302
  if (received === void 0) return () => Effect.succeed(void 0);
294
- const rows = receivedRows(received.change);
303
+ const staged = stagedOwnOf(received.change);
304
+ const rows = staged === void 0 ? receivedRows(received.change) : void 0;
295
305
  const own = {
296
306
  ...listed,
297
307
  packs: received.change.add ?? []
298
308
  };
299
309
  return (input) => {
300
- const row = rows.get(input.oid);
310
+ if (staged !== void 0) {
311
+ if (!staged.headers.has(input.oid)) return own.packs.length === 0 ? Effect.succeed(void 0) : objects.read(own, {
312
+ ...input,
313
+ listedOnly: true
314
+ });
315
+ return Effect.flatMap(staged.readRow(input.oid), (row) => row === void 0 ? Effect.succeed(void 0) : Effect.map(receivedObject(received.change, row), gitObjectOf));
316
+ }
317
+ const row = rows?.get(input.oid);
301
318
  if (row !== void 0) return Effect.map(receivedObject(received.change, row), gitObjectOf);
302
319
  return own.packs.length === 0 ? Effect.succeed(void 0) : objects.read(own, {
303
320
  ...input,
@@ -310,35 +327,6 @@ const pushedOf = (objects, listed, received) => {
310
327
  * reads one, its bytes let go unread. A read that fails throws, so the walk trusts nothing.
311
328
  */
312
329
  const broughtCommit = (pushed) => (oid) => Effect.flatMap(pushed({ oid }), (object) => Effect.as(dropBody(object?.bytes), object?.type === "commit"));
313
- /** The refs the repo mirrors, among `rows` of `mirrors`: each one an active mirror names, with its destination. */
314
- const activeMirrors = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
315
- const active = /* @__PURE__ */ new Map();
316
- for (const row of rows) {
317
- const mirror = yield* decodeRow(MirrorRow, row, `Mirror '${row.id}'`);
318
- if (mirror.state === "active") active.set(row.id, mirror.destination);
319
- }
320
- return active;
321
- });
322
- /**
323
- * `sync.mirror`'s row for each destination an active mirror of a ref the commit moves names, one
324
- * however many of its refs move, found by name among the jobs the server knows: none until
325
- * `Sync.layer` has bound them.
326
- */
327
- const mirrorJobs = (core, moved, mirrored) => {
328
- const definition = core.jobOf?.(mirrorJobName);
329
- if (definition === void 0) return [];
330
- const jobs = /* @__PURE__ */ new Map();
331
- for (const { ref } of moved) {
332
- const destination = mirrored.get(ref);
333
- if (destination === void 0) continue;
334
- const key = mirrorJobKey(destination);
335
- jobs.set(key, definition.job({
336
- key,
337
- data: { destination }
338
- }));
339
- }
340
- return [...jobs.values()];
341
- };
342
330
  /** The repo's stored packs and the received pack's, before the commit lists it: a push's changes read both. */
343
331
  const withReceived = (listed, received) => received === void 0 ? listed : {
344
332
  ...listed,
@@ -347,26 +335,37 @@ const withReceived = (listed, received) => received === void 0 ? listed : {
347
335
  /** The objects, with the rows a receive puts read first: they're written only by the commit. */
348
336
  const withReceivedRows = (objects, received) => {
349
337
  const change = received?.change;
350
- const rows = receivedRows(change);
351
- if (rows.size === 0) return objects;
352
- const rowsOf = (before) => (oids, each) => Effect.forEach(oids, Effect.fnUntraced(function* (oid) {
353
- const row = rows.get(oid);
354
- if (row === void 0) return;
355
- const chunked = chunkedOf(row.value);
356
- if (chunked !== void 0 && before !== void 0 && !(yield* before(oid, chunked.size))) return;
357
- yield* each(yield* receivedObject(change, row));
358
- }), { discard: true });
338
+ const staged = stagedOwnOf(change);
339
+ const rows = staged === void 0 ? receivedRows(change) : void 0;
340
+ const hasOwn = (oid) => staged !== void 0 ? staged.headers.has(oid) : rows?.has(oid) ?? false;
341
+ if ((staged !== void 0 ? staged.headers.size : rows?.size ?? 0) === 0) return objects;
342
+ const rowOf = (oid) => staged !== void 0 ? staged.readRow(oid) : Effect.succeed(rows?.get(oid));
343
+ const rowsOf = (before) => Effect.fnUntraced(function* (oids, each) {
344
+ const fetched = staged !== void 0 ? yield* staged.readRows(oids) : oids.map((oid) => rows?.get(oid));
345
+ for (const [index, oid] of oids.entries()) {
346
+ const row = fetched[index];
347
+ if (row === void 0) continue;
348
+ const chunked = chunkedOf(row.value);
349
+ if (chunked !== void 0 && before !== void 0 && !(yield* before(oid, chunked.size))) continue;
350
+ yield* each(yield* receivedObject(change, row));
351
+ }
352
+ });
359
353
  return {
360
354
  ...objects,
361
355
  read: (listed, input) => {
362
- const row = rows.get(input.oid);
363
- return row === void 0 ? objects.read(listed, input) : Effect.map(receivedObject(change, row), gitObjectOf);
356
+ if (!hasOwn(input.oid)) return objects.read(listed, input);
357
+ return Effect.flatMap(rowOf(input.oid), (row) => row === void 0 ? objects.read(listed, input) : Effect.map(receivedObject(change, row), gitObjectOf));
364
358
  },
365
359
  headers: Effect.fnUntraced(function* (listed, input) {
366
360
  const answer = /* @__PURE__ */ new Map();
367
- const stored = input.oids.filter((oid) => !rows.has(oid));
361
+ const stored = input.oids.filter((oid) => !hasOwn(oid));
368
362
  for (const oid of input.oids) {
369
- const row = rows.get(oid);
363
+ if (staged !== void 0) {
364
+ const header = staged.headers.get(oid);
365
+ if (header !== void 0) answer.set(oid, header);
366
+ continue;
367
+ }
368
+ const row = rows?.get(oid);
370
369
  if (row === void 0) continue;
371
370
  answer.set(oid, yield* headerOfRow(row));
372
371
  }
@@ -379,17 +378,17 @@ const withReceivedRows = (objects, received) => {
379
378
  objects: Effect.fnUntraced(function* (listed, input) {
380
379
  const asked = [...new Set(input.oids)];
381
380
  const [first] = asked;
382
- if (first === void 0 || !asked.some((oid) => rows.has(oid))) return yield* objects.objects(listed, {
381
+ if (first === void 0 || !asked.some(hasOwn)) return yield* objects.objects(listed, {
383
382
  ...input,
384
383
  oids: asked
385
384
  });
386
- const fromRows = rows.has(first);
387
- const own = asked.filter((oid) => rows.has(oid) === fromRows);
385
+ const fromRows = hasOwn(first);
386
+ const own = asked.filter((oid) => hasOwn(oid) === fromRows);
388
387
  const answered = fromRows ? yield* allottedRows(rowsOf, own, input.bytes) : yield* objects.objects(listed, {
389
388
  ...input,
390
389
  oids: own
391
390
  });
392
- const left = /* @__PURE__ */ new Set([...answered.left, ...asked.filter((oid) => rows.has(oid) !== fromRows)]);
391
+ const left = /* @__PURE__ */ new Set([...answered.left, ...asked.filter((oid) => hasOwn(oid) !== fromRows)]);
393
392
  return {
394
393
  objects: answered.objects,
395
394
  left: asked.filter((oid) => left.has(oid))
@@ -441,7 +440,8 @@ const buildFence = (build) => [
441
440
  * answers, it fails, to be sent again (Q270). `changed`: whether a row of a build's fence,
442
441
  * `unchanged`, holds another value than its plan read.
443
442
  */
444
- const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fence, received, kept, mark, branches, touched, guard, unchanged = []) {
443
+ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (core, repo, fence, received, kept, mark, branches, touched, guard, unchanged = [], countPuts = true) {
444
+ const { store } = core;
445
445
  const own = received?.quarantine === void 0 ? [] : [received.quarantine];
446
446
  const batched = isStagedReceive(received) ? [batchesRead] : [];
447
447
  const keyed = receiptReads(kept);
@@ -450,10 +450,16 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
450
450
  id
451
451
  }));
452
452
  const linkedRows = received?.linked?.rows ?? [];
453
- const rowCounts = linkedRows.map((oid) => ({
453
+ const rowCounts = linkedRows.map((prefix) => ({
454
454
  collection: objectCollections.objects,
455
- prefix: oid
455
+ prefix
456
456
  }));
457
+ if (countPuts) {
458
+ for (const { collection, id } of received?.change.put ?? []) if (rowCounts.length < limits.counts && collection === objectCollections.objects) rowCounts.push({
459
+ collection,
460
+ prefix: id
461
+ });
462
+ }
457
463
  const { record, snapshot } = yield* readRecord(store, repo.internalId, [
458
464
  refsRead,
459
465
  ...outboxReads,
@@ -508,7 +514,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
508
514
  const refs = yield* wholeRefs(pushWhole, refRows);
509
515
  const outbox = yield* decodeOutbox([headRows, cursorRows]);
510
516
  const held = ownRow === void 0 ? void 0 : yield* decodeRow(QuarantineRow, ownRow, `The push's quarantine row '${ownRow.id}'`);
511
- const mirrored = yield* activeMirrors(mirrorRows);
517
+ const mirrorJobs = core.mirrorJobs === void 0 || core.jobOf === void 0 ? void 0 : yield* core.mirrorJobs(mirrorRows, core.jobOf);
512
518
  const revoked = yield* Effect.match(fence.check(fenced), {
513
519
  onFailure: (error) => error,
514
520
  onSuccess: () => void 0
@@ -547,7 +553,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
547
553
  receipt,
548
554
  outbox,
549
555
  record,
550
- mirrored,
556
+ mirrorJobs,
551
557
  facts,
552
558
  stats,
553
559
  times,
@@ -555,6 +561,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
555
561
  reserved,
556
562
  indexRow,
557
563
  changed,
564
+ counts: snapshot.counts.slice(linkedRows.length),
558
565
  roots: yield* rootsOf(rootRows)
559
566
  };
560
567
  });
@@ -566,16 +573,17 @@ const settingsOf = (record) => ({
566
573
  /** The rules, the registrations' checks, then the hook groups, once, at the first read the push decides on. */
567
574
  const runChecks = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, facts) {
568
575
  const context = checking(input);
569
- const ruled = yield* registeredAfter(checks, input, yield* runPushRules(checks, input, context));
576
+ const ruled = yield* runPushRules(checks, input, context);
577
+ const refused = yield* registeredAfter(checks, input, ruled.updates, ruled.refused);
570
578
  const whole = yield* runHookGroups(checks.groups?.() ?? [], context, {
571
579
  atomic: input.atomic,
572
580
  updates: ruled.updates,
573
- refused: ruled.refused
581
+ refused
574
582
  });
575
583
  const checked = {
576
584
  facts,
577
585
  updates: ruled.updates,
578
- refused: ruled.refused,
586
+ refused,
579
587
  filesAllowed: ruled.filesAllowed,
580
588
  bypassed: ruled.bypassed
581
589
  };
@@ -622,20 +630,18 @@ const checkAll = /* @__PURE__ */ Effect.fnUntraced(function* (checks, request, i
622
630
  };
623
631
  });
624
632
  /**
625
- * The rules' answer, with the refs the registered checks refuse among the rest: each in turn, by band
626
- * then registration name, on the refs none before it refused, so a ref's first refusal is its answer.
633
+ * `before`, the refusals so far, with the refs among `updates` the registered checks refuse: each in
634
+ * turn, by band then registration name, on the refs none before it refused, so a ref's first
635
+ * refusal is its answer.
627
636
  */
628
- const registeredAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, ruled) {
629
- const refused = new Map(ruled.refused);
637
+ const registeredAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, moved, before) {
638
+ const refused = new Map(before);
630
639
  for (const { handler } of checks.registered?.() ?? []) {
631
- const updates = ruled.updates.filter((update) => !refused.has(update.ref));
640
+ const updates = moved.filter((update) => !refused.has(update.ref));
632
641
  if (updates.length === 0) break;
633
642
  for (const [ref, error] of yield* handler(input, updates)) if (!refused.has(ref)) refused.set(ref, error);
634
643
  }
635
- return {
636
- ...ruled,
637
- refused
638
- };
644
+ return refused;
639
645
  });
640
646
  /** Whether a push has anything to check: a rule, a registered check, or a hook group. */
641
647
  const checksOf = /* @__PURE__ */ Effect.fnUntraced(function* (core) {
@@ -816,7 +822,7 @@ const unindexedPush = () => gitError("RESOURCE_EXHAUSTED", "This push can't be c
816
822
  /** `error`, a read by ID the index can't close yet told as the push's own. */
817
823
  const asPushCheck = (error) => isUnindexedRead(error) ? unindexedPush() : error;
818
824
  /** The request's pack into its quarantine, or `undefined` for a push with none. */
819
- const receive = (objects, listed, request) => {
825
+ const receive = (objects, listed, request, hasLooseRows) => {
820
826
  const { pack, shallow, signal } = request;
821
827
  if (pack === void 0) return Effect.succeed({
822
828
  received: void 0,
@@ -832,7 +838,8 @@ const receive = (objects, listed, request) => {
832
838
  });
833
839
  const input = {
834
840
  pack: pack.bytes,
835
- objects: pack.objects
841
+ objects: pack.objects,
842
+ hasLooseRows
836
843
  };
837
844
  if (pack.length !== void 0) input.length = pack.length;
838
845
  if (pack.atMost !== void 0) input.atMost = pack.atMost;
@@ -897,7 +904,7 @@ const lists = (body, own) => body.delete.some((key) => key.collection === own.co
897
904
  * only, refused as the commit would be, its `writes` or none, and answered before it, for
898
905
  * `checkPush`: nothing before that point writes, reserves or enqueues, with no pack.
899
906
  */
900
- const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRepo, view, views, heldAt }, key, answers, checking = false) => Effect.scoped(Effect.gen(function* () {
907
+ const pushOnto = (request, { listed, defaultBranch, mark, roots, hasLooseRows, repo: checkedRepo, view, views, heldAt }, key, answers, checking = false) => Effect.scoped(Effect.gen(function* () {
901
908
  const core = yield* CoreParts;
902
909
  const { objects: sealed, fetchLimits, files = defaultPushFiles, repo: repoSizes = defaultPushRepo } = yield* ObjectsParts;
903
910
  const authorize = yield* Authorize;
@@ -908,7 +915,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
908
915
  const { received, rooted } = yield* receive(yield* read({
909
916
  view,
910
917
  at: seen
911
- }), listed, request).pipe(Effect.provideService(HeldBy, heldUntil(heldAt, fetchLimits)), Effect.tapError((error) => isAwaitingUpkeep(error) ? bestEffort(ensureRepack(core, core.jobs, listed.repo, fetchLimits)) : Effect.void), Effect.mapError(asPushCheck));
918
+ }), listed, request, hasLooseRows).pipe(Effect.provideService(HeldBy, heldUntil(heldAt, fetchLimits)), Effect.tapError((error) => isAwaitingUpkeep(error) ? bestEffort(ensureRepack(core, core.jobs, listed.repo, fetchLimits)) : Effect.void), Effect.mapError(asPushCheck));
912
919
  const ownedPack = ownPack(request, received);
913
920
  let listing = false;
914
921
  if (ownedPack !== void 0) yield* Effect.addFinalizer((exit) => listing || Exit.hasInterrupts(exit) ? Effect.void : Effect.flatMap(Clock.currentTimeMillis, (at) => abandonOwn({
@@ -995,7 +1002,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
995
1002
  });
996
1003
  const headsOf = (edit) => edit.to === null ? void 0 : request.publishes?.get(edit.ref);
997
1004
  const publishedAt = Effect.fnUntraced(function* (refs, at, index) {
998
- const plain = request.edits.filter((edit) => headsOf(edit) === void 0);
1005
+ const plain = request.edits.filter((edit) => headsOf(edit) === void 0 && !movesAsGitsOwn(hidden, request.as, edit.ref));
999
1006
  const refused = new Map(yield* unpublishedAt(refs, at, index, refView, plain, ownOf));
1000
1007
  for (const edit of request.edits) {
1001
1008
  const heads = headsOf(edit);
@@ -1038,9 +1045,10 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
1038
1045
  const fence = fenceAll(request, decidingFor(request).map((one) => core.fences(one, target)));
1039
1046
  const ready = objects.readyShallow && request.edits.some((edit) => edit.ref === defaultBranch || edit.ref.startsWith("refs/tags/"));
1040
1047
  const jobs = (received?.change.add?.length ?? 0) > 0 || isStagedReceive(received) || ready ? [core.repackJobRow()] : [];
1041
- const own = updates.filter((update) => gitsOwnMove(hidden, request.as, update.ref));
1042
- const outside = updates.filter((update) => !gitsOwnMove(hidden, request.as, update.ref));
1043
- const checks = outside.length === 0 ? void 0 : yield* checksOf(core);
1048
+ const own = updates.filter((update) => movesAsGitsOwn(hidden, request.as, update.ref));
1049
+ const outside = updates.filter((update) => !movesAsGitsOwn(hidden, request.as, update.ref));
1050
+ const segments = own.filter((update) => anyoneMoves(hidden, update.ref));
1051
+ const checks = outside.length === 0 && segments.length === 0 ? void 0 : yield* checksOf(core);
1044
1052
  const branches = request.source === "queue" ? [] : outside.map((update) => update.ref).filter((ref) => ref.startsWith("refs/heads/") && isRefName(ref));
1045
1053
  const touched = updates.map(({ ref }) => ref).filter(isRefName);
1046
1054
  const scope = yield* callScope;
@@ -1088,14 +1096,14 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
1088
1096
  let checked;
1089
1097
  for (let tries = 0; tries < 10; tries += 1) {
1090
1098
  const at = yield* Clock.currentTimeMillis;
1091
- const decide = yield* finalRead(store, target, fence, received, key, mark, branches, touched, request.guard, request.writes?.unchanged);
1092
- const { read, receipt, outbox, record, mirrored, facts, stats, times, queued, reserved, indexRow } = decide;
1099
+ const decide = yield* finalRead(core, target, fence, received, key, mark, branches, touched, request.guard, request.writes?.unchanged, tries > 0 || hasLooseRows);
1100
+ const { read, receipt, outbox, record, mirrorJobs, facts, stats, times, queued, reserved, indexRow } = decide;
1093
1101
  const indexed = SealedObjects.whole(sealed, pushWhole).index?.status(indexRow, at, listedIds(decide.at, received?.change));
1094
1102
  if (receipt !== void 0) return yield* answers.held(receipt);
1095
1103
  const published = yield* publishedAt(read.refs, decide.at, indexRow);
1096
1104
  const { writes } = request;
1097
1105
  if (writes !== void 0 && (writes.unchanged === void 0 ? read.version !== writes.version : decide.changed)) return yield* Effect.fail(queueMoved(repo));
1098
- const rowsMoved = received === void 0 ? noRows : yield* rowsAtCommit(store, listed.repo, received.change, read.version);
1106
+ const rowsMoved = received === void 0 ? noRows : (times.loose?.objects ?? 0) === 0 ? received.change.rows : yield* rowsAtCommit(store, listed.repo, received.change, read.version, decide.counts);
1099
1107
  if (rowsMoved === void 0) continue;
1100
1108
  const added = addedBytes(received?.change, rowsMoved);
1101
1109
  const sized = repoChecked(repoSizes, stats.ownBytes, added);
@@ -1120,17 +1128,34 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
1120
1128
  ...changing,
1121
1129
  signal: unaborted
1122
1130
  };
1123
- if (by !== void 0) judging.covered = coveredTips(read.refs, by.covers);
1131
+ judging.reach = (tips) => SealedObjects.visibleWhole(sealed, pushWhole, decide.at, {
1132
+ tips,
1133
+ row: indexRow?.value,
1134
+ roots
1135
+ }, () => walkedVisible(whole, decide.at, {
1136
+ tips,
1137
+ roots
1138
+ }, judgedWalk));
1139
+ judging.roots = roots;
1140
+ if (by !== void 0) judging.covered = coveredTips(read.refs, (ref) => by.covers(ref) && !movesAsGitsOwn(hidden, request.as, ref));
1124
1141
  if (by !== void 0) judging.refuses = by.refuses;
1125
1142
  if (by?.covers(read.head) === true) judging.defaultTip = read.refs.get(read.head);
1126
1143
  return commitChangesOf(judging, updates);
1127
1144
  }
1128
1145
  };
1129
- checked = yield* checkAll(checks, request, input, seen, (one) => (operation) => authorize.check({
1146
+ const ruled = outside.length === 0 ? void 0 : yield* checkAll(checks, request, input, seen, (one) => (operation) => authorize.check({
1130
1147
  caller: one,
1131
1148
  operation,
1132
1149
  repo: checkedRepo
1133
1150
  }));
1151
+ checked = {
1152
+ facts: seen,
1153
+ updates: [],
1154
+ filesAllowed: /* @__PURE__ */ new Map(),
1155
+ bypassed: /* @__PURE__ */ new Map(),
1156
+ ...ruled,
1157
+ refused: yield* registeredAfter(checks, input, segments, ruled?.refused ?? input.refused)
1158
+ };
1134
1159
  } else if (checked !== void 0 && !factsHeld(checked.facts, seen)) return yield* Effect.fail(changedWhileChecked());
1135
1160
  if (checked?.whole !== void 0) return yield* Effect.fail(checked.whole);
1136
1161
  const decided = checked === void 0 ? {
@@ -1183,7 +1208,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
1183
1208
  if (yield* settleName(store, scope, settling)) continue;
1184
1209
  const envelope = repoEnvelope(caller, name);
1185
1210
  const id = newChangeId();
1186
- const shown = planned.moved.filter((move) => !gitsOwnMove(core.hiddenRefs(), request.as, move.ref));
1211
+ const shown = planned.moved.filter((move) => !movesAsGitsOwn(core.hiddenRefs(), request.as, move.ref));
1187
1212
  const optionsPast = pushOptionsProblem(request.pushOptions, shown.length);
1188
1213
  if (optionsPast !== void 0) return yield* Effect.fail(optionsPast);
1189
1214
  const push = pushOf(core.access, id, shown, request);
@@ -1212,6 +1237,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
1212
1237
  const pushed = pushedRows(core.access, shown, times, at);
1213
1238
  const moved = planned.moves ? rowsMoved : noRows;
1214
1239
  const loose = looseRows(times.loose, moved);
1240
+ const foldLoose = moved.bytes > 0 && (loose[0]?.value.bytes ?? 0) > 16777216 ? [core.repackJobRow()] : [];
1215
1241
  const body = {
1216
1242
  id,
1217
1243
  expect: planned.expect,
@@ -1233,7 +1259,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
1233
1259
  jobs: withJobs([
1234
1260
  ...planned.jobs,
1235
1261
  ...appended.jobs,
1236
- ...mirrorJobs(core, planned.moved, mirrored),
1262
+ ...mirrorJobs?.(planned.moved) ?? [],
1237
1263
  ...writes?.jobs ?? [],
1238
1264
  ...woken,
1239
1265
  ...shown.length > 0 ? indexJobs(core, indexed) : [],
@@ -1241,7 +1267,8 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
1241
1267
  ], [
1242
1268
  ...kept.jobs,
1243
1269
  ...also?.jobs ?? [],
1244
- ...rooted?.jobs ?? []
1270
+ ...rooted?.jobs ?? [],
1271
+ ...foldLoose
1245
1272
  ])
1246
1273
  };
1247
1274
  const objects = (received?.change.put?.length ?? 0) + (received?.change.delete?.length ?? 0);
@@ -1338,4 +1365,24 @@ const keyedPushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answ
1338
1365
  });
1339
1366
  /** `keyedPushWith` for `refs.update`, answering the decide's ref answer. */
1340
1367
  const keyedPush = (request, keyed) => keyedPushWith(request, refsAnswers, keyed);
1341
- export { buildFence, checkPush, gitPush, isQueueMoved, keyedGitPush, keyedPush, keyedPushWith, push, pushFetched, pushWith, retriedCodes };
1368
+ /**
1369
+ * Whether `error` refuses a push until upkeep runs, by its reason: `awaitingRepack`'s, or
1370
+ * `awaitingUpkeep`'s for a repo whose published batches are at `batchesMost`.
1371
+ */
1372
+ const isAwaitingUpkeep = (error) => error.code === "UNAVAILABLE" && (error.context?.reason === "packs-awaiting-repack" || error.context?.reason === "batches-awaiting-upkeep");
1373
+ /**
1374
+ * The repo's `git.repack` row made due, for a push refused `packs-awaiting-repack`, so its hint
1375
+ * holds: added if it's gone, and retried if it spent its tries, since an add leaves a failed row
1376
+ * failed, its data rebuilt once it has compacted. A row already waiting or running is left as it is.
1377
+ * A repo deleted since the push read it takes none, as its purge may have dropped its scope (#1911).
1378
+ */
1379
+ const ensureRepack = /* @__PURE__ */ Effect.fnUntraced(function* (core, jobs, repo, fetchLimits) {
1380
+ if (!(yield* heldAdd(heldStore(core.store), repo, fetchLimits, { jobs: [core.repackJobRow()] }).pipe(Effect.as(true), Effect.catchTag("RepoGone", () => Effect.succeed(false))))) return;
1381
+ const scope = repoScope(repo);
1382
+ const job = {
1383
+ name: repackJobName,
1384
+ key: repackJobKey
1385
+ };
1386
+ yield* storeCall(jobs.retry(scope, job)).pipe(Effect.catchIf(notFailed, () => Effect.void));
1387
+ });
1388
+ export { buildFence, checkPush, ensureRepack, gitPush, isQueueMoved, keyedGitPush, keyedPush, keyedPushWith, push, pushFetched, pushWith, retriedCodes };
@@ -3,6 +3,6 @@ import "../contracts/refs.mjs";
3
3
  import "../contracts/repos.mjs";
4
4
  import "../contracts/result.mjs";
5
5
  import "../store/records.mjs";
6
- import "effect/Effect";
6
+ import { JobInput, Key, Moment, Read, Row } from "@ref0/infra";
7
7
  import "effect/Schema";
8
- import { JobInput, Key, Moment, Read, Row } from "@ref0/infra";
8
+ import "effect/Effect";
@@ -2,8 +2,8 @@ import { fail, gitErrorFrom, httpStatus } from "../contracts/result.mjs";
2
2
  import { decodeRow } from "../store/errors.mjs";
3
3
  import { KeptRepoInfo, keyLive } from "../store/records.mjs";
4
4
  import { collections } from "../store/scopes.mjs";
5
- import * as Effect from "effect/Effect";
6
5
  import * as Schema from "effect/Schema";
6
+ import * as Effect from "effect/Effect";
7
7
  // src/core/receipts.ts
8
8
  /**
9
9
  * A receipt row's day, in milliseconds. It's `keyKept` at least, so a receipt `keyKept` hasn't
@@ -63,7 +63,13 @@ const KeptAnswer = /* @__PURE__ */ Schema.Union([
63
63
  answer: Schema.Json
64
64
  }),
65
65
  Schema.Struct({ kind: Schema.Literal("done") }),
66
- Schema.Struct({ kind: Schema.Literal("fork") })
66
+ Schema.Struct({ kind: Schema.Literal("fork") }),
67
+ Schema.Struct({
68
+ kind: Schema.Literal("deepen"),
69
+ run: Schema.String,
70
+ info: Schema.optionalKey(KeptRepoInfo),
71
+ error: Schema.optionalKey(KeptError)
72
+ })
67
73
  ]);
68
74
  /**
69
75
  * A keyed write's receipt, in the scope it wrote, saved in the write's own commit: the input its
@@ -260,6 +266,7 @@ const receiptAnswered = (held) => {
260
266
  case "queue":
261
267
  case "done": return true;
262
268
  case "fork": return true;
269
+ case "deepen": return held.answer.info !== void 0 || held.answer.error !== void 0;
263
270
  }
264
271
  };
265
272
  /** The answer a repo create, update or rename's receipt kept, for the write sent again. */
@@ -1,11 +1,11 @@
1
1
  import { storeCommit } from "../store/errors.mjs";
2
- import { currentRepo, gitJob } from "../store/job-try.mjs";
2
+ import { currentRepo, gitJob, jobTryTimeout } from "../store/job-try.mjs";
3
3
  import { readRecord } from "../store/repo-record.mjs";
4
4
  import { newChangeId, repoScope, selfKey } from "../store/scopes.mjs";
5
5
  import { copyRead, indexCopies, indexRowKeys, otherRowsReads, ownRowsRead } from "./ref-index.mjs";
6
- import * as Effect from "effect/Effect";
7
- import * as Schema from "effect/Schema";
8
6
  import { Job } from "@ref0/infra";
7
+ import * as Schema from "effect/Schema";
8
+ import * as Effect from "effect/Effect";
9
9
  // src/core/ref-index-job.ts
10
10
  /**
11
11
  * `git.ref-index`, a repo's ref index rebuilt under the server's stamp (#668), as
@@ -157,7 +157,7 @@ const rebuildTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
157
157
  const rebuildFailed = (_data, failure) => Effect.flatMap(currentRepo, (repo) => Effect.logError(`git.ref-index left repo ${repo}'s ref index stale: ${failure.error instanceof Error ? failure.error.message : String(failure.error)}`));
158
158
  const RefIndexJob = /* @__PURE__ */ Job.make(refIndexJobName, {
159
159
  payload: RefIndexJobData,
160
- timeout: "5 minutes",
160
+ timeout: jobTryTimeout,
161
161
  retry: {
162
162
  limit: 10,
163
163
  delay: "1 second",