@ref0/git 0.0.0 → 0.2.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 (503) hide show
  1. package/dist/LICENSE +202 -0
  2. package/dist/access/private-refs.d.mts +27 -0
  3. package/dist/access/private-refs.mjs +173 -0
  4. package/dist/access.d.mts +2 -0
  5. package/dist/access.mjs +1 -0
  6. package/dist/auth/access-jwt.d.mts +21 -0
  7. package/dist/auth/access-jwt.mjs +102 -0
  8. package/dist/auth/acting.mjs +15 -0
  9. package/dist/auth/authorize.d.mts +5 -0
  10. package/dist/auth/authorize.mjs +292 -0
  11. package/dist/auth/credentials.mjs +57 -0
  12. package/dist/auth/fences.d.mts +5 -0
  13. package/dist/auth/fences.mjs +65 -0
  14. package/dist/auth/grants.mjs +61 -0
  15. package/dist/auth/helpers.d.mts +17 -0
  16. package/dist/auth/helpers.mjs +25 -0
  17. package/dist/auth/host-function.d.mts +4 -0
  18. package/dist/auth/host-function.mjs +69 -0
  19. package/dist/auth/identify.d.mts +6 -0
  20. package/dist/auth/identify.mjs +97 -0
  21. package/dist/auth/token-rows.mjs +100 -0
  22. package/dist/auth/token-text.mjs +66 -0
  23. package/dist/auth/tokens.d.mts +10 -0
  24. package/dist/auth/tokens.mjs +347 -0
  25. package/dist/auth.d.mts +7 -0
  26. package/dist/auth.mjs +6 -0
  27. package/dist/client/answer.mjs +141 -0
  28. package/dist/client/client.d.mts +23 -0
  29. package/dist/client/client.mjs +51 -0
  30. package/dist/client/git-http.mjs +201 -0
  31. package/dist/client/helper-node.mjs +19 -0
  32. package/dist/client/local.mjs +160 -0
  33. package/dist/client/negotiate.mjs +170 -0
  34. package/dist/client/push-upload.mjs +53 -0
  35. package/dist/client/remote-helper.mjs +129 -0
  36. package/dist/client/remote.mjs +398 -0
  37. package/dist/client/run-remote-helper.d.mts +35 -0
  38. package/dist/client/run-remote-helper.mjs +259 -0
  39. package/dist/client/scrub.d.mts +18 -0
  40. package/dist/client/scrub.mjs +38 -0
  41. package/dist/client/transport.d.mts +2 -0
  42. package/dist/client/transport.mjs +211 -0
  43. package/dist/contracts/access.d.mts +87 -0
  44. package/dist/contracts/actors.d.mts +144 -0
  45. package/dist/contracts/blobs.d.mts +38 -0
  46. package/dist/contracts/calls-spent.d.mts +11 -0
  47. package/dist/contracts/calls-spent.mjs +150 -0
  48. package/dist/contracts/client.d.mts +90 -0
  49. package/dist/contracts/commits.d.mts +126 -0
  50. package/dist/contracts/engine.d.mts +134 -0
  51. package/dist/contracts/events.d.mts +276 -0
  52. package/dist/contracts/files.d.mts +75 -0
  53. package/dist/contracts/forks.d.mts +78 -0
  54. package/dist/contracts/grants.d.mts +60 -0
  55. package/dist/contracts/handlers.d.mts +10 -0
  56. package/dist/contracts/ids.d.mts +15 -0
  57. package/dist/contracts/ids.mjs +15 -0
  58. package/dist/contracts/lfs.d.mts +27 -0
  59. package/dist/contracts/merges.d.mts +33 -0
  60. package/dist/contracts/objects.d.mts +645 -0
  61. package/dist/contracts/objects.mjs +54 -0
  62. package/dist/contracts/operations.d.mts +133 -0
  63. package/dist/contracts/promises.d.mts +63 -0
  64. package/dist/contracts/push-uploads.d.mts +44 -0
  65. package/dist/contracts/queue.d.mts +401 -0
  66. package/dist/contracts/refs.d.mts +95 -0
  67. package/dist/contracts/remote.d.mts +50 -0
  68. package/dist/contracts/repos.d.mts +153 -0
  69. package/dist/contracts/result.d.mts +126 -0
  70. package/dist/contracts/result.mjs +34 -0
  71. package/dist/contracts/rules.d.mts +159 -0
  72. package/dist/contracts/server.d.mts +245 -0
  73. package/dist/contracts/services.d.mts +36 -0
  74. package/dist/contracts/services.mjs +13 -0
  75. package/dist/contracts/signin.d.mts +126 -0
  76. package/dist/contracts/store.d.mts +41 -0
  77. package/dist/contracts/sync.d.mts +210 -0
  78. package/dist/contracts/sync.mjs +8 -0
  79. package/dist/contracts/tags.d.mts +50 -0
  80. package/dist/contracts/tags.mjs +6 -0
  81. package/dist/contracts/tokens.d.mts +87 -0
  82. package/dist/contracts/tokens.mjs +15 -0
  83. package/dist/contracts/topics.d.mts +174 -0
  84. package/dist/contracts/trees.d.mts +84 -0
  85. package/dist/contracts/work.d.mts +31 -0
  86. package/dist/core/access.d.mts +22 -0
  87. package/dist/core/access.mjs +262 -0
  88. package/dist/core/ancestry.mjs +235 -0
  89. package/dist/core/clock.mjs +18 -0
  90. package/dist/core/events/deliver.mjs +468 -0
  91. package/dist/core/events/stream.d.mts +19 -0
  92. package/dist/core/events/stream.mjs +290 -0
  93. package/dist/core/forks.mjs +1027 -0
  94. package/dist/core/hooks/post-receive.mjs +204 -0
  95. package/dist/core/hooks/pre-receive.d.mts +5 -0
  96. package/dist/core/hooks/pre-receive.mjs +34 -0
  97. package/dist/core/index-job.mjs +198 -0
  98. package/dist/core/names.mjs +30 -0
  99. package/dist/core/objects/blobs.mjs +60 -0
  100. package/dist/core/objects/commit-writes.mjs +185 -0
  101. package/dist/core/objects/commits.mjs +172 -0
  102. package/dist/core/objects/files.mjs +211 -0
  103. package/dist/core/objects/lines.mjs +42 -0
  104. package/dist/core/objects/merges.mjs +83 -0
  105. package/dist/core/objects/peel.mjs +166 -0
  106. package/dist/core/objects/reading.mjs +284 -0
  107. package/dist/core/objects/tags.mjs +96 -0
  108. package/dist/core/objects/tree-edits.mjs +266 -0
  109. package/dist/core/objects/trees.mjs +229 -0
  110. package/dist/core/objects/writing.mjs +266 -0
  111. package/dist/core/own-writes.mjs +94 -0
  112. package/dist/core/promise.mjs +46 -0
  113. package/dist/core/publish.mjs +142 -0
  114. package/dist/core/push-decide.mjs +206 -0
  115. package/dist/core/push.mjs +1069 -0
  116. package/dist/core/receipts.d.mts +7 -0
  117. package/dist/core/receipts.mjs +234 -0
  118. package/dist/core/ref-conflicts.mjs +27 -0
  119. package/dist/core/refs.mjs +359 -0
  120. package/dist/core/repack.mjs +521 -0
  121. package/dist/core/repos.mjs +752 -0
  122. package/dist/core/rules/changes.mjs +57 -0
  123. package/dist/core/rules/check.mjs +101 -0
  124. package/dist/core/rules/commit-changes.mjs +216 -0
  125. package/dist/core/rules/context.d.mts +9 -0
  126. package/dist/core/rules/context.mjs +120 -0
  127. package/dist/core/rules/define.d.mts +5 -0
  128. package/dist/core/rules/define.mjs +13 -0
  129. package/dist/core/rules/facts.mjs +13 -0
  130. package/dist/core/rules/fetch.d.mts +5 -0
  131. package/dist/core/rules/fetch.mjs +59 -0
  132. package/dist/core/rules/file-globs.mjs +55 -0
  133. package/dist/core/rules/files.mjs +142 -0
  134. package/dist/core/rules/patterns.mjs +23 -0
  135. package/dist/core/rules/protect.d.mts +9 -0
  136. package/dist/core/rules/protect.mjs +116 -0
  137. package/dist/core/seam.d.mts +24 -0
  138. package/dist/core/seam.mjs +41 -0
  139. package/dist/core/sight.mjs +99 -0
  140. package/dist/core/tokens.mjs +95 -0
  141. package/dist/core/view.d.mts +9 -0
  142. package/dist/core/view.mjs +221 -0
  143. package/dist/core/work.mjs +92 -0
  144. package/dist/effect.d.mts +20 -0
  145. package/dist/effect.mjs +18 -0
  146. package/dist/engine/allotted-xdiff.d.mts +4 -0
  147. package/dist/engine/allotted-xdiff.mjs +80 -0
  148. package/dist/engine/attribute-patterns.mjs +163 -0
  149. package/dist/engine/attributes.mjs +226 -0
  150. package/dist/engine/combined.mjs +653 -0
  151. package/dist/engine/commits.mjs +90 -0
  152. package/dist/engine/content.d.mts +4 -0
  153. package/dist/engine/content.mjs +221 -0
  154. package/dist/engine/diff.mjs +49 -0
  155. package/dist/engine/engine.d.mts +25 -0
  156. package/dist/engine/engine.mjs +49 -0
  157. package/dist/engine/failures.d.mts +4 -0
  158. package/dist/engine/failures.mjs +23 -0
  159. package/dist/engine/line-count.mjs +23 -0
  160. package/dist/engine/merge-base-walk.d.mts +2 -0
  161. package/dist/engine/merge-base-walk.mjs +265 -0
  162. package/dist/engine/merge-bases.mjs +27 -0
  163. package/dist/engine/merge-renames.mjs +165 -0
  164. package/dist/engine/merge.mjs +1125 -0
  165. package/dist/engine/parts.d.mts +8 -0
  166. package/dist/engine/parts.mjs +9 -0
  167. package/dist/engine/reads.d.mts +5 -0
  168. package/dist/engine/reads.mjs +105 -0
  169. package/dist/engine/walk.mjs +328 -0
  170. package/dist/engine/xdiff/NOTICE.md +63 -0
  171. package/dist/engine/xdiff/compiled.d.mts +7 -0
  172. package/dist/engine/xdiff/compiled.mjs +9 -0
  173. package/dist/engine/xdiff/embedded.mjs +4 -0
  174. package/dist/engine/xdiff/node.d.mts +7 -0
  175. package/dist/engine/xdiff/node.mjs +10 -0
  176. package/dist/engine/xdiff/upstream/LGPL-2.1 +511 -0
  177. package/dist/engine/xdiff/xdiff.wasm +0 -0
  178. package/dist/engine/xdiff.d.mts +34 -0
  179. package/dist/engine/xdiff.mjs +380 -0
  180. package/dist/engine.d.mts +3 -0
  181. package/dist/engine.mjs +3 -0
  182. package/dist/extend.d.mts +3 -0
  183. package/dist/extend.mjs +1 -0
  184. package/dist/http/answers.mjs +74 -0
  185. package/dist/http/bodies.mjs +143 -0
  186. package/dist/http/core-parts.mjs +252 -0
  187. package/dist/http/fetch-depth.mjs +26 -0
  188. package/dist/http/handler.mjs +94 -0
  189. package/dist/http/node.d.mts +70 -0
  190. package/dist/http/node.mjs +178 -0
  191. package/dist/http/paths.d.mts +9 -0
  192. package/dist/http/paths.mjs +118 -0
  193. package/dist/http/push-uploads.mjs +286 -0
  194. package/dist/http/receive-pack.mjs +235 -0
  195. package/dist/http/upload-pack.mjs +229 -0
  196. package/dist/index.d.mts +46 -0
  197. package/dist/index.mjs +16 -0
  198. package/dist/lfs/calls.mjs +16 -0
  199. package/dist/lfs/locks.mjs +161 -0
  200. package/dist/lfs/objects.mjs +370 -0
  201. package/dist/lfs/pointers.mjs +141 -0
  202. package/dist/lfs/repo.mjs +42 -0
  203. package/dist/lfs/rows.mjs +108 -0
  204. package/dist/lfs/service.mjs +34 -0
  205. package/dist/lfs/upkeep.mjs +162 -0
  206. package/dist/lfs/wire.mjs +102 -0
  207. package/dist/node.d.mts +3 -0
  208. package/dist/node.mjs +3 -0
  209. package/dist/protocol/bytes/buffers.d.mts +38 -0
  210. package/dist/protocol/bytes/buffers.mjs +62 -0
  211. package/dist/protocol/bytes/crc32.d.mts +4 -0
  212. package/dist/protocol/bytes/crc32.mjs +14 -0
  213. package/dist/protocol/bytes/deflate.d.mts +78 -0
  214. package/dist/protocol/bytes/deflate.mjs +175 -0
  215. package/dist/protocol/bytes/errors.d.mts +20 -0
  216. package/dist/protocol/bytes/errors.mjs +19 -0
  217. package/dist/protocol/bytes/hex.mjs +16 -0
  218. package/dist/protocol/bytes/hmac-sha256.mjs +91 -0
  219. package/dist/protocol/bytes/inflate.d.mts +40 -0
  220. package/dist/protocol/bytes/inflate.mjs +109 -0
  221. package/dist/protocol/bytes/joined.d.mts +2 -0
  222. package/dist/protocol/bytes/joined.mjs +25 -0
  223. package/dist/protocol/bytes/sha1-hasher.d.mts +20 -0
  224. package/dist/protocol/bytes/sha1-hasher.mjs +72 -0
  225. package/dist/protocol/bytes/sha1.d.mts +35 -0
  226. package/dist/protocol/bytes/sha1.mjs +409 -0
  227. package/dist/protocol/bytes/sha256.mjs +156 -0
  228. package/dist/protocol/bytes/streams.mjs +11 -0
  229. package/dist/protocol/bytes/text.mjs +19 -0
  230. package/dist/protocol/diff/diff-raw.d.mts +29 -0
  231. package/dist/protocol/diff/diff-raw.mjs +73 -0
  232. package/dist/protocol/diff/patch.mjs +92 -0
  233. package/dist/protocol/diff/paths.mjs +67 -0
  234. package/dist/protocol/diff/read.d.mts +62 -0
  235. package/dist/protocol/diff/read.mjs +342 -0
  236. package/dist/protocol/diff/rename-similarity.mjs +428 -0
  237. package/dist/protocol/diff/text.mjs +12 -0
  238. package/dist/protocol/diff/tree-diff.d.mts +41 -0
  239. package/dist/protocol/diff/tree-diff.mjs +607 -0
  240. package/dist/protocol/framing/band.d.mts +10 -0
  241. package/dist/protocol/framing/band.mjs +16 -0
  242. package/dist/protocol/framing/pkt-line.d.mts +48 -0
  243. package/dist/protocol/framing/pkt-line.mjs +92 -0
  244. package/dist/protocol/objects/checked-blobs.mjs +127 -0
  245. package/dist/protocol/objects/commit.d.mts +25 -0
  246. package/dist/protocol/objects/commit.mjs +138 -0
  247. package/dist/protocol/objects/fsck-gitmodules.mjs +296 -0
  248. package/dist/protocol/objects/fsck-names.mjs +189 -0
  249. package/dist/protocol/objects/fsck.mjs +297 -0
  250. package/dist/protocol/objects/headers.mjs +109 -0
  251. package/dist/protocol/objects/held.mjs +56 -0
  252. package/dist/protocol/objects/iconv.mjs +145 -0
  253. package/dist/protocol/objects/ident.mjs +111 -0
  254. package/dist/protocol/objects/lfs-pointer.d.mts +8 -0
  255. package/dist/protocol/objects/lfs-pointer.mjs +63 -0
  256. package/dist/protocol/objects/links-raw.mjs +89 -0
  257. package/dist/protocol/objects/object-rules.mjs +75 -0
  258. package/dist/protocol/objects/object.d.mts +16 -0
  259. package/dist/protocol/objects/object.mjs +29 -0
  260. package/dist/protocol/objects/tag.d.mts +21 -0
  261. package/dist/protocol/objects/tag.mjs +96 -0
  262. package/dist/protocol/objects/tree.d.mts +43 -0
  263. package/dist/protocol/objects/tree.mjs +162 -0
  264. package/dist/protocol/objects/utf8-verify.mjs +71 -0
  265. package/dist/protocol/packs/delta.d.mts +57 -0
  266. package/dist/protocol/packs/delta.mjs +229 -0
  267. package/dist/protocol/packs/graph.mjs +78 -0
  268. package/dist/protocol/packs/idx.d.mts +54 -0
  269. package/dist/protocol/packs/idx.mjs +274 -0
  270. package/dist/protocol/packs/indexer.d.mts +167 -0
  271. package/dist/protocol/packs/indexer.mjs +507 -0
  272. package/dist/protocol/packs/parts.d.mts +40 -0
  273. package/dist/protocol/packs/parts.mjs +89 -0
  274. package/dist/protocol/packs/pos.mjs +51 -0
  275. package/dist/protocol/packs/reader.d.mts +180 -0
  276. package/dist/protocol/packs/reader.mjs +414 -0
  277. package/dist/protocol/packs/rev.d.mts +32 -0
  278. package/dist/protocol/packs/rev.mjs +99 -0
  279. package/dist/protocol/packs/step.d.mts +10 -0
  280. package/dist/protocol/packs/step.mjs +12 -0
  281. package/dist/protocol/packs/write-error.d.mts +12 -0
  282. package/dist/protocol/packs/write-error.mjs +27 -0
  283. package/dist/protocol/packs/writer.d.mts +157 -0
  284. package/dist/protocol/packs/writer.mjs +353 -0
  285. package/dist/protocol/wire/advertisement.d.mts +72 -0
  286. package/dist/protocol/wire/advertisement.mjs +161 -0
  287. package/dist/protocol/wire/fetch.d.mts +155 -0
  288. package/dist/protocol/wire/fetch.mjs +458 -0
  289. package/dist/protocol/wire/lines.mjs +107 -0
  290. package/dist/protocol/wire/push-uploads.mjs +43 -0
  291. package/dist/protocol/wire/receive-pack.d.mts +71 -0
  292. package/dist/protocol/wire/receive-pack.mjs +157 -0
  293. package/dist/protocol/wire/report-status.d.mts +47 -0
  294. package/dist/protocol/wire/report-status.mjs +119 -0
  295. package/dist/protocol/wire/v2.d.mts +90 -0
  296. package/dist/protocol/wire/v2.mjs +185 -0
  297. package/dist/protocol.d.mts +31 -0
  298. package/dist/protocol.mjs +31 -0
  299. package/dist/queue/advance.mjs +1036 -0
  300. package/dist/queue/callers.mjs +134 -0
  301. package/dist/queue/calls.mjs +1154 -0
  302. package/dist/queue/commit.mjs +85 -0
  303. package/dist/queue/host.d.mts +15 -0
  304. package/dist/queue/host.mjs +88 -0
  305. package/dist/queue/ids.d.mts +5 -0
  306. package/dist/queue/ids.mjs +21 -0
  307. package/dist/queue/lanes.mjs +86 -0
  308. package/dist/queue/limits.mjs +99 -0
  309. package/dist/queue/pages.mjs +76 -0
  310. package/dist/queue/push-option.mjs +62 -0
  311. package/dist/queue/rows.mjs +206 -0
  312. package/dist/queue/schedule.mjs +132 -0
  313. package/dist/queue/search.mjs +315 -0
  314. package/dist/queue/state.mjs +325 -0
  315. package/dist/queue/steps.mjs +317 -0
  316. package/dist/remote-helper.d.mts +3 -0
  317. package/dist/remote-helper.mjs +3 -0
  318. package/dist/rest/api.d.mts +23 -0
  319. package/dist/rest/api.mjs +27 -0
  320. package/dist/rest/blobs.d.mts +58 -0
  321. package/dist/rest/blobs.mjs +41 -0
  322. package/dist/rest/caller.d.mts +102 -0
  323. package/dist/rest/caller.mjs +18 -0
  324. package/dist/rest/client.d.mts +18 -0
  325. package/dist/rest/client.mjs +587 -0
  326. package/dist/rest/commits.d.mts +435 -0
  327. package/dist/rest/commits.mjs +140 -0
  328. package/dist/rest/errors.d.mts +44 -0
  329. package/dist/rest/errors.mjs +186 -0
  330. package/dist/rest/events.d.mts +38 -0
  331. package/dist/rest/events.mjs +74 -0
  332. package/dist/rest/files.d.mts +179 -0
  333. package/dist/rest/files.mjs +92 -0
  334. package/dist/rest/forks.d.mts +205 -0
  335. package/dist/rest/forks.mjs +51 -0
  336. package/dist/rest/handler.d.mts +17 -0
  337. package/dist/rest/handler.mjs +106 -0
  338. package/dist/rest/handlers.d.mts +8 -0
  339. package/dist/rest/handlers.mjs +592 -0
  340. package/dist/rest/listen.d.mts +24 -0
  341. package/dist/rest/listen.mjs +142 -0
  342. package/dist/rest/me.d.mts +55 -0
  343. package/dist/rest/me.mjs +21 -0
  344. package/dist/rest/merges.d.mts +90 -0
  345. package/dist/rest/merges.mjs +39 -0
  346. package/dist/rest/paths.mjs +86 -0
  347. package/dist/rest/queue.d.mts +486 -0
  348. package/dist/rest/queue.mjs +228 -0
  349. package/dist/rest/refs.d.mts +232 -0
  350. package/dist/rest/refs.mjs +86 -0
  351. package/dist/rest/repos.d.mts +223 -0
  352. package/dist/rest/repos.mjs +93 -0
  353. package/dist/rest/tags.d.mts +153 -0
  354. package/dist/rest/tags.mjs +72 -0
  355. package/dist/rest/tokens.d.mts +297 -0
  356. package/dist/rest/tokens.mjs +88 -0
  357. package/dist/rest/topics.d.mts +257 -0
  358. package/dist/rest/topics.mjs +116 -0
  359. package/dist/rest/trees.d.mts +158 -0
  360. package/dist/rest/trees.mjs +118 -0
  361. package/dist/rest/wire.mjs +57 -0
  362. package/dist/rest/work.d.mts +107 -0
  363. package/dist/rest/work.mjs +77 -0
  364. package/dist/rest.d.mts +8 -0
  365. package/dist/rest.mjs +5 -0
  366. package/dist/server/extension.d.mts +14 -0
  367. package/dist/server/extension.mjs +85 -0
  368. package/dist/server/routes.d.mts +25 -0
  369. package/dist/server/routes.mjs +67 -0
  370. package/dist/server/server.d.mts +2 -0
  371. package/dist/server/server.mjs +439 -0
  372. package/dist/signin/codes.mjs +47 -0
  373. package/dist/signin/context.d.mts +9 -0
  374. package/dist/signin/context.mjs +121 -0
  375. package/dist/signin/device.mjs +122 -0
  376. package/dist/signin/forms.mjs +157 -0
  377. package/dist/signin/grants.d.mts +5 -0
  378. package/dist/signin/grants.mjs +257 -0
  379. package/dist/signin/route.mjs +68 -0
  380. package/dist/signin/web.mjs +125 -0
  381. package/dist/signin/wire.d.mts +42 -0
  382. package/dist/signin/wire.mjs +43 -0
  383. package/dist/storage/allotted.mjs +102 -0
  384. package/dist/storage/budget.mjs +96 -0
  385. package/dist/storage/calls.d.mts +18 -0
  386. package/dist/storage/calls.mjs +273 -0
  387. package/dist/storage/clean-up.mjs +124 -0
  388. package/dist/storage/distinct-ids.mjs +39 -0
  389. package/dist/storage/ewah.mjs +97 -0
  390. package/dist/storage/fetch.d.mts +13 -0
  391. package/dist/storage/fetch.mjs +792 -0
  392. package/dist/storage/fsck.mjs +77 -0
  393. package/dist/storage/held-memo.mjs +188 -0
  394. package/dist/storage/index-bitmaps.d.mts +4 -0
  395. package/dist/storage/index-bitmaps.mjs +654 -0
  396. package/dist/storage/index-build.d.mts +15 -0
  397. package/dist/storage/index-build.mjs +1433 -0
  398. package/dist/storage/index-fetch.d.mts +9 -0
  399. package/dist/storage/index-fetch.mjs +756 -0
  400. package/dist/storage/index-files.mjs +232 -0
  401. package/dist/storage/index-graph.d.mts +3 -0
  402. package/dist/storage/index-graph.mjs +1049 -0
  403. package/dist/storage/index-layers.mjs +317 -0
  404. package/dist/storage/index-reach.mjs +216 -0
  405. package/dist/storage/index-remap.d.mts +8 -0
  406. package/dist/storage/index-remap.mjs +592 -0
  407. package/dist/storage/layout.mjs +69 -0
  408. package/dist/storage/lfs-pointers.d.mts +21 -0
  409. package/dist/storage/lfs-pointers.mjs +175 -0
  410. package/dist/storage/link-join.mjs +106 -0
  411. package/dist/storage/links.mjs +105 -0
  412. package/dist/storage/loose.d.mts +15 -0
  413. package/dist/storage/loose.mjs +120 -0
  414. package/dist/storage/memory-budget.d.mts +8 -0
  415. package/dist/storage/memory-budget.mjs +546 -0
  416. package/dist/storage/merge.mjs +416 -0
  417. package/dist/storage/object-rows.d.mts +6 -0
  418. package/dist/storage/object-rows.mjs +211 -0
  419. package/dist/storage/pack-order.d.mts +8 -0
  420. package/dist/storage/pack-order.mjs +779 -0
  421. package/dist/storage/pack-ranges.d.mts +5 -0
  422. package/dist/storage/pack-ranges.mjs +284 -0
  423. package/dist/storage/pack-reads.d.mts +11 -0
  424. package/dist/storage/pack-reads.mjs +990 -0
  425. package/dist/storage/pack-receive.d.mts +11 -0
  426. package/dist/storage/pack-receive.mjs +449 -0
  427. package/dist/storage/packs.d.mts +56 -0
  428. package/dist/storage/packs.mjs +600 -0
  429. package/dist/storage/prune.mjs +506 -0
  430. package/dist/storage/push-allotment.mjs +109 -0
  431. package/dist/storage/push-uploads.mjs +151 -0
  432. package/dist/storage/pushed-commits.mjs +136 -0
  433. package/dist/storage/quarantine.mjs +98 -0
  434. package/dist/storage/raw-ids.mjs +44 -0
  435. package/dist/storage/ready.d.mts +19 -0
  436. package/dist/storage/ready.mjs +328 -0
  437. package/dist/storage/receive-links.mjs +297 -0
  438. package/dist/storage/repack-job.mjs +48 -0
  439. package/dist/storage/repack.d.mts +31 -0
  440. package/dist/storage/repack.mjs +182 -0
  441. package/dist/storage/roots.mjs +42 -0
  442. package/dist/storage/rows.d.mts +3 -0
  443. package/dist/storage/rows.mjs +71 -0
  444. package/dist/storage/shallow.d.mts +5 -0
  445. package/dist/storage/shallow.mjs +128 -0
  446. package/dist/storage/stream-whole.mjs +236 -0
  447. package/dist/storage/unpack.mjs +236 -0
  448. package/dist/storage/visible.mjs +137 -0
  449. package/dist/storage/walk.d.mts +7 -0
  450. package/dist/storage/walk.mjs +170 -0
  451. package/dist/storage/wants.mjs +362 -0
  452. package/dist/store/call-count.d.mts +47 -0
  453. package/dist/store/call-count.mjs +207 -0
  454. package/dist/store/catalogue.d.mts +7 -0
  455. package/dist/store/catalogue.mjs +643 -0
  456. package/dist/store/crossing.mjs +66 -0
  457. package/dist/store/cursor-seal.d.mts +2 -0
  458. package/dist/store/cursor-seal.mjs +85 -0
  459. package/dist/store/errors.d.mts +12 -0
  460. package/dist/store/errors.mjs +129 -0
  461. package/dist/store/git-store.mjs +75 -0
  462. package/dist/store/list-job.mjs +35 -0
  463. package/dist/store/outbox.d.mts +7 -0
  464. package/dist/store/outbox.mjs +295 -0
  465. package/dist/store/queue-jobs.mjs +43 -0
  466. package/dist/store/random.mjs +28 -0
  467. package/dist/store/records.d.mts +4 -0
  468. package/dist/store/records.mjs +192 -0
  469. package/dist/store/ref-rows.d.mts +4 -0
  470. package/dist/store/ref-rows.mjs +30 -0
  471. package/dist/store/repo-record.mjs +100 -0
  472. package/dist/store/reservations.mjs +82 -0
  473. package/dist/store/scopes.mjs +170 -0
  474. package/dist/store/settle.mjs +63 -0
  475. package/dist/store/topic-jobs.mjs +62 -0
  476. package/dist/sync/bound.d.mts +7 -0
  477. package/dist/sync/bound.mjs +29 -0
  478. package/dist/sync/github.d.mts +12 -0
  479. package/dist/sync/github.mjs +297 -0
  480. package/dist/sync/import.d.mts +8 -0
  481. package/dist/sync/import.mjs +154 -0
  482. package/dist/sync/jobs.d.mts +9 -0
  483. package/dist/sync/jobs.mjs +80 -0
  484. package/dist/sync/mirror.d.mts +9 -0
  485. package/dist/sync/mirror.mjs +227 -0
  486. package/dist/sync/publish.d.mts +5 -0
  487. package/dist/sync/publish.mjs +117 -0
  488. package/dist/sync/records.mjs +73 -0
  489. package/dist/sync/smart-http.d.mts +8 -0
  490. package/dist/sync/smart-http.mjs +23 -0
  491. package/dist/sync/step.mjs +334 -0
  492. package/dist/sync/tries.mjs +126 -0
  493. package/dist/sync.d.mts +8 -0
  494. package/dist/sync.mjs +8 -0
  495. package/dist/topics/advance.mjs +554 -0
  496. package/dist/topics/calls.mjs +346 -0
  497. package/dist/topics/directory.mjs +107 -0
  498. package/dist/topics/host.d.mts +11 -0
  499. package/dist/topics/host.mjs +71 -0
  500. package/dist/topics/members.mjs +177 -0
  501. package/dist/topics/rows.mjs +99 -0
  502. package/dist/topics/topic.mjs +126 -0
  503. package/package.json +86 -5
