@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
@@ -265,8 +265,9 @@ const indexShallow = /* @__PURE__ */ Effect.fnUntraced(function* (walk, request)
265
265
  });
266
266
  /** What it held, given back, but for the lines it returns: nothing, when it held nothing. */
267
267
  const given = Effect.suspend(() => Effect.andThen(heldBytes > 0 ? read.release(heldBytes) : Effect.void, readsHeld > 0 ? read.letGoReads(readsHeld) : Effect.void));
268
- const shallows = yield* clientShallowsOf(request.shallows);
269
- const clientShallows = new Set(shallows.map((shallow) => shallow.oid));
268
+ const held = yield* clientShallowsOf(request.shallows);
269
+ const clientShallows = new Set(held.map((shallow) => shallow.oid));
270
+ const shallows = held.filter((shallow) => !read.roots.has(shallow.oid));
270
271
  const depth = request.depth;
271
272
  if (depth === void 0) {
272
273
  yield* given;
@@ -297,7 +298,8 @@ const indexShallow = /* @__PURE__ */ Effect.fnUntraced(function* (walk, request)
297
298
  yield* keep(2 * (edge.numbers.length + edge.extras.length) * 70);
298
299
  const edgeOids = yield* oidsOf(edge);
299
300
  const unshallowed = shallows.filter((shallow) => hasMet(within, shallow));
300
- const kept = shallows.filter((shallow) => !hasMet(within, shallow)).map((each) => each.oid);
301
+ const unshallowedIds = new Set(unshallowed.map((shallow) => shallow.oid));
302
+ const kept = [...clientShallows].filter((oid) => !unshallowedIds.has(oid));
301
303
  const starts = yield* startsOf(unshallowed);
302
304
  yield* given;
303
305
  return {
@@ -0,0 +1,48 @@
1
+ /**
2
+ * A receive's largest blobs, as they're settled: a blob no larger than the smallest of a full list
3
+ * costs one compare, so a push of many small files keeps nothing.
4
+ */
5
+ var LargestFiles = class {
6
+ #kept = [];
7
+ #least = 0;
8
+ #partial = false;
9
+ /** A list going on from `from`, what a receive's step before this one kept. */
10
+ constructor(from) {
11
+ if (from === void 0) return;
12
+ this.#kept.push(...from.largest);
13
+ this.#partial = from.largestPartial === true;
14
+ this.#least = this.#kept.at(-1)?.size ?? 0;
15
+ }
16
+ add(oid, size) {
17
+ const kept = this.#kept;
18
+ if (kept.length === 64 && size <= this.#least) {
19
+ this.#partial = true;
20
+ return;
21
+ }
22
+ kept.push({
23
+ oid,
24
+ size
25
+ });
26
+ kept.sort((a, b) => b.size - a.size);
27
+ if (kept.length > 64) {
28
+ kept.pop();
29
+ this.#partial = true;
30
+ }
31
+ this.#least = kept.at(-1)?.size ?? 0;
32
+ }
33
+ /** The list, largest first, and `largestPartial` when it left a blob out. */
34
+ finish() {
35
+ const largest = [...this.#kept];
36
+ return this.#partial ? {
37
+ largest,
38
+ largestPartial: true
39
+ } : { largest };
40
+ }
41
+ };
42
+ /** The largest of `objects`' blobs, as `LargestFiles` keeps them: a receive kept as rows. */
43
+ const largestOf = (objects) => {
44
+ const largest = new LargestFiles();
45
+ for (const object of objects) if (object.type === "blob") largest.add(object.oid, object.bytes.byteLength);
46
+ return largest.finish();
47
+ };
48
+ export { LargestFiles, largestOf };
@@ -209,9 +209,18 @@ var ReceivedPointers = class {
209
209
  };
210
210
  /** At a step's end, the pointers `found` as their table holds them, for the next step's `carried`. */
211
211
  const pointersRecords = (found) => LfsPointers.pagesOf(found).map((page, at) => page.subarray(0, Math.min(pageEntries, found.count - at * pageEntries) * 57));
212
+ /**
213
+ * One page `pointersRecords` gave, read as pointers again, as import keeps them between its
214
+ * segments and its copy: `undefined` for bytes that aren't whole entries, or more than a page.
215
+ */
216
+ const pointersOfRecord = (record) => {
217
+ const count = record.byteLength / 57;
218
+ if (!Number.isInteger(count) || count > 1024) return void 0;
219
+ return LfsPointers.made(count, [record]);
220
+ };
212
221
  /** The pointers among a receive's whole objects, found by `pointers`. */
213
222
  const pointersOfObjects = /* @__PURE__ */ Effect.fnUntraced(function* (objects, pointers = new ReceivedPointers()) {
214
223
  for (const object of objects) if (object.type === "blob") yield* pointers.add(object.oid, object.bytes);
215
224
  return pointers.finish();
216
225
  });
217
- export { ReceivedPointers, lfsOidAt, lfsPointers, lfsPointersMost, lfsSizeAt, noLfsPointers, pageEntries, pointerSizeMost, pointersOfBlob, pointersOfObjects, pointersRecords };
226
+ export { ReceivedPointers, lfsOidAt, lfsPointers, lfsPointersMost, lfsSizeAt, noLfsPointers, pageEntries, pointerSizeMost, pointersOfBlob, pointersOfObjects, pointersOfRecord, pointersRecords };
@@ -8,6 +8,7 @@ import { copyRowsPage, eachHeldRow, gitObjectOf, heldRows, rowHeaders, rowSizes,
8
8
  import { allotmentWithin } from "../contracts/object-values.mjs";
9
9
  import { allottedRows } from "./allotted.mjs";
10
10
  import { pointersOfObjects } from "./lfs-pointers.mjs";
11
+ import { largestOf } from "./largest-files.mjs";
11
12
  import { wholeRoots } from "./roots.mjs";
12
13
  import { commitBytes, unpackObjects } from "./unpack.mjs";
13
14
  import { gitError } from "../contracts/result.mjs";
@@ -68,7 +69,8 @@ const receiveRows = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed,
68
69
  },
69
70
  bytes: unpacked.bytes,
70
71
  objects: unpacked.objects.length,
71
- lfsPointers: yield* pointersOfObjects(unpacked.objects)
72
+ lfsPointers: yield* pointersOfObjects(unpacked.objects),
73
+ ...largestOf(unpacked.objects)
72
74
  };
73
75
  if (unpacked.cut.length > 0) quarantine.cut = unpacked.cut;
74
76
  received.add(quarantine);
@@ -1,7 +1,7 @@
1
1
  import { gitError } from "../contracts/result.mjs";
2
2
  import { RequestHolding } from "../store/call-count.mjs";
3
- import { pushFloorsOf, readerFloors, readerMost } from "./budget.mjs";
4
- import { packIndexerLimits } from "./pack-reads.mjs";
3
+ import { pushFloorsOf, readerFloors, readerMost, receiveObjectsMostOf } from "./budget.mjs";
4
+ import { indexBytes, packIndexerLimits } from "./pack-reads.mjs";
5
5
  import { ReceivedPointers, lfsPointersMost, pageEntries } from "./lfs-pointers.mjs";
6
6
  import { receiveRoomAdmitted } from "./receive-admission.mjs";
7
7
  import { ReceiveRoom } from "./runs.mjs";
@@ -948,7 +948,8 @@ const upkeepRuns = {
948
948
  * The room a prune walk's reader holds its packs' `.idx` and `.rev` in, whatever their sum: a
949
949
  * fixed size, never sized up to what's spare, which a walk charges once in place of each pack's
950
950
  * (#2230). About 1,050,000 objects' indexes at 32 B an object. A merge cuts each pack it writes so
951
- * its index fits, and a walk refuses a listed pack whose index alone passes it.
951
+ * its index fits, a push takes no more objects than `pruneIndexObjectsMost`, and a walk refuses a
952
+ * listed pack whose index alone passes it.
952
953
  *
953
954
  * It fits beside the rest of a walk at its bounds: `pruneWalkHeld()`'s 47,844,271, this
954
955
  * 33,554,432 and the read reserve's 4,194,688 come to 85,593,391, under the default memory's
@@ -956,6 +957,29 @@ const upkeepRuns = {
956
957
  */
957
958
  const pruneIndexFloor = 33554432;
958
959
  /**
960
+ * The most objects whose pack's index fits `pruneIndexFloor`, 1,048,528: 32 B an object past its
961
+ * fixed 1,508, in a pack under 2 GiB, whose index takes no large offsets (#2402). Every pack prune
962
+ * meets is: a received one's entries each start under `pushUploadMost` and take at most
963
+ * `packFileBytes`, and a merge cuts under `maxPackSizeMost`.
964
+ */
965
+ const pruneIndexObjectsMost = Math.floor((pruneIndexFloor - indexBytes({
966
+ objects: 0,
967
+ bytes: 0
968
+ })) / (indexBytes({
969
+ objects: 1,
970
+ bytes: 0
971
+ }) - indexBytes({
972
+ objects: 0,
973
+ bytes: 0
974
+ })));
975
+ /**
976
+ * The most objects one push of `size`'s length takes in a `packs()` instance of `memory`: what its
977
+ * memory takes, `receiveObjectsMostOf`, and no more than `pruneIndexObjectsMost`, so a prune walk
978
+ * holds its pack's index, which no merge cuts while it's alone. Past it, a push is refused before
979
+ * it waits, by the most. In a Worker's 128 MB, 1,048,528, whatever its length.
980
+ */
981
+ const pushObjectsMostOf = (memory, size = {}) => Math.min(receiveObjectsMostOf(memory, size), pruneIndexObjectsMost);
982
+ /**
959
983
  * What a prune walk's seen set holds (#2019): a bit for each object of each of `packs`, at its rank,
960
984
  * and for each of `outside` objects no listed pack holds, its ID, at `fetchEntryBytes`. A part's
961
985
  * save puts the same bytes, the IDs at 20 each, so its read holds no more.
@@ -1099,4 +1123,4 @@ var AllottedPointers = class {
1099
1123
  return this.#pointers.finish();
1100
1124
  }
1101
1125
  };
1102
- export { AllottedPointers, MemoryAllotment, MemoryBudget, allottedWithin, fetchBusy, growWaitMs, headStuckMs, joinRoomOf, outsideOn, pruneIndexFloor, pruneSeenBytes, pushBusy, pushEntryTooLarge, pushIndexTooLarge, pushMemoryOf, pushTooLarge, pushWaitMs, readBusy, readerMemoryOf, upkeepMemoryOf, upkeepRuns, upkeepTooLarge };
1126
+ export { AllottedPointers, MemoryAllotment, MemoryBudget, allottedWithin, fetchBusy, growWaitMs, headStuckMs, joinRoomOf, outsideOn, pruneIndexFloor, pruneIndexObjectsMost, pruneSeenBytes, pushBusy, pushEntryTooLarge, pushIndexTooLarge, pushMemoryOf, pushObjectsMostOf, pushTooLarge, pushWaitMs, readBusy, readerMemoryOf, upkeepMemoryOf, upkeepRuns, upkeepTooLarge };
@@ -21,6 +21,7 @@ import { eachHeldRow, gitObjectOf, rowHeaders, rowSizes, rowsStartingWith, start
21
21
  import { LeavingRow, decodeHeld } from "./rows.mjs";
22
22
  import { SingleFlight } from "./single-flight.mjs";
23
23
  import { allotted, keptOrLeft } from "./allotted.mjs";
24
+ import { fileBytesMost } from "./file-limits.mjs";
24
25
  import * as Effect from "effect/Effect";
25
26
  import * as Option from "effect/Option";
26
27
  import * as Cause from "effect/Cause";
@@ -32,11 +33,6 @@ import * as Fiber from "effect/Fiber";
32
33
  // src/storage/pack-reads.ts
33
34
  /** The largest object `packs()` reads whole: a file past it is stored and sent as it is. */
34
35
  const packObjectBytes = 16777216;
35
- /**
36
- * The largest file `packs()` takes, GitHub's limit: a blob sent whole, hashed as it streams and
37
- * never held, and sent back as it is stored.
38
- */
39
- const packFileBytes = 104857600;
40
36
  /** How `packs()` resolves an entry, on a receive and on a read. */
41
37
  const packIndexerLimits = {
42
38
  objectBytes: packObjectBytes,
@@ -45,10 +41,14 @@ const packIndexerLimits = {
45
41
  nameBytes: 4 * packObjectBytes,
46
42
  chainReads: 64
47
43
  };
48
- /** How large an entry's header may say it is, for reads of headers alone: a file's to `packFileBytes`. */
44
+ /**
45
+ * How large an entry's header may say it is, for reads of headers alone: a file's to `fileBytesMost`,
46
+ * the most a push's `refuseAbove` may let in. A file past `packObjectBytes` is sent as it's stored,
47
+ * never read whole.
48
+ */
49
49
  const headerLimits = {
50
50
  ...packIndexerLimits,
51
- objectBytes: packFileBytes
51
+ objectBytes: fileBytesMost
52
52
  };
53
53
  /**
54
54
  * What one operation's reads keep of the objects they resolve, across every pack it reads: a
@@ -1688,4 +1688,4 @@ const narrowedTo = (reads, visible) => {
1688
1688
  wholeBlobs: (oids) => Effect.flatMap(only(oids), reads.wholeBlobs)
1689
1689
  };
1690
1690
  };
1691
- export { IndexReloaded, IndexShort, PackBlocks, PackIndexes, blockBytes, blockHeld, blocksHeld, entryEnd, hashedNowMost, hashedRunMost, headerLimits, indexBytes, indexSeedShare, isIndexReloaded, isIndexShort, loadedLookup, packFileBytes, packIndexerLimits, packObjectBytes, packObjects, packReader, rangedLookup, readCacheBytes, seedBytes };
1691
+ export { IndexReloaded, IndexShort, PackBlocks, PackIndexes, blockBytes, blockHeld, blocksHeld, entryEnd, hashedNowMost, hashedRunMost, headerLimits, indexBytes, indexSeedShare, isIndexReloaded, isIndexShort, loadedLookup, packIndexerLimits, packObjectBytes, packObjects, packReader, rangedLookup, readCacheBytes, seedBytes };
@@ -18,6 +18,8 @@ import { packPutOptions, startPut } from "./merge.mjs";
18
18
  import { repoTypes } from "./held-types.mjs";
19
19
  import { checkedFilesRefused, checkedOverflow, checkedRecords, fsckRefusal, receiveChecked } from "./fsck.mjs";
20
20
  import { packFiles } from "./layout.mjs";
21
+ import { fileBytesMost, fileRefuseBytes } from "./file-limits.mjs";
22
+ import { LargestFiles } from "./largest-files.mjs";
21
23
  import { ReceivedPointers, pointersRecords } from "./lfs-pointers.mjs";
22
24
  import { boundaryNotInPack, linkReader, segmentCut, segmentTooLarge, tagTargetMissing, wrongType } from "./links.mjs";
23
25
  import { noRows } from "./object-rows.mjs";
@@ -30,7 +32,7 @@ import { checkRow, checkRowAt, sweepHeld, sweepRowAt, sweepRows } from "./receiv
30
32
  import { pushPackTooLarge, pushUploadMost } from "./push-uploads.mjs";
31
33
  import { chainUnitsOf, receiveTable, receiveTableBytes } from "./receive-table.mjs";
32
34
  import { rootsCollected } from "./roots.mjs";
33
- import { packFileBytes, packIndexerLimits, packObjectBytes, packReader } from "./pack-reads.mjs";
35
+ import { packIndexerLimits, packObjectBytes, packReader } from "./pack-reads.mjs";
34
36
  import { dropRefused, openQuarantine, stillOpen } from "./quarantine.mjs";
35
37
  import { malformedPack, ofsRefused, readFailure } from "./unpack.mjs";
36
38
  import { oidBytes } from "../protocol/packs/idx.mjs";
@@ -39,12 +41,47 @@ import * as Result from "effect/Result";
39
41
  import * as Data from "effect/Data";
40
42
  // src/storage/pack-receive.ts
41
43
  /**
42
- * How large the reader lets an entry be: a whole one to `packFileBytes`, kept only if it's a blob.
44
+ * How large the reader lets an entry be: a whole one to `fileBytesMost`, kept only if it's a blob,
45
+ * so a file past a push's `refuseAbove` is named, then refused by core with its path (#2395).
43
46
  * Anything else, and any delta, is resolved whole, within `packObjectBytes`.
44
47
  */
45
48
  const receiveLimits = {
46
49
  ...packIndexerLimits,
47
- objectBytes: packFileBytes
50
+ objectBytes: fileBytesMost
51
+ };
52
+ /**
53
+ * The steps of a staged receive that lists no largest files, an import's: a file past
54
+ * `fileRefuseBytes` is refused as it's read, by its offset alone. A push upload's steps list them,
55
+ * carried from step to step, and read an entry to what the try's CPU leaves past its share, as
56
+ * `StepInput.largest` says (#2468).
57
+ */
58
+ const stepLimits = {
59
+ ...packIndexerLimits,
60
+ objectBytes: fileRefuseBytes
61
+ };
62
+ /**
63
+ * A push upload's step's limits, from the largest entry it reads, `entryMost`, as
64
+ * `StepInput.largest` says: the reader takes a whole entry to it, and each delta's instructions to
65
+ * `deltaBytes` or it if less; the indexer resolves and names a delta's result to the least of its
66
+ * own limits and it. So on a host whose try reads a smaller entry than `packObjectBytes`, no delta
67
+ * costs more than its largest entry (#2500). The indexer's `deltaBytes` stays
68
+ * `packIndexerLimits`': it bounds a chain's instructions together as it reads them again, each
69
+ * delta's already held to the reader's.
70
+ */
71
+ const listingLimits = (entryMost) => {
72
+ const { objectBytes, deltaBytes, nameBytes } = packIndexerLimits;
73
+ return {
74
+ reader: {
75
+ ...packIndexerLimits,
76
+ deltaBytes: Math.min(deltaBytes, entryMost),
77
+ objectBytes: entryMost
78
+ },
79
+ indexer: {
80
+ ...packIndexerLimits,
81
+ objectBytes: Math.min(objectBytes, entryMost),
82
+ nameBytes: Math.min(nameBytes, entryMost)
83
+ }
84
+ };
48
85
  };
49
86
  /** What the reader may hold besides the entries it hands on: its inflater and buffers. */
50
87
  const readerBytes = 1048576;
@@ -153,25 +190,28 @@ const tooDeep = (offset, links) => gitError("RESOURCE_EXHAUSTED", `The delta at
153
190
  hint: deepHint,
154
191
  context: { reason: "too-large" }
155
192
  });
156
- /** What a pusher does so Git sends each file past `packObjectBytes` whole, past its next gc too, or keeps it out of the pack with Git LFS. */
157
- const wholeHint = "Set `git config core.bigFileThreshold 16m`, run `git repack -adf`, then push again, or track the file with Git LFS";
158
193
  /**
159
- * A delta whose base or result is past `packObjectBytes`: Git sends one for a file it holds as a
160
- * delta, so its hint has Git hold files that size whole. Its reason is its own, not
194
+ * What a pusher does so Git sends each file past `most` whole, past its next gc too, or keeps it
195
+ * out of the pack with Git LFS: `packObjectBytes`' 16m, or a smaller host's step's in KiB.
196
+ */
197
+ const wholeHintOf = (most) => `Set \`git config core.bigFileThreshold ${most % 1048576 === 0 ? `${most / 1048576}m` : `${Math.floor(most / 1024)}k`}\`, run \`git repack -adf\`, then push again, or track the file with Git LFS`;
198
+ /**
199
+ * A delta whose base or result is past `most`, `packObjectBytes` or a push upload's step's largest
200
+ * entry: Git sends one for a file it holds as a delta, so its hint has Git hold files that size whole. Its reason is its own, not
161
201
  * `object-too-large`: the same file sent whole is taken, so a pack that names its base outside it
162
202
  * fails where one holding the file alone lands.
163
203
  */
164
- const deltaTooLarge = (offset) => gitError("RESOURCE_EXHAUSTED", `The delta at ${offset} is of an object past the ${packObjectBytes.toLocaleString("en-US")} bytes this server resolves`, {
165
- hint: wholeHint,
204
+ const deltaTooLarge = (offset, most) => gitError("RESOURCE_EXHAUSTED", `The delta at ${offset} is of an object past the ${most.toLocaleString("en-US")} bytes this server resolves`, {
205
+ hint: wholeHintOf(most),
166
206
  context: { reason: "delta-too-large" }
167
207
  });
168
208
  /** A whole object past `packObjectBytes` that isn't a file. */
169
209
  const wholeTooLarge = (offset, kind) => gitError("RESOURCE_EXHAUSTED", `The ${kind} at ${offset} is past the ${packObjectBytes.toLocaleString("en-US")} bytes this server reads whole`, { context: { reason: "object-too-large" } });
170
210
  /** A file past `packObjectBytes` that a tree names as its `.gitmodules` or `.gitattributes`. */
171
211
  const checkedTooLarge = (offset) => gitError("RESOURCE_EXHAUSTED", `The .gitmodules or .gitattributes at ${offset} is past the ${packObjectBytes.toLocaleString("en-US")} bytes this server reads to check it`, { context: { reason: "object-too-large" } });
172
- /** An entry the indexer found no place for, as the push's refusal. */
173
- const unindexable = (offset, why) => {
174
- if (why === "too big") return deltaTooLarge(offset);
212
+ /** An entry the indexer found no place for, as the push's refusal, `most` the largest it resolves. */
213
+ const unindexable = (offset, why, most = packObjectBytes) => {
214
+ if (why === "too big") return deltaTooLarge(offset, most);
175
215
  if (why === "too deep") return gitError("RESOURCE_EXHAUSTED", `The delta at ${offset} is in too long a chain`, {
176
216
  hint: deepHint,
177
217
  context: { reason: "too-large" }
@@ -226,7 +266,8 @@ const startUpload = (bucket, key, input) => Effect.map(startPut(bucket, key, pac
226
266
  */
227
267
  const receivePack = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
228
268
  const { store, bucket, listed, at, prune, receive } = input;
229
- if (receive.objects > receiveTableMost) return yield* Effect.fail(tooMany(receive.objects, receiveTableMost));
269
+ const most = input.objectsMost ?? receiveTableMost;
270
+ if (receive.objects > most) return yield* Effect.fail(tooMany(receive.objects, most));
230
271
  const past = segmentTooLarge(receive);
231
272
  if (past !== void 0) return yield* Effect.fail(past);
232
273
  const opened = yield* openQuarantine({
@@ -393,6 +434,12 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
393
434
  }, step && stepOf(step, carried?.state.links));
394
435
  const checked = carried?.checked ?? receiveChecked();
395
436
  const pointers = memory.pointers;
437
+ const listing = step === void 0 || step.largest !== void 0;
438
+ const largest = new LargestFiles(carried?.state.largest);
439
+ const limited = step?.largest === void 0 ? void 0 : listingLimits(step.largest.entryMost);
440
+ let inflated = 0;
441
+ const resolveMost = limited?.indexer.objectBytes ?? 16777216;
442
+ const refused = (offset, why) => unindexable(offset, why, resolveMost);
396
443
  const indexer = new PackIndexer({
397
444
  entryAt: (offset, before) => {
398
445
  if (state.stored === void 0 || state.sweepAt !== void 0 && offset !== state.sweepAt) return deferring;
@@ -406,7 +453,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
406
453
  },
407
454
  allot: memory.outside,
408
455
  held: (offset) => state.held?.get(offset)
409
- }, packIndexerLimits, new IndexerCache(memory.cache));
456
+ }, limited?.indexer ?? packIndexerLimits, new IndexerCache(memory.cache));
410
457
  const malformedDelta = (error) => malformedPack(error.message);
411
458
  /**
412
459
  * The pack's own object `oid`, as the table finds it by its hash: its slot, with a found row so
@@ -504,7 +551,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
504
551
  });
505
552
  return checkBytesFrom(oid, type, next, shallowCommit, boundaryCommit, graphed, 0);
506
553
  };
507
- const checkResolved = (oid, type, offset, resolved) => resolved.kind === "unindexable" ? Effect.fail(unindexable(offset, resolved.why)) : checkBytes(oid, type, resolved.object.bytes);
554
+ const checkResolved = (oid, type, offset, resolved) => resolved.kind === "unindexable" ? Effect.fail(refused(offset, resolved.why)) : checkBytes(oid, type, resolved.object.bytes);
508
555
  /** The object at `offset`, `oid` of `type`, checked as `checkBytes` says, or deferred for sweeps. */
509
556
  const check = (oid, type, offset) => {
510
557
  const resolved = indexer.resolve(offset);
@@ -514,13 +561,13 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
514
561
  /** A check that waited for the sweeps: the object at `offset`, its ID hashed again from its bytes. */
515
562
  const checkAt = Effect.fnUntraced(function* (offset, type) {
516
563
  const resolved = yield* stepEffect(indexer.resolve(offset));
517
- if (resolved.kind === "unindexable") return yield* Effect.fail(unindexable(offset, resolved.why));
564
+ if (resolved.kind === "unindexable") return yield* Effect.fail(refused(offset, resolved.why));
518
565
  const { bytes } = resolved.object;
519
566
  const checkedBytes = checkBytes(idOf(type, bytes), type, bytes);
520
567
  if (checkedBytes !== void 0) yield* checkedBytes;
521
568
  });
522
569
  const readPointerResolved = (oid, offset, resolved) => {
523
- if (resolved.kind === "unindexable") return Effect.fail(unindexable(offset, resolved.why));
570
+ if (resolved.kind === "unindexable") return Effect.fail(refused(offset, resolved.why));
524
571
  if (lfsPointerOfBlob(resolved.object.bytes) === void 0) return void 0;
525
572
  return pointers.add(oid, resolved.object.bytes);
526
573
  };
@@ -554,7 +601,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
554
601
  */
555
602
  const placed = (indexed, ended) => {
556
603
  const whole = state.large.get(indexed.offset);
557
- if (whole === void 0 || indexed.oid === void 0) return Effect.fail(unindexable(indexed.offset, indexed.why));
604
+ if (whole === void 0 || indexed.oid === void 0) return Effect.fail(refused(indexed.offset, indexed.why));
558
605
  const { kind, size } = whole;
559
606
  if (kind !== "blob") return Effect.fail(wholeTooLarge(indexed.offset, kind));
560
607
  return {
@@ -577,7 +624,10 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
577
624
  });
578
625
  const slot = recorded.add(object.oid, object.offset, type);
579
626
  if (chain !== void 0) recorded.setChain(slot, chain.links, chain.units, chain.base);
580
- if (type === "blob") return ReceivedPointers.mayHold(indexed.size) ? readPointer(object.oid, object.offset) : void 0;
627
+ if (type === "blob") {
628
+ largest.add(object.oid, indexed.size);
629
+ return ReceivedPointers.mayHold(indexed.size) ? readPointer(object.oid, object.offset) : void 0;
630
+ }
581
631
  return check(object.oid, type, object.offset);
582
632
  };
583
633
  const settleObject = (recorded, indexed, chain, until) => {
@@ -598,6 +648,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
598
648
  const indexed = given.kind === "unindexable" ? placed(given, ended) : given;
599
649
  if (Effect.isEffect(indexed)) return indexed;
600
650
  const { object } = indexed;
651
+ if (indexed.base !== void 0) inflated += indexed.size;
601
652
  const base = indexed.base === void 0 || ended.base?.kind !== "oid" ? void 0 : {
602
653
  oid: ended.base.oid,
603
654
  offset: indexed.base
@@ -623,7 +674,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
623
674
  const records = state.table;
624
675
  const base = ended.base?.kind === "oid" ? ended.base.oid : void 0;
625
676
  let slot = base === void 0 ? void 0 : recordOf(base);
626
- if (records !== void 0 && base !== void 0 && slot === void 0) return records.awaited(base, ended.offset) ? void 0 : yield* Effect.fail(unindexable(ended.offset, "base not before"));
677
+ if (records !== void 0 && base !== void 0 && slot === void 0) return records.awaited(base, ended.offset) ? void 0 : yield* Effect.fail(refused(ended.offset, "base not before"));
627
678
  const sibling = slot !== void 0 && slot === state.walked;
628
679
  state.walked = slot;
629
680
  for (let link = 0, until = ended.offset; records !== void 0 && slot !== void 0; link += 1) {
@@ -652,7 +703,8 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
652
703
  const sink = {
653
704
  begin: (header) => {
654
705
  state.count = header.count;
655
- if (state.count > receiveTableMost) return Effect.fail(tooMany(state.count, receiveTableMost));
706
+ const most = input.objectsMost ?? receiveTableMost;
707
+ if (state.count > most) return Effect.fail(tooMany(state.count, most));
656
708
  const sizing = room.take(receiveTableBytes(state.count)) ?? Effect.void;
657
709
  return Effect.map(sizing, () => {
658
710
  state.table = receiveTable(state.count);
@@ -672,9 +724,10 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
672
724
  indexer.data(bytes);
673
725
  },
674
726
  entryEnd: (ended) => {
727
+ inflated += ended.size;
675
728
  const done = entryEnded(ended);
676
729
  if (step === void 0) return done;
677
- const pauseAfter = () => ended.index + 1 < state.count && step.pause(ended.index + 1, ended.offset + ended.compressed) ? "pause" : void 0;
730
+ const pauseAfter = () => ended.index + 1 < state.count && step.pause(ended.index + 1, ended.offset + ended.compressed, inflated) ? "pause" : void 0;
678
731
  return done === void 0 ? pauseAfter() : Effect.map(done, pauseAfter);
679
732
  }
680
733
  };
@@ -707,6 +760,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
707
760
  linkedRows: [...state.linkedRows],
708
761
  parents: [...state.parents],
709
762
  large: [...state.large],
763
+ ...step?.largest !== void 0 && { largest: largest.finish() },
710
764
  ...ended && { joining: {
711
765
  leftOut: ended.leftOut,
712
766
  otherRuns: ended.otherRuns
@@ -731,7 +785,8 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
731
785
  const teed = { read: body.read.pipe(Effect.mapError(readFailure), Effect.tap((piece) => piece === void 0 || upload === void 0 ? Effect.void : upload.send(piece))) };
732
786
  const hasher = step === void 0 ? nativeSha1Hasher() : stagedHash(step.staged.checksum);
733
787
  const indexed = Effect.gen(function* () {
734
- const read = yield* readPackFrom(teed, hasher, sink, receiveLimits, meter, resume).pipe(Effect.mapError((error) => error instanceof DeltaError ? malformedDelta(error) : readFailure(error)), Effect.ensuring(body.cancel));
788
+ const limits = step === void 0 ? receiveLimits : limited?.reader ?? stepLimits;
789
+ const read = yield* readPackFrom(teed, hasher, sink, limits, meter, resume).pipe(Effect.mapError((error) => error instanceof DeltaError ? malformedDelta(error) : readFailure(error)), Effect.ensuring(body.cancel));
735
790
  if (upload !== void 0 && !("paused" in read)) yield* upload.finish(read.bytes);
736
791
  return read;
737
792
  }).pipe(Effect.onError(() => upload?.abort ?? Effect.void));
@@ -749,7 +804,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
749
804
  /** A deferred entry read again in a sweep: its header, its data, then its end as it streamed. */
750
805
  const sweepEntry = Effect.fnUntraced(function* (row) {
751
806
  const entry = yield* reader.blocks.entryAt(pack, row.offset, (each) => memory.outside(each.size));
752
- if (entry === "too big") return yield* Effect.fail(unindexable(row.offset, "too big"));
807
+ if (entry === "too big") return yield* Effect.fail(refused(row.offset, "too big"));
753
808
  const ended = {
754
809
  ...entry.entry,
755
810
  compressed: row.compressed,
@@ -873,7 +928,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
873
928
  if (slot === void 0 || state.table === void 0) return void 0;
874
929
  const offset = state.table.offsetAt(slot);
875
930
  const resolved = yield* stepEffect(indexer.resolve(offset));
876
- if (resolved.kind === "unindexable") return yield* Effect.fail(state.large.has(offset) ? checkedTooLarge(offset) : unindexable(offset, resolved.why));
931
+ if (resolved.kind === "unindexable") return yield* Effect.fail(state.large.has(offset) ? checkedTooLarge(offset) : refused(offset, resolved.why));
877
932
  const { kind, bytes } = resolved.object;
878
933
  if (idOf(kind, bytes) !== oid) return yield* Effect.fail(foundWrongly);
879
934
  return {
@@ -1001,6 +1056,9 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
1001
1056
  };
1002
1057
  const rooted = roots?.roots();
1003
1058
  if (rooted !== void 0) quarantine.roots = rooted;
1059
+ const kept = listing ? largest.finish() : void 0;
1060
+ if (kept?.largest !== void 0) quarantine.largest = kept.largest;
1061
+ if (kept?.largestPartial === true) quarantine.largestPartial = true;
1004
1062
  if (leftOut.length > 0) quarantine.cut = leftOut;
1005
1063
  if (named && state.linkedRows.size <= 64) quarantine.linked = {
1006
1064
  packs: [...state.linkedPacks],