@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
@@ -1,29 +1,20 @@
1
- import { isGitError } from "../../contracts/result.mjs";
1
+ import { gitError } from "../../contracts/result.mjs";
2
2
  import { emptyTree } from "../../protocol/objects/object.mjs";
3
3
  import { WalkRefused, combinedPaths } from "../../engine/combined.mjs";
4
+ import { noRepoRoots, parentsWithin } from "../../protocol/objects/commit.mjs";
4
5
  import { allotmentWithin } from "../../contracts/object-values.mjs";
5
6
  import { openTreeBytes } from "../../storage/budget.mjs";
6
7
  import { openTreesRefusal } from "../../storage/push-allotment.mjs";
7
- import { answerFailed } from "../../contracts/calls-spent.mjs";
8
+ import "../ancestry.mjs";
8
9
  import { commitOf, treeOf, withEmptyTree } from "./changes.mjs";
9
10
  import * as Effect from "effect/Effect";
10
- import * as Option from "effect/Option";
11
11
  import * as Predicate from "effect/Predicate";
12
12
  import * as Stream from "effect/Stream";
13
+ import * as Option from "effect/Option";
13
14
  // src/core/rules/commit-changes.ts
14
15
  /** Whether `received` brings any object at all: a pack, or rows. */
15
16
  const brings = (received) => (received.change.add?.length ?? 0) > 0 || (received.change.put?.length ?? 0) > 0;
16
17
  /**
17
- * What the engine's walk threw, back in Effect: its allotment's refusal, a read's error, as the
18
- * engine throws Git's errors with each as the cause, and a spent call bound's as the defect it is.
19
- * Anything else is a defect.
20
- */
21
- const walkFailure = (cause) => {
22
- if (cause instanceof WalkRefused) return Stream.fail(cause);
23
- const error = Predicate.hasProperty(cause, "cause") ? cause.cause : void 0;
24
- return isGitError(error) ? Stream.fromEffect(answerFailed(error)) : Stream.die(cause);
25
- };
26
- /**
27
18
  * An allotment of at most `most` bytes for a walk's open trees, refused past it with
28
19
  * `openTreesRefusal`, outside any memory budget: the walk's own when it has neither its push's
29
20
  * allotment nor a reader's. A push whose storage keeps one walks within it: its open trees grow
@@ -45,7 +36,7 @@ const commitPaths = (input, commit, allotment) => Stream.unwrap(Effect.gen(funct
45
36
  signal: input.signal
46
37
  };
47
38
  if (input.batch !== void 0) walked.objects = input.batch;
48
- return Stream.fromAsyncIterable(combinedPaths(walked), (cause) => cause).pipe(Stream.catch(walkFailure));
39
+ return combinedPaths(walked);
49
40
  }));
50
41
  /** How far back a chain search looks: the first-parent chain's first 1,000 commits (Q734). */
51
42
  const chainMost = 1e3;
@@ -78,10 +69,9 @@ const chainSearch = (input, starts) => {
78
69
  };
79
70
  /**
80
71
  * `commit`'s paths against the parents that count. On the first path the rule refuses, when a
81
- * parent was left out, it searches the chains for those left out, and for the tip itself on a move
82
- * (Q734). A tip it finds was judged on its way there, so nothing more is listed; a parent it finds
83
- * counts, and the commit is walked again against it and each parent at a covered tip. Otherwise
84
- * the walk goes on, and the path is listed. A push with no refused path pays for no search.
72
+ * parent was left out, it searches the chains for those left out (Q734): a parent it finds counts,
73
+ * and the commit is walked again against it and each parent at a covered tip. Otherwise the walk
74
+ * goes on, and the path is listed. A push with no refused path pays for no search.
85
75
  */
