@ref0/git 0.11.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 (262) hide show
  1. package/dist/access/private-refs.mjs +8 -7
  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 +14 -3
  28. package/dist/contracts/git.d.mts +41 -12
  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 +30 -23
  42. package/dist/contracts/result.mjs +24 -9
  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 +90 -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.d.mts +1 -0
  54. package/dist/core/access.mjs +34 -13
  55. package/dist/core/ancestry.d.mts +9 -0
  56. package/dist/core/ancestry.mjs +6 -6
  57. package/dist/core/asked.mjs +68 -0
  58. package/dist/core/call-names.mjs +1 -0
  59. package/dist/core/call-services.mjs +2 -1
  60. package/dist/core/events/deliver.d.mts +1 -0
  61. package/dist/core/events/deliver.mjs +15 -3
  62. package/dist/core/forks.mjs +42 -16
  63. package/dist/core/imports.mjs +156 -13
  64. package/dist/core/index-job.mjs +9 -6
  65. package/dist/core/job-view.mjs +8 -9
  66. package/dist/core/mirror-rows.mjs +19 -4
  67. package/dist/core/objects/commits.mjs +16 -6
  68. package/dist/core/objects/reading.mjs +17 -9
  69. package/dist/core/parts.d.mts +8 -2
  70. package/dist/core/parts.mjs +1 -4
  71. package/dist/core/purge.mjs +76 -6
  72. package/dist/core/push-decide.mjs +1 -1
  73. package/dist/core/push-files.d.mts +12 -0
  74. package/dist/core/push-files.mjs +225 -0
  75. package/dist/core/push-repo.d.mts +8 -0
  76. package/dist/core/push-repo.mjs +56 -0
  77. package/dist/core/push.d.mts +17 -0
  78. package/dist/core/push.mjs +107 -32
  79. package/dist/core/receipts.mjs +26 -10
  80. package/dist/core/ref-view.mjs +59 -5
  81. package/dist/core/refs.mjs +18 -10
  82. package/dist/core/registered-rows.mjs +7 -5
  83. package/dist/core/repack.mjs +16 -11
  84. package/dist/core/repo-info.mjs +16 -9
  85. package/dist/core/repos.mjs +30 -14
  86. package/dist/core/saved-caller-views.d.mts +18 -0
  87. package/dist/core/saved-caller-views.mjs +17 -4
  88. package/dist/core/saved-callers-public.d.mts +3 -3
  89. package/dist/core/saved-callers-public.mjs +3 -2
  90. package/dist/core/saved-callers.d.mts +7 -0
  91. package/dist/core/seam.mjs +2 -2
  92. package/dist/core/view.d.mts +6 -0
  93. package/dist/core/view.mjs +45 -12
  94. package/dist/core/work.mjs +47 -22
  95. package/dist/effect.d.mts +3 -1
  96. package/dist/effect.mjs +3 -1
  97. package/dist/engine/reads.mjs +13 -6
  98. package/dist/engine/walk.mjs +4 -4
  99. package/dist/event-streams/event-streams.d.mts +1 -1
  100. package/dist/event-streams/event-streams.mjs +1 -1
  101. package/dist/event-streams/stream.d.mts +1 -1
  102. package/dist/event-streams/stream.mjs +1 -1
  103. package/dist/extend.d.mts +4 -3
  104. package/dist/extend.mjs +3 -2
  105. package/dist/http/answers.mjs +4 -2
  106. package/dist/http/core-parts.mjs +64 -15
  107. package/dist/http/handler.mjs +2 -2
  108. package/dist/http/node.mjs +5 -4
  109. package/dist/http/parts.d.mts +1 -0
  110. package/dist/http/push-upload-job.mjs +503 -0
  111. package/dist/http/push-uploads.d.mts +1 -0
  112. package/dist/http/push-uploads.mjs +120 -59
  113. package/dist/http/upload-pack.mjs +7 -6
  114. package/dist/index.d.mts +23 -24
  115. package/dist/index.mjs +4 -7
  116. package/dist/lfs/base.d.mts +7 -3
  117. package/dist/lfs/base.mjs +2 -1
  118. package/dist/lfs/copy.d.mts +46 -0
  119. package/dist/lfs/copy.mjs +26 -0
  120. package/dist/lfs/layer.mjs +4 -2
  121. package/dist/lfs/locks.mjs +14 -9
  122. package/dist/lfs/objects.d.mts +6 -0
  123. package/dist/lfs/objects.mjs +95 -61
  124. package/dist/lfs/rows.d.mts +13 -0
  125. package/dist/lfs/service.d.mts +1 -7
  126. package/dist/lfs/service.mjs +1 -9
  127. package/dist/lfs/upload-most.mjs +5 -5
  128. package/dist/node.d.mts +2 -2
  129. package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
  130. package/dist/protocol/bytes/sha256.d.mts +32 -0
  131. package/dist/protocol/bytes/sha256.mjs +105 -49
  132. package/dist/protocol/wire/advertisement.mjs +9 -4
  133. package/dist/protocol/wire/lines.d.mts +4 -2
  134. package/dist/protocol/wire/lines.mjs +11 -5
  135. package/dist/protocol/wire/push-uploads.mjs +13 -1
  136. package/dist/protocol/wire/v2.mjs +2 -2
  137. package/dist/protocol.d.mts +3 -1
  138. package/dist/protocol.mjs +3 -1
  139. package/dist/queue/advance.mjs +1 -1
  140. package/dist/queue/calls.mjs +21 -1
  141. package/dist/queue/host.d.mts +1 -7
  142. package/dist/queue/host.mjs +1 -7
  143. package/dist/queue/layer.mjs +1 -1
  144. package/dist/queue/trim.mjs +1 -1
  145. package/dist/rest/blobs.d.mts +16 -8
  146. package/dist/rest/blobs.mjs +1 -1
  147. package/dist/rest/caller.d.mts +49 -9
  148. package/dist/rest/caller.mjs +1 -1
  149. package/dist/rest/client.d.mts +10 -3
  150. package/dist/rest/client.mjs +4 -0
  151. package/dist/rest/commits.d.mts +272 -239
  152. package/dist/rest/errors.d.mts +24 -4
  153. package/dist/rest/events.d.mts +9 -6
  154. package/dist/rest/events.mjs +1 -2
  155. package/dist/rest/files.d.mts +112 -100
  156. package/dist/rest/forks.d.mts +146 -122
  157. package/dist/rest/handler.mjs +4 -57
  158. package/dist/rest/handlers.d.mts +1 -1
  159. package/dist/rest/handlers.mjs +18 -4
  160. package/dist/rest/layer.mjs +10 -2
  161. package/dist/rest/me.d.mts +8 -4
  162. package/dist/rest/merges.d.mts +8 -4
  163. package/dist/rest/paths.mjs +1 -0
  164. package/dist/rest/queue.d.mts +292 -236
  165. package/dist/rest/refs.d.mts +98 -69
  166. package/dist/rest/repos.d.mts +133 -105
  167. package/dist/rest/tags.d.mts +100 -88
  168. package/dist/rest/tokens.d.mts +192 -168
  169. package/dist/rest/topics.d.mts +154 -134
  170. package/dist/rest/trees.d.mts +32 -16
  171. package/dist/rest/work.d.mts +467 -20
  172. package/dist/rest/work.mjs +8 -0
  173. package/dist/server/edge-node.d.mts +9 -13
  174. package/dist/server/edge-node.mjs +9 -12
  175. package/dist/server/git-layer.d.mts +1 -6
  176. package/dist/server/git-layer.mjs +2 -2
  177. package/dist/server/git-namespace.d.mts +4 -4
  178. package/dist/server/joined.d.mts +15 -22
  179. package/dist/server/joined.mjs +5 -29
  180. package/dist/server/lifecycle.mjs +107 -23
  181. package/dist/server/registry.mjs +9 -1
  182. package/dist/server/server.mjs +139 -216
  183. package/dist/storage/budget.mjs +2 -2
  184. package/dist/storage/clean-up.mjs +13 -10
  185. package/dist/storage/fetch.mjs +13 -8
  186. package/dist/storage/file-limits.mjs +24 -0
  187. package/dist/storage/index-build.d.mts +1 -0
  188. package/dist/storage/index-build.mjs +106 -62
  189. package/dist/storage/index-fetch.mjs +16 -3
  190. package/dist/storage/index-reach.mjs +33 -5
  191. package/dist/storage/index-remap.mjs +8 -1
  192. package/dist/storage/index-shallow.mjs +5 -3
  193. package/dist/storage/largest-files.mjs +48 -0
  194. package/dist/storage/lfs-pointers.mjs +10 -1
  195. package/dist/storage/loose.mjs +3 -1
  196. package/dist/storage/memory-budget.mjs +154 -8
  197. package/dist/storage/merge-cut.mjs +5 -4
  198. package/dist/storage/pack-reads.mjs +246 -34
  199. package/dist/storage/pack-receive.mjs +83 -25
  200. package/dist/storage/packs.mjs +37 -21
  201. package/dist/storage/prune-keep.mjs +203 -34
  202. package/dist/storage/prune-seen.mjs +11 -6
  203. package/dist/storage/prune-walk.mjs +219 -81
  204. package/dist/storage/prune.mjs +629 -196
  205. package/dist/storage/push-uploads.mjs +36 -12
  206. package/dist/storage/quarantine.mjs +9 -7
  207. package/dist/storage/ready.mjs +47 -19
  208. package/dist/storage/receive-bounds.mjs +29 -8
  209. package/dist/storage/receive-state.mjs +8 -0
  210. package/dist/storage/receive-steps.mjs +71 -18
  211. package/dist/storage/repack.d.mts +1 -1
  212. package/dist/storage/repack.mjs +1 -8
  213. package/dist/storage/rows.mjs +12 -1
  214. package/dist/storage/shallow.d.mts +1 -0
  215. package/dist/storage/shallow.mjs +26 -4
  216. package/dist/storage/stream-whole.mjs +5 -2
  217. package/dist/storage/visible.mjs +29 -1
  218. package/dist/storage/walk.mjs +2 -1
  219. package/dist/store/catalogue.mjs +1 -0
  220. package/dist/store/cursor-seal-namespace.d.mts +2 -0
  221. package/dist/store/cursor-seal-public.d.mts +5 -0
  222. package/dist/store/cursor-seal-public.mjs +5 -0
  223. package/dist/store/cursor-seal.d.mts +16 -2
  224. package/dist/store/cursor-seal.mjs +26 -14
  225. package/dist/store/errors.mjs +9 -1
  226. package/dist/store/records.d.mts +2 -0
  227. package/dist/store/records.mjs +9 -6
  228. package/dist/store/repo-record.d.mts +27 -0
  229. package/dist/store/repo-record.mjs +141 -4
  230. package/dist/store/scopes.mjs +10 -2
  231. package/dist/sync/bound.d.mts +2 -0
  232. package/dist/sync/bound.mjs +11 -2
  233. package/dist/sync/github.d.mts +6 -1
  234. package/dist/sync/github.mjs +63 -42
  235. package/dist/sync/http.mjs +36 -1
  236. package/dist/sync/import.mjs +4 -2
  237. package/dist/sync/layer.mjs +6 -2
  238. package/dist/sync/lfs-batch.mjs +119 -0
  239. package/dist/sync/lfs-copy.mjs +251 -0
  240. package/dist/sync/mirror.mjs +227 -147
  241. package/dist/sync/said.mjs +204 -0
  242. package/dist/sync/smart-http.mjs +4 -2
  243. package/dist/sync/step.mjs +33 -13
  244. package/dist/sync/tries.mjs +71 -24
  245. package/dist/sync.d.mts +2 -2
  246. package/dist/topics/advance.mjs +10 -3
  247. package/dist/topics/host.mjs +1 -19
  248. package/dist/topics/layer.mjs +1 -1
  249. package/package.json +3 -8
  250. package/dist/auth/bridge.mjs +0 -30
  251. package/dist/auth/helpers.d.mts +0 -17
  252. package/dist/core/purge.d.mts +0 -8
  253. package/dist/core/registered-rows.d.mts +0 -4
  254. package/dist/core/repack.d.mts +0 -11
  255. package/dist/http/handler.d.mts +0 -2
  256. package/dist/rest/handler.d.mts +0 -21
  257. package/dist/rest.d.mts +0 -2
  258. package/dist/rest.mjs +0 -1
  259. package/dist/server/registry.d.mts +0 -16
  260. package/dist/server/server.d.mts +0 -36
  261. package/dist/storage/repack-job.d.mts +0 -3
  262. package/dist/topics/host.d.mts +0 -7
