@ref0/git 0.14.0 → 0.20.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 (351) hide show
  1. package/dist/auth/access-jwt.mjs +2 -2
  2. package/dist/auth/authorize.mjs +3 -3
  3. package/dist/auth/fences.d.mts +1 -2
  4. package/dist/auth/fences.mjs +3 -3
  5. package/dist/auth/grants.mjs +4 -4
  6. package/dist/auth/host-function.mjs +18 -1
  7. package/dist/auth/identify.d.mts +1 -1
  8. package/dist/auth/identify.mjs +3 -3
  9. package/dist/auth/token-cleanup.mjs +67 -0
  10. package/dist/auth/token-rows.mjs +1 -1
  11. package/dist/auth/token-text.mjs +9 -1
  12. package/dist/auth/tokens-base.d.mts +35 -0
  13. package/dist/auth/tokens-base.mjs +13 -0
  14. package/dist/auth/tokens-layer.d.mts +2 -27
  15. package/dist/auth/tokens-layer.mjs +6 -11
  16. package/dist/auth/tokens-public.d.mts +3 -3
  17. package/dist/auth/tokens.d.mts +7 -10
  18. package/dist/auth/tokens.mjs +9 -80
  19. package/dist/client/answer.mjs +21 -42
  20. package/dist/client/client.d.mts +2 -4
  21. package/dist/client/git-http.mjs +17 -7
  22. package/dist/client/local.mjs +14 -13
  23. package/dist/client/push-upload.mjs +9 -8
  24. package/dist/client/remote.mjs +8 -10
  25. package/dist/client/run-remote-helper.d.mts +1 -0
  26. package/dist/client/run-remote-helper.mjs +58 -24
  27. package/dist/client/slice-push.d.mts +1 -1
  28. package/dist/client/transport.mjs +105 -46
  29. package/dist/contracts/blobs.d.mts +55 -8
  30. package/dist/contracts/blobs.mjs +16 -2
  31. package/dist/contracts/call-allowance.d.mts +13 -0
  32. package/dist/contracts/call-allowance.mjs +44 -0
  33. package/dist/contracts/calls-spent.mjs +8 -3
  34. package/dist/contracts/client.d.mts +15 -16
  35. package/dist/contracts/commits.d.mts +24 -24
  36. package/dist/contracts/engine.d.mts +6 -1
  37. package/dist/contracts/engine.mjs +10 -1
  38. package/dist/contracts/files.d.mts +10 -10
  39. package/dist/contracts/forks.d.mts +17 -17
  40. package/dist/contracts/git-events.d.mts +29 -1
  41. package/dist/contracts/git-hooks.d.mts +1 -1
  42. package/dist/contracts/git.d.mts +21 -0
  43. package/dist/contracts/grants.d.mts +24 -4
  44. package/dist/contracts/handlers.d.mts +1 -1
  45. package/dist/contracts/lfs.d.mts +28 -2
  46. package/dist/contracts/merges.d.mts +3 -2
  47. package/dist/contracts/objects.d.mts +23 -25
  48. package/dist/contracts/queue.d.mts +40 -12
  49. package/dist/contracts/queue.mjs +3 -4
  50. package/dist/contracts/refs.d.mts +26 -23
  51. package/dist/contracts/remote.d.mts +6 -7
  52. package/dist/contracts/remote.mjs +4 -1
  53. package/dist/contracts/repos.d.mts +29 -138
  54. package/dist/contracts/repos.mjs +5 -3
  55. package/dist/contracts/result.d.mts +35 -16
  56. package/dist/contracts/result.mjs +35 -7
  57. package/dist/contracts/server.d.mts +25 -50
  58. package/dist/contracts/services.d.mts +1 -1
  59. package/dist/contracts/store.d.mts +6 -5
  60. package/dist/contracts/sync.d.mts +11 -7
  61. package/dist/contracts/sync.mjs +12 -2
  62. package/dist/contracts/tags.d.mts +10 -10
  63. package/dist/contracts/time.d.mts +3 -0
  64. package/dist/contracts/{promises.mjs → time.mjs} +1 -1
  65. package/dist/contracts/tokens.d.mts +15 -17
  66. package/dist/contracts/tokens.mjs +3 -2
  67. package/dist/contracts/topics.d.mts +1 -1
  68. package/dist/contracts/trees.d.mts +12 -12
  69. package/dist/contracts/work.d.mts +24 -13
  70. package/dist/core/access.d.mts +1 -2
  71. package/dist/core/access.mjs +20 -9
  72. package/dist/core/ancestry.d.mts +1 -0
  73. package/dist/core/asked.mjs +1 -1
  74. package/dist/core/call-names.mjs +6 -1
  75. package/dist/core/call-services.mjs +11 -3
  76. package/dist/core/events/deliver.d.mts +1 -2
  77. package/dist/core/events/deliver.mjs +43 -36
  78. package/dist/core/events/retired.mjs +119 -0
  79. package/dist/core/forks.mjs +928 -432
  80. package/dist/core/hooks/groups.mjs +1 -1
  81. package/dist/core/imports.mjs +29 -23
  82. package/dist/core/index-job.mjs +122 -34
  83. package/dist/core/index-lost.d.mts +1 -2
  84. package/dist/core/index-lost.mjs +2 -2
  85. package/dist/core/loose-tally.mjs +1 -1
  86. package/dist/core/objects/blobs.mjs +129 -3
  87. package/dist/core/objects/lines.mjs +2 -2
  88. package/dist/core/objects/merges.mjs +4 -1
  89. package/dist/core/objects/objects-layer.d.mts +1 -1
  90. package/dist/core/objects/objects-layer.mjs +3 -3
  91. package/dist/core/objects/reading.mjs +24 -13
  92. package/dist/core/objects/tags.mjs +4 -1
  93. package/dist/core/objects/trees.mjs +2 -2
  94. package/dist/core/objects/writing.mjs +2 -2
  95. package/dist/core/own-writes.mjs +1 -1
  96. package/dist/core/parts.d.mts +4 -5
  97. package/dist/core/parts.mjs +3 -8
  98. package/dist/core/promise.mjs +9 -12
  99. package/dist/core/purge.mjs +287 -83
  100. package/dist/core/push-decide.mjs +2 -0
  101. package/dist/core/push-files.d.mts +1 -1
  102. package/dist/core/push.mjs +58 -47
  103. package/dist/core/receipts.mjs +8 -3
  104. package/dist/core/ref-index-job.mjs +4 -4
  105. package/dist/core/ref-view.mjs +2 -2
  106. package/dist/core/refs.mjs +5 -5
  107. package/dist/core/registered-rows.mjs +2 -2
  108. package/dist/core/repack.mjs +36 -21
  109. package/dist/core/repo-info.mjs +3 -3
  110. package/dist/core/repos.mjs +21 -9
  111. package/dist/core/rules/commit-changes.d.mts +0 -1
  112. package/dist/core/saved-caller-views.d.mts +7 -2
  113. package/dist/core/saved-caller-views.mjs +2 -2
  114. package/dist/core/saved-callers.d.mts +19 -2
  115. package/dist/core/seam.d.mts +16 -26
  116. package/dist/core/seam.mjs +7 -28
  117. package/dist/core/tokens.mjs +1 -1
  118. package/dist/core/view.mjs +7 -15
  119. package/dist/core/work.mjs +59 -14
  120. package/dist/effect.d.mts +3 -12
  121. package/dist/effect.mjs +1 -10
  122. package/dist/engine/failures.mjs +2 -1
  123. package/dist/engine/reads.mjs +4 -4
  124. package/dist/event-streams/stream.d.mts +2 -2
  125. package/dist/event-streams/stream.mjs +37 -14
  126. package/dist/extend.d.mts +2 -3
  127. package/dist/extend.mjs +2 -1
  128. package/dist/http/answers.mjs +8 -5
  129. package/dist/http/core-parts.mjs +95 -79
  130. package/dist/http/handler.mjs +34 -7
  131. package/dist/http/node.d.mts +14 -1
  132. package/dist/http/node.mjs +56 -27
  133. package/dist/http/parts.d.mts +1 -0
  134. package/dist/http/push-upload-job.mjs +30 -26
  135. package/dist/http/push-uploads.mjs +36 -21
  136. package/dist/http/upload-pack.mjs +3 -3
  137. package/dist/index.d.mts +14 -14
  138. package/dist/index.mjs +2 -2
  139. package/dist/lfs/answer.mjs +37 -0
  140. package/dist/lfs/base.d.mts +2 -0
  141. package/dist/lfs/base.mjs +25 -1
  142. package/dist/lfs/copy.d.mts +21 -7
  143. package/dist/lfs/copy.mjs +89 -6
  144. package/dist/lfs/layer.d.mts +15 -1
  145. package/dist/lfs/layer.mjs +24 -11
  146. package/dist/lfs/locks.mjs +2 -2
  147. package/dist/lfs/objects.d.mts +1 -0
  148. package/dist/lfs/objects.mjs +87 -17
  149. package/dist/lfs/pointers.mjs +2 -2
  150. package/dist/lfs/rows.mjs +42 -8
  151. package/dist/lfs/upkeep.mjs +48 -14
  152. package/dist/lfs/wire.mjs +6 -31
  153. package/dist/merges/merges.mjs +2 -2
  154. package/dist/node.d.mts +2 -2
  155. package/dist/protocol/bytes/buffers.mjs +13 -5
  156. package/dist/protocol/bytes/reader.mjs +6 -1
  157. package/dist/protocol/bytes/streams.mjs +27 -1
  158. package/dist/protocol/diff/read.d.mts +4 -3
  159. package/dist/protocol/diff/read.mjs +8 -3
  160. package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
  161. package/dist/protocol/objects/lfs-pointer.mjs +1 -3
  162. package/dist/protocol/objects/links-raw.mjs +24 -10
  163. package/dist/protocol/objects/tag.d.mts +1 -1
  164. package/dist/protocol/objects/tree.mjs +23 -6
  165. package/dist/protocol/packs/delta.d.mts +6 -3
  166. package/dist/protocol/packs/delta.mjs +96 -32
  167. package/dist/protocol/packs/idx.d.mts +2 -1
  168. package/dist/protocol/packs/idx.mjs +22 -3
  169. package/dist/protocol/packs/parts.d.mts +4 -1
  170. package/dist/protocol/packs/parts.mjs +10 -7
  171. package/dist/protocol/packs/reader.d.mts +5 -0
  172. package/dist/protocol/packs/reader.mjs +3 -2
  173. package/dist/protocol/packs/writer.mjs +26 -8
  174. package/dist/queue/advance.mjs +21 -24
  175. package/dist/queue/base.d.mts +55 -0
  176. package/dist/queue/base.mjs +44 -0
  177. package/dist/queue/calls.mjs +51 -54
  178. package/dist/queue/commit.mjs +1 -1
  179. package/dist/queue/host.d.mts +1 -15
  180. package/dist/queue/host.mjs +2 -7
  181. package/dist/queue/layer.d.mts +2 -1
  182. package/dist/queue/layer.mjs +10 -3
  183. package/dist/queue/limits.mjs +2 -0
  184. package/dist/queue/push-option.mjs +9 -24
  185. package/dist/queue/schedule.mjs +1 -1
  186. package/dist/queue/state.mjs +2 -10
  187. package/dist/queue/trim.mjs +5 -3
  188. package/dist/rest/blobs.mjs +29 -5
  189. package/dist/rest/caller.d.mts +4 -4271
  190. package/dist/rest/caller.mjs +4 -0
  191. package/dist/rest/client.d.mts +8 -5
  192. package/dist/rest/client.mjs +19 -2
  193. package/dist/rest/handlers.mjs +50 -5
  194. package/dist/rest/layer.d.mts +2 -2
  195. package/dist/rest/layer.mjs +5 -12
  196. package/dist/rest/me.d.mts +3 -432
  197. package/dist/server/check-fetch.mjs +3 -3
  198. package/dist/server/edge-node.d.mts +11 -8
  199. package/dist/server/edge-node.mjs +9 -6
  200. package/dist/server/edge.d.mts +21 -7
  201. package/dist/server/edge.mjs +32 -11
  202. package/dist/server/extension.mjs +1 -1
  203. package/dist/server/git-layer.d.mts +5 -5
  204. package/dist/server/git-layer.mjs +28 -22
  205. package/dist/server/git-namespace.d.mts +4 -3
  206. package/dist/server/git-namespace.mjs +3 -2
  207. package/dist/server/joined.d.mts +6 -18
  208. package/dist/server/joined.mjs +9 -36
  209. package/dist/server/lifecycle.mjs +18 -106
  210. package/dist/server/registry.mjs +24 -7
  211. package/dist/server/server.mjs +205 -346
  212. package/dist/signin/context.d.mts +1 -2
  213. package/dist/signin/layer.d.mts +1 -1
  214. package/dist/signin/layer.mjs +1 -1
  215. package/dist/storage/allotted.mjs +18 -3
  216. package/dist/storage/batch-upkeep.mjs +274 -0
  217. package/dist/storage/batches.d.mts +8 -0
  218. package/dist/storage/batches.mjs +344 -0
  219. package/dist/storage/calls.d.mts +1 -2
  220. package/dist/storage/calls.mjs +144 -158
  221. package/dist/storage/chunks.d.mts +9 -0
  222. package/dist/storage/chunks.mjs +297 -0
  223. package/dist/storage/clean-up.mjs +72 -9
  224. package/dist/storage/counted-bucket.mjs +4 -4
  225. package/dist/storage/fetch.d.mts +1 -0
  226. package/dist/storage/fetch.mjs +287 -210
  227. package/dist/storage/host-bucket.mjs +1 -2
  228. package/dist/storage/id-mix.mjs +19 -5
  229. package/dist/storage/index-bitmaps.mjs +9 -2
  230. package/dist/storage/index-build.d.mts +0 -1
  231. package/dist/storage/index-build.mjs +80 -23
  232. package/dist/storage/index-fetch.mjs +113 -72
  233. package/dist/storage/index-files.d.mts +3 -0
  234. package/dist/storage/index-files.mjs +10 -5
  235. package/dist/storage/index-graph.mjs +72 -22
  236. package/dist/storage/index-remap.mjs +200 -64
  237. package/dist/storage/index-whole.mjs +127 -0
  238. package/dist/storage/largest-files.mjs +1 -1
  239. package/dist/storage/layout.mjs +23 -0
  240. package/dist/storage/loose.d.mts +7 -4
  241. package/dist/storage/loose.mjs +212 -67
  242. package/dist/storage/memory-budget.mjs +16 -4
  243. package/dist/storage/merge-plan.mjs +3 -2
  244. package/dist/storage/merge-row.mjs +7 -1
  245. package/dist/storage/merge-stream.mjs +164 -25
  246. package/dist/storage/merge-walk.mjs +8 -4
  247. package/dist/storage/merge-write.mjs +1 -1
  248. package/dist/storage/merge.d.mts +1 -1
  249. package/dist/storage/merge.mjs +1 -1
  250. package/dist/storage/object-rows.d.mts +1 -0
  251. package/dist/storage/object-rows.mjs +385 -65
  252. package/dist/storage/oid-table.mjs +171 -0
  253. package/dist/storage/pack-order.mjs +8 -4
  254. package/dist/storage/pack-ranges.d.mts +1 -2
  255. package/dist/storage/pack-ranges.mjs +4 -5
  256. package/dist/storage/pack-reads.d.mts +2 -1
  257. package/dist/storage/pack-reads.mjs +158 -42
  258. package/dist/storage/pack-receive.d.mts +1 -1
  259. package/dist/storage/pack-receive.mjs +2 -2
  260. package/dist/storage/packs.d.mts +1 -1
  261. package/dist/storage/packs.mjs +136 -66
  262. package/dist/storage/placed-reads.mjs +1 -1
  263. package/dist/storage/plan-columns.d.mts +4 -0
  264. package/dist/storage/plan-columns.mjs +238 -0
  265. package/dist/storage/prune-keep.mjs +134 -41
  266. package/dist/storage/prune-walk.mjs +202 -62
  267. package/dist/storage/prune.mjs +194 -91
  268. package/dist/storage/push-allotment.mjs +91 -12
  269. package/dist/storage/push-uploads.mjs +4 -4
  270. package/dist/storage/pushed-commits.mjs +4 -2
  271. package/dist/storage/quarantine.d.mts +1 -1
  272. package/dist/storage/range-cache.mjs +125 -8
  273. package/dist/storage/ready.d.mts +1 -1
  274. package/dist/storage/ready.mjs +8 -6
  275. package/dist/storage/receive-bounds.mjs +23 -8
  276. package/dist/storage/repack-backlog.mjs +6 -3
  277. package/dist/storage/repack.d.mts +1 -1
  278. package/dist/storage/rows.d.mts +1 -1
  279. package/dist/storage/rows.mjs +1 -1
  280. package/dist/storage/runs.mjs +195 -43
  281. package/dist/storage/send-list.d.mts +1 -0
  282. package/dist/storage/send-list.mjs +54 -10
  283. package/dist/storage/single-flight.mjs +13 -7
  284. package/dist/storage/stream-whole.mjs +127 -26
  285. package/dist/storage/unpack.mjs +371 -79
  286. package/dist/storage/visible.mjs +2 -2
  287. package/dist/storage/walk.mjs +192 -38
  288. package/dist/storage/wants.mjs +5 -5
  289. package/dist/store/bodies.mjs +38 -0
  290. package/dist/store/call-count.d.mts +8 -12
  291. package/dist/store/call-count.mjs +34 -46
  292. package/dist/store/catalogue.d.mts +2 -2
  293. package/dist/store/catalogue.mjs +145 -35
  294. package/dist/store/crossing.mjs +1 -3
  295. package/dist/store/cursor-seal.d.mts +1 -2
  296. package/dist/store/cursor-seal.mjs +16 -6
  297. package/dist/store/door.mjs +183 -0
  298. package/dist/store/errors.d.mts +3 -4
  299. package/dist/store/errors.mjs +15 -33
  300. package/dist/store/git-store.mjs +25 -7
  301. package/dist/store/job-try.mjs +9 -32
  302. package/dist/store/list-job.mjs +44 -8
  303. package/dist/store/records.d.mts +3 -0
  304. package/dist/store/records.mjs +3 -0
  305. package/dist/store/repo-record.d.mts +1 -2
  306. package/dist/store/repo-record.mjs +32 -20
  307. package/dist/store/reservations.mjs +1 -1
  308. package/dist/store/scopes.mjs +11 -0
  309. package/dist/store/settle.mjs +4 -4
  310. package/dist/sync/github.mjs +3 -3
  311. package/dist/sync/import.mjs +31 -18
  312. package/dist/sync/lfs-batch.mjs +4 -5
  313. package/dist/sync/lfs-copy.mjs +17 -6
  314. package/dist/sync/mirror.mjs +34 -31
  315. package/dist/sync/said.mjs +16 -37
  316. package/dist/sync/step.mjs +33 -25
  317. package/dist/sync/tries.mjs +9 -9
  318. package/dist/topics/advance.mjs +10 -11
  319. package/dist/topics/base.d.mts +15 -0
  320. package/dist/topics/base.mjs +8 -0
  321. package/dist/topics/host.mjs +1 -1
  322. package/dist/topics/layer.d.mts +4 -9
  323. package/dist/topics/layer.mjs +2 -3
  324. package/dist/topics/members.mjs +4 -4
  325. package/dist/topics/public.d.mts +2 -1
  326. package/dist/topics/topic.mjs +2 -2
  327. package/package.json +5 -4
  328. package/dist/contracts/promises.d.mts +0 -39
  329. package/dist/core/call-names.d.mts +0 -3
  330. package/dist/core/clock.mjs +0 -18
  331. package/dist/lfs/calls.mjs +0 -26
  332. package/dist/rest/api.d.mts +0 -23
  333. package/dist/rest/blobs.d.mts +0 -833
  334. package/dist/rest/commits.d.mts +0 -3543
  335. package/dist/rest/errors.d.mts +0 -2124
  336. package/dist/rest/events.d.mts +0 -426
  337. package/dist/rest/files.d.mts +0 -1342
  338. package/dist/rest/forks.d.mts +0 -2160
  339. package/dist/rest/handlers.d.mts +0 -8
  340. package/dist/rest/merges.d.mts +0 -477
  341. package/dist/rest/queue.d.mts +0 -5917
  342. package/dist/rest/refs.d.mts +0 -2988
  343. package/dist/rest/repos.d.mts +0 -2567
  344. package/dist/rest/tags.d.mts +0 -1316
  345. package/dist/rest/tokens.d.mts +0 -2614
  346. package/dist/rest/topics.d.mts +0 -2224
  347. package/dist/rest/trees.d.mts +0 -1709
  348. package/dist/rest/work.d.mts +0 -1695
  349. package/dist/server/lifecycle.d.mts +0 -2
  350. package/dist/store/promises.d.mts +0 -11
  351. package/dist/store/promises.mjs +0 -327
