@ref0/git 0.14.0 → 0.20.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 (351) hide show
  1. package/dist/auth/access-jwt.mjs +2 -2
  2. package/dist/auth/authorize.mjs +3 -3
  3. package/dist/auth/fences.d.mts +1 -2
  4. package/dist/auth/fences.mjs +3 -3
  5. package/dist/auth/grants.mjs +4 -4
  6. package/dist/auth/host-function.mjs +18 -1
  7. package/dist/auth/identify.d.mts +1 -1
  8. package/dist/auth/identify.mjs +3 -3
  9. package/dist/auth/token-cleanup.mjs +67 -0
  10. package/dist/auth/token-rows.mjs +1 -1
  11. package/dist/auth/token-text.mjs +9 -1
  12. package/dist/auth/tokens-base.d.mts +35 -0
  13. package/dist/auth/tokens-base.mjs +13 -0
  14. package/dist/auth/tokens-layer.d.mts +2 -27
  15. package/dist/auth/tokens-layer.mjs +6 -11
  16. package/dist/auth/tokens-public.d.mts +3 -3
  17. package/dist/auth/tokens.d.mts +7 -10
  18. package/dist/auth/tokens.mjs +9 -80
  19. package/dist/client/answer.mjs +21 -42
  20. package/dist/client/client.d.mts +2 -4
  21. package/dist/client/git-http.mjs +17 -7
  22. package/dist/client/local.mjs +14 -13
  23. package/dist/client/push-upload.mjs +9 -8
  24. package/dist/client/remote.mjs +8 -10
  25. package/dist/client/run-remote-helper.d.mts +1 -0
  26. package/dist/client/run-remote-helper.mjs +58 -24
  27. package/dist/client/slice-push.d.mts +1 -1
  28. package/dist/client/transport.mjs +105 -46
  29. package/dist/contracts/blobs.d.mts +55 -8
  30. package/dist/contracts/blobs.mjs +16 -2
  31. package/dist/contracts/call-allowance.d.mts +13 -0
  32. package/dist/contracts/call-allowance.mjs +44 -0
  33. package/dist/contracts/calls-spent.mjs +8 -3
  34. package/dist/contracts/client.d.mts +15 -16
  35. package/dist/contracts/commits.d.mts +24 -24
  36. package/dist/contracts/engine.d.mts +6 -1
  37. package/dist/contracts/engine.mjs +10 -1
  38. package/dist/contracts/files.d.mts +10 -10
  39. package/dist/contracts/forks.d.mts +17 -17
  40. package/dist/contracts/git-events.d.mts +29 -1
  41. package/dist/contracts/git-hooks.d.mts +1 -1
  42. package/dist/contracts/git.d.mts +21 -0
  43. package/dist/contracts/grants.d.mts +24 -4
  44. package/dist/contracts/handlers.d.mts +1 -1
  45. package/dist/contracts/lfs.d.mts +28 -2
  46. package/dist/contracts/merges.d.mts +3 -2
  47. package/dist/contracts/objects.d.mts +23 -25
  48. package/dist/contracts/queue.d.mts +40 -12
  49. package/dist/contracts/queue.mjs +3 -4
  50. package/dist/contracts/refs.d.mts +26 -23
  51. package/dist/contracts/remote.d.mts +6 -7
  52. package/dist/contracts/remote.mjs +4 -1
  53. package/dist/contracts/repos.d.mts +29 -138
  54. package/dist/contracts/repos.mjs +5 -3
  55. package/dist/contracts/result.d.mts +35 -16
  56. package/dist/contracts/result.mjs +35 -7
  57. package/dist/contracts/server.d.mts +25 -50
  58. package/dist/contracts/services.d.mts +1 -1
  59. package/dist/contracts/store.d.mts +6 -5
  60. package/dist/contracts/sync.d.mts +11 -7
  61. package/dist/contracts/sync.mjs +12 -2
  62. package/dist/contracts/tags.d.mts +10 -10
  63. package/dist/contracts/time.d.mts +3 -0
  64. package/dist/contracts/{promises.mjs → time.mjs} +1 -1
  65. package/dist/contracts/tokens.d.mts +15 -17
  66. package/dist/contracts/tokens.mjs +3 -2
  67. package/dist/contracts/topics.d.mts +1 -1
  68. package/dist/contracts/trees.d.mts +12 -12
  69. package/dist/contracts/work.d.mts +24 -13
  70. package/dist/core/access.d.mts +1 -2
  71. package/dist/core/access.mjs +20 -9
  72. package/dist/core/ancestry.d.mts +1 -0
  73. package/dist/core/asked.mjs +1 -1
  74. package/dist/core/call-names.mjs +6 -1
  75. package/dist/core/call-services.mjs +11 -3
  76. package/dist/core/events/deliver.d.mts +1 -2
  77. package/dist/core/events/deliver.mjs +43 -36
  78. package/dist/core/events/retired.mjs +119 -0
  79. package/dist/core/forks.mjs +928 -432
  80. package/dist/core/hooks/groups.mjs +1 -1
  81. package/dist/core/imports.mjs +29 -23
  82. package/dist/core/index-job.mjs +122 -34
  83. package/dist/core/index-lost.d.mts +1 -2
  84. package/dist/core/index-lost.mjs +2 -2
  85. package/dist/core/loose-tally.mjs +1 -1
  86. package/dist/core/objects/blobs.mjs +129 -3
  87. package/dist/core/objects/lines.mjs +2 -2
  88. package/dist/core/objects/merges.mjs +4 -1
  89. package/dist/core/objects/objects-layer.d.mts +1 -1
  90. package/dist/core/objects/objects-layer.mjs +3 -3
  91. package/dist/core/objects/reading.mjs +24 -13
  92. package/dist/core/objects/tags.mjs +4 -1
  93. package/dist/core/objects/trees.mjs +2 -2
  94. package/dist/core/objects/writing.mjs +2 -2
  95. package/dist/core/own-writes.mjs +1 -1
  96. package/dist/core/parts.d.mts +4 -5
  97. package/dist/core/parts.mjs +3 -8
  98. package/dist/core/promise.mjs +9 -12
  99. package/dist/core/purge.mjs +287 -83
  100. package/dist/core/push-decide.mjs +2 -0
  101. package/dist/core/push-files.d.mts +1 -1
  102. package/dist/core/push.mjs +58 -47
  103. package/dist/core/receipts.mjs +8 -3
  104. package/dist/core/ref-index-job.mjs +4 -4
  105. package/dist/core/ref-view.mjs +2 -2
  106. package/dist/core/refs.mjs +5 -5
  107. package/dist/core/registered-rows.mjs +2 -2
  108. package/dist/core/repack.mjs +36 -21
  109. package/dist/core/repo-info.mjs +3 -3
  110. package/dist/core/repos.mjs +21 -9
  111. package/dist/core/rules/commit-changes.d.mts +0 -1
  112. package/dist/core/saved-caller-views.d.mts +7 -2
  113. package/dist/core/saved-caller-views.mjs +2 -2
  114. package/dist/core/saved-callers.d.mts +19 -2
  115. package/dist/core/seam.d.mts +16 -26
  116. package/dist/core/seam.mjs +7 -28
  117. package/dist/core/tokens.mjs +1 -1
  118. package/dist/core/view.mjs +7 -15
  119. package/dist/core/work.mjs +59 -14
  120. package/dist/effect.d.mts +3 -12
  121. package/dist/effect.mjs +1 -10
  122. package/dist/engine/failures.mjs +2 -1
  123. package/dist/engine/reads.mjs +4 -4
  124. package/dist/event-streams/stream.d.mts +2 -2
  125. package/dist/event-streams/stream.mjs +37 -14
  126. package/dist/extend.d.mts +2 -3
  127. package/dist/extend.mjs +2 -1
  128. package/dist/http/answers.mjs +8 -5
  129. package/dist/http/core-parts.mjs +95 -79
  130. package/dist/http/handler.mjs +34 -7
  131. package/dist/http/node.d.mts +14 -1
  132. package/dist/http/node.mjs +56 -27
  133. package/dist/http/parts.d.mts +1 -0
  134. package/dist/http/push-upload-job.mjs +30 -26
  135. package/dist/http/push-uploads.mjs +36 -21
  136. package/dist/http/upload-pack.mjs +3 -3
  137. package/dist/index.d.mts +14 -14
  138. package/dist/index.mjs +2 -2
  139. package/dist/lfs/answer.mjs +37 -0
  140. package/dist/lfs/base.d.mts +2 -0
  141. package/dist/lfs/base.mjs +25 -1
  142. package/dist/lfs/copy.d.mts +21 -7
  143. package/dist/lfs/copy.mjs +89 -6
  144. package/dist/lfs/layer.d.mts +15 -1
  145. package/dist/lfs/layer.mjs +24 -11
  146. package/dist/lfs/locks.mjs +2 -2
  147. package/dist/lfs/objects.d.mts +1 -0
  148. package/dist/lfs/objects.mjs +87 -17
  149. package/dist/lfs/pointers.mjs +2 -2
  150. package/dist/lfs/rows.mjs +42 -8
  151. package/dist/lfs/upkeep.mjs +48 -14
  152. package/dist/lfs/wire.mjs +6 -31
  153. package/dist/merges/merges.mjs +2 -2
  154. package/dist/node.d.mts +2 -2
  155. package/dist/protocol/bytes/buffers.mjs +13 -5
  156. package/dist/protocol/bytes/reader.mjs +6 -1
  157. package/dist/protocol/bytes/streams.mjs +27 -1
  158. package/dist/protocol/diff/read.d.mts +4 -3
  159. package/dist/protocol/diff/read.mjs +8 -3
  160. package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
  161. package/dist/protocol/objects/lfs-pointer.mjs +1 -3
  162. package/dist/protocol/objects/links-raw.mjs +24 -10
  163. package/dist/protocol/objects/tag.d.mts +1 -1
  164. package/dist/protocol/objects/tree.mjs +23 -6
  165. package/dist/protocol/packs/delta.d.mts +6 -3
  166. package/dist/protocol/packs/delta.mjs +96 -32
  167. package/dist/protocol/packs/idx.d.mts +2 -1
  168. package/dist/protocol/packs/idx.mjs +22 -3
  169. package/dist/protocol/packs/parts.d.mts +4 -1
  170. package/dist/protocol/packs/parts.mjs +10 -7
  171. package/dist/protocol/packs/reader.d.mts +5 -0
  172. package/dist/protocol/packs/reader.mjs +3 -2
  173. package/dist/protocol/packs/writer.mjs +26 -8
  174. package/dist/queue/advance.mjs +21 -24
  175. package/dist/queue/base.d.mts +55 -0
  176. package/dist/queue/base.mjs +44 -0
  177. package/dist/queue/calls.mjs +51 -54
  178. package/dist/queue/commit.mjs +1 -1
  179. package/dist/queue/host.d.mts +1 -15
  180. package/dist/queue/host.mjs +2 -7
  181. package/dist/queue/layer.d.mts +2 -1
  182. package/dist/queue/layer.mjs +10 -3
  183. package/dist/queue/limits.mjs +2 -0
  184. package/dist/queue/push-option.mjs +9 -24
  185. package/dist/queue/schedule.mjs +1 -1
  186. package/dist/queue/state.mjs +2 -10
  187. package/dist/queue/trim.mjs +5 -3
  188. package/dist/rest/blobs.mjs +29 -5
  189. package/dist/rest/caller.d.mts +4 -4271
  190. package/dist/rest/caller.mjs +4 -0
  191. package/dist/rest/client.d.mts +8 -5
  192. package/dist/rest/client.mjs +19 -2
  193. package/dist/rest/handlers.mjs +50 -5
  194. package/dist/rest/layer.d.mts +2 -2
  195. package/dist/rest/layer.mjs +5 -12
  196. package/dist/rest/me.d.mts +3 -432
  197. package/dist/server/check-fetch.mjs +3 -3
  198. package/dist/server/edge-node.d.mts +11 -8
  199. package/dist/server/edge-node.mjs +9 -6
  200. package/dist/server/edge.d.mts +21 -7
  201. package/dist/server/edge.mjs +32 -11
  202. package/dist/server/extension.mjs +1 -1
  203. package/dist/server/git-layer.d.mts +5 -5
  204. package/dist/server/git-layer.mjs +28 -22
  205. package/dist/server/git-namespace.d.mts +4 -3
  206. package/dist/server/git-namespace.mjs +3 -2
  207. package/dist/server/joined.d.mts +6 -18
  208. package/dist/server/joined.mjs +9 -36
  209. package/dist/server/lifecycle.mjs +18 -106
  210. package/dist/server/registry.mjs +24 -7
  211. package/dist/server/server.mjs +205 -346
  212. package/dist/signin/context.d.mts +1 -2
  213. package/dist/signin/layer.d.mts +1 -1
  214. package/dist/signin/layer.mjs +1 -1
  215. package/dist/storage/allotted.mjs +18 -3
  216. package/dist/storage/batch-upkeep.mjs +274 -0
  217. package/dist/storage/batches.d.mts +8 -0
  218. package/dist/storage/batches.mjs +344 -0
  219. package/dist/storage/calls.d.mts +1 -2
  220. package/dist/storage/calls.mjs +144 -158
  221. package/dist/storage/chunks.d.mts +9 -0
  222. package/dist/storage/chunks.mjs +297 -0
  223. package/dist/storage/clean-up.mjs +72 -9
  224. package/dist/storage/counted-bucket.mjs +4 -4
  225. package/dist/storage/fetch.d.mts +1 -0
  226. package/dist/storage/fetch.mjs +287 -210
  227. package/dist/storage/host-bucket.mjs +1 -2
  228. package/dist/storage/id-mix.mjs +19 -5
  229. package/dist/storage/index-bitmaps.mjs +9 -2
  230. package/dist/storage/index-build.d.mts +0 -1
  231. package/dist/storage/index-build.mjs +80 -23
  232. package/dist/storage/index-fetch.mjs +113 -72
  233. package/dist/storage/index-files.d.mts +3 -0
  234. package/dist/storage/index-files.mjs +10 -5
  235. package/dist/storage/index-graph.mjs +72 -22
  236. package/dist/storage/index-remap.mjs +200 -64
  237. package/dist/storage/index-whole.mjs +127 -0
  238. package/dist/storage/largest-files.mjs +1 -1
  239. package/dist/storage/layout.mjs +23 -0
  240. package/dist/storage/loose.d.mts +7 -4
  241. package/dist/storage/loose.mjs +212 -67
  242. package/dist/storage/memory-budget.mjs +16 -4
  243. package/dist/storage/merge-plan.mjs +3 -2
  244. package/dist/storage/merge-row.mjs +7 -1
  245. package/dist/storage/merge-stream.mjs +164 -25
  246. package/dist/storage/merge-walk.mjs +8 -4
  247. package/dist/storage/merge-write.mjs +1 -1
  248. package/dist/storage/merge.d.mts +1 -1
  249. package/dist/storage/merge.mjs +1 -1
  250. package/dist/storage/object-rows.d.mts +1 -0
  251. package/dist/storage/object-rows.mjs +385 -65
  252. package/dist/storage/oid-table.mjs +171 -0
  253. package/dist/storage/pack-order.mjs +8 -4
  254. package/dist/storage/pack-ranges.d.mts +1 -2
  255. package/dist/storage/pack-ranges.mjs +4 -5
  256. package/dist/storage/pack-reads.d.mts +2 -1
  257. package/dist/storage/pack-reads.mjs +158 -42
  258. package/dist/storage/pack-receive.d.mts +1 -1
  259. package/dist/storage/pack-receive.mjs +2 -2
  260. package/dist/storage/packs.d.mts +1 -1
  261. package/dist/storage/packs.mjs +136 -66
  262. package/dist/storage/placed-reads.mjs +1 -1
  263. package/dist/storage/plan-columns.d.mts +4 -0
  264. package/dist/storage/plan-columns.mjs +238 -0
  265. package/dist/storage/prune-keep.mjs +134 -41
  266. package/dist/storage/prune-walk.mjs +202 -62
  267. package/dist/storage/prune.mjs +194 -91
  268. package/dist/storage/push-allotment.mjs +91 -12
  269. package/dist/storage/push-uploads.mjs +4 -4
  270. package/dist/storage/pushed-commits.mjs +4 -2
  271. package/dist/storage/quarantine.d.mts +1 -1
  272. package/dist/storage/range-cache.mjs +125 -8
  273. package/dist/storage/ready.d.mts +1 -1
  274. package/dist/storage/ready.mjs +8 -6
  275. package/dist/storage/receive-bounds.mjs +23 -8
  276. package/dist/storage/repack-backlog.mjs +6 -3
  277. package/dist/storage/repack.d.mts +1 -1
  278. package/dist/storage/rows.d.mts +1 -1
  279. package/dist/storage/rows.mjs +1 -1
  280. package/dist/storage/runs.mjs +195 -43
  281. package/dist/storage/send-list.d.mts +1 -0
  282. package/dist/storage/send-list.mjs +54 -10
  283. package/dist/storage/single-flight.mjs +13 -7
  284. package/dist/storage/stream-whole.mjs +127 -26
  285. package/dist/storage/unpack.mjs +371 -79
  286. package/dist/storage/visible.mjs +2 -2
  287. package/dist/storage/walk.mjs +192 -38
  288. package/dist/storage/wants.mjs +5 -5
  289. package/dist/store/bodies.mjs +38 -0
  290. package/dist/store/call-count.d.mts +8 -12
  291. package/dist/store/call-count.mjs +34 -46
  292. package/dist/store/catalogue.d.mts +2 -2
  293. package/dist/store/catalogue.mjs +145 -35
  294. package/dist/store/crossing.mjs +1 -3
  295. package/dist/store/cursor-seal.d.mts +1 -2
  296. package/dist/store/cursor-seal.mjs +16 -6
  297. package/dist/store/door.mjs +183 -0
  298. package/dist/store/errors.d.mts +3 -4
  299. package/dist/store/errors.mjs +15 -33
  300. package/dist/store/git-store.mjs +25 -7
  301. package/dist/store/job-try.mjs +9 -32
  302. package/dist/store/list-job.mjs +44 -8
  303. package/dist/store/records.d.mts +3 -0
  304. package/dist/store/records.mjs +3 -0
  305. package/dist/store/repo-record.d.mts +1 -2
  306. package/dist/store/repo-record.mjs +32 -20
  307. package/dist/store/reservations.mjs +1 -1
  308. package/dist/store/scopes.mjs +11 -0
  309. package/dist/store/settle.mjs +4 -4
  310. package/dist/sync/github.mjs +3 -3
  311. package/dist/sync/import.mjs +31 -18
  312. package/dist/sync/lfs-batch.mjs +4 -5
  313. package/dist/sync/lfs-copy.mjs +17 -6
  314. package/dist/sync/mirror.mjs +34 -31
  315. package/dist/sync/said.mjs +16 -37
  316. package/dist/sync/step.mjs +33 -25
  317. package/dist/sync/tries.mjs +9 -9
  318. package/dist/topics/advance.mjs +10 -11
  319. package/dist/topics/base.d.mts +15 -0
  320. package/dist/topics/base.mjs +8 -0
  321. package/dist/topics/host.mjs +1 -1
  322. package/dist/topics/layer.d.mts +4 -9
  323. package/dist/topics/layer.mjs +2 -3
  324. package/dist/topics/members.mjs +4 -4
  325. package/dist/topics/public.d.mts +2 -1
  326. package/dist/topics/topic.mjs +2 -2
  327. package/package.json +5 -4
  328. package/dist/contracts/promises.d.mts +0 -39
  329. package/dist/core/call-names.d.mts +0 -3
  330. package/dist/core/clock.mjs +0 -18
  331. package/dist/lfs/calls.mjs +0 -26
  332. package/dist/rest/api.d.mts +0 -23
  333. package/dist/rest/blobs.d.mts +0 -833
  334. package/dist/rest/commits.d.mts +0 -3543
  335. package/dist/rest/errors.d.mts +0 -2124
  336. package/dist/rest/events.d.mts +0 -426
  337. package/dist/rest/files.d.mts +0 -1342
  338. package/dist/rest/forks.d.mts +0 -2160
  339. package/dist/rest/handlers.d.mts +0 -8
  340. package/dist/rest/merges.d.mts +0 -477
  341. package/dist/rest/queue.d.mts +0 -5917
  342. package/dist/rest/refs.d.mts +0 -2988
  343. package/dist/rest/repos.d.mts +0 -2567
  344. package/dist/rest/tags.d.mts +0 -1316
  345. package/dist/rest/tokens.d.mts +0 -2614
  346. package/dist/rest/topics.d.mts +0 -2224
  347. package/dist/rest/trees.d.mts +0 -1709
  348. package/dist/rest/work.d.mts +0 -1695
  349. package/dist/server/lifecycle.d.mts +0 -2
  350. package/dist/store/promises.d.mts +0 -11
  351. package/dist/store/promises.mjs +0 -327