86
76
  const judgedPaths = (input, commit, search, allotment) => {
87
77
  const { refuses } = input;
@@ -89,20 +79,18 @@ const judgedPaths = (input, commit, search, allotment) => {
89
79
  oid: commit.oid,
90
80
  parents: commit.counted
91
81
  };
92
- if (!(refuses !== void 0 && (commit.left.length > 0 || commit.self !== void 0))) return commitPaths(input, walked, allotment);
82
+ if (!(refuses !== void 0 && commit.left.length > 0)) return commitPaths(input, walked, allotment);
93
83
  return Stream.suspend(() => {
94
- const candidates = commit.self === void 0 ? commit.left : [commit.self, ...commit.left];
95
84
  let trusted;
96
85
  const listed = (change) => {
97
86
  if (trusted !== void 0 || !refuses(change)) return Effect.succeed(change);
98
- return Effect.map(search(candidates), (found) => {
87
+ return Effect.map(search(commit.left), (found) => {
99
88
  trusted = found;
100
89
  return found.length > 0 ? void 0 : change;
101
90
  });
102
91
  };
103
92
  const again = Stream.suspend(() => {
104
93
  if (trusted === void 0 || trusted.length === 0) return Stream.empty;
105
- if (commit.self !== void 0 && trusted.includes(commit.self)) return Stream.empty;
106
94
  const counts = /* @__PURE__ */ new Set([...commit.counted, ...trusted]);
107
95
  const parents = commit.parents.filter((parent) => counts.has(parent) || input.covered?.(parent) === true);
108
96
  return commitPaths(input, {
@@ -114,36 +102,108 @@ const judgedPaths = (input, commit, search, allotment) => {
114
102
  });
115
103
  };
116
104
  /**
117
- * How a move's new tip is walked, one that brings no commits of its own: an API write, or a push
118
- * of a ref onto a commit it doesn't bring (Q732, Q734). When the tip's first parent is the old tip,
119
- * or the tip of a ref `covered` holds, it's walked against that parent and each later one that
120
- * counts, so a merge commit of a covered branch is judged as a push of that one commit is.
121
- * Otherwise it's walked against the old tip, or as a root for a ref it makes, so what the tip takes
122
- * from a commit the rule never saw, made unpublished, a fork's pull head or an older commit of a
123
- * covered branch, is listed, unless a refusal's search finds it judged. A squash, a rebase and a
124
- * fast-forward still differ from the old tip by what they bring.
105
+ * A move's walk past `limit` commits it adds: what it adds can't be judged, so the rule refuses the
106
+ * ref with it, as it does a walk its allotment stops.
125
107
  */
126
- const movedTip = /* @__PURE__ */ Effect.fnUntraced(function* (input, update) {
108
+ const movePastLimit = (limit) => new WalkRefused({ refusal: gitError("RESOURCE_EXHAUSTED", `This move adds over ${limit} commits to check, a merge counted per parent`, {
109
+ hint: "Move the ref in steps",
110
+ context: { reason: "walk-limit" }
111
+ }) });
112
+ /** What the old tip reaches, past its walk's bound, refuses the ref as the walk's limit does. */
113
+ const refusedPastBound = (error) => Effect.fail(error.code === "RESOURCE_EXHAUSTED" ? new WalkRefused({ refusal: error }) : error);
114
+ /**
115
+ * The commits from `to` down to `ends` and the repo's roots, each read once, less those `held`
116
+ * answers for and the commits behind them: none past `limit`, each counted for its parents.
117
+ */
118
+ const walkedDown = /* @__PURE__ */ Effect.fnUntraced(function* (input, to, ends, held, limit) {
119
+ const read = withEmptyTree(input.read);
120
+ const added = [];
121
+ const passed = /* @__PURE__ */ new Set([to]);
122
+ let frontier = [to];
123
+ let taken = 0;
124
+ while (frontier.length > 0) {
125
+ const open = frontier.filter((oid) => !ends(oid));
126
+ const kept = held === void 0 || open.length === 0 ? /* @__PURE__ */ new Set() : yield* held(open);
127
+ frontier = [];
128
+ for (const oid of open) {
129
+ if (kept.has(oid)) continue;
130
+ if (taken >= limit) return void 0;
131
+ const commit = yield* commitOf(read, oid, input.signal);
132
+ if (commit === void 0) continue;
133
+ const parents = parentsWithin(input.roots ?? noRepoRoots, oid, commit.parents);
134
+ taken += Math.max(1, parents.length);
135
+ added.push({
136
+ oid,
137
+ parents
138
+ });
139
+ for (const parent of parents) {
140
+ if (passed.has(parent)) continue;
141
+ passed.add(parent);
142
+ frontier.push(parent);
143
+ }
144
+ }
145
+ }
146
+ return added;
147
+ });
148
+ /** The commits of `walked` whose parents lead down to `from`: newer than it, so none it reaches. */
149
+ const leadingTo = (walked, from) => {
150
+ const children = /* @__PURE__ */ new Map();
151
+ for (const commit of walked) for (const parent of commit.parents) children.set(parent, [...children.get(parent) ?? [], commit.oid]);
152
+ const leads = /* @__PURE__ */ new Set();
153
+ const waiting = [...children.get(from) ?? []];
154
+ for (let oid = waiting.pop(); oid !== void 0; oid = waiting.pop()) {
155
+ if (leads.has(oid)) continue;
156
+ leads.add(oid);
157
+ waiting.push(...children.get(oid) ?? []);
158
+ }
159
+ return leads;
160
+ };
161
+ /**
162
+ * Which of `oids`, commits newer than the old tip, the default branch reaches when the rule covers
163
+ * it and it isn't the old tip itself: none past its walk's bound, so those are judged, never let
164
+ * through unread.
165
+ */
166
+ const defaultHolds = (input, from, oids) => {
167
+ const { defaultTip } = input;
168
+ const reach = defaultTip === void 0 || defaultTip === from ? void 0 : input.reach?.([defaultTip]);
169
+ if (reach === void 0 || oids.length === 0) return Effect.succeed(/* @__PURE__ */ new Set());
170
+ return reach.has(oids, { signal: input.signal }).pipe(Effect.catchIf((error) => error.code === "RESOURCE_EXHAUSTED", () => Effect.succeed(/* @__PURE__ */ new Set())));
171
+ };
172
+ /**
173
+ * The commits a move's new tip adds to its ref, one that brings no commits of its own: an API
174
+ * write, or a push of a ref onto a commit it doesn't bring. A walk from the tip ends at each commit
175
+ * already on the ref, which the old tip reaches, as `reach` answers, or on the default branch when
176
+ * the rule covers it, and at each covered tip, which a rule judged on its way there, but not at a
177
+ * covered tip's older commits. Each commit it adds is then walked as a push's brought one is
178
+ * (#3016), so a commit made unpublished and moved onto later, deleting what its parent added,
179
+ * can't hide the parent's paths. Past `limit` commits it's refused, as a push's walks are past
180
+ * `ancestryLimit`.
181
+ *
182
+ * It walks first without `reach`, within `limit`, and asks the old tip's and the default branch's
183
+ * of the commits whose parents don't lead down to the old tip. Those that do, newer than it, are
184
+ * asked of the default branch's alone: a fast-forward, or a merge commit onto the old tip, of a
185
+ * branch the default isn't, so a repo with no reachability index never walks the ref's whole
186
+ * history to answer that its new commits aren't in it. A move onto older history, past `limit`
187
+ * that way, walks again asking.
188
+ */
189
+ const addedBy = /* @__PURE__ */ Effect.fnUntraced(function* (input, update) {
127
190
  const { to, from } = update;
128
- if (input.covered?.(to) === true) return void 0;
129
- const commit = yield* commitOf(withEmptyTree(input.read), to, input.signal);
130
- const counts = (parent) => parent === from || input.covered?.(parent) === true;
131
- const parents = commit?.parents ?? [];
132
- const [first, ...rest] = parents;
133
- if (first !== void 0 && counts(first)) return {
134
- oid: to,
135
- parents,
136
- counted: [first, ...rest.filter(counts)],
137
- left: rest.filter((parent) => !counts(parent))
138
- };
139
- const fallback = from === null ? [] : [from];
140
- return {
141
- oid: to,
142
- parents: [...fallback, ...parents],
143
- counted: fallback,
144
- left: parents,
145
- self: to
146
- };
191
+ const limit = input.limit ?? 1e4;
192
+ const tips = [from, input.defaultTip].filter((tip) => tip !== null && tip !== void 0);
193
+ const judged = tips.length === 0 ? void 0 : input.reach?.(tips);
194
+ const ends = (oid) => oid === from || input.covered?.(oid) === true;
195
+ const asking = judged === void 0 ? void 0 : (open) => judged.has(open, { signal: input.signal }).pipe(Effect.catch(refusedPastBound));
196
+ const walked = yield* walkedDown(input, to, ends, void 0, limit);
197
+ if (walked !== void 0) {
198
+ const leads = leadingTo(walked, from);
199
+ const asked = walked.filter((commit) => !leads.has(commit.oid)).map((commit) => commit.oid);
200
+ const held = asking === void 0 || asked.length === 0 ? /* @__PURE__ */ new Set() : yield* asking(asked);
201
+ const onDefault = yield* defaultHolds(input, from, [...leads]);
202
+ return walked.filter((commit) => !held.has(commit.oid) && !onDefault.has(commit.oid));
203
+ }
204
+ const added = asking === void 0 ? void 0 : yield* walkedDown(input, to, ends, asking, limit);
205
+ if (added === void 0) return yield* Effect.fail(movePastLimit(limit));
206
+ return added;
147
207
  });
148
208
  /**
149
209
  * `CommitChangesInput.covered` for a rule over the refs `covers` names: whether a commit is the
@@ -165,7 +225,7 @@ const commitChangesOf = (input, updates) => Stream.unwrap(Effect.gen(function* (
165
225
  const olds = updates.map((update) => update.from);
166
226
  const search = chainSearch(input, [...olds, input.defaultTip]);
167
227
  const tips = /* @__PURE__ */ new Set();
168
- const pushedPaths = (commit, listed) => Stream.unwrap(Effect.map(input.source === "git" ? pushedJudged(input, commit, listed, olds) : Effect.succeed({
228
+ const pushedPaths = (commit, listed, judges = input.source === "git") => Stream.unwrap(Effect.map(judges ? pushedJudged(input, commit, listed, olds) : Effect.succeed({
169
229
  ...commit,
170
230
  counted: commit.parents,
171
231
  left: []
@@ -191,16 +251,12 @@ const commitChangesOf = (input, updates) => Stream.unwrap(Effect.gen(function* (
191
251
  const moved = Stream.fromIterable(updates).pipe(Stream.flatMap((update) => Stream.unwrap(Effect.gen(function* () {
192
252
  const { to } = update;
193
253
  if (to === null || tips.has(to)) return Stream.empty;
194
- const judged = yield* movedTip(input, {
254
+ const added = yield* addedBy(input, {
195
255
  ...update,
196
256
  to
197
257
  });
198
- if (judged === void 0) return Stream.empty;
199
- return judgedPaths(input, judged, search, allotment).pipe(Stream.map((change) => ({
200
- commit: to,
201
- root: false,
202
- change
203
- })));
258
+ const listed = new Set(added.map((commit) => commit.oid));
259
+ return Stream.fromIterable(added).pipe(Stream.flatMap((commit) => pushedPaths(commit, listed, true)));
204
260
  }))));
205
261
  return Stream.concat(pushed, moved);
206
262
  }));
@@ -10,11 +10,11 @@ import { CommitChange, RuleOperation } from "../../contracts/rules.mjs";
10
10
  import "../../auth/host-function.mjs";
11
11
  import { CallScope } from "../../store/call-count.mjs";
12
12
  import { Ordered } from "../hooks/order.mjs";
13
- import { WalkFailure } from "./commit-changes.mjs";
14
- import * as Effect from "effect/Effect";
13
+ import { WalkFailure } from "../../engine/combined.mjs";
15
14
  import "effect/Schema";
16
- import "effect/Result";
15
+ import * as Effect from "effect/Effect";
17
16
  import * as Stream from "effect/Stream";
17
+ import "effect/Result";
18
18
  /** One push's checks' input: the request, each edit's kind, and the repo's facts at one read. */
19
19
  export interface CheckInput {
20
20
  readonly caller: Caller;
@@ -2,12 +2,13 @@ import { accept, decisionAnswer, reject } from "../../contracts/result.mjs";
2
2
  import { actingOf } from "../../auth/acting.mjs";
3
3
  import { WalkRefused } from "../../engine/combined.mjs";
4
4
  import { inCallScope, scopedContext } from "../../store/call-count.mjs";
5
+ import * as Schema from "effect/Schema";
5
6
  import * as Effect from "effect/Effect";
7
+ import * as Stream from "effect/Stream";
8
+ import * as Context from "effect/Context";
6
9
  import * as Option from "effect/Option";
7
- import * as Schema from "effect/Schema";
8
10
  import * as Exit from "effect/Exit";
9
11
  import * as Result from "effect/Result";
10
- import * as Stream from "effect/Stream";
11
12
  import * as Deferred from "effect/Deferred";
12
13
  // src/core/rules/context.ts
13
14
  /**
@@ -99,33 +100,36 @@ const checking = (input) => {
99
100
  }
100
101
  };
101
102
  };
102
- /**
103
- * Each `commitChanges` Git made, with its form for a rule that says what it covers and refuses,
104
- * kept off the contract. It's keyed by the Stream, so an input a host spreads into a copy keeps it.
105
- */
106
- const coveredChanges = /* @__PURE__ */ new WeakMap();
103
+ const CoveredChanges = Context.Reference("@ref0/git/CoveredChanges", { defaultValue: () => void 0 });
107
104
  /**
108
105
  * `input.commitChanges` for a rule that says what it covers and refuses, such as `Rules.files`: a
109
106
  * parent counts at one of its refs' tips, and a path it refuses searches for one on the chains
110
107
  * (Q732, Q734). Only it fails with the allotment's `WalkRefused`, which the rule answers. A
111
108
  * `commitChanges` Git didn't make, such as a test's, lists its own.
112
109
  */
113
- const commitChangesCovered = (input, by) => coveredChanges.get(input.commitChanges)?.(by) ?? input.commitChanges;
110
+ const commitChangesCovered = (input, by) => Stream.unwrap(Effect.map(Effect.service(CoveredChanges), (entry) => entry !== void 0 && entry.stream === input.commitChanges ? entry.covered(by) : input.commitChanges));
114
111
  /** `stream` in the push's call scope, its allotment's refusal as the `GitError` it carries. */
115
112
  const inScope = (checking, stream) => Stream.updateContext(stream, scopedContext(checking.scope));
116
113
  const refusalOf = (error) => error instanceof WalkRefused ? error.refusal : error;
117
114
  /**
118
115
  * A check's context of `updates`: its `changes` and `commitChanges` read `changed`'s files, each in
119
- * the push's call scope, whichever fiber runs them.
116
+ * the push's call scope, whichever fiber runs them, and `provide` carries its covered form on the
117
+ * check's fiber.
120
118
  */
121
119
  const pushContextOf = (checking, updates, changed, extra) => {
122
120
  const commitChanges = Stream.mapError(inScope(checking, checking.commitChanges(changed)), refusalOf);
123
- coveredChanges.set(commitChanges, (by) => inScope(checking, checking.commitChanges(changed, by)));
121
+ const covered = {
122
+ stream: commitChanges,
123
+ covered: (by) => inScope(checking, checking.commitChanges(changed, by))
124
+ };
124
125
  return {
125
- ...checking.contextOf(updates),
126
- changes: inCallScope(checking.changes(changed), checking.scope),
127
- commitChanges,
128
- ...extra
126
+ input: {
127
+ ...checking.contextOf(updates),
128
+ changes: inCallScope(checking.changes(changed), checking.scope),
129
+ commitChanges,
130
+ ...extra
131
+ },
132
+ provide: (effect) => Effect.provideService(effect, CoveredChanges, covered)
129
133
  };
130
134
  };
131
135
  /** A push rule's, a hook group's or `prepare`'s answer, which carries no value. */
@@ -3,8 +3,8 @@ import { FetchAdjustment } from "../../contracts/rules.mjs";
3
3
  import { hostEffect, logRefusal, rejectedError } from "../../auth/host-function.mjs";
4
4
  import { checkedAnswer } from "./context.mjs";
5
5
  import { fetchRulesOf } from "./service.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
  // src/core/rules/fetch.ts
9
9
  /** What a rule's input holds for `check`, besides its actor and repo. */
10
10
  const inputOf = (check) => {
@@ -1,6 +1,7 @@
1
1
  import { accept, reject } from "../../contracts/result.mjs";
2
2
  import { patternList, refMatcher, shortRef } from "./patterns.mjs";
3
3
  import * as Effect from "effect/Effect";
4
+ import * as Predicate from "effect/Predicate";
4
5
  // src/core/rules/protect.ts
5
6
  const refSources = [
6
7
  "git",
@@ -15,10 +16,28 @@ const sourceWords = {
15
16
  queue: "the merge queue",
16
17
  import: "an import"
17
18
  };
18
- /** Each `Rules.protect` and `Rules.lock` rule's protection, for the server's start and `refs.protection`. */
19
- const protections = /* @__PURE__ */ new WeakMap();
19
+ /**
20
+ * A `Rules.protect` or `Rules.lock` rule carrying its protection in a private slot, in place of a
21
+ * module `WeakMap` (#771, K8). `#protection in rule` checks the exact instance's internal slot
22
+ * without invoking any `Proxy` trap, so spread copies, `Object.create` clones, proxies and
23
+ * shadow-target membranes all miss without throwing.
24
+ */
25
+ var ProtectedRule = class {
26
+ kind = "push";
27
+ name;
28
+ check;
29
+ #protection;
30
+ constructor(name, check, protection) {
31
+ this.name = name;
32
+ this.check = check;
33
+ this.#protection = protection;
34
+ }
35
+ static protectionOf(rule) {
36
+ return Predicate.isObject(rule) && #protection in rule ? rule.#protection : void 0;
37
+ }
38
+ };
20
39
  /** The sources `rule` lets change its refs, when it's a `Rules.protect` or `Rules.lock` that names any. */
21
- const protectedSources = (rule) => protections.get(rule)?.sources;
40
+ const protectedSources = (rule) => ProtectedRule.protectionOf(rule)?.sources;
22
41
  /**
23
42
  * How `rules`' `Rules.protect` and `Rules.lock` guard `ref`, or `undefined` when none names it. A
24
43
  * change passes every rule that matches, so the sources are those each one that names any lets in,
@@ -26,7 +45,7 @@ const protectedSources = (rule) => protections.get(rule)?.sources;
26
45
  */
27
46
  const refProtection = (rules, ref) => {
28
47
  const matching = rules.flatMap((rule) => {
29
- const protection = protections.get(rule);
48
+ const protection = ProtectedRule.protectionOf(rule);
30
49
  return protection?.matches(ref) === true ? [protection] : [];
31
50
  });
32
51
  if (matching.length === 0) return void 0;
@@ -86,22 +105,16 @@ const bypassOf = (kind, input, move) => ({
86
105
  const protectRule = (kind, patterns, options) => {
87
106
  const matches = refMatcher(patterns);
88
107
  const sources = sourcesOf(options.sources);
89
- const rule = {
90
- kind: "push",
91
- name: `Rules.${kind}(${patternList(patterns).join(", ")})`,
92
- check: (input) => {
93
- const move = input.update.kind;
94
- if (!matches(input.update.ref) || move === "create") return Effect.succeed(accept());
95
- const refusal = refusalOf(input, sources);
96
- if (refusal === void 0) return Effect.succeed(accept());
97
- return Effect.map(input.authorize(bypassOf(kind, input, move)), (answer) => answer.kind === "accept" ? accept() : reject(refusal));
98
- }
99
- };
100
- protections.set(rule, {
108
+ return new ProtectedRule(`Rules.${kind}(${patternList(patterns).join(", ")})`, (input) => {
109
+ const move = input.update.kind;
110
+ if (!matches(input.update.ref) || move === "create") return Effect.succeed(accept());
111
+ const refusal = refusalOf(input, sources);
112
+ if (refusal === void 0) return Effect.succeed(accept());
113
+ return Effect.map(input.authorize(bypassOf(kind, input, move)), (answer) => answer.kind === "accept" ? accept() : reject(refusal));
114
+ }, {
101
115
  matches,
102
116
  sources
103
117
  });
104
- return rule;
105
118
  };
106
119
  /**
107
120
  * Creating the ref is allowed; deleting it and force-pushing it are refused, and with `sources`,
@@ -5,8 +5,8 @@ import { InternalRepoId } from "../contracts/ids.mjs";
5
5
  import { GitError } from "../contracts/result.mjs";
6
6
  import { QueueNeeds } from "./parts.mjs";
7
7
  import { SavedCaller } from "./saved-callers.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
  import * as Context from "effect/Context";
11
11
  /**
12
12
  * A saved caller as asked again, with the repo as it is now, its name and visibility, and their
@@ -6,11 +6,11 @@ import { CoreParts } from "./parts.mjs";
6
6
  import { retriedCodes } from "./push.mjs";
7
7
  import { refViewAgain } from "./ref-view.mjs";
8
8
  import { askAgain } from "./saved-callers.mjs";
9
- import * as Clock from "effect/Clock";
10
- import * as Effect from "effect/Effect";
11
9
  import * as Schema from "effect/Schema";
12
- import * as Result from "effect/Result";
10
+ import * as Effect from "effect/Effect";
13
11
  import * as Context from "effect/Context";
12
+ import * as Result from "effect/Result";
13
+ import * as Clock from "effect/Clock";
14
14
  // src/core/saved-caller-views.ts
15
15
  /**
16
16
  * `saved` asked again, as it is now (`askAgain`), then its view of `repo` asked afresh for `kind`
@@ -2,8 +2,8 @@ import "../contracts/actors.mjs";
2
2
  import "../contracts/result.mjs";
3
3
  import "../contracts/authorize.mjs";
4
4
  import "./parts.mjs";
5
- import "effect/Effect";
6
5
  import * as Schema from "effect/Schema";
6
+ import "effect/Effect";
7
7
  import "effect/Types";
8
8
  /**
9
9
  * Who saved work that runs later, a queue entry or a mirror (#679, #1945), as its row keeps it:
@@ -3,8 +3,8 @@ import { tokenInfoOf } from "../auth/identify.mjs";
3
3
  import { readToken, tokenState } from "../auth/token-rows.mjs";
4
4
  import { grantAgain, grantOf } from "../contracts/authorize.mjs";
5
5
  import { CoreParts } from "./parts.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
  // src/core/saved-callers.ts
9
9
  /**
10
10
  * Who saved work that runs later, a queue entry or a mirror (#679, #1945), as its row keeps it:
@@ -3,7 +3,6 @@ import { RepoName } from "../contracts/ids.mjs";
3
3
  import { Operation } from "../contracts/operations.mjs";
4
4
  import { GitError } from "../contracts/result.mjs";
5
5
  import { ServerCalls } from "../contracts/server.mjs";
6
- import { EffectCalls } from "../contracts/services.mjs";
7
6
  import { TokenId } from "../contracts/tokens.mjs";
8
7
  import { Identify } from "../auth/identify.mjs";
9
8
  import { CallCount } from "../store/call-count.mjs";
@@ -35,7 +34,7 @@ export interface ServedRest {
35
34
  * The Effect calls, each deciding for `caller`, the one `identify` answered: its token's scope or
36
35
  * its grant is the ceiling, whatever actor an input names.
37
36
  */
38
- readonly callsFor: (caller: Caller) => EffectCalls<ServerCalls>;
37
+ readonly callsFor: (caller: Caller) => ServerCalls;
39
38
  /**
40
39
  * Whether Git's own tokens are on now: a call face names `tokens` whether or not they are, so
41
40
  * REST's tokens URLs ask this first, before `authorize`.
@@ -12,8 +12,8 @@ import { WholeRepo } from "../store/ref-rows.mjs";
12
12
  import "./access.mjs";
13
13
  import "./objects/objects.mjs";
14
14
  import "./parts.mjs";
15
- import * as Effect from "effect/Effect";
16
15
  import { Read, Row } from "@ref0/infra";
16
+ import * as Effect from "effect/Effect";
17
17
  import "effect/Context";
18
18
  /**
19
19
  * The server's objects, sealed: a call reaches them only through a `RepoView` core built for its
@@ -91,8 +91,11 @@ export interface RepoView {
91
91
  readonly resolved: ResolvedRepo;
92
92
  /** The caller's ref view of the repo's refs, asked of `authorize` the first time it's needed. */
93
93
  readonly refView: Effect.Effect<RefView, GitError>;
94
- /** The refs among `rows` the caller sees, by name. */
95
- readonly refs: (rows: readonly Row[]) => Effect.Effect<ReadonlyMap<RefName, Oid>, GitError>;
94
+ /**
95
+ * The refs among `rows` the caller sees, by name. `pushing`, for receive-pack's advertisement,
96
+ * keeps a mirror's segments for a whole view too, so its next push leases from their tips.
97
+ */
98
+ readonly refs: (rows: readonly Row[], pushing?: boolean) => Effect.Effect<ReadonlyMap<RefName, Oid>, GitError>;
96
99
  /**
97
100
  * Whether `Objects.read` answers only what `at.refs` reach, and the caller's own writes: for a
98
101
  * caller who doesn't see every ref, and for every reader of a fork on a server with `access`
@@ -1,5 +1,5 @@
1
- import { gitsOwnMove } from "../protocol/wire/lines.mjs";
2
- import { answerSpent, resultCall } from "../store/errors.mjs";
1
+ import { anyoneMoves, gitsOwnMove } from "../protocol/wire/lines.mjs";
2
+ import { answerSpent } from "../store/errors.mjs";
3
3
  import { upstreamOf } from "../store/catalogue.mjs";
4
4
  import { collections } from "../store/scopes.mjs";
5
5
  import { scopedReader } from "../storage/calls.mjs";
@@ -10,7 +10,7 @@ import { walkedRoots, withPushed } from "../storage/visible.mjs";
10
10
  import { WholeRepo, storedPeel, storesPeel, wholeRefs } from "../store/ref-rows.mjs";
11
11
  import { acting, openRepo, repoAccess } from "./access.mjs";
12
12
  import { ownWriter, ownWritesOf } from "./own-writes.mjs";
13
- import { AudienceMemo, anyOwned, refViewIn, viewedIn } from "./ref-view.mjs";
13
+ import { anyOwned, freshRefView, refViewIn, viewedIn } from "./ref-view.mjs";
14
14
  import { CoreParts, ObjectsParts, coreContext } from "./parts.mjs";
15
15
  import * as Effect from "effect/Effect";
16
16
  import * as Predicate from "effect/Predicate";
@@ -205,7 +205,7 @@ const viewOf = /* @__PURE__ */ Effect.fnUntraced(function* (caller, resolved, ow
205
205
  const { objects: sealed } = yield* ObjectsParts;
206
206
  const needs = yield* coreContext;
207
207
  const held = Effect.provideContext(refViewIn(caller, repoAccess(resolved)), needs);
208
- const asked = options.fresh === true ? Effect.provideService(held, AudienceMemo, /* @__PURE__ */ new Map()) : held;
208
+ const asked = options.fresh === true ? yield* freshRefView(held) : held;
209
209
  const refView = owner === void 0 ? asked : Effect.map(asked, (seen) => ownersView(seen, core.hiddenRefs(), owner));
210
210
  const whole = SealedObjects.whole(sealed, viewWhole);
211
211
  const followsRefs = objectsFollowRefs(core, resolved);
@@ -214,11 +214,13 @@ const viewOf = /* @__PURE__ */ Effect.fnUntraced(function* (caller, resolved, ow
214
214
  resolved,
215
215
  refView,
216
216
  narrowed,
217
- refs: Effect.fnUntraced(function* (rows) {
217
+ refs: Effect.fnUntraced(function* (rows, pushing = false) {
218
218
  const all = yield* wholeRefs(viewWhole, rows);
219
219
  const seen = yield* refView;
220
- if (seen.whole && !anyOwned(core.hiddenRefs())) return all;
221
- return new Map([...all].filter(([name]) => seen.sees(name)));
220
+ const hidden = core.hiddenRefs();
221
+ if (seen.whole && !anyOwned(hidden)) return all;
222
+ const kept = pushing && seen.whole ? (name) => seen.sees(name) || anyoneMoves(hidden, name) : seen.sees;
223
+ return new Map([...all].filter(([name]) => kept(name)));
222
224
  })
223
225
  };
224
226
  viewRoots.set(view, (at) => Effect.provideContext(Effect.gen(function* () {
@@ -293,11 +295,10 @@ const viewOf = /* @__PURE__ */ Effect.fnUntraced(function* (caller, resolved, ow
293
295
  const parentBy = (pick) => (oids, input) => Effect.flatMap(callScope, (scope) => Effect.provideContext(inCallScope(Effect.scoped(Effect.gen(function* () {
294
296
  const objects = yield* union;
295
297
  if (objects === void 0) return /* @__PURE__ */ new Set();
296
- const reader = yield* scopedReader(objects[pick], at.listed);
297
- return yield* resultCall(() => reader.held({
298
+ return yield* (yield* scopedReader(objects[pick], at.listed)).held({
298
299
  ...input,
299
300
  oids
300
- }));
301
+ });
301
302
  })), scope), context));
302
303
  return yield* viewedIn(caller, resolved.internalId, key, tips.tips, falling({
303
304
  has: own === void 0 ? parentBy("refusing") : orElse(own, parentBy("refusing")),
@@ -15,9 +15,9 @@ import { refViewIn } from "./ref-view.mjs";
15
15
  import { heldReceipt, receiptAnswered, receiptReads, receiptWrites } from "./receipts.mjs";
16
16
  import { fail } from "../contracts/result.mjs";
17
17
  import { CoreParts, QueueParts } from "./parts.mjs";
18
- import * as Clock from "effect/Clock";
19
- import * as Effect from "effect/Effect";
20
18
  import { limits } from "@ref0/infra";
19
+ import * as Effect from "effect/Effect";
20
+ import * as Clock from "effect/Clock";
21
21
  // src/core/work.ts
22
22
  /**
23
23
  * The UTF-8 bytes a `work.list` cursor's text is padded to before it's sealed, the seal's own
@@ -1,25 +1,12 @@
1
+ import { grownBy } from "../contracts/object-values.mjs";
1
2
  import * as Effect from "effect/Effect";
2
3
  import * as Semaphore from "effect/Semaphore";
3
4
  // src/engine/allotted-xdiff.ts
4
5
  /** Linear memory grows by whole 64 KiB pages, so a call's pages cover its memory rounded up. */
5
6
  const pageBytes = 65536;
6
7
  const pagesOf = (bytes) => Math.ceil(bytes / pageBytes) * pageBytes;
7
- /**
8
- * `allotment` grown by `bytes`, as an Effect: on the spot, or once its wait ends. A wait
9
- * interrupted before it ends gives back what it's granted after, so nothing holds it.
10
- */
11
- const granted = (allotment, bytes) => Effect.suspend(() => {
12
- const answer = allotment.grow(bytes);
13
- if (answer instanceof Promise) {
14
- const waited = Effect.onInterrupt(Effect.promise(() => answer), () => Effect.sync(() => {
15
- answer.then((late) => {
16
- if (late === void 0) allotment.shrink(bytes);
17
- });
18
- }));
19
- return Effect.flatMap(waited, (settled) => settled === void 0 ? Effect.void : Effect.fail(settled));
20
- }
21
- return answer === void 0 ? Effect.void : Effect.fail(answer);
22
- });
8
+ /** `allotment` grown by `bytes`, as an Effect: on the spot, or once its wait ends. */
9
+ const granted = (allotment, bytes) => Effect.flatMap(grownBy(allotment, bytes), (refused) => refused === void 0 ? Effect.void : Effect.fail(refused));
23
10
  /** Whether a call was refused for reaching its ceiling, not by its admission or its stack. */
24
11
  const pastCeiling = (answer) => answer.kind === "refused" && answer.limit === "memory";
25
12
  /**
@@ -3,6 +3,9 @@ import "../contracts/ids.mjs";
3
3
  import "../contracts/objects.mjs";
4
4
  import { GitError, Rejected } from "../contracts/result.mjs";
5
5
  import * as Schema from "effect/Schema";
6
+ import "effect/Stream";
7
+ /** What stops a walk: a read's error, or its allotment's refusal. */
8
+ export type WalkFailure = GitError | WalkRefused;
6
9
  declare const WalkRefused_base: Schema.Class<WalkRefused, Schema.TaggedStruct<"WalkRefused", {
7
10
  readonly refusal: Schema.declare<GitError, unknown>;
8
11
  }>, import("effect/Cause").YieldableError>;