@ref0/git 0.20.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) hide show
  1. package/dist/access/private-refs.mjs +1 -1
  2. package/dist/auth/access-jwt.mjs +3 -3
  3. package/dist/auth/auth-namespace.d.mts +3 -3
  4. package/dist/auth/auth-namespace.mjs +3 -2
  5. package/dist/auth/auth.d.mts +3 -3
  6. package/dist/auth/auth.mjs +9 -8
  7. package/dist/auth/authorize.mjs +1 -1
  8. package/dist/auth/fences.d.mts +1 -1
  9. package/dist/auth/host-function.mjs +1 -1
  10. package/dist/auth/host-services.mjs +4 -6
  11. package/dist/auth/identify.d.mts +1 -1
  12. package/dist/auth/identify.mjs +6 -0
  13. package/dist/auth/token-cleanup.mjs +2 -2
  14. package/dist/auth/token-rows.mjs +6 -1
  15. package/dist/auth/token-text.mjs +1 -1
  16. package/dist/auth/tokens-base.d.mts +1 -1
  17. package/dist/auth/tokens.d.mts +1 -1
  18. package/dist/auth/tokens.mjs +1 -1
  19. package/dist/client/client.d.mts +15 -7
  20. package/dist/client/client.mjs +21 -12
  21. package/dist/client/git-http.mjs +1 -1
  22. package/dist/client/local.mjs +60 -24
  23. package/dist/client/negotiate.mjs +3 -3
  24. package/dist/client/push-upload.mjs +26 -10
  25. package/dist/client/remote.mjs +4 -3
  26. package/dist/client/run-remote-helper.d.mts +2 -2
  27. package/dist/client/run-remote-helper.mjs +6 -6
  28. package/dist/client/slice-push.d.mts +1 -1
  29. package/dist/client/transport.mjs +3 -3
  30. package/dist/contracts/blobs.d.mts +3 -3
  31. package/dist/contracts/blobs.mjs +1 -1
  32. package/dist/contracts/calls-spent.mjs +5 -33
  33. package/dist/contracts/client.d.mts +15 -14
  34. package/dist/contracts/commits.d.mts +4 -4
  35. package/dist/contracts/commits.mjs +1 -1
  36. package/dist/contracts/engine.d.mts +2 -2
  37. package/dist/contracts/events.d.mts +1 -1
  38. package/dist/contracts/events.mjs +1 -1
  39. package/dist/contracts/files.d.mts +4 -4
  40. package/dist/contracts/files.mjs +1 -1
  41. package/dist/contracts/forks.d.mts +4 -4
  42. package/dist/contracts/forks.mjs +1 -1
  43. package/dist/contracts/git-hooks.d.mts +1 -1
  44. package/dist/contracts/git.d.mts +9 -5
  45. package/dist/contracts/grants.d.mts +1 -1
  46. package/dist/contracts/merges.d.mts +1 -1
  47. package/dist/contracts/object-values.d.mts +1 -0
  48. package/dist/contracts/object-values.mjs +16 -1
  49. package/dist/contracts/objects.d.mts +30 -18
  50. package/dist/contracts/opaque.mjs +1 -1
  51. package/dist/contracts/operations.mjs +1 -1
  52. package/dist/contracts/queue.d.mts +208 -44
  53. package/dist/contracts/queue.mjs +5 -5
  54. package/dist/contracts/refs.d.mts +5 -5
  55. package/dist/contracts/refs.mjs +1 -1
  56. package/dist/contracts/remote.d.mts +3 -6
  57. package/dist/contracts/repos.d.mts +3 -3
  58. package/dist/contracts/repos.mjs +1 -1
  59. package/dist/contracts/result.d.mts +10 -7
  60. package/dist/contracts/result.mjs +8 -3
  61. package/dist/contracts/rules.d.mts +13 -12
  62. package/dist/contracts/server.d.mts +8 -10
  63. package/dist/contracts/services.d.mts +6 -9
  64. package/dist/contracts/services.mjs +1 -2
  65. package/dist/contracts/signin.d.mts +1 -1
  66. package/dist/contracts/store.d.mts +2 -2
  67. package/dist/contracts/sync.d.mts +63 -6
  68. package/dist/contracts/sync.mjs +3 -2
  69. package/dist/contracts/tags.d.mts +3 -3
  70. package/dist/contracts/tags.mjs +1 -1
  71. package/dist/contracts/tokens.d.mts +2 -2
  72. package/dist/contracts/tokens.mjs +1 -1
  73. package/dist/contracts/topics.d.mts +9 -9
  74. package/dist/contracts/trees.d.mts +4 -4
  75. package/dist/contracts/trees.mjs +1 -1
  76. package/dist/contracts/work.d.mts +4 -4
  77. package/dist/contracts/work.mjs +2 -2
  78. package/dist/core/access.d.mts +1 -1
  79. package/dist/core/ancestry.mjs +30 -34
  80. package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
  81. package/dist/core/call-services.mjs +1 -1
  82. package/dist/core/events/deliver.d.mts +2 -2
  83. package/dist/core/events/deliver.mjs +3 -3
  84. package/dist/core/events/retired.mjs +1 -1
  85. package/dist/core/forks.mjs +5 -5
  86. package/dist/core/hooks/groups.mjs +2 -2
  87. package/dist/core/imports.mjs +101 -21
  88. package/dist/core/index-job.mjs +14 -9
  89. package/dist/core/index-lost.d.mts +1 -1
  90. package/dist/core/loose-tally.mjs +38 -15
  91. package/dist/core/merge-parts.d.mts +17 -4
  92. package/dist/core/merge-parts.mjs +7 -2
  93. package/dist/core/mirror-rows.mjs +31 -1
  94. package/dist/core/objects/blobs.mjs +8 -10
  95. package/dist/core/objects/files.mjs +20 -17
  96. package/dist/core/objects/objects-layer.mjs +1 -1
  97. package/dist/core/objects/peel.mjs +1 -7
  98. package/dist/core/objects/reading.mjs +19 -18
  99. package/dist/core/objects/tree-edits.mjs +1 -1
  100. package/dist/core/objects/trees.mjs +257 -58
  101. package/dist/core/objects/writing.mjs +3 -9
  102. package/dist/core/own-writes.mjs +1 -1
  103. package/dist/core/parts.d.mts +8 -1
  104. package/dist/core/parts.mjs +8 -4
  105. package/dist/core/purge.mjs +31 -18
  106. package/dist/core/push.d.mts +2 -2
  107. package/dist/core/push.mjs +145 -98
  108. package/dist/core/receipts.d.mts +2 -2
  109. package/dist/core/receipts.mjs +9 -2
  110. package/dist/core/ref-index-job.mjs +4 -4
  111. package/dist/core/ref-view.mjs +74 -31
  112. package/dist/core/refs.mjs +3 -3
  113. package/dist/core/repack.mjs +25 -30
  114. package/dist/core/repo-info.mjs +1 -1
  115. package/dist/core/repos.mjs +1 -1
  116. package/dist/core/rules/changes.mjs +18 -40
  117. package/dist/core/rules/check.mjs +6 -5
  118. package/dist/core/rules/commit-changes.mjs +114 -58
  119. package/dist/core/rules/context.d.mts +3 -3
  120. package/dist/core/rules/context.mjs +18 -14
  121. package/dist/core/rules/fetch.mjs +1 -1
  122. package/dist/core/rules/protect.mjs +30 -17
  123. package/dist/core/saved-caller-views.d.mts +1 -1
  124. package/dist/core/saved-caller-views.mjs +3 -3
  125. package/dist/core/saved-callers.d.mts +1 -1
  126. package/dist/core/saved-callers.mjs +1 -1
  127. package/dist/core/seam.d.mts +1 -2
  128. package/dist/core/view.d.mts +6 -3
  129. package/dist/core/view.mjs +11 -10
  130. package/dist/core/work.mjs +2 -2
  131. package/dist/engine/allotted-xdiff.mjs +3 -16
  132. package/dist/engine/combined.d.mts +3 -0
  133. package/dist/engine/combined.mjs +200 -185
  134. package/dist/engine/content.d.mts +2 -2
  135. package/dist/engine/content.mjs +1 -1
  136. package/dist/engine/merge.mjs +7 -9
  137. package/dist/engine/reads.d.mts +2 -2
  138. package/dist/engine/reads.mjs +22 -14
  139. package/dist/engine/xdiff.d.mts +1 -1
  140. package/dist/engine/xdiff.mjs +1 -1
  141. package/dist/event-streams/event-streams.d.mts +1 -1
  142. package/dist/event-streams/event-streams.mjs +1 -1
  143. package/dist/event-streams/stream.d.mts +2 -2
  144. package/dist/event-streams/stream.mjs +3 -3
  145. package/dist/extend.d.mts +2 -6
  146. package/dist/extend.mjs +1 -5
  147. package/dist/http/core-parts.mjs +83 -26
  148. package/dist/http/handler.mjs +54 -9
  149. package/dist/http/parts.d.mts +1 -0
  150. package/dist/http/push-upload-job.mjs +138 -24
  151. package/dist/http/push-uploads.mjs +2 -2
  152. package/dist/http/receive-pack.mjs +14 -53
  153. package/dist/http/request-snapshot.mjs +258 -0
  154. package/dist/http/upload-pack.mjs +23 -18
  155. package/dist/index.d.mts +29 -21
  156. package/dist/index.mjs +11 -2
  157. package/dist/lfs/base.d.mts +1 -1
  158. package/dist/lfs/copy.d.mts +49 -1
  159. package/dist/lfs/copy.mjs +135 -22
  160. package/dist/lfs/layer.d.mts +4 -3
  161. package/dist/lfs/layer.mjs +4 -5
  162. package/dist/lfs/locks.mjs +2 -2
  163. package/dist/lfs/objects.d.mts +1 -1
  164. package/dist/lfs/objects.mjs +3 -3
  165. package/dist/lfs/pointers.mjs +1 -1
  166. package/dist/lfs/rows.d.mts +1 -1
  167. package/dist/lfs/rows.mjs +11 -4
  168. package/dist/lfs/upkeep.mjs +40 -9
  169. package/dist/lfs/uploaded.mjs +1 -1
  170. package/dist/lfs/wire.mjs +1 -1
  171. package/dist/merges/merges.mjs +17 -2
  172. package/dist/protocol/bytes/buffers.d.mts +1 -1
  173. package/dist/protocol/bytes/buffers.mjs +1 -1
  174. package/dist/protocol/bytes/deflate.d.mts +1 -1
  175. package/dist/protocol/bytes/deflate.mjs +1 -1
  176. package/dist/protocol/bytes/inflate.d.mts +1 -1
  177. package/dist/protocol/bytes/inflate.mjs +1 -1
  178. package/dist/protocol/bytes/sha1.d.mts +1 -1
  179. package/dist/protocol/bytes/sha1.mjs +1 -1
  180. package/dist/protocol/diff/read.d.mts +2 -1
  181. package/dist/protocol/diff/read.mjs +102 -8
  182. package/dist/protocol/packs/graph.mjs +1 -1
  183. package/dist/protocol/packs/idx.d.mts +1 -1
  184. package/dist/protocol/packs/idx.mjs +1 -1
  185. package/dist/protocol/packs/parts.mjs +1 -1
  186. package/dist/protocol/packs/reader.d.mts +1 -1
  187. package/dist/protocol/packs/reader.mjs +1 -1
  188. package/dist/protocol/packs/write-error.d.mts +1 -1
  189. package/dist/protocol/packs/write-error.mjs +1 -1
  190. package/dist/protocol/packs/writer.mjs +3 -3
  191. package/dist/protocol/wire/advertisement.d.mts +1 -1
  192. package/dist/protocol/wire/advertisement.mjs +3 -2
  193. package/dist/protocol/wire/fetch.d.mts +1 -1
  194. package/dist/protocol/wire/fetch.mjs +1 -1
  195. package/dist/protocol/wire/lines.d.mts +9 -1
  196. package/dist/protocol/wire/lines.mjs +28 -1
  197. package/dist/protocol/wire/push-uploads.mjs +10 -7
  198. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  199. package/dist/protocol/wire/receive-pack.mjs +1 -1
  200. package/dist/protocol/wire/report-status.d.mts +1 -1
  201. package/dist/protocol/wire/report-status.mjs +1 -1
  202. package/dist/protocol/wire/v2.d.mts +1 -1
  203. package/dist/protocol/wire/v2.mjs +1 -1
  204. package/dist/queue/advance.mjs +31 -24
  205. package/dist/queue/base.d.mts +5 -3
  206. package/dist/queue/calls.mjs +5 -5
  207. package/dist/queue/commit.mjs +1 -1
  208. package/dist/queue/host.d.mts +1 -1
  209. package/dist/queue/layer.d.mts +0 -1
  210. package/dist/queue/layer.mjs +9 -5
  211. package/dist/queue/schedule.mjs +1 -1
  212. package/dist/queue/search.mjs +1 -1
  213. package/dist/queue/state.mjs +1 -1
  214. package/dist/queue/trim.mjs +2 -2
  215. package/dist/rest/client.d.mts +1 -1
  216. package/dist/rest/client.mjs +6 -6
  217. package/dist/rest/errors.mjs +1 -1
  218. package/dist/rest/handler.mjs +2 -2
  219. package/dist/rest/handlers.mjs +16 -6
  220. package/dist/rest/layer.mjs +1 -1
  221. package/dist/rest/listen.mjs +2 -2
  222. package/dist/rest/refs.mjs +1 -1
  223. package/dist/server/edge.mjs +27 -3
  224. package/dist/server/git-layer.d.mts +1 -2
  225. package/dist/server/git-layer.mjs +4 -5
  226. package/dist/server/lifecycle.mjs +1 -1
  227. package/dist/server/registry.mjs +2 -8
  228. package/dist/server/server.mjs +62 -43
  229. package/dist/signin/context.d.mts +1 -1
  230. package/dist/signin/context.mjs +1 -1
  231. package/dist/signin/forms.mjs +1 -1
  232. package/dist/signin/grants.d.mts +2 -2
  233. package/dist/signin/grants.mjs +1 -1
  234. package/dist/signin/wire.mjs +1 -1
  235. package/dist/storage/allotted.mjs +4 -9
  236. package/dist/storage/batch-upkeep.mjs +31 -12
  237. package/dist/storage/batches.d.mts +2 -3
  238. package/dist/storage/batches.mjs +52 -49
  239. package/dist/storage/budget.mjs +23 -1
  240. package/dist/storage/calls.d.mts +1 -1
  241. package/dist/storage/calls.mjs +41 -43
  242. package/dist/storage/charged-cache.mjs +180 -0
  243. package/dist/storage/chunks.d.mts +3 -3
  244. package/dist/storage/chunks.mjs +121 -8
  245. package/dist/storage/counted-bucket.mjs +32 -10
  246. package/dist/storage/fetch-row-cache.d.mts +6 -0
  247. package/dist/storage/fetch-row-cache.mjs +211 -0
  248. package/dist/storage/fetch.d.mts +1 -0
  249. package/dist/storage/fetch.mjs +54 -242
  250. package/dist/storage/held-types.d.mts +0 -1
  251. package/dist/storage/held-types.mjs +13 -4
  252. package/dist/storage/host-bucket.mjs +9 -4
  253. package/dist/storage/index-bitmaps.mjs +340 -65
  254. package/dist/storage/index-build.d.mts +2 -3
  255. package/dist/storage/index-build.mjs +274 -56
  256. package/dist/storage/index-fetch.d.mts +3 -1
  257. package/dist/storage/index-fetch.mjs +60 -21
  258. package/dist/storage/index-graph.mjs +1 -1
  259. package/dist/storage/index-layers.mjs +55 -25
  260. package/dist/storage/index-reach.mjs +15 -22
  261. package/dist/storage/index-whole.d.mts +7 -0
  262. package/dist/storage/index-whole.mjs +145 -37
  263. package/dist/storage/largest-files.mjs +1 -7
  264. package/dist/storage/layout.mjs +17 -1
  265. package/dist/storage/lfs-pointers.mjs +1 -6
  266. package/dist/storage/link-join.mjs +55 -16
  267. package/dist/storage/list-source.d.mts +7 -0
  268. package/dist/storage/list-source.mjs +288 -0
  269. package/dist/storage/loose.d.mts +8 -8
  270. package/dist/storage/loose.mjs +157 -91
  271. package/dist/storage/memory-budget.mjs +226 -22
  272. package/dist/storage/merge-cut.mjs +9 -6
  273. package/dist/storage/merge-fence.mjs +1 -1
  274. package/dist/storage/merge-row.mjs +1 -1
  275. package/dist/storage/merge.d.mts +2 -3
  276. package/dist/storage/merge.mjs +2 -2
  277. package/dist/storage/object-rows.d.mts +3 -3
  278. package/dist/storage/object-rows.mjs +179 -38
  279. package/dist/storage/pack-order.mjs +97 -44
  280. package/dist/storage/pack-ranges.mjs +44 -16
  281. package/dist/storage/pack-reads.d.mts +5 -3
  282. package/dist/storage/pack-reads.mjs +236 -72
  283. package/dist/storage/pack-receive.d.mts +1 -2
  284. package/dist/storage/pack-receive.mjs +24 -18
  285. package/dist/storage/packs.d.mts +1 -1
  286. package/dist/storage/packs.mjs +477 -116
  287. package/dist/storage/placed-reads.mjs +33 -16
  288. package/dist/storage/prune-seen.mjs +1 -1
  289. package/dist/storage/prune-walk.mjs +1 -1
  290. package/dist/storage/prune.mjs +4 -31
  291. package/dist/storage/push-allotment.mjs +26 -14
  292. package/dist/storage/push-uploads.mjs +195 -57
  293. package/dist/storage/pushed-commits.mjs +20 -1
  294. package/dist/storage/quarantine.d.mts +2 -3
  295. package/dist/storage/range-cache.mjs +175 -40
  296. package/dist/storage/raw-ids.mjs +39 -10
  297. package/dist/storage/ready.d.mts +2 -3
  298. package/dist/storage/ready.mjs +114 -38
  299. package/dist/storage/receive-bounds.mjs +31 -9
  300. package/dist/storage/receive-cache.d.mts +7 -0
  301. package/dist/storage/receive-cache.mjs +147 -0
  302. package/dist/storage/receive-files.mjs +1 -1
  303. package/dist/storage/receive-links.mjs +1 -1
  304. package/dist/storage/receive-state.d.mts +2 -2
  305. package/dist/storage/receive-state.mjs +6 -8
  306. package/dist/storage/receive-steps.d.mts +20 -0
  307. package/dist/storage/receive-steps.mjs +298 -13
  308. package/dist/storage/repack-backlog.mjs +1 -6
  309. package/dist/storage/repack-contained.mjs +2 -2
  310. package/dist/storage/repack-job.mjs +1 -1
  311. package/dist/storage/repack.d.mts +2 -3
  312. package/dist/storage/repack.mjs +54 -9
  313. package/dist/storage/request-cache.mjs +57 -0
  314. package/dist/storage/roots.mjs +1 -24
  315. package/dist/storage/rows.d.mts +2 -2
  316. package/dist/storage/rows.mjs +1 -1
  317. package/dist/storage/runs.d.mts +2 -2
  318. package/dist/storage/runs.mjs +1 -1
  319. package/dist/storage/send-list.mjs +62 -25
  320. package/dist/storage/stream-whole.mjs +84 -63
  321. package/dist/storage/swap-walk.mjs +1 -1
  322. package/dist/storage/unpack.mjs +878 -450
  323. package/dist/storage/visible.mjs +110 -32
  324. package/dist/storage/walk.mjs +1 -0
  325. package/dist/storage/wants.mjs +22 -58
  326. package/dist/store/call-count.d.mts +2 -2
  327. package/dist/store/call-count.mjs +24 -11
  328. package/dist/store/catalogue.d.mts +1 -1
  329. package/dist/store/catalogue.mjs +19 -7
  330. package/dist/store/crossing.mjs +1 -7
  331. package/dist/store/cursor-seal.d.mts +1 -1
  332. package/dist/store/cursor-seal.mjs +1 -1
  333. package/dist/store/door.mjs +9 -4
  334. package/dist/store/errors.d.mts +2 -2
  335. package/dist/store/errors.mjs +107 -19
  336. package/dist/store/git-store.mjs +7 -2
  337. package/dist/store/job-try.mjs +90 -9
  338. package/dist/store/list-job.mjs +10 -34
  339. package/dist/store/outbox.d.mts +2 -2
  340. package/dist/store/outbox.mjs +2 -2
  341. package/dist/store/queue-jobs.mjs +6 -12
  342. package/dist/store/records.d.mts +2 -2
  343. package/dist/store/records.mjs +2 -2
  344. package/dist/store/ref-rows.d.mts +2 -2
  345. package/dist/store/ref-rows.mjs +2 -2
  346. package/dist/store/repo-record.d.mts +2 -2
  347. package/dist/store/repo-record.mjs +3 -3
  348. package/dist/store/request-snapshot.mjs +5 -0
  349. package/dist/store/reservations.mjs +2 -2
  350. package/dist/store/topic-jobs.mjs +5 -11
  351. package/dist/sync/bound.d.mts +3 -3
  352. package/dist/sync/bound.mjs +10 -7
  353. package/dist/sync/github.mjs +65 -67
  354. package/dist/sync/http.mjs +1 -1
  355. package/dist/sync/import.mjs +201 -66
  356. package/dist/sync/layer.d.mts +1 -1
  357. package/dist/sync/layer.mjs +6 -6
  358. package/dist/sync/lfs-batch.mjs +1 -1
  359. package/dist/sync/lfs-copy.mjs +175 -15
  360. package/dist/sync/mirror.mjs +5 -10
  361. package/dist/sync/said.mjs +1 -1
  362. package/dist/sync/step.mjs +268 -86
  363. package/dist/sync/tries.mjs +25 -6
  364. package/dist/sync.d.mts +2 -2
  365. package/dist/sync.mjs +2 -2
  366. package/dist/topics/advance.mjs +3 -3
  367. package/dist/topics/calls.mjs +1 -1
  368. package/dist/topics/layer.d.mts +15 -14
  369. package/dist/topics/members.mjs +1 -1
  370. package/dist/topics/topic.mjs +1 -1
  371. package/package.json +3 -13
  372. package/dist/auth/helpers.mjs +0 -17
  373. package/dist/auth.d.mts +0 -5
  374. package/dist/auth.mjs +0 -5
  375. package/dist/core/rules/commit-changes.d.mts +0 -12
  376. package/dist/effect.d.mts +0 -9
  377. package/dist/effect.mjs +0 -7
  378. package/dist/server/joined.d.mts +0 -70
  379. package/dist/server/joined.mjs +0 -41
