@ref0/git 0.20.0 → 0.25.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 (378) 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 +20 -17
  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 +2 -2
  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 +125 -94
  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 +3 -15
  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/host-bucket.mjs +9 -4
  252. package/dist/storage/index-bitmaps.mjs +77 -49
  253. package/dist/storage/index-build.d.mts +2 -3
  254. package/dist/storage/index-build.mjs +248 -48
  255. package/dist/storage/index-fetch.d.mts +3 -1
  256. package/dist/storage/index-fetch.mjs +60 -21
  257. package/dist/storage/index-graph.mjs +1 -1
  258. package/dist/storage/index-layers.mjs +55 -25
  259. package/dist/storage/index-reach.mjs +15 -22
  260. package/dist/storage/index-whole.d.mts +7 -0
  261. package/dist/storage/index-whole.mjs +145 -37
  262. package/dist/storage/largest-files.mjs +1 -7
  263. package/dist/storage/layout.mjs +17 -1
  264. package/dist/storage/lfs-pointers.mjs +1 -6
  265. package/dist/storage/link-join.mjs +55 -16
  266. package/dist/storage/list-source.d.mts +7 -0
  267. package/dist/storage/list-source.mjs +288 -0
  268. package/dist/storage/loose.d.mts +8 -8
  269. package/dist/storage/loose.mjs +157 -91
  270. package/dist/storage/memory-budget.mjs +226 -22
  271. package/dist/storage/merge-cut.mjs +9 -6
  272. package/dist/storage/merge-fence.mjs +1 -1
  273. package/dist/storage/merge-row.mjs +1 -1
  274. package/dist/storage/merge.d.mts +2 -3
  275. package/dist/storage/merge.mjs +2 -2
  276. package/dist/storage/object-rows.d.mts +3 -3
  277. package/dist/storage/object-rows.mjs +179 -38
  278. package/dist/storage/pack-order.mjs +97 -44
  279. package/dist/storage/pack-ranges.mjs +44 -16
  280. package/dist/storage/pack-reads.d.mts +5 -3
  281. package/dist/storage/pack-reads.mjs +236 -72
  282. package/dist/storage/pack-receive.d.mts +1 -2
  283. package/dist/storage/pack-receive.mjs +21 -17
  284. package/dist/storage/packs.d.mts +1 -1
  285. package/dist/storage/packs.mjs +477 -116
  286. package/dist/storage/placed-reads.mjs +33 -16
  287. package/dist/storage/prune-seen.mjs +1 -1
  288. package/dist/storage/prune-walk.mjs +1 -1
  289. package/dist/storage/prune.mjs +4 -31
  290. package/dist/storage/push-allotment.mjs +26 -14
  291. package/dist/storage/push-uploads.mjs +195 -57
  292. package/dist/storage/pushed-commits.mjs +20 -1
  293. package/dist/storage/quarantine.d.mts +2 -3
  294. package/dist/storage/range-cache.mjs +175 -40
  295. package/dist/storage/raw-ids.mjs +39 -10
  296. package/dist/storage/ready.d.mts +2 -3
  297. package/dist/storage/ready.mjs +114 -38
  298. package/dist/storage/receive-bounds.mjs +31 -9
  299. package/dist/storage/receive-cache.d.mts +7 -0
  300. package/dist/storage/receive-cache.mjs +147 -0
  301. package/dist/storage/receive-files.mjs +1 -1
  302. package/dist/storage/receive-links.mjs +1 -1
  303. package/dist/storage/receive-state.d.mts +2 -2
  304. package/dist/storage/receive-state.mjs +6 -8
  305. package/dist/storage/receive-steps.d.mts +20 -0
  306. package/dist/storage/receive-steps.mjs +298 -13
  307. package/dist/storage/repack-backlog.mjs +1 -6
  308. package/dist/storage/repack-contained.mjs +2 -2
  309. package/dist/storage/repack-job.mjs +1 -1
  310. package/dist/storage/repack.d.mts +2 -3
  311. package/dist/storage/repack.mjs +54 -9
  312. package/dist/storage/request-cache.mjs +57 -0
  313. package/dist/storage/roots.mjs +1 -24
  314. package/dist/storage/rows.d.mts +2 -2
  315. package/dist/storage/rows.mjs +1 -1
  316. package/dist/storage/runs.d.mts +2 -2
  317. package/dist/storage/runs.mjs +1 -1
  318. package/dist/storage/send-list.mjs +62 -25
  319. package/dist/storage/stream-whole.mjs +84 -63
  320. package/dist/storage/swap-walk.mjs +1 -1
  321. package/dist/storage/unpack.mjs +878 -450
  322. package/dist/storage/visible.mjs +110 -32
  323. package/dist/storage/walk.mjs +1 -0
  324. package/dist/storage/wants.mjs +22 -58
  325. package/dist/store/call-count.d.mts +2 -2
  326. package/dist/store/call-count.mjs +24 -11
  327. package/dist/store/catalogue.d.mts +1 -1
  328. package/dist/store/catalogue.mjs +19 -7
  329. package/dist/store/crossing.mjs +1 -7
  330. package/dist/store/cursor-seal.d.mts +1 -1
  331. package/dist/store/cursor-seal.mjs +1 -1
  332. package/dist/store/door.mjs +9 -4
  333. package/dist/store/errors.d.mts +2 -2
  334. package/dist/store/errors.mjs +107 -19
  335. package/dist/store/git-store.mjs +7 -2
  336. package/dist/store/job-try.mjs +90 -9
  337. package/dist/store/list-job.mjs +10 -34
  338. package/dist/store/outbox.d.mts +2 -2
  339. package/dist/store/outbox.mjs +2 -2
  340. package/dist/store/queue-jobs.mjs +6 -12
  341. package/dist/store/records.d.mts +2 -2
  342. package/dist/store/records.mjs +2 -2
  343. package/dist/store/ref-rows.d.mts +2 -2
  344. package/dist/store/ref-rows.mjs +2 -2
  345. package/dist/store/repo-record.d.mts +2 -2
  346. package/dist/store/repo-record.mjs +3 -3
  347. package/dist/store/request-snapshot.mjs +5 -0
  348. package/dist/store/reservations.mjs +2 -2
  349. package/dist/store/topic-jobs.mjs +5 -11
  350. package/dist/sync/bound.d.mts +3 -3
  351. package/dist/sync/bound.mjs +10 -7
  352. package/dist/sync/github.mjs +65 -67
  353. package/dist/sync/http.mjs +1 -1
  354. package/dist/sync/import.mjs +201 -66
  355. package/dist/sync/layer.d.mts +1 -1
  356. package/dist/sync/layer.mjs +6 -6
  357. package/dist/sync/lfs-batch.mjs +1 -1
  358. package/dist/sync/lfs-copy.mjs +175 -15
  359. package/dist/sync/mirror.mjs +5 -10
  360. package/dist/sync/said.mjs +1 -1
  361. package/dist/sync/step.mjs +268 -86
  362. package/dist/sync/tries.mjs +25 -6
  363. package/dist/sync.d.mts +2 -2
  364. package/dist/sync.mjs +2 -2
  365. package/dist/topics/advance.mjs +3 -3
  366. package/dist/topics/calls.mjs +1 -1
  367. package/dist/topics/layer.d.mts +15 -14
  368. package/dist/topics/members.mjs +1 -1
  369. package/dist/topics/topic.mjs +1 -1
  370. package/package.json +3 -13
  371. package/dist/auth/helpers.mjs +0 -17
  372. package/dist/auth.d.mts +0 -5
  373. package/dist/auth.mjs +0 -5
  374. package/dist/core/rules/commit-changes.d.mts +0 -12
  375. package/dist/effect.d.mts +0 -9
  376. package/dist/effect.mjs +0 -7
  377. package/dist/server/joined.d.mts +0 -70
  378. package/dist/server/joined.mjs +0 -41