@@ -1,6 +1,6 @@
1
1
  import { fail, gitError } from "../contracts/result.mjs";
2
2
  import { openTreeBytes } from "../storage/budget.mjs";
3
- import { objectsFace, scopedReceive, walkObjects } from "../storage/calls.mjs";
3
+ import { scopedReceive, walkObjects } from "../storage/calls.mjs";
4
4
  import { isUnindexedRead } from "../storage/index-visible.mjs";
5
5
  import { openTreesRefusal } from "../storage/push-allotment.mjs";
6
6
  import { isLoose } from "../storage/loose.mjs";
@@ -8,17 +8,21 @@ import { listedIds } from "../storage/listed-ids.mjs";
8
8
  import { indexRowKey, isPackId, objectCollections } from "../storage/layout.mjs";
9
9
  import { noLfsPointers } from "../storage/lfs-pointers.mjs";
10
10
  import { isShallowRoot } from "../storage/links.mjs";
11
- import { isAwaitingRepack } from "../storage/repack-backlog.mjs";
11
+ import { isAwaitingUpkeep } from "../storage/repack-backlog.mjs";
12
12
  import { allottedRows } from "../storage/allotted.mjs";
13
- import { gitObjectOf, noRows, objectOfRow, receivedRows } from "../storage/object-rows.mjs";
13
+ import { chunkedOf } from "../storage/chunks.mjs";
14
+ import { gitObjectOf, headerOfRow, noRows, receivedObject, receivedRows } from "../storage/object-rows.mjs";
14
15
  import { pruneClearedKey } from "../storage/prune.mjs";
15
16
  import { abandonOwn } from "../storage/quarantine.mjs";
16
17
  import { readyBytesOf, readyKey } from "../storage/ready.mjs";
17
- import { QuarantineRow, decodeHeld } from "../storage/rows.mjs";
18
- import { bestEffort, decodeRow, fromInfra, storeCall } from "../store/errors.mjs";
18
+ import { QuarantineRow } from "../storage/rows.mjs";
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";
19
22
  import { callScope } from "../store/call-count.mjs";
20
23
  import { decodePacks, gitStore } from "../store/git-store.mjs";
21
24
  import { WholeRepo, refBytesOf, storesPeel, wholeRefs } from "../store/ref-rows.mjs";
25
+ import { dropBody } from "../protocol/bytes/reader.mjs";
22
26
  import { gitsOwnMove, hiddenUnder } from "../protocol/wire/lines.mjs";
23
27
  import { sliceOf } from "../protocol/wire/push-limits.mjs";
24
28
  import { pushCounts } from "./events/seen.mjs";
@@ -27,7 +31,7 @@ import { appendEvents, decodeOutbox, firstSeq, outboxReads, repoEnvelope } from
27
31
  import { rowsAtCommit } from "./loose-tally.mjs";
28
32
  import { MirrorRow, mirrorJobKey } from "./mirror-rows.mjs";
29
33
  import { PrunedMark, mirrorJobName } from "../store/records.mjs";
30
- import { HeldBy, decodeStats, heldUntil, looseRows, readRecord, repoStats, rootsMoved, rootsOf, timeRow } from "../store/repo-record.mjs";
34
+ import { HeldBy, decodeStats, heldUntil, looseRows, movedRoots, readRecord, repoStats, rootsMoved, rootsOf, timeRow } from "../store/repo-record.mjs";
31
35
  import { advanceRow } from "../store/queue-jobs.mjs";
32
36
  import { liveReservations, reservedTarget } from "../store/reservations.mjs";
33
37
  import { settleName } from "../store/settle.mjs";
@@ -54,7 +58,7 @@ import { defaultPushFiles, filesChecked } from "./push-files.mjs";
54
58
  import { addedBytes, defaultPushRepo, repoChecked } from "./push-repo.mjs";
55
59
  import { Authorize, check } from "../contracts/authorize.mjs";
56
60
  import { read } from "./objects/objects.mjs";
57
- import * as Clock$1 from "effect/Clock";
61
+ import * as Clock from "effect/Clock";
58
62
  import * as Effect from "effect/Effect";
59
63
  import * as Exit from "effect/Exit";
60
64
  import * as Result from "effect/Result";
@@ -294,7 +298,7 @@ const pushedOf = (objects, listed, received) => {
294
298
  };
295
299
  return (input) => {
296
300
  const row = rows.get(input.oid);
297
- if (row !== void 0) return Effect.map(objectOfRow(row), gitObjectOf);
301
+ if (row !== void 0) return Effect.map(receivedObject(received.change, row), gitObjectOf);
298
302
  return own.packs.length === 0 ? Effect.succeed(void 0) : objects.read(own, {
299
303
  ...input,
300
304
  listedOnly: true
@@ -305,7 +309,7 @@ const pushedOf = (objects, listed, received) => {
305
309
  * Whether the push brings commit `oid`, for the file rules' walk: its own object, read as `pushed`
306
310
  * reads one, its bytes let go unread. A read that fails throws, so the walk trusts nothing.
307
311
  */
308
- const broughtCommit = (pushed) => (oid) => Effect.flatMap(pushed({ oid }), (object) => Effect.as(Effect.promise(() => object?.bytes.cancel().catch(() => void 0) ?? Promise.resolve()), object?.type === "commit"));
312
+ const broughtCommit = (pushed) => (oid) => Effect.flatMap(pushed({ oid }), (object) => Effect.as(dropBody(object?.bytes), object?.type === "commit"));
309
313
  /** The refs the repo mirrors, among `rows` of `mirrors`: each one an active mirror names, with its destination. */
310
314
  const activeMirrors = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
311
315
  const active = /* @__PURE__ */ new Map();
@@ -342,17 +346,21 @@ const withReceived = (listed, received) => received === void 0 ? listed : {
342
346
  };
343
347
  /** The objects, with the rows a receive puts read first: they're written only by the commit. */
344
348
  const withReceivedRows = (objects, received) => {
345
- const rows = receivedRows(received?.change);
349
+ const change = received?.change;
350
+ const rows = receivedRows(change);
346
351
  if (rows.size === 0) return objects;
347
- const rowsOf = (oids, each) => Effect.forEach(oids, (oid) => {
352
+ const rowsOf = (before) => (oids, each) => Effect.forEach(oids, Effect.fnUntraced(function* (oid) {
348
353
  const row = rows.get(oid);
349
- return row === void 0 ? Effect.void : Effect.flatMap(objectOfRow(row), each);
350
- }, { discard: true });
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 });
351
359
  return {
352
360
  ...objects,
353
361
  read: (listed, input) => {
354
362
  const row = rows.get(input.oid);
355
- return row === void 0 ? objects.read(listed, input) : Effect.map(objectOfRow(row), gitObjectOf);
363
+ return row === void 0 ? objects.read(listed, input) : Effect.map(receivedObject(change, row), gitObjectOf);
356
364
  },
357
365
  headers: Effect.fnUntraced(function* (listed, input) {
358
366
  const answer = /* @__PURE__ */ new Map();
@@ -360,11 +368,7 @@ const withReceivedRows = (objects, received) => {
360
368
  for (const oid of input.oids) {
361
369
  const row = rows.get(oid);
362
370
  if (row === void 0) continue;
363
- const object = yield* objectOfRow(row);
364
- answer.set(oid, {
365
- type: object.type,
366
- size: object.bytes.byteLength
367
- });
371
+ answer.set(oid, yield* headerOfRow(row));
368
372
  }
369
373
  if (stored.length > 0) for (const [oid, header] of yield* objects.headers(listed, {
370
374
  ...input,
@@ -439,6 +443,7 @@ const buildFence = (build) => [
439
443
  */
440
444
  const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fence, received, kept, mark, branches, touched, guard, unchanged = []) {
441
445
  const own = received?.quarantine === void 0 ? [] : [received.quarantine];
446
+ const batched = isStagedReceive(received) ? [batchesRead] : [];
442
447
  const keyed = receiptReads(kept);
443
448
  const targets = branches.map((id) => ({
444
449
  collection: collections.queueReservations,
@@ -469,6 +474,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
469
474
  collection,
470
475
  id
471
476
  })),
477
+ ...batched,
472
478
  ...touched.map((id) => ({
473
479
  collection: collections.mirrors,
474
480
  id
@@ -492,14 +498,16 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
492
498
  const guardedAt = guardAt + (guard?.reads.length ?? 0);
493
499
  if (guard !== void 0) yield* guard.check(rest.slice(guardAt, guardedAt));
494
500
  const now = rest.slice(guardedAt, guardedAt + unchanged.length);
495
- const mirrorRows = rest.slice(guardedAt + unchanged.length).flat();
501
+ const batchedAt = guardedAt + unchanged.length;
502
+ const batchRows = batched.length === 0 ? void 0 : rest[batchedAt] ?? [];
503
+ const mirrorRows = rest.slice(batchedAt + batched.length).flat();
496
504
  const changed = unchanged.some((row, at) => !Equal.equals(row.value, now[at]?.[0]?.value));
497
505
  const packs = yield* decodePacks(packRows);
498
506
  const times = yield* decodeStats(timeRows);
499
507
  const [ownRow] = own.length === 0 ? [] : rest[0] ?? [];
500
508
  const refs = yield* wholeRefs(pushWhole, refRows);
501
509
  const outbox = yield* decodeOutbox([headRows, cursorRows]);
502
- const held = ownRow === void 0 ? void 0 : yield* decodeHeld(QuarantineRow, ownRow);
510
+ const held = ownRow === void 0 ? void 0 : yield* decodeRow(QuarantineRow, ownRow, `The push's quarantine row '${ownRow.id}'`);
503
511
  const mirrored = yield* activeMirrors(mirrorRows);
504
512
  const revoked = yield* Effect.match(fence.check(fenced), {
505
513
  onFailure: (error) => error,
@@ -518,7 +526,8 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
518
526
  version: snapshot.version,
519
527
  packs
520
528
  };
521
- if (held !== void 0) read.quarantine = held.value.state;
529
+ if (held !== void 0) read.quarantine = held.state;
530
+ if (batchRows !== void 0) read.batches = batchRows.length;
522
531
  if (revoked !== void 0) read.revoked = revoked;
523
532
  if (cruftRows.length <= 64) read.packs = {
524
533
  listed: new Set(packs.map(({ id }) => id)),
@@ -870,17 +879,14 @@ const movedKinds = (updates, moved) => {
870
879
  kind: kinds.get(move.ref) ?? "force"
871
880
  }));
872
881
  };
873
- /**
874
- * The pack a push's own receive put under its `quarantine` row: none for a push with no pack, one
875
- * of rows alone, or a caller's `received`, which stays its caller's to end.
876
- */
877
- const ownPack = (request, received) => {
882
+ function ownPack(request, received, staged) {
878
883
  const id = received?.quarantine?.id;
879
884
  if (request.pack === void 0 || !("bytes" in request.pack) || id === void 0) return void 0;
880
- return isPackId(id) ? id : void 0;
881
- };
882
- /** Whether a commit lists `pack`: its change deletes the pack's own `quarantine` row. */
883
- const lists = (body, pack) => body.delete.some((key) => key.collection === objectCollections.quarantine && key.id === pack);
885
+ if (staged === true) return stagedBatchOf(received);
886
+ return received?.quarantine?.collection === objectCollections.quarantine && isPackId(id) ? id : void 0;
887
+ }
888
+ /** Whether a commit lists `pack` or publishes a batch: its change deletes its quarantine row. */
889
+ const lists = (body, own) => body.delete.some((key) => key.collection === own.collection && key.id === own.id);
884
890
  /**
885
891
  * The push decide's loop past its first read, onto `listed`, keeping its answer under `key`:
886
892
  * the pack received into its quarantine; each edit's kind from the objects; then a read of the
@@ -902,33 +908,36 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
902
908
  const { received, rooted } = yield* receive(yield* read({
903
909
  view,
904
910
  at: seen
905
- }), listed, request).pipe(Effect.provideService(HeldBy, heldUntil(heldAt, fetchLimits)), Effect.tapError((error) => isAwaitingRepack(error) ? bestEffort(ensureRepack(core, core.jobs, listed.repo, fetchLimits)) : Effect.void), Effect.mapError(asPushCheck));
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));
906
912
  const ownedPack = ownPack(request, received);
907
913
  let listing = false;
908
- if (ownedPack !== void 0) yield* Effect.addFinalizer((exit) => listing || Exit.hasInterrupts(exit) ? Effect.void : Effect.flatMap(Clock$1.currentTimeMillis, (at) => abandonOwn({
914
+ if (ownedPack !== void 0) yield* Effect.addFinalizer((exit) => listing || Exit.hasInterrupts(exit) ? Effect.void : Effect.flatMap(Clock.currentTimeMillis, (at) => abandonOwn({
909
915
  store: gitStore(store),
910
916
  repo: listed.repo,
911
917
  pack: ownedPack,
912
918
  at,
913
919
  repackJobRow: core.repackJobRow
914
920
  })));
921
+ const ownedBatch = ownPack(request, received, true);
922
+ if (ownedBatch !== void 0) yield* Effect.addFinalizer((exit) => listing || Exit.hasInterrupts(exit) ? Effect.void : abandonBatch(gitStore(store), listed.repo, ownedBatch));
915
923
  const viewed = received === void 0 ? seen : {
916
924
  ...seen,
917
925
  pushed: received
918
926
  };
919
- const objects = yield* walkObjects(objectsFace(yield* read({
927
+ const objects = yield* walkObjects(yield* read({
920
928
  view,
921
929
  at: viewed
922
- })), received?.allotment);
930
+ }), received?.allotment);
923
931
  const pushedObjects = withReceivedRows(objects, received);
924
932
  const pushedListed = withReceived(listed, received);
925
933
  const pushed = pushedOf(objects, listed, received);
934
+ const walked = request.roots === void 0 ? roots : movedRoots(roots, request.roots);
926
935
  const kindsInput = {
927
936
  objects: pushedObjects,
928
937
  listed: pushedListed,
929
938
  pushed,
930
939
  edits: request.edits,
931
- roots,
940
+ roots: walked,
932
941
  ...call
933
942
  };
934
943
  if (rooted !== void 0) kindsInput.missing = rooted;
@@ -954,7 +963,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
954
963
  for (const [ref, error] of unseen) refused.set(ref, error);
955
964
  const { access } = core;
956
965
  const barred = access?.patterns.some((pattern) => refViews.some((refView) => !publishable(refView, pattern))) === true;
957
- const whole = objectsFace(SealedObjects.whole(sealed, pushWhole));
966
+ const whole = SealedObjects.whole(sealed, pushWhole);
958
967
  const wholePushed = access === void 0 || !barred && request.publishes === void 0 ? void 0 : withReceivedRows(yield* walkObjects(whole, received?.allotment), received);
959
968
  const refView = refViews[0] ?? (yield* view.refView);
960
969
  const publishedRefs = (refs) => new Map([...refs].filter(([ref]) => hiddenUnder(hidden, ref) === void 0));
@@ -964,7 +973,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
964
973
  const here = oids.filter((oid) => made.has(oid));
965
974
  const stored = oids.filter((oid) => !made.has(oid));
966
975
  if (stored.length === 0) return Effect.succeed(new Set(here));
967
- return Effect.map(Effect.flatMap(Clock$1.currentTimeMillis, (now) => ownWritesOf(core.store, listed.repo, writer, stored, now)), (kept) => /* @__PURE__ */ new Set([...here, ...kept]));
976
+ return Effect.map(Effect.flatMap(Clock.currentTimeMillis, (now) => ownWritesOf(core.store, listed.repo, writer, stored, now)), (kept) => /* @__PURE__ */ new Set([...here, ...kept]));
968
977
  };
969
978
  const unpublishedAt = (refs, at, index, judging, edits, own) => access === void 0 || wholePushed === void 0 ? Effect.succeed(/* @__PURE__ */ new Map()) : unpublished({
970
979
  access,
@@ -1028,7 +1037,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
1028
1037
  };
1029
1038
  const fence = fenceAll(request, decidingFor(request).map((one) => core.fences(one, target)));
1030
1039
  const ready = objects.readyShallow && request.edits.some((edit) => edit.ref === defaultBranch || edit.ref.startsWith("refs/tags/"));
1031
- const jobs = (received?.change.add?.length ?? 0) > 0 || ready ? [core.repackJobRow()] : [];
1040
+ const jobs = (received?.change.add?.length ?? 0) > 0 || isStagedReceive(received) || ready ? [core.repackJobRow()] : [];
1032
1041
  const own = updates.filter((update) => gitsOwnMove(hidden, request.as, update.ref));
1033
1042
  const outside = updates.filter((update) => !gitsOwnMove(hidden, request.as, update.ref));
1034
1043
  const checks = outside.length === 0 ? void 0 : yield* checksOf(core);
@@ -1078,7 +1087,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
1078
1087
  if (request.request !== void 0) base.request = request.request;
1079
1088
  let checked;
1080
1089
  for (let tries = 0; tries < 10; tries += 1) {
1081
- const at = yield* Clock$1.currentTimeMillis;
1090
+ const at = yield* Clock.currentTimeMillis;
1082
1091
  const decide = yield* finalRead(store, target, fence, received, key, mark, branches, touched, request.guard, request.writes?.unchanged);
1083
1092
  const { read, receipt, outbox, record, mirrored, facts, stats, times, queued, reserved, indexRow } = decide;
1084
1093
  const indexed = SealedObjects.whole(sealed, pushWhole).index?.status(indexRow, at, listedIds(decide.at, received?.change));
@@ -1142,8 +1151,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
1142
1151
  ...unseen
1143
1152
  ])
1144
1153
  };
1145
- const fetchedRoots = request.fetched?.roots;
1146
- const rooted = fetchedRoots === void 0 ? void 0 : yield* rootsMoved(decide.roots, fetchedRoots, indexJobs(core, indexed));
1154
+ const rooted = request.roots === void 0 ? void 0 : yield* rootsMoved(decide.roots, request.roots, indexJobs(core, indexed));
1147
1155
  const chosen = withRoots(decidePush({
1148
1156
  read,
1149
1157
  command: decided,
@@ -1152,6 +1160,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
1152
1160
  const clears = read.marked === true && clearsMark(chosen);
1153
1161
  const decision = clears ? clearedAt(chosen, at) : chosen;
1154
1162
  const upkept = clears && jobs.length === 0 ? [core.repackJobRow()] : jobs;
1163
+ if (decision.kind === "answer" && decision.answer.kind === "error" && isAwaitingUpkeep(decision.answer.error)) yield* bestEffort(ensureRepack(core, core.jobs, listed.repo, fetchLimits));
1155
1164
  const planned = yield* planOf(decision, read.version, upkept);
1156
1165
  const { change } = planned;
1157
1166
  const refusal = writes === void 0 && !checking ? void 0 : refusalOf(planned.answer);
@@ -1160,7 +1169,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
1160
1169
  const liftedOnMoves = [...checked?.bypassed ?? none].filter(([ref]) => movedRefs.has(ref));
1161
1170
  const answer = yield* answers.answer(planned.answer, forced, new Map(liftedOnMoves), [...warned, ...sized.warned]);
1162
1171
  if (checking) return answer;
1163
- const also = planned.answer.updates.some((update) => update.kind === "rejected") || request.also === void 0 ? void 0 : request.also(yield* Clock$1.currentTimeMillis, received);
1172
+ const also = planned.answer.updates.some((update) => update.kind === "rejected") || request.also === void 0 ? void 0 : request.also(yield* Clock.currentTimeMillis, received);
1164
1173
  const alsoWrites = (also?.put.length ?? 0) + (also?.delete?.length ?? 0);
1165
1174
  const quiet = key === void 0 && alsoWrites === 0 && writes === void 0;
1166
1175
  if (!planned.moves && quiet) return answer;
@@ -1247,8 +1256,10 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
1247
1256
  try: () => checkWrites(body),
1248
1257
  catch: (cause) => fromInfra(cause)
1249
1258
  }).pipe(Effect.mapError(commitTooLarge(received, body)));
1250
- if ((yield* storeCall(() => store.commit(scope, body)).pipe(Effect.mapError(commitTooLarge(received, body)))).ok) {
1251
- listing = ownedPack !== void 0 && lists(body, ownedPack);
1259
+ if ((yield* storeCommit(store.commit(scope, body)).pipe(Effect.mapError(commitTooLarge(received, body)))).ok) {
1260
+ const own = received?.quarantine;
1261
+ listing = own !== void 0 && lists(body, own);
1262
+ if (listing && ownedBatch !== void 0) yield* promoteOwn(gitStore(store), listed.repo, ownedBatch, 4);
1252
1263
  return final;
1253
1264
  }
1254
1265
  }
@@ -1272,7 +1283,7 @@ const pushWith = (request, answers, key) => pushThrough(request, answers, key, f
1272
1283
  /** `pushWith`, or with `checking`, its checks alone, as `pushOnto` says. */
1273
1284
  const pushThrough = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, key, checking) {
1274
1285
  const operation = operationOf(request);
1275
- const heldAt = yield* Clock$1.currentTimeMillis;
1286
+ const heldAt = yield* Clock.currentTimeMillis;
1276
1287
  const resolved = yield* firstRead(request.caller, operation, request.internalId).pipe(Effect.tapError((error) => retriedCodes.has(error.code) ? Effect.void : refuseQueued(request, [error], "access")));
1277
1288
  const opened = yield* listedFor(request, operation, resolved, heldAt);
1278
1289
  return yield* pushOnto(request, opened, key, answers, checking);
@@ -1319,7 +1330,7 @@ const pushFetched = (request) => pushWith(request, {
1319
1330
  */
1320
1331
  const keyedPushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, keyed) {
1321
1332
  const operation = operationOf(request);
1322
- const heldAt = yield* Clock$1.currentTimeMillis;
1333
+ const heldAt = yield* Clock.currentTimeMillis;
1323
1334
  const resolved = yield* keyedRead(request.caller, operation, keyed.missed, request.internalId);
1324
1335
  if (resolved === void 0) return void 0;
1325
1336
  const opened = yield* listedFor(request, operation, resolved, heldAt);
@@ -68,12 +68,15 @@ const KeptAnswer = /* @__PURE__ */ Schema.Union([
68
68
  /**
69
69
  * A keyed write's receipt, in the scope it wrote, saved in the write's own commit: the input its
70
70
  * key came with, when, and what it answered. A work write's receipt is `pending`, with no
71
- * answer, from when it takes the key until the queue answered (Q150). Errors are never kept.
71
+ * answer, from when it takes the key until the queue answered (Q150), and `failed` holds the claim
72
+ * its job had failed under then, when it had: the write sent again calls the queue only while that
73
+ * failure stands. Errors are never kept.
72
74
  */
73
75
  const ReceiptRow = /* @__PURE__ */ Schema.Struct({
74
76
  input: Schema.String,
75
77
  at: Schema.Int,
76
78
  pending: Schema.optionalKey(Schema.Literal(true)),
79
+ failed: Schema.optionalKey(Schema.Int),
77
80
  answer: Schema.optionalKey(KeptAnswer)
78
81
  });
79
82
  /** A row's day, padded so a collection keyed by it reads the oldest first. */
@@ -140,8 +143,10 @@ const receiptRow = (kept, answer) => {
140
143
  input: kept.input,
141
144
  at: kept.at
142
145
  };
143
- if (answer === "pending") value.pending = true;
144
- else value.answer = answer;
146
+ if (answer.kind === "pending") {
147
+ value.pending = true;
148
+ if (answer.failed !== void 0) value.failed = answer.failed;
149
+ } else value.answer = answer;
145
150
  return {
146
151
  ...receiptKey(kept),
147
152
  value
@@ -1,5 +1,5 @@
1
- import { storeCall } from "../store/errors.mjs";
2
- import { currentRepo, gitJob, repoTry } from "../store/job-try.mjs";
1
+ import { storeCommit } from "../store/errors.mjs";
2
+ import { currentRepo, gitJob } 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";
@@ -145,7 +145,7 @@ const rebuildTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
145
145
  if (!sameStep(step, planned)) return again;
146
146
  const write = writeOf(index, record, step, snapshot.results.slice(1), rows);
147
147
  if (write === void 0) return void 0;
148
- yield* storeCall(() => store.commit(repoScope(internalId), {
148
+ yield* storeCommit(store.commit(repoScope(internalId), {
149
149
  id: newChangeId(),
150
150
  expect: snapshot.version,
151
151
  put: write.put,
@@ -167,7 +167,7 @@ const RefIndexJob = /* @__PURE__ */ Job.make(refIndexJobName, {
167
167
  rebuild: () => ({})
168
168
  });
169
169
  /** `git.ref-index`, over the server's ref index: each try one step of its rebuild, whose `more` starts its tries again. */
170
- const refIndexJob = (parts) => gitJob(RefIndexJob, () => repoTry((store, repo) => rebuildTry(parts, store, repo)), { onFailure: rebuildFailed });
170
+ const refIndexJob = (parts) => gitJob(RefIndexJob, () => Effect.flatMap(currentRepo, (repo) => rebuildTry(parts, parts.store, repo)), { onFailure: rebuildFailed });
171
171
  /** The repo's `git.ref-index` row, due now. */
172
172
  const refIndexJobRow = (job) => job.job({
173
173
  key: refIndexJobKey,
@@ -4,7 +4,7 @@ import { withRequestHold } from "../store/call-count.mjs";
4
4
  import { CoreParts } from "./parts.mjs";
5
5
  import { ownedAway } from "../protocol/wire/lines.mjs";
6
6
  import { Authorize, audience, check, grantOf } from "../contracts/authorize.mjs";
7
- import * as Clock$1 from "effect/Clock";
7
+ import * as Clock from "effect/Clock";
8
8
  import * as Effect from "effect/Effect";
9
9
  import * as Option from "effect/Option";
10
10
  import { byBytes } from "@ref0/infra";
@@ -182,7 +182,7 @@ const accessAgain = /* @__PURE__ */ Effect.fnUntraced(function* (caller, kind, r
182
182
  });
183
183
  if (caller.token !== void 0) {
184
184
  const held = yield* readToken(core.store, caller.token.id);
185
- const now = yield* Clock$1.currentTimeMillis;
185
+ const now = yield* Clock.currentTimeMillis;
186
186
  if (!(held !== void 0 && tokenState(held.row, now) === "active")) return yield* fail("UNAUTHENTICATED", "The token is revoked or past its expiry");
187
187
  }
188
188
  });
@@ -24,7 +24,7 @@ import { fail } from "../contracts/result.mjs";
24
24
  import { CoreParts, ObjectsParts } from "./parts.mjs";
25
25
  import { bypassKinds, hostAuthorize } from "../auth/authorize.mjs";
26
26
  import { Authorize, check } from "../contracts/authorize.mjs";
27
- import * as Clock$1 from "effect/Clock";
27
+ import * as Clock from "effect/Clock";
28
28
  import * as Effect from "effect/Effect";
29
29
  import { byBytes, jsonBytes, limits } from "@ref0/infra";
30
30
  const maxRefLimit = 1e3;
@@ -289,7 +289,7 @@ const refCalls = (bound) => {
289
289
  const { fetchLimits } = yield* ObjectsParts;
290
290
  if (!(yield* heldAdd(heldStore(core.store), internalId, fetchLimits, { jobs }).pipe(Effect.as(true), Effect.catchTag("RepoGone", () => Effect.succeed(false))))) return;
291
291
  const scope = repoScope(internalId);
292
- for (const { name, key } of jobs) yield* storeCall(() => core.jobs.retry(scope, {
292
+ for (const { name, key } of jobs) yield* storeCall(core.jobs.retry(scope, {
293
293
  name,
294
294
  key
295
295
  })).pipe(Effect.catchIf(notFailed, () => Effect.void));
@@ -419,7 +419,7 @@ const refCalls = (bound) => {
419
419
  }]];
420
420
  }));
421
421
  if (reads.length > refListRangesMost) return yield* tooManyRanges(reads.length, prefix);
422
- const { results } = yield* storeCall(() => core.store.read(scope, reads));
422
+ const { results } = yield* storeCall(core.store.read(scope, reads));
423
423
  const rows = [];
424
424
  let at = 0;
425
425
  let next;
@@ -498,7 +498,7 @@ const refCalls = (bound) => {
498
498
  "refs.update",
499
499
  edits,
500
500
  atomic
501
- ], yield* Clock$1.currentTimeMillis);
501
+ ], yield* Clock.currentTimeMillis);
502
502
  const keyed = yield* keyedRecord(core.store, repo, kept, (access) => Effect.andThen(check({
503
503
  caller,
504
504
  operation: {
@@ -561,7 +561,7 @@ const refCalls = (bound) => {
561
561
  collection: run.collection,
562
562
  id
563
563
  }));
564
- const snapshot = yield* storeCall(() => core.store.read(scope, reads, counts));
564
+ const snapshot = yield* storeCall(core.store.read(scope, reads, counts));
565
565
  return { count: snapshot.counts.reduce((total, each, at) => total + each * (signs[at] ?? 0), 0) + points.reduce((total, { sign }, at) => total + ((snapshot.results[at]?.length ?? 0) > 0 ? sign : 0), 0) };
566
566
  }),
567
567
  update
@@ -1,6 +1,6 @@
1
1
  import { fail } from "../contracts/result.mjs";
2
2
  import { asAsked, readAsked } from "./asked.mjs";
3
- import { storeCall } from "../store/errors.mjs";
3
+ import { storeCommit } from "../store/errors.mjs";
4
4
  import { heldAdd, heldStore, readRecord } from "../store/repo-record.mjs";
5
5
  import { newChangeId, repoScope } from "../store/scopes.mjs";
6
6
  import * as Effect from "effect/Effect";
@@ -39,7 +39,7 @@ const registeredRows = (name, base) => {
39
39
  };
40
40
  })),
41
41
  source: (repo) => within([], (bound) => Effect.map(readRecord(bound.store, repo), ({ record }) => record?.fork?.upstreamInternalId)),
42
- commit: (repo, at, writes) => within([...writes.put ?? [], ...writes.delete ?? []], (bound) => storeCall(() => bound.store.commit(repoScope(repo), {
42
+ commit: (repo, at, writes) => within([...writes.put ?? [], ...writes.delete ?? []], (bound) => storeCommit(bound.store.commit(repoScope(repo), {
43
43
  id: newChangeId(),
44
44
  expect: at,
45
45
  put: [...writes.put ?? []],
@@ -1,9 +1,9 @@
1
1
  import { keepsEvents } from "../contracts/events.mjs";
2
2
  import { fail } from "../contracts/result.mjs";
3
- import { bestEffort, decodeRow, resultCall, storeCall, thrownError } from "../store/errors.mjs";
3
+ import { bestEffort, decodeRow, storeCall, storeCommit, thrownError } from "../store/errors.mjs";
4
4
  import { untilAborted } from "../store/crossing.mjs";
5
5
  import { gitJob } from "../store/job-try.mjs";
6
- import { decodePacks, featureChange, gitStore, packRow } from "../store/git-store.mjs";
6
+ import { decodePacks, featureChange, packRow, tryGitStore } from "../store/git-store.mjs";
7
7
  import { appendEvents, decodeOutbox, outboxReads, repoEnvelope } from "../store/outbox.mjs";
8
8
  import { decodeStats, heldAdd, heldStore, looseRows, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
9
9
  import { settleName } from "../store/settle.mjs";
@@ -12,6 +12,7 @@ import { indexRowKey, isPackId, objectCollections } from "../storage/layout.mjs"
12
12
  import { listedIds } from "../storage/listed-ids.mjs";
13
13
  import { noRows } from "../storage/object-rows.mjs";
14
14
  import { ReadyRow, readyBytesOf } from "../storage/ready.mjs";
15
+ import { prunePassKey } from "../storage/prune.mjs";
15
16
  import { ApartRow, apartAfter, apartKey } from "../storage/repack-contained.mjs";
16
17
  import { SwapsSettled, swapsKey, swapsLeft } from "../storage/swap-walk.mjs";
17
18
  import { QuarantineRow, decodeHeld, decodeLeft, deletedLeaveAt, isLeftKey, leavingKey, leavingLate, leavingRow, leftPack } from "../storage/rows.mjs";
@@ -323,6 +324,24 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId,
323
324
  const remapLate = (parts, at, writing) => writing >= at + parts.fetchLimits.milliseconds - jobLeaseMargin;
324
325
  /** Whether two reads of the `index` row hold the same row, or both none. */
325
326
  const sameIndex = (a, b) => a === void 0 || b === void 0 ? a === b : JSON.stringify(a.value) === JSON.stringify(b.value);
327
+ /** Whether `row` is a prune pass's own row, which says when the last pass ran. */
328
+ const isPassRow = (row) => row.collection === prunePassKey.collection && row.id === prunePassKey.id;
329
+ /**
330
+ * `step` for a reread's commit: a run's end that puts the pass's row, its pass a period on, puts
331
+ * none there, and saves the pass due now, as the read it was planned on may not hold (#2525).
332
+ */
333
+ const passDueNow = (step, at) => {
334
+ const put = step?.change.put ?? [];
335
+ if (step?.prune === void 0 || !put.some(isPassRow)) return step;
336
+ return {
337
+ ...step,
338
+ change: {
339
+ ...step.change,
340
+ put: put.filter((row) => !isPassRow(row))
341
+ },
342
+ prune: at
343
+ };
344
+ };
326
345
  /**
327
346
  * Commits a step's change at a read's version, with the receipts and own writes whose days are past, a deleted repo's every own write, and, for a
328
347
  * live repo with events, the run's row and the last step's `repo.maintained`. A live repo's last
@@ -331,7 +350,8 @@ const sameIndex = (a, b) => a === void 0 || b === void 0 ? a === b : JSON.string
331
350
  * given, `given`: past another, it was laid over layers that are gone, so the change commits
332
351
  * without it, and the next `git.index` builds again.
333
352
  */
334
- const commitStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, internalId, read, step, at, first, given) {
353
+ const commitStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, internalId, read, planned, at, first, given) {
354
+ const step = first ? planned : passDueNow(planned, at);
335
355
  const scope = repoScope(internalId);
336
356
  const now = yield* parts.now;
337
357
  const late = now - at;
@@ -375,8 +395,9 @@ const commitStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
375
395
  const laid = step?.index !== void 0 && !tooLate && sameIndex(read.index, given) ? [replacedAtCommit(step.index, at, writing)] : [];
376
396
  const index = SealedObjects.whole(parts.objects, upkeepWhole).index;
377
397
  const { indexJobRow } = parts;
378
- const removes = (step?.change.remove?.length ?? 0) > 0 && !deleted;
379
- const pruning = (laid.length > 0 || !removes || read.index === void 0 ? laid : [read.index]).flatMap((row) => index === void 0 || indexJobRow === void 0 ? [] : indexJobs({ indexJobRow }, index.status(row, now, listing)));
398
+ const { add = [], remove = [] } = step?.change ?? {};
399
+ const moves = (add.length > 0 || remove.length > 0) && !deleted;
400
+ const pruning = (laid.length > 0 || !moves || read.index === void 0 ? laid : [read.index]).flatMap((row) => index === void 0 || indexJobRow === void 0 ? [] : indexJobs({ indexJobRow }, index.status(row, now, listing)));
380
401
  const apart = [...apartAfter(read.apart, step?.change ?? { rows: noRows }), ...swapsLeft(read.swaps, step?.change ?? { rows: noRows })];
381
402
  const pass = step?.prune === void 0 || deleted ? [] : [pruneJobRow(step.prune)];
382
403
  const loose = looseRows(read.times.loose, step?.change.rows ?? noRows);
@@ -411,14 +432,14 @@ const commitStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
411
432
  put: [...change.put ?? [], maintained]
412
433
  };
413
434
  if (isEmpty(change)) {
414
- if (ends) yield* bestEffort(storeCall(() => store.commit(scope, timed)));
435
+ if (ends) yield* bestEffort(storeCommit(store.commit(scope, timed)));
415
436
  return {
416
437
  ok: true,
417
438
  sweep
418
439
  };
419
440
  }
420
441
  return {
421
- ok: (yield* storeCall(() => store.commit(scope, ends ? timed : change))).ok,
442
+ ok: (yield* storeCommit(store.commit(scope, ends ? timed : change))).ok,
422
443
  sweep
423
444
  };
424
445
  });
@@ -445,7 +466,7 @@ const reviveParked = /* @__PURE__ */ Effect.fnUntraced(function* (store, interna
445
466
  let after;
446
467
  for (let read = 0; read < 10; read += 1) {
447
468
  const page = after === void 0 ? {} : { page: { after } };
448
- const listed = yield* storeCall(() => store.list(scope, {
469
+ const listed = yield* storeCall(store.jobs.list(scope, {
449
470
  state: "failed",
450
471
  ...page
451
472
  }));
@@ -456,7 +477,7 @@ const reviveParked = /* @__PURE__ */ Effect.fnUntraced(function* (store, interna
456
477
  name: repackJobName,
457
478
  key: pruneJobKey
458
479
  };
459
- return yield* storeCall(() => store.retry(scope, job, { data: {} })).pipe(Effect.catchIf(notFailed, () => Effect.void));
480
+ return yield* storeCall(store.jobs.retry(scope, job, { data: {} })).pipe(Effect.catchIf(notFailed, () => Effect.void));
460
481
  }
461
482
  if (listed.next === void 0) return;
462
483
  after = listed.next;
@@ -508,7 +529,7 @@ const repackStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
508
529
  const tags = [...served].flatMap(([name, oid]) => name.startsWith("refs/tags/") ? [oid] : []);
509
530
  const tip = served.get(headOf(first.record.defaultBranch));
510
531
  const input = {
511
- store: gitStore(store),
532
+ store: yield* tryGitStore(store),
512
533
  stats,
513
534
  at,
514
535
  tags,
@@ -526,7 +547,7 @@ const repackStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
526
547
  change: { rows: noRows },
527
548
  more: false
528
549
  } : void 0;
529
- const step = (first.record.deleted === true ? held ?? (yield* leavingOf(parts, first.packs, first.record.changedAt)) : void 0) ?? (yield* resultCall(() => SealedObjects.whole(parts.objects, upkeepWhole).maintain(listed, input)));
550
+ const step = (first.record.deleted === true ? held ?? (yield* leavingOf(parts, first.packs, first.record.changedAt)) : void 0) ?? (yield* SealedObjects.whole(parts.objects, upkeepWhole).maintain(listed, input));
530
551
  if (step?.yielded === true) return void 0;
531
552
  let read = first;
532
553
  for (let tries = 1;; tries += 1) {
@@ -593,13 +614,12 @@ const rewalking = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, int
593
614
  */
594
615
  const repackTry = (parts) => ({ missed = 0 }) => Effect.flatMap(Effect.all([
595
616
  CurrentJob.current,
596
- CurrentJob.store,
597
617
  CurrentJob.signal,
598
618
  CurrentJob.deadline
599
- ]), ([job, store, signal, deadline]) => {
619
+ ]), ([job, signal, deadline]) => {
600
620
  const pass = job.key === pruneJobKey;
601
621
  const steps = pass ? "prune" : "others";
602
- const step = repackStep(parts, store, jobRepo(job), signal, deadline, missed, job.attempt > 1, steps);
622
+ const step = repackStep(parts, parts.store, jobRepo(job), signal, deadline, missed, job.attempt > 1, steps);
603
623
  return pass ? Effect.catchIf(step, parksPass, (error) => Effect.die(parked(error))) : step;
604
624
  });
605
625
  /**
@@ -673,11 +693,6 @@ const ensureRepack = /* @__PURE__ */ Effect.fnUntraced(function* (core, jobs, re
673
693
  name: repackJobName,
674
694
  key: repackJobKey
675
695
  };
676
- yield* storeCall(() => jobs.retry(scope, job)).pipe(Effect.catchIf(notFailed, () => Effect.void));
696
+ yield* storeCall(jobs.retry(scope, job)).pipe(Effect.catchIf(notFailed, () => Effect.void));
677
697
  });
678
- /**
679
- * The retry of a core with no queue, a client's: nothing runs its jobs, so none fails and there
680
- * is nothing to revive, and `ensureRepack`'s add alone is what it keeps.
681
- */
682
- const noRepackRetry = { retry: async () => {} };
683
- export { ensureRepack, leavingPage, noRepackRetry, passParked, repackJob, repackJobRow, repackSlowJitter, repackSlowWait, repackTimeout, upkeepsOf };
698
+ export { ensureRepack, leavingPage, passParked, repackJob, repackJobRow, repackSlowJitter, repackSlowWait, repackTimeout, upkeepsOf };
@@ -10,7 +10,7 @@ import { anyOwned, refViewIn, wholeView } from "./ref-view.mjs";
10
10
  import { SealedObjects } from "./view.mjs";
11
11
  import { CoreParts, ObjectsParts, QueueParts } from "./parts.mjs";
12
12
  import { check } from "../contracts/authorize.mjs";
13
- import * as Clock$1 from "effect/Clock";
13
+ import * as Clock from "effect/Clock";
14
14
  import * as Effect from "effect/Effect";
15
15
  // src/core/repo-info.ts
16
16
  /**
@@ -49,8 +49,8 @@ const restricted = ({ repo, refs, pushedAt }) => pushedAt === void 0 ? {
49
49
  /** The repo's jobs, and `index` while a refusal stops its index builds, as `RepoWork` says. */
50
50
  const repoWork = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, sealed, indexRow, packs) {
51
51
  const { jobs } = yield* QueueParts;
52
- const counts = yield* storeCall(() => jobs.count(repoScope(internalId)));
53
- const status = SealedObjects.indexStatus(sealed)?.(indexRow, yield* Clock$1.currentTimeMillis, packs.map(({ id }) => id));
52
+ const counts = yield* storeCall(jobs.count(repoScope(internalId)));
53
+ const status = SealedObjects.indexStatus(sealed)?.(indexRow, yield* Clock.currentTimeMillis, packs.map(({ id }) => id));
54
54
  const index = indexHoldOf(status);
55
55
  return index === void 0 ? counts : {
56
56
  ...counts,