@@ -10,6 +10,7 @@ import { keptKey, takenBack } from "../store/records.mjs";
10
10
  import { refuseLive, reservationOf, reservedRepo } from "../store/reservations.mjs";
11
11
  import { collections, newInternalId, reachedKey, repoScope } from "../store/scopes.mjs";
12
12
  import { alreadyExists, callerFor, contended, contendedAfterWrites, indexDeleteJobs, keyedRecord, nameMoved, openKeyed, openRepo, purgeJobs, repoAccess, unlessHidden } from "./access.mjs";
13
+ import { importReads, importStatusOf } from "./imports.mjs";
13
14
  import { createdInfo, infoReads, repoInfo } from "./repo-info.mjs";
14
15
  import { isRefName } from "./names.mjs";
15
16
  import { shortRef } from "./rules/patterns.mjs";
@@ -19,7 +20,7 @@ import { fail } from "../contracts/result.mjs";
19
20
  import { CoreParts } from "./parts.mjs";
20
21
  import { pruneJobRow } from "../storage/repack-job.mjs";
21
22
  import { check } from "../contracts/authorize.mjs";
22
- import * as Clock$1 from "effect/Clock";
23
+ import * as Clock from "effect/Clock";
23
24
  import * as Effect from "effect/Effect";
24
25
  // src/core/repos.ts