@@ -85,6 +85,17 @@ const importOwner = Object.freeze({
85
85
  owner: "import"
86
86
  });
87
87
  /**
88
+ * Git's own refs on a ref0 upstream, which no reader sees. Only a mirror's segment refs under it,
89
+ * `refs/ref0/mirror/<run>/<n>`, does a writer move: the mirror's own transport, pushed as a caller
90
+ * who reads every ref, and the target ref moves to them once they're whole (#2989, #3005).
91
+ */
92
+ const ref0Owner = Object.freeze({
93
+ prefix: "refs/ref0/",
94
+ owner: "ref0"
95
+ });
96
+ /** Where a mirror pushes its segments, the one part of `refs/ref0/` a writer moves. */
97
+ const mirrorSegments = "refs/ref0/mirror/";
98
+ /**
88
99
  * Git's own rows, beside each registered prefix's, which a server's registry adds at its seal: a
89
100
  * client's table, and the one this module's public encoders read.
90
101
  */
@@ -92,6 +103,11 @@ const gitsOwnRefs = [{
92
103
  owner: importOwner,
93
104
  underPrefix: "hidden",
94
105
  mover: "an import"
106
+ }, {
107
+ owner: ref0Owner,
108
+ underPrefix: "owned",
109
+ mover: "a mirror, under refs/ref0/mirror/,",
110
+ movedUnder: mirrorSegments
95
111
  }];
96
112
  /**
97
113
  * A registered prefix's row, as the registry adds it for a registration with `refs`: listed for a prefix
@@ -115,6 +131,17 @@ const hiddenUnder = (table, name) => table.find((hidden) => name.startsWith(hidd
115
131
  * a move of it no rule, hook, `ref.updated` or index update sees, and that owner's view sees it.
116
132
  */
117
133
  const gitsOwnMove = (table, as, ref) => as !== void 0 && hiddenUnder(table, ref)?.owner === as;
134
+ /** Whether any writer moves `ref`: it's under its row's `movedUnder`, as a mirror's segment is. */
135
+ const anyoneMoves = (table, ref) => {
136
+ const under = hiddenUnder(table, ref)?.movedUnder;
137
+ return under !== void 0 && ref.startsWith(under);
138
+ };
139
+ /**
140
+ * Whether a write moves `ref` as Git's own: its owner's move, or any writer's under a row's
141
+ * `movedUnder`, as a mirror's segments, which no reader sees. No rule, hook, publish check,
142
+ * `ref.updated` or `pushedAt` sees it.
143
+ */
144
+ const movesAsGitsOwn = (table, as, ref) => gitsOwnMove(table, as, ref) || anyoneMoves(table, ref);
118
145
  /**
119
146
  * Whether a host's own listing for `prefix` shows `name`, as `refs.list` does: a ref under a
120
147
  * hidden prefix only for a prefix under it, of any kind, since the host's code asks for it.
@@ -135,4 +162,4 @@ const listsRef = (table, name, prefixes) => {
135
162
  if (prefixes.length === 0) return hidden === void 0;
136
163
  return prefixes.some((prefix) => name.startsWith(prefix) && (hidden === void 0 || hidden.underPrefix === "listed" && prefix.startsWith(hidden.owner.prefix)));
137
164
  };
138
- export { byName, decoded, encodeErr, fetchReaches, gitsOwnMove, gitsOwnRefs, hiddenUnder, hostLists, importOwner, isWord, listsRef, ownedAway, readSection, refusedText, registeredRow, textLines, unwritable };
165
+ export { anyoneMoves, byName, decoded, encodeErr, fetchReaches, gitsOwnMove, gitsOwnRefs, hiddenUnder, hostLists, importOwner, isWord, listsRef, mirrorSegments, movesAsGitsOwn, ownedAway, readSection, ref0Owner, refusedText, registeredRow, textLines, unwritable };
@@ -7,16 +7,19 @@
7
7
  const pushUploadCapability = "push-upload";
8
8
  /** The capability for `above`. */
9
9
  const pushUploadOffer = (above) => `${pushUploadCapability}=${above}`;
10
- /** The size a receive-pack advertisement's capabilities offer the upload above, if they do. */
11
- const pushUploadAbove = (capabilities) => {
12
- const prefix = `${pushUploadCapability}=`;
10
+ const capNumber = (capabilities, name, nonzero) => {
11
+ const prefix = `${name}=`;
13
12
  const offered = capabilities.find((capability) => capability.startsWith(prefix));
14
13
  if (offered === void 0) return void 0;
15
14
  const raw = offered.slice(prefix.length);
16
- if (!/^[0-9]+$/.test(raw)) return void 0;
17
- const above = Number(raw);
18
- return Number.isSafeInteger(above) ? above : void 0;
15
+ if (!/^[0-9]+$/.test(raw) || nonzero && raw.startsWith("0")) return void 0;
16
+ const value = Number(raw);
17
+ return Number.isSafeInteger(value) ? value : void 0;
19
18
  };
19
+ /** The size a receive-pack advertisement's capabilities offer the upload above, if they do. */
20
+ const pushUploadAbove = (capabilities) => capNumber(capabilities, pushUploadCapability, false);
21
+ /** The max pack bytes a receive-pack advertisement's `ref0-push-bytes=<most>` allows, if any. */
22
+ const pushBytesLimit = (capabilities) => capNumber(capabilities, "ref0-push-bytes", true);
20
23
  /** `seconds` within `retryAfterLeast` and `retryAfterMost`, whole. */
21
24
  const retryAfterOf = (seconds) => Math.min(Math.max(Math.ceil(seconds), 1), 10);
22
25
  /**
@@ -29,4 +32,4 @@ const retryAfterOf = (seconds) => Math.min(Math.max(Math.ceil(seconds), 1), 10);
29
32
  * report.
30
33
  */
31
34
  const completeMost = 432e5;
32
- export { completeMost, pushUploadAbove, pushUploadCapability, pushUploadOffer, retryAfterOf };
35
+ export { completeMost, pushBytesLimit, pushUploadAbove, pushUploadCapability, pushUploadOffer, retryAfterOf };
@@ -1,6 +1,6 @@
1
1
  import { WireDecodeError, WireEncodeError } from "../bytes/errors.mjs";
2
- import * as Effect from "effect/Effect";
3
2
  import * as Schema from "effect/Schema";
3
+ import * as Effect from "effect/Effect";
4
4
  /**
5
5
  * The start of a push: what Git sends to `git-receive-pack` before the pack itself, as
6
6
  * `gitprotocol-pack` defines it. A server reads only this, then streams the rest of the body,
@@ -3,8 +3,8 @@ import { joinedBytes } from "../bytes/joined.mjs";
3
3
  import { isOid, quoted } from "../bytes/text.mjs";
4
4
  import { dataPkt, pktText, readPkt } from "../framing/pkt-line.mjs";
5
5
  import { decoded, isWord, textLines, unwritable } from "./lines.mjs";
6
- import * as Effect from "effect/Effect";
7
6
  import * as Schema from "effect/Schema";
7
+ import * as Effect from "effect/Effect";
8
8
  import * as Result from "effect/Result";
9
9
  // src/protocol/wire/receive-pack.ts
10
10
  /**
@@ -1,6 +1,6 @@
1
1
  import { WireDecodeError, WireEncodeError } from "../bytes/errors.mjs";
2
- import * as Effect from "effect/Effect";
3
2
  import * as Schema from "effect/Schema";
3
+ import * as Effect from "effect/Effect";
4
4
  /**
5
5
  * What `git-receive-pack` answers a push with: whether the pack unpacked, and each ref's
6
6
  * result, `ok` or `ng` with a reason, as `report-status` and `report-status-v2` define it.
@@ -3,8 +3,8 @@ import { quoted } from "../bytes/text.mjs";
3
3
  import { onBand } from "../framing/band.mjs";
4
4
  import { flushPkt, pktText, readPkt } from "../framing/pkt-line.mjs";
5
5
  import { decoded, isWord, textLines, unwritable } from "./lines.mjs";
6
- import * as Effect from "effect/Effect";
7
6
  import * as Schema from "effect/Schema";
7
+ import * as Effect from "effect/Effect";
8
8
  import * as Result from "effect/Result";
9
9
  // src/protocol/wire/report-status.ts
10
10
  /**
@@ -1,8 +1,8 @@
1
1
  import { WireDecodeError, WireEncodeError } from "../bytes/errors.mjs";
2
2
  import { ServedRefs } from "./advertisement.mjs";
3
3
  import "./lines.mjs";
4
- import * as Effect from "effect/Effect";
5
4
  import * as Schema from "effect/Schema";
5
+ import * as Effect from "effect/Effect";
6
6
  /**
7
7
  * Protocol v2 as `git-upload-pack` serves it over smart HTTP: its capability advertisement, the
8
8
  * requests that follow it, `command=<name>`, capabilities, a delim and the command's arguments,
@@ -4,8 +4,8 @@ import { isOid, quoted } from "../bytes/text.mjs";
4
4
  import { delimPkt, pktText, readPkt } from "../framing/pkt-line.mjs";
5
5
  import { AdvertisedRef, headOf, pastServiceLine, servedHead } from "./advertisement.mjs";
6
6
  import { byName, decoded, gitsOwnRefs, isWord, listsRef, readSection, refusedText, textLines, unwritable } from "./lines.mjs";
7
- import * as Effect from "effect/Effect";
8
7
  import * as Schema from "effect/Schema";
8
+ import * as Effect from "effect/Effect";
9
9
  import * as Result from "effect/Result";
10
10
  // src/protocol/wire/v2.ts
11
11
  /**
@@ -34,13 +34,13 @@ import { blameGroup, failEntries, groupsOf, openSearched, passGroup, reportDetai
34
34
  import { QueuePlan, entryNotes, loadTarget, openHolds, orderOf, storedId } from "./state.mjs";
35
35
  import { AdvanceData, CandidateData, advanceName, buildName, buildRow, timeoutName, timeoutRow } from "../store/queue-jobs.mjs";
36
36
  import { addTargetHold, advanceAfter, closeAll, closeCandidate, endEntry, entryOf, isOpen, movedOutside, releaseHold, removeEntry, stackOf, workHolds } from "./steps.mjs";
37
- import * as Clock from "effect/Clock";
38
- import * as Effect from "effect/Effect";
39
- import * as Schema from "effect/Schema";
40
- import * as Result from "effect/Result";
41
37
  import { CurrentJob, Job } from "@ref0/infra";
38
+ import * as Schema from "effect/Schema";
39
+ import * as Effect from "effect/Effect";
42
40
  import * as Predicate from "effect/Predicate";
43
41
  import * as Context from "effect/Context";
42
+ import * as Result from "effect/Result";
43
+ import * as Clock from "effect/Clock";
44
44
  // src/queue/advance.ts
45
45
  /**
46
46
  * The queue's jobs. `queue.advance`, one per target, moves it on a step at a time: a
@@ -66,6 +66,13 @@ const queueTry = (host, data, run) => Effect.flatMap(Effect.all([CurrentJob.curr
66
66
  signal
67
67
  }));
68
68
  const overCore = (host, _context, step) => Effect.provideContext(step, host.needs);
69
+ /**
70
+ * Ends `run` cleanly when it failed `NOT_FOUND` because its repo was already deleted: once
71
+ * `record` is absent or marked `deleted`, retrying a queue job can only fail the same way, and
72
+ * pointless retries contend for the claim lock. Any other `NOT_FOUND` (while the repo is still
73
+ * live) and any other failure keep the job's retry policy.
74
+ */
75
+ const endWhenDeleted = (context, internalId, run) => run.pipe(Effect.catch((error) => error.code !== "NOT_FOUND" ? Effect.fail(error) : readRecord(context.store, internalId).pipe(Effect.flatMap(({ record }) => record === void 0 || record.deleted === true ? Effect.succeed(void 0) : Effect.fail(error)))));
69
76
  /** A plan's write by the queue itself, its rules skipped: the calls that led to it were checked. */
70
77
  const queueOwn = (context, plan, answer) => ({
71
78
  kind: "write",
@@ -905,10 +912,7 @@ const buildStep = /* @__PURE__ */ Effect.fnUntraced(function* (host$1, context,
905
912
  const made = new MadeObjects();
906
913
  const read = (input) => {
907
914
  const object = made.get(input.oid);
908
- return object === void 0 ? opened.read(input) : Promise.resolve({
909
- kind: "success",
910
- value: gitObjectOf(object)
911
- });
915
+ return object === void 0 ? opened.read(input) : Effect.sync(() => gitObjectOf(object));
912
916
  };
913
917
  const links = landing ? row.entries : [...row.carried ?? [], ...row.entries];
914
918
  const from = row.built?.linked ?? 0;
@@ -952,21 +956,24 @@ const buildStep = /* @__PURE__ */ Effect.fnUntraced(function* (host$1, context,
952
956
  by
953
957
  };
954
958
  let first;
955
- const tooLarge = tried.tooLarge?.candidate === id ? tried.tooLarge : void 0;
959
+ const unlinked = tried.unlinked?.candidate === id ? tried.unlinked : void 0;
956
960
  const linkOf = Effect.fnUntraced(function* (entry, entryRow, onto) {
957
961
  const key = yield* linkKey(linking, onto, entry, entryRow);
958
962
  if (reached.at === from) first = {
959
963
  entry,
960
964
  key
961
965
  };
962
- if (tooLarge?.key === key) return yield* Effect.fail(linkFailed(entry, {
963
- kind: "tooLarge",
964
- summary: tooLarge.summary
965
- }));
966
+ if (unlinked?.key === key) return yield* Effect.fail(linkFailed(entry, unlinked.failure));
966
967
  const kept = last.get(key);
967
968
  const before = made.count;
968
969
  if (kept !== void 0) for (const { type, bytes } of kept.objects) yield* made.add(type, bytes);
969
- const commit = kept?.commit ?? (yield* linkOnto(linking, entry, entryRow, onto));
970
+ const commit = kept?.commit ?? (yield* linkOnto(linking, entry, entryRow, onto).pipe(Effect.tapErrorTag("LinkFailed", ({ failure }) => Effect.sync(() => {
971
+ tried.unlinked = {
972
+ candidate: id,
973
+ key,
974
+ failure
975
+ };
976
+ }))));
970
977
  by.set(key, {
971
978
  commit,
972
979
  objects: made.objects.slice(before)
@@ -988,16 +995,16 @@ const buildStep = /* @__PURE__ */ Effect.fnUntraced(function* (host$1, context,
988
995
  if (reached.at > from) return Effect.succeed(reached);
989
996
  if (first === void 0) return Effect.fail(error);
990
997
  const { entry, key } = first;
991
- const summary = `${entry} can't be linked within one build try: ${error.message}`;
992
- tried.tooLarge = {
998
+ const tooLarge = {
999
+ kind: "tooLarge",
1000
+ summary: `${entry} can't be linked within one build try: ${error.message}`
1001
+ };
1002
+ tried.unlinked = {
993
1003
  candidate: id,
994
1004
  key,
995
- summary
1005
+ failure: tooLarge
996
1006
  };
997
- return Effect.succeed({ failed: linkFailed(entry, {
998
- kind: "tooLarge",
999
- summary
1000
- }) });
1007
+ return Effect.succeed({ failed: linkFailed(entry, tooLarge) });
1001
1008
  }));
1002
1009
  const plan = new QueuePlan(state, now);
1003
1010
  if ("failed" in built) {
@@ -1273,9 +1280,9 @@ const queueJobs = (host, onFailure) => {
1273
1280
  const candidateOf = (job, context) => loadCandidate(context, jobRepo(job), job.data.candidate).pipe(Effect.map((loaded) => loaded?.state));
1274
1281
  return [
1275
1282
  queueTrimJob(host, onFailure),
1276
- jobParts(AdvanceJob, (data) => queueTry(host, data, (job, context) => overCore(host, context, advance(host, job, context))), { onFailure: holdOnFailure(host, targetOf, onFailure, unbatch) }),
1277
- jobParts(BuildJob, (data) => queueTry(host, data, (job, context) => Effect.asVoid(overCore(host, context, build(job, context)))), { onFailure: holdOnFailure(host, candidateOf, onFailure) }),
1278
- jobParts(TimeoutJob, (data) => queueTry(host, data, (job, context) => Effect.asVoid(overCore(host, context, timeout(job, context)))), { onFailure: holdOnFailure(host, candidateOf, onFailure) })
1283
+ jobParts(AdvanceJob, (data) => queueTry(host, data, (job, context) => endWhenDeleted(context, jobRepo(job), overCore(host, context, advance(host, job, context)))), { onFailure: holdOnFailure(host, targetOf, onFailure, unbatch) }),
1284
+ jobParts(BuildJob, (data) => queueTry(host, data, (job, context) => Effect.asVoid(endWhenDeleted(context, jobRepo(job), overCore(host, context, build(job, context))))), { onFailure: holdOnFailure(host, candidateOf, onFailure) }),
1285
+ jobParts(TimeoutJob, (data) => queueTry(host, data, (job, context) => Effect.asVoid(endWhenDeleted(context, jobRepo(job), overCore(host, context, timeout(job, context))))), { onFailure: holdOnFailure(host, candidateOf, onFailure) })
1279
1286
  ];
1280
1287
  };
1281
1288
  export { checkPublish, queueJobs };
@@ -3,13 +3,13 @@ import { InternalRepoId, RepoName } from "../contracts/ids.mjs";
3
3
  import { MergeQueueCalls } from "../contracts/queue.mjs";
4
4
  import { RefEdit, RefsUpdated } from "../contracts/refs.mjs";
5
5
  import { GitError } from "../contracts/result.mjs";
6
- import { EffectCalls } from "../contracts/services.mjs";
6
+ import { Needing } from "../contracts/services.mjs";
7
7
  import { WorkFailed } from "../core/events/deliver.mjs";
8
8
  import { QueueNeeds } from "../core/parts.mjs";
9
9
  import { EntryAdderOf } from "../core/saved-caller-views.mjs";
10
10
  import { QueueHost } from "./host.mjs";
11
- import * as Effect from "effect/Effect";
12
11
  import { Records } from "@ref0/infra";
12
+ import * as Effect from "effect/Effect";
13
13
  import * as Context from "effect/Context";
14
14
  /** The branches a push queues, once it's landed: the lines Git prints as `remote:` for them. */
15
15
  export type QueuedBranches = (updated: RefsUpdated) => Effect.Effect<readonly string[]>;
@@ -32,7 +32,7 @@ export type QueuePush = (caller: Caller, repo: RepoName, edits: readonly RefEdit
32
32
  export interface QueueAttached {
33
33
  readonly host: QueueHost;
34
34
  /** The `queue` group deciding for `bound`, as the server's other groups do. */
35
- readonly calls: (bound?: Caller) => EffectCalls<MergeQueueCalls, QueueNeeds>;
35
+ readonly calls: (bound?: Caller) => Needing<MergeQueueCalls, QueueNeeds>;
36
36
  readonly push: QueuePush;
37
37
  /** `SavedCallers.queueEntry`'s reader of who added an entry. */
38
38
  readonly entryAdder: EntryAdderOf;
@@ -44,6 +44,8 @@ declare const QueueBase_base: Context.ServiceClass<QueueBase, "@ref0/git/queue/Q
44
44
  /** The CPU one try may use, from the adapter's `RequestLimits`: none where it gives none. */
45
45
  readonly cpuMs: number | undefined;
46
46
  readonly attach: (queue: QueueAttached) => Effect.Effect<void>;
47
+ /** The server's door, which each of `MergeQueue`'s calls goes through, as core's do. */
48
+ readonly door: <A>(effect: Effect.Effect<A, GitError>) => Effect.Effect<A, GitError>;
47
49
  }>;
48
50
  /**
49
51
  * What core hands `MergeQueue.layer`, inside the runtime only: the parts the queue runs over, what
@@ -13,7 +13,7 @@ import { Changes } from "../core/changes.mjs";
13
13
  import { unseenRef } from "../core/rules/check.mjs";
14
14
  import { savedCallerOf } from "../core/saved-callers.mjs";
15
15
  import { limitsOf } from "../engine/reads.mjs";
16
- import { decodeRow, resultCall, storeCall } from "../store/errors.mjs";
16
+ import { decodeRow, storeCall } from "../store/errors.mjs";
17
17
  import { keptKey } from "../store/records.mjs";
18
18
  import { readRecord } from "../store/repo-record.mjs";
19
19
  import { refuseLive, reservedTarget, topicMember } from "../store/reservations.mjs";
@@ -28,9 +28,9 @@ import { CandidateRow, EntryRow, HoldRow } from "./rows.mjs";
28
28
  import { QueuePlan, entryNotes, loadTarget, openHolds, orderOf, readEntries, unknownId } from "./state.mjs";
29
29
  import { noQueue } from "./base.mjs";
30
30
  import { addTargetHold, advanceAfter, aheadOf, candidateOf, closeAll, closeCandidate, endSearch, entryOf, held, holdOf, isOpen, joinedAt, keyHoldsOf, releaseHold, removeEntry, setChecking, supersede } from "./steps.mjs";
31
- import * as Clock from "effect/Clock";
32
- import * as Effect from "effect/Effect";
33
31
  import * as Schema from "effect/Schema";
32
+ import * as Effect from "effect/Effect";
33
+ import * as Clock from "effect/Clock";
34
34
  // src/queue/calls.ts
35
35
  const idKinds = {
36
36
  e: {
@@ -362,8 +362,8 @@ const lanesFor = /* @__PURE__ */ Effect.fnUntraced(function* (caller, opened) {
362
362
  const { between } = yield* Changes;
363
363
  const diff = between({
364
364
  objects: {
365
- read: (_, at) => resultCall(() => repo.read(at)),
366
- objects: (_, at) => resultCall(() => repo.batch(at))
365
+ read: (_, at) => repo.read(at),
366
+ objects: (_, at) => repo.batch(at)
367
367
  },
368
368
  listed: repo.listed,
369
369
  from: tip ?? void 0,
@@ -11,9 +11,9 @@ import { trimRow } from "../store/queue-jobs.mjs";
11
11
  import { queueLimits, targetsFull } from "./limits.mjs";
12
12
  import { noteAlone } from "./state.mjs";
13
13
  import { CoreParts, asHost } from "../core/parts.mjs";
14
+ import * as Schema from "effect/Schema";
14
15
  import * as Effect from "effect/Effect";
15
16
  import * as Option from "effect/Option";
16
- import * as Schema from "effect/Schema";
17
17
  // src/queue/commit.ts
18
18
  /** An answer as its receipt keeps it: every answer is built from JSON rows, so it is JSON. */
19
19
  const asJson = /* @__PURE__ */ Schema.decodeUnknownSync(Schema.Json);
@@ -3,8 +3,8 @@ import { RepoName } from "../contracts/ids.mjs";
3
3
  import { MergeQueueOptions, QueueKeys } from "../contracts/queue.mjs";
4
4
  import { GitError } from "../contracts/result.mjs";
5
5
  import { QueueNeeds } from "../core/parts.mjs";
6
- import * as Effect from "effect/Effect";
7
6
  import { Records } from "@ref0/infra";
7
+ import * as Effect from "effect/Effect";
8
8
  import * as Context from "effect/Context";
9
9
  /**
10
10
  * What the queue runs over, which `MergeQueue.layer` makes: the server's services, which its jobs
@@ -1,7 +1,6 @@
1
1
  import { Git } from "../contracts/git.mjs";
2
2
  import { MergeQueue, MergeQueueLayerOptions } from "../contracts/queue.mjs";
3
3
  import { GitError } from "../contracts/result.mjs";
4
- import "../contracts/services.mjs";
5
4
  import { Merges } from "../core/merge-parts.mjs";
6
5
  import { QueueBase } from "./base.mjs";
7
6
  import { QueueInternals } from "./host.mjs";
@@ -9,14 +9,18 @@ import { QueueInternals, queueKeysOf, queueOptions } from "./host.mjs";
9
9
  import { buildMillisecondsOf } from "./limits.mjs";
10
10
  import { queuePush } from "./push-option.mjs";
11
11
  import * as Effect from "effect/Effect";
12
- import * as Option from "effect/Option";
13
12
  import * as Context from "effect/Context";
14
13
  import * as Layer from "effect/Layer";
14
+ import * as Option from "effect/Option";
15
15
  // src/queue/layer.ts
16
- /** `git.queue` over `host`, each call deciding for its `by`, over the host's parts. */
17
- const queueService = (host) => {
18
- const run = (by, call) => Effect.provideContext(acting(by, call(queueCalls(host, by))), host.needs);
16
+ /**
17
+ * `git.queue` over `host`, each call deciding for its `by`, over the host's parts and through the
18
+ * server's `door`, with the queue's `keys`.
19
+ */
20
+ const queueService = (host, door) => {
21
+ const run = (by, call) => door(Effect.suspend(() => Effect.provideContext(acting(by, call(queueCalls(host, by))), host.needs)));
19
22
  return {
23
+ keys: host.keys,
20
24
  add: (repo, input, by) => run(by, (calls) => calls.add(repo, input)),
21
25
  remove: (entry, input, by) => run(by, (calls) => calls.remove(entry, input)),
22
26
  hold: (...[first, input, by]) => run(by, (calls) => calls.hold(...[first, input])),
@@ -64,7 +68,7 @@ const layer = (options) => {
64
68
  push: queuePush(host),
65
69
  entryAdder: entryAdderOf
66
70
  });
67
- return Context.make(MergeQueue, queueService(host)).pipe(Context.add(QueueInternals, host));
71
+ return Context.make(MergeQueue, queueService(host, base.door)).pipe(Context.add(QueueInternals, host));
68
72
  }));
69
73
  };
70
74
  export { layer, queueService };
@@ -6,8 +6,8 @@ import { lanesNamed } from "./lanes.mjs";
6
6
  import { entryNotes, orderOf } from "./state.mjs";
7
7
  import { candidateOf, entryOf } from "./steps.mjs";
8
8
  import { CoreParts } from "../core/parts.mjs";
9
- import * as Effect from "effect/Effect";
10
9
  import * as Schema from "effect/Schema";
10
+ import * as Effect from "effect/Effect";
11
11
  import * as Predicate from "effect/Predicate";
12
12
  // src/queue/schedule.ts
13
13
  /** A target's last outcomes, as its row keeps them, oldest first. */
@@ -5,8 +5,8 @@ import { openCandidate } from "./calls.mjs";
5
5
  import { lanesNamed, placeOf, placed } from "./lanes.mjs";
6
6
  import { concurrencyOf, roomFor, schedulesOf } from "./schedule.mjs";
7
7
  import { candidateOf, closeCandidate, endEntry, endSearch, isOpen, releaseEntry, setChecking } from "./steps.mjs";
8
- import * as Effect from "effect/Effect";
9
8
  import * as Schema from "effect/Schema";
9
+ import * as Effect from "effect/Effect";
10
10
  // src/queue/search.ts
11
11
  /** A report's summary and URL, for the events of the entries it failed. */
12
12
  const reportDetails = (report) => {
@@ -9,8 +9,8 @@ import { collections, prunedKey } from "../store/scopes.mjs";
9
9
  import { queueId } from "./ids.mjs";
10
10
  import { placeOrder } from "./pages.mjs";
11
11
  import { CandidateRow, CounterRow, EntryRow, HoldRow, KeyRow, MetaRow, ReportRow, TargetRow } from "./rows.mjs";
12
- import * as Effect from "effect/Effect";
13
12
  import * as Schema from "effect/Schema";
13
+ import * as Effect from "effect/Effect";
14
14
  // src/queue/state.ts
15
15
  /** The queue merges onto its target's tip whoever added the entry: it reads the repo whole. */
16
16
  const queueWhole = /* @__PURE__ */ WholeRepo.mint();
@@ -7,10 +7,10 @@ import { collections, jobRepo, newChangeId, repoScope } from "../store/scopes.mj
7
7
  import { queueJobRetry, queueLimits } from "./limits.mjs";
8
8
  import { CandidateRow, EntryRow, HoldRow, KeyRow, TargetRow } from "./rows.mjs";
9
9
  import { keyRowId } from "./state.mjs";
10
- import * as Clock from "effect/Clock";
11
- import * as Effect from "effect/Effect";
12
10
  import { CurrentJob, Job } from "@ref0/infra";
11
+ import * as Effect from "effect/Effect";
13
12
  import * as Context from "effect/Context";
13
+ import * as Clock from "effect/Clock";
14
14
  // src/queue/trim.ts
15
15
  const phases = [
16
16
  "targets",
@@ -7,9 +7,9 @@ import { CreatedToken, TokenCreateInput, TokenTarget, Tokens } from "../contract
7
7
  import { RestEvents } from "./listen.mjs";
8
8
  import { Me } from "./me.mjs";
9
9
  import * as Effect from "effect/Effect";
10
- import * as HttpClient from "effect/http/HttpClient";
11
10
  import * as Context from "effect/Context";
12
11
  import * as Layer from "effect/Layer";
12
+ import * as HttpClient from "effect/http/HttpClient";
13
13
  declare namespace client_d_exports {
14
14
  export { RestClient, RestClientCalls, RestRepoCalls, RestTokenCalls, layer, make };
15
15
  }
@@ -8,19 +8,19 @@ import { abortable, credentialHeader, credentialRefused, pauseOf, shouldRetry, u
8
8
  import { jsonError, restFailure } from "./errors.mjs";
9
9
  import { listenOver } from "./listen.mjs";
10
10
  import { readableUrl } from "./paths.mjs";
11
- import * as Effect from "effect/Effect";
12
- import * as HttpClient from "effect/http/HttpClient";
13
- import * as HttpClientResponse from "effect/http/HttpClientResponse";
14
- import * as Option from "effect/Option";
15
11
  import * as Schema from "effect/Schema";
16
- import * as Exit from "effect/Exit";
12
+ import * as Effect from "effect/Effect";
17
13
  import * as Predicate from "effect/Predicate";
14
+ import * as Stream from "effect/Stream";
18
15
  import * as Context from "effect/Context";
19
16
  import * as Layer from "effect/Layer";
20
- import * as Stream from "effect/Stream";
17
+ import * as Option from "effect/Option";
18
+ import * as Exit from "effect/Exit";
19
+ import * as HttpClient from "effect/http/HttpClient";
21
20
  import * as Scope from "effect/Scope";
22
21
  import * as FetchHttpClient from "effect/http/FetchHttpClient";
23
22
  import * as HttpClientRequest from "effect/http/HttpClientRequest";
23
+ import * as HttpClientResponse from "effect/http/HttpClientResponse";
24
24
  import * as HttpClientError from "effect/http/HttpClientError";
25
25
  import { HttpApiClient } from "effect/http-api";
26
26
  // src/rest/client.ts
@@ -1,8 +1,8 @@
1
1
  import { ContextValue, GitErrorBody, gitError, gitErrorBodies, gitErrorFrom, httpStatus, isGitErrorCode, refusalCodeHeader } from "../contracts/result.mjs";
2
2
  import { bodyStart, dropped } from "../client/transport.mjs";
3
+ import * as Schema from "effect/Schema";
3
4
  import * as Effect from "effect/Effect";
4
5
  import * as Option from "effect/Option";
5
- import * as Schema from "effect/Schema";
6
6
  import { HttpApiSchema } from "effect/http-api";
7
7
  import * as SchemaAST from "effect/SchemaAST";
8
8
  // src/rest/errors.ts
@@ -9,11 +9,11 @@ import { normalBase, restPath, wireRepoPath } from "./paths.mjs";
9
9
  import { exitIn, noCall } from "../store/crossing.mjs";
10
10
  import { answerSpent } from "../store/errors.mjs";
11
11
  import "effect/Effect";
12
+ import * as Context from "effect/Context";
13
+ import * as Layer from "effect/Layer";
12
14
  import * as Option from "effect/Option";
13
15
  import * as Cause from "effect/Cause";
14
16
  import * as Exit from "effect/Exit";
15
- import * as Context from "effect/Context";
16
- import * as Layer from "effect/Layer";
17
17
  import { HttpApiBuilder } from "effect/http-api";
18
18
  import * as HttpRouter from "effect/http/HttpRouter";
19
19
  import * as HttpServer from "effect/http/HttpServer";
@@ -14,9 +14,9 @@ import { GitCallerMiddleware, GitRestServices, IncomingRequest } from "./caller.
14
14
  import { sseResponse } from "./events.mjs";
15
15
  import { answerSpent } from "../store/errors.mjs";
16
16
  import * as Effect from "effect/Effect";
17
- import * as Option from "effect/Option";
18
- import * as Layer from "effect/Layer";
19
17
  import * as Stream from "effect/Stream";
18
+ import * as Layer from "effect/Layer";
19
+ import * as Option from "effect/Option";
20
20
  import { HttpApiBuilder, HttpApiSchema } from "effect/http-api";
21
21
  import * as HttpServerRequest from "effect/http/HttpServerRequest";
22
22
  import { HttpApiSchemaError } from "effect/http-api/HttpApiError";
@@ -354,9 +354,14 @@ const BlobsHandlers = HttpApiBuilder.group(GitRestApi, "blobs", (handlers) => ha
354
354
  });
355
355
  })));
356
356
  const TreesHandlers = HttpApiBuilder.group(GitRestApi, "trees", (handlers) => handlers.handle("get", ({ params, query }) => Effect.gen(function* () {
357
- return yield* (yield* callsFor).trees.get(params.repo, {
357
+ const server = yield* callsFor;
358
+ const limit = query.limit === void 0 ? {} : { limit: Math.min(query.limit, 200) };
359
+ return yield* server.trees.get(params.repo, {
358
360
  oid: params.oid,
359
- ...readInput(query),
361
+ ...readInput({
362
+ ...query,
363
+ ...limit
364
+ }),
360
365
  actor: yield* actor
361
366
  });
362
367
  })).handle("diff", ({ params, payload }) => Effect.gen(function* () {
@@ -448,8 +453,13 @@ const MergesHandlers = HttpApiBuilder.group(GitRestApi, "merges", (handlers) =>
448
453
  });
449
454
  })));
450
455
  const FilesHandlers = HttpApiBuilder.group(GitRestApi, "files", (handlers) => handlers.handle("list", ({ params, query }) => Effect.gen(function* () {
451
- return yield* (yield* callsFor).files.list(params.repo, {
452
- ...readInput(query),
456
+ const server = yield* callsFor;
457
+ const limit = query.limit === void 0 ? {} : { limit: Math.min(query.limit, 200) };
458
+ return yield* server.files.list(params.repo, {
459
+ ...readInput({
460
+ ...query,
461
+ ...limit
462
+ }),
453
463
  actor: yield* actor
454
464
  });
455
465
  })).handle("read", ({ params, payload }) => Effect.gen(function* () {
@@ -5,9 +5,9 @@ import { ServedParts } from "../core/seam.mjs";
5
5
  import { GitRestServices } from "./caller.mjs";
6
6
  import { notFound, restApp } from "./handler.mjs";
7
7
  import * as Effect from "effect/Effect";
8
- import * as Option from "effect/Option";
9
8
  import * as Context from "effect/Context";
10
9
  import * as Layer from "effect/Layer";
10
+ import * as Option from "effect/Option";
11
11
  // src/rest/layer.ts
12
12
  var layer_exports = /* @__PURE__ */ __exportAll({ layer: () => layer });
13
13
  /** REST's URLs under `<base>`, as `restPath` owns them: each a route of the `rest` registration. */
@@ -1,10 +1,10 @@
1
1
  import { gitError } from "../contracts/result.mjs";
2
2
  import { RepoStreamEvent, StreamEnd } from "./wire.mjs";
3
- import * as Effect from "effect/Effect";
4
- import * as Option from "effect/Option";
5
3
  import * as Schema from "effect/Schema";
4
+ import * as Effect from "effect/Effect";
6
5
  import * as Predicate from "effect/Predicate";
7
6
  import * as Stream from "effect/Stream";
7
+ import * as Option from "effect/Option";
8
8
  import * as Sse from "effect/encoding/Sse";
9
9
  // src/rest/listen.ts
10
10
  /** The first pause before opening again a connection that sent no event, doubled up to 9 s. */
@@ -1,5 +1,5 @@
1
- import { Listing } from "../contracts/engine.mjs";
2
1
  import { Ref, RefCount, RefCountFields, RefList, RefOutcome, RefProtection, RefsProtections, RefsSees, RefsUpdate } from "../contracts/refs.mjs";
2
+ import { Listing } from "../contracts/engine.mjs";
3
3
  import { GitCallerMiddleware } from "./caller.mjs";
4
4
  import { GitErrors } from "./errors.mjs";
5
5
  import { PageQuery, RepoParam, WriteKey } from "./wire.mjs";
@@ -2,12 +2,27 @@ import { handle } from "../contracts/git.mjs";
2
2
  import { gitError } from "../contracts/result.mjs";
3
3
  import { refusal } from "../http/answers.mjs";
4
4
  import { buildRefused, retries, retryDelay } from "./lifecycle.mjs";
5
+ import { HostRuntime } from "@ref0/infra";
5
6
  import * as Effect from "effect/Effect";
7
+ import * as Layer from "effect/Layer";
6
8
  import * as Cause from "effect/Cause";
7
9
  import * as Exit from "effect/Exit";
8
- import { HostRuntime } from "@ref0/infra";
9
- import * as Layer from "effect/Layer";
10
+ import * as Tracer from "effect/Tracer";
10
11
  // src/server/edge.ts
12
+ /** A W3C `traceparent` header's trace, span, and flags: `00-<trace>-<span>-<flags>`. */
13
+ const traceparentPattern = /^00-([\da-f]{32})-([\da-f]{16})-([\da-f]{2})$/;
14
+ const zeroTraceId = "00000000000000000000000000000000";
15
+ const zeroSpanId = "0000000000000000";
16
+ /** The caller's external span from `request`'s `traceparent` header, when valid (#3019). */
17
+ const parentOf = (request) => {
18
+ const [, traceId, spanId, flags] = traceparentPattern.exec(request.headers.get("traceparent") ?? "") ?? [];
19
+ if (traceId === void 0 || spanId === void 0 || flags === void 0 || traceId === zeroTraceId || spanId === zeroSpanId) return;
20
+ return Tracer.externalSpan({
21
+ traceId,
22
+ spanId,
23
+ sampled: (Number.parseInt(flags, 16) & 1) === 1
24
+ });
25
+ };
11
26
  /**
12
27
  * A host's one runtime over `layer`, `Git.layer` and its adapter, which every entry, object class,
13
28
  * job runner and direct run shares: it builds on its first use, and again on a fresh runtime after
@@ -36,7 +51,16 @@ const runtime = (layer) => {
36
51
  * disposes of it; `toFetch` builds nothing of its own.
37
52
  */
38
53
  const toFetch = (host) => async (request) => {
39
- const answer = await host.runPromiseExit(handle(request), { signal: request.signal });
54
+ const parent = parentOf(request);
55
+ const attributes = {
56
+ "http.method": request.method,
57
+ "url.path": new URL(request.url).pathname
58
+ };
59
+ const traced = handle(request).pipe(Effect.tap((response) => Effect.annotateCurrentSpan("http.status_code", response.status)), Effect.withSpan("git.fetch", parent === void 0 ? { attributes } : {
60
+ attributes,
61
+ parent
62
+ }));
63
+ const answer = await host.runPromiseExit(traced, { signal: request.signal });
40
64
  if (Exit.isSuccess(answer)) return answer.value;
41
65
  if (request.signal.aborted && Cause.hasInterruptsOnly(answer.cause)) return new Response(null, { status: 499 });
42
66
  return refusal(buildRefused(host.state()) ?? gitError("INTERNAL", "The server failed"));