@@ -1,9 +1,40 @@
1
+ import * as Schema from "effect/Schema";
2
+ import * as Result from "effect/Result";
3
+ import * as Hex from "effect/encoding/Hex";
1
4
  // src/protocol/bytes/sha256.ts
2
5
  /**
3
- * SHA-256, as FIPS 180-4 defines it, written a piece at a time: LFS checks an upload's bytes as
4
- * they stream past, and the runtime's `crypto.subtle` takes only bytes held whole.
6
+ * SHA-256, as FIPS 180-4 defines it, written a piece at a time, whose state is plain data: LFS
7
+ * checks an upload's bytes as they stream past, and a release asset's parts, each put in a request
8
+ * of its own, hash on from the state the part before left. The runtime's `crypto.subtle` takes only
9
+ * bytes held whole, and its `DigestStream` keeps its state where nothing can save it.
5
10
  */
6
- const rounds = Uint32Array.from([
11
+ const Word = /* @__PURE__ */ Schema.Number.check(Schema.isUint32());
12
+ /**
13
+ * A SHA-256's state between writes: its eight words, the bytes it took, and the bytes past its last
14
+ * whole 64-byte block, as lowercase hex, as many as `length` leaves past a block. Decode stored
15
+ * state through it, so a damaged one fails by name before a `Sha256` goes on from it.
16
+ */
17
+ const Sha256State = /* @__PURE__ */ Schema.Struct({
18
+ words: Schema.Tuple([
19
+ Word,
20
+ Word,
21
+ Word,
22
+ Word,
23
+ Word,
24
+ Word,
25
+ Word,
26
+ Word
27
+ ]),
28
+ length: Schema.Int.check(Schema.isBetween({
29
+ minimum: 0,
30
+ maximum: Number.MAX_SAFE_INTEGER / 8
31
+ })),
32
+ pending: Schema.String.check(Schema.isPattern(/^(?:[0-9a-f]{2}){0,63}$/))
33
+ }).check(Schema.makeFilter((state) => state.pending.length / 2 === state.length % 64 || "its pending bytes are not the bytes past its last whole block"));
34
+ /** A stored state, checked: a typed failure for one no `Sha256` could have written. */
35
+ const decodeSha256State = /* @__PURE__ */ Schema.decodeUnknownEffect(Sha256State);
36
+ /** The 64 round constants, signed 32-bit, as the rounds add them. */
37
+ const rounds = Int32Array.from([
7
38
  1116352408,
8
39
  1899447441,
9
40
  3049323471,
@@ -79,26 +110,51 @@ const initial = [
79
110
  528734635,
80
111
  1541459225
81
112
  ];
82
- const rotate = (word, by) => word >>> by | word << 32 - by;
83
113
  var Sha256 = class {
84
- #words = Uint32Array.from(initial);
114
+ #words;
85
115
  #block = /* @__PURE__ */ new Uint8Array(64);
86
- #schedule = /* @__PURE__ */ new Uint32Array(64);
87
- #filled = 0;
88
- #length = 0;
116
+ #blockView = new DataView(this.#block.buffer);
117
+ #schedule = /* @__PURE__ */ new Int32Array(64);
118
+ #filled;
119
+ #length;
120
+ /**
121
+ * A hash from the start, or going on from `state`, which it trusts: one `decodeSha256State`
122
+ * hasn't checked and that holds a block or more of pending bytes throws a `RangeError`.
123
+ */
124
+ constructor(state) {
125
+ const pending = state === void 0 ? /* @__PURE__ */ new Uint8Array(0) : Result.getOrThrow(Hex.decode(state.pending));
126
+ if (pending.length >= 64) throw new RangeError("a SHA-256's pending bytes fill a block");
127
+ this.#words = [...state?.words ?? initial];
128
+ this.#block.set(pending);
129
+ this.#filled = pending.length;
130
+ this.#length = state?.length ?? 0;
131
+ }
89
132
  /** Takes `bytes`, after every byte before them. */
90
133
  update(bytes) {
134
+ let at = 0;
91
135
  this.#length += bytes.length;
92
- for (let at = 0; at < bytes.length;) {
93
- const take = Math.min(64 - this.#filled, bytes.length - at);
94
- this.#block.set(bytes.subarray(at, at + take), this.#filled);
95
- this.#filled += take;
96
- at += take;
97
- if (this.#filled === 64) {
98
- this.#compress();
99
- this.#filled = 0;
100
- }
136
+ if (this.#filled > 0) {
137
+ at = Math.min(64 - this.#filled, bytes.length);
138
+ this.#block.set(bytes.subarray(0, at), this.#filled);
139
+ this.#filled += at;
140
+ if (this.#filled < 64) return;
141
+ this.#compress(this.#blockView, 0);
142
+ this.#filled = 0;
101
143
  }
144
+ if (at + 64 <= bytes.length) {
145
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
146
+ for (; at + 64 <= bytes.length; at += 64) this.#compress(view, at);
147
+ }
148
+ this.#block.set(bytes.subarray(at));
149
+ this.#filled = bytes.length - at;
150
+ }
151
+ /** The state to go on from, as plain data. */
152
+ state() {
153
+ return {
154
+ words: [...this.#words],
155
+ length: this.#length,
156
+ pending: Hex.encode(this.#block.subarray(0, this.#filled))
157
+ };
102
158
  }
103
159
  /** The digest of every byte taken, as 64 lowercase hex digits; the hash takes no more after it. */
104
160
  hex() {
@@ -106,51 +162,51 @@ var Sha256 = class {
106
162
  this.#block[this.#filled] = 128;
107
163
  this.#block.fill(0, this.#filled + 1);
108
164
  if (this.#filled >= 56) {
109
- this.#compress();
165
+ this.#compress(this.#blockView, 0);
110
166
  this.#block.fill(0);
111
167
  }
112
- const view = new DataView(this.#block.buffer);
113
- view.setUint32(56, Math.floor(bits / 2 ** 32));
114
- view.setUint32(60, bits >>> 0);
115
- this.#compress();
116
- return Array.from(this.#words, (word) => word.toString(16).padStart(8, "0")).join("");
168
+ this.#blockView.setUint32(56, Math.floor(bits / 2 ** 32));
169
+ this.#blockView.setUint32(60, bits >>> 0);
170
+ this.#compress(this.#blockView, 0);
171
+ return this.#words.map((word) => word.toString(16).padStart(8, "0")).join("");
117
172
  }
118
- #compress() {
173
+ /**
174
+ * Hashes the 64 bytes of `view` from `from` into the words, its working words in locals and its
175
+ * schedule in one reused array, each signed 32-bit until it's stored: an array of words read
176
+ * back through `?? 0` held it to about 55 MiB/s in Node.
177
+ */
178
+ #compress(view, from) {
119
179
  const w = this.#schedule;
120
- const view = new DataView(this.#block.buffer);
121
- for (let t = 0; t < 16; t += 1) w[t] = view.getUint32(t * 4);
180
+ for (let t = 0; t < 16; t += 1) w[t] = view.getInt32(from + t * 4);
122
181
  for (let t = 16; t < 64; t += 1) {
123
- const back2 = w[t - 2] ?? 0;
124
- const back15 = w[t - 15] ?? 0;
125
- const s0 = rotate(back15, 7) ^ rotate(back15, 18) ^ back15 >>> 3;
126
- const s1 = rotate(back2, 17) ^ rotate(back2, 19) ^ back2 >>> 10;
127
- w[t] = (w[t - 16] ?? 0) + s0 + (w[t - 7] ?? 0) + s1;
182
+ const back2 = w[t - 2];
183
+ const back15 = w[t - 15];
184
+ const s0 = (back15 >>> 7 | back15 << 25) ^ (back15 >>> 18 | back15 << 14) ^ back15 >>> 3;
185
+ const s1 = (back2 >>> 17 | back2 << 15) ^ (back2 >>> 19 | back2 << 13) ^ back2 >>> 10;
186
+ w[t] = w[t - 16] + s0 + w[t - 7] + s1 | 0;
128
187
  }
129
- let [a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0] = this.#words;
188
+ let [a, b, c, d, e, f, g, h] = this.#words;
130
189
  for (let t = 0; t < 64; t += 1) {
131
- const s1 = rotate(e, 6) ^ rotate(e, 11) ^ rotate(e, 25);
132
- const choice = e & f ^ ~e & g;
133
- const first = h + s1 + choice + (rounds[t] ?? 0) + (w[t] ?? 0) >>> 0;
134
- const second = (rotate(a, 2) ^ rotate(a, 13) ^ rotate(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
190
+ const s1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7);
191
+ const first = h + s1 + (e & f ^ ~e & g) + rounds[t] + w[t] | 0;
192
+ const second = ((a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10)) + (a & b ^ a & c ^ b & c) | 0;
135
193
  h = g;
136
194
  g = f;
137
195
  f = e;
138
- e = d + first >>> 0;
196
+ e = d + first | 0;
139
197
  d = c;
140
198
  c = b;
141
199
  b = a;
142
- a = first + second >>> 0;
200
+ a = first + second | 0;
143
201
  }
144
- for (const [at, word] of [
145
- a,
146
- b,
147
- c,
148
- d,
149
- e,
150
- f,
151
- g,
152
- h
153
- ].entries()) this.#words[at] = (this.#words[at] ?? 0) + word;
202
+ this.#words[0] = this.#words[0] + a >>> 0;
203
+ this.#words[1] = this.#words[1] + b >>> 0;
204
+ this.#words[2] = this.#words[2] + c >>> 0;
205
+ this.#words[3] = this.#words[3] + d >>> 0;
206
+ this.#words[4] = this.#words[4] + e >>> 0;
207
+ this.#words[5] = this.#words[5] + f >>> 0;
208
+ this.#words[6] = this.#words[6] + g >>> 0;
209
+ this.#words[7] = this.#words[7] + h >>> 0;
154
210
  }
155
211
  };
156
- export { Sha256 };
212
+ export { Sha256, Sha256State, decodeSha256State };
@@ -83,16 +83,17 @@ const receivePackCapabilities = (agent, offers = {}) => [
83
83
  ];
84
84
  /**
85
85
  * `info/refs` for `service` in v0, as `encodeAdvertisement` writes it, with none of the refs under
86
- * `table`'s prefixes: a server's own, its registered prefixes among them.
86
+ * `table`'s prefixes: a server's own, its registered prefixes among them. `roots` are upload-pack's
87
+ * `shallow` lines, as `advertisementPages` writes them.
87
88
  */
88
- const advertisementOf = /* @__PURE__ */ Effect.fnUntraced(function* (service, served, capabilities, table) {
89
+ const advertisementOf = /* @__PURE__ */ Effect.fnUntraced(function* (service, served, capabilities, table, roots = []) {
89
90
  const head = headOf(served);
90
91
  const lines = advertisementPages(service, service === "git-upload-pack" && head !== void 0 ? { headRef: head } : {}, capabilities, table);
91
92
  const refs = served.refs.toSorted((a, b) => byName(a.name, b.name));
92
93
  return joinedBytes([
93
94
  yield* lines.start,
94
95
  yield* lines.page(refs),
95
- yield* lines.end
96
+ yield* lines.end(roots)
96
97
  ]);
97
98
  });
98
99
  /**
@@ -118,6 +119,10 @@ const onLines = (what, texts) => {
118
119
  * `info/refs` for `service` in v0, a page at a time: the service line, its flush and `HEAD`, then
119
120
  * each page's refs, `capabilities` on the first line written, each tag's peel after it for
120
121
  * `git-upload-pack`, and a ref-less line for the capabilities when no ref came, then the flush.
122
+ * Before the flush, `git-upload-pack`'s writes a `shallow` line for each root `end` is given, as
123
+ * Git's own upload-pack writes a shallow repo's grafts: a v0 fetch that asks for no depth has no
124
+ * other place to be told where the history stops, and Git's client writes them to a clone's
125
+ * shallow file.
121
126
  */
122
127
  const advertisementPages = (service, listed, capabilities, table) => {
123
128
  const uploading = service === "git-upload-pack";
@@ -139,7 +144,7 @@ const advertisementPages = (service, listed, capabilities, table) => {
139
144
  const shown = refs.filter((ref) => listsRef(table, ref.name, []));
140
145
  return Effect.andThen(onLines("advertisement", shown.map((ref) => ref.name)), () => textLines(lines(shown), false));
141
146
  },
142
- end: Effect.suspend(() => textLines(first ? [`${zero} capabilities^{}\0${caps}\n`] : [], true))
147
+ end: (roots) => Effect.suspend(() => textLines([...first ? [`${zero} capabilities^{}\0${caps}\n`] : [], ...uploading ? roots.map((root) => `shallow ${root}\n`) : []], true))
143
148
  };
144
149
  };
145
150
  /**
@@ -12,11 +12,13 @@ export declare const encodeErr: (message: string) => Effect.Effect<Uint8Array<Ar
12
12
  * A prefix whose refs are Git's own: only `owner`, the registration that registered it or an import,
13
13
  * moves one, and no push or API call does. v0 never advertises them. v2's `ls-refs`, and
14
14
  * `refs.list`, list one only for an asked prefix under it when `underPrefix` is `listed`, and never
15
- * when it's `hidden`, nor does a fetch reach a commit only a `hidden` one holds.
15
+ * when it's `hidden`, nor does a fetch reach a commit only a `hidden` one holds. An `owned` one is
16
+ * the owner's alone: no listing, count, fetch, fork or `refs.get` shows it to anyone else, a caller
17
+ * who reads every private pattern included.
16
18
  */
17
19
  export interface HiddenRefs {
18
20
  readonly owner: RefOwner;
19
- readonly underPrefix: 'listed' | 'hidden';
21
+ readonly underPrefix: 'listed' | 'hidden' | 'owned';
20
22
  /** Who moves them, as a refusal says it. */
21
23
  readonly mover: string;
22
24
  }
@@ -95,13 +95,19 @@ const gitsOwnRefs = [{
95
95
  }];
96
96
  /**
97
97
  * A registered prefix's row, as the registry adds it for a registration with `refs`: listed for a prefix
98
- * under it, and moved only by the registration, which a refusal names.
98
+ * under it, or `owned`, the registration's alone, when it registered `refsReadBy: 'owner'`, and moved only by
99
+ * the registration, which a refusal names.
99
100
  */
100
- const registeredRow = (owner) => ({
101
+ const registeredRow = (owner, owned = false) => ({
101
102
  owner,
102
- underPrefix: "listed",
103
+ underPrefix: owned ? "owned" : "listed",
103
104
  mover: `the ${owner.owner} feature`
104
105
  });
106
+ /**
107
+ * Whether `name`, or every ref under the prefix `name` when it ends in `/`, is under an `owned`
108
+ * prefix: one no caller's view sees, which only its owner's, `viewOf`'s, adds back.
109
+ */
110
+ const ownedAway = (table, name) => hiddenUnder(table, name)?.underPrefix === "owned";
105
111
  /** `table`'s hidden prefix `name` is under, if any. */
106
112
  const hiddenUnder = (table, name) => table.find((hidden) => name.startsWith(hidden.owner.prefix));
107
113
  /**
@@ -111,7 +117,7 @@ const hiddenUnder = (table, name) => table.find((hidden) => name.startsWith(hidd
111
117
  const gitsOwnMove = (table, as, ref) => as !== void 0 && hiddenUnder(table, ref)?.owner === as;
112
118
  /**
113
119
  * Whether a host's own listing for `prefix` shows `name`, as `refs.list` does: a ref under a
114
- * hidden prefix only for a prefix under it, of either kind, since the host's code asks for it.
120
+ * hidden prefix only for a prefix under it, of any kind, since the host's code asks for it.
115
121
  */
116
122
  const hostLists = (table, name, prefix) => {
117
123
  const hidden = hiddenUnder(table, name);
@@ -129,4 +135,4 @@ const listsRef = (table, name, prefixes) => {
129
135
  if (prefixes.length === 0) return hidden === void 0;
130
136
  return prefixes.some((prefix) => name.startsWith(prefix) && (hidden === void 0 || hidden.underPrefix === "listed" && prefix.startsWith(hidden.owner.prefix)));
131
137
  };
132
- export { byName, decoded, encodeErr, fetchReaches, gitsOwnMove, gitsOwnRefs, hiddenUnder, hostLists, importOwner, isWord, listsRef, readSection, refusedText, registeredRow, textLines, unwritable };
138
+ export { byName, decoded, encodeErr, fetchReaches, gitsOwnMove, gitsOwnRefs, hiddenUnder, hostLists, importOwner, isWord, listsRef, ownedAway, readSection, refusedText, registeredRow, textLines, unwritable };
@@ -17,4 +17,16 @@ const pushUploadAbove = (capabilities) => {
17
17
  const above = Number(raw);
18
18
  return Number.isSafeInteger(above) ? above : void 0;
19
19
  };
20
- export { pushUploadAbove, pushUploadCapability, pushUploadOffer };
20
+ /** `seconds` within `retryAfterLeast` and `retryAfterMost`, whole. */
21
+ const retryAfterOf = (seconds) => Math.min(Math.max(Math.ceil(seconds), 1), 10);
22
+ /**
23
+ * The least time a claimed upload keeps before its row's `removeAt`, set at begin a day past its
24
+ * links' hour: complete claims an upload only this long or more before it, so upkeep leaves its
25
+ * push at least this long to be received. It's also how long a client sends complete again while
26
+ * it answers 202, counted from its first, so a client never gives up on an upload upkeep could
27
+ * delete sooner; the server may still land it after. At `removeAt` upkeep deletes the upload's
28
+ * rows, its answer with them, so a step still running then finds them gone, stops, and keeps no
29
+ * report.
30
+ */
31
+ const completeMost = 432e5;
32
+ export { completeMost, pushUploadAbove, pushUploadCapability, pushUploadOffer, retryAfterOf };
@@ -127,7 +127,7 @@ const lsRefsOf = /* @__PURE__ */ Effect.fnUntraced(function* (served, asked, tab
127
127
  return joinedBytes([
128
128
  yield* lines.start,
129
129
  yield* lines.page(refs),
130
- yield* lines.end
130
+ yield* lines.end([])
131
131
  ]);
132
132
  });
133
133
  /**
@@ -151,7 +151,7 @@ const lsRefsPages = (listed, asked, table) => {
151
151
  return {
152
152
  start: Effect.suspend(() => lines(served.head === void 0 ? [] : [served.head], () => headLines(served, asked))),
153
153
  page: (refs) => Effect.suspend(() => lines(refs.map((ref) => ref.name), () => refs.filter((ref) => listsRef(table, ref.name, asked.prefixes)).map((ref) => `${ref.oid} ${ref.name}${peeled(ref.peeled)}\n`))),
154
- end: textLines([], true)
154
+ end: () => textLines([], true)
155
155
  };
156
156
  };
157
157
  /**
@@ -5,6 +5,8 @@ import { WireDecodeError, WireEncodeError } from "./protocol/bytes/errors.mjs";
5
5
  import { InflateError, Inflated, MemberInflater, inflaterBytes, memberInflater } from "./protocol/bytes/inflate.mjs";
6
6
  import { joinedBytes } from "./protocol/bytes/joined.mjs";
7
7
  import { Sha1, Sha1State, decodeSha1State, sha1Of } from "./protocol/bytes/sha1.mjs";
8
+ import { Sha256, Sha256State, decodeSha256State } from "./protocol/bytes/sha256.mjs";
9
+ import { Sha256Hasher, nativeSha256Hasher } from "./protocol/bytes/sha256-hasher.mjs";
8
10
  import { DiffEntry, DiffStatus, parseDiffRaw } from "./protocol/diff/diff-raw.mjs";
9
11
  import { DiffError, DiffLimits, DiffRead, defaultDiffLimits } from "./protocol/diff/read.mjs";
10
12
  import { LineCount, LineCounter, PairedChanges, WireDiffInput, countLines, pairRenames, walkTrees } from "./protocol/diff/tree-diff.mjs";
@@ -29,4 +31,4 @@ import { AckMode, FetchAnswerHead, FetchAnswerStart, FetchRound, encodeAcknowled
29
31
  import { PushStart, PushStartRead, RefCommand, encodePushStart, maxPushOptionBytes, maxPushOptions, pushOptionsRefusal, readPushStart, withCommands } from "./protocol/wire/receive-pack.mjs";
30
32
  import { PushReport, PushReportRead, RefResult, ReportFormat, encodePushReport, readPushReport } from "./protocol/wire/report-status.mjs";
31
33
  import { LsRefs, LsRefsAnswer, V2Advertised, V2Command, V2Request, encodeLsRefs, encodeV2Capabilities, encodeV2Request, lsRefsArguments, maxPrefixes, readLsRefs, readLsRefsAnswer, readV2Capabilities, readV2Request, v2Capabilities } from "./protocol/wire/v2.mjs";
32
- export { AckMode, AdvertisedRef, type Band, BufferError, BufferMeter, type ByteEntry, DeflateError, DeltaError, DeltaFault, type DeltaInput, type DeltaOutput, type DiffEntry, DiffError, type DiffLimits, type DiffRead, type DiffStatus, type FetchAnswerHead, type FetchAnswerStart, FetchRound, type GitService, type IndexedEntry, type IndexedObject, type IndexerLimits, type IndexerReads, InflateError, type Inflated, type LineCount, type LineCounter, LsRefs, LsRefsAnswer, type MemberDeflater, type MemberInflater, type PackBase, type PackCopied, type PackCopy, type PackDigest, type PackEnd, type PackEntry, type PackEntryAt, type PackEntryEnd, type PackEntryKind, PackError, PackFault, type PackHasher, type PackIndex, PackIndexError, PackIndexFault, PackIndexer, type PackLimits, type PackObject, type PackObjects, type PackOutput, type PackPart, PackParts, type PackPaused, type PackRead, type PackResume, type PackReverse, type PackSink, type PackSource, type PackStream, type PackStreamOptions, PackTransportError, PackWriteError, PackWriteFault, type PackWriteLimits, type PackWritten, type PairedChanges, type PausingSink, type Pkt, type PktRead, PushReport, type PushReportRead, PushStart, type PushStartRead, type RawObject, RefCommand, RefResult, type ReportFormat, type Resolved, type ResolvedObject, ServedRefs, Sha1, Sha1State, type SourceRefs, type Step, type TreeItem, type UnindexableWhy, V2Advertised, V2Command, V2Request, WireDecodeError, type WireDiffInput, WireEncodeError, advertisedHead, advertisedRefs, advertisedSource, allotOrFail, allotScoped, appliedDelta, applyDelta, boundedSource, capacityOf, compareEntries, copyPieceBytes, countLines, crc32Start, crc32Update, decodeCommit, decodeSha1State, decodeTag, defaultDiffLimits, deflateWhole, deflatedMost, deflaterBytes, delimPkt, emptyTree, encodeAcknowledgments, encodeAdvertisement, encodeCommit, encodeErr, encodeFetchRound, encodeLsRefs, encodePkt, encodePushReport, encodePushStart, encodeTag, encodeTextPkt, encodeTree, encodeV0Acks, encodeV2Capabilities, encodeV2Request, entryHeader, fetchAnswerEnd, fetchAnswerStart, filterSpec, flushPkt, headOf, inflaterBytes, isObjectType, joinedBytes, lsRefsArguments, maxBandData, maxPktData, maxPrefixes, maxPushOptionBytes, maxPushOptions, maxSmallBandData, memberDeflater, memberInflater, notOurRef, objectId, objectTypes, onBand, onRoundBand, packEnd, packIndexBytes, packObjectBytes, packPageObjects, packParts, packPieceBytes, packReadBytes, packReverseBytes, packStream, packfileLine, pairRenames, parseDiffRaw, parseFilter, parseTreeBytes, pktText, pushOptionsRefusal, readEntryAt, readEntryHeader, readFetch, readFetchRound, readLsRefs, readLsRefsAnswer, readPack, readPackFrom, readPackIndex, readPackReverse, readPkt, readPushReport, readPushStart, readV0FetchAnswer, readV2Capabilities, readV2FetchAnswer, readV2Request, receivePackCapabilities, sha1Of, stepEffect, subjectOf, treeMatches, uploadPackCapabilities, v2Capabilities, walkTrees, wholeObjectBytes, withCommands, writePack, writePackIndex };
34
+ export { AckMode, AdvertisedRef, type Band, BufferError, BufferMeter, type ByteEntry, DeflateError, DeltaError, DeltaFault, type DeltaInput, type DeltaOutput, type DiffEntry, DiffError, type DiffLimits, type DiffRead, type DiffStatus, type FetchAnswerHead, type FetchAnswerStart, FetchRound, type GitService, type IndexedEntry, type IndexedObject, type IndexerLimits, type IndexerReads, InflateError, type Inflated, type LineCount, type LineCounter, LsRefs, LsRefsAnswer, type MemberDeflater, type MemberInflater, type PackBase, type PackCopied, type PackCopy, type PackDigest, type PackEnd, type PackEntry, type PackEntryAt, type PackEntryEnd, type PackEntryKind, PackError, PackFault, type PackHasher, type PackIndex, PackIndexError, PackIndexFault, PackIndexer, type PackLimits, type PackObject, type PackObjects, type PackOutput, type PackPart, PackParts, type PackPaused, type PackRead, type PackResume, type PackReverse, type PackSink, type PackSource, type PackStream, type PackStreamOptions, PackTransportError, PackWriteError, PackWriteFault, type PackWriteLimits, type PackWritten, type PairedChanges, type PausingSink, type Pkt, type PktRead, PushReport, type PushReportRead, PushStart, type PushStartRead, type RawObject, RefCommand, RefResult, type ReportFormat, type Resolved, type ResolvedObject, ServedRefs, Sha1, Sha1State, Sha256, type Sha256Hasher, Sha256State, type SourceRefs, type Step, type TreeItem, type UnindexableWhy, V2Advertised, V2Command, V2Request, WireDecodeError, type WireDiffInput, WireEncodeError, advertisedHead, advertisedRefs, advertisedSource, allotOrFail, allotScoped, appliedDelta, applyDelta, boundedSource, capacityOf, compareEntries, copyPieceBytes, countLines, crc32Start, crc32Update, decodeCommit, decodeSha1State, decodeSha256State, decodeTag, defaultDiffLimits, deflateWhole, deflatedMost, deflaterBytes, delimPkt, emptyTree, encodeAcknowledgments, encodeAdvertisement, encodeCommit, encodeErr, encodeFetchRound, encodeLsRefs, encodePkt, encodePushReport, encodePushStart, encodeTag, encodeTextPkt, encodeTree, encodeV0Acks, encodeV2Capabilities, encodeV2Request, entryHeader, fetchAnswerEnd, fetchAnswerStart, filterSpec, flushPkt, headOf, inflaterBytes, isObjectType, joinedBytes, lsRefsArguments, maxBandData, maxPktData, maxPrefixes, maxPushOptionBytes, maxPushOptions, maxSmallBandData, memberDeflater, memberInflater, nativeSha256Hasher, notOurRef, objectId, objectTypes, onBand, onRoundBand, packEnd, packIndexBytes, packObjectBytes, packPageObjects, packParts, packPieceBytes, packReadBytes, packReverseBytes, packStream, packfileLine, pairRenames, parseDiffRaw, parseFilter, parseTreeBytes, pktText, pushOptionsRefusal, readEntryAt, readEntryHeader, readFetch, readFetchRound, readLsRefs, readLsRefsAnswer, readPack, readPackFrom, readPackIndex, readPackReverse, readPkt, readPushReport, readPushStart, readV0FetchAnswer, readV2Capabilities, readV2FetchAnswer, readV2Request, receivePackCapabilities, sha1Of, stepEffect, subjectOf, treeMatches, uploadPackCapabilities, v2Capabilities, walkTrees, wholeObjectBytes, withCommands, writePack, writePackIndex };
package/dist/protocol.mjs CHANGED
@@ -5,6 +5,8 @@ import { WireDecodeError, WireEncodeError } from "./protocol/bytes/errors.mjs";
5
5
  import { InflateError, inflaterBytes, memberInflater } from "./protocol/bytes/inflate.mjs";
6
6
  import { joinedBytes } from "./protocol/bytes/joined.mjs";
7
7
  import { Sha1, Sha1State, decodeSha1State, sha1Of } from "./protocol/bytes/sha1.mjs";
8
+ import { Sha256, Sha256State, decodeSha256State } from "./protocol/bytes/sha256.mjs";
9
+ import { nativeSha256Hasher } from "./protocol/bytes/sha256-hasher.mjs";
8
10
  import { parseDiffRaw } from "./protocol/diff/diff-raw.mjs";
9
11
  import { DiffError, defaultDiffLimits } from "./protocol/diff/read.mjs";
10
12
  import { countLines, pairRenames, walkTrees } from "./protocol/diff/tree-diff.mjs";
@@ -29,4 +31,4 @@ import { AckMode, FetchRound, encodeAcknowledgments, encodeFetchRound, encodeV0A
29
31
  import { PushStart, RefCommand, encodePushStart, maxPushOptionBytes, maxPushOptions, pushOptionsRefusal, readPushStart, withCommands } from "./protocol/wire/receive-pack.mjs";
30
32
  import { PushReport, RefResult, encodePushReport, readPushReport } from "./protocol/wire/report-status.mjs";
31
33
  import { LsRefs, LsRefsAnswer, V2Advertised, V2Command, V2Request, encodeLsRefs, encodeV2Capabilities, encodeV2Request, lsRefsArguments, maxPrefixes, readLsRefs, readLsRefsAnswer, readV2Capabilities, readV2Request, v2Capabilities } from "./protocol/wire/v2.mjs";
32
- export { AckMode, AdvertisedRef, BufferError, BufferMeter, DeflateError, DeltaError, DeltaFault, DiffError, FetchRound, InflateError, LsRefs, LsRefsAnswer, PackError, PackFault, PackIndexError, PackIndexFault, PackIndexer, PackParts, PackTransportError, PackWriteError, PackWriteFault, PushReport, PushStart, RefCommand, RefResult, ServedRefs, Sha1, Sha1State, V2Advertised, V2Command, V2Request, WireDecodeError, WireEncodeError, advertisedHead, advertisedRefs, advertisedSource, allotOrFail, allotScoped, appliedDelta, applyDelta, boundedSource, capacityOf, compareEntries, copyPieceBytes, countLines, crc32Start, crc32Update, decodeCommit, decodeSha1State, decodeTag, defaultDiffLimits, deflateWhole, deflatedMost, deflaterBytes, delimPkt, emptyTree, encodeAcknowledgments, encodeAdvertisement, encodeCommit, encodeErr, encodeFetchRound, encodeLsRefs, encodePkt, encodePushReport, encodePushStart, encodeTag, encodeTextPkt, encodeTree, encodeV0Acks, encodeV2Capabilities, encodeV2Request, entryHeader, fetchAnswerEnd, fetchAnswerStart, filterSpec, flushPkt, headOf, inflaterBytes, isObjectType, joinedBytes, lsRefsArguments, maxBandData, maxPktData, maxPrefixes, maxPushOptionBytes, maxPushOptions, maxSmallBandData, memberDeflater, memberInflater, notOurRef, objectId, objectTypes, onBand, onRoundBand, packEnd, packIndexBytes, packObjectBytes, packPageObjects, packParts, packPieceBytes, packReadBytes, packReverseBytes, packStream, packfileLine, pairRenames, parseDiffRaw, parseFilter, parseTreeBytes, pktText, pushOptionsRefusal, readEntryAt, readEntryHeader, readFetch, readFetchRound, readLsRefs, readLsRefsAnswer, readPack, readPackFrom, readPackIndex, readPackReverse, readPkt, readPushReport, readPushStart, readV0FetchAnswer, readV2Capabilities, readV2FetchAnswer, readV2Request, receivePackCapabilities, sha1Of, stepEffect, subjectOf, treeMatches, uploadPackCapabilities, v2Capabilities, walkTrees, wholeObjectBytes, withCommands, writePack, writePackIndex };
34
+ export { AckMode, AdvertisedRef, BufferError, BufferMeter, DeflateError, DeltaError, DeltaFault, DiffError, FetchRound, InflateError, LsRefs, LsRefsAnswer, PackError, PackFault, PackIndexError, PackIndexFault, PackIndexer, PackParts, PackTransportError, PackWriteError, PackWriteFault, PushReport, PushStart, RefCommand, RefResult, ServedRefs, Sha1, Sha1State, Sha256, Sha256State, V2Advertised, V2Command, V2Request, WireDecodeError, WireEncodeError, advertisedHead, advertisedRefs, advertisedSource, allotOrFail, allotScoped, appliedDelta, applyDelta, boundedSource, capacityOf, compareEntries, copyPieceBytes, countLines, crc32Start, crc32Update, decodeCommit, decodeSha1State, decodeSha256State, decodeTag, defaultDiffLimits, deflateWhole, deflatedMost, deflaterBytes, delimPkt, emptyTree, encodeAcknowledgments, encodeAdvertisement, encodeCommit, encodeErr, encodeFetchRound, encodeLsRefs, encodePkt, encodePushReport, encodePushStart, encodeTag, encodeTextPkt, encodeTree, encodeV0Acks, encodeV2Capabilities, encodeV2Request, entryHeader, fetchAnswerEnd, fetchAnswerStart, filterSpec, flushPkt, headOf, inflaterBytes, isObjectType, joinedBytes, lsRefsArguments, maxBandData, maxPktData, maxPrefixes, maxPushOptionBytes, maxPushOptions, maxSmallBandData, memberDeflater, memberInflater, nativeSha256Hasher, notOurRef, objectId, objectTypes, onBand, onRoundBand, packEnd, packIndexBytes, packObjectBytes, packPageObjects, packParts, packPieceBytes, packReadBytes, packReverseBytes, packStream, packfileLine, pairRenames, parseDiffRaw, parseFilter, parseTreeBytes, pktText, pushOptionsRefusal, readEntryAt, readEntryHeader, readFetch, readFetchRound, readLsRefs, readLsRefsAnswer, readPack, readPackFrom, readPackIndex, readPackReverse, readPkt, readPushReport, readPushStart, readV0FetchAnswer, readV2Capabilities, readV2FetchAnswer, readV2Request, receivePackCapabilities, sha1Of, stepEffect, subjectOf, treeMatches, uploadPackCapabilities, v2Capabilities, walkTrees, wholeObjectBytes, withCommands, writePack, writePackIndex };
@@ -1266,7 +1266,7 @@ const TimeoutJob = /* @__PURE__ */ Job.make(timeoutName, {
1266
1266
  retry: queueJobRetry
1267
1267
  });
1268
1268
  /**
1269
- * The queue's jobs over `host`, which `createGitServer` registers beside its own, each passing its
1269
+ * The queue's jobs over `host`, which `MergeQueue.layer` registers beside Git's own, each passing its
1270
1270
  * last failure on to `onFailure` once it holds its target.
1271
1271
  */
1272
1272
  const queueJobs = (host, onFailure) => {
@@ -149,6 +149,26 @@ const openKeyedQueue = /* @__PURE__ */ Effect.fnUntraced(function* (answer, host
149
149
  return yield* contended();
150
150
  });
151
151
  /**
152
+ * Who added queue entry `entry`, as its row saved them at the add, read from the server's store
153
+ * for `SavedCallers.queueEntry`: a host's call for its own jobs, so no caller is asked. `undefined`
154
+ * unless the entry is still in the queue, waiting, checking or held: an ID no queue made, an entry
155
+ * or repo that's gone, and one that merged, failed or was removed name no one to act for.
156
+ */
157
+ const entryAdderOf = /* @__PURE__ */ Effect.fnUntraced(function* (entry) {
158
+ const { collection, schema, what } = idKinds.e;
159
+ const parts = queueIdParts("e", entry);
160
+ if (parts === void 0) return void 0;
161
+ const { store } = yield* CoreParts;
162
+ const { record, snapshot } = yield* readRecord(store, parts.internalId, [{
163
+ collection,
164
+ id: entry
165
+ }]);
166
+ const [found] = snapshot.results[1] ?? [];
167
+ if (record === void 0 || record.deleted === true || found === void 0) return void 0;
168
+ const row = yield* decodeRow(schema, found, `The ${what} '${entry}'`);
169
+ return row.state === "waiting" || row.state === "checking" || row.state === "held" ? row : void 0;
170
+ });
171
+ /**
152
172
  * The repo, row and queue an entry's, candidate's or hold's ID names, once `caller` may do the
153
173
  * operation on its repo. An ID whose repo the caller can't read is as one that names nothing.
154
174
  */
@@ -1308,4 +1328,4 @@ const holdsIn = (repo, fresh, ids, open) => ids.flatMap((id) => {
1308
1328
  });
1309
1329
  /** `queue-full` once a target holds `queueLimits.holds` open holds, its own and its keys'. */
1310
1330
  const holdsLeft = (row) => openHolds(row).length >= queueLimits.holds ? queueFull("holds", queueLimits.holds) : Effect.void;
1311
- export { addAdmitted, admitEntry, checkOwned, openCandidate, openEntry, openQueue, pinnedEvent, queueCalls, restartTarget };
1331
+ export { addAdmitted, admitEntry, checkOwned, entryAdderOf, openCandidate, openEntry, openQueue, pinnedEvent, queueCalls, restartTarget };
@@ -8,7 +8,7 @@ import * as Effect from "effect/Effect";
8
8
  import { Records } from "@ref0/infra";
9
9
  import * as Context from "effect/Context";
10
10
  /**
11
- * What the queue runs over, which `createGitServer` makes: the server's services, which its jobs
11
+ * What the queue runs over, which `MergeQueue.layer` makes: the server's services, which its jobs
12
12
  * run over, as its pushes' queueing does, and the queue each repo has, if any.
13
13
  */
14
14
  export interface QueueHost {
@@ -36,10 +36,4 @@ declare const QueueBase_base: Context.ServiceClass<QueueBase, "@ref0/git/queue/Q
36
36
  * queue's host for `git push -o queue` and the checks the seal runs. No entry point names it.
37
37
  */
38
38
  export declare class QueueBase extends /* @__PURE__ */ QueueBase_base {}
39
- /**
40
- * One queue every repo has, as `createGitServer`'s `queue` takes it, checked now as `checkQueue`
41
- * checks it, so a bad one throws its `TypeError` where the host writes it. A bridge: it goes with
42
- * `createGitServer` in 2c-3b.
43
- */
44
- export declare const mergeQueue: (options: MergeQueueOptions) => MergeQueueOptions;
45
39
  export {};
@@ -65,12 +65,6 @@ const checkQueue = (options) => {
65
65
  checkWhole("entryCommits", entryCommits, queueLimits.entryCommitsMost);
66
66
  return options;
67
67
  };
68
- /**
69
- * One queue every repo has, as `createGitServer`'s `queue` takes it, checked now as `checkQueue`
70
- * checks it, so a bad one throws its `TypeError` where the host writes it. A bridge: it goes with
71
- * `createGitServer` in 2c-3b.
72
- */
73
- const mergeQueue = (options) => checkQueue(options);
74
68
  /** The `keys` every repo's queue has: `undefined` for a queue per repo, whose repos may differ. */
75
69
  const queueKeysOf = (options) => Predicate.isFunction(options) ? void 0 : options.keys;
76
70
  /**
@@ -91,4 +85,4 @@ const queueOptions = (options) => {
91
85
  catch: (cause) => gitError("UNAVAILABLE", "The server could not find this repo’s merge queue", { cause })
92
86
  });
93
87
  };
94
- export { QueueBase, QueueInternals, checkQueue, checkTimeout, isTimeout, mergeQueue, queueKeysOf, queueOptions };
88
+ export { QueueBase, QueueInternals, checkQueue, checkTimeout, isTimeout, queueKeysOf, queueOptions };
@@ -1,7 +1,7 @@
1
1
  import { register } from "../contracts/git.mjs";
2
2
  import { MergeQueue } from "../contracts/queue.mjs";
3
3
  import { MergeParts, Merges, mergePartsOption } from "../core/merge-parts.mjs";
4
- import { acting } from "../core/parts.mjs";
4
+ import { acting } from "../core/access.mjs";
5
5
  import { queueJobs } from "./advance.mjs";
6
6
  import { queueCalls } from "./calls.mjs";
7
7
  import { QueueBase, QueueInternals, queueKeysOf, queueOptions } from "./host.mjs";
@@ -280,7 +280,7 @@ const TrimJob = /* @__PURE__ */ Job.make(trimName, {
280
280
  retry: queueJobRetry
281
281
  });
282
282
  /**
283
- * `queue.trim` over `host`, which `createGitServer` registers beside the queue's other jobs: its
283
+ * `queue.trim` over `host`, which `MergeQueue.layer` registers beside the queue's other jobs: its
284
284
  * time is the host's clock, as the other jobs' is. A try that fails its last retry passes its
285
285
  * failure to `onFailure`, so the host's `repo.work.failed` names it and `work.retry` runs it again:
286
286
  * a failed job's row stays failed whatever a target's first write saves.
@@ -111,6 +111,7 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
111
111
  readonly reason?: string;
112
112
  readonly packs?: number;
113
113
  readonly most?: number;
114
+ readonly retryAfter?: number;
114
115
  };
115
116
  }, unknown, never, never>, Schema.Codec<{
116
117
  readonly code: "ALREADY_EXISTS";
@@ -216,6 +217,7 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
216
217
  readonly reason?: string;
217
218
  readonly packs?: number;
218
219
  readonly most?: number;
220
+ readonly retryAfter?: number;
219
221
  };
220
222
  }, unknown, never, never>, {
221
223
  "ref0-code": Schema.String;
@@ -291,7 +293,7 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
291
293
  readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
292
294
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
293
295
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
294
- reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
296
+ reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "repo-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
295
297
  indexBytes: Schema.optionalKey<Schema.Number>;
296
298
  pushBytes: Schema.optionalKey<Schema.Number>;
297
299
  most: Schema.optionalKey<Schema.Number>;
@@ -307,9 +309,10 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
307
309
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
308
310
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
309
311
  id: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
310
- reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
312
+ reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes", "starting"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
311
313
  packs: Schema.optionalKey<Schema.Number>;
312
314
  most: Schema.optionalKey<Schema.Number>;
315
+ retryAfter: Schema.optionalKey<Schema.Number>;
313
316
  }>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>>;
314
317
  }>, Schema.Struct<{
315
318
  readonly code: Schema.Literal<"ALREADY_EXISTS">;
@@ -383,7 +386,7 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
383
386
  readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
384
387
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
385
388
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
386
- reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
389
+ reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "repo-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
387
390
  indexBytes: Schema.optionalKey<Schema.Number>;
388
391
  pushBytes: Schema.optionalKey<Schema.Number>;
389
392
  most: Schema.optionalKey<Schema.Number>;
@@ -399,9 +402,10 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
399
402
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
400
403
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
401
404
  id: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
402
- reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
405
+ reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes", "starting"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
403
406
  packs: Schema.optionalKey<Schema.Number>;
404
407
  most: Schema.optionalKey<Schema.Number>;
408
+ retryAfter: Schema.optionalKey<Schema.Number>;
405
409
  }>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>>;
406
410
  }>, {
407
411
  "ref0-code": Schema.String;
@@ -521,6 +525,7 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
521
525
  readonly reason?: string;
522
526
  readonly packs?: number;
523
527
  readonly most?: number;
528
+ readonly retryAfter?: number;
524
529
  };
525
530
  }, unknown, never, never>, Schema.Codec<{
526
531
  readonly code: "ALREADY_EXISTS";
@@ -626,6 +631,7 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
626
631
  readonly reason?: string;
627
632
  readonly packs?: number;
628
633
  readonly most?: number;
634
+ readonly retryAfter?: number;
629
635
  };
630
636
  }, unknown, never, never>, {
631
637
  "ref0-code": Schema.String;
@@ -701,7 +707,7 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
701
707
  readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
702
708
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
703
709
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
704
- reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
710
+ reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "repo-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
705
711
  indexBytes: Schema.optionalKey<Schema.Number>;
706
712
  pushBytes: Schema.optionalKey<Schema.Number>;
707
713
  most: Schema.optionalKey<Schema.Number>;
@@ -717,9 +723,10 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
717
723
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
718
724
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
719
725
  id: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
720
- reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
726
+ reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes", "starting"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
721
727
  packs: Schema.optionalKey<Schema.Number>;
722
728
  most: Schema.optionalKey<Schema.Number>;
729
+ retryAfter: Schema.optionalKey<Schema.Number>;
723
730
  }>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>>;
724
731
  }>, Schema.Struct<{
725
732
  readonly code: Schema.Literal<"ALREADY_EXISTS">;
@@ -793,7 +800,7 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
793
800
  readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
794
801
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
795
802
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
796
- reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
803
+ reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "repo-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
797
804
  indexBytes: Schema.optionalKey<Schema.Number>;
798
805
  pushBytes: Schema.optionalKey<Schema.Number>;
799
806
  most: Schema.optionalKey<Schema.Number>;
@@ -809,9 +816,10 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
809
816
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
810
817
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
811
818
  id: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
812
- reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
819
+ reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes", "starting"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
813
820
  packs: Schema.optionalKey<Schema.Number>;
814
821
  most: Schema.optionalKey<Schema.Number>;
822
+ retryAfter: Schema.optionalKey<Schema.Number>;
815
823
  }>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>>;
816
824
  }>, {
817
825
  "ref0-code": Schema.String;
@@ -28,7 +28,7 @@ var BlobsApiGroup = class extends HttpApiGroup.make("blobs").add(HttpApiEndpoint
28
28
  query: LimitsFields,
29
29
  success: BlobBytes,
30
30
  error: GitErrors
31
- }).annotateMerge(OpenApi.annotations({ description: "A blob's bytes, streamed and checked against its ID as they go: a body that ends short of its `Content-Length` failed the check, as `DATA_LOSS`. `bytes` has no default, so the file limit, 100 MiB, caps it. `object-too-large` comes before the first byte, past a `bytes` the caller sets or for a blob stored as a delta past 16 MiB. `milliseconds` limits the call until it answers, not the body after it." })), HttpApiEndpoint.post("create", "/repos/:repo/-/blobs", {
31
+ }).annotateMerge(OpenApi.annotations({ description: "A blob's bytes, streamed and checked against its ID as they go: a body that ends short of its `Content-Length` failed the check, as `DATA_LOSS`. `bytes` has no default, so the largest file a host may let a push take, 1 GiB, caps it. `object-too-large` comes before the first byte, past a `bytes` the caller sets or for a blob stored as a delta past 16 MiB. `milliseconds` limits the call until it answers, not the body after it." })), HttpApiEndpoint.post("create", "/repos/:repo/-/blobs", {
32
32
  params: RepoParam,
33
33
  query: WriteKey,
34
34
  payload: HttpApiSchema.StreamUint8Array({ contentType: "application/octet-stream" }),