@ref0/git 0.12.0 → 0.14.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 (247) hide show
  1. package/dist/access/private-refs.mjs +3 -3
  2. package/dist/auth/auth.d.mts +2 -2
  3. package/dist/auth/auth.mjs +3 -6
  4. package/dist/auth/authorize.mjs +1 -17
  5. package/dist/auth/helpers.mjs +3 -11
  6. package/dist/auth/host-services.mjs +11 -0
  7. package/dist/auth/policy.d.mts +27 -7
  8. package/dist/auth/policy.mjs +8 -4
  9. package/dist/auth/tokens-layer.d.mts +1 -2
  10. package/dist/auth/tokens-layer.mjs +2 -3
  11. package/dist/auth/tokens-public.d.mts +3 -3
  12. package/dist/auth/tokens.d.mts +1 -8
  13. package/dist/auth/tokens.mjs +1 -8
  14. package/dist/auth.d.mts +1 -4
  15. package/dist/auth.mjs +1 -3
  16. package/dist/client/git-http.mjs +18 -4
  17. package/dist/client/push-upload.mjs +33 -7
  18. package/dist/client/remote.mjs +94 -28
  19. package/dist/client/slice-push.d.mts +1 -1
  20. package/dist/contracts/access.d.mts +8 -8
  21. package/dist/contracts/actors.d.mts +2 -34
  22. package/dist/contracts/blobs.d.mts +2 -2
  23. package/dist/contracts/client.d.mts +8 -3
  24. package/dist/contracts/commits.d.mts +10 -2
  25. package/dist/contracts/commits.mjs +9 -1
  26. package/dist/contracts/files.d.mts +2 -2
  27. package/dist/contracts/forks.d.mts +11 -1
  28. package/dist/contracts/git.d.mts +18 -7
  29. package/dist/contracts/git.mjs +3 -2
  30. package/dist/contracts/lfs.d.mts +0 -7
  31. package/dist/contracts/objects.d.mts +80 -10
  32. package/dist/contracts/operations.d.mts +3 -0
  33. package/dist/contracts/operations.mjs +12 -2
  34. package/dist/contracts/push-uploads.d.mts +44 -5
  35. package/dist/contracts/push-uploads.mjs +7 -3
  36. package/dist/contracts/refs.d.mts +28 -6
  37. package/dist/contracts/remote.mjs +1 -3
  38. package/dist/contracts/repo-records.d.mts +1 -0
  39. package/dist/contracts/repos.d.mts +90 -2
  40. package/dist/contracts/repos.mjs +29 -2
  41. package/dist/contracts/result.d.mts +23 -18
  42. package/dist/contracts/result.mjs +17 -4
  43. package/dist/contracts/rules.d.mts +22 -22
  44. package/dist/contracts/server.d.mts +28 -77
  45. package/dist/contracts/signin.d.mts +1 -1
  46. package/dist/contracts/sync.d.mts +79 -19
  47. package/dist/contracts/sync.mjs +34 -10
  48. package/dist/contracts/tokens.d.mts +1 -6
  49. package/dist/contracts/tokens.mjs +1 -2
  50. package/dist/contracts/topics.d.mts +0 -5
  51. package/dist/contracts/work.d.mts +66 -2
  52. package/dist/contracts/work.mjs +8 -1
  53. package/dist/core/access.mjs +27 -5
  54. package/dist/core/ancestry.d.mts +9 -0
  55. package/dist/core/ancestry.mjs +6 -6
  56. package/dist/core/asked.mjs +42 -4
  57. package/dist/core/call-names.mjs +1 -0
  58. package/dist/core/call-services.mjs +2 -1
  59. package/dist/core/events/deliver.mjs +10 -2
  60. package/dist/core/forks.mjs +3 -3
  61. package/dist/core/imports.mjs +147 -9
  62. package/dist/core/index-job.mjs +9 -6
  63. package/dist/core/job-view.mjs +8 -9
  64. package/dist/core/mirror-rows.mjs +19 -4
  65. package/dist/core/objects/commits.mjs +16 -6
  66. package/dist/core/parts.d.mts +6 -1
  67. package/dist/core/parts.mjs +1 -4
  68. package/dist/core/purge.mjs +76 -6
  69. package/dist/core/push-decide.mjs +1 -1
  70. package/dist/core/push-files.d.mts +12 -0
  71. package/dist/core/push-files.mjs +225 -0
  72. package/dist/core/push-repo.d.mts +8 -0
  73. package/dist/core/push-repo.mjs +56 -0
  74. package/dist/core/push.d.mts +17 -0
  75. package/dist/core/push.mjs +98 -26
  76. package/dist/core/receipts.mjs +26 -10
  77. package/dist/core/ref-view.mjs +59 -5
  78. package/dist/core/refs.mjs +13 -8
  79. package/dist/core/repack.mjs +11 -8
  80. package/dist/core/repo-info.mjs +16 -9
  81. package/dist/core/repos.mjs +30 -14
  82. package/dist/core/seam.mjs +2 -2
  83. package/dist/core/view.d.mts +6 -0
  84. package/dist/core/view.mjs +45 -12
  85. package/dist/core/work.mjs +47 -22
  86. package/dist/effect.d.mts +3 -1
  87. package/dist/effect.mjs +3 -1
  88. package/dist/engine/reads.mjs +13 -6
  89. package/dist/engine/walk.mjs +4 -4
  90. package/dist/event-streams/event-streams.d.mts +1 -1
  91. package/dist/event-streams/event-streams.mjs +1 -1
  92. package/dist/event-streams/stream.d.mts +1 -1
  93. package/dist/event-streams/stream.mjs +1 -1
  94. package/dist/extend.d.mts +3 -3
  95. package/dist/extend.mjs +2 -2
  96. package/dist/http/answers.mjs +4 -2
  97. package/dist/http/core-parts.mjs +64 -15
  98. package/dist/http/handler.mjs +2 -2
  99. package/dist/http/node.mjs +5 -4
  100. package/dist/http/parts.d.mts +1 -0
  101. package/dist/http/push-upload-job.mjs +503 -0
  102. package/dist/http/push-uploads.d.mts +1 -0
  103. package/dist/http/push-uploads.mjs +114 -56
  104. package/dist/http/upload-pack.mjs +7 -6
  105. package/dist/index.d.mts +23 -24
  106. package/dist/index.mjs +4 -7
  107. package/dist/lfs/base.d.mts +7 -3
  108. package/dist/lfs/base.mjs +2 -1
  109. package/dist/lfs/copy.d.mts +46 -0
  110. package/dist/lfs/copy.mjs +26 -0
  111. package/dist/lfs/layer.mjs +4 -2
  112. package/dist/lfs/objects.d.mts +6 -0
  113. package/dist/lfs/objects.mjs +68 -41
  114. package/dist/lfs/rows.d.mts +13 -0
  115. package/dist/lfs/service.d.mts +1 -7
  116. package/dist/lfs/service.mjs +1 -9
  117. package/dist/lfs/upload-most.mjs +5 -5
  118. package/dist/node.d.mts +2 -2
  119. package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
  120. package/dist/protocol/bytes/sha256.d.mts +32 -0
  121. package/dist/protocol/bytes/sha256.mjs +105 -49
  122. package/dist/protocol/wire/advertisement.mjs +9 -4
  123. package/dist/protocol/wire/lines.d.mts +4 -2
  124. package/dist/protocol/wire/lines.mjs +11 -5
  125. package/dist/protocol/wire/push-uploads.mjs +13 -1
  126. package/dist/protocol/wire/v2.mjs +2 -2
  127. package/dist/protocol.d.mts +3 -1
  128. package/dist/protocol.mjs +3 -1
  129. package/dist/queue/advance.mjs +1 -1
  130. package/dist/queue/host.d.mts +1 -7
  131. package/dist/queue/host.mjs +1 -7
  132. package/dist/queue/layer.mjs +1 -1
  133. package/dist/queue/trim.mjs +1 -1
  134. package/dist/rest/blobs.d.mts +31 -23
  135. package/dist/rest/blobs.mjs +1 -1
  136. package/dist/rest/caller.d.mts +49 -9
  137. package/dist/rest/caller.mjs +1 -1
  138. package/dist/rest/client.d.mts +10 -3
  139. package/dist/rest/client.mjs +4 -0
  140. package/dist/rest/commits.d.mts +273 -240
  141. package/dist/rest/errors.d.mts +24 -4
  142. package/dist/rest/events.d.mts +9 -6
  143. package/dist/rest/events.mjs +1 -2
  144. package/dist/rest/files.d.mts +127 -115
  145. package/dist/rest/forks.d.mts +121 -97
  146. package/dist/rest/handler.mjs +4 -57
  147. package/dist/rest/handlers.d.mts +1 -1
  148. package/dist/rest/handlers.mjs +18 -4
  149. package/dist/rest/layer.mjs +2 -1
  150. package/dist/rest/me.d.mts +8 -4
  151. package/dist/rest/merges.d.mts +8 -4
  152. package/dist/rest/paths.mjs +1 -0
  153. package/dist/rest/queue.d.mts +282 -226
  154. package/dist/rest/refs.d.mts +205 -176
  155. package/dist/rest/repos.d.mts +108 -80
  156. package/dist/rest/tags.d.mts +24 -12
  157. package/dist/rest/tokens.d.mts +235 -211
  158. package/dist/rest/topics.d.mts +53 -33
  159. package/dist/rest/trees.d.mts +105 -89
  160. package/dist/rest/work.d.mts +467 -20
  161. package/dist/rest/work.mjs +8 -0
  162. package/dist/server/edge-node.d.mts +9 -13
  163. package/dist/server/edge-node.mjs +9 -12
  164. package/dist/server/git-layer.d.mts +1 -6
  165. package/dist/server/git-layer.mjs +2 -2
  166. package/dist/server/git-namespace.d.mts +3 -3
  167. package/dist/server/joined.d.mts +15 -22
  168. package/dist/server/joined.mjs +5 -29
  169. package/dist/server/lifecycle.mjs +107 -23
  170. package/dist/server/registry.mjs +9 -1
  171. package/dist/server/server.mjs +133 -212
  172. package/dist/storage/budget.mjs +2 -2
  173. package/dist/storage/clean-up.mjs +13 -10
  174. package/dist/storage/fetch.mjs +13 -8
  175. package/dist/storage/file-limits.mjs +24 -0
  176. package/dist/storage/index-build.d.mts +1 -0
  177. package/dist/storage/index-build.mjs +106 -62
  178. package/dist/storage/index-fetch.mjs +16 -3
  179. package/dist/storage/index-reach.mjs +33 -5
  180. package/dist/storage/index-remap.mjs +8 -1
  181. package/dist/storage/index-shallow.mjs +5 -3
  182. package/dist/storage/largest-files.mjs +48 -0
  183. package/dist/storage/lfs-pointers.mjs +10 -1
  184. package/dist/storage/loose.mjs +3 -1
  185. package/dist/storage/memory-budget.mjs +28 -4
  186. package/dist/storage/pack-reads.mjs +8 -8
  187. package/dist/storage/pack-receive.mjs +83 -25
  188. package/dist/storage/packs.mjs +37 -21
  189. package/dist/storage/prune-keep.mjs +203 -34
  190. package/dist/storage/prune-walk.mjs +54 -16
  191. package/dist/storage/prune.mjs +629 -196
  192. package/dist/storage/push-uploads.mjs +36 -12
  193. package/dist/storage/quarantine.mjs +9 -9
  194. package/dist/storage/ready.mjs +47 -19
  195. package/dist/storage/receive-bounds.mjs +29 -8
  196. package/dist/storage/receive-state.mjs +8 -0
  197. package/dist/storage/receive-steps.mjs +71 -18
  198. package/dist/storage/repack.d.mts +1 -1
  199. package/dist/storage/repack.mjs +1 -8
  200. package/dist/storage/rows.mjs +12 -1
  201. package/dist/storage/shallow.d.mts +1 -0
  202. package/dist/storage/shallow.mjs +26 -4
  203. package/dist/storage/stream-whole.mjs +5 -2
  204. package/dist/storage/visible.mjs +29 -1
  205. package/dist/storage/walk.mjs +2 -1
  206. package/dist/store/catalogue.mjs +1 -0
  207. package/dist/store/cursor-seal-namespace.d.mts +2 -0
  208. package/dist/store/cursor-seal-public.d.mts +5 -0
  209. package/dist/store/cursor-seal-public.mjs +5 -0
  210. package/dist/store/cursor-seal.d.mts +16 -2
  211. package/dist/store/cursor-seal.mjs +26 -14
  212. package/dist/store/errors.mjs +9 -1
  213. package/dist/store/records.d.mts +2 -0
  214. package/dist/store/records.mjs +9 -6
  215. package/dist/store/repo-record.d.mts +9 -7
  216. package/dist/store/repo-record.mjs +102 -19
  217. package/dist/store/scopes.mjs +10 -2
  218. package/dist/sync/bound.d.mts +2 -0
  219. package/dist/sync/bound.mjs +11 -2
  220. package/dist/sync/github.d.mts +6 -1
  221. package/dist/sync/github.mjs +55 -43
  222. package/dist/sync/http.mjs +36 -1
  223. package/dist/sync/import.mjs +1 -0
  224. package/dist/sync/layer.mjs +6 -2
  225. package/dist/sync/lfs-batch.mjs +119 -0
  226. package/dist/sync/lfs-copy.mjs +251 -0
  227. package/dist/sync/mirror.mjs +210 -137
  228. package/dist/sync/smart-http.mjs +4 -2
  229. package/dist/sync/step.mjs +25 -5
  230. package/dist/sync/tries.mjs +45 -14
  231. package/dist/sync.d.mts +2 -2
  232. package/dist/topics/host.mjs +1 -19
  233. package/dist/topics/layer.mjs +1 -1
  234. package/package.json +3 -8
  235. package/dist/auth/bridge.mjs +0 -30
  236. package/dist/auth/helpers.d.mts +0 -17
  237. package/dist/core/purge.d.mts +0 -8
  238. package/dist/core/registered-rows.d.mts +0 -5
  239. package/dist/core/repack.d.mts +0 -11
  240. package/dist/http/handler.d.mts +0 -2
  241. package/dist/rest/handler.d.mts +0 -21
  242. package/dist/rest.d.mts +0 -2
  243. package/dist/rest.mjs +0 -1
  244. package/dist/server/registry.d.mts +0 -16
  245. package/dist/server/server.d.mts +0 -36
  246. package/dist/storage/repack-job.d.mts +0 -3
  247. package/dist/topics/host.d.mts +0 -7