25
26
  const defaultBranch = "refs/heads/main";
@@ -304,7 +305,7 @@ const createWith = /* @__PURE__ */ Effect.fnUntraced(function* (caller, input, a
304
305
  }
305
306
  });
306
307
  for (let attempt = 0; attempt < 5; attempt += 1) {
307
- const at = yield* Clock$1.currentTimeMillis;
308
+ const at = yield* Clock.currentTimeMillis;
308
309
  const kept = yield* keptKey(caller, input.key, [
309
310
  "create",
310
311
  id,
@@ -370,7 +371,8 @@ const createWith = /* @__PURE__ */ Effect.fnUntraced(function* (caller, input, a
370
371
  ...receiptKeys(kept),
371
372
  ...dropped.delete,
372
373
  ...also.put.map(keyOf)
373
- ]
374
+ ],
375
+ jobs: [...receipt.jobs.length > 0 ? [core.repackJobRow()] : [], ...purgeJobs(core, at)]
374
376
  })) === "lost") return yield* alreadyExists(id);
375
377
  return {
376
378
  info,
@@ -379,6 +381,8 @@ const createWith = /* @__PURE__ */ Effect.fnUntraced(function* (caller, input, a
379
381
  }
380
382
  return yield* contended();
381
383
  });
384
+ /** Whether a read of the repo confirms it once `authorize` answers, as `unconfirmed` says. */
385
+ const confirmOf = (input) => input.unconfirmed === true ? "skip" : "read";
382
386
  /**
383
387
  * `repos`: each call reads the repo's record, decides the next one, and commits it in the repo's
384
388
  * own scope, with `git.list` saved beside it, then projects the record into `git/repos`. The
@@ -396,10 +400,17 @@ const repoCalls = (bound) => {
396
400
  repo
397
401
  };
398
402
  const caller = callerOf(input);
399
- const confirm = input.unconfirmed === true ? "skip" : "read";
400
- const opened = yield* openRepo(caller, operation, infoReads, input.internalId, confirm);
403
+ const opened = yield* openRepo(caller, operation, infoReads, input.internalId, confirmOf(input));
401
404
  return yield* repoInfo(caller, opened.internalId, opened.record, opened.snapshot.results.slice(1));
402
405
  });
406
+ const importState = Effect.fnUntraced(function* (repo, input) {
407
+ const operation = {
408
+ kind: "read",
409
+ repo
410
+ };
411
+ const opened = yield* openRepo(callerOf(input), operation, importReads, input.internalId, confirmOf(input));
412
+ return yield* importStatusOf(opened.snapshot.results.slice(1));
413
+ });
403
414
  const list = Effect.fnUntraced(function* (input) {
404
415
  const core = yield* CoreParts;
405
416
  const { store } = core;
@@ -540,6 +551,7 @@ const repoCalls = (bound) => {
540
551
  return {
541
552
  create,
542
553
  get,
554
+ importState,
543
555
  list,
544
556
  update: Effect.fnUntraced(function* (repo, input) {
545
557
  const core = yield* CoreParts;
@@ -550,7 +562,7 @@ const repoCalls = (bound) => {
550
562
  yield* privateDefault(input.defaultBranch);
551
563
  }
552
564
  for (let attempt = 0; attempt < 5; attempt += 1) {
553
- const at = yield* Clock$1.currentTimeMillis;
565
+ const at = yield* Clock.currentTimeMillis;
554
566
  const caller = callerOf(input);
555
567
  const kept = yield* keptKey(caller, input.key, [
556
568
  "update",
@@ -621,7 +633,7 @@ const repoCalls = (bound) => {
621
633
  if (!isRepoName(to)) return yield* badRepoName(to);
622
634
  if (to === repo) return yield* fail("INVALID_ARGUMENT", "A rename names another name");
623
635
  for (let attempt = 0; attempt < 5; attempt += 1) {
624
- const at = yield* Clock$1.currentTimeMillis;
636
+ const at = yield* Clock.currentTimeMillis;
625
637
  const kept = yield* keptKey(caller, input.key, [
626
638
  "rename",
627
639
  repo,
@@ -734,7 +746,7 @@ const repoCalls = (bound) => {
734
746
  const { store } = core;
735
747
  const caller = callerOf(input);
736
748
  for (let attempt = 0; attempt < 5; attempt += 1) {
737
- const at = yield* Clock$1.currentTimeMillis;
749
+ const at = yield* Clock.currentTimeMillis;
738
750
  const kept = yield* keptKey(caller, input.key, ["delete", repo], at);
739
751
  const keyed = yield* keyedRecord(store, repo, kept, (access) => Effect.andThen(check({
740
752
  caller,
@@ -779,7 +791,7 @@ const repoCalls = (bound) => {
779
791
  exempt: true,
780
792
  confirmed: name
781
793
  });
782
- const deletedAt = yield* Clock$1.currentTimeMillis;
794
+ const deletedAt = yield* Clock.currentTimeMillis;
783
795
  const deleted = {
784
796
  ...record,
785
797
  deleted: true,
@@ -4,7 +4,6 @@ import "../../contracts/objects.mjs";
4
4
  import "../../contracts/refs.mjs";
5
5
  import { GitError } from "../../contracts/result.mjs";
6
6
  import "../../contracts/rules.mjs";
7
- import "../../contracts/services.mjs";
8
7
  import "../../contracts/store.mjs";
9
8
  import { WalkRefused } from "../../engine/combined.mjs";
10
9
  import "effect/Effect";
@@ -3,8 +3,8 @@ import { Caller, RepoAccess } from "../contracts/actors.mjs";
3
3
  import "../contracts/authorize.mjs";
4
4
  import { InternalRepoId } from "../contracts/ids.mjs";
5
5
  import { GitError } from "../contracts/result.mjs";
6
- import "./parts.mjs";
7
- import "./saved-callers.mjs";
6
+ import { QueueNeeds } from "./parts.mjs";
7
+ import { SavedCaller } from "./saved-callers.mjs";
8
8
  import * as Effect from "effect/Effect";
9
9
  import * as Schema from "effect/Schema";
10
10
  import * as Context from "effect/Context";
@@ -42,6 +42,11 @@ export declare const Saved: Schema.Union<readonly [Schema.Struct<{
42
42
  readonly id: Schema.String;
43
43
  }>]>;
44
44
  export type Saved = typeof Saved.Type;
45
+ /**
46
+ * How `SavedCallers.queueEntry` reads who added a queue entry, as its row saved them: the queue's own
47
+ * reader, which sits above the core, as the server hands it.
48
+ */
49
+ export type EntryAdderOf = (entry: string) => Effect.Effect<SavedCaller | undefined, GitError, QueueNeeds>;
45
50
  declare const SavedCallers_base: Context.ServiceClass<SavedCallers, "@ref0/git/SavedCallers", {
46
51
  /** `caller` as work keeps it, its actor named `actor`: its kind and IDs, nothing more. */
47
52
  readonly save: (actor: string, caller: Caller) => Effect.Effect<Saved>;
@@ -6,7 +6,7 @@ import { CoreParts } from "./parts.mjs";
6
6
  import { retriedCodes } from "./push.mjs";
7
7
  import { refViewAgain } from "./ref-view.mjs";
8
8
  import { askAgain } from "./saved-callers.mjs";
9
- import * as Clock$1 from "effect/Clock";
9
+ import * as Clock from "effect/Clock";
10
10
  import * as Effect from "effect/Effect";
11
11
  import * as Schema from "effect/Schema";
12
12
  import * as Result from "effect/Result";
@@ -20,7 +20,7 @@ import * as Context from "effect/Context";
20
20
  * with a code a try retries, fails, so the try runs again.
21
21
  */
22
22
  const viewAgainOf = /* @__PURE__ */ Effect.fnUntraced(function* (saved, repo, kind, signal) {
23
- const asked = yield* askAgain(saved, yield* Clock$1.currentTimeMillis, signal);
23
+ const asked = yield* askAgain(saved, yield* Clock.currentTimeMillis, signal);
24
24
  if (asked.kind === "refused") return asked;
25
25
  const view = yield* Effect.result(refViewAgain(asked.caller, kind, repo));
26
26
  if (Result.isFailure(view)) {
@@ -3,5 +3,22 @@ import "../contracts/result.mjs";
3
3
  import "../contracts/authorize.mjs";
4
4
  import "./parts.mjs";
5
5
  import "effect/Effect";
6
- import "effect/Schema";
7
- import "effect/Types";
6
+ import * as Schema from "effect/Schema";
7
+ import "effect/Types";
8
+ /**
9
+ * Who saved work that runs later, a queue entry or a mirror (#679, #1945), as its row keeps it:
10
+ * the actor's ID, the subject's, the ID of the token it came with, never its secret, and the
11
+ * extension's grant that gave it, by its resolver and the `id` it asks that again with. Each try
12
+ * asks it again with `askAgain`, so a credential that ended stops the work. The `meta` it came
13
+ * with was the sign-in's at the save, and isn't kept.
14
+ */
15
+ export declare const SavedCaller: Schema.Struct<{
16
+ readonly actor: Schema.String;
17
+ readonly subject: Schema.optionalKey<Schema.String>;
18
+ readonly token: Schema.optionalKey<Schema.String>;
19
+ readonly grant: Schema.optionalKey<Schema.Struct<{
20
+ readonly resolver: Schema.String;
21
+ readonly id: Schema.String;
22
+ }>>;
23
+ }>;
24
+ export type SavedCaller = typeof SavedCaller.Type;
@@ -7,8 +7,6 @@ import { EffectCalls } from "../contracts/services.mjs";
7
7
  import { TokenId } from "../contracts/tokens.mjs";
8
8
  import { Identify } from "../auth/identify.mjs";
9
9
  import { CallCount } from "../store/call-count.mjs";
10
- import { BridgeDoor } from "../store/promises.mjs";
11
- import { CallNames } from "./call-names.mjs";
12
10
  import { FeedItem } from "../contracts/events.mjs";
13
11
  import "../contracts/authorize.mjs";
14
12
  import { QueueNeeds } from "./parts.mjs";
@@ -26,15 +24,13 @@ export interface SeamAuthorizeInput {
26
24
  readonly repo?: RepoName;
27
25
  }
28
26
  /**
29
- * What a server's own routes, such as REST's, reach under `GitServer`'s Promise surface: its
30
- * `identify` and `authorize`, its Effect calls for one caller, and where a renamed repo went. The
31
- * layers put REST below the server, so the seam sits here. Each of them dies once the server is
32
- * closed; the server's door alone decides the rest.
27
+ * What REST serves the server's calls through: where it serves, who a request is, the Effect calls
28
+ * for one caller, `authorize` for the calls that trust host code, and where a renamed repo went.
29
+ * The layers put REST below the server, so it sits here. Each part goes through the server's door,
30
+ * so one asked once the server is closed dies closed.
33
31
  */
34
- export interface ServerParts {
32
+ export interface ServedRest {
35
33
  readonly basePath: string;
36
- /** The context the server's calls run over, which its jobs and routes provide. */
37
- readonly needs: Context.Context<QueueNeeds>;
38
34
  /**
39
35
  * The Effect calls, each deciding for `caller`, the one `identify` answered: its token's scope or
40
36
  * its grant is the ceiling, whatever actor an input names.
@@ -48,8 +44,9 @@ export interface ServerParts {
48
44
  readonly identify: Identify;
49
45
  readonly authorize: (input: SeamAuthorizeInput) => Effect.Effect<void, GitError>;
50
46
  /**
51
- * The name a renamed repo moved to, while nothing has been made under its old one, told only to
52
- * a `caller` that may read the repo there: `undefined` for anyone else.
47
+ * Where a renamed repo is today, while nothing has been made under its old name: its name now,
48
+ * found by internal ID past any later rename, never whatever repo took the name it first moved
49
+ * to. Told only to a `caller` that may read it: `undefined` for anyone else.
53
50
  */
54
51
  readonly renamedTo: (caller: Caller, repo: RepoName) => Effect.Effect<RepoName | undefined, GitError>;
55
52
  /**
@@ -67,21 +64,14 @@ export interface ServerParts {
67
64
  }
68
65
  /** Opens a repo's event stream for `caller`: `openFeed` over the server's core and clock. */
69
66
  export type Listen = (caller: Caller, repo: RepoName, after: number | undefined) => Effect.Effect<ReadableStream<FeedItem>, GitError>;
70
- /** A server's parts before its runtime is built: where it serves, its groups, and its build. */
71
- export interface Seam {
72
- readonly basePath: string;
73
- readonly names: CallNames;
74
- /** Whether the server has its queue now, which `names`' `queue` group answers only once it does. */
75
- readonly queueOn: () => boolean;
76
- /** The server's door, which a route outside its runtime, such as REST's, asks before and after. */
77
- readonly door: BridgeDoor;
78
- /** The parts once the build is done: `UNAVAILABLE`, naming its failure, once it failed. */
79
- readonly parts: Effect.Effect<ServerParts, GitError>;
80
- }
81
- declare const ServerSeam_base: Context.ServiceClass<ServerSeam, "@ref0/git/ServerSeam", Seam>;
67
+ declare const ServedParts_base: Context.ServiceClass<ServedParts, "@ref0/git/ServedParts", {
68
+ readonly rest: ServedRest;
69
+ readonly needs: Context.Context<QueueNeeds>;
70
+ }>;
82
71
  /**
83
- * The seam of the server `Git.layer` built, which a feature that serves the server's calls, as
84
- * `Rest.layer` does, reads as it builds. Internal: no entry exports it.
72
+ * What the server `Git.layer` built hands the features that serve its calls, as `Rest.layer` does,
73
+ * as they build: REST's parts, and the context the server's calls run over, which its jobs and
74
+ * routes provide. Internal: no entry exports it.
85
75
  */
86
- export declare class ServerSeam extends /* @__PURE__ */ ServerSeam_base {}
76
+ export declare class ServedParts extends /* @__PURE__ */ ServedParts_base {}
87
77
  export {};
@@ -1,7 +1,5 @@
1
- import { noTokens } from "../auth/tokens-layer.mjs";
2
1
  import { redirectOf, resolveRepo } from "../store/catalogue.mjs";
3
2
  import { readableRedirect, repoAccess } from "./access.mjs";
4
- import { callOrMissing, heldGroup, lazyGroups } from "./promise.mjs";
5
3
  import { revokeCheck } from "./tokens.mjs";
6
4
  import { check } from "../contracts/authorize.mjs";
7
5
  import { CoreParts } from "./parts.mjs";
@@ -9,30 +7,11 @@ import * as Effect from "effect/Effect";
9
7
  import * as Context from "effect/Context";
10
8
  // src/core/seam.ts
11
9
  /**
12
- * The seam of the server `Git.layer` built, which a feature that serves the server's calls, as
13
- * `Rest.layer` does, reads as it builds. Internal: no entry exports it.
10
+ * What the server `Git.layer` built hands the features that serve its calls, as `Rest.layer` does,
11
+ * as they build: REST's parts, and the context the server's calls run over, which its jobs and
12
+ * routes provide. Internal: no entry exports it.
14
13
  */
15
- var ServerSeam = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/ServerSeam")) {};
16
- const seamByServer = /* @__PURE__ */ new WeakMap();
17
- /** Called once for a server, by `openServer` or a test world's face. */
18
- const attachParts = (server, seam) => {
19
- seamByServer.set(server, seam);
20
- };
21
- /** A server's seam: `undefined` for one with none attached. */
22
- const seamOf = (server) => seamByServer.get(server);
23
- /** `seam`'s parts but its needs and bound, each waiting for the build: a route's, made before it. */
24
- const lazyParts = (seam) => {
25
- const { parts } = seam;
26
- return {
27
- basePath: seam.basePath,
28
- callsFor: (caller) => heldGroup(lazyGroups(seam.names, (group, name, args) => Effect.flatMap(parts, (built) => callOrMissing(built.callsFor(caller), group, name, () => Effect.fail(noTokens))(...args))), "queue", seam.queueOn),
29
- tokensOn: Effect.flatMap(parts, (built) => built.tokensOn),
30
- identify: (request) => Effect.flatMap(parts, (built) => built.identify(request)),
31
- authorize: (input) => Effect.flatMap(parts, (built) => built.authorize(input)),
32
- renamedTo: (caller, repo) => Effect.flatMap(parts, (built) => built.renamedTo(caller, repo)),
33
- listen: (caller, repo, after) => Effect.flatMap(parts, (built) => built.listen(caller, repo, after))
34
- };
35
- };
14
+ var ServedParts = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/ServedParts")) {};
36
15
  /**
37
16
  * `authorize` for a route: a repo's operation with the repo's access, or a revoke against the
38
17
  * token's own coverage. A repo that isn't there is asked without access, and a caller it lets
@@ -60,7 +39,7 @@ const seamAuthorize = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
60
39
  /** Where `repo` went, for a route's redirect: only to a caller that may read it there. */
61
40
  const renamedTo = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo) {
62
41
  const { store } = yield* CoreParts;
63
- const to = yield* redirectOf(store, repo);
64
- return to === void 0 ? void 0 : yield* readableRedirect(caller, to);
42
+ const moved = yield* redirectOf(store, repo);
43
+ return moved === void 0 ? void 0 : yield* readableRedirect(caller, moved.to, moved.internalId);
65
44
  });
66
- export { ServerSeam, attachParts, lazyParts, renamedTo, seamAuthorize, seamOf };
45
+ export { ServedParts, renamedTo, seamAuthorize };
@@ -1,6 +1,6 @@
1
1
  import { fail, gitError } from "../contracts/result.mjs";
2
2
  import { readToken } from "../auth/token-rows.mjs";
3
- import { isPrefixTarget, tokenParties } from "../auth/tokens.mjs";
3
+ import { isPrefixTarget, tokenParties } from "../auth/token-text.mjs";
4
4
  import { isHost } from "../contracts/git.mjs";
5
5
  import { namedRecordOf } from "../store/catalogue.mjs";
6
6
  import { confirmed, openRepo, repoAccess } from "./access.mjs";
@@ -2,7 +2,7 @@ import { gitsOwnMove } from "../protocol/wire/lines.mjs";
2
2
  import { answerSpent, resultCall } from "../store/errors.mjs";
3
3
  import { upstreamOf } from "../store/catalogue.mjs";
4
4
  import { collections } from "../store/scopes.mjs";
5
- import { answeredBy, effectWithin, objectsFace, scopedReader } from "../storage/calls.mjs";
5
+ import { scopedReader } from "../storage/calls.mjs";
6
6
  import { callScope, inCallScope } from "../store/call-count.mjs";
7
7
  import { askingOnLost } from "../storage/index-visible.mjs";
8
8
  import { indexRowKey } from "../storage/layout.mjs";
@@ -47,18 +47,10 @@ var SealedObjects = class SealedObjects {
47
47
  * error alone, never the objects, so it's no way past a view.
48
48
  */
49
49
  static onReceive(sealed, seen) {
50
- const watch = (objects) => {
51
- const effect = effectWithin(objects.receive);
52
- const receive = async (listed, input) => {
53
- const result = await objects.receive(listed, input);
54
- if (result.kind === "error") seen(result.error);
55
- return result;
56
- };
57
- return {
58
- ...objects,
59
- receive: answeredBy(receive, (listed, input) => Effect.tapError(answerSpent(effect(listed, input)), (error) => Effect.sync(() => seen(error))))
60
- };
61
- };
50
+ const watch = (objects) => ({
51
+ ...objects,
52
+ receive: (listed, input) => Effect.tapError(answerSpent(objects.receive(listed, input)), (error) => Effect.sync(() => seen(error)))
53
+ });
62
54
  const indexed = sealed.#indexed;
63
55
  if (indexed === void 0) return new SealedObjects(watch(sealed.#objects));
64
56
  const watched = watch(indexed);
@@ -95,7 +87,7 @@ var SealedObjects = class SealedObjects {
95
87
  * refused past its bound. Either costs the same whatever roots the tips don't reach.
96
88
  */
97
89
  static rootsReached(sealed, _whole, at, input) {
98
- const walked = Effect.suspend(() => walkedRoots(objectsFace(sealed.#objects), at, input));
90
+ const walked = Effect.suspend(() => walkedRoots(sealed.#objects, at, input));
99
91
  const fast = sealed.#indexed?.rootsReached;
100
92
  if (fast === void 0) return walked;
101
93
  return Effect.flatMap(fast(at, input), (reached) => reached === void 0 ? walked : Effect.succeed(reached));
@@ -291,7 +283,7 @@ const viewOf = /* @__PURE__ */ Effect.fnUntraced(function* (caller, resolved, ow
291
283
  parted ??= SealedObjects.parted(sealed, viewWhole, at.listed, asked, at.pushed);
292
284
  return parted?.[pick];
293
285
  };
294
- const seenAs = (pick) => Effect.map(viewedIn(caller, resolved.internalId, `${key}:${pick}`, both, part(pick)), objectsFace);
286
+ const seenAs = (pick) => viewedIn(caller, resolved.internalId, `${key}:${pick}`, both, part(pick));
295
287
  return {
296
288
  refusing: yield* seenAs("refusing"),
297
289
  shown: yield* seenAs("shown")
@@ -4,7 +4,7 @@ import { badCursor } from "../engine/reads.mjs";
4
4
  import { utf8 } from "../protocol/bytes/text.mjs";
5
5
  import { afterCommit } from "../store/call-count.mjs";
6
6
  import { listBound } from "../store/cursor-seal.mjs";
7
- import { storeCall } from "../store/errors.mjs";
7
+ import { storeCall, storeCommit } from "../store/errors.mjs";
8
8
  import { keptKey } from "../store/records.mjs";
9
9
  import { readRecord } from "../store/repo-record.mjs";
10
10
  import { newChangeId, repoScope } from "../store/scopes.mjs";
@@ -15,7 +15,7 @@ import { refViewIn } from "./ref-view.mjs";
15
15
  import { heldReceipt, receiptAnswered, receiptReads, receiptWrites } from "./receipts.mjs";
16
16
  import { fail } from "../contracts/result.mjs";
17
17
  import { CoreParts, QueueParts } from "./parts.mjs";
18
- import * as Clock$1 from "effect/Clock";
18
+ import * as Clock from "effect/Clock";
19
19
  import * as Effect from "effect/Effect";
20
20
  import { limits } from "@ref0/infra";
21
21
  // src/core/work.ts
@@ -45,29 +45,29 @@ const storeCursor = (text) => {
45
45
  return text.slice(start, start + Number(length[1]));
46
46
  };
47
47
  /** Commits a work write's receipt, and `git.repack` due to sweep it, at the scope's `expect`. */
48
- const commitReceipt = (internalId, write) => Effect.flatMap(Effect.service(CoreParts), (core) => storeCall(() => {
48
+ const commitReceipt = (internalId, write) => Effect.flatMap(Effect.service(CoreParts), (core) => {
49
49
  const receipt = receiptWrites(write.kept, write.answer, core.repackJobRow);
50
50
  const change = {
51
51
  id: newChangeId(),
52
52
  expect: write.expect
53
53
  };
54
- return core.store.commit(repoScope(internalId), {
54
+ return storeCommit(core.store.commit(repoScope(internalId), {
55
55
  ...change,
56
56
  put: [...receipt.put],
57
57
  jobs: [...receipt.jobs]
58
- });
59
- }));
58
+ }));
59
+ });
60
60
  /**
61
61
  * Marks a work write's receipt answered once the queue took the write, so the write sent again
62
- * answers as it did. The queue's calls join no commit, so a write stopped before this answers as
63
- * the queue does when it's sent again (Q150).
62
+ * answers as it did. The queue's calls join no commit, so a write stopped before this is sent
63
+ * again to a `pending` receipt, which `ranBefore` reads (Q150).
64
64
  */
65
65
  const keepAnswer = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, kept) {
66
66
  const core = yield* CoreParts;
67
67
  for (let attempt = 0; attempt < 5; attempt += 1) {
68
68
  const scope = repoScope(internalId);
69
69
  const write = {
70
- expect: (yield* storeCall(() => core.store.read(scope, []))).version,
70
+ expect: (yield* storeCall(core.store.read(scope, []))).version,
71
71
  kept,
72
72
  answer: { kind: "done" }
73
73
  };
@@ -79,6 +79,44 @@ const keepAnswer = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, kept
79
79
  tries: 5
80
80
  }));
81
81
  });
82
+ const unread = { kind: "unread" };
83
+ /** `job`'s failure, from the queue's failed jobs of its name, `failedFindPages` at most. */
84
+ const failureOf = /* @__PURE__ */ Effect.fnUntraced(function* (scope, job) {
85
+ const { jobs } = yield* QueueParts;
86
+ let after;
87
+ for (let page = 0; page < 10; page += 1) {
88
+ const request = {
89
+ state: "failed",
90
+ name: job.name
91
+ };
92
+ if (after !== void 0) request.page = { after };
93
+ const listed = yield* storeCall(jobs.list(scope, request));
94
+ const failed = listed.items.find((item) => item.key === job.key);
95
+ if (failed?.claim !== void 0) return {
96
+ kind: "failed",
97
+ claim: failed.claim
98
+ };
99
+ if (failed !== void 0) return unread;
100
+ if (listed.next === void 0) return { kind: "none" };
101
+ after = listed.next;
102
+ }
103
+ return unread;
104
+ });
105
+ /**
106
+ * Whether a work write sent again to its `pending` receipt finds the first send's queue call ran:
107
+ * the receipt names the claim its job had failed under, and the job is no longer failed under it,
108
+ * retried, discarded, or failed again since. Claims are numbered afresh in a scope, never reused,
109
+ * so a failure under the same claim is the one the first send found. A receipt that names none,
110
+ * or a failure past `failedFindPages`, can't tell, and the write calls the queue again.
111
+ */
112
+ const ranBefore = (held, now) => {
113
+ if (held.failed === void 0) return false;
114
+ switch (now.kind) {
115
+ case "failed": return now.claim !== held.failed;
116
+ case "none": return true;
117
+ case "unread": return false;
118
+ }
119
+ };
82
120
  /**
83
121
  * A page of the jobs in `internalId`'s scope, as `list` and `listById` answer them, those `shown`
84
122
  * keeps. With `access`, a cursor is sealed for `list`'s page of the repo in its state: the store's
@@ -102,7 +140,7 @@ const jobsPage = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, list,
102
140
  request.page = page;
103
141
  }
104
142
  const { jobs } = yield* QueueParts;
105
- const listed = yield* storeCall(() => jobs.list(repoScope(internalId), request));
143
+ const listed = yield* storeCall(jobs.list(repoScope(internalId), request));
106
144
  const items = listed.items.filter(shown);
107
145
  if (listed.next === void 0) return { items };
108
146
  return {
@@ -130,7 +168,7 @@ const workCalls = (bound) => {
130
168
  kind,
131
169
  job.name,
132
170
  job.key
133
- ], yield* Clock$1.currentTimeMillis, "requestKey");
171
+ ], yield* Clock.currentTimeMillis, "requestKey");
134
172
  for (let attempt = 0; attempt < 5; attempt += 1) {
135
173
  const opened = yield* openRepo(caller, operation, receiptReads(kept), input.internalId, "skip");
136
174
  const { internalId, snapshot } = opened;
@@ -138,18 +176,25 @@ const workCalls = (bound) => {
138
176
  const seen = seesJob(yield* refViewIn(caller, repoOf), job);
139
177
  const held = yield* heldReceipt(snapshot.results.slice(1), kept);
140
178
  if (held !== void 0 && receiptAnswered(held)) return;
179
+ const scope = repoScope(internalId);
180
+ const failure = kept !== void 0 && seen ? yield* failureOf(scope, job) : unread;
181
+ if (kept !== void 0 && held !== void 0 && ranBefore(held, failure)) {
182
+ yield* afterCommit(keepAnswer(internalId, kept));
183
+ return;
184
+ }
141
185
  if (kept !== void 0 && held === void 0) {
186
+ const answer = { kind: "pending" };
187
+ if (failure.kind === "failed") answer.failed = failure.claim;
142
188
  const write = {
143
189
  expect: snapshot.version,
144
190
  kept,
145
- answer: "pending"
191
+ answer
146
192
  };
147
193
  if (!(yield* commitReceipt(internalId, write)).ok) continue;
148
194
  }
149
- const scope = repoScope(internalId);
150
195
  if (!seen && kind === "work.retry") return yield* fail("NOT_FOUND", `No job '${job.name}' '${job.key}'`);
151
196
  if (!seen) {} else if (kind === "work.discard" && isDeliverJob(job) && keepsEvents(core.events)) yield* skipFailed(core.store, jobs, scope, job, core.events.deliveries);
152
- else yield* storeCall(() => kind === "work.retry" ? jobs.retry(scope, job) : jobs.discard(scope, job));
197
+ else yield* storeCall(kind === "work.retry" ? jobs.retry(scope, job) : jobs.discard(scope, job));
153
198
  if (kept !== void 0) yield* afterCommit(keepAnswer(internalId, kept));
154
199
  return;
155
200
  }
package/dist/effect.d.mts CHANGED
@@ -2,17 +2,8 @@ import { EffectCalls, GitCaller, GitStore } from "./contracts/services.mjs";
2
2
  import { IndexCalls, IndexReachInput, IndexReached, IndexStatus, IndexTip, IndexTry, IndexTryInput } from "./contracts/objects.mjs";
3
3
  import { Actor } from "./contracts/actors.mjs";
4
4
  import { RepoName } from "./contracts/ids.mjs";
5
- import { CallAllowance, CallBudget, CallBudgetOptions } from "./store/call-count.mjs";
5
+ import { CallAllowance } from "./contracts/call-allowance.mjs";
6
+ import { CallBudget, CallBudgetOptions } from "./store/call-count.mjs";
6
7
  import { commitCallsMost, storeCall } from "./store/errors.mjs";
7
8
  import { bucketCall } from "./storage/calls.mjs";
8
- import { GitRestApi } from "./rest/api.mjs";
9
- import { GitCallerMiddleware, GitRestServices, RestServerSeam } from "./rest/caller.mjs";
10
- import { GitErrors } from "./rest/errors.mjs";
11
- import { GitRestHandlers } from "./rest/handlers.mjs";
12
- import { MeApiGroup } from "./rest/me.mjs";
13
- import { RefsApiGroup } from "./rest/refs.mjs";
14
- import { ReposApiGroup } from "./rest/repos.mjs";
15
- import { TokensApiGroup } from "./rest/tokens.mjs";
16
- import { WorkApiGroup } from "./rest/work.mjs";
17
- import { SeamAuthorizeInput, TokenRevokeCheck } from "./core/seam.mjs";
18
- export { Actor, type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, type IndexCalls, type IndexReachInput, type IndexReached, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, MeApiGroup, RefsApiGroup, RepoName, ReposApiGroup, type RestServerSeam, type SeamAuthorizeInput, type TokenRevokeCheck, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
9
+ export { Actor, type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitStore, type IndexCalls, type IndexReachInput, type IndexReached, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, RepoName, bucketCall, commitCallsMost, storeCall };
package/dist/effect.mjs CHANGED
@@ -4,13 +4,4 @@ import { RepoName } from "./contracts/ids.mjs";
4
4
  import { CallBudget } from "./store/call-count.mjs";
5
5
  import { commitCallsMost, storeCall } from "./store/errors.mjs";
6
6
  import { bucketCall } from "./storage/calls.mjs";
7
- import { GitRestApi } from "./rest/api.mjs";
8
- import { GitCallerMiddleware, GitRestServices } from "./rest/caller.mjs";
9
- import { GitErrors } from "./rest/errors.mjs";
10
- import { GitRestHandlers } from "./rest/handlers.mjs";
11
- import { MeApiGroup } from "./rest/me.mjs";
12
- import { RefsApiGroup } from "./rest/refs.mjs";
13
- import { ReposApiGroup } from "./rest/repos.mjs";
14
- import { TokensApiGroup } from "./rest/tokens.mjs";
15
- import { WorkApiGroup } from "./rest/work.mjs";
16
- export { Actor, CallBudget, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, MeApiGroup, RefsApiGroup, RepoName, ReposApiGroup, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
7
+ export { Actor, CallBudget, GitCaller, GitStore, RepoName, bucketCall, commitCallsMost, storeCall };
@@ -1,10 +1,11 @@
1
- import { gitError, isGitError } from "../contracts/result.mjs";
1
+ import { gitError, isGitError, pastRoots } from "../contracts/result.mjs";
2
2
  // src/engine/failures.ts
3
3
  /** A diff's failure as Git's error: the read's own, or the reader's, a limit as `limit`. */
4
4
  const fromDiff = (limit) => (error) => {
5
5
  if (isGitError(error)) return error;
6
6
  switch (error.reason) {
7
7
  case "missing": return gitError("NOT_FOUND", error.message);
8
+ case "past-roots": return pastRoots(error.message, error.oid ?? "");
8
9
  case "malformed":
9
10
  case "unreadable": return gitError("DATA_LOSS", error.message);
10
11
  case "diff-limit": return gitError("RESOURCE_EXHAUSTED", error.message, { context: { reason: limit } });
@@ -3,7 +3,7 @@ import { sha1Of } from "../protocol/bytes/sha1.mjs";
3
3
  import { utf8 } from "../protocol/bytes/text.mjs";
4
4
  import { defaultDiffLimits } from "../protocol/diff/read.mjs";
5
5
  import { fromAnswer } from "../contracts/calls-spent.mjs";
6
- import * as Clock$1 from "effect/Clock";
6
+ import * as Clock from "effect/Clock";
7
7
  import * as Effect from "effect/Effect";
8
8
  import * as Hex from "effect/encoding/Hex";
9
9
  // src/engine/reads.ts
@@ -37,7 +37,7 @@ const limitsOf = (limits = {}) => {
37
37
  });
38
38
  };
39
39
  /** A call's deadline, `milliseconds` from now. */
40
- const deadlineOf = (milliseconds, reason) => Effect.map(Clock$1.currentTimeMillis, (now) => ({
40
+ const deadlineOf = (milliseconds, reason) => Effect.map(Clock.currentTimeMillis, (now) => ({
41
41
  at: now + milliseconds,
42
42
  milliseconds,
43
43
  reason
@@ -52,7 +52,7 @@ const stepDeadline = (milliseconds, reason, call) => call === void 0 ? deadlineO
52
52
  });
53
53
  const ranPast = (deadline) => fail("RESOURCE_EXHAUSTED", `The call ran past ${deadline.milliseconds} ms`, { context: { reason: deadline.reason } });
54
54
  /** Fails once `deadline` has passed: a check between steps no timer can interrupt. */
55
- const within = (deadline) => Effect.flatMap(Clock$1.currentTimeMillis, (now) => now > deadline.at ? ranPast(deadline) : Effect.void);
55
+ const within = (deadline) => Effect.flatMap(Clock.currentTimeMillis, (now) => now > deadline.at ? ranPast(deadline) : Effect.void);
56
56
  /**
57
57
  * `objects` as the diff's reader batches through it, as `readThrough` reads: the call's deadline
58
58
  * checked first, its signal passed on, its error result a failure.
@@ -76,7 +76,7 @@ const readThrough = (read, deadline) => (oid) => Effect.andThen(within(deadline)
76
76
  * that can't fire meanwhile. A step of a longer call takes the call's deadline with its own
77
77
  * `reason`.
78
78
  */
79
- const timed = (effect, deadline) => Effect.flatMap(Clock$1.currentTimeMillis, (now) => Effect.timeoutOrElse(effect, {
79
+ const timed = (effect, deadline) => Effect.flatMap(Clock.currentTimeMillis, (now) => Effect.timeoutOrElse(effect, {
80
80
  duration: Math.max(0, deadline.at - now),
81
81
  orElse: () => ranPast(deadline)
82
82
  })).pipe(Effect.catch((error) => Effect.andThen(within(deadline), Effect.fail(error))), Effect.tap(() => within(deadline)));
@@ -1,16 +1,16 @@
1
- import { Clock } from "../contracts/promises.mjs";
2
1
  import { Caller } from "../contracts/actors.mjs";
3
2
  import "../contracts/events.mjs";
4
3
  import { RepoName } from "../contracts/ids.mjs";
5
4
  import { GitError } from "../contracts/result.mjs";
6
5
  import { Authorize } from "../contracts/authorize.mjs";
7
6
  import { CoreParts } from "../core/parts.mjs";
7
+ import * as EffectClock from "effect/Clock";
8
8
  import * as Effect from "effect/Effect";
9
9
  import * as Context from "effect/Context";
10
10
  import "effect/Stream";
11
11
  /** What a stream reads beside the server's core: the adapter's clock, and the server's guard. */
12
12
  export interface FeedFields {
13
- readonly clock: Clock;
13
+ readonly clock: EffectClock.Clock;
14
14
  /** Fails once the server is closed. */
15
15
  readonly guard: Effect.Effect<void, GitError>;
16
16
  /** Aborts as the server closes: it ends the stream, which errors with the closed rejection. */