@@ -0,0 +1,317 @@
1
+ import { hexOf } from "../protocol/bytes/hex.mjs";
2
+ import { rawLinks } from "../protocol/objects/links-raw.mjs";
3
+ import { isTreeMode } from "../protocol/objects/object.mjs";
4
+ import { parseTreeBytes } from "../protocol/objects/tree.mjs";
5
+ import { oidBytes } from "../protocol/packs/idx.mjs";
6
+ import { gitError } from "../store/errors.mjs";
7
+ import { bitmapWords } from "./ewah.mjs";
8
+ import { ewahMostWords, openBitmaps } from "./index-bitmaps.mjs";
9
+ import { indexFiles, isPackId, packFiles } from "./layout.mjs";
10
+ import { joinIds, missing } from "./link-join.mjs";
11
+ import { indexedRanges, openRanges, rangeRanks, rankOf, readExactly, searchReads } from "./pack-ranges.mjs";
12
+ import { readWhole } from "./pack-reads.mjs";
13
+ import { compareIds } from "./raw-ids.mjs";
14
+ import { levelTooLarge } from "./wants.mjs";
15
+ import { tryUnlessSpent } from "../contracts/calls-spent.mjs";
16
+ import * as Effect from "effect/Effect";
17
+ // src/storage/index-layers.ts
18
+ /**
19
+ * The reachability index read across its layers. Each layer is a build of its own, its positions
20
+ * after the layers below: its groups in order, each one's packs in position order, then the rows
21
+ * it read. So a layer added never moves a position below it, and a bitmap stored in any layer is
22
+ * a bitmap of the positions up to its own last, each one after it unset.
23
+ *
24
+ * A reader opens every layer from one `index` row, so it never mixes the layers of two of its
25
+ * versions (the core EM's condition for layers, 22 Nov).
26
+ */
27
+ const lost = (message) => gitError("DATA_LOSS", message);
28
+ /**
29
+ * The most objects a walk that closes a tip's reach reads, for a tip with no bitmap: about the
30
+ * 100 first-parent commits between bitmaps, and the trees each one changes, at spike C's 8 reads
31
+ * a commit, twice over. Past it the walk ends, and its caller takes the bounded walk.
32
+ */
33
+ const walkMost = 2e3;
34
+ /** How many IDs `positionsOf` finds by a search each, past which it joins. */
35
+ const searchedMost = 64;
36
+ /**
37
+ * The most bucket calls finding `count` IDs in packs of `packs` objects takes: by a search each,
38
+ * `searchReads` of each pack's `.idx` and one `.pos` read, or by a join of each pack's ranges.
39
+ */
40
+ const lookupCalls = (count, packs) => ({
41
+ searched: count * (packs.reduce((sum, objects) => sum + searchReads(objects), 0) + 1),
42
+ joined: packs.reduce((sum, objects) => sum + 2 * Math.ceil(objects / rangeRanks), 0)
43
+ });
44
+ const storedOf = (pack) => isPackId(pack.id) ? Effect.succeed({
45
+ id: pack.id,
46
+ bytes: pack.bytes
47
+ }) : Effect.fail(lost(`'${pack.id}' isn't a pack's ID`));
48
+ /** The rows of `runs` by ID, each with its position. */
49
+ const regionOfRuns = (runs) => {
50
+ const only = runs[0];
51
+ if (runs.length === 1 && only !== void 0) return {
52
+ ids: only.ids,
53
+ positions: Uint32Array.from({ length: only.ids.length / 20 }, (_, at) => only.first + at)
54
+ };
55
+ const all = runs.flatMap((run) => Array.from({ length: run.ids.length / 20 }, (_, at) => ({
56
+ run,
57
+ at
58
+ })));
59
+ all.sort((a, b) => compareIds(a.run.ids, a.at * 20, b.run.ids, b.at * 20));
60
+ const ids = new Uint8Array(all.length * 20);
61
+ const positions = new Uint32Array(all.length);
62
+ for (const [index, { run, at }] of all.entries()) {
63
+ ids.set(run.ids.subarray(at * 20, at * 20 + 20), index * 20);
64
+ positions[index] = run.first + at;
65
+ }
66
+ return {
67
+ ids,
68
+ positions
69
+ };
70
+ };
71
+ /** Where `id` is among the region's rows, by a binary search, or `missing`. */
72
+ const regionPosition = (region, id) => {
73
+ let low = 0;
74
+ let high = region.positions.length;
75
+ while (low < high) {
76
+ const middle = low + high >>> 1;
77
+ const compared = compareIds(id, 0, region.ids, middle * 20);
78
+ if (compared === 0) return region.positions[middle] ?? 4294967295;
79
+ if (compared < 0) high = middle;
80
+ else low = middle + 1;
81
+ }
82
+ return missing;
83
+ };
84
+ /** `.rev`'s header, before its ranks. */
85
+ const revHeaderBytes = 12;
86
+ /**
87
+ * The layers of `spans`, oldest first, over `listed`: each pack's `.idx` and `.pos` opened at its
88
+ * base, and each layer's `.region` read. A pack a layer names that `listed` doesn't hold is
89
+ * `DATA_LOSS`: the caller checks the index covers the listing first.
90
+ */
91
+ const openLayout = (bucket, listed, spans, indexed) => Effect.gen(function* () {
92
+ const byId = new Map(listed.packs.map((pack) => [pack.id, pack]));
93
+ const ranges = [];
94
+ const runs = [];
95
+ let position = 0;
96
+ for (const span of spans) {
97
+ if (span.first !== position) return yield* Effect.fail(lost(`The index's layer ${span.build} starts at ${span.first}, not ${position}`));
98
+ const rows = span.groups.reduce((sum, group) => sum + group.rows, 0);
99
+ const key = indexFiles(listed.repo, span.build).region;
100
+ const ids = rows === 0 ? /* @__PURE__ */ new Uint8Array(0) : yield* readWhole(bucket, key);
101
+ if (ids?.byteLength !== rows * 20) return yield* Effect.fail(lost(`${key} doesn't hold its layer's ${rows} rows`));
102
+ let row = 0;
103
+ for (const group of span.groups) {
104
+ for (const id of group.packs) {
105
+ const pack = byId.get(id);
106
+ if (pack === void 0) return yield* Effect.fail(lost(`The index's pack ${id} isn't listed`));
107
+ ranges.push(indexed === void 0 ? yield* openRanges(bucket, yield* storedOf(pack), pack.objects, position) : yield* indexedRanges(bucket, yield* indexed(pack), pack.objects, position));
108
+ position += pack.objects;
109
+ }
110
+ if (group.rows > 0) {
111
+ runs.push({
112
+ first: position,
113
+ ids: ids.subarray(row * 20, (row + group.rows) * 20)
114
+ });
115
+ row += group.rows;
116
+ position += group.rows;
117
+ }
118
+ }
119
+ }
120
+ const region = regionOfRuns(runs);
121
+ const total = position;
122
+ const idAt = (at) => Effect.gen(function* () {
123
+ for (const pack of ranges) {
124
+ if (at < pack.base || at >= pack.base + pack.count) continue;
125
+ const key = packFiles(pack.pack.id).rev;
126
+ const bytes = yield* readExactly(bucket, key, revHeaderBytes + (at - pack.base) * 4, 4);
127
+ const rank = new DataView(bytes.buffer, bytes.byteOffset, 4).getUint32(0);
128
+ if (rank >= pack.count) return yield* Effect.fail(lost(`${key} names rank ${rank} of ${pack.count}`));
129
+ return yield* pack.ids(rank, 1);
130
+ }
131
+ for (const run of runs) {
132
+ const within = at - run.first;
133
+ if (within >= 0 && within * 20 < run.ids.length) return run.ids.slice(within * 20, within * 20 + 20);
134
+ }
135
+ return yield* Effect.fail(lost(`The index holds no position ${at} of ${total}`));
136
+ });
137
+ const searched = (ids, count) => Effect.gen(function* () {
138
+ const out = new Uint32Array(count).fill(missing);
139
+ for (let at = 0; at < count; at += 1) {
140
+ const id = ids.subarray(at * 20, at * 20 + 20);
141
+ for (const pack of ranges) {
142
+ const rank = yield* rankOf(pack, id);
143
+ if (rank === void 0) continue;
144
+ out[at] = pack.base + ((yield* pack.positions(rank, 1))[0] ?? 0);
145
+ break;
146
+ }
147
+ out[at] = Math.min(out[at] ?? 4294967295, regionPosition(region, id));
148
+ }
149
+ return out;
150
+ });
151
+ const joined = (ids, count) => joinIds(ids, count, ranges, region);
152
+ return {
153
+ ranges,
154
+ region,
155
+ positions: total,
156
+ idAt,
157
+ positionsOf: (ids, count, searchedUpTo = searchedMost) => count <= searchedUpTo ? searched(ids, count) : joined(ids, count)
158
+ };
159
+ });
160
+ /** How many objects the walk reads at once, and how many bitmap ranges `orInto` does. */
161
+ const readsAtOnce = 16;
162
+ /**
163
+ * What `LayerBitmaps.orInto` holds into a union of `words` words, beside it: an entry's bytes and
164
+ * its words for each range it reads at once, each at most an EWAH of those words.
165
+ */
166
+ const orIntoBytes = (words) => readsAtOnce * ewahMostWords(words) * 8;
167
+ /** The bitmaps of `layers`, each layer's table read once. */
168
+ const openLayerBitmaps = (bucket, repo, layers) => Effect.gen(function* () {
169
+ const byPosition = /* @__PURE__ */ new Map();
170
+ const numbered = /* @__PURE__ */ new Map();
171
+ for (const layer of layers) {
172
+ if (layer.bitmaps === 0) continue;
173
+ const open = yield* openBitmaps(bucket, indexFiles(repo, layer.build).bitmaps, {
174
+ positions: layer.first + layer.positions,
175
+ count: layer.bitmaps,
176
+ table: layer.table
177
+ });
178
+ for (const entry of open.entries) {
179
+ byPosition.set(entry.position, {
180
+ open,
181
+ entry
182
+ });
183
+ if (entry.number !== 4294967295) numbered.set(entry.number, entry.position);
184
+ }
185
+ }
186
+ return {
187
+ count: byPosition.size,
188
+ has: (position) => byPosition.has(position),
189
+ bitmapAt: (position) => {
190
+ const found = byPosition.get(position);
191
+ return found === void 0 ? Effect.succeed(void 0) : found.open.bitmapOf(found.entry);
192
+ },
193
+ orInto: (positions, into) => {
194
+ const byFile = /* @__PURE__ */ new Map();
195
+ for (const position of new Set(positions)) {
196
+ const found = byPosition.get(position);
197
+ if (found === void 0) continue;
198
+ const entries = byFile.get(found.open) ?? [];
199
+ entries.push(found.entry);
200
+ byFile.set(found.open, entries);
201
+ }
202
+ return Effect.forEach(byFile, ([open, entries]) => open.orInto(entries, into, readsAtOnce), { discard: true });
203
+ },
204
+ numbered,
205
+ entries: [...byPosition.values()].map(({ open, entry }) => ({
206
+ from: open,
207
+ entry
208
+ })).sort((a, b) => a.entry.position - b.entry.position)
209
+ };
210
+ });
211
+ /** `from` ORed into `into`, which may be longer: the positions past `from`'s are unset in it. */
212
+ const orWords = (from, into) => {
213
+ const length = Math.min(from.length, into.length);
214
+ for (let at = 0; at < length; at += 1) into[at] = ((into[at] ?? 0) | (from[at] ?? 0)) >>> 0;
215
+ };
216
+ const bytesOf = (object) => tryUnlessSpent(async () => new Uint8Array(await new Response(object.bytes).arrayBuffer()), (cause) => gitError("UNAVAILABLE", `Object ${object.oid} couldn't be read`, {
217
+ cause,
218
+ hint: "Try again"
219
+ }));
220
+ /** A gitlink names a commit of another repo, no object of this one. */
221
+ const gitlinkMode = "160000";
222
+ /** What a walk holds for each link a read object's parse makes: its ID, entry and join's place. */
223
+ const linkHeldBytes = 320;
224
+ /** A tree entry's least bytes: a 5-digit mode, a space, a 1-byte name, a NUL and its ID. */
225
+ const leastEntryBytes = 28;
226
+ /**
227
+ * `follow` of a batch of read objects, with what following them holds charged to `allotment`
228
+ * first and given back after: each one's bytes, and a link for each `leastEntryBytes` of them,
229
+ * the most its parse can make. A blob is never read, so it's charged nothing. Past what the
230
+ * budget holds alone, it's `levelTooLarge`, as the want walk's.
231
+ */
232
+ const whileFollowed = (allotment, objects, follow) => {
233
+ const bytes = objects.reduce((sum, object) => object === void 0 || object.type === "blob" ? sum : sum + object.size + Math.ceil(object.size / leastEntryBytes) * linkHeldBytes, 0);
234
+ return Effect.acquireUseRelease(allotment.grow(bytes, levelTooLarge), () => follow, () => Effect.sync(() => allotment.shrink(bytes)));
235
+ };
236
+ /**
237
+ * The positions `starts` reach, as words over every position, or `undefined` when it can't say:
238
+ * a walk past `most` reads, an object it can't find, or a link to an ID the index doesn't hold,
239
+ * such as one listed after it. A position with a stored bitmap is ORed whole and not walked; any
240
+ * other is read, and its links found by position, a few at a time. A blob is reached and never
241
+ * read. It holds a word for each 32 positions and at most `most` IDs still to read, charged to
242
+ * `allotment`, and each batch it follows, charged by `whileFollowed`.
243
+ */
244
+ const reachOf = (input, starts) => Effect.gen(function* () {
245
+ const { layout, bitmaps } = input;
246
+ const most = input.most ?? 2e3;
247
+ const words = bitmapWords(layout.positions);
248
+ const held = words * 4 + most * 24;
249
+ yield* Effect.acquireRelease(input.allotment.grow(held), () => Effect.sync(() => input.allotment.shrink(held)));
250
+ const bits = new Uint32Array(words);
251
+ const queue = [];
252
+ const has = (position) => ((bits[position >>> 5] ?? 0) & 1 << (position & 31)) !== 0;
253
+ /** `position`, with what its bitmap holds, or to be read when it has links and none. */
254
+ const take = (position, id, links) => Effect.gen(function* () {
255
+ if (has(position)) return;
256
+ const stored = yield* bitmaps.bitmapAt(position);
257
+ if (stored !== void 0) {
258
+ orWords(stored, bits);
259
+ return;
260
+ }
261
+ bits[position >>> 5] = ((bits[position >>> 5] ?? 0) | 1 << (position & 31)) >>> 0;
262
+ if (links) queue.push(id ?? (yield* layout.idAt(position)));
263
+ });
264
+ for (const start of starts) yield* take(start.position, start.id, true);
265
+ let reads = 0;
266
+ while (queue.length > 0) {
267
+ const batch = queue.splice(0, readsAtOnce);
268
+ reads += batch.length;
269
+ if (reads > most) return void 0;
270
+ const objects = yield* Effect.forEach(batch, (id) => input.read(hexOf(id)), { concurrency: readsAtOnce });
271
+ const followed = Effect.gen(function* () {
272
+ const linked = [];
273
+ for (const object of objects) {
274
+ if (object === void 0) return false;
275
+ if (object.type === "blob") {
276
+ yield* Effect.promise(() => object.bytes.cancel());
277
+ continue;
278
+ }
279
+ const bytes = yield* bytesOf(object);
280
+ if (object.type === "tree") {
281
+ const entries = yield* Effect.mapError(parseTreeBytes(bytes), (error) => lost(`The tree ${object.oid} is unreadable: ${error.message}`));
282
+ for (const entry of entries) if (entry.mode !== gitlinkMode) linked.push({
283
+ id: oidBytes(entry.oid),
284
+ links: isTreeMode(entry.mode)
285
+ });
286
+ continue;
287
+ }
288
+ const malformed = rawLinks(object.type, bytes, (from, at) => linked.push({
289
+ id: from.slice(at, at + 20),
290
+ links: true
291
+ }));
292
+ if (malformed !== void 0) return yield* Effect.fail(lost(`The ${object.type} ${object.oid} is unreadable: ${malformed}`));
293
+ }
294
+ const ids = new Uint8Array(linked.length * 20);
295
+ for (const [at, link] of linked.entries()) ids.set(link.id, at * 20);
296
+ const positions = yield* layout.positionsOf(ids, linked.length);
297
+ for (const [at, link] of linked.entries()) {
298
+ const position = positions[at] ?? 4294967295;
299
+ if (position === 4294967295) return false;
300
+ yield* take(position, link.id, link.links);
301
+ if (reads + queue.length > most) return false;
302
+ }
303
+ return true;
304
+ });
305
+ if (!(yield* whileFollowed(input.allotment, objects, followed))) return void 0;
306
+ }
307
+ return bits;
308
+ }).pipe(Effect.scoped);
309
+ /** Each of `oids` as 20 bytes, in their order. */
310
+ const idsOf = (oids) => {
311
+ const ids = new Uint8Array(oids.length * 20);
312
+ for (const [at, oid] of oids.entries()) ids.set(oidBytes(oid), at * 20);
313
+ return ids;
314
+ };
315
+ /** Whether `position` is set in `bits`. */
316
+ const hasBit = (bits, position) => ((bits[position >>> 5] ?? 0) & 1 << (position & 31)) !== 0;
317
+ export { hasBit, idsOf, lookupCalls, openLayerBitmaps, openLayout, orIntoBytes, orWords, reachOf, walkMost, whileFollowed };
@@ -0,0 +1,216 @@
1
+ import { bitmapWords } from "./ewah.mjs";
2
+ import { builtIndexOf, coversAll, decodeIndexValue } from "./index-build.mjs";
3
+ import { hasBit, idsOf, openLayerBitmaps, openLayout, orIntoBytes, orWords, reachOf, whileFollowed } from "./index-layers.mjs";
4
+ import { missing } from "./link-join.mjs";
5
+ import { readBusy } from "./memory-budget.mjs";
6
+ import { onward, stepsOf } from "./wants.mjs";
7
+ import * as Effect from "effect/Effect";
8
+ // src/storage/index-reach.ts
9
+ /**
10
+ * The want check on the reachability index (#596, piece 1): which wants a fetch's tips reach, as
11
+ * the OR of the tips' bitmaps and a bit test each, with no walk of the repo's history.
12
+ *
13
+ * **A tip the index doesn't hold**, as a push's between its commit and its update, or a queue
14
+ * candidate's, which saves none, is walked from until it meets the index, and closed from what it
15
+ * met. Once every tip is closed, the union holds all they reach: what the index holds by its
16
+ * bit, and what it doesn't by the walk, so a want neither has is unreachable, held or not. An
17
+ * import's history arrives whole before its first ref moves, so no object the index holds
18
+ * links to one it doesn't.
19
+ *
20
+ * **A read never saves `git.index`.** Once a run of the job has finished, every tip has a stored
21
+ * bitmap, since an update makes one for each tip that has none. So a read meets a tip with none
22
+ * only between a push's commit and that push's try, and the push saved the try in its commit.
23
+ * Such a read walks that tip's reach itself, from the nearest stored bitmaps, within its own
24
+ * allotment and `walkMost` reads, and keeps what it found in the instance's `ReachCache`, keyed
25
+ * by the layer and the tip, so the next read of it walks nothing (the core EM, 22 Nov).
26
+ */
27
+ /** The positions set in `bits`, ascending. */
28
+ const positionsIn = (bits) => {
29
+ const found = [];
30
+ for (const [word, value] of bits.entries()) for (let open = value; open !== 0; open &= open - 1) found.push(word * 32 + 31 - Math.clz32(open & -open));
31
+ return found;
32
+ };
33
+ /** The most bytes of walked reaches an instance keeps. */
34
+ const reachCacheBytes = 8388608;
35
+ /** The reaches a read walked for tips with no stored bitmap, by build and position, least lately used gone first. */
36
+ var ReachCache = class {
37
+ #kept = /* @__PURE__ */ new Map();
38
+ #most;
39
+ #bytes = 0;
40
+ constructor(most = reachCacheBytes) {
41
+ this.#most = most;
42
+ }
43
+ get(key) {
44
+ const found = this.#kept.get(key);
45
+ if (found === void 0) return void 0;
46
+ this.#kept.delete(key);
47
+ this.#kept.set(key, found);
48
+ return found;
49
+ }
50
+ set(key, bits) {
51
+ if (bits.byteLength > this.#most) return;
52
+ const old = this.#kept.get(key);
53
+ if (old !== void 0) this.#bytes -= old.byteLength;
54
+ this.#kept.delete(key);
55
+ this.#kept.set(key, bits);
56
+ this.#bytes += bits.byteLength;
57
+ for (const [first, kept] of this.#kept) {
58
+ if (this.#bytes <= this.#most) break;
59
+ this.#kept.delete(first);
60
+ this.#bytes -= kept.byteLength;
61
+ }
62
+ }
63
+ };
64
+ /** What the walk from tips the index doesn't hold charges for each ID outside it it keeps. */
65
+ const outsideIdBytes = 160;
66
+ /**
67
+ * What `tips`, none of which the index holds, reach before they meet it, through `onward`: each
68
+ * object outside the index, read or not, counted, and each position met set in `met`, kept as a
69
+ * bit, not walked. A blob is reached and never read, and an object the repo doesn't hold, as a
70
+ * shallow repo's parent, is left out. Past `most` objects outside it, it stops, not closed. Each
71
+ * batch it follows is charged by `whileFollowed`, and it holds at most `most` IDs between them.
72
+ */
73
+ const outsideOf = (input, tips, most) => Effect.gen(function* () {
74
+ const words = bitmapWords(input.layout.positions);
75
+ const held = words * 4 + most * outsideIdBytes;
76
+ yield* Effect.acquireRelease(input.allotment.grow(held), () => Effect.sync(() => input.allotment.shrink(held)));
77
+ const ids = new Set(tips);
78
+ const met = new Uint32Array(words);
79
+ let frontier = [...tips];
80
+ while (frontier.length > 0) {
81
+ const level = frontier;
82
+ frontier = [];
83
+ for (let from = 0; from < level.length; from += 16) {
84
+ const batch = level.slice(from, from + 16);
85
+ const objects = yield* Effect.forEach(batch, input.read, { concurrency: 16 });
86
+ const followed = Effect.gen(function* () {
87
+ const read = /* @__PURE__ */ new Set();
88
+ const linked = /* @__PURE__ */ new Set();
89
+ for (const [at, oid] of batch.entries()) {
90
+ const object = objects[at];
91
+ if (object === void 0) {
92
+ ids.delete(oid);
93
+ continue;
94
+ }
95
+ const steps = yield* stepsOf(object, true);
96
+ for (const each of onward(steps)) if (!ids.has(each)) read.add(each);
97
+ for (const each of steps.reached) if (!ids.has(each)) linked.add(each);
98
+ }
99
+ const next = [.../* @__PURE__ */ new Set([...read, ...linked])];
100
+ const positions = yield* input.layout.positionsOf(idsOf(next), next.length);
101
+ for (const [at, oid] of next.entries()) {
102
+ const position = positions[at] ?? 4294967295;
103
+ if (position !== 4294967295) {
104
+ met[position >>> 5] = ((met[position >>> 5] ?? 0) | 1 << (position & 31)) >>> 0;
105
+ continue;
106
+ }
107
+ if (ids.size >= most) return false;
108
+ ids.add(oid);
109
+ if (read.has(oid)) frontier.push(oid);
110
+ }
111
+ return true;
112
+ });
113
+ if (!(yield* whileFollowed(input.allotment, objects, followed))) return {
114
+ ids,
115
+ met,
116
+ closed: false
117
+ };
118
+ }
119
+ }
120
+ return {
121
+ ids,
122
+ met,
123
+ closed: true
124
+ };
125
+ });
126
+ /**
127
+ * Which of `input.wants` the tips reach, by the index `input.row` names over `listed`. A want the
128
+ * tips' union holds, or their walk outside the index met, is `true`; any other is `false` once
129
+ * every tip's reach is closed. A tip whose reach won't close within `most` leaves those
130
+ * unanswered and sets `pastLimit`, and its caller refuses them alike. An index that doesn't cover
131
+ * `listed`, as after a repack took a covered pack out, answers nothing, for the caller's walk.
132
+ */
133
+ const indexReach = (parts, listed, input) => Effect.gen(function* () {
134
+ const built = builtIndexOf(decodeIndexValue(input.row));
135
+ if (built === void 0 || !coversAll(built.layers, listed)) return {
136
+ answers: /* @__PURE__ */ new Map(),
137
+ walked: 0
138
+ };
139
+ const last = built.layers[built.layers.length - 1];
140
+ const words = bitmapWords(last === void 0 ? 0 : last.first + last.positions);
141
+ const allotment = yield* parts.budget.allot(words * 4 + orIntoBytes(words), readBusy);
142
+ const layout = yield* openLayout(parts.bucket, listed, built.layers);
143
+ const bitmaps = yield* openLayerBitmaps(parts.bucket, listed.repo, built.layers);
144
+ const reach = {
145
+ layout,
146
+ bitmaps,
147
+ read: yield* parts.objects(listed),
148
+ allotment,
149
+ most: parts.most ?? 2e3
150
+ };
151
+ const tips = [...new Set(input.tips)];
152
+ const tipIds = idsOf(tips);
153
+ const tipPositions = yield* layout.positionsOf(tipIds, tips.length);
154
+ const union = new Uint32Array(words);
155
+ let known = true;
156
+ let walked = 0;
157
+ yield* bitmaps.orInto([...tipPositions].filter((position) => position !== 4294967295 && bitmaps.has(position)), union);
158
+ const uncovered = tips.filter((_, at) => tipPositions[at] === missing);
159
+ const outside = uncovered.length === 0 ? void 0 : yield* outsideOf(reach, uncovered, reach.most);
160
+ if (outside !== void 0) {
161
+ const met = positionsIn(outside.met);
162
+ yield* bitmaps.orInto(met.filter((position) => bitmaps.has(position)), union);
163
+ const rest = met.filter((position) => !hasBit(union, position)).map((position) => ({ position }));
164
+ const closing = () => rest.length === 0 ? Effect.succeed(/* @__PURE__ */ new Uint32Array(0)) : reachOf({
165
+ ...reach,
166
+ most: reach.most - outside.ids.size
167
+ }, rest);
168
+ const bits = outside.closed ? yield* closing() : void 0;
169
+ if (bits === void 0) known = false;
170
+ else orWords(bits, union);
171
+ }
172
+ walked += uncovered.length;
173
+ for (const [at, position] of tipPositions.entries()) {
174
+ if (position === 4294967295 || bitmaps.has(position)) continue;
175
+ const key = `${last?.build ?? ""}:${position}`;
176
+ const cached = parts.cache.get(key);
177
+ if (cached !== void 0) {
178
+ orWords(cached, union);
179
+ continue;
180
+ }
181
+ const id = tipIds.subarray(at * 20, at * 20 + 20);
182
+ const bits = yield* reachOf(reach, [{
183
+ position,
184
+ id
185
+ }]);
186
+ walked += 1;
187
+ if (bits === void 0) {
188
+ known = false;
189
+ continue;
190
+ }
191
+ parts.cache.set(key, bits);
192
+ orWords(bits, union);
193
+ }
194
+ const wants = [...new Set(input.wants)];
195
+ const wantPositions = yield* layout.positionsOf(idsOf(wants), wants.length);
196
+ const answers = /* @__PURE__ */ new Map();
197
+ for (const [at, want] of wants.entries()) {
198
+ const position = wantPositions[at] ?? 4294967295;
199
+ if (position === 4294967295 ? outside?.ids.has(want) === true : hasBit(union, position)) answers.set(want, true);
200
+ else if (known) answers.set(want, false);
201
+ }
202
+ if (known) return {
203
+ answers,
204
+ walked
205
+ };
206
+ const past = {
207
+ answers,
208
+ walked,
209
+ pastLimit: reach.most
210
+ };
211
+ return built.refusal === void 0 ? past : {
212
+ ...past,
213
+ updatesRefused: true
214
+ };
215
+ }).pipe(Effect.scoped);
216
+ export { ReachCache, indexReach, reachCacheBytes };
@@ -0,0 +1,8 @@
1
+ import "../contracts/objects.mjs";
2
+ import "../contracts/store.mjs";
3
+ import "./index-build.mjs";
4
+ import "../store/call-count.mjs";
5
+ import "./memory-budget.mjs";
6
+ import "../contracts/promises.mjs";
7
+ import { Moment, Row } from "@ref0/infra";
8
+ import "effect/Effect";