@@ -4,8 +4,8 @@ import { IndexedStorage } from "../core/objects/objects.mjs";
4
4
  import { isRefName } from "../core/names.mjs";
5
5
  import { fullPattern, isClassedPattern, refMatcher, refusedGlob } from "../core/rules/patterns.mjs";
6
6
  import { isWellFormed, utf8 } from "../protocol/bytes/text.mjs";
7
- import * as Effect from "effect/Effect";
8
7
  import { byBytes, limits } from "@ref0/infra";
8
+ import * as Effect from "effect/Effect";
9
9
  import * as Layer from "effect/Layer";
10
10
  // src/access/private-refs.ts
11
11
  const compiled = (pattern) => {
@@ -3,13 +3,13 @@ import { gitError } from "../contracts/result.mjs";
3
3
  import { utf8 } from "../protocol/bytes/text.mjs";
4
4
  import { bytesFromBase64Url, fromBase64Url } from "../store/random.mjs";
5
5
  import { make } from "./auth.mjs";
6
- import * as Clock from "effect/Clock";
6
+ import * as Schema from "effect/Schema";
7
7
  import * as Effect from "effect/Effect";
8
+ import * as Option from "effect/Option";
8
9
  import * as HttpClient from "effect/http/HttpClient";
9
10
  import * as HttpClientResponse from "effect/http/HttpClientResponse";
10
- import * as Option from "effect/Option";
11
+ import * as Clock from "effect/Clock";
11
12
  import * as Ref from "effect/Ref";
12
- import * as Schema from "effect/Schema";
13
13
  // src/auth/access-jwt.ts
14
14
  /** The header Access signs each request it lets through with. */
15
15
  const accessHeader = "cf-access-jwt-assertion";
@@ -1,6 +1,6 @@
1
1
  import { Auth, AuthService, Input, bearer, layer, make } from "./auth.mjs";
2
- import { AccessJwtIdentity, AccessJwtOptions, accessJwt } from "./access-jwt.mjs";
2
+ import { AccessJwtIdentity, AccessJwtOptions, accessHeader, accessJwt } from "./access-jwt.mjs";
3
3
  declare namespace auth_namespace_d_exports {
4
- export { AccessJwtIdentity, AccessJwtOptions, Auth, AuthService, Input, accessJwt, bearer, layer, make };
4
+ export { AccessJwtIdentity, AccessJwtOptions, Auth, AuthService, Input, accessHeader, accessJwt, bearer, layer, make };
5
5
  }
6
- export { type AccessJwtIdentity, type AccessJwtOptions, Auth, AuthService, Input, accessJwt, auth_namespace_d_exports, bearer, layer, make };
6
+ export { type AccessJwtIdentity, type AccessJwtOptions, Auth, AuthService, Input, accessHeader, accessJwt, auth_namespace_d_exports, bearer, layer, make };
@@ -1,12 +1,13 @@
1
1
  import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
2
2
  import { Auth, bearer, layer, make } from "./auth.mjs";
3
- import { accessJwt } from "./access-jwt.mjs";
3
+ import { accessHeader, accessJwt } from "./access-jwt.mjs";
4
4
  // src/auth/auth-namespace.ts
5
5
  var auth_namespace_exports = /* @__PURE__ */ __exportAll({
6
6
  Auth: () => Auth,
7
+ accessHeader: () => accessHeader,
7
8
  accessJwt: () => accessJwt,
8
9
  bearer: () => bearer,
9
10
  layer: () => layer,
10
11
  make: () => make
11
12
  });
12
- export { Auth, accessJwt, auth_namespace_exports, bearer, layer, make };
13
+ export { Auth, accessHeader, accessJwt, auth_namespace_exports, bearer, layer, make };
@@ -1,11 +1,11 @@
1
1
  import { Actor, AuthInput, NamedActor } from "../contracts/actors.mjs";
2
2
  import { GitError } from "../contracts/result.mjs";
3
3
  import * as Effect from "effect/Effect";
4
- import * as Option from "effect/Option";
5
4
  import * as Context from "effect/Context";
6
5
  import * as Layer from "effect/Layer";
7
- import * as Redacted from "effect/Redacted";
6
+ import * as Option from "effect/Option";
8
7
  import * as Scope from "effect/Scope";
8
+ import * as Redacted from "effect/Redacted";
9
9
  /** What `identify` is asked: the request, and the credential it carries, if it carries one. */
10
10
  export type Input = Omit<AuthInput, 'signal'>;
11
11
  export interface AuthService {
@@ -29,7 +29,7 @@ export declare const layer: <E = never, R = never>(auth: AuthService | Effect.Ef
29
29
  /**
30
30
  * One secret for one actor, such as an admin token: sent as a Bearer token, or as Basic's
31
31
  * password, as Git sends one from its credential helper. Compared by hash, so the time taken
32
- * doesn't say where a guess differs.
32
+ * doesn't say where a guess differs; the secret's own hash is taken once, at the first check.
33
33
  */
34
34
  export declare const bearer: (options: {
35
35
  readonly token: Redacted.Redacted<string>;
@@ -1,8 +1,9 @@
1
- import { bearer as bearer$1 } from "./helpers.mjs";
1
+ import { credentialSecret } from "./credentials.mjs";
2
+ import { hashSecret, sameHash } from "./token-text.mjs";
2
3
  import * as Effect from "effect/Effect";
3
- import * as Option from "effect/Option";
4
4
  import * as Context from "effect/Context";
5
5
  import * as Layer from "effect/Layer";
6
+ import * as Option from "effect/Option";
6
7
  import * as Redacted from "effect/Redacted";
7
8
  // src/auth/auth.ts
8
9
  /**
@@ -17,13 +18,13 @@ const layer = (auth) => Effect.isEffect(auth) ? Layer.effect(Auth, auth) : Layer
17
18
  /**
18
19
  * One secret for one actor, such as an admin token: sent as a Bearer token, or as Basic's
19
20
  * password, as Git sends one from its credential helper. Compared by hash, so the time taken
20
- * doesn't say where a guess differs.
21
+ * doesn't say where a guess differs; the secret's own hash is taken once, at the first check.
21
22
  */
22
23
  const bearer = (options) => {
23
- const known = bearer$1({
24
- token: Redacted.value(options.token),
25
- actor: options.actor
26
- });
27
- return make((input) => Effect.map(Effect.promise(() => known(input)), Option.fromNullishOr));
24
+ let known;
25
+ const secret = Effect.suspend(() => known === void 0 ? Effect.tap(hashSecret(Redacted.value(options.token)), (hash) => Effect.sync(() => {
26
+ known = hash;
27
+ })) : Effect.succeed(known));
28
+ return make(({ credentials }) => credentials === void 0 ? Effect.succeedNone : Effect.map(Effect.all([hashSecret(credentialSecret(credentials)), secret]), ([given, held]) => sameHash(given, held) ? Option.some(options.actor) : Option.none()));
28
29
  };
29
30
  export { Auth, bearer, layer, make };
@@ -6,8 +6,8 @@ import { utf8 } from "../protocol/bytes/text.mjs";
6
6
  import { internalIdOf } from "../store/catalogue.mjs";
7
7
  import { isTokenOf } from "./token-text.mjs";
8
8
  import { hostCall, hostEffect, logRefusal, rejectedError, withAbortSignal } from "./host-function.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
  // src/auth/authorize.ts
12
12
  /**
13
13
  * `INVALID_ARGUMENT` when any of `named` has an `id` past `maxActorIdLength` bytes in UTF-8, else
@@ -2,8 +2,8 @@ import { Caller } from "../contracts/actors.mjs";
2
2
  import { InternalRepoId, RepoName } from "../contracts/ids.mjs";
3
3
  import { GitError } from "../contracts/result.mjs";
4
4
  import "./grants.mjs";
5
- import * as Effect from "effect/Effect";
6
5
  import { Read, Records, Row } from "@ref0/infra";
6
+ import * as Effect from "effect/Effect";
7
7
  /** The repo a write commits to: its scope's ID and its name now. */
8
8
  export interface FencedRepo {
9
9
  readonly internalId: InternalRepoId;
@@ -2,8 +2,8 @@ import { GitErrorBody, gitError } from "../contracts/result.mjs";
2
2
  import { spentAt } from "../contracts/calls-spent.mjs";
3
3
  import { isServerClosed, tryClosing } from "../store/closed.mjs";
4
4
  import { randomText } from "../store/random.mjs";
5
- import * as Effect from "effect/Effect";
6
5
  import * as Schema from "effect/Schema";
6
+ import * as Effect from "effect/Effect";
7
7
  import * as Cause from "effect/Cause";
8
8
  import * as Fiber from "effect/Fiber";
9
9
  // src/auth/host-function.ts
@@ -1,11 +1,9 @@
1
1
  import { aboutOf } from "./authorize.mjs";
2
- import { runIn, uncounted } from "../store/crossing.mjs";
3
- import { hostCall } from "./host-function.mjs";
2
+ import { hostEffect } from "./host-function.mjs";
3
+ import * as Effect from "effect/Effect";
4
4
  // src/auth/host-services.ts
5
- /** A host's own `Policy` and `Auth` make no call through Git's doors. */
6
- const hostDecider = /* @__PURE__ */ uncounted("the host's own Policy and Auth");
7
5
  /** The host's `Policy`, each answer a host function the host's log names as `'authorize'`'s. */
8
- const hostPolicy = (policy) => ({ authorize: (input) => hostCall("authorize", aboutOf(input.caller, input.operation), (signal) => runIn(policy.authorize(input), hostDecider, signal)) });
6
+ const hostPolicy = (policy) => ({ authorize: (input) => hostEffect("authorize", aboutOf(input.caller, input.operation), Effect.suspend(() => policy.authorize(input))) });
9
7
  /** The host's `Auth`, each answer a host function the host's log names as `'auth'`'s. */
10
- const hostAuth = (auth) => auth === void 0 ? void 0 : { identify: (input) => hostCall("auth", {}, (signal) => runIn(auth.identify(input), hostDecider, signal)) };
8
+ const hostAuth = (auth) => auth === void 0 ? void 0 : { identify: (input) => hostEffect("auth", {}, Effect.suspend(() => auth.identify(input))) };
11
9
  export { hostAuth, hostPolicy };
@@ -4,7 +4,7 @@ import { GitError } from "../contracts/result.mjs";
4
4
  import "../contracts/tokens.mjs";
5
5
  import "./auth.mjs";
6
6
  import "./grants.mjs";
7
- import * as Effect from "effect/Effect";
8
7
  import { Records } from "@ref0/infra";
8
+ import * as Effect from "effect/Effect";
9
9
  /** Who sent a request: its `Caller`, or `UNAUTHENTICATED` for a credential no one knows. */
10
10
  export type Identify = (request: Request) => Effect.Effect<Caller, GitError>;
@@ -1,4 +1,5 @@
1
1
  import { gitError } from "../contracts/result.mjs";
2
+ import { RepoRecordAhead } from "../store/catalogue.mjs";
2
3
  import { longActorId } from "./authorize.mjs";
3
4
  import { credentialSecret, requestCredentials } from "./credentials.mjs";
4
5
  import { grantCaller } from "./grants.mjs";
@@ -84,6 +85,11 @@ const identifier = (options) => {
84
85
  if (!options.tokens()) return yield* Effect.fail(unknownCredential());
85
86
  const held = yield* verifyToken(options.store, secret, yield* options.now);
86
87
  if (held === void 0) return yield* Effect.fail(unknownCredential());
88
+ if (held.place.kind === "repo" && held.repo !== void 0 && held.selfSnapshot !== void 0) (yield* RepoRecordAhead)?.give({
89
+ internalId: held.place.internalId,
90
+ record: held.repo,
91
+ snapshot: held.selfSnapshot
92
+ });
87
93
  return tokenCaller(held);
88
94
  }
89
95
  const granted = yield* fromGrants(request, credentials);
@@ -2,9 +2,9 @@ import { decodeRow, storeCall, storeCommit } from "../store/errors.mjs";
2
2
  import { gitJob } from "../store/job-try.mjs";
3
3
  import { collections, newChangeId } from "../store/scopes.mjs";
4
4
  import { tokenKey } from "./token-rows.mjs";
5
- import * as Effect from "effect/Effect";
6
- import * as Schema from "effect/Schema";
7
5
  import { CurrentJob, Job } from "@ref0/infra";
6
+ import * as Schema from "effect/Schema";
7
+ import * as Effect from "effect/Effect";
8
8
  /** How long a row is kept past its expiry, so a list still shows what just ended. */
9
9
  const keptAfterExpiry = 6048e5;
10
10
  const cleanupBatch = 100;
@@ -3,8 +3,8 @@ import { decodeRow, storeCall } from "../store/errors.mjs";
3
3
  import { StoredRepo } from "../store/records.mjs";
4
4
  import { collections, selfKey } from "../store/scopes.mjs";
5
5
  import { hashSecret, placeScope, readTokenText, sameHash, tokenIdPlace } from "./token-text.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/auth/token-rows.ts
9
9
  const Party = /* @__PURE__ */ Schema.Struct({ id: Schema.String });
10
10
  /**
@@ -74,6 +74,11 @@ const readToken = /* @__PURE__ */ Effect.fnUntraced(function* (store, id, reads
74
74
  row,
75
75
  record: tokenRecord(id, row, { repo: repo.name }),
76
76
  repo,
77
+ selfSnapshot: {
78
+ version,
79
+ results: [snapshot.results[1] ?? []],
80
+ counts: []
81
+ },
77
82
  results
78
83
  };
79
84
  });
@@ -3,8 +3,8 @@ import { gitError } from "../contracts/result.mjs";
3
3
  import { utf8 } from "../protocol/bytes/text.mjs";
4
4
  import { fromBase64Url, randomText, toBase64Url } from "../store/random.mjs";
5
5
  import { repoScope } from "../store/scopes.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/auth/token-text.ts
9
9
  const prefixText = "gt_";
10
10
  const placeText = (place) => place.kind === "repo" ? place.internalId : `p_${toBase64Url(utf8(place.prefix))}`;
@@ -1,8 +1,8 @@
1
1
  import { EventLog } from "../contracts/events.mjs";
2
2
  import { GitError } from "../contracts/result.mjs";
3
3
  import { HeldTokenCalls } from "./tokens.mjs";
4
- import * as Effect from "effect/Effect";
5
4
  import { JobDefinition, Moment, Records } from "@ref0/infra";
5
+ import * as Effect from "effect/Effect";
6
6
  import * as Context from "effect/Context";
7
7
  /** What Git's own tokens mint with once they're on, and what sign-in's routes answer through. */
8
8
  export interface HeldTokens {
@@ -4,8 +4,8 @@ import { InternalRepoId } from "../contracts/ids.mjs";
4
4
  import "../contracts/result.mjs";
5
5
  import { Tokens } from "../contracts/tokens.mjs";
6
6
  import "../store/outbox.mjs";
7
- import "effect/Effect";
8
7
  import { JobDefinition, Moment, Read, Records, Row } from "@ref0/infra";
8
+ import "effect/Effect";
9
9
  /** Git's token calls, where a create or a list may name the repo `authorize` checked, as `held`. */
10
10
  export type HeldTokenCalls = Omit<Tokens['Service'], 'create' | 'list' | 'revoke'> & {
11
11
  readonly create: (...args: [...Parameters<Tokens['Service']['create']>, held?: InternalRepoId]) => ReturnType<Tokens['Service']['create']>;
@@ -9,8 +9,8 @@ import { longActorId } from "./authorize.mjs";
9
9
  import { keptAfterExpiry } from "./token-cleanup.mjs";
10
10
  import { TokenRow, readToken, tokenKey, tokenRecord, tokenState } from "./token-rows.mjs";
11
11
  import { hashSecret, isPrefixTarget, newSecret, newTokenId, placeScope, tokenParties, tokenText } from "./token-text.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
  import * as Random from "effect/Random";
15
15
  /** The longest a token may live. */
16
16
  const maxTokenLife = 31536e6;
@@ -1,24 +1,32 @@
1
1
  import { GitClientCalls, GitClientOptions, PagedInput } from "../contracts/client.mjs";
2
- import * as Effect from "effect/Effect";
3
2
  import { Listing } from "@ref0/infra";
4
- import * as Context from "effect/Context";
3
+ import * as Effect from "effect/Effect";
5
4
  import * as Stream from "effect/Stream";
5
+ import * as Context from "effect/Context";
6
+ import * as Layer from "effect/Layer";
7
+ import * as Scope$1 from "effect/Scope";
6
8
  declare namespace client_d_exports {
7
- export { GitClient, GitClientCalls, make, paginate };
9
+ export { GitClient, GitClientCalls, layer, make, paginate };
8
10
  }
9
11
  declare const GitClient_base: Context.ServiceClass<GitClient, "@ref0/git/GitClient", GitClientCalls>;
10
12
  /**
11
- * A client of one remote as a service, for a program that's handed one: with `GitClient` from
12
- * `@ref0/git`, `Layer.succeed(GitClient.GitClient, GitClient.make(options))` provides it.
13
+ * A client of one remote as a service, for a program that's handed one: `GitClient.layer(options)`
14
+ * provides it and releases its local storage when the Layer's `Scope` closes.
13
15
  */
14
16
  export declare class GitClient extends /* @__PURE__ */ GitClient_base {}
15
17
  /**
16
18
  * A client of `options.url`, as Effects: `remoteRefs`, `fetch` and `push` on the remote over Git's
17
19
  * smart HTTP, and the server's calls on its own storage, which a fetch fills and a push reads. Each
18
20
  * is an edge a host calls, as the server's Effect face is: a spent bound, a `CallBudget`'s or the
19
- * platform's cap, fails as its refusal, never a defect. Interrupting a call stops it.
21
+ * platform's cap, fails as its refusal, never a defect. Interrupting a call stops it. The client's
22
+ * local storage belongs to the caller's `Scope` and releases when that scope closes.
23
+ */
24
+ export declare const make: (options: GitClientOptions) => Effect.Effect<GitClientCalls, never, Scope$1.Scope>;
25
+ /**
26
+ * A Layer providing `GitClient` over `options`: acquires the client's local storage on first call
27
+ * and releases it when the Layer's `Scope` closes, interrupting any in-flight storage build.
20
28
  */
21
- export declare const make: (options: GitClientOptions) => GitClientCalls;
29
+ export declare const layer: (options: GitClientOptions) => Layer.Layer<GitClient>;
22
30
  /**
23
31
  * Each item `list` answers, a page at a time, from the input's `page` on: the next page asked for
24
32
  * only once the last one's items are taken. A refused page fails the stream with its own error,
@@ -1,39 +1,48 @@
1
1
  import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
2
- import { guardedCalls, noDoor } from "../core/promise.mjs";
2
+ import { aroundCalls } from "../core/call-groups.mjs";
3
+ import { answerSpent } from "../store/errors.mjs";
3
4
  import { gitHttp } from "./git-http.mjs";
4
5
  import { localSide } from "./local.mjs";
5
6
  import { fetchInto, pushFrom, remoteRefs } from "./remote.mjs";
6
7
  import * as Effect from "effect/Effect";
7
- import * as Option from "effect/Option";
8
- import * as Context from "effect/Context";
9
8
  import * as Stream from "effect/Stream";
9
+ import * as Context from "effect/Context";
10
+ import * as Layer from "effect/Layer";
11
+ import * as Option from "effect/Option";
10
12
  // src/client/client.ts
11
13
  var client_exports = /* @__PURE__ */ __exportAll({
12
14
  GitClient: () => GitClient,
15
+ layer: () => layer,
13
16
  make: () => make,
14
17
  paginate: () => paginate
15
18
  });
16
19
  /**
17
- * A client of one remote as a service, for a program that's handed one: with `GitClient` from
18
- * `@ref0/git`, `Layer.succeed(GitClient.GitClient, GitClient.make(options))` provides it.
20
+ * A client of one remote as a service, for a program that's handed one: `GitClient.layer(options)`
21
+ * provides it and releases its local storage when the Layer's `Scope` closes.
19
22
  */
20
23
  var GitClient = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/GitClient")) {};
21
24
  /**
22
25
  * A client of `options.url`, as Effects: `remoteRefs`, `fetch` and `push` on the remote over Git's
23
26
  * smart HTTP, and the server's calls on its own storage, which a fetch fills and a push reads. Each
24
27
  * is an edge a host calls, as the server's Effect face is: a spent bound, a `CallBudget`'s or the
25
- * platform's cap, fails as its refusal, never a defect. Interrupting a call stops it.
28
+ * platform's cap, fails as its refusal, never a defect. Interrupting a call stops it. The client's
29
+ * local storage belongs to the caller's `Scope` and releases when that scope closes.
26
30
  */
27
- const make = (options) => {
28
- const local = localSide(options);
31
+ const make = /* @__PURE__ */ Effect.fnUntraced(function* (options) {
32
+ const local = yield* localSide(options);
29
33
  const http = gitHttp(options);
30
- return guardedCalls({
34
+ return aroundCalls({
31
35
  remoteRefs: (input) => remoteRefs(http, input),
32
36
  fetch: (input) => fetchInto(http, local, input),
33
37
  push: (input) => pushFrom(http, local, input),
34
38
  ...local.calls
35
- }, noDoor);
36
- };
39
+ }, answerSpent);
40
+ });
41
+ /**
42
+ * A Layer providing `GitClient` over `options`: acquires the client's local storage on first call
43
+ * and releases it when the Layer's `Scope` closes, interrupting any in-flight storage build.
44
+ */
45
+ const layer = (options) => Layer.effect(GitClient, make(options));
37
46
  /**
38
47
  * Each item `list` answers, a page at a time, from the input's `page` on: the next page asked for
39
48
  * only once the last one's items are taken. A refused page fails the stream with its own error,
@@ -51,4 +60,4 @@ const paginate = (list, ...args) => {
51
60
  }), (listed) => [listed.items, Option.fromUndefinedOr(listed.next)]);
52
61
  });
53
62
  };
54
- export { GitClient, client_exports, make, paginate };
63
+ export { GitClient, client_exports, layer, make, paginate };
@@ -6,8 +6,8 @@ import { retryAfterOf } from "../protocol/wire/push-uploads.mjs";
6
6
  import { jsonIssue } from "../protocol/wire/json.mjs";
7
7
  import { emptyReads, emptyReadsMost } from "./answer.mjs";
8
8
  import { bodyText, dropped, remoteFetch, remoteFetchOver } from "./transport.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
  // src/client/git-http.ts
12
12
  /**
13
13
  * Git's smart HTTP as a client sends it, as `gitprotocol-http` says: `info/refs` for a service's
@@ -1,3 +1,4 @@
1
+ import { spentOf } from "../contracts/calls-spent.mjs";
1
2
  import { gitError } from "../contracts/result.mjs";
2
3
  import { blobCalls } from "../core/objects/blobs.mjs";
3
4
  import { commitCalls } from "../core/objects/commits.mjs";
@@ -6,7 +7,7 @@ import { mergeCalls } from "../core/objects/merges.mjs";
6
7
  import { tagCalls } from "../core/objects/tags.mjs";
7
8
  import { treeCalls } from "../core/objects/trees.mjs";
8
9
  import { callNames } from "../core/call-names.mjs";
9
- import { callOf, lazyGroups, providedCalls } from "../core/promise.mjs";
10
+ import { callOf, lazyGroups, providedCalls } from "../core/call-groups.mjs";
10
11
  import { heldGrants } from "../auth/grants.mjs";
11
12
  import { CoreParts, ObjectsParts } from "../core/parts.mjs";
12
13
  import { Objects } from "../core/objects/objects.mjs";
@@ -25,14 +26,17 @@ import { doorBucket, doorRecords, openDoor } from "../store/door.mjs";
25
26
  import { newInternalId } from "../store/scopes.mjs";
26
27
  import { defaultFetchLimits } from "../storage/fetch.mjs";
27
28
  import { loose } from "../storage/loose.mjs";
28
- import * as Effect from "effect/Effect";
29
- import * as Option from "effect/Option";
30
- import * as Cause from "effect/Cause";
31
29
  import { Bucket, Records } from "@ref0/infra";
30
+ import * as Effect from "effect/Effect";
32
31
  import * as Context from "effect/Context";
33
32
  import * as Layer from "effect/Layer";
33
+ import * as Option from "effect/Option";
34
+ import * as Cause from "effect/Cause";
35
+ import * as Exit from "effect/Exit";
36
+ import * as Scope$1 from "effect/Scope";
34
37
  import * as Memory from "@ref0/infra/memory";
35
- import * as ManagedRuntime from "effect/ManagedRuntime";
38
+ import * as Deferred from "effect/Deferred";
39
+ import * as Fiber from "effect/Fiber";
36
40
  // src/client/local.ts
37
41
  /** The one repo a client's storage holds, by the name its catalogue lists it under. */
38
42
  const localRepo = "local";
@@ -59,8 +63,6 @@ const localAuthorize = {
59
63
  grantOf: () => void 0,
60
64
  grantAgain: () => Effect.succeed(void 0)
61
65
  };
62
- /** A client's built local side, in its runtime. */
63
- const Local = /* @__PURE__ */ Context.Service("@ref0/git/client/Local");
64
66
  /**
65
67
  * The local repo: its record written, and listed in the catalogue, unless the store holds it
66
68
  * already, as an adapter kept from an earlier client's does. A create another client on the same
@@ -85,16 +87,18 @@ const failedStart = (cause) => gitError("UNAVAILABLE", "The Git client's storage
85
87
  cause: Cause.squash(cause),
86
88
  hint: "Fix the client's adapter, then make the client again"
87
89
  });
90
+ /** What a client's calls answer after its `Scope` closed its local storage. */
91
+ const closedClientError = () => gitError("FAILED_PRECONDITION", "This Git client is closed", { hint: "Make a new client in an open Scope to run further calls" });
88
92
  /**
89
- * The client's core over the adapter's services, as its runtime builds it: `objects` opened on
90
- * them, `loose()` when left out, and the local repo made, so it exists before any call runs. It
91
- * runs no `Merges`, so its merges and patches refuse as `merges-off`.
93
+ * The client's core over the built adapter's services: `objects` opened on them, `loose()` when
94
+ * left out, and the local repo made, so it exists before any call runs. It runs no `Merges`, so its
95
+ * merges and patches refuse as `merges-off`.
92
96
  */
93
- const localLayer = (options) => Layer.effect(Local, Effect.gen(function* () {
94
- const records = yield* Records.Records;
95
- const bucket = yield* Effect.serviceOption(Bucket.Bucket);
97
+ const makeLocal = /* @__PURE__ */ Effect.fnUntraced(function* (options, builtAdapter) {
98
+ const records = Context.get(builtAdapter, Records.Records);
99
+ const bucket = yield* Effect.provideContext(Effect.serviceOption(Bucket.Bucket), builtAdapter);
96
100
  const effectClock = yield* Effect.clockWith(Effect.succeed);
97
- const context = yield* Effect.context();
101
+ const context = Context.merge(yield* Effect.context(), builtAdapter);
98
102
  const store = doorRecords(records, context, openDoor);
99
103
  const now = Effect.sync(() => effectClock.currentTimeMillisUnsafe());
100
104
  const objects = (options.objects ?? loose()).open({
@@ -145,17 +149,49 @@ const localLayer = (options) => Layer.effect(Local, Effect.gen(function* () {
145
149
  merges: providedCalls(mergeCalls(localCaller), needs)
146
150
  }
147
151
  };
148
- }));
152
+ });
149
153
  /**
150
- * A client's local side over `options.adapter`, `Memory.layer()` when left out: the server's core,
151
- * with no queue, deciding everything for its own caller. Its runtime builds the adapter and makes
152
- * the local repo once, on the first call, which every call made before it ends joins; a failed
153
- * build stays failed, and each call answers its `UNAVAILABLE`, or the make's own error.
154
+ * A client's local side over `options.adapter`, `Memory.layerRecords()` when left out: the server's
155
+ * core, with no queue, deciding everything for its own caller. It builds on the caller's runtime
156
+ * once, on the first call, into a scope tied to the caller's `Scope`, which every concurrent first
157
+ * call shares; a failed build closes its storage scope immediately before settling callers with its
158
+ * `UNAVAILABLE` (or the make's own error) and stays failed, and closing the caller's `Scope`
159
+ * interrupts any in-flight build and closes the storage scope.
154
160
  */
155
- const localSide = (options) => {
156
- const adapter = (options.adapter ?? Memory.layer()).pipe(Layer.catchCause((cause) => Layer.effect(Records.Records, Effect.fail(failedStart(cause)))));
157
- const runtime = ManagedRuntime.make(Layer.provide(localLayer(options), adapter));
158
- const built = Effect.map(runtime.contextEffect, Context.get(Local));
161
+ const localSide = /* @__PURE__ */ Effect.fnUntraced(function* (options) {
162
+ const parentScope = yield* Effect.scope;
163
+ const adapter = (options.adapter ?? Memory.layerRecords()).pipe(Layer.catchCause((cause) => {
164
+ const spent = spentOf(cause);
165
+ return Layer.effect(Records.Records, spent !== void 0 ? Effect.die(spent) : Effect.fail(failedStart(cause)));
166
+ }));
167
+ const storageScope = Scope$1.makeUnsafe();
168
+ let closed = false;
169
+ let building;
170
+ let buildFiber;
171
+ yield* Scope$1.addFinalizerExit(parentScope, (exit) => Effect.suspend(() => {
172
+ closed = true;
173
+ const fiber = buildFiber;
174
+ const gate = building;
175
+ const stop = fiber === void 0 ? Effect.void : Fiber.interrupt(fiber);
176
+ const settleGate = gate === void 0 ? Effect.void : Effect.asVoid(Deferred.fail(gate, closedClientError()));
177
+ return Effect.andThen(stop, Effect.ensuring(Scope$1.close(storageScope, exit), settleGate));
178
+ }));
179
+ const settleAfterClose = (gate, closeWith, settle) => Effect.flatMap(Effect.exit(Scope$1.close(storageScope, closeWith)), (closeExit) => {
180
+ const spent = Exit.isFailure(closeExit) ? spentOf(closeExit.cause) : void 0;
181
+ return spent !== void 0 ? Deferred.die(gate, spent) : settle();
182
+ });
183
+ const built = Effect.suspend(() => {
184
+ if (closed) return Effect.fail(closedClientError());
185
+ if (building !== void 0) return Deferred.await(building);
186
+ const gate = Deferred.makeUnsafe();
187
+ building = gate;
188
+ const make = Effect.flatMap(Layer.buildWithScope(adapter, storageScope), (builtAdapter) => makeLocal(options, builtAdapter));
189
+ const run = Effect.asVoid(Effect.uninterruptibleMask((restore) => Effect.flatMap(Effect.exit(restore(make)), (exit) => Exit.isFailure(exit) ? settleAfterClose(gate, exit, () => closed ? Deferred.fail(gate, closedClientError()) : Deferred.done(gate, exit)) : closed ? settleAfterClose(gate, Exit.void, () => Deferred.fail(gate, closedClientError())) : Deferred.done(gate, exit))));
190
+ return Effect.flatMap(Effect.forkDetach(run), (fiber) => {
191
+ buildFiber = fiber;
192
+ return Deferred.await(gate);
193
+ });
194
+ });
159
195
  const calls = lazyGroups(localNames, (group, name, [input]) => Effect.flatMap(built, ({ groups }) => callOf(groups, group, name)(localRepo, {
160
196
  ...input,
161
197
  actor: localCaller.actor
@@ -165,5 +201,5 @@ const localSide = (options) => {
165
201
  built,
166
202
  calls
167
203
  };
168
- };
204
+ });
169
205
  export { localRepo, localSide };
@@ -32,7 +32,7 @@ const encodedBy = (write) => Effect.mapError(write, (error) => gitError("INVALID
32
32
  * below a shallow fetch's edge, ends its line, as does a commit in common: Git's client offers no
33
33
  * ancestor of a commit the remote holds, and reads none.
34
34
  */
35
- const haveWalk = (objects, listed, tips) => {
35
+ const haveWalk = (objects, listed, tips, shallows) => {
36
36
  const queue = [];
37
37
  const seen = /* @__PURE__ */ new Set();
38
38
  const common = /* @__PURE__ */ new Set();
@@ -65,7 +65,7 @@ const haveWalk = (objects, listed, tips) => {
65
65
  continue;
66
66
  }
67
67
  const commit = yield* decodedBy(decodeCommit(bytes));
68
- parentsOf.set(at, commit.parents);
68
+ parentsOf.set(at, shallows.has(at) ? [] : commit.parents);
69
69
  enqueue({
70
70
  oid: at,
71
71
  at: commit.committer.at
@@ -105,7 +105,7 @@ const refused = (message) => gitError("FAILED_PRECONDITION", `The remote refused
105
105
  /** The rounds, then the pack: interrupted, the answer being read is cancelled. */
106
106
  const negotiate = /* @__PURE__ */ Effect.fnUntraced(function* (negotiation) {
107
107
  const { http, version, request } = negotiation;
108
- const walk = haveWalk(negotiation.objects, negotiation.listed, negotiation.tips);
108
+ const walk = haveWalk(negotiation.objects, negotiation.listed, negotiation.tips, new Set(request.shallows));
109
109
  const deepened = request.depth !== void 0;
110
110
  const common = [];
111
111
  /** One round's answer, read to the start of its pack or, when it has none, whole. */