@@ -1,10 +1,12 @@
1
1
  import { keepsEvents } from "../contracts/events.mjs";
2
+ import { check } from "../contracts/authorize.mjs";
2
3
  import { badCursor } from "../engine/reads.mjs";
3
4
  import { utf8 } from "../protocol/bytes/text.mjs";
4
5
  import { afterCommit } from "../store/call-count.mjs";
5
6
  import { listBound } from "../store/cursor-seal.mjs";
6
7
  import { storeCall } from "../store/errors.mjs";
7
8
  import { keptKey } from "../store/records.mjs";
9
+ import { readRecord } from "../store/repo-record.mjs";
8
10
  import { newChangeId, repoScope } from "../store/scopes.mjs";
9
11
  import { callerFor, contended, openRepo, repoAccess } from "./access.mjs";
10
12
  import { isDeliverJob, skipFailed } from "./events/deliver.mjs";
@@ -77,6 +79,37 @@ const keepAnswer = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, kept
77
79
  tries: 5
78
80
  }));
79
81
  });
82
+ /**
83
+ * A page of the jobs in `internalId`'s scope, as `list` and `listById` answer them, those `shown`
84
+ * keeps. With `access`, a cursor is sealed for `list`'s page of the repo in its state: the store's
85
+ * names the job its page ends on, which may be one the caller doesn't see. A page is left short
86
+ * rather than read on, so its length is the store's page less the jobs the caller can't see;
87
+ * `next` still goes on where the store's page ended.
88
+ */
89
+ const jobsPage = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, list, input, shown) {
90
+ const core = yield* CoreParts;
91
+ const sealed = core.access !== void 0;
92
+ const bound = listBound(list, internalId, input.state ?? "");
93
+ const sent = input.page?.after;
94
+ const opens = sent === void 0 || !sealed ? sent : yield* core.cursors.open(bound, sent);
95
+ const after = sealed && opens !== void 0 ? storeCursor(opens) : opens;
96
+ if (sent !== void 0 && after === void 0) return yield* badCursor();
97
+ const request = {};
98
+ if (input.state !== void 0) request.state = input.state;
99
+ if (input.page !== void 0) {
100
+ const page = { ...input.page };
101
+ if (after !== void 0) page.after = after;
102
+ request.page = page;
103
+ }
104
+ const { jobs } = yield* QueueParts;
105
+ const listed = yield* storeCall(() => jobs.list(repoScope(internalId), request));
106
+ const items = listed.items.filter(shown);
107
+ if (listed.next === void 0) return { items };
108
+ return {
109
+ items,
110
+ next: sealed ? yield* core.cursors.seal(bound, yield* workCursorText(listed.next)) : listed.next
111
+ };
112
+ });
80
113
  /** `work`: a repo's jobs, over the queue's own calls, once `authorize` lets the caller. */
81
114
  const workCalls = (bound) => {
82
115
  const callerOf = callerFor(bound);
@@ -129,31 +162,23 @@ const workCalls = (bound) => {
129
162
  kind: "work.list",
130
163
  repo
131
164
  }, [], input.internalId);
132
- const { internalId } = opened;
133
165
  const repoOf = repoAccess(opened);
134
166
  const refView = yield* refViewIn(caller, repoOf);
167
+ return yield* jobsPage(opened.internalId, "work.list", input, (item) => seesJob(refView, item));
168
+ }),
169
+ listById: Effect.fnUntraced(function* (internalId, input) {
170
+ const caller = callerOf(input);
171
+ yield* check({
172
+ caller,
173
+ operation: {
174
+ kind: "work.listById",
175
+ internalId
176
+ }
177
+ });
135
178
  const core = yield* CoreParts;
136
- const sealed = core.access !== void 0;
137
- const bound = listBound("work.list", internalId, input.state ?? "");
138
- const sent = input.page?.after;
139
- const opens = sent === void 0 || !sealed ? sent : yield* core.cursors.open(bound, sent);
140
- const after = sealed && opens !== void 0 ? storeCursor(opens) : opens;
141
- if (sent !== void 0 && after === void 0) return yield* badCursor();
142
- const request = {};
143
- if (input.state !== void 0) request.state = input.state;
144
- if (input.page !== void 0) {
145
- const page = { ...input.page };
146
- if (after !== void 0) page.after = after;
147
- request.page = page;
148
- }
149
- const { jobs } = yield* QueueParts;
150
- const listed = yield* storeCall(() => jobs.list(repoScope(internalId), request));
151
- const items = listed.items.filter((item) => seesJob(refView, item));
152
- if (listed.next === void 0) return { items };
153
- return {
154
- items,
155
- next: sealed ? yield* core.cursors.seal(bound, yield* workCursorText(listed.next)) : listed.next
156
- };
179
+ const { record } = yield* readRecord(core.store, internalId);
180
+ if (record === void 0) return yield* fail("NOT_FOUND", `No repo '${internalId}'`);
181
+ return yield* jobsPage(internalId, "work.listById", input, () => true);
157
182
  }),
158
183
  retry: write("work.retry"),
159
184
  discard: write("work.discard")
package/dist/effect.d.mts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { EffectCalls, GitCaller, GitStore } from "./contracts/services.mjs";
2
2
  import { IndexCalls, IndexReachInput, IndexReached, IndexStatus, IndexTip, IndexTry, IndexTryInput } from "./contracts/objects.mjs";
3
+ import { Actor } from "./contracts/actors.mjs";
4
+ import { RepoName } from "./contracts/ids.mjs";
3
5
  import { CallAllowance, CallBudget, CallBudgetOptions } from "./store/call-count.mjs";
4
6
  import { commitCallsMost, storeCall } from "./store/errors.mjs";
5
7
  import { bucketCall } from "./storage/calls.mjs";
@@ -13,4 +15,4 @@ import { ReposApiGroup } from "./rest/repos.mjs";
13
15
  import { TokensApiGroup } from "./rest/tokens.mjs";
14
16
  import { WorkApiGroup } from "./rest/work.mjs";
15
17
  import { SeamAuthorizeInput, TokenRevokeCheck } from "./core/seam.mjs";
16
- export { type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, type IndexCalls, type IndexReachInput, type IndexReached, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, MeApiGroup, RefsApiGroup, ReposApiGroup, type RestServerSeam, type SeamAuthorizeInput, type TokenRevokeCheck, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
18
+ export { Actor, type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, type IndexCalls, type IndexReachInput, type IndexReached, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, MeApiGroup, RefsApiGroup, RepoName, ReposApiGroup, type RestServerSeam, type SeamAuthorizeInput, type TokenRevokeCheck, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
package/dist/effect.mjs CHANGED
@@ -1,4 +1,6 @@
1
1
  import { GitCaller, GitStore } from "./contracts/services.mjs";
2
+ import { Actor } from "./contracts/actors.mjs";
3
+ import { RepoName } from "./contracts/ids.mjs";
2
4
  import { CallBudget } from "./store/call-count.mjs";
3
5
  import { commitCallsMost, storeCall } from "./store/errors.mjs";
4
6
  import { bucketCall } from "./storage/calls.mjs";
@@ -11,4 +13,4 @@ import { RefsApiGroup } from "./rest/refs.mjs";
11
13
  import { ReposApiGroup } from "./rest/repos.mjs";
12
14
  import { TokensApiGroup } from "./rest/tokens.mjs";
13
15
  import { WorkApiGroup } from "./rest/work.mjs";
14
- export { CallBudget, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, MeApiGroup, RefsApiGroup, ReposApiGroup, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
16
+ export { Actor, CallBudget, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, MeApiGroup, RefsApiGroup, RepoName, ReposApiGroup, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
@@ -81,13 +81,20 @@ const timed = (effect, deadline) => Effect.flatMap(Clock$1.currentTimeMillis, (n
81
81
  orElse: () => ranPast(deadline)
82
82
  })).pipe(Effect.catch((error) => Effect.andThen(within(deadline), Effect.fail(error))), Effect.tap(() => within(deadline)));
83
83
  /**
84
- * A page's size: the caller's whole number, held to 1 through `maxPageLimit` as the store's lists
85
- * hold it. A limit that isn't a whole number is refused, since no page holds part of an item.
84
+ * The most a page of `commits.list` holds when called in process: a caller that reads a range
85
+ * whole, such as a release's notes past 1,000 commits, lists it in one walk, where each page of
86
+ * `maxPageLimit` would walk it again. The REST API holds its pages to `maxPageLimit`.
86
87
  */
87
- const limitOf = (page = {}) => {
88
+ const logLimitMost = 1001;
89
+ /**
90
+ * A page's size: the caller's whole number, held to 1 through `most`, `maxPageLimit` as the
91
+ * store's lists hold it unless a call names more. A limit that isn't a whole number is refused,
92
+ * since no page holds part of an item.
93
+ */
94
+ const limitOf = (page = {}, most = 200) => {
88
95
  const limit = page.limit ?? 50;
89
- if (!Number.isSafeInteger(limit)) return fail("INVALID_ARGUMENT", "A page limit is a whole number", { hint: `Leave it out for 50, or pass 1 through 200` });
90
- return Effect.succeed(Math.min(Math.max(limit, 1), 200));
96
+ if (!Number.isSafeInteger(limit)) return fail("INVALID_ARGUMENT", "A page limit is a whole number", { hint: `Leave it out for 50, or pass 1 through ${most}` });
97
+ return Effect.succeed(Math.min(Math.max(limit, 1), most));
91
98
  };
92
99
  /** What binds a cursor to its call's input: the SHA-1 of each part, NUL-joined. */
93
100
  const inputDigest = (parts) => Effect.map(sha1Of(utf8(parts.join("\0"))), (digest) => Hex.encode(digest).slice(0, 16));
@@ -102,4 +109,4 @@ const indexOf = (after, digest) => {
102
109
  if (held !== digest || rest.length > 0 || !/^[1-9]\d*$/.test(index ?? "")) return badCursor();
103
110
  return Effect.succeed(Number(index));
104
111
  };
105
- export { badCursor, deadlineOf, defaultMilliseconds, indexCursor, indexOf, inputDigest, limitOf, limitsOf, readThrough, readsThrough, stepDeadline, timed, within };
112
+ export { badCursor, deadlineOf, defaultMilliseconds, indexCursor, indexOf, inputDigest, limitOf, limitsOf, logLimitMost, readThrough, readsThrough, stepDeadline, timed, within };
@@ -218,7 +218,7 @@ const started = /* @__PURE__ */ Effect.fnUntraced(function* (reader, wants, have
218
218
  * `--author`, `--committer`, `--max-age` and `--min-age` do. Each walk here sees each of `roots`
219
219
  * as having no parents, as Git's shallow grafts make a repo's roots.
220
220
  */
221
- const walkHistory = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, call, roots = noRepoRoots) {
221
+ const walkHistory = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, call, roots = noRepoRoots, most = 200) {
222
222
  const haves = input.haves ?? [];
223
223
  if (input.wants.length === 0) return yield* fail("INVALID_ARGUMENT", "A walk needs a want");
224
224
  const digest = yield* inputDigest([
@@ -229,7 +229,7 @@ const walkHistory = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, ca
229
229
  filterKey(input)
230
230
  ]);
231
231
  const stale = staleOf(input);
232
- return yield* paged(read, input, digest, (walk, take) => haves.length > 0 ? limited(walk, take, input) : unlimited(walk, take, stale), call, roots);
232
+ return yield* paged(read, input, digest, (walk, take) => haves.length > 0 ? limited(walk, take, input) : unlimited(walk, take, stale), call, roots, most);
233
233
  });
234
234
  /** `rev-list --count <wants> ^<haves>`: how many commits the walk lists, within its limits. */
235
235
  const countHistory = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, call, roots = noRepoRoots) {
@@ -325,9 +325,9 @@ const simplified = /* @__PURE__ */ Effect.fnUntraced(function* (walk, parts, tak
325
325
  * walk runs again from the start each page, within the call's limits, and lists after its
326
326
  * cursor's commit, so a cursor holds the input's digest and that commit.
327
327
  */
328
- const paged = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, digest, run, call, roots) {
328
+ const paged = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, digest, run, call, roots, most = 200) {
329
329
  const limits = yield* limitsOf(input.limits);
330
- const limit = yield* limitOf(input.page);
330
+ const limit = yield* limitOf(input.page, most);
331
331
  const after = yield* afterOf(input.page?.after, digest);
332
332
  const items = [];
333
333
  const keeps = keeperOf(input);
@@ -17,7 +17,7 @@ export interface EventStreamCalls {
17
17
  readonly feed: (input: FeedInput) => Stream.Stream<FeedItem, GitError>;
18
18
  }
19
19
  declare const EventStreams_base: Context.ServiceClass<EventStreams, "@ref0/git/EventStreams", EventStreamCalls>;
20
- /** A server's event feeds: every server's context holds it, `createGitServer`'s and `Git.layer`'s. */
20
+ /** A server's event feeds: every server's context holds it. */
21
21
  export declare class EventStreams extends /* @__PURE__ */ EventStreams_base {}
22
22
  export declare const feed: (input: FeedInput) => Stream.Stream<FeedItem, GitError, EventStreams>;
23
23
  /**
@@ -10,7 +10,7 @@ var event_streams_exports = /* @__PURE__ */ __exportAll({
10
10
  feed: () => feed,
11
11
  layer: () => layer
12
12
  });
13
- /** A server's event feeds: every server's context holds it, `createGitServer`'s and `Git.layer`'s. */
13
+ /** A server's event feeds: every server's context holds it. */
14
14
  var EventStreams = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/EventStreams")) {};
15
15
  const feed = (input) => Stream.unwrap(Effect.map(Effect.service(EventStreams), (streams) => streams.feed(input)));
16
16
  /**
@@ -24,7 +24,7 @@ export interface FeedFields {
24
24
  declare const FeedParts_base: Context.ServiceClass<FeedParts, "@ref0/git/event-streams/FeedParts", FeedFields>;
25
25
  /**
26
26
  * The server's `FeedFields`, which `EventStreams.layer()` builds over beside core's needs.
27
- * Internal: until 2c, only `createGitServer` provides it.
27
+ * Internal: only `Git.layer`'s core provides it.
28
28
  */
29
29
  export declare class FeedParts extends /* @__PURE__ */ FeedParts_base {}
30
30
  /** What `EventStreams.feed` is asked: whose events, from which repo, and after which `seq`. */
@@ -19,7 +19,7 @@ import * as Stream from "effect/Stream";
19
19
  // src/event-streams/stream.ts
20
20
  /**
21
21
  * The server's `FeedFields`, which `EventStreams.layer()` builds over beside core's needs.
22
- * Internal: until 2c, only `createGitServer` provides it.
22
+ * Internal: only `Git.layer`'s core provides it.
23
23
  */
24
24
  var FeedParts = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/event-streams/FeedParts")) {};
25
25
  /** The `FeedNeeds` a feed opened over, with its clock, which each later step runs over. */
package/dist/extend.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { isServerClosed } from "./store/closed.mjs";
2
- import { Joined, JoinedAdapter, JoinedCalls, Joining, joinLayer } from "./server/joined.mjs";
2
+ import { Joined, JoinedAdapter, JoinedCalls } from "./server/joined.mjs";
3
3
  import { Bucket } from "./contracts/objects.mjs";
4
4
  import { Clock, RecordStore, Store } from "./contracts/promises.mjs";
5
- import { ImportState } from "./contracts/sync.mjs";
5
+ import { ImportLfsMissed, ImportLfsReason, ImportState, ImportStatus } from "./contracts/sync.mjs";
6
6
  import { heldUntil, inTime } from "./store/repo-record.mjs";
7
- export { type Bucket, type Clock, type ImportState, type Joined, type JoinedAdapter, JoinedCalls, type Joining, type RecordStore, type Store, heldUntil, inTime, isServerClosed, joinLayer };
7
+ export { type Bucket, type Clock, type ImportLfsMissed, type ImportLfsReason, type ImportState, type ImportStatus, type Joined, type JoinedAdapter, JoinedCalls, type RecordStore, type Store, heldUntil, inTime, isServerClosed };
package/dist/extend.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  import { isServerClosed } from "./store/closed.mjs";
2
- import { JoinedCalls, joinLayer } from "./server/joined.mjs";
2
+ import { JoinedCalls } from "./server/joined.mjs";
3
3
  import { heldUntil, inTime } from "./store/repo-record.mjs";
4
- export { JoinedCalls, heldUntil, inTime, isServerClosed, joinLayer };
4
+ export { JoinedCalls, heldUntil, inTime, isServerClosed };
@@ -43,14 +43,16 @@ const notFound = () => refused(404, "NOT_FOUND", "Repository not found");
43
43
  * read gets the 404 a missing repo gets, so the repo's existence stays hidden. Pass `true` for an
44
44
  * answer that isn't a repo read, such as a push, a feature route or an approval page, so
45
45
  * `NOT_ALLOWED` keeps its 403. Any other refusal's body is its message, then its `hintLines`, which
46
- * Git prints as `remote:` lines.
46
+ * Git prints as `remote:` lines, and an `UNAVAILABLE` naming its `retryAfter` sets `Retry-After`.
47
47
  */
48
48
  const refusal = (error, pushing = false) => {
49
49
  if (error.code === "UNAUTHENTICATED") return signIn(error.message);
50
50
  if (error.code === "NOT_FOUND" || error.code === "NOT_ALLOWED" && !pushing) return notFound();
51
51
  const rateLimited = error.code === "RESOURCE_EXHAUSTED" && error.context?.reason === "rate-limited";
52
52
  const body = [error.message, ...hintLines(error.hint)].join("\n");
53
- return refused(rateLimited ? 429 : httpStatus[error.code], error.code, body);
53
+ const retryAfter = error.code === "UNAVAILABLE" ? error.context?.retryAfter : void 0;
54
+ const headers = retryAfter === void 0 ? void 0 : { "retry-after": `${retryAfter}` };
55
+ return refused(rateLimited ? 429 : httpStatus[error.code], error.code, body, headers);
54
56
  };
55
57
  /** A 301 to `location`, as a renamed repo's old `info/refs` answers. */
56
58
  const moved = (location) => {
@@ -1,13 +1,13 @@
1
- import { fail, gitErrorFrom } from "../contracts/result.mjs";
2
- import { openRepo, repoAccess } from "../core/access.mjs";
1
+ import { fail, gitError, gitErrorFrom } from "../contracts/result.mjs";
2
+ import { contended, openRepo, repoAccess } from "../core/access.mjs";
3
3
  import { accessAgain } from "../core/ref-view.mjs";
4
- import { gitPush } from "../core/push.mjs";
4
+ import { gitPush, keyedGitPush } from "../core/push.mjs";
5
5
  import { runFetchRules } from "../core/rules/fetch.mjs";
6
6
  import { fetchRulesOf } from "../core/rules/service.mjs";
7
7
  import { CoreParts, ObjectsParts } from "../core/parts.mjs";
8
- import { SealedObjects, viewOf } from "../core/view.mjs";
9
- import { notReachable } from "../storage/visible.mjs";
10
- import { heldOf, unreachableWant } from "../storage/wants.mjs";
8
+ import { SealedObjects, rootsSeen, viewOf } from "../core/view.mjs";
9
+ import { isVisibleTooLong, notReachable } from "../storage/visible.mjs";
10
+ import { heldOf, unreachableWant, wantWalkMost } from "../storage/wants.mjs";
11
11
  import { objectsFace } from "../storage/calls.mjs";
12
12
  import { indexRowKey } from "../storage/layout.mjs";
13
13
  import { spentIn } from "../contracts/calls-spent.mjs";
@@ -68,6 +68,16 @@ const fullClone = (table, request, refs) => {
68
68
  const wants = new Set(request.wants);
69
69
  return request.haves.length === 0 && request.shallows.length === 0 && request.depth === void 0 && request.deepenRelative !== true && request.filter === void 0 && refs.every((ref) => !fetchReaches(table, ref.name) || wants.has(ref.oid));
70
70
  };
71
+ /**
72
+ * A v0 listing's refusal where no index covers the listing and the walk of the caller's visible
73
+ * commits passes its bound before it ends: a root told as `shallow` it can't read names a hidden
74
+ * commit, and one left out sends a clone history it can't connect. v2 tells only the roots a
75
+ * fetch's pack sends, which asks no such question.
76
+ */
77
+ const rootsPastWalk = () => gitError("RESOURCE_EXHAUSTED", `Can't tell which of the repo's shallow roots you can read within ${wantWalkMost} objects: fetch with Git's protocol v2, \`git -c protocol.version=2\``, {
78
+ hint: "Fetch with Git protocol v2",
79
+ context: { reason: "walk-limit" }
80
+ });
71
81
  const coreHttpParts = (parts, options = {}) => {
72
82
  const { needs } = parts;
73
83
  const core = Context.get(needs, CoreParts);
@@ -192,7 +202,8 @@ const coreHttpParts = (parts, options = {}) => {
192
202
  * at its own. Each later page reads the record in its own call and asks `current`, and the first
193
203
  * page and `HEAD` ask it of `HEAD`'s read, the later of theirs, so a repo deleted, renamed or made
194
204
  * private, a right lost or a token revoked since the open, a POST's body read between, ends the
195
- * listing.
205
+ * listing. The repo's roots are read with page 1, and those `caller` may be told are asked once
206
+ * the last page is listed, as `ListedRefs.roots` says.
196
207
  */
197
208
  const listsAt = Effect.fnUntraced(function* (caller, repo, resolved) {
198
209
  const { internalId } = resolved;
@@ -211,8 +222,9 @@ const coreHttpParts = (parts, options = {}) => {
211
222
  });
212
223
  /** The refs of `rows` `view` sees, each tag peeled: a row with no peel fails in the stream. */
213
224
  const refsOf = ({ rows, view }) => Effect.flatMap(view.refs(rows), (seen) => advertised(rows, seen));
214
- const page = yield* readRecord(core.store, internalId, [refPage()]);
225
+ const page = yield* readRecord(core.store, internalId, [refPage(), repoRootsKey]);
215
226
  if (page.record === void 0) return yield* fail("NOT_FOUND", `No repo '${repo}'`);
227
+ const roots = yield* rootsOf(page.snapshot.results[2]);
216
228
  const head = headOf(page.record.defaultBranch);
217
229
  const headRead = {
218
230
  collection: collections.refs,
@@ -233,19 +245,52 @@ const coreHttpParts = (parts, options = {}) => {
233
245
  });
234
246
  let pending = first;
235
247
  let after = first.last;
248
+ const hidden = core.hiddenRefs();
249
+ const tips = [];
250
+ const shownOf = Effect.fnUntraced(function* (at) {
251
+ const refs = yield* refsOf(at);
252
+ if (roots.size > 0) for (const { name, oid } of refs) tips.push({
253
+ name,
254
+ oid
255
+ });
256
+ return refs;
257
+ });
236
258
  const next = Effect.gen(function* () {
237
259
  const page = pending;
238
260
  pending = void 0;
239
- if (page !== void 0) return yield* refsOf(page);
261
+ if (page !== void 0) return yield* shownOf(page);
240
262
  if (after === void 0) return void 0;
241
263
  const later = yield* pageAt(after);
242
264
  after = later.last;
243
- return yield* refsOf(later);
265
+ return yield* shownOf(later);
266
+ });
267
+ const told = Effect.gen(function* () {
268
+ if (roots.size === 0) return [];
269
+ const read = yield* readRecord(core.store, internalId, [
270
+ packsRead,
271
+ indexRowKey,
272
+ repoRootsKey
273
+ ]);
274
+ const { view } = yield* current(caller, repo, resolved, read);
275
+ const seen = yield* view.refView;
276
+ const [, packRows = [], indexRows = [], rootRows] = read.snapshot.results;
277
+ const packs = yield* decodePacks(packRows);
278
+ const at = {
279
+ listed: {
280
+ repo: internalId,
281
+ version: read.snapshot.version,
282
+ packs
283
+ },
284
+ index: indexRows[0]?.value,
285
+ roots: yield* rootsOf(rootRows),
286
+ tips: [...new Set(tips.flatMap(({ name, oid }) => seen.sees(name) ? [oid] : []))]
287
+ };
288
+ return [...yield* Effect.catchIf(rootsSeen(view, at), isVisibleTooLong, () => Effect.fail(rootsPastWalk()))].toSorted();
244
289
  });
245
- const hidden = core.hiddenRefs();
246
290
  const listed = {
247
291
  next: Effect.provideContext(next, needs),
248
- hidden
292
+ hidden,
293
+ roots: Effect.provideContext(told, needs)
249
294
  };
250
295
  const shown = hiddenUnder(hidden, head) === void 0;
251
296
  if (shown && refView.sees(head)) listed.head = head;
@@ -300,6 +345,7 @@ const coreHttpParts = (parts, options = {}) => {
300
345
  const unruled = (yield* fetchRulesOf()).length === 0;
301
346
  if (at.whole && unruled && fullClone(core.hiddenRefs(), request, at.refs.refs)) fetching.whole = true;
302
347
  if (request.thinPack === true && at.seesAll && unruled) fetching.thin = true;
348
+ if (at.roots.size > 0) fetching.roots = [...at.roots];
303
349
  return yield* at.objects.fetch(at.listed, fetching);
304
350
  })
305
351
  };
@@ -391,10 +437,11 @@ const landed = (stored, objects, caller, repo, input, internalId) => {
391
437
  edits: input.edits,
392
438
  atomic: input.atomic,
393
439
  pushOptions: input.pushOptions,
394
- request: input.request,
395
440
  signal: input.signal
396
441
  };
397
- if (input.pack !== void 0) {
442
+ if (input.request !== void 0) request.request = input.request;
443
+ if (input.stepped !== void 0) request.pack = input.stepped;
444
+ else if (input.pack !== void 0) {
398
445
  const { bytes, objects, length, atMost } = input.pack;
399
446
  const pack = {
400
447
  bytes,
@@ -406,7 +453,9 @@ const landed = (stored, objects, caller, repo, input, internalId) => {
406
453
  }
407
454
  if (internalId !== void 0) request.internalId = internalId;
408
455
  if (input.shallow !== void 0) request.shallow = input.shallow;
409
- return Effect.provideService(gitPush(request), ObjectsParts, {
456
+ const { key } = input;
457
+ const pushing = key === void 0 ? gitPush(request) : Effect.flatMap(keyedGitPush(request, key), (answer) => answer === void 0 ? contended() : Effect.succeed(answer));
458
+ return Effect.provideService(pushing, ObjectsParts, {
410
459
  ...stored,
411
460
  objects
412
461
  });
@@ -21,8 +21,8 @@ const gitHttp = (parts) => {
21
21
  } };
22
22
  };
23
23
  /**
24
- * What git-lfs prints from a server without `lfs()`, to the person pushing as much as its host: who
25
- * turns it on, and nothing only a host sets. The host's step, `lfs()`, is in `docs/deploy/large-pushes.md`.
24
+ * What git-lfs prints from a server without `Lfs.layer()`, to the person pushing as much as its
25
+ * host: who turns it on, and nothing only a host sets. The host's step is in `docs/deploy/large-pushes.md`.
26
26
  */
27
27
  const lfsOff = "This server has no Git LFS: its host turns it on";
28
28
  /** A request to Git LFS's API: its refusals are LFS's JSON, as git-lfs reads them. */
@@ -148,8 +148,9 @@ const answerAt = (handler, incoming, response, url) => {
148
148
  });
149
149
  };
150
150
  /**
151
- * A Git server, or any `fetch`, as a `node:http` or `node:http2` listener or an Express route:
152
- * `createServer(toNodeHandler(git))`; beside an app's own routes, `toNodeMiddleware`. The body
151
+ * A `fetch` as a `node:http` or `node:http2` listener or an Express route, which
152
+ * `@ref0/git/node`'s `toNodeHandler` hands a runtime's `Git.toFetch`; beside an app's own routes,
153
+ * `toNodeMiddleware`. The body
153
154
  * streams to Git unread. The response streams back as Node can take it, and a client that
154
155
  * disconnects or resets its stream before the response ends, which a `close` of the HTTP/2
155
156
  * stream, or the HTTP/1 response, before `writableEnded` says, aborts the request's `signal`, which ends Git's reads and leaves it
@@ -159,8 +160,8 @@ const answerAt = (handler, incoming, response, url) => {
159
160
  */
160
161
  const toNodeHandler = (handler) => (incoming, response) => answerAt(handler, incoming, response, void 0);
161
162
  /**
162
- * A Git server, or any `fetch`, beside an app's own routes, as an Express middleware:
163
- * `app.use(toNodeMiddleware(git, (url) => gitPathOf(url, '/git')))`, before any body parser. A
163
+ * A `fetch` beside an app's own routes, as an Express middleware, which `@ref0/git/node`'s
164
+ * `toNodeMiddleware` hands a runtime's `Git.toFetch`, before any body parser. A
164
165
  * request `pathOf` names is answered at the path it gives, as `toNodeHandler` answers it, the
165
166
  * query kept; every other goes on to `next`, its body unread. `pathOf` is handed the URL `fetch`
166
167
  * gets, with its dot segments resolved, so the path Express routed by never decides. A URL that
@@ -5,6 +5,7 @@ import "../contracts/refs.mjs";
5
5
  import "../contracts/result.mjs";
6
6
  import "../auth/identify.mjs";
7
7
  import "../core/access.mjs";
8
+ import "../core/push.mjs";
8
9
  import "../store/call-count.mjs";
9
10
  import "../protocol/wire/advertisement.mjs";
10
11
  import "../protocol/wire/lines.mjs";