@ref0/git 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (615) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +12 -0
  2. package/dist/access/private-refs.d.mts +12 -9
  3. package/dist/access/private-refs.mjs +69 -46
  4. package/dist/auth/access-jwt.mjs +7 -7
  5. package/dist/auth/auth.d.mts +41 -0
  6. package/dist/auth/auth.mjs +39 -0
  7. package/dist/auth/authorize.mjs +57 -80
  8. package/dist/auth/bridge.mjs +30 -0
  9. package/dist/auth/fences.d.mts +23 -3
  10. package/dist/auth/fences.mjs +3 -3
  11. package/dist/auth/grants.d.mts +25 -0
  12. package/dist/auth/grants.mjs +29 -34
  13. package/dist/auth/helpers.mjs +4 -4
  14. package/dist/auth/host-function.d.mts +9 -2
  15. package/dist/auth/host-function.mjs +36 -9
  16. package/dist/auth/identify.d.mts +4 -1
  17. package/dist/auth/identify.mjs +9 -11
  18. package/dist/auth/namespaces.d.mts +3 -0
  19. package/dist/auth/policy.d.mts +57 -0
  20. package/dist/auth/policy.mjs +56 -0
  21. package/dist/auth/token-rows.mjs +6 -6
  22. package/dist/auth/token-text.mjs +16 -4
  23. package/dist/auth/tokens.d.mts +4 -1
  24. package/dist/auth/tokens.mjs +51 -13
  25. package/dist/auth.d.mts +2 -1
  26. package/dist/auth.mjs +2 -1
  27. package/dist/client/answer.mjs +49 -11
  28. package/dist/client/client.d.mts +2 -2
  29. package/dist/client/client.mjs +5 -6
  30. package/dist/client/git-http.d.mts +6 -0
  31. package/dist/client/git-http.mjs +23 -36
  32. package/dist/client/helper-node.d.mts +12 -0
  33. package/dist/client/helper-node.mjs +108 -5
  34. package/dist/client/local.mjs +97 -92
  35. package/dist/client/negotiate.mjs +10 -8
  36. package/dist/client/push-upload.d.mts +14 -0
  37. package/dist/client/push-upload.mjs +12 -12
  38. package/dist/client/remote-helper.mjs +22 -20
  39. package/dist/client/remote.mjs +28 -22
  40. package/dist/client/run-remote-helper.d.mts +40 -16
  41. package/dist/client/run-remote-helper.mjs +147 -154
  42. package/dist/client/scrub.d.mts +8 -2
  43. package/dist/client/scrub.mjs +76 -4
  44. package/dist/client/slice-push.d.mts +77 -0
  45. package/dist/client/slice-push.mjs +169 -0
  46. package/dist/client/slice-report.mjs +188 -0
  47. package/dist/client/slices.d.mts +44 -0
  48. package/dist/client/slices.mjs +131 -0
  49. package/dist/client/transport.d.mts +1 -0
  50. package/dist/client/transport.mjs +30 -26
  51. package/dist/contracts/access.d.mts +36 -9
  52. package/dist/contracts/actors.d.mts +28 -10
  53. package/dist/contracts/actors.mjs +17 -0
  54. package/dist/contracts/authorize.d.mts +77 -0
  55. package/dist/contracts/authorize.mjs +25 -0
  56. package/dist/contracts/blobs.d.mts +48 -15
  57. package/dist/contracts/blobs.mjs +30 -0
  58. package/dist/contracts/calls-spent.d.mts +1 -0
  59. package/dist/contracts/calls-spent.mjs +60 -19
  60. package/dist/contracts/client.d.mts +14 -16
  61. package/dist/contracts/commits.d.mts +558 -76
  62. package/dist/contracts/commits.mjs +147 -0
  63. package/dist/contracts/engine.d.mts +91 -55
  64. package/dist/contracts/engine.mjs +103 -0
  65. package/dist/contracts/events.d.mts +1382 -205
  66. package/dist/contracts/events.mjs +485 -0
  67. package/dist/contracts/files.d.mts +295 -50
  68. package/dist/contracts/files.mjs +100 -0
  69. package/dist/contracts/forks.d.mts +306 -25
  70. package/dist/contracts/forks.mjs +39 -0
  71. package/dist/contracts/git.d.mts +107 -0
  72. package/dist/contracts/git.mjs +23 -0
  73. package/dist/contracts/grants.d.mts +2 -2
  74. package/dist/contracts/handlers.d.mts +2 -1
  75. package/dist/contracts/ids.d.mts +23 -8
  76. package/dist/contracts/ids.mjs +40 -5
  77. package/dist/contracts/lfs.d.mts +9 -4
  78. package/dist/contracts/merges.d.mts +68 -16
  79. package/dist/contracts/merges.mjs +27 -0
  80. package/dist/contracts/namespaces.d.mts +14 -0
  81. package/dist/contracts/object-values.d.mts +96 -0
  82. package/dist/contracts/object-values.mjs +104 -0
  83. package/dist/contracts/objects.d.mts +324 -88
  84. package/dist/contracts/operations.d.mts +24 -16
  85. package/dist/contracts/promises.d.mts +17 -31
  86. package/dist/contracts/promises.mjs +13 -0
  87. package/dist/contracts/push-uploads.d.mts +39 -24
  88. package/dist/contracts/push-uploads.mjs +54 -0
  89. package/dist/contracts/queue.d.mts +445 -139
  90. package/dist/contracts/queue.mjs +197 -0
  91. package/dist/contracts/refs.d.mts +248 -45
  92. package/dist/contracts/refs.mjs +117 -0
  93. package/dist/contracts/repo-records.d.mts +34 -0
  94. package/dist/contracts/repo-records.mjs +18 -0
  95. package/dist/contracts/repos.d.mts +411 -58
  96. package/dist/contracts/repos.mjs +136 -0
  97. package/dist/contracts/result.d.mts +342 -69
  98. package/dist/contracts/result.mjs +350 -5
  99. package/dist/contracts/rules.d.mts +60 -48
  100. package/dist/contracts/rules.mjs +9 -0
  101. package/dist/contracts/server.d.mts +173 -80
  102. package/dist/contracts/services.d.mts +15 -24
  103. package/dist/contracts/services.mjs +5 -9
  104. package/dist/contracts/signin.d.mts +64 -31
  105. package/dist/contracts/signin.mjs +18 -0
  106. package/dist/contracts/store.d.mts +45 -5
  107. package/dist/contracts/store.mjs +31 -0
  108. package/dist/contracts/sync.d.mts +82 -47
  109. package/dist/contracts/sync.mjs +41 -2
  110. package/dist/contracts/tags.d.mts +204 -22
  111. package/dist/contracts/tags.mjs +51 -1
  112. package/dist/contracts/tokens.d.mts +32 -7
  113. package/dist/contracts/tokens.mjs +31 -1
  114. package/dist/contracts/topics.d.mts +128 -66
  115. package/dist/contracts/topics.mjs +109 -0
  116. package/dist/contracts/trees.d.mts +132 -52
  117. package/dist/contracts/trees.mjs +105 -0
  118. package/dist/contracts/work.d.mts +127 -20
  119. package/dist/contracts/work.mjs +69 -0
  120. package/dist/core/access.d.mts +26 -15
  121. package/dist/core/access.mjs +77 -108
  122. package/dist/core/ancestry.mjs +86 -18
  123. package/dist/core/call-names.d.mts +1 -0
  124. package/dist/core/call-names.mjs +94 -0
  125. package/dist/core/call-services.mjs +73 -0
  126. package/dist/core/changes.d.mts +31 -0
  127. package/dist/core/changes.mjs +5 -0
  128. package/dist/core/clock.mjs +3 -3
  129. package/dist/core/events/deliver.mjs +130 -37
  130. package/dist/core/events/seen.mjs +124 -0
  131. package/dist/core/forks.mjs +371 -159
  132. package/dist/core/hooks/order.d.mts +9 -0
  133. package/dist/core/hooks/order.mjs +25 -0
  134. package/dist/core/hooks/post-receive.mjs +25 -16
  135. package/dist/core/hooks/pre-receive.d.mts +8 -1
  136. package/dist/core/hooks/pre-receive.mjs +8 -6
  137. package/dist/core/imports.mjs +212 -0
  138. package/dist/core/index-job.mjs +131 -38
  139. package/dist/core/merge-parts.d.mts +30 -0
  140. package/dist/core/merge-parts.mjs +31 -0
  141. package/dist/core/names.mjs +4 -16
  142. package/dist/core/namespaces.d.mts +2 -0
  143. package/dist/core/objects/blobs.mjs +4 -4
  144. package/dist/core/objects/commit-writes.mjs +19 -17
  145. package/dist/core/objects/commits.mjs +12 -12
  146. package/dist/core/objects/files.mjs +10 -11
  147. package/dist/core/objects/lines.mjs +15 -32
  148. package/dist/core/objects/merges.mjs +4 -4
  149. package/dist/core/objects/objects-layer.d.mts +21 -0
  150. package/dist/core/objects/objects-layer.mjs +47 -0
  151. package/dist/core/objects/objects-namespace.d.mts +6 -0
  152. package/dist/core/objects/objects-namespace.mjs +13 -0
  153. package/dist/core/objects/objects.d.mts +49 -0
  154. package/dist/core/objects/objects.mjs +18 -0
  155. package/dist/core/objects/peel.mjs +3 -3
  156. package/dist/core/objects/reading.mjs +135 -40
  157. package/dist/core/objects/tags.mjs +7 -7
  158. package/dist/core/objects/tree-edits.mjs +40 -27
  159. package/dist/core/objects/trees.mjs +23 -18
  160. package/dist/core/objects/writing.mjs +43 -44
  161. package/dist/core/own-writes.mjs +3 -3
  162. package/dist/core/parts.d.mts +125 -0
  163. package/dist/core/parts.mjs +59 -0
  164. package/dist/core/promise.mjs +39 -17
  165. package/dist/core/publish.mjs +27 -17
  166. package/dist/core/purge.mjs +242 -0
  167. package/dist/core/push-decide.mjs +93 -28
  168. package/dist/core/push.mjs +301 -156
  169. package/dist/core/receipts.d.mts +4 -3
  170. package/dist/core/receipts.mjs +20 -12
  171. package/dist/core/ref-conflicts.mjs +70 -4
  172. package/dist/core/ref-index-job.mjs +181 -0
  173. package/dist/core/ref-index.d.mts +25 -0
  174. package/dist/core/ref-index.mjs +136 -0
  175. package/dist/core/ref-view.mjs +166 -0
  176. package/dist/core/refs.mjs +313 -95
  177. package/dist/core/repack.d.mts +10 -0
  178. package/dist/core/repack.mjs +261 -81
  179. package/dist/core/repo-info.mjs +99 -0
  180. package/dist/core/repos.mjs +114 -80
  181. package/dist/core/rules/changes.mjs +48 -20
  182. package/dist/core/rules/check.mjs +29 -22
  183. package/dist/core/rules/commit-changes.d.mts +13 -0
  184. package/dist/core/rules/commit-changes.mjs +100 -91
  185. package/dist/core/rules/context.d.mts +67 -8
  186. package/dist/core/rules/context.mjs +88 -51
  187. package/dist/core/rules/facts.mjs +1 -1
  188. package/dist/core/rules/fetch.mjs +24 -26
  189. package/dist/core/rules/files.d.mts +13 -0
  190. package/dist/core/rules/files.mjs +27 -28
  191. package/dist/core/rules/namespace.d.mts +2 -0
  192. package/dist/core/rules/patterns.mjs +29 -5
  193. package/dist/core/rules/protect.d.mts +12 -6
  194. package/dist/core/rules/protect.mjs +22 -20
  195. package/dist/core/rules/rules-layer.d.mts +17 -0
  196. package/dist/core/rules/rules-layer.mjs +26 -0
  197. package/dist/core/rules/rules.d.mts +8 -0
  198. package/dist/core/rules/rules.mjs +16 -0
  199. package/dist/core/rules/service.mjs +18 -0
  200. package/dist/core/seam.d.mts +10 -5
  201. package/dist/core/seam.mjs +36 -19
  202. package/dist/core/tokens.mjs +29 -23
  203. package/dist/core/view.d.mts +105 -6
  204. package/dist/core/view.mjs +211 -109
  205. package/dist/core/work.mjs +40 -14
  206. package/dist/effect.d.mts +3 -4
  207. package/dist/effect.mjs +2 -3
  208. package/dist/engine/allotted-xdiff.d.mts +1 -0
  209. package/dist/engine/allotted-xdiff.mjs +1 -1
  210. package/dist/engine/attributes.mjs +1 -1
  211. package/dist/engine/combined.d.mts +18 -0
  212. package/dist/engine/combined.mjs +39 -44
  213. package/dist/engine/commits.mjs +5 -4
  214. package/dist/engine/content.d.mts +3 -2
  215. package/dist/engine/content.mjs +2 -2
  216. package/dist/engine/failures.d.mts +2 -2
  217. package/dist/engine/failures.mjs +2 -9
  218. package/dist/engine/merge-base-walk.d.mts +3 -2
  219. package/dist/engine/merge-base-walk.mjs +1 -1
  220. package/dist/engine/merge-bases.mjs +3 -2
  221. package/dist/engine/merge.mjs +568 -566
  222. package/dist/engine/parts.d.mts +3 -2
  223. package/dist/engine/parts.mjs +40 -7
  224. package/dist/engine/reads.d.mts +1 -0
  225. package/dist/engine/reads.mjs +5 -5
  226. package/dist/engine/walk.mjs +23 -24
  227. package/dist/engine/xdiff.d.mts +2 -33
  228. package/dist/engine/xdiff.mjs +6 -3
  229. package/dist/event-streams/event-streams.d.mts +25 -0
  230. package/dist/event-streams/event-streams.mjs +22 -0
  231. package/dist/event-streams/namespace.d.mts +2 -0
  232. package/dist/event-streams/stream.d.mts +42 -0
  233. package/dist/{core/events → event-streams}/stream.mjs +112 -48
  234. package/dist/extend.d.mts +5 -2
  235. package/dist/extend.mjs +3 -1
  236. package/dist/http/answers.mjs +8 -4
  237. package/dist/http/bodies.mjs +84 -56
  238. package/dist/http/core-parts.mjs +206 -60
  239. package/dist/http/handler.d.mts +2 -0
  240. package/dist/http/handler.mjs +17 -11
  241. package/dist/http/node.mjs +10 -6
  242. package/dist/http/parts.d.mts +12 -0
  243. package/dist/http/push-uploads.d.mts +9 -0
  244. package/dist/http/push-uploads.mjs +76 -66
  245. package/dist/http/receive-pack.mjs +162 -28
  246. package/dist/http/upload-pack.mjs +106 -81
  247. package/dist/index.d.mts +48 -28
  248. package/dist/index.mjs +29 -7
  249. package/dist/lfs/calls.mjs +2 -2
  250. package/dist/lfs/locks.mjs +24 -20
  251. package/dist/lfs/objects.d.mts +7 -0
  252. package/dist/lfs/objects.mjs +32 -27
  253. package/dist/lfs/pointers.mjs +7 -7
  254. package/dist/lfs/purge.mjs +50 -0
  255. package/dist/lfs/repo.mjs +5 -5
  256. package/dist/lfs/rows.mjs +9 -9
  257. package/dist/lfs/service.d.mts +9 -0
  258. package/dist/lfs/service.mjs +32 -25
  259. package/dist/lfs/upkeep.mjs +5 -5
  260. package/dist/lfs/wire.mjs +80 -38
  261. package/dist/merges/merges.d.mts +20 -0
  262. package/dist/merges/merges.mjs +32 -0
  263. package/dist/merges/namespace.d.mts +2 -0
  264. package/dist/merges/public.d.mts +6 -0
  265. package/dist/merges/public.mjs +10 -0
  266. package/dist/node.d.mts +1 -2
  267. package/dist/node.mjs +1 -3
  268. package/dist/protocol/bytes/buffers.d.mts +9 -3
  269. package/dist/protocol/bytes/buffers.mjs +11 -5
  270. package/dist/protocol/bytes/deflate.d.mts +7 -5
  271. package/dist/protocol/bytes/deflate.mjs +59 -23
  272. package/dist/protocol/bytes/inflate.d.mts +4 -3
  273. package/dist/protocol/bytes/inflate.mjs +61 -26
  274. package/dist/protocol/bytes/reader.mjs +61 -0
  275. package/dist/protocol/bytes/sha1-hasher.d.mts +3 -1
  276. package/dist/protocol/bytes/sha1-hasher.mjs +13 -3
  277. package/dist/protocol/bytes/sha1.d.mts +1 -1
  278. package/dist/protocol/bytes/sha1.mjs +5 -5
  279. package/dist/protocol/bytes/streams.mjs +16 -6
  280. package/dist/protocol/diff/patch.d.mts +4 -0
  281. package/dist/protocol/diff/patch.mjs +1 -1
  282. package/dist/protocol/diff/paths.mjs +1 -1
  283. package/dist/protocol/diff/read.d.mts +1 -1
  284. package/dist/protocol/diff/read.mjs +102 -90
  285. package/dist/protocol/framing/pkt-line.d.mts +1 -0
  286. package/dist/protocol/framing/pkt-line.mjs +40 -6
  287. package/dist/protocol/objects/checked-blobs.d.mts +1 -0
  288. package/dist/protocol/objects/fsck.mjs +7 -1
  289. package/dist/protocol/objects/held.mjs +5 -11
  290. package/dist/protocol/objects/ident.mjs +1 -1
  291. package/dist/protocol/objects/object-rules.mjs +15 -7
  292. package/dist/protocol/objects/object.d.mts +6 -2
  293. package/dist/protocol/objects/object.mjs +5 -2
  294. package/dist/protocol/objects/tag.d.mts +3 -1
  295. package/dist/protocol/objects/tag.mjs +27 -1
  296. package/dist/protocol/objects/tree.mjs +1 -1
  297. package/dist/protocol/packs/delta.d.mts +1 -1
  298. package/dist/protocol/packs/delta.mjs +2 -2
  299. package/dist/protocol/packs/graph.mjs +55 -56
  300. package/dist/protocol/packs/idx.d.mts +4 -2
  301. package/dist/protocol/packs/idx.mjs +156 -63
  302. package/dist/protocol/packs/indexer.d.mts +22 -4
  303. package/dist/protocol/packs/indexer.mjs +14 -35
  304. package/dist/protocol/packs/parts.mjs +5 -5
  305. package/dist/protocol/packs/pos.mjs +12 -5
  306. package/dist/protocol/packs/reader.d.mts +19 -12
  307. package/dist/protocol/packs/reader.mjs +252 -25
  308. package/dist/protocol/packs/rev.d.mts +1 -1
  309. package/dist/protocol/packs/rev.mjs +42 -24
  310. package/dist/protocol/packs/types-file.mjs +85 -0
  311. package/dist/protocol/packs/write-error.d.mts +1 -1
  312. package/dist/protocol/packs/write-error.mjs +2 -2
  313. package/dist/protocol/packs/writer.d.mts +40 -15
  314. package/dist/protocol/packs/writer.mjs +142 -49
  315. package/dist/protocol/wire/advertisement.d.mts +39 -14
  316. package/dist/protocol/wire/advertisement.mjs +127 -31
  317. package/dist/protocol/wire/fetch.d.mts +57 -19
  318. package/dist/protocol/wire/fetch.mjs +57 -26
  319. package/dist/protocol/wire/json.mjs +25 -0
  320. package/dist/protocol/wire/lines.d.mts +10 -0
  321. package/dist/protocol/wire/lines.mjs +20 -6
  322. package/dist/protocol/wire/push-limits.d.mts +6 -0
  323. package/dist/protocol/wire/push-limits.mjs +88 -0
  324. package/dist/protocol/wire/push-uploads.mjs +3 -28
  325. package/dist/protocol/wire/receive-pack.d.mts +30 -14
  326. package/dist/protocol/wire/receive-pack.mjs +29 -2
  327. package/dist/protocol/wire/report-status.d.mts +30 -11
  328. package/dist/protocol/wire/report-status.mjs +21 -2
  329. package/dist/protocol/wire/v2.d.mts +56 -29
  330. package/dist/protocol/wire/v2.mjs +91 -16
  331. package/dist/protocol.d.mts +4 -3
  332. package/dist/protocol.mjs +7 -6
  333. package/dist/queue/advance.mjs +191 -121
  334. package/dist/queue/callers.mjs +12 -9
  335. package/dist/queue/calls.mjs +311 -155
  336. package/dist/queue/commit.mjs +70 -26
  337. package/dist/queue/host.d.mts +40 -13
  338. package/dist/queue/host.mjs +37 -39
  339. package/dist/queue/lanes.mjs +1 -1
  340. package/dist/queue/layer.d.mts +14 -0
  341. package/dist/queue/layer.mjs +55 -0
  342. package/dist/queue/limits.mjs +13 -2
  343. package/dist/queue/namespace.d.mts +2 -0
  344. package/dist/queue/pages.mjs +1 -1
  345. package/dist/queue/public.d.mts +6 -0
  346. package/dist/queue/public.mjs +21 -0
  347. package/dist/queue/push-option.mjs +49 -30
  348. package/dist/queue/rows.mjs +24 -16
  349. package/dist/queue/schedule.mjs +23 -23
  350. package/dist/queue/search.mjs +8 -7
  351. package/dist/queue/state.mjs +49 -13
  352. package/dist/queue/steps.mjs +6 -3
  353. package/dist/remote-helper.d.mts +5 -2
  354. package/dist/remote-helper.mjs +5 -2
  355. package/dist/rest/api.d.mts +1 -1
  356. package/dist/rest/blobs.d.mts +799 -32
  357. package/dist/rest/blobs.mjs +4 -4
  358. package/dist/rest/caller.d.mts +4163 -36
  359. package/dist/rest/caller.mjs +2 -2
  360. package/dist/rest/client.mjs +82 -72
  361. package/dist/rest/commits.d.mts +3253 -182
  362. package/dist/rest/commits.mjs +18 -64
  363. package/dist/rest/errors.d.mts +2082 -22
  364. package/dist/rest/errors.mjs +46 -89
  365. package/dist/rest/events.d.mts +394 -11
  366. package/dist/rest/events.mjs +13 -9
  367. package/dist/rest/files.d.mts +1239 -88
  368. package/dist/rest/files.mjs +11 -42
  369. package/dist/rest/forks.d.mts +2005 -62
  370. package/dist/rest/forks.mjs +10 -13
  371. package/dist/rest/handler.d.mts +4 -0
  372. package/dist/rest/handler.mjs +57 -26
  373. package/dist/rest/handlers.mjs +55 -62
  374. package/dist/rest/listen.d.mts +5 -8
  375. package/dist/rest/listen.mjs +23 -29
  376. package/dist/rest/me.d.mts +393 -10
  377. package/dist/rest/me.mjs +2 -2
  378. package/dist/rest/merges.d.mts +399 -16
  379. package/dist/rest/merges.mjs +3 -17
  380. package/dist/rest/paths.mjs +1 -0
  381. package/dist/rest/queue.d.mts +5615 -240
  382. package/dist/rest/queue.mjs +15 -130
  383. package/dist/rest/refs.d.mts +2859 -132
  384. package/dist/rest/refs.mjs +19 -39
  385. package/dist/rest/repos.d.mts +2392 -64
  386. package/dist/rest/repos.mjs +10 -33
  387. package/dist/rest/tags.d.mts +1211 -60
  388. package/dist/rest/tags.mjs +6 -34
  389. package/dist/rest/tokens.d.mts +2473 -170
  390. package/dist/rest/tokens.mjs +7 -4
  391. package/dist/rest/topics.d.mts +2060 -113
  392. package/dist/rest/topics.mjs +23 -71
  393. package/dist/rest/trees.d.mts +1610 -75
  394. package/dist/rest/trees.mjs +16 -57
  395. package/dist/rest/wire.d.mts +402 -0
  396. package/dist/rest/wire.mjs +32 -46
  397. package/dist/rest/work.d.mts +1179 -38
  398. package/dist/rest/work.mjs +7 -51
  399. package/dist/rest.d.mts +3 -3
  400. package/dist/server/extension.d.mts +11 -4
  401. package/dist/server/extension.mjs +85 -53
  402. package/dist/server/git-layer.d.mts +23 -0
  403. package/dist/server/git-layer.mjs +107 -0
  404. package/dist/server/git-namespace.d.mts +6 -0
  405. package/dist/server/git-namespace.mjs +15 -0
  406. package/dist/server/lifecycle.d.mts +2 -0
  407. package/dist/server/lifecycle.mjs +82 -0
  408. package/dist/server/namespaces.d.mts +2 -0
  409. package/dist/server/registry.d.mts +9 -0
  410. package/dist/server/registry.mjs +167 -0
  411. package/dist/server/route-match.mjs +88 -0
  412. package/dist/server/routes.d.mts +15 -8
  413. package/dist/server/routes.mjs +35 -33
  414. package/dist/server/server.d.mts +27 -2
  415. package/dist/server/server.mjs +493 -234
  416. package/dist/signin/codes.mjs +9 -6
  417. package/dist/signin/context.d.mts +2 -1
  418. package/dist/signin/context.mjs +4 -4
  419. package/dist/signin/device.mjs +8 -8
  420. package/dist/signin/forms.mjs +11 -29
  421. package/dist/signin/grants.d.mts +5 -3
  422. package/dist/signin/grants.mjs +20 -19
  423. package/dist/signin/route.mjs +2 -2
  424. package/dist/signin/web.mjs +7 -7
  425. package/dist/signin/wire.mjs +6 -6
  426. package/dist/storage/bits.mjs +41 -0
  427. package/dist/storage/budget.mjs +51 -18
  428. package/dist/storage/calls.d.mts +22 -4
  429. package/dist/storage/calls.mjs +347 -110
  430. package/dist/storage/clean-up.mjs +80 -35
  431. package/dist/storage/counted-bucket.mjs +115 -0
  432. package/dist/storage/fetch.d.mts +5 -1
  433. package/dist/storage/fetch.mjs +428 -79
  434. package/dist/storage/fsck.mjs +56 -7
  435. package/dist/storage/held-types.d.mts +7 -0
  436. package/dist/storage/held-types.mjs +263 -0
  437. package/dist/storage/host-bucket.mjs +28 -0
  438. package/dist/storage/id-mix.d.mts +1 -0
  439. package/dist/storage/id-mix.mjs +55 -0
  440. package/dist/storage/index-bitmaps.d.mts +2 -1
  441. package/dist/storage/index-bitmaps.mjs +233 -101
  442. package/dist/storage/index-build.d.mts +7 -3
  443. package/dist/storage/index-build.mjs +674 -174
  444. package/dist/storage/index-fetch.d.mts +4 -1
  445. package/dist/storage/index-fetch.mjs +365 -342
  446. package/dist/storage/index-files.mjs +25 -27
  447. package/dist/storage/index-graph.d.mts +2 -1
  448. package/dist/storage/index-graph.mjs +127 -91
  449. package/dist/storage/index-layers.d.mts +11 -0
  450. package/dist/storage/index-layers.mjs +258 -78
  451. package/dist/storage/index-reach.mjs +181 -75
  452. package/dist/storage/index-remap.mjs +74 -32
  453. package/dist/storage/index-shallow.mjs +311 -0
  454. package/dist/storage/index-visible.mjs +168 -0
  455. package/dist/storage/layout.d.mts +1 -0
  456. package/dist/storage/layout.mjs +39 -8
  457. package/dist/storage/lfs-pointers.d.mts +3 -1
  458. package/dist/storage/lfs-pointers.mjs +25 -9
  459. package/dist/storage/link-join.d.mts +4 -0
  460. package/dist/storage/link-join.mjs +50 -12
  461. package/dist/storage/links.mjs +89 -4
  462. package/dist/storage/listed-ids.mjs +10 -0
  463. package/dist/storage/loose.d.mts +11 -4
  464. package/dist/storage/loose.mjs +103 -69
  465. package/dist/storage/memory-budget.d.mts +5 -0
  466. package/dist/storage/memory-budget.mjs +530 -102
  467. package/dist/storage/merge-choose.mjs +258 -0
  468. package/dist/storage/merge-cut.mjs +47 -0
  469. package/dist/storage/merge-fence.mjs +89 -0
  470. package/dist/storage/merge-index.mjs +347 -0
  471. package/dist/storage/merge-most.mjs +202 -0
  472. package/dist/storage/merge-plan.mjs +171 -0
  473. package/dist/storage/merge-row.mjs +258 -0
  474. package/dist/storage/merge-stream.mjs +497 -0
  475. package/dist/storage/merge-walk.mjs +199 -0
  476. package/dist/storage/merge-write.mjs +129 -0
  477. package/dist/storage/merge.d.mts +10 -0
  478. package/dist/storage/merge.mjs +82 -306
  479. package/dist/storage/object-rows.d.mts +4 -2
  480. package/dist/storage/object-rows.mjs +101 -17
  481. package/dist/storage/pack-order.d.mts +1 -1
  482. package/dist/storage/pack-order.mjs +71 -54
  483. package/dist/storage/pack-ranges.d.mts +1 -1
  484. package/dist/storage/pack-ranges.mjs +396 -60
  485. package/dist/storage/pack-reads.d.mts +6 -2
  486. package/dist/storage/pack-reads.mjs +613 -124
  487. package/dist/storage/pack-receive.d.mts +7 -2
  488. package/dist/storage/pack-receive.mjs +820 -237
  489. package/dist/storage/packs-memory.d.mts +25 -0
  490. package/dist/storage/packs-memory.mjs +49 -0
  491. package/dist/storage/packs.d.mts +9 -7
  492. package/dist/storage/packs.mjs +562 -218
  493. package/dist/storage/placed-reads.mjs +205 -0
  494. package/dist/storage/promise-calls.mjs +29 -0
  495. package/dist/storage/prune-keep.mjs +164 -0
  496. package/dist/storage/prune-walk.mjs +578 -0
  497. package/dist/storage/prune.mjs +739 -332
  498. package/dist/storage/push-allotment.mjs +3 -3
  499. package/dist/storage/push-uploads.mjs +24 -14
  500. package/dist/storage/pushed-commits.mjs +8 -9
  501. package/dist/storage/quarantine.d.mts +10 -0
  502. package/dist/storage/quarantine.mjs +28 -25
  503. package/dist/storage/range-cache.mjs +71 -0
  504. package/dist/storage/raw-ids.mjs +20 -1
  505. package/dist/storage/ready.d.mts +6 -4
  506. package/dist/storage/ready.mjs +109 -48
  507. package/dist/storage/receive-admission.mjs +67 -0
  508. package/dist/storage/receive-bounds.d.mts +1 -0
  509. package/dist/storage/receive-bounds.mjs +202 -0
  510. package/dist/storage/receive-files.mjs +248 -0
  511. package/dist/storage/receive-links.mjs +281 -244
  512. package/dist/storage/receive-state.d.mts +9 -0
  513. package/dist/storage/receive-state.mjs +150 -0
  514. package/dist/storage/receive-steps.mjs +344 -0
  515. package/dist/storage/receive-sweep.mjs +160 -0
  516. package/dist/storage/receive-table.d.mts +3 -0
  517. package/dist/storage/receive-table.mjs +197 -0
  518. package/dist/storage/repack-backlog.mjs +70 -0
  519. package/dist/storage/repack-contained.mjs +269 -0
  520. package/dist/storage/repack-job.d.mts +3 -0
  521. package/dist/storage/repack-job.mjs +24 -7
  522. package/dist/storage/repack.d.mts +6 -6
  523. package/dist/storage/repack.mjs +156 -77
  524. package/dist/storage/roots.mjs +23 -7
  525. package/dist/storage/rows.d.mts +6 -3
  526. package/dist/storage/rows.mjs +41 -8
  527. package/dist/storage/runs.d.mts +8 -0
  528. package/dist/storage/runs.mjs +731 -0
  529. package/dist/storage/send-list.d.mts +9 -0
  530. package/dist/storage/send-list.mjs +504 -0
  531. package/dist/storage/shallow.d.mts +3 -3
  532. package/dist/storage/shallow.mjs +7 -7
  533. package/dist/storage/single-flight.mjs +47 -0
  534. package/dist/storage/stream-whole.mjs +121 -54
  535. package/dist/storage/swap-walk.mjs +188 -0
  536. package/dist/storage/unpack.mjs +54 -23
  537. package/dist/storage/visible.mjs +58 -39
  538. package/dist/storage/walk.d.mts +4 -1
  539. package/dist/storage/walk.mjs +33 -14
  540. package/dist/storage/wants.mjs +185 -33
  541. package/dist/storage/written-bases.mjs +172 -0
  542. package/dist/store/call-count.d.mts +69 -4
  543. package/dist/store/call-count.mjs +193 -51
  544. package/dist/store/catalogue.d.mts +18 -4
  545. package/dist/store/catalogue.mjs +135 -48
  546. package/dist/store/closed.d.mts +21 -0
  547. package/dist/store/closed.mjs +34 -0
  548. package/dist/store/crossing.mjs +10 -9
  549. package/dist/store/cursor-seal.d.mts +12 -1
  550. package/dist/store/cursor-seal.mjs +11 -7
  551. package/dist/store/errors.d.mts +2 -2
  552. package/dist/store/errors.mjs +120 -26
  553. package/dist/store/git-store.mjs +21 -2
  554. package/dist/store/list-job.mjs +5 -5
  555. package/dist/store/outbox.d.mts +15 -5
  556. package/dist/store/outbox.mjs +110 -30
  557. package/dist/store/promises.d.mts +6 -0
  558. package/dist/store/promises.mjs +317 -0
  559. package/dist/store/queue-jobs.mjs +12 -12
  560. package/dist/store/records.d.mts +64 -1
  561. package/dist/store/records.mjs +101 -32
  562. package/dist/store/ref-rows.d.mts +18 -2
  563. package/dist/store/ref-rows.mjs +62 -5
  564. package/dist/store/repo-record.mjs +11 -9
  565. package/dist/store/reservations.mjs +9 -8
  566. package/dist/store/scopes.mjs +13 -1
  567. package/dist/store/settle.mjs +1 -1
  568. package/dist/store/topic-jobs.mjs +4 -4
  569. package/dist/sync/bound.d.mts +5 -3
  570. package/dist/sync/bound.mjs +41 -7
  571. package/dist/sync/github.mjs +7 -7
  572. package/dist/sync/import.d.mts +2 -0
  573. package/dist/sync/import.mjs +46 -50
  574. package/dist/sync/jobs.d.mts +3 -3
  575. package/dist/sync/jobs.mjs +36 -41
  576. package/dist/sync/mirror.d.mts +5 -1
  577. package/dist/sync/mirror.mjs +121 -44
  578. package/dist/sync/publish.d.mts +1 -0
  579. package/dist/sync/publish.mjs +10 -12
  580. package/dist/sync/step.mjs +439 -71
  581. package/dist/sync/tries.mjs +52 -34
  582. package/dist/sync.d.mts +3 -3
  583. package/dist/sync.mjs +2 -2
  584. package/dist/topics/advance.mjs +105 -87
  585. package/dist/topics/calls.mjs +99 -69
  586. package/dist/topics/directory.mjs +31 -11
  587. package/dist/topics/host.d.mts +1 -2
  588. package/dist/topics/host.mjs +3 -13
  589. package/dist/topics/members.mjs +30 -24
  590. package/dist/topics/rows.mjs +10 -9
  591. package/dist/topics/topic.mjs +42 -16
  592. package/package.json +8 -15
  593. package/dist/auth/authorize.d.mts +0 -5
  594. package/dist/contracts/objects.mjs +0 -54
  595. package/dist/core/events/stream.d.mts +0 -19
  596. package/dist/core/rules/define.d.mts +0 -5
  597. package/dist/core/rules/define.mjs +0 -13
  598. package/dist/core/rules/fetch.d.mts +0 -5
  599. package/dist/core/sight.mjs +0 -99
  600. package/dist/engine/engine.d.mts +0 -25
  601. package/dist/engine/engine.mjs +0 -49
  602. package/dist/engine/xdiff/NOTICE.md +0 -63
  603. package/dist/engine/xdiff/compiled.d.mts +0 -7
  604. package/dist/engine/xdiff/compiled.mjs +0 -9
  605. package/dist/engine/xdiff/embedded.mjs +0 -4
  606. package/dist/engine/xdiff/node.d.mts +0 -7
  607. package/dist/engine/xdiff/node.mjs +0 -10
  608. package/dist/engine/xdiff/upstream/LGPL-2.1 +0 -511
  609. package/dist/engine/xdiff/xdiff.wasm +0 -0
  610. package/dist/engine.d.mts +0 -3
  611. package/dist/engine.mjs +0 -3
  612. package/dist/storage/distinct-ids.mjs +0 -39
  613. package/dist/storage/held-memo.mjs +0 -188
  614. package/dist/storage/index-remap.d.mts +0 -8
  615. package/dist/sync/records.mjs +0 -73
@@ -1,32 +1,36 @@
1
+ import { spentIn } from "../contracts/calls-spent.mjs";
2
+ import { gitError } from "../contracts/result.mjs";
1
3
  import { hexOf } from "../protocol/bytes/hex.mjs";
2
4
  import { Sha1 } from "../protocol/bytes/sha1.mjs";
3
5
  import { writeCommitGraph } from "../protocol/packs/graph.mjs";
4
6
  import { IndexerCache } from "../protocol/packs/indexer.mjs";
5
7
  import { oidBytes } from "../protocol/packs/idx.mjs";
6
8
  import { rawLinks } from "../protocol/objects/links-raw.mjs";
7
- import { gitError } from "../store/errors.mjs";
8
9
  import { randomText } from "../store/random.mjs";
9
- import { allottableOf } from "./budget.mjs";
10
- import { bucketCall, bucketPut } from "./calls.mjs";
11
- import { EdgeFiles, copyBitmaps, copyHeldBytes, copyRunBytes, edgesBytesOf, edgesFileOf, ewahMostWords, noNumber, runsMost, storedBitmaps, storedSize, writeBitmaps } from "./index-bitmaps.mjs";
10
+ import { allottableOf, uploadPartBytes } from "./budget.mjs";
11
+ import { bucketDo, bucketPut, joined, readWhole, sizedPutCalls, streamedPutCalls } from "./calls.mjs";
12
+ import { BitmapsPart, EdgeFiles, bitmapOrder, bitmapsMostBytes, bitmapsPut, copyBitmaps, copyHeldBytes, copyRunBytes, edgesBytesOf, edgesFileOf, ewahMostWords, noNumber, orderKey, partBitmaps, partBytesMost, runsMost, storedBitmaps, storedSize, writeBitmaps } from "./index-bitmaps.mjs";
12
13
  import { BasesWriter, TypesWriter, indexBasesBytes, indexTypesBytes, openBases, openTypes, typeCodes } from "./index-files.mjs";
13
- import { bitmapWords } from "./ewah.mjs";
14
- import { graphChunk, mergeHeldBytes, mergeIndexGraphs, openGraphLayers, openIndexGraph, writeIndexGraph } from "./index-graph.mjs";
14
+ import { bitmapOf, bitmapWords, ewahOf, orEwah } from "./ewah.mjs";
15
+ import { graphChunk, indexGraphBytes, mergeHeldBytes, mergeIndexGraphs, openGraphLayers, openIndexGraph, writeIndexGraph } from "./index-graph.mjs";
15
16
  import { hasBit, idsOf, lookupCalls, openLayerBitmaps, openLayout, orIntoBytes, reachOf } from "./index-layers.mjs";
16
17
  import { indexFiles, indexPrefix, indexRowKey, isPackId, packFiles } from "./layout.mjs";
18
+ import { listedIds } from "./listed-ids.mjs";
17
19
  import { joinBytes, joinLinks } from "./link-join.mjs";
18
20
  import { outsideOn, readBusy } from "./memory-budget.mjs";
19
21
  import { startPut } from "./merge.mjs";
20
22
  import { eachPageAt, objectOfRow } from "./object-rows.mjs";
21
- import { SliceLinks, SliceRefused, cutAtSpent, isSliceRefused, linksPastMemory, nothingSettled, readSlice, spentOf } from "./pack-order.mjs";
22
- import { PackBlocks, packIndexerLimits, readWhole } from "./pack-reads.mjs";
23
+ import { SliceLinks, SliceRefused, cutAtSpent, isSliceRefused, linksPastMemory, nothingSettled, readSlice, slicePackOf, sliceRefusal, spentOf } from "./pack-order.mjs";
24
+ import { PackBlocks, blocksHeld, packIndexerLimits } from "./pack-reads.mjs";
23
25
  import { rangeRanks, readExactly } from "./pack-ranges.mjs";
26
+ import { rangeCached } from "./range-cache.mjs";
24
27
  import { compareIds } from "./raw-ids.mjs";
28
+ import * as Schema from "effect/Schema";
25
29
  import * as Effect from "effect/Effect";
26
30
  import * as Result from "effect/Result";
27
- import * as Schema from "effect/Schema";
31
+ import * as Cause from "effect/Cause";
28
32
  import * as Option from "effect/Option";
29
- import * as Exit from "effect/Exit";
33
+ import * as Stream from "effect/Stream";
30
34
  // src/storage/index-build.ts
31
35
  /**
32
36
  * The reachability index's first build, `git.index`'s steps, one a try: the region's rows read,
@@ -43,9 +47,9 @@ import * as Exit from "effect/Exit";
43
47
  const lost = (message) => gitError("DATA_LOSS", message);
44
48
  /** A build's ID, new for each: `i_` and 12 random bytes. */
45
49
  const newBuildId = () => `i_${randomText(12)}`;
46
- const Count = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
50
+ const Count = /* @__PURE__ */ Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
47
51
  /** One read slice, by the order it was read: what its edges, types and bases parts cover. */
48
- const IndexSlice = Schema.Struct({
52
+ const IndexSlice = /* @__PURE__ */ Schema.Struct({
49
53
  first: Count,
50
54
  positions: Count,
51
55
  sources: Count,
@@ -62,7 +66,7 @@ const indexSteps = [
62
66
  "commit"
63
67
  ];
64
68
  /** One run of a layer's positions: its packs, in position order, then the rows it read. */
65
- const IndexGroup = Schema.Struct({
69
+ const IndexGroup = /* @__PURE__ */ Schema.Struct({
66
70
  packs: Schema.Array(Schema.String),
67
71
  rows: Count
68
72
  });
@@ -73,7 +77,7 @@ const IndexGroup = Schema.Struct({
73
77
  * over the packs and rows listed since, numbered after the layers below, so no position or
74
78
  * bitmap below it changes; a merge makes the layers one, their positions as they were.
75
79
  */
76
- const IndexLayer = Schema.Struct({
80
+ const IndexLayer = /* @__PURE__ */ Schema.Struct({
77
81
  build: Schema.String,
78
82
  groups: Schema.Array(IndexGroup),
79
83
  region: Schema.String,
@@ -91,7 +95,7 @@ const IndexLayer = Schema.Struct({
91
95
  * `below` is the row's layers an update builds on, none for a whole build; a merge's are the
92
96
  * layers it makes one of, and it covers no pack of its own.
93
97
  */
94
- const IndexData = Schema.Struct({
98
+ const IndexData = /* @__PURE__ */ Schema.Struct({
95
99
  below: Schema.Array(IndexLayer),
96
100
  merge: Schema.Boolean,
97
101
  build: Schema.String,
@@ -107,10 +111,23 @@ const IndexData = Schema.Struct({
107
111
  bitmaps: Count,
108
112
  table: Count,
109
113
  /** The read step's slices narrowed, as `narrowedAfter` moves them: none, in full slices. */
110
- narrowed: Schema.optionalKey(Schema.suspend(() => Narrowed))
114
+ narrowed: Schema.optionalKey(Schema.suspend(() => Narrowed)),
115
+ /** The parts of the bitmaps step's walks below that earlier tries closed: none, no part. */
116
+ reaches: Schema.optionalKey(Count),
117
+ /** A whole build's bitmaps written so far, a part a try: none before its first part. */
118
+ bitmapsCut: Schema.optionalKey(Schema.suspend(() => BitmapsCut))
119
+ });
120
+ /**
121
+ * A whole build's bitmaps under way (#1068): the key of the order they're made in, how many of
122
+ * it the parts hold, and each part's count. A try whose order has another key starts again.
123
+ */
124
+ const BitmapsCut = /* @__PURE__ */ Schema.Struct({
125
+ order: Schema.String,
126
+ done: Count,
127
+ parts: Schema.Array(Count)
111
128
  });
112
129
  /** A build its row no longer names, kept readable until `at` and prune's grace pass. */
113
- const ReplacedBuild = Schema.Struct({
130
+ const ReplacedBuild = /* @__PURE__ */ Schema.Struct({
114
131
  build: Schema.String,
115
132
  at: Count
116
133
  });
@@ -118,19 +135,33 @@ const ReplacedBuild = Schema.Struct({
118
135
  * A refusal for spent tries: when it was made, how many there have been in a row, and when a push
119
136
  * may save the next round of tries.
120
137
  */
121
- const IndexTries = Schema.Struct({
138
+ const IndexTries = /* @__PURE__ */ Schema.Struct({
122
139
  at: Count,
123
140
  refusals: Count,
124
141
  next: Count
125
142
  });
126
143
  /**
127
- * An update whose tries were spent, on the row it would have added a layer to: its reason and
128
- * tries, as a refused row's. The layers stand, and reads answer from them; `status` says the
129
- * refusal, and no push saves the job until its wait has passed. The next build's row has none.
144
+ * The host's bounds a step was refused at for good: the memory `packs()` allots, and the store
145
+ * calls a try may make, where the adapter bounds them. Only a host that changes one mends the
146
+ * refusal, so `status` says `retry` once they differ (Q886).
130
147
  */
131
- const IndexRefusal = Schema.Struct({
148
+ const IndexBounds = /* @__PURE__ */ Schema.Struct({
149
+ memory: Count,
150
+ bucket: Schema.optionalKey(Count),
151
+ subrequests: Schema.optionalKey(Count)
152
+ });
153
+ /**
154
+ * An update refused, on the row it would have added a layer to: its reason, and either the tries
155
+ * spent, as a refused row's, or the host's `bounds` a step of it can't be made within. The layers
156
+ * stand, and reads answer from them; `status` says the refusal, and no push saves the job until
157
+ * its wait has passed or the bounds have changed. The next build's row has none.
158
+ */
159
+ const IndexRefusal = /* @__PURE__ */ Schema.Struct({
132
160
  reason: Schema.String,
133
- tries: IndexTries
161
+ tries: Schema.optionalKey(IndexTries),
162
+ bounds: Schema.optionalKey(IndexBounds),
163
+ /** The pack a refused slice cuts: the refusal stands while it's listed (Q886). */
164
+ pack: Schema.optionalKey(Schema.String)
134
165
  });
135
166
  /**
136
167
  * The repo's index, `index`/`current`: its layers, oldest first, at most `layersMost`, and the
@@ -139,7 +170,7 @@ const IndexRefusal = Schema.Struct({
139
170
  * row that leaves after the build changes nothing. `rounds` is how many rounds of tries the repo
140
171
  * had used once it was built, or once its update's were spent, as a refused row's.
141
172
  */
142
- const BuiltIndex = Schema.Struct({
173
+ const BuiltIndex = /* @__PURE__ */ Schema.Struct({
143
174
  rounds: Count,
144
175
  layers: Schema.Array(IndexLayer),
145
176
  replaced: Schema.Array(ReplacedBuild),
@@ -160,18 +191,39 @@ const triesWaitOf = (refusals) => Math.min(triesWait * 2 ** Math.max(0, refusals
160
191
  * one, up to `triesWaitMost` (the coordinator, 22 Nov). `rounds` is how many rounds of tries the
161
192
  * repo has used, either refusal's: the next round a push saves is that one, a job key never used.
162
193
  */
163
- const RefusedIndex = Schema.Struct({
194
+ const RefusedIndex = /* @__PURE__ */ Schema.Struct({
164
195
  refused: Schema.Struct({
165
196
  commits: Count,
166
197
  most: Count,
167
198
  reason: Schema.String,
168
199
  rounds: Count,
169
- tries: Schema.optionalKey(IndexTries)
200
+ tries: Schema.optionalKey(IndexTries),
201
+ bounds: Schema.optionalKey(IndexBounds),
202
+ pack: Schema.optionalKey(Schema.String)
170
203
  }),
171
204
  replaced: Schema.Array(ReplacedBuild)
172
205
  });
173
- const IndexRow = Schema.Union([BuiltIndex, RefusedIndex]);
174
- const decodeRowOption = Schema.decodeUnknownOption(IndexRow);
206
+ /** A try's bounds, from its parts: the graph's, its budget's memory and its counted calls. */
207
+ const limitsOf = (parts) => ({
208
+ graphMost: parts.graphMost,
209
+ memory: parts.budget.total,
210
+ calls: parts.counted?.most
211
+ });
212
+ /** The host's bounds in `limits`, as a refused row keeps them: an unbounded kind left out. */
213
+ const boundsOf = (limits) => {
214
+ const bounds = { memory: limits.memory };
215
+ const { calls } = limits;
216
+ if (calls !== void 0 && Number.isFinite(calls.bucket)) bounds.bucket = calls.bucket;
217
+ if (calls !== void 0 && Number.isFinite(calls.subrequests)) bounds.subrequests = calls.subrequests;
218
+ return bounds;
219
+ };
220
+ /** Whether `kept`, the bounds a refusal was made at, are the host's in `limits` now. */
221
+ const boundsHold = (kept, limits) => {
222
+ const now = boundsOf(limits);
223
+ return kept.memory === now.memory && kept.bucket === now.bucket && kept.subrequests === now.subrequests;
224
+ };
225
+ const IndexRow = /* @__PURE__ */ Schema.Union([BuiltIndex, RefusedIndex]);
226
+ const decodeRowOption = /* @__PURE__ */ Schema.decodeUnknownOption(IndexRow);
175
227
  /** `row`'s layers, when it has some: a row of none is as no row. */
176
228
  const builtOf = (row) => row === void 0 || "refused" in row || row.layers.length === 0 ? void 0 : row;
177
229
  /** An `index` row's value decoded, at the read's boundary: none for one unreadable. */
@@ -191,11 +243,11 @@ const sliceBounds = {
191
243
  /** The memory one try takes: its base cache and blocks' floors, then what they may grow to. */
192
244
  const floors = {
193
245
  cache: 8388608,
194
- blocks: 2097152
246
+ blocks: blocksHeld(2)
195
247
  };
196
248
  const most = {
197
249
  cache: packIndexerLimits.cacheBytes,
198
- blocks: 8388608
250
+ blocks: blocksHeld(8)
199
251
  };
200
252
  /**
201
253
  * The most the bitmaps step keeps of edges files and of bitmaps made, past what a repo fills. At
@@ -205,18 +257,10 @@ const edgesMost = 12582912;
205
257
  const madeMost = 8388608;
206
258
  /** The listing's packs in position order: biggest first, ties by ID. */
207
259
  const positionOrder = (packs) => [...packs].sort((a, b) => b.bytes - a.bytes || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
208
- /** A put of `bytes` at `key`, done again when a try that died had put it already. */
209
260
  /** A put that found its key there: a try that died after its put landed, done again. */
210
261
  const alreadyThere = (error) => error.code === "ALREADY_EXISTS";
211
- const putOnce = (bucket, key, bytes) => bucketPut(bucket, (retrying) => bucket.put(key, streamOf(bytes), {
212
- size: bytes.byteLength,
213
- retrying
214
- })).pipe(Effect.catchIf(alreadyThere, () => Effect.void));
215
- /** `bytes` as a stream of one chunk, so a put holds no copy of them. */
216
- const streamOf = (bytes) => new ReadableStream({ start: (controller) => {
217
- controller.enqueue(bytes);
218
- controller.close();
219
- } });
262
+ /** A put of `bytes` at `key`, done again when a try that died had put it already. */
263
+ const putOnce = (bucket, key, bytes) => bucketPut(bucket, key, bytes).pipe(Effect.catchIf(alreadyThere, () => Effect.void));
220
264
  /** The most an edges file of `links` takes, each link kept. */
221
265
  const edgesMostOf = (links) => edgesBytesOf({
222
266
  sources: links.sources,
@@ -235,6 +279,25 @@ const wordsOf = (bytes) => {
235
279
  const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
236
280
  return Uint32Array.from({ length: bytes.byteLength / 4 }, (_, at) => view.getUint32(at * 4));
237
281
  };
282
+ /**
283
+ * A reach part at `key`, read and decoded into `allotment`: each chunk charged as it comes, the
284
+ * part beside its walks while both are held, then the walks alone (#1132).
285
+ */
286
+ const keptReaches = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, words, allotment) {
287
+ const chunks = [];
288
+ yield* bucketDo(Stream.runForEach(bucket.read(key), (chunk) => {
289
+ chunks.push(chunk);
290
+ return allotment.grow(chunk.byteLength);
291
+ }));
292
+ const read = chunks.reduce((sum, chunk) => sum + chunk.byteLength, 0);
293
+ yield* allotment.grow(2 * read + words * 4);
294
+ const bytes = joined(chunks.splice(0));
295
+ const kept = reachesOf(bytes, words);
296
+ allotment.shrink(2 * read + (kept?.open === void 0 ? words * 4 : 0));
297
+ if (kept === void 0) return yield* Effect.fail(lost(`${key}'s cut walk is unreadable`));
298
+ yield* allotment.grow(kept.closed.size * 8);
299
+ return kept;
300
+ });
238
301
  const readScratch = (bucket, key) => Effect.flatMap(readWhole(bucket, key), (bytes) => bytes === void 0 ? Effect.fail(lost(`${key} is missing`)) : Effect.succeed(bytes));
239
302
  /** The packs every layer of `built` covers. */
240
303
  const coveredPacks = (layers) => new Set(layers.flatMap((layer) => layer.groups.flatMap((group) => group.packs)));
@@ -305,8 +368,8 @@ const spanOf = (data) => ({
305
368
  * Every layer's positions, `data`'s own last: the layout across them, this layer's own packs'
306
369
  * ranges, its first position, and where its rows start, after its packs.
307
370
  */
308
- const layoutOf = (bucket, listed, data) => Effect.gen(function* () {
309
- const layout = yield* openLayout(bucket, listed, [...data.below, spanOf(data)]);
371
+ const layoutOf = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, listed, data, options) {
372
+ const layout = yield* openLayout(bucket, listed, [...data.below, spanOf(data)], void 0, options);
310
373
  const own = layout.ranges.slice(layout.ranges.length - data.packs.length);
311
374
  const first = firstOf(data.below);
312
375
  return {
@@ -342,24 +405,34 @@ const withRows = (region, first, ids) => {
342
405
  /**
343
406
  * The most calls a read step makes after its slice, over packs of `counts` objects: its join's,
344
407
  * each pack's `.idx` IDs read a chunk of `rangeRanks` at a time, and a chunk's positions when it
345
- * holds a link, then the slice's three puts. No store call: the join reads the packs' files alone,
346
- * and the job's own reads and settle aren't `packs()`'s to count. A slice's own calls leave this
347
- * many of the try's bounds for them (#681).
408
+ * holds a link, then the slice's three puts, each charged as `multipart` charges its file at its
409
+ * most: its edges, made in the try's memory of `held` bytes, since a slice ends past the entry
410
+ * whose links reach the bound; then of a slice of `entries`, a type byte an entry and two words of
411
+ * `.bases` an entry. No store call: the join reads the packs' files alone, and the job's own
412
+ * reads and settle aren't `packs()`'s to count. A slice's own calls leave this many of the try's
413
+ * bounds for them (#681).
348
414
  */
349
- const indexReadCallsAfter = (counts) => ({
350
- bucket: counts.reduce((sum, count) => sum + 2 * Math.ceil(count / rangeRanks), 0) + 3,
415
+ const indexReadCallsAfter = (counts, multipart, { entries, held }) => ({
416
+ bucket: counts.reduce((sum, count) => sum + 2 * Math.ceil(count / rangeRanks), 0) + sizedPutCalls(multipart, held) + sizedPutCalls(multipart, entries) + sizedPutCalls(multipart, entries * 8),
351
417
  store: 0
352
418
  });
353
419
  /**
420
+ * A refusal whose index row keeps its whole text, `message` then the host's step: the one text
421
+ * `lint/host-hints.test.ts` lets name the host's setup, since only the host's log and
422
+ * `GitObjects.index.status`, in process, read the row.
423
+ */
424
+ const refusedRow = (message, hostHint, reason) => gitError("RESOURCE_EXHAUSTED", message, {
425
+ hostHint,
426
+ cause: new SliceRefused(`${message} ${hostHint}`),
427
+ context: { reason }
428
+ });
429
+ /**
354
430
  * The refusal of a build whose read step needs `needs` calls of `kind` after its slice, at or past
355
431
  * the try's `most` of them: no slice could read within the rest, so it refuses before any (#681).
356
432
  */
357
433
  const reservePast = (kind, needs, most) => {
358
- const message = `Indexing needs ${needs} ${kind === "bucket" ? "bucket calls" : "subrequests"} to join and write, more than the limit of ${most}. Raise \`callLimits.${kind}\` in \`cloudflare()\`'s options, up to the platform's cap.`;
359
- return gitError("RESOURCE_EXHAUSTED", message, {
360
- cause: new SliceRefused(message),
361
- context: { reason: "too-many-store-calls" }
362
- });
434
+ const message = `Indexing needs ${needs} ${kind === "bucket" ? "bucket calls" : "subrequests"} to join and write, more than the limit of ${most}.`;
435
+ return refusedRow(message, raiseCalls(kind), "too-many-store-calls");
363
436
  };
364
437
  /**
365
438
  * The refusal of a read step whose join and puts ran out of the try's `most` calls past its
@@ -368,10 +441,121 @@ const reservePast = (kind, needs, most) => {
368
441
  const reserveShort = (pack, position, most) => {
369
442
  const message = `Pack ${pack}'s slice at ${position} left its join and writes short of ${most} bucket calls: indexReadCallsAfter is too small`;
370
443
  return gitError("RESOURCE_EXHAUSTED", message, {
371
- cause: new SliceRefused(message),
444
+ cause: new SliceRefused(message, pack),
372
445
  context: { reason: "too-many-store-calls" }
373
446
  });
374
447
  };
448
+ /**
449
+ * The most calls the bitmaps step makes once its walks below have spent their bound: the put of
450
+ * the part that keeps the walks the try closed, or a whole build's bitmaps part, charged as
451
+ * `multipart` charges a file of the try's memory, `held` bytes, since each is made in it whole.
452
+ * The step's other calls, and the walks', leave it this many of the try's bounds (#1068).
453
+ */
454
+ const indexBitmapsCallsAfter = (multipart, held) => ({
455
+ bucket: sizedPutCalls(multipart, held),
456
+ store: 0
457
+ });
458
+ /**
459
+ * The refusal of an update whose bitmaps step closed no walk below its layer, and read no object
460
+ * past where its reach part left the walk, within its try's `most` calls of `kind`: the next try
461
+ * would spend them at the same place, so its refusal stands until the host's bounds change (#1068,
462
+ * Q854, Q886).
463
+ */
464
+ /** A whole build's bitmap that no try's calls can make, by the commit or tip it's for. */
465
+ const bitmapUnwritten = (kind, most, position) => {
466
+ const what = kind === "bucket" ? "bucket calls" : "subrequests";
467
+ const message = `${position === void 0 ? "The index's bitmaps" : `The index's bitmap for position ${position}`} can't be made within ${most} ${what}.`;
468
+ return refusedRow(message, raiseCalls(kind), "too-many-store-calls");
469
+ };
470
+ /** A whole build whose bitmaps' parts can't be joined within one try's calls. */
471
+ const bitmapsUnjoined = (needs, most) => {
472
+ const message = `The index's bitmaps need ${needs} bucket calls to join their parts, past the ${most} a try may make.`;
473
+ return refusedRow(message, raiseCalls("bucket"), "too-many-store-calls");
474
+ };
475
+ const reachUnsettled = (kind, most) => {
476
+ const message = `The update's bitmaps can't close one more walk below its layer within ${most} ${kind === "bucket" ? "bucket calls" : "subrequests"}.`;
477
+ return refusedRow(message, raiseCalls(kind), "too-many-store-calls");
478
+ };
479
+ /**
480
+ * A reach part, as big-endian words: the count of walks closed, then each one's position, its
481
+ * EWAH's length and words; then 1 and the cut walk's position, its reads, its set positions' EWAH
482
+ * length and words, its queue's length and how many of the queue's first are commits, or 0 for
483
+ * none; then the queue's IDs, 20 bytes each.
484
+ */
485
+ const reachesBytes = ({ closed, open }) => {
486
+ const set = open === void 0 ? void 0 : ewahOf(open.walk.bits);
487
+ let length = 2 + (set === void 0 ? 0 : 5 + set.length);
488
+ for (const ewah of closed.values()) length += 2 + ewah.length;
489
+ const bytes = new Uint8Array(length * 4 + (open === void 0 ? 0 : open.walk.queue.length * 20));
490
+ const view = new DataView(bytes.buffer);
491
+ let at = 0;
492
+ const put = (words) => {
493
+ for (let word = 0; word < words.length; word += 1) view.setUint32(at + word * 4, words[word] ?? 0);
494
+ at += words.length * 4;
495
+ };
496
+ put([closed.size]);
497
+ for (const [position, ewah] of closed) {
498
+ put([position, ewah.length]);
499
+ put(ewah);
500
+ }
501
+ if (open === void 0 || set === void 0) return bytes;
502
+ put([
503
+ 1,
504
+ open.position,
505
+ open.walk.reads,
506
+ set.length
507
+ ]);
508
+ put(set);
509
+ put([open.walk.queue.length, open.walk.commits]);
510
+ for (const [index, id] of open.walk.queue.entries()) bytes.set(id, at + index * 20);
511
+ return bytes;
512
+ };
513
+ /** The most `reachesBytes` holds of `reaches`: its part, and the cut walk's EWAH beside it. */
514
+ const reachesMostBytes = ({ closed, open }) => {
515
+ const set = open === void 0 ? 0 : ewahMostWords(open.walk.bits.length);
516
+ let length = 2 + (open === void 0 ? 0 : 5 + 2 * set);
517
+ for (const ewah of closed.values()) length += 2 + ewah.length;
518
+ return length * 4 + (open === void 0 ? 0 : open.walk.queue.length * 20);
519
+ };
520
+ /**
521
+ * What a reach part keeps, each walk's set positions over `positions`'s words, each read straight
522
+ * from the part's words: no copy of them whole beside it (#1132).
523
+ */
524
+ const reachesOf = (bytes, words) => {
525
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
526
+ const length = Math.floor(bytes.byteLength / 4);
527
+ const word = (at) => at < length ? view.getUint32(at * 4) : 0;
528
+ const wordsAt = (at, count) => Uint32Array.from({ length: Math.max(0, Math.min(count, length - at)) }, (_, from) => view.getUint32((at + from) * 4));
529
+ const closed = /* @__PURE__ */ new Map();
530
+ let at = 1;
531
+ for (let walk = 0; walk < word(0); walk += 1) {
532
+ const count = word(at + 1);
533
+ closed.set(word(at), wordsAt(at + 2, count));
534
+ at += 2 + count;
535
+ }
536
+ if (word(at) !== 1) return { closed };
537
+ const [position, reads, count] = [
538
+ word(at + 1),
539
+ word(at + 2),
540
+ word(at + 3)
541
+ ];
542
+ const bits = bitmapOf(wordsAt(at + 4, count), words);
543
+ const [queued, commits] = [word(at + 4 + count), word(at + 5 + count)];
544
+ const idsAt = (at + 6 + count) * 4;
545
+ if (bits === void 0 || commits > queued || idsAt + queued * 20 !== bytes.byteLength) return void 0;
546
+ return {
547
+ closed,
548
+ open: {
549
+ position,
550
+ walk: {
551
+ bits,
552
+ queue: Array.from({ length: queued }, (_, index) => bytes.slice(idsAt + index * 20, idsAt + (index + 1) * 20)),
553
+ commits,
554
+ reads
555
+ }
556
+ }
557
+ };
558
+ };
375
559
  /** A try's join of its links, its workspace grown into `allotment` while it runs. */
376
560
  const joinCharged = (links, ranges, region, allotment) => {
377
561
  const bytes = joinBytes(links.size);
@@ -382,7 +566,7 @@ const joinCharged = (links, ranges, region, allotment) => {
382
566
  * their IDs, the SHA-1 of those, and, for the region step, their types, links and commits.
383
567
  * `undefined` once the repo moved under the read.
384
568
  */
385
- const readRegion = (parts, listed, each, skip) => Effect.gen(function* () {
569
+ const readRegion = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, each, skip) {
386
570
  let ids = /* @__PURE__ */ new Uint8Array(1280);
387
571
  let rows = 0;
388
572
  if (!(yield* eachPageAt(parts.store, listed.repo, listed.version, (page) => Effect.gen(function* () {
@@ -412,7 +596,7 @@ const readRegion = (parts, listed, each, skip) => Effect.gen(function* () {
412
596
  * charged to `allotment`: its links as they grow, and each row's ID, type and commit entry and
413
597
  * the row's own bytes while it's parsed.
414
598
  */
415
- const regionStep = (parts, listed, data, allotment) => Effect.gen(function* () {
599
+ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
416
600
  const { bucket } = parts;
417
601
  const files = indexFiles(listed.repo, data.build);
418
602
  const { layout, first, packed } = yield* layoutOf(bucket, listed, data);
@@ -420,7 +604,7 @@ const regionStep = (parts, listed, data, allotment) => Effect.gen(function* () {
420
604
  const links = new SliceLinks((bytes) => allotment.tryGrow(bytes));
421
605
  const types = [];
422
606
  const commits = [];
423
- const parsed = (object, at) => Effect.gen(function* () {
607
+ const parsed = Effect.fnUntraced(function* (object, at) {
424
608
  types.push(typeCodes[object.type]);
425
609
  if (object.type === "blob") return;
426
610
  links.begin(packed + at, object.type);
@@ -455,10 +639,10 @@ const regionStep = (parts, listed, data, allotment) => Effect.gen(function* () {
455
639
  const targets = yield* joinCharged(links, layout.ranges, region, allotment);
456
640
  const slice = data.slices.length;
457
641
  yield* allotment.grow(edgesMostOf(links) + read.rows + graphFileBytes(commits));
458
- const edges = edgesFileOf(files.edges(slice), packed, read.rows, links, targets);
642
+ const edges = edgesFileOf(files.edges(slice, read.rows), packed, read.rows, links, targets);
459
643
  yield* putOnce(bucket, edges.slice.key, edges.bytes);
460
- yield* putOnce(bucket, files.typesPart(slice), Uint8Array.from(types));
461
- yield* putOnce(bucket, files.basesPart(slice), /* @__PURE__ */ new Uint8Array(0));
644
+ yield* putOnce(bucket, files.typesPart(slice, read.rows), Uint8Array.from(types));
645
+ yield* putOnce(bucket, files.basesPart(slice, read.rows), /* @__PURE__ */ new Uint8Array(0));
462
646
  yield* putOnce(bucket, files.region, read.ids);
463
647
  yield* putOnce(bucket, files.regionGraph, writeCommitGraph(commits));
464
648
  return {
@@ -473,7 +657,7 @@ const regionStep = (parts, listed, data, allotment) => Effect.gen(function* () {
473
657
  * The rows the layers below hold, which an update's region leaves at their positions there: the
474
658
  * repo's rows at `listed`'s version, each found among the layers, and kept by ID.
475
659
  */
476
- const heldBelow = (parts, listed, layout, first) => Effect.gen(function* () {
660
+ const heldBelow = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, layout, first) {
477
661
  const read = yield* readRegion(parts, listed);
478
662
  const held = /* @__PURE__ */ new Set();
479
663
  if (read === void 0 || read.rows === 0) return held;
@@ -489,7 +673,7 @@ const regionRowBytes = 256;
489
673
  /** Each of `layers`' graphs, opened at its first graph number. */
490
674
  const belowGraphs = (bucket, repo, layers) => Effect.forEach(layers, (layer) => openIndexGraph(bucket, indexFiles(repo, layer.build).graph, layer.graphFirst));
491
675
  /** The graph step: every pack's `.graph` and the region's, merged. */
492
- const graphStep = (parts, listed, data, allotment) => Effect.gen(function* () {
676
+ const graphStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
493
677
  const files = indexFiles(listed.repo, data.build);
494
678
  const graphs = data.packs.map((id) => isPackId(id) ? packFiles(id).graph : id);
495
679
  if (data.rows > 0) graphs.push(files.regionGraph);
@@ -521,14 +705,14 @@ const graphStep = (parts, listed, data, allotment) => Effect.gen(function* () {
521
705
  * holds to the last, `headReads` at once. A slice holds at most `sliceEntriesMost` positions, so each
522
706
  * read is inside the room `headsBytes` charges for the header reads it stands in for.
523
707
  */
524
- const storedTypesOf = (bucket, files, slices, base) => (positions) => Effect.gen(function* () {
708
+ const storedTypesOf = (bucket, files, slices, base) => Effect.fnUntraced(function* (positions) {
525
709
  const codes = /* @__PURE__ */ new Map();
526
710
  const reads = slices.flatMap((slice, number) => {
527
711
  const held = positions.filter((position) => base + position >= slice.first && base + position < slice.first + slice.positions);
528
712
  if (held.length === 0) return [];
529
713
  const from = Math.min(...held) + base - slice.first;
530
714
  const length = Math.max(...held) + base - slice.first - from + 1;
531
- return [Effect.map(readExactly(bucket, files.typesPart(number), from, length), (types) => {
715
+ return [Effect.map(readExactly(bucket, files.typesPart(number, slice.positions), from, length), (types) => {
532
716
  for (const position of held) {
533
717
  const code = types[position + base - slice.first - from];
534
718
  if (code !== void 0) codes.set(position, code);
@@ -547,10 +731,15 @@ const storedTypesOf = (bucket, files, slices, base) => (positions) => Effect.gen
547
731
  * the try's bound less `indexReadCallsAfter`, then its join and puts over the whole bound; a slice
548
732
  * that settles nothing is read again alone, and one alone that can't is refused (#681).
549
733
  */
550
- const readStep = (parts, listed, data, allotment) => Effect.gen(function* () {
734
+ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
551
735
  const { counted } = parts;
552
736
  const counts = data.packs.map((id) => listed.packs.find((each) => each.id === id)?.objects ?? 0);
553
- const reserve = indexReadCallsAfter(counts);
737
+ const bounds = parts.bounds ?? sliceBounds;
738
+ const entries = data.narrowed?.entries ?? bounds.entries ?? 65536;
739
+ const reserve = indexReadCallsAfter(counts, parts.bucket.multipart, {
740
+ entries,
741
+ held: allotment.bytes + allotment.growable
742
+ });
554
743
  const subrequestsAfter = reserve.bucket + reserve.store;
555
744
  if (counted !== void 0 && reserve.bucket >= counted.most.bucket) return yield* Effect.fail(reservePast("bucket", reserve.bucket, counted.most.bucket));
556
745
  if (counted !== void 0 && subrequestsAfter >= counted.most.subrequests) return yield* Effect.fail(reservePast("subrequests", subrequestsAfter, counted.most.subrequests));
@@ -560,11 +749,12 @@ const readStep = (parts, listed, data, allotment) => Effect.gen(function* () {
560
749
  }).bucket;
561
750
  let through = lower;
562
751
  const bucket = {
563
- multipart: lower.multipart,
752
+ ...lower,
564
753
  put: (key, body, options) => through.put(key, body, options),
565
- read: (key, range, options) => through.read(key, range, options),
566
- delete: (key, options) => through.delete(key, options),
567
- list: (prefix, page, options) => through.list(prefix, page, options)
754
+ read: (key, range) => through.read(key, range),
755
+ remove: (key) => through.remove(key),
756
+ removeMany: (keys, options) => through.removeMany(keys, options),
757
+ list: (prefix, page) => through.list(prefix, page)
568
758
  };
569
759
  const whole = counted?.most.bucket ?? Number.POSITIVE_INFINITY;
570
760
  const files = indexFiles(listed.repo, data.build);
@@ -573,8 +763,6 @@ const readStep = (parts, listed, data, allotment) => Effect.gen(function* () {
573
763
  position: data.position
574
764
  };
575
765
  const opened = yield* Effect.result(cutAtSpent(layoutOf(bucket, listed, data)));
576
- const bounds = parts.bounds ?? sliceBounds;
577
- const entries = data.narrowed?.entries ?? bounds.entries ?? 65536;
578
766
  if (Result.isFailure(opened)) {
579
767
  const spent = spentOf(opened.failure);
580
768
  if (spent === void 0) return yield* Effect.fail(opened.failure);
@@ -597,10 +785,10 @@ const readStep = (parts, listed, data, allotment) => Effect.gen(function* () {
597
785
  ...bounds,
598
786
  entries
599
787
  },
600
- blocks: new PackBlocks(bucket, allotment.room(floors.blocks, most.blocks)),
788
+ blocks: new PackBlocks(bucket, allotment.room(floors.blocks, most.blocks, true)),
601
789
  cache: new IndexerCache(allotment.room(floors.cache, most.cache)),
602
790
  links,
603
- allot: outsideOn(allotment),
791
+ allot: outsideOn((bytes) => allotment.grow(bytes)),
604
792
  storedTypes: storedTypesOf(bucket, files, data.slices, pack.base),
605
793
  calls: counted === void 0 ? void 0 : {
606
794
  made: () => counted.made().bucket,
@@ -617,10 +805,11 @@ const readStep = (parts, listed, data, allotment) => Effect.gen(function* () {
617
805
  const edges = yield* Effect.gen(function* () {
618
806
  const targets = yield* joinCharged(links, ranges, region, allotment);
619
807
  yield* allotment.grow(edgesMostOf(links) + slice.bases.length * 4);
620
- const made = edgesFileOf(files.edges(number), first, slice.types.length, links, targets);
808
+ const positions = slice.types.length;
809
+ const made = edgesFileOf(files.edges(number, positions), first, positions, links, targets);
621
810
  yield* putOnce(bucket, made.slice.key, made.bytes);
622
- yield* putOnce(bucket, files.typesPart(number), slice.types);
623
- yield* putOnce(bucket, files.basesPart(number), wordsBytes(slice.bases));
811
+ yield* putOnce(bucket, files.typesPart(number, positions), slice.types);
812
+ yield* putOnce(bucket, files.basesPart(number, positions), wordsBytes(slice.bases));
624
813
  return made;
625
814
  }).pipe(cutAtSpent, Effect.catchIf((error) => spentOf(error) !== void 0, () => Effect.fail(reserveShort(data.packs[data.pack] ?? "", at.position, whole))));
626
815
  const slices = [...data.slices, {
@@ -656,7 +845,7 @@ const readStep = (parts, listed, data, allotment) => Effect.gen(function* () {
656
845
  * twice log2 of the span in tries, and the entries past its span are read in full slices (the
657
846
  * coordinator, 22 Nov). Only a slice of one that settles nothing is refused (#681).
658
847
  */
659
- const Narrowed = Schema.Struct({
848
+ const Narrowed = /* @__PURE__ */ Schema.Struct({
660
849
  entries: Count,
661
850
  to: Count
662
851
  });
@@ -688,6 +877,26 @@ const byPosition = (data) => [...data.slices.entries()].sort(([, a], [, b]) => a
688
877
  * ask one question (#814).
689
878
  */
690
879
  const wantsBitmap = (position, bitmaps) => position !== 4294967295 && !bitmaps.has(position);
880
+ /** What an update holds for each of its entries: its number, position and ID. */
881
+ const entriesHeld = (count) => count * 32;
882
+ /**
883
+ * The positions of the commits below a layer that its own commits, `rows` from graph number
884
+ * `first`, name as a first or second parent: an update walks below from these before any other
885
+ * position, since what one reaches needs no walk of its own. Their order among themselves
886
+ * changes no read, as a later walk stops at an earlier one's closed bitmap. An octopus' later
887
+ * parents aren't among them, as one missed costs only its walk.
888
+ */
889
+ const entriesOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows, first, graph, layout, allotment) {
890
+ const numbers = /* @__PURE__ */ new Set();
891
+ for (let at = 0; at < rows.length; at += 3) for (const parent of [rows[at] ?? 2147483647, rows[at + 1] ?? 2147483647]) if ((parent & 2147483648) === 0 && parent < first) numbers.add(parent);
892
+ if (numbers.size === 0) return [];
893
+ yield* allotment.grow(entriesHeld(numbers.size));
894
+ const below = [...numbers];
895
+ const positions = yield* layout.positionsOf(yield* graph.idsAt(below), below.length);
896
+ const found = [];
897
+ for (const position of positions) if (position !== 4294967295) found.push(position);
898
+ return found;
899
+ });
691
900
  const chooseCommits = (rows, tips, first = 0) => {
692
901
  const commits = rows.length / 3;
693
902
  const walked = new Uint8Array(commits);
@@ -709,18 +918,107 @@ const chooseCommits = (rows, tips, first = 0) => {
709
918
  * own commits down their first parents. Its walk ORs a stored bitmap it meets below its layer,
710
919
  * and closes any other position there by reading its objects. `undefined` when one won't close
711
920
  * within `walkMost`: the update gives way to a whole build.
921
+ *
922
+ * With `parts.counted`, all it reads and writes is through the try's bound less
923
+ * `indexBitmapsCallsAfter`. Where that runs out, the walks below the try closed go in a reach part
924
+ * through the whole bound, each with every earlier try's, and the next try ORs them with no walk.
925
+ * The walk it was in goes there too, cut where the bound ran out, and the next try goes on from
926
+ * it. A try that closed no walk and read no object further refuses, as the next would spend its
927
+ * calls at the same place (#1068).
928
+ * A try that put a part ends as `more`, which counts none of the job's `indexTries` failures, so
929
+ * an update whose walks below take more than that many tries still lands.
930
+ *
931
+ * Each part is the build's scratch, under its ID: once its row lands, prune deletes the build's
932
+ * scratch and keeps its stored files; a build no row names, as when its job is refused, loses all
933
+ * its files to prune after its grace.
712
934
  */
713
- const bitmapsStep = (parts, listed, data, input, allotment) => Effect.gen(function* () {
714
- const { bucket } = parts;
935
+ const bitmapsStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, input, allotment) {
936
+ const { counted } = parts;
937
+ const reserve = indexBitmapsCallsAfter(parts.bucket.multipart, allotment.bytes + allotment.growable);
938
+ const subrequestsAfter = reserve.bucket + reserve.store;
939
+ if (counted !== void 0 && reserve.bucket >= counted.most.bucket) return yield* Effect.fail(reservePast("bucket", reserve.bucket, counted.most.bucket));
940
+ if (counted !== void 0 && subrequestsAfter >= counted.most.subrequests) return yield* Effect.fail(reservePast("subrequests", subrequestsAfter, counted.most.subrequests));
941
+ const lower = counted === void 0 ? void 0 : counted.within({
942
+ bucket: counted.most.bucket - reserve.bucket,
943
+ subrequests: counted.most.subrequests - subrequestsAfter
944
+ });
945
+ const walks = {
946
+ closed: /* @__PURE__ */ new Map(),
947
+ fresh: 0
948
+ };
949
+ const written = yield* Effect.result(cutAtSpent(bitmapsWritten(parts, lower, listed, data, input, allotment, walks)));
950
+ if (Result.isSuccess(written)) return written.success;
951
+ const spent = spentOf(written.failure);
952
+ if (spent === void 0) return yield* Effect.fail(written.failure);
953
+ const most = counted?.most[spent.bound] ?? spent.most;
954
+ if (data.below.length === 0) return yield* Effect.fail(bitmapUnwritten(spent.bound, most));
955
+ if (walks.fresh === 0 && !readFurther(walks)) return yield* Effect.fail(reachUnsettled(spent.bound, most));
956
+ const part = data.reaches ?? 0;
957
+ const reaches = { closed: walks.closed };
958
+ if (walks.cut !== void 0) reaches.open = walks.cut;
959
+ const partBytes = reachesMostBytes(reaches);
960
+ yield* allotment.grow(partBytes);
961
+ yield* putOnce(parts.bucket, indexFiles(listed.repo, data.build).reaches(part), reachesBytes(reaches)).pipe(Effect.ensuring(Effect.sync(() => allotment.shrink(partBytes))));
962
+ yield* Effect.logInfo(`git.index's bitmaps step for repo ${listed.repo} spent its try's calls: ${walks.fresh} walks below closed, ${walks.cut === void 0 ? "none cut" : `one cut at ${walks.cut.walk.reads} reads`}, the next try goes on`);
963
+ return {
964
+ ...data,
965
+ reaches: part + 1
966
+ };
967
+ });
968
+ /**
969
+ * Whether a try's cut walk went past where its reach part carried it in: an object read further,
970
+ * or a position set that the carried walk hadn't, as a stored bitmap ORed in a batch the bound
971
+ * cut. A try that did neither would spend its calls at the same place again.
972
+ */
973
+ const readFurther = ({ carried, cut }) => {
974
+ if (cut === void 0) return false;
975
+ const from = carried?.position === cut.position ? carried.walk : void 0;
976
+ if (cut.walk.reads > (from?.reads ?? 0)) return true;
977
+ return cut.walk.bits.some((word, at) => (word & ~(from?.bits[at] ?? 0)) !== 0);
978
+ };
979
+ /**
980
+ * The most a bitmaps step keeps of its layout's `.idx` and `.pos` ranges for its walks' joins:
981
+ * s1m's whole join, 23,994,800 B at its 1M positions, fits (M5). Past it, the step keeps what it
982
+ * read first and lets the rest through.
983
+ */
984
+ const bitmapsJoinMost = 25165824;
985
+ /**
986
+ * What a bitmaps step holds for the join ranges it keeps, over packs of `objects`: each pack's
987
+ * `.idx` and `.pos`, 20 B and 4 B a rank, and an entry for each of a chunk's two ranges, at most
988
+ * `bitmapsJoinMost`. It's what a join can read, from the counts alone, never what a try did.
989
+ */
990
+ const bitmapsJoinHeld = (objects) => Math.min(bitmapsJoinMost, objects.reduce((sum, count) => sum + count * 24 + Math.ceil(count / rangeRanks) * 2 * 320, 0));
991
+ /**
992
+ * The step's kept join ranges over `bucket`, charged at `bitmapsJoinHeld` before any read and let
993
+ * go as its scope ends, however the step ends: each walk below's batch joins every covered pack's
994
+ * ranges, which are read once a step this way, not once a batch.
995
+ */
996
+ const keptJoins = (bucket, listed, data, allotment) => {
997
+ const covered = new Set([...data.below, spanOf(data)].flatMap((layer) => layer.groups.flatMap((group) => group.packs)));
998
+ const held = bitmapsJoinHeld(listed.packs.filter(({ id }) => covered.has(id)).map((pack) => pack.objects));
999
+ return Effect.acquireRelease(Effect.map(allotment.grow(held), () => rangeCached(bucket, held, { evict: false })), (ranges) => Effect.sync(() => {
1000
+ ranges.clear();
1001
+ allotment.shrink(held);
1002
+ }));
1003
+ };
1004
+ /** `bitmapsStep`'s reads and writes, through `lower` when given, each walk below in `walks`. */
1005
+ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower, listed, data, input, allotment, walks) {
1006
+ const bucket = lower?.bucket ?? parts.bucket;
715
1007
  const files = indexFiles(listed.repo, data.build);
716
- const { layout, first } = yield* layoutOf(bucket, listed, data);
1008
+ const joins = data.below.length === 0 ? void 0 : yield* keptJoins(bucket, listed, data, allotment);
1009
+ const { layout, first } = joins === void 0 ? yield* layoutOf(bucket, listed, data) : yield* layoutOf(joins.bucket, listed, data, { cached: true });
717
1010
  const { positions } = layout;
718
1011
  const graphFirst = graphFirstOf(data.below);
719
1012
  const own = yield* openIndexGraph(bucket, files.graph, graphFirst);
720
1013
  const graph = openGraphLayers([...yield* belowGraphs(bucket, listed.repo, data.below), own]);
721
1014
  yield* allotment.grow(own.commits * 12);
722
1015
  const rows = yield* own.rows;
723
- const stored = yield* openLayerBitmaps(bucket, listed.repo, data.below);
1016
+ let entries;
1017
+ const entriesBelow = Effect.gen(function* () {
1018
+ entries ??= yield* entriesOf(rows, graphFirst, graph, layout, allotment);
1019
+ return entries;
1020
+ });
1021
+ const stored = yield* openLayerBitmaps(bucket, listed.repo, data.below, allotment);
724
1022
  const tips = [...new Set(input.tips)];
725
1023
  const tipIds = idsOf(tips);
726
1024
  const tipPositions = yield* layout.positionsOf(tipIds, tips.length);
@@ -757,22 +1055,61 @@ const bitmapsStep = (parts, listed, data, input, allotment) => Effect.gen(functi
757
1055
  number: noNumber,
758
1056
  generation: latest + 1
759
1057
  });
1058
+ const words = bitmapWords(positions);
1059
+ const part = data.reaches ?? 0;
1060
+ const { closed } = walks;
1061
+ if (data.below.length > 0 && part > 0) {
1062
+ const kept = yield* keptReaches(bucket, files.reaches(part - 1), words, allotment);
1063
+ for (const [position, ewah] of kept.closed) closed.set(position, ewah);
1064
+ if (kept.open !== void 0) walks.carried = kept.open;
1065
+ }
1066
+ const buffer = data.below.length === 0 ? 0 : words;
1067
+ const walking = new Uint32Array(buffer);
1068
+ const decoded = new Uint32Array(buffer);
1069
+ if (buffer > 0) yield* allotment.grow(buffer * 8);
1070
+ const readyAt = Effect.fnUntraced(function* (position) {
1071
+ const ewah = closed.get(position);
1072
+ if (ewah === void 0) return yield* stored.bitmapAt(position);
1073
+ if (!orEwah(ewah, decoded.fill(0))) return yield* Effect.fail(lost(`${files.reaches(part - 1)}'s walk from ${position} is unreadable`));
1074
+ return decoded;
1075
+ });
760
1076
  const reach = parts.objects === void 0 ? void 0 : {
761
1077
  layout,
762
- bitmaps: stored,
763
- read: yield* parts.objects(listed),
764
- allotment
1078
+ bitmaps: {
1079
+ ...stored,
1080
+ bitmapAt: readyAt
1081
+ },
1082
+ read: yield* parts.objects(listed, allotment, ...lower === void 0 ? [] : [lower]),
1083
+ allotment,
1084
+ bits: walking
765
1085
  };
766
1086
  const below = data.below.length === 0 ? void 0 : {
767
1087
  first,
768
- reach: (position) => Effect.gen(function* () {
769
- const bitmap = yield* stored.bitmapAt(position);
1088
+ entries: entriesBelow,
1089
+ ready: readyAt,
1090
+ reach: Effect.fnUntraced(function* (position) {
1091
+ const bitmap = yield* readyAt(position);
770
1092
  if (bitmap !== void 0 || reach === void 0) return bitmap;
771
- return yield* reachOf(reach, [{ position }]);
1093
+ const carry = { cut: (walk) => {
1094
+ walks.cut = {
1095
+ position,
1096
+ walk
1097
+ };
1098
+ } };
1099
+ if (walks.carried?.position === position) carry.from = walks.carried.walk;
1100
+ const walked = yield* reachOf(reach, [{ position }], carry);
1101
+ if (walked === void 0) return void 0;
1102
+ const most = ewahMostWords(walked.length) * 4;
1103
+ yield* allotment.grow(8 + most);
1104
+ const ewah = ewahOf(walked);
1105
+ allotment.shrink(most - ewah.byteLength);
1106
+ closed.set(position, ewah);
1107
+ walks.fresh += 1;
1108
+ return walked;
772
1109
  })
773
1110
  };
774
1111
  const slices = byPosition(data).map(([number, slice]) => ({
775
- key: files.edges(number),
1112
+ key: files.edges(number, slice.positions),
776
1113
  first: slice.first,
777
1114
  positions: slice.positions,
778
1115
  sources: slice.sources,
@@ -792,6 +1129,7 @@ const bitmapsStep = (parts, listed, data, input, allotment) => Effect.gen(functi
792
1129
  kept: Math.min(madeMost, madeAll)
793
1130
  };
794
1131
  if (below !== void 0) bitmapsInput.below = below;
1132
+ if (data.below.length === 0 && lower !== void 0) return yield* bitmapsCutTry(parts, files, data, bitmapsInput, allotment);
795
1133
  const already = yield* storedSize(bucket, files.bitmaps);
796
1134
  const written = already === void 0 ? yield* writeBitmaps(bitmapsInput) : yield* storedBitmaps(bucket, files.bitmaps, positions, already);
797
1135
  if (written === void 0) return void 0;
@@ -801,13 +1139,113 @@ const bitmapsStep = (parts, listed, data, input, allotment) => Effect.gen(functi
801
1139
  bitmaps: written.count,
802
1140
  table: written.table
803
1141
  };
1142
+ }, Effect.scoped);
1143
+ /**
1144
+ * One try of a whole build's bitmaps under its bound (#1068): the next part, those of the order
1145
+ * from where the last part ended, through the try's bound less `indexBitmapsCallsAfter`, then put
1146
+ * through the whole bound. Once the parts hold the order, the try joins them into `.bitmaps`. A
1147
+ * bitmap the bound cuts is left whole for the next try, and a try that makes none refuses, as the
1148
+ * next would spend its calls at the same place.
1149
+ */
1150
+ const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files, data, input, allotment) {
1151
+ const order = bitmapOrder(input.chosen);
1152
+ const ordered = orderKey(order);
1153
+ const cut = data.bitmapsCut?.order === ordered ? data.bitmapsCut : {
1154
+ order: ordered,
1155
+ done: 0,
1156
+ parts: []
1157
+ };
1158
+ if (cut.done >= order.length) return yield* bitmapsJoined(parts, files, data, cut, input.positions, allotment);
1159
+ yield* allotment.grow(partBytesMost);
1160
+ const key = files.bitmapsPart(cut.order, cut.parts.length);
1161
+ const landed = yield* readWhole(parts.bucket, key);
1162
+ if (landed !== void 0) {
1163
+ const count = yield* partCount(key, landed);
1164
+ return {
1165
+ ...data,
1166
+ bitmapsCut: next(cut, count)
1167
+ };
1168
+ }
1169
+ const into = new BitmapsPart(partBytesMost);
1170
+ const made = yield* Effect.result(cutAtSpent(writeBitmaps({
1171
+ ...input,
1172
+ part: {
1173
+ from: cut.done,
1174
+ into
1175
+ }
1176
+ })));
1177
+ if (Result.isFailure(made)) {
1178
+ const spent = spentOf(made.failure);
1179
+ if (spent === void 0) return yield* Effect.fail(made.failure);
1180
+ if (into.count === 0) {
1181
+ const most = parts.counted?.most[spent.bound] ?? spent.most;
1182
+ return yield* Effect.fail(bitmapUnwritten(spent.bound, most, order[cut.done]?.position ?? 0));
1183
+ }
1184
+ } else if (into.count === 0) return yield* Effect.fail(lost(`No bitmap of ${input.positions} positions fits a part`));
1185
+ const count = yield* partPut(parts.bucket, key, into);
1186
+ if (count === void 0) return data;
1187
+ return {
1188
+ ...data,
1189
+ bitmapsCut: next(cut, count)
1190
+ };
1191
+ });
1192
+ /** `cut` with its next part, of `count` bitmaps, made. */
1193
+ const next = (cut, count) => ({
1194
+ order: cut.order,
1195
+ done: cut.done + count,
1196
+ parts: [...cut.parts, count]
1197
+ });
1198
+ /** How many bitmaps the part at `key` holds, as `bytes` read. */
1199
+ const partCount = (key, bytes) => {
1200
+ const held = partBitmaps(bytes);
1201
+ return held === void 0 ? Effect.fail(lost(`${key} is unreadable`)) : Effect.succeed(held.length);
1202
+ };
1203
+ /**
1204
+ * A part's put, and how many bitmaps it holds, or `undefined` where another try put one at its key
1205
+ * since this try looked. Reading that one would pass the try's bound, which kept one call for the
1206
+ * put alone.
1207
+ */
1208
+ const partPut = (bucket, key, part) => {
1209
+ const bytes = part.finish();
1210
+ const count = part.count;
1211
+ return bucketPut(bucket, key, bytes).pipe(Effect.as(count), Effect.catchIf(alreadyThere, () => Effect.succeed(void 0)));
1212
+ };
1213
+ /**
1214
+ * A whole build's `.bitmaps`, its parts joined in order through one put: the same bytes one try's
1215
+ * `writeBitmaps` would put. Its calls are one read a part and the put's own, all known before it
1216
+ * reads, so past the try's bound it refuses before its first call.
1217
+ */
1218
+ const bitmapsJoined = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files, data, cut, positions, allotment) {
1219
+ const { bucket, counted } = parts;
1220
+ const atMost = bitmapsMostBytes(positions, cut.done);
1221
+ const needs = cut.parts.length + Math.ceil(atMost / uploadPartBytes) + 2;
1222
+ if (counted !== void 0 && needs > counted.most.bucket - counted.made().bucket) return yield* Effect.fail(bitmapsUnjoined(needs, counted.most.bucket));
1223
+ const already = yield* storedSize(bucket, files.bitmaps);
1224
+ const written = already === void 0 ? yield* Effect.scoped(Effect.gen(function* () {
1225
+ yield* allotment.grow(partBytesMost + Math.min(atMost, uploadPartBytes));
1226
+ const put = yield* bitmapsPut(bucket, files.bitmaps, positions, cut.done);
1227
+ for (const [number, held] of cut.parts.entries()) {
1228
+ const key = files.bitmapsPart(cut.order, number);
1229
+ const bitmaps = partBitmaps(yield* readScratch(bucket, key));
1230
+ if (bitmaps?.length !== held) return yield* Effect.fail(lost(`${key} is unreadable`));
1231
+ for (const bitmap of bitmaps) yield* put.addBytes(bitmap.position, bitmap.number, bitmap.bytes);
1232
+ }
1233
+ return yield* put.finish;
1234
+ })) : yield* storedBitmaps(bucket, files.bitmaps, positions, already);
1235
+ const { bitmapsCut: _, ...rest } = data;
1236
+ return {
1237
+ ...rest,
1238
+ step: "files",
1239
+ bitmaps: written.count,
1240
+ table: written.table
1241
+ };
804
1242
  });
805
1243
  /**
806
1244
  * The files step: `.types` and `.bases`, each its parts streamed in position order, and each
807
1245
  * found there on its own when a try that died after its put landed is done again. It holds a
808
1246
  * part as read, its words, and what it writes of it, charged to `allotment` first.
809
1247
  */
810
- const filesStep = (parts, listed, data, allotment) => Effect.gen(function* () {
1248
+ const filesStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
811
1249
  const { bucket } = parts;
812
1250
  const files = indexFiles(listed.repo, data.build);
813
1251
  const positions = coveredPositions(listed, data);
@@ -819,18 +1257,16 @@ const filesStep = (parts, listed, data, allotment) => Effect.gen(function* () {
819
1257
  const types = Effect.gen(function* () {
820
1258
  const writer = new TypesWriter(positions);
821
1259
  const put = yield* startPut(bucket, files.types, { size: indexTypesBytes(positions) });
822
- yield* Effect.addFinalizer((exit) => Exit.isFailure(exit) ? put.abort : Effect.void);
823
1260
  yield* put.write(writer.head());
824
- for (const [number] of ordered) yield* put.write(yield* writer.part(yield* readScratch(bucket, files.typesPart(number))));
1261
+ for (const [number, slice] of ordered) yield* put.write(yield* writer.part(yield* readScratch(bucket, files.typesPart(number, slice.positions))));
825
1262
  yield* put.write(yield* writer.end());
826
1263
  yield* put.finish;
827
1264
  });
828
1265
  const bases = Effect.gen(function* () {
829
1266
  const writer = new BasesWriter(every, deltas);
830
1267
  const put = yield* startPut(bucket, files.bases, { size: indexBasesBytes(every, deltas) });
831
- yield* Effect.addFinalizer((exit) => Exit.isFailure(exit) ? put.abort : Effect.void);
832
1268
  yield* put.write(writer.head());
833
- for (const [number] of ordered) yield* put.write(yield* writer.rows(wordsOf(yield* readScratch(bucket, files.basesPart(number)))));
1269
+ for (const [number, slice] of ordered) yield* put.write(yield* writer.rows(wordsOf(yield* readScratch(bucket, files.basesPart(number, slice.positions)))));
834
1270
  yield* put.write(yield* writer.end());
835
1271
  yield* put.finish;
836
1272
  });
@@ -849,14 +1285,21 @@ const rowsOfLayer = (layer) => layer.groups.reduce((sum, group) => sum + group.r
849
1285
  /**
850
1286
  * The most bucket calls `mergeStep` makes once its layers' graphs are open, each bound from its
851
1287
  * merging layers alone, so a try that can't make them refuses before it reads (the core EM's condition 3
852
- * on part 2). A file a try that died already put makes fewer.
1288
+ * on part 2). A file a try that died already put makes fewer. Its `.graph`, `.types`, `.bases` and
1289
+ * region are each told their size, so charged as `multipart` charges a put of it; its `.bitmaps`
1290
+ * goes up with no length told, so in `multipart`'s parts, each a call, beside its `begin` and `end`.
853
1291
  */
854
- const mergeCallsAfterOpen = (merging) => {
1292
+ const mergeCallsAfterOpen = (merging, multipart) => {
855
1293
  const { layers, octopus, packs, tips } = merging;
856
1294
  const chunks = (count, size) => Math.ceil(count / size);
857
1295
  const commits = layers.reduce((sum, layer) => sum + layer.commits, 0);
1296
+ const bitmaps = layers.reduce((sum, layer) => sum + layer.bitmaps, 0);
858
1297
  const passes = octopus.some((each) => each > 0) ? 4 : 3;
859
- let calls = 8 + (layers.some((layer) => rowsOfLayer(layer) > 0) ? 1 : 0);
1298
+ const positions = merging.positions ?? firstOf(layers);
1299
+ const deltas = merging.deltas ?? layers.reduce((sum, layer) => sum + layer.deltas, 0);
1300
+ const rows = layers.reduce((sum, layer) => sum + rowsOfLayer(layer), 0);
1301
+ const entries = octopus.reduce((sum, each) => sum + each, 0);
1302
+ let calls = 4 + sizedPutCalls(multipart, indexGraphBytes(commits, entries)) + sizedPutCalls(multipart, indexTypesBytes(positions)) + sizedPutCalls(multipart, indexBasesBytes(positions, deltas)) + streamedPutCalls(multipart, bitmapsMostBytes(positions, bitmaps)) + (rows > 0 ? sizedPutCalls(multipart, rows * 20) : 0);
860
1303
  for (const [at, layer] of layers.entries()) {
861
1304
  const graphed = chunks(layer.commits, graphChunk);
862
1305
  if (rowsOfLayer(layer) > 0) calls += 2;
@@ -900,16 +1343,14 @@ const mergeHeldMost = (merging) => {
900
1343
  };
901
1344
  /**
902
1345
  * The refusal of a merge that can't fit a try's bound or its instance's memory: the next try
903
- * would come to the same, so its row waits as one for spent tries does, its layers kept.
1346
+ * would come to the same, so its refusal stands until the host's bounds change, its layers kept
1347
+ * (Q886).
904
1348
  */
905
1349
  const mergePast = (needs, what, most, raise) => {
906
- const message = `Merging the index's layers needs ${needs} ${what}, more than the limit of ${most}. ${raise}`;
907
- return gitError("RESOURCE_EXHAUSTED", message, {
908
- cause: new SliceRefused(message),
909
- context: { reason: what === "bytes" ? "too-large" : "too-many-store-calls" }
910
- });
1350
+ const message = `Merging the index's layers needs ${needs} ${what}, more than the limit of ${most}.`;
1351
+ return refusedRow(message, raise, what === "bytes" ? "too-large" : "too-many-store-calls");
911
1352
  };
912
- const raiseCalls = (kind) => `Raise \`callLimits.${kind}\` in \`cloudflare()\`'s options, up to the platform's cap.`;
1353
+ const raiseCalls = (kind) => `Raise \`callLimits.${kind}\` in \`Cloudflare.layer\`'s options, up to the platform's cap.`;
913
1354
  /** A refusal when `needs` more calls are past what the try has left of its bound. */
914
1355
  const callsPast = (parts, needs) => {
915
1356
  const { counted } = parts;
@@ -918,7 +1359,7 @@ const callsPast = (parts, needs) => {
918
1359
  for (const kind of ["bucket", "subrequests"]) if (made[kind] + needs > counted.most[kind]) return mergePast(made[kind] + needs, `${kind === "bucket" ? "bucket calls" : "subrequests"}`, counted.most[kind], raiseCalls(kind));
919
1360
  };
920
1361
  /** The merged region's digest, its IDs each layer's in turn, put once. */
921
- const mergedRegion = (bucket, repo, layers, key) => Effect.gen(function* () {
1362
+ const mergedRegion = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, repo, layers, key) {
922
1363
  const regions = yield* Effect.forEach(layers, (layer) => rowsOfLayer(layer) === 0 ? Effect.succeed(/* @__PURE__ */ new Uint8Array(0)) : readScratch(bucket, indexFiles(repo, layer.build).region));
923
1364
  const region = new Uint8Array(regions.reduce((sum, ids) => sum + ids.byteLength, 0));
924
1365
  let at = 0;
@@ -936,11 +1377,9 @@ const mergedRegion = (bucket, repo, layers, key) => Effect.gen(function* () {
936
1377
  * each layer's runs, the union gone once they're chosen. Only a tip with a stored bitmap is
937
1378
  * ORed, so its lists are the bitmaps' at most.
938
1379
  */
939
- const liveBitmaps = (layout, stored, tips, positions) => Effect.gen(function* () {
1380
+ const liveBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (layout, stored, tips, positions) {
940
1381
  const live = new Uint32Array(bitmapWords(positions));
941
- const lookups = lookupCalls(tips.length, layout.ranges.map((pack) => pack.count));
942
- const searchedUpTo = lookups.searched <= lookups.joined ? tips.length : 0;
943
- const found = yield* layout.positionsOf(idsOf(tips), tips.length, searchedUpTo);
1382
+ const found = yield* layout.positionsOf(idsOf(tips), tips.length);
944
1383
  const bitmapped = [];
945
1384
  for (const position of found) if (position !== 4294967295 && stored.has(position)) bitmapped.push(position);
946
1385
  yield* stored.orInto(bitmapped, live);
@@ -952,7 +1391,7 @@ const liveBitmaps = (layout, stored, tips, positions) => Effect.gen(function* ()
952
1391
  * moves them, or where they were. A file a try that died already put is kept. Its caller charges
953
1392
  * the bitmaps' entries, `mergeEntryBytes` each; the copy charges its own.
954
1393
  */
955
- const copyMergedBitmaps = (input) => Effect.gen(function* () {
1394
+ const copyMergedBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
956
1395
  const { bucket, files, positions, kept } = input;
957
1396
  const stored = yield* storedSize(bucket, files.bitmaps);
958
1397
  if (stored !== void 0) return yield* storedBitmaps(bucket, files.bitmaps, positions, stored);
@@ -1001,7 +1440,7 @@ const copyMergedBitmaps = (input) => Effect.gen(function* () {
1001
1440
  * `mergeHeldMost`: past the try's bound, or past what the instance allots, it refuses before it
1002
1441
  * reads, and its row keeps the layers as a refusal for spent tries does (part 2's condition 3).
1003
1442
  */
1004
- const mergeStep = (parts, listed, data, input, allotment) => Effect.gen(function* () {
1443
+ const mergeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, input, allotment) {
1005
1444
  const { bucket } = parts;
1006
1445
  const { repo } = listed;
1007
1446
  const layers = data.below;
@@ -1020,10 +1459,11 @@ const mergeStep = (parts, listed, data, input, allotment) => Effect.gen(function
1020
1459
  packs,
1021
1460
  tips: tips.length
1022
1461
  };
1023
- const past = callsPast(parts, mergeCallsAfterOpen(merging));
1462
+ const past = callsPast(parts, mergeCallsAfterOpen(merging, bucket.multipart));
1024
1463
  if (past !== void 0) return yield* Effect.fail(past);
1025
1464
  const held = mergeHeldMost(merging);
1026
- const tooLarge = mergePast(held, "bytes", parts.budget.total, "Raise `PacksOptions.memory`.");
1465
+ const most = parts.budget.mostOf(true);
1466
+ const tooLarge = mergePast(held, "bytes", most, "Raise `PacksOptions.memory`.");
1027
1467
  yield* allotment.grow(held, tooLarge);
1028
1468
  allotment.shrink(held);
1029
1469
  const rows = layers.reduce((sum, layer) => sum + rowsOfLayer(layer), 0);
@@ -1057,7 +1497,6 @@ const mergeStep = (parts, listed, data, input, allotment) => Effect.gen(function
1057
1497
  const types = Effect.gen(function* () {
1058
1498
  const writer = new TypesWriter(positions);
1059
1499
  const put = yield* startPut(bucket, files.types, { size: indexTypesBytes(positions) });
1060
- yield* Effect.addFinalizer((exit) => Exit.isFailure(exit) ? put.abort : Effect.void);
1061
1500
  yield* put.write(writer.head());
1062
1501
  for (const layer of layers) {
1063
1502
  const types = yield* openTypes(bucket, indexFiles(repo, layer.build).types, layer.positions);
@@ -1072,7 +1511,6 @@ const mergeStep = (parts, listed, data, input, allotment) => Effect.gen(function
1072
1511
  const bases = Effect.gen(function* () {
1073
1512
  const writer = new BasesWriter(positions, deltas);
1074
1513
  const put = yield* startPut(bucket, files.bases, { size: indexBasesBytes(positions, deltas) });
1075
- yield* Effect.addFinalizer((exit) => Exit.isFailure(exit) ? put.abort : Effect.void);
1076
1514
  yield* put.write(writer.head());
1077
1515
  for (const layer of layers) {
1078
1516
  const key = indexFiles(repo, layer.build).bases;
@@ -1103,14 +1541,14 @@ const mergeStep = (parts, listed, data, input, allotment) => Effect.gen(function
1103
1541
  * before `from`; and the scratch of a build kept for its stored files alone. Answers when the next
1104
1542
  * file it kept is due: `at` itself once it has deleted `pruneMost`, with more left to look at.
1105
1543
  */
1106
- const pruneBuilds = (bucket, repo, keep, replaced, at, grace, from = 0) => Effect.gen(function* () {
1544
+ const pruneBuilds = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, repo, keep, replaced, at, grace, from = 0) {
1107
1545
  const prefix = indexPrefix(repo);
1108
1546
  const replacedAt = new Map(replaced.map((each) => [each.build, each.at]));
1109
1547
  let due;
1110
1548
  let after;
1111
1549
  let deleted = 0;
1112
1550
  for (;;) {
1113
- const page = yield* bucketCall((signal) => bucket.list(prefix, after === void 0 ? {} : { after }, { signal }));
1551
+ const page = yield* bucketDo(bucket.list(prefix, after === void 0 ? {} : { after }));
1114
1552
  for (const item of page.items) {
1115
1553
  const name = item.key.slice(prefix.length);
1116
1554
  const build = name.split(/[./]/)[0] ?? "";
@@ -1122,7 +1560,7 @@ const pruneBuilds = (bucket, repo, keep, replaced, at, grace, from = 0) => Effec
1122
1560
  due = Math.min(due ?? Number.POSITIVE_INFINITY, since + grace);
1123
1561
  continue;
1124
1562
  }
1125
- yield* bucketCall((signal) => bucket.delete(item.key, { signal }));
1563
+ yield* bucketDo(bucket.remove(item.key));
1126
1564
  deleted += 1;
1127
1565
  if (deleted >= 200) return at;
1128
1566
  }
@@ -1150,6 +1588,12 @@ const coveredPositions = (listed, data) => {
1150
1588
  /** The rounds a row written by `input`'s try records: its round and those before it. */
1151
1589
  const roundsAfter = (input) => (input.round ?? 0) + 1;
1152
1590
  /**
1591
+ * Whether `data` is an update that adds nothing to the layers below it: no pack, row, commit or
1592
+ * bitmap. One starts when a try can't tell the row is up to date, as when a write beside it moves
1593
+ * the repo's version during its read, and finds at its commit that it was.
1594
+ */
1595
+ const addsNothing = (data) => data.merge !== true && data.below.length > 0 && data.packs.length === 0 && data.rows === 0 && data.commits === 0 && data.bitmaps === 0;
1596
+ /**
1153
1597
  * The commit step: the row, its layers those below the build and the build's own, over the packs
1154
1598
  * it began with and its region.
1155
1599
  */
@@ -1216,18 +1660,28 @@ const covers = (data, listed) => coversAll([...data.below, { groups: [{
1216
1660
  packs: data.packs,
1217
1661
  rows: data.rows
1218
1662
  }] }], listed);
1663
+ /** Whether `error` is a file's failing its own checks, as a `.bitmaps` lost or cut short. */
1664
+ const isLost = (error) => error.code === "DATA_LOSS";
1665
+ /** A build's meeting with layers whose files fail their own checks: an error in the log. */
1666
+ const layersLost = (listed, error) => Effect.logError(`git.index found repo ${listed.repo}'s index unreadable, so it builds it again whole: ${error.message}`);
1219
1667
  /**
1220
1668
  * Whether `built` holds all of `listed` and a bitmap for every tip: no pack or row listed since
1221
1669
  * its layers, and none of `tips` without a bitmap. A tip whose object no layer holds once every
1222
1670
  * pack and row is covered, such as a ref to an object the repo lacks, is left as it is: no update
1223
- * would give it one. The try that finds it so only prunes.
1671
+ * would give it one. The try that finds it so only prunes. Its joins are charged to an upkeep
1672
+ * allotment of its own, so a try with no room for one fails `readBusy` and the queue tries it
1673
+ * again. A join past all upkeep may hold, the budget less the read reserve, fails `readBusy` too,
1674
+ * retried up to `indexTries`, but no production budget gets there: `allottableOf(defaultMemory)`
1675
+ * less `readReserveBytes`, 99,090,048 B, holds a join of about 12.2M IDs.
1676
+ * `moved` when the repo's rows moved under the read: whether it holds is unknown at `listed`.
1224
1677
  */
1225
- const upToDate = (parts, listed, built, tips) => Effect.gen(function* () {
1678
+ const upToDate = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, built, tips) {
1226
1679
  const covered = coveredPacks(built.layers);
1227
1680
  if (listed.packs.some((pack) => !covered.has(pack.id))) return false;
1228
- const layout = yield* openLayout(parts.bucket, listed, built.layers);
1681
+ const allotment = yield* parts.budget.upkeep(0, readBusy);
1682
+ const layout = yield* openLayout(parts.bucket, listed, built.layers, void 0, { allotment });
1229
1683
  const read = yield* readRegion(parts, listed);
1230
- if (read === void 0) return false;
1684
+ if (read === void 0) return "moved";
1231
1685
  if ((yield* layout.positionsOf(read.ids, read.rows)).some((position) => position === 4294967295)) return false;
1232
1686
  const bitmaps = yield* openLayerBitmaps(parts.bucket, listed.repo, built.layers);
1233
1687
  const unique = [...new Set(tips)];
@@ -1244,12 +1698,41 @@ const ownBuilt = (row, round) => !("refused" in row) && row.refusal === void 0 &
1244
1698
  /** How many rounds of tries the repo had used when `row` was written. */
1245
1699
  const roundsOf = (row) => "refused" in row ? row.refused.rounds : row.rounds;
1246
1700
  /**
1247
- * `GitObjects.index.status`: what the repo's `index` row says at `at`, one `IndexStatus`. A
1248
- * built row's round is the one that built it, whose tries keep it up a layer at a time. One whose
1249
- * update was refused for spent tries is `refused` until its wait passes, then `retry` at the next
1250
- * round, though its layers stand.
1701
+ * What a refusal says at `at` under `limits`, with `packs` listed: `refused` for spent tries until
1702
+ * their wait passes, `too-large` for a step the host's bounds it kept can't make while they stand
1703
+ * and the pack its slice cuts is listed, and `retry` at the next round once either has ended.
1704
+ */
1705
+ const refusalStatus = (refusal, round, limits, at, packs) => {
1706
+ const { reason, tries, bounds, pack } = refusal;
1707
+ if (tries !== void 0) return at >= tries.next ? {
1708
+ state: "retry",
1709
+ reason,
1710
+ round
1711
+ } : {
1712
+ state: "refused",
1713
+ reason,
1714
+ retryAt: tries.next
1715
+ };
1716
+ if (bounds === void 0) return {
1717
+ state: "too-large",
1718
+ reason
1719
+ };
1720
+ return boundsHold(bounds, limits) && (pack === void 0 || packs.includes(pack)) ? {
1721
+ state: "too-large",
1722
+ reason
1723
+ } : {
1724
+ state: "retry",
1725
+ reason,
1726
+ round
1727
+ };
1728
+ };
1729
+ /**
1730
+ * `GitObjects.index.status`: what the repo's `index` row says at `at`, one `IndexStatus`, under
1731
+ * the server's `limits`. A built row's round is the one that built it, whose tries keep it up a
1732
+ * layer at a time. One whose update was refused says so as a refused row does, though its layers
1733
+ * stand. A refusal at the graph's bound stands while the bound is the same (Q735).
1251
1734
  */
1252
- const indexStatus = (row, graphMost, at) => {
1735
+ const indexStatus = (row, limits, at, packs) => {
1253
1736
  if (row === void 0) return { state: "unbuilt" };
1254
1737
  if (!("refused" in row)) {
1255
1738
  const { refusal, rounds } = row;
@@ -1257,31 +1740,15 @@ const indexStatus = (row, graphMost, at) => {
1257
1740
  state: "built",
1258
1741
  round: Math.max(0, rounds - 1)
1259
1742
  };
1260
- const { reason, tries } = refusal;
1261
- return at >= tries.next ? {
1262
- state: "retry",
1263
- reason,
1264
- round: rounds
1265
- } : {
1266
- state: "refused",
1267
- reason,
1268
- retryAt: tries.next
1269
- };
1743
+ return refusalStatus(refusal, rounds, limits, at, packs);
1270
1744
  }
1271
- const { most, reason, rounds, tries } = row.refused;
1272
- if (most !== graphMost || tries !== void 0 && at >= tries.next) return {
1745
+ const { refused } = row;
1746
+ if (refused.most !== limits.graphMost) return {
1273
1747
  state: "retry",
1274
- reason,
1275
- round: rounds
1276
- };
1277
- return tries === void 0 ? {
1278
- state: "too-large",
1279
- reason
1280
- } : {
1281
- state: "refused",
1282
- reason,
1283
- retryAt: tries.next
1748
+ reason: refused.reason,
1749
+ round: refused.rounds
1284
1750
  };
1751
+ return refusalStatus(refused, refused.rounds, limits, at, packs);
1285
1752
  };
1286
1753
  /**
1287
1754
  * Whether a ref-moving commit saves `git.index` over `status`: none built, a built index to keep
@@ -1289,11 +1756,19 @@ const indexStatus = (row, graphMost, at) => {
1289
1756
  */
1290
1757
  const indexSaves = (status) => status.state === "unbuilt" || status.state === "built" || status.state === "retry";
1291
1758
  /**
1759
+ * `step`, with a line in the log naming it where a spent count of its try's calls ends the try,
1760
+ * so a field read of an alarm that spent its bound names the step (#1068).
1761
+ */
1762
+ const spentNamed = (name, repo) => (step) => Effect.tapCause(step, (cause) => {
1763
+ const spent = spentIn(Cause.squash(cause));
1764
+ return spent === void 0 ? Effect.void : Effect.logWarning(`git.index's ${name} step for repo ${repo} spent its try's calls: ${spent.message}`);
1765
+ });
1766
+ /**
1292
1767
  * One try of the build of `listed`: its next step, from `input.data`, or a new build when none
1293
1768
  * is under way, or when a pack it covers left the listing. Before its region is read, any change
1294
1769
  * to the packs starts it again, since its rows are read at the try's own version.
1295
1770
  */
1296
- const indexStep = (parts, listed, input) => Effect.gen(function* () {
1771
+ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, input) {
1297
1772
  const { row } = input;
1298
1773
  const keptOf = (building) => {
1299
1774
  const keep = /* @__PURE__ */ new Map();
@@ -1307,16 +1782,11 @@ const indexStep = (parts, listed, input) => Effect.gen(function* () {
1307
1782
  return prunedAt(due);
1308
1783
  }
1309
1784
  const round = input.round ?? 0;
1785
+ const limits = limitsOf(parts);
1310
1786
  if (row !== void 0 && roundsOf(row) > round && !ownBuilt(row, round)) return prunedAt(yield* prune());
1311
- const waiting = (reason) => {
1787
+ const refusing = (reason, held) => {
1312
1788
  const rounds = round + 1;
1313
1789
  const kept = builtOf(row);
1314
- const refusals = ((row === void 0 ? void 0 : "refused" in row ? row.refused.tries : row.refusal?.tries)?.refusals ?? 0) + 1;
1315
- const tries = {
1316
- at: input.at,
1317
- refusals,
1318
- next: input.at + triesWaitOf(refusals)
1319
- };
1320
1790
  if (kept !== void 0) return {
1321
1791
  kind: "done",
1322
1792
  row: {
@@ -1325,7 +1795,7 @@ const indexStep = (parts, listed, input) => Effect.gen(function* () {
1325
1795
  replaced: replacedBy(input, kept.layers),
1326
1796
  refusal: {
1327
1797
  reason,
1328
- tries
1798
+ ...held
1329
1799
  }
1330
1800
  }
1331
1801
  };
@@ -1337,17 +1807,36 @@ const indexStep = (parts, listed, input) => Effect.gen(function* () {
1337
1807
  most: parts.graphMost,
1338
1808
  reason,
1339
1809
  rounds,
1340
- tries
1810
+ ...held
1341
1811
  },
1342
1812
  replaced: replacedBy(input)
1343
1813
  }
1344
1814
  };
1345
1815
  };
1816
+ const waiting = (reason) => {
1817
+ const refusals = ((row === void 0 ? void 0 : "refused" in row ? row.refused.tries : row.refusal?.tries)?.refusals ?? 0) + 1;
1818
+ return refusing(reason, { tries: {
1819
+ at: input.at,
1820
+ refusals,
1821
+ next: input.at + triesWaitOf(refusals)
1822
+ } });
1823
+ };
1824
+ const final = (error) => {
1825
+ const reason = sliceRefusal(error);
1826
+ const pack = slicePackOf(error);
1827
+ const bounds = boundsOf(limits);
1828
+ return refusing(reason, pack === void 0 ? { bounds } : {
1829
+ bounds,
1830
+ pack
1831
+ });
1832
+ };
1346
1833
  if (input.failed !== void 0) return waiting(input.failed.reason);
1347
- if (input.data === void 0 && row !== void 0 && !indexSaves(indexStatus(row, parts.graphMost, input.at))) return prunedAt(yield* prune());
1834
+ if (input.data === void 0 && row !== void 0 && !indexSaves(indexStatus(row, limits, input.at, listedIds(listed)))) return prunedAt(yield* prune());
1348
1835
  const built = builtOf(row);
1349
- if (input.data === void 0 && built !== void 0 && coversAll(built.layers, listed) && (yield* upToDate(parts, listed, built, input.tips))) return prunedAt(yield* prune());
1350
- const fresh = () => built === void 0 || !coversAll(built.layers, listed) ? started(listed) : built.layers.length < 8 ? startedUpdate(listed, built) : startedMerge(listed, built);
1836
+ const current = input.data === void 0 && built !== void 0 && coversAll(built.layers, listed) ? yield* upToDate(parts, listed, built, input.tips).pipe(Effect.catchIf(isLost, (error) => Effect.as(layersLost(listed, error), "lost"))) : false;
1837
+ if (current === true) return prunedAt(yield* prune());
1838
+ if (current === "moved" && input.lastCheck !== true) return { kind: "moved" };
1839
+ const fresh = () => built === void 0 || current === "lost" || !coversAll(built.layers, listed) ? started(listed) : built.layers.length < 8 ? startedUpdate(listed, built) : startedMerge(listed, built);
1351
1840
  const kept = input.data;
1352
1841
  const sameBelow = kept !== void 0 && (kept.below.length === 0 || kept.below.map((layer) => layer.build).join() === (built?.layers ?? []).map((layer) => layer.build).join());
1353
1842
  const again = (from) => from.below.length === 0 && from.merge !== true ? started(listed) : fresh();
@@ -1356,19 +1845,26 @@ const indexStep = (parts, listed, input) => Effect.gen(function* () {
1356
1845
  kind: "more",
1357
1846
  data: next
1358
1847
  });
1848
+ const orWhole = (step) => data.below.length === 0 ? step : step.pipe(Effect.catchIf(isLost, (error) => Effect.as(layersLost(listed, error), started(listed))));
1849
+ if (input.lastCheck === true && input.data === void 0) return more(data);
1359
1850
  if (data.step === "region") yield* prune(data.build);
1851
+ if (data.step === "commit" && addsNothing(data)) {
1852
+ yield* prune();
1853
+ return prunedAt(input.at);
1854
+ }
1360
1855
  if (data.step === "commit") return yield* commitStep(listed, data, input);
1361
- const allotment = yield* parts.budget.allot(floors.cache + floors.blocks, readBusy);
1362
- if (data.step === "region") return more(yield* regionStep(parts, listed, data, allotment));
1363
- if (data.step === "files") return more(yield* filesStep(parts, listed, data, allotment));
1856
+ const allotment = yield* parts.budget.upkeep(floors.cache + floors.blocks, readBusy);
1857
+ const named = spentNamed(data.step, listed.repo);
1858
+ if (data.step === "region") return more(yield* named(orWhole(regionStep(parts, listed, data, allotment))));
1859
+ if (data.step === "files") return more(yield* named(orWhole(filesStep(parts, listed, data, allotment))));
1364
1860
  if (data.step === "merge") {
1365
- const merged = yield* Effect.result(mergeStep(parts, listed, data, input, allotment));
1861
+ const merged = yield* Effect.result(named(orWhole(mergeStep(parts, listed, data, input, allotment))));
1366
1862
  if (Result.isSuccess(merged)) return more(merged.success);
1367
- if (isSliceRefused(merged.failure)) return waiting(merged.failure.message);
1863
+ if (isSliceRefused(merged.failure)) return final(merged.failure);
1368
1864
  return yield* Effect.fail(merged.failure);
1369
1865
  }
1370
1866
  if (data.step === "graph") {
1371
- const graphed = yield* graphStep(parts, listed, data, allotment);
1867
+ const graphed = yield* named(orWhole(graphStep(parts, listed, data, allotment)));
1372
1868
  if ("step" in graphed) return more(graphed);
1373
1869
  return {
1374
1870
  kind: "done",
@@ -1384,14 +1880,17 @@ const indexStep = (parts, listed, input) => Effect.gen(function* () {
1384
1880
  };
1385
1881
  }
1386
1882
  if (data.step === "read") {
1387
- const read = yield* Effect.result(readStep(parts, listed, data, allotment));
1883
+ const read = yield* Effect.result(named(orWhole(readStep(parts, listed, data, allotment))));
1388
1884
  if (Result.isSuccess(read)) return more(read.success);
1389
- if (isSliceRefused(read.failure)) return waiting(read.failure.message);
1885
+ if (isSliceRefused(read.failure)) return final(read.failure);
1390
1886
  return yield* Effect.fail(read.failure);
1391
1887
  }
1392
- return more((yield* bitmapsStep(parts, listed, data, input, allotment)) ?? started(listed));
1393
- }).pipe(Effect.scoped);
1394
- const decodeDataOption = Schema.decodeUnknownOption(IndexData);
1888
+ const bitmaps = yield* Effect.result(named(orWhole(bitmapsStep(parts, listed, data, input, allotment))));
1889
+ if (Result.isSuccess(bitmaps)) return more(bitmaps.success ?? started(listed));
1890
+ if (isSliceRefused(bitmaps.failure)) return final(bitmaps.failure);
1891
+ return yield* Effect.fail(bitmaps.failure);
1892
+ }, Effect.scoped);
1893
+ const decodeDataOption = /* @__PURE__ */ Schema.decodeUnknownOption(IndexData);
1395
1894
  /**
1396
1895
  * The most the graph step holds in a `packs()` instance of `memory`: half what it allots, about
1397
1896
  * 48 MB in a Worker's 128 MB, at 16 bytes a commit about 3 M commits.
@@ -1403,7 +1902,7 @@ const graphMostOf = (memory) => Math.floor(allottableOf(memory) / 2);
1403
1902
  * change wrote, is as none, as `indexStatus` reads it: the try starts a new build, and prune
1404
1903
  * deletes the old one's files once the grace has passed since they were written.
1405
1904
  */
1406
- const indexTry = (parts, limits, listed, input) => Effect.gen(function* () {
1905
+ const indexTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, limits, listed, input) {
1407
1906
  const step = {
1408
1907
  tips: [...new Set(input.tips.map((tip) => tip.oid))],
1409
1908
  at: input.at,
@@ -1416,6 +1915,7 @@ const indexTry = (parts, limits, listed, input) => Effect.gen(function* () {
1416
1915
  if (row !== void 0) step.row = row;
1417
1916
  if (input.deleted !== void 0) step.deleted = input.deleted;
1418
1917
  if (input.failed !== void 0) step.failed = input.failed;
1918
+ if (input.lastCheck === true) step.lastCheck = true;
1419
1919
  const ended = yield* indexStep({
1420
1920
  ...parts,
1421
1921
  graphMost: limits.graphMost
@@ -1430,4 +1930,4 @@ const indexTry = (parts, limits, listed, input) => Effect.gen(function* () {
1430
1930
  data: ended.data
1431
1931
  };
1432
1932
  });
1433
- export { BuiltIndex, IndexData, IndexGroup, IndexLayer, IndexRefusal, IndexRow, IndexSlice, IndexTries, Narrowed, RefusedIndex, ReplacedBuild, belowGraphs, builtIndexOf, chooseCommits, copyMergedBitmaps, coveredPacks, coversAll, decodeIndexValue, edgesMost, floors, graphMostOf, indexReadCallsAfter, indexRowOf, indexSaves, indexStatus, indexStep, indexSteps, indexTry, madeMost, mergeCallsAfterOpen, mergeChunk, mergeHeldMost, narrowedAfter, newBuildId, positionOrder, pruneBuilds, putOnce, rowsOfLayer, sliceBounds, storedTypesOf, triesWait, triesWaitMost, triesWaitOf, wordsOf };
1933
+ export { BitmapsCut, BuiltIndex, IndexBounds, IndexData, IndexGroup, IndexLayer, IndexRefusal, IndexRow, IndexSlice, IndexTries, Narrowed, RefusedIndex, ReplacedBuild, belowGraphs, bitmapsJoinHeld, bitmapsJoinMost, boundsOf, builtIndexOf, chooseCommits, copyMergedBitmaps, coveredPacks, coversAll, decodeIndexValue, edgesMost, entriesHeld, floors, graphMostOf, indexBitmapsCallsAfter, indexReadCallsAfter, indexRowOf, indexSaves, indexStatus, indexStep, indexSteps, indexTry, limitsOf, madeMost, mergeCallsAfterOpen, mergeChunk, mergeHeldMost, narrowedAfter, newBuildId, positionOrder, pruneBuilds, putOnce, reachesBytes, reachesOf, readFurther, rowsOfLayer, sliceBounds, storedTypesOf, triesWait, triesWaitMost, triesWaitOf, wordsOf };