@ref0/git 0.8.0 → 0.10.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 (102) hide show
  1. package/dist/contracts/calls-spent.d.mts +2 -12
  2. package/dist/contracts/calls-spent.mjs +4 -5
  3. package/dist/contracts/commits.d.mts +14 -2
  4. package/dist/contracts/commits.mjs +22 -3
  5. package/dist/contracts/events.d.mts +70 -4
  6. package/dist/contracts/events.mjs +27 -3
  7. package/dist/contracts/git.d.mts +13 -3
  8. package/dist/contracts/objects.d.mts +18 -0
  9. package/dist/contracts/queue.d.mts +3 -2
  10. package/dist/contracts/queue.mjs +4 -2
  11. package/dist/contracts/refs.mjs +3 -1
  12. package/dist/core/ancestry.mjs +5 -4
  13. package/dist/core/events/seen.mjs +5 -4
  14. package/dist/core/index-job.mjs +23 -1
  15. package/dist/core/index-lost.d.mts +11 -0
  16. package/dist/core/index-lost.mjs +55 -0
  17. package/dist/core/job-view.mjs +20 -0
  18. package/dist/core/objects/commit-writes.mjs +1 -1
  19. package/dist/core/objects/commits.mjs +10 -9
  20. package/dist/core/objects/merges.mjs +1 -1
  21. package/dist/core/objects/reading.mjs +28 -13
  22. package/dist/core/objects/trees.mjs +1 -1
  23. package/dist/core/parts.d.mts +7 -0
  24. package/dist/core/publish.mjs +9 -5
  25. package/dist/core/purge.mjs +16 -3
  26. package/dist/core/push.mjs +27 -11
  27. package/dist/core/ref-view.mjs +1 -25
  28. package/dist/core/repack.mjs +36 -14
  29. package/dist/core/view.d.mts +10 -1
  30. package/dist/core/view.mjs +15 -6
  31. package/dist/core/work.mjs +47 -4
  32. package/dist/effect.d.mts +2 -3
  33. package/dist/effect.mjs +2 -3
  34. package/dist/engine/commits.mjs +4 -3
  35. package/dist/engine/merge-bases.mjs +5 -3
  36. package/dist/engine/merge.mjs +4 -3
  37. package/dist/engine/parts.d.mts +1 -0
  38. package/dist/engine/parts.mjs +1 -1
  39. package/dist/engine/walk.mjs +62 -20
  40. package/dist/http/core-parts.mjs +17 -8
  41. package/dist/index.d.mts +4 -4
  42. package/dist/index.mjs +3 -3
  43. package/dist/lfs/objects.mjs +7 -4
  44. package/dist/lfs/upkeep.mjs +6 -5
  45. package/dist/lfs/upload-most.mjs +8 -2
  46. package/dist/protocol/bytes/streams.mjs +84 -2
  47. package/dist/protocol/diff/read.d.mts +1 -0
  48. package/dist/protocol/diff/read.mjs +5 -2
  49. package/dist/protocol/objects/commit.d.mts +7 -0
  50. package/dist/protocol/objects/commit.mjs +5 -1
  51. package/dist/queue/advance.mjs +39 -10
  52. package/dist/queue/host.d.mts +4 -0
  53. package/dist/queue/layer.mjs +4 -2
  54. package/dist/queue/limits.mjs +18 -2
  55. package/dist/queue/rows.mjs +2 -1
  56. package/dist/queue/trim.mjs +2 -2
  57. package/dist/rest/commits.d.mts +202 -198
  58. package/dist/rest/forks.d.mts +99 -99
  59. package/dist/rest/refs.d.mts +144 -144
  60. package/dist/rest/repos.d.mts +48 -48
  61. package/dist/rest/topics.d.mts +112 -112
  62. package/dist/rest/trees.d.mts +58 -58
  63. package/dist/rest/wire.d.mts +19 -1
  64. package/dist/rest/work.d.mts +39 -39
  65. package/dist/server/joined.d.mts +11 -5
  66. package/dist/server/joined.mjs +3 -2
  67. package/dist/server/registry.mjs +11 -5
  68. package/dist/server/server.mjs +16 -4
  69. package/dist/storage/index-bitmaps.mjs +16 -10
  70. package/dist/storage/index-build.mjs +61 -13
  71. package/dist/storage/index-graph.d.mts +1 -0
  72. package/dist/storage/index-graph.mjs +29 -5
  73. package/dist/storage/index-layers.d.mts +1 -0
  74. package/dist/storage/index-layers.mjs +5 -2
  75. package/dist/storage/index-reach.mjs +7 -5
  76. package/dist/storage/index-remap.mjs +5 -5
  77. package/dist/storage/index-visible.mjs +16 -5
  78. package/dist/storage/links.mjs +3 -3
  79. package/dist/storage/pack-order.d.mts +1 -0
  80. package/dist/storage/pack-order.mjs +18 -1
  81. package/dist/storage/prune-walk.mjs +5 -2
  82. package/dist/storage/prune.mjs +107 -37
  83. package/dist/storage/receive-bounds.mjs +3 -2
  84. package/dist/storage/visible.mjs +3 -2
  85. package/dist/storage/walk.d.mts +1 -0
  86. package/dist/storage/walk.mjs +9 -5
  87. package/dist/storage/wants.mjs +17 -11
  88. package/dist/store/call-count.d.mts +8 -0
  89. package/dist/store/call-count.mjs +15 -7
  90. package/dist/store/errors.d.mts +7 -1
  91. package/dist/store/errors.mjs +7 -1
  92. package/dist/store/job-try.mjs +3 -1
  93. package/dist/store/records.mjs +17 -2
  94. package/dist/store/repo-record.mjs +9 -2
  95. package/dist/store/scopes.mjs +10 -2
  96. package/dist/sync/bound.d.mts +1 -1
  97. package/dist/sync/import.mjs +1 -1
  98. package/dist/sync/layer.mjs +4 -7
  99. package/dist/sync/mirror.mjs +1 -1
  100. package/dist/topics/advance.mjs +4 -4
  101. package/dist/topics/layer.mjs +1 -1
  102. package/package.json +3 -3
@@ -1,7 +1,7 @@
1
1
  import { objectsReadMost } from "../contracts/object-values.mjs";
2
2
  import { gitError } from "../contracts/result.mjs";
3
3
  import { hexOf } from "../protocol/bytes/hex.mjs";
4
- import { decodeCommit } from "../protocol/objects/commit.mjs";
4
+ import { decodeCommit, noRepoRoots, parentsWithin } from "../protocol/objects/commit.mjs";
5
5
  import { decodeTag, readTagTarget } from "../protocol/objects/tag.mjs";
6
6
  import { oidBytes } from "../protocol/packs/idx.mjs";
7
7
  import { effectOf, walkObjects } from "./calls.mjs";
@@ -97,14 +97,17 @@ const nowhere = {
97
97
  * walk reads trees; a tag to what it tags; a tree to its folders, and to its files, which are
98
98
  * reached unread. A blob, or a tree in a walk that reads none, leads nowhere, its bytes unread.
99
99
  */
100
- /** Where a walk goes from an object read whole: a blob, or a tree it doesn't walk, goes nowhere. */
101
- const stepsOfBytes = /* @__PURE__ */ Effect.fnUntraced(function* (object, bytes, readsTrees) {
100
+ /**
101
+ * Where a walk goes from an object read whole: a blob, or a tree it doesn't walk, goes nowhere. One
102
+ * of `roots` leads to its tree alone, never its parents.
103
+ */
104
+ const stepsOfBytes = /* @__PURE__ */ Effect.fnUntraced(function* (object, bytes, readsTrees, roots) {
102
105
  if (object.type === "blob" || object.type === "tree" && !readsTrees) return nowhere;
103
106
  const failed = (error) => unreadable(object, error.message);
104
107
  if (object.type === "commit") {
105
108
  const commit = yield* Effect.mapError(decodeCommit(bytes), failed);
106
109
  return {
107
- history: commit.parents,
110
+ history: parentsWithin(roots, object.oid, commit.parents),
108
111
  trees: readsTrees ? [commit.tree] : [],
109
112
  reached: []
110
113
  };
@@ -126,12 +129,12 @@ const stepsOfBytes = /* @__PURE__ */ Effect.fnUntraced(function* (object, bytes,
126
129
  * Where a walk goes from an object streamed: a blob, or a tree it doesn't walk, is cancelled
127
130
  * unread, so a tag's blob of any size costs its header alone.
128
131
  */
129
- const stepsOf = /* @__PURE__ */ Effect.fnUntraced(function* (object, readsTrees) {
132
+ const stepsOf = /* @__PURE__ */ Effect.fnUntraced(function* (object, readsTrees, roots = noRepoRoots) {
130
133
  if (object.type === "blob" || object.type === "tree" && !readsTrees) {
131
134
  yield* Effect.promise(() => object.bytes.cancel());
132
135
  return nowhere;
133
136
  }
134
- return yield* stepsOfBytes(object, yield* bytesOf(object), readsTrees);
137
+ return yield* stepsOfBytes(object, yield* bytesOf(object), readsTrees, roots);
135
138
  });
136
139
  /**
137
140
  * Every object a walk reads next from `steps`, a tag's object among them: what the visible set's
@@ -254,9 +257,10 @@ const lookedUp = /* @__PURE__ */ Effect.fnUntraced(function* (input, packed) {
254
257
  });
255
258
  /**
256
259
  * A read's meeting with an index that fails its own checks, `DATA_LOSS`: one error line in the
257
- * log, so the host hears of it, while the read walks as with no index.
260
+ * log, so the host hears of it, then `lost`, the core's ask for the row's rebuild, while the read
261
+ * walks as with no index.
258
262
  */
259
- const indexUnreadable = (repo, error) => Effect.logError(`The reachability index of repo ${repo} is unreadable, so its reads walk: ${error.message}`);
263
+ const indexUnreadable = (repo, error, lost = Effect.void) => Effect.logError(`The reachability index of repo ${repo} is unreadable, so its reads walk: ${error.message}`).pipe(Effect.andThen(lost));
260
264
  /**
261
265
  * The first of `wants` no readable ref reaches, or `undefined`. A want a ref names passes with no
262
266
  * read, as nearly every fetch's do. With the repo's reachability index, each other want is
@@ -275,8 +279,9 @@ const unreachableWant = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
275
279
  row: index.row,
276
280
  tips: [...input.tips],
277
281
  wants: asked,
282
+ roots: input.roots,
278
283
  ...signal
279
- }).pipe(Effect.catchIf((error) => error.code === "DATA_LOSS", (error) => indexUnreadable(input.listed.repo, error).pipe(Effect.as({ answers: /* @__PURE__ */ new Map() }))));
284
+ }).pipe(Effect.catchIf((error) => error.code === "DATA_LOSS", (error) => indexUnreadable(input.listed.repo, error, index.lost).pipe(Effect.as({ answers: /* @__PURE__ */ new Map() }))));
280
285
  if (pastLimit !== void 0 && asked.some((want) => answers.get(want) !== true)) return yield* Effect.fail(refused === true ? updatesRefused(pastLimit) : updatePending(pastLimit));
281
286
  const unknown = asked.filter((want) => answers.get(want) === void 0);
282
287
  const walked = unknown.length === 0 ? void 0 : yield* walkedWant({
@@ -303,6 +308,7 @@ const walkedWant = /* @__PURE__ */ Effect.fnUntraced(function* (given) {
303
308
  const looked = yield* lookedUp(input, packed);
304
309
  if (looked.absent !== void 0) return looked.absent;
305
310
  const most = input.most ?? 1e4;
311
+ const roots = input.roots ?? noRepoRoots;
306
312
  let left = packed.count;
307
313
  let deepLeft = looked.deep;
308
314
  const call = input.signal === void 0 ? {} : { signal: input.signal };
@@ -357,7 +363,7 @@ const walkedWant = /* @__PURE__ */ Effect.fnUntraced(function* (given) {
357
363
  yield* Effect.forEach(tagged, (oid) => Effect.flatMap(input.objects.read(input.listed, {
358
364
  oid,
359
365
  ...call
360
- }), (object) => object === void 0 ? Effect.void : Effect.map(stepsOf(object, readsTrees), follow)), {
366
+ }), (object) => object === void 0 ? Effect.void : Effect.map(stepsOf(object, readsTrees, roots), follow)), {
361
367
  concurrency: 16,
362
368
  discard: true
363
369
  });
@@ -371,7 +377,7 @@ const walkedWant = /* @__PURE__ */ Effect.fnUntraced(function* (given) {
371
377
  });
372
378
  let held = 0;
373
379
  for (const object of read.objects.values()) held += object.bytes.byteLength;
374
- yield* Effect.ensuring(Effect.forEach(read.objects.values(), (object) => Effect.map(stepsOfBytes(object, object.bytes, readsTrees), follow), { discard: true }), Effect.sync(() => allotment.shrink(held)));
380
+ yield* Effect.ensuring(Effect.forEach(read.objects.values(), (object) => Effect.map(stepsOfBytes(object, object.bytes, readsTrees, roots), follow), { discard: true }), Effect.sync(() => allotment.shrink(held)));
375
381
  asked = [...read.left];
376
382
  }
377
383
  }
@@ -88,6 +88,14 @@ export declare class CallBudget extends /* @__PURE__ */ CallBudget_base {
88
88
  * nothing.
89
89
  */
90
90
  static readonly charged: (http: HttpClient.HttpClient) => HttpClient.HttpClient;
91
+ /**
92
+ * `effect`, run with `calls` store calls held back for what must follow it, such as the commit
93
+ * that records a send: charged before it starts, so a budget in scope that can't cover them and
94
+ * `effect`'s own calls refuses before `effect`'s first call goes, with the defect `CallsSpent`,
95
+ * as a store call is, and given back once it ends, for the calls they were held for. With
96
+ * nothing in scope, it holds nothing.
97
+ */
98
+ static readonly withReserved: (calls: number) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
91
99
  /**
92
100
  * Whether the budget in scope, or one it nests in, has spent a kind of call it limits, so the
93
101
  * next call of that kind is refused: a host's call answers `RESOURCE_EXHAUSTED`,
@@ -237,6 +237,14 @@ var CallBudget = class CallBudget extends (/* @__PURE__ */ Context.Service()("@r
237
237
  */
238
238
  static charged = (http) => HttpClient.transform(http, (effect) => Effect.andThen(chargeCall("fetch"), effect));
239
239
  /**
240
+ * `effect`, run with `calls` store calls held back for what must follow it, such as the commit
241
+ * that records a send: charged before it starts, so a budget in scope that can't cover them and
242
+ * `effect`'s own calls refuses before `effect`'s first call goes, with the defect `CallsSpent`,
243
+ * as a store call is, and given back once it ends, for the calls they were held for. With
244
+ * nothing in scope, it holds nothing.
245
+ */
246
+ static withReserved = (calls) => (effect) => Effect.flatMap(heldCall("store", calls), (given) => Effect.ensuring(effect, given));
247
+ /**
240
248
  * Whether the budget in scope, or one it nests in, has spent a kind of call it limits, so the
241
249
  * next call of that kind is refused: a host's call answers `RESOURCE_EXHAUSTED`,
242
250
  * `reason: 'call-budget'`.
@@ -402,19 +410,19 @@ const chargeCalls = (kind, calls) => Effect.flatMap(Effect.all([
402
410
  return Effect.void;
403
411
  });
404
412
  /**
405
- * One call of `kind` held back for a call to come, charged now as `chargeCall` charges it, so
406
- * the calls before it stop one short: what it gives is that call given back, once, to the counts
407
- * it was charged to, right before the call it was held for (#647).
413
+ * `calls` calls of `kind` held back for calls to come, charged now as `chargeCalls` charges them,
414
+ * so the calls before them stop that many short: what it gives is those calls given back, once, to
415
+ * the counts they were charged to, right before the calls they were held for (#647).
408
416
  */
409
- const heldCall = (kind) => Effect.flatMap(Effect.all([requestCount, inScope]), ([request, budget]) => {
417
+ const heldCall = (kind, calls = 1) => Effect.flatMap(Effect.all([requestCount, inScope]), ([request, budget]) => {
410
418
  let held = true;
411
419
  const given = Effect.sync(() => {
412
420
  if (!held) return;
413
421
  held = false;
414
- if (request !== void 0) add(request, kind, -1);
415
- for (const made of countsOf(chainOf(budget))) add(made, kind, -1);
422
+ if (request !== void 0) add(request, kind, -calls);
423
+ for (const made of countsOf(chainOf(budget))) add(made, kind, -calls);
416
424
  });
417
- return Effect.as(chargeCall(kind), given);
425
+ return Effect.as(chargeCalls(kind, calls), given);
418
426
  });
419
427
  /** The budget that refused each `CallsSpent` a budget refused, which `spentBudget` reads. */
420
428
  const spentBudgets = /* @__PURE__ */ new WeakMap();
@@ -13,4 +13,10 @@ import "effect/Stream";
13
13
  export declare function storeCall<A>(run: () => Promise<A>): Effect.Effect<A, GitError>;
14
14
  export declare function storeCall<A, E, R>(run: Effect.Effect<A, E, R>, options?: {
15
15
  readonly resend?: boolean;
16
- }): Effect.Effect<A, GitError, R>;
16
+ }): Effect.Effect<A, GitError, R>;
17
+ /**
18
+ * The most store calls one try at a write makes through `storeCall`: its read, the commit it
19
+ * decides, and that commit sent again as often as a lost reply may send it. A caller that must
20
+ * keep room for a write, such as a step that records a send, holds this many for each try.
21
+ */
22
+ export declare const commitCallsMost: number;
@@ -136,6 +136,12 @@ const effectStoreCall = /* @__PURE__ */ Effect.fnUntraced(function* (run, resend
136
136
  yield* chargeResends(1);
137
137
  }
138
138
  });
139
+ /**
140
+ * The most store calls one try at a write makes through `storeCall`: its read, the commit it
141
+ * decides, and that commit sent again as often as a lost reply may send it. A caller that must
142
+ * keep room for a write, such as a step that records a send, holds this many for each try.
143
+ */
144
+ const commitCallsMost = 3;
139
145
  /** What a commit sent `commitResendsMost` times again, with no reply, throws: it may have landed. */
140
146
  var Unsettled = class extends Error {
141
147
  name = "Unsettled";
@@ -248,4 +254,4 @@ const endedEarly = (cause) => {
248
254
  cause
249
255
  });
250
256
  };
251
- export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody, resending, resultCall, routeEdge, storeCall, storeWatch, thrownError };
257
+ export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, commitCallsMost, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody, resending, resultCall, routeEdge, storeCall, storeWatch, thrownError };
@@ -118,6 +118,8 @@ const gitJob = (job, handler, options = {}) => {
118
118
  remakes.set(definition, made);
119
119
  return definition;
120
120
  };
121
+ /** `job`, `handler` and `options` as `JobParts`. */
122
+ const jobParts = (job, handler, options) => (take) => take(job, handler, options);
121
123
  /**
122
124
  * `jobs`, each `gitJob` made remade in `limits`, a server's, and any other as it is: what a server
123
125
  * registers, so each try counts its calls against the adapter's bound.
@@ -127,4 +129,4 @@ const jobsWithin = (limits, jobs) => jobs.map((job) => remakes.get(job)?.(limits
127
129
  const currentRepo = Effect.map(CurrentJob.current, jobRepo);
128
130
  /** `step` over the try's store, fenced by its claim and gated by the server's door, and its repo. */
129
131
  const repoTry = (step) => Effect.flatMap(Effect.all([CurrentJob.store, currentRepo]), ([store, repo]) => step(store, repo));
130
- export { currentRepo, gitJob, jobLimitsOf, jobsWithin, repoTry, stepTooLarge };
132
+ export { currentRepo, gitJob, jobLimitsOf, jobParts, jobsWithin, repoTry, stepTooLarge };
@@ -1,4 +1,4 @@
1
- import { InternalRepoId, maxWriteKeyLength } from "../contracts/ids.mjs";
1
+ import { InternalRepoId, Oid, maxWriteKeyLength } from "../contracts/ids.mjs";
2
2
  import { fail } from "../contracts/result.mjs";
3
3
  import { Pack } from "../contracts/store.mjs";
4
4
  import { utf8 } from "../protocol/bytes/text.mjs";
@@ -167,6 +167,21 @@ const StoredRepo = /* @__PURE__ */ Schema.Struct({
167
167
  refIndexBuilding: Schema.optionalKey(RefIndexBuilding)
168
168
  });
169
169
  /**
170
+ * The most roots a repo keeps in its `repo/roots` row, 10,000: an import's last segment's boundary
171
+ * is what becomes the repo's roots when it lands, the row's only writer, so `receiveBoundaryMost`
172
+ * is this bound too. At 43 B an ID as JSON, its quotes and comma with it, the row is at most 430 KB.
173
+ */
174
+ const repoRootsMost = 1e4;
175
+ /** A root's ID as the row keeps it: 40 lowercase hex digits. */
176
+ const RootId = Oid.check(Schema.isPattern(/^[0-9a-f]{40}$/));
177
+ /**
178
+ * A repo's roots, `repo/roots` in its scope: the commits it holds without their parents, as Git's
179
+ * `shallow` file names them, at most `repoRootsMost`, which their only writer, an import's landing,
180
+ * holds them to. Every walk sees a root as having no parents (`RepoRoots`). A row of any other ID,
181
+ * or past the bound, doesn't decode, so its read is `DATA_LOSS`.
182
+ */
183
+ const RepoRootsRow = /* @__PURE__ */ Schema.Struct({ roots: Schema.Array(RootId).check(Schema.isMaxLength(repoRootsMost)) });
184
+ /**
170
185
  * A rename's record once it lost its new name to a repo made there first: the name it left, which
171
186
  * its entry still holds, since a rename leaves its old name only when it wins the new one, at a
172
187
  * revision past the tombstone a win would have left there, with the rename's receipt and its index row deleted.
@@ -256,4 +271,4 @@ const LooseTally = /* @__PURE__ */ Schema.Struct({
256
271
  const PackRow = Pack.mapFields(Struct.omit(["id"]));
257
272
  /** A row's ID by its sequence number, zero-padded so the rows read in order. */
258
273
  const versionId = (sequence) => String(sequence).padStart(16, "0");
259
- export { CatalogueEntry, CreatedRow, ForkOf, ForkRow, KeptRepoInfo, LooseTally, PackRow, PrunedMark, ReachedMark, RefIndexBuilding, RenamedFrom, StatsTime, StoredRepo, callerKey, checkWriteKey, importJobName, keptKey, keyDigest, keyKept, keyLive, markHolds, mirrorJobName, takenBack, versionId };
274
+ export { CatalogueEntry, CreatedRow, ForkOf, ForkRow, KeptRepoInfo, LooseTally, PackRow, PrunedMark, ReachedMark, RefIndexBuilding, RenamedFrom, RepoRootsRow, StatsTime, StoredRepo, callerKey, checkWriteKey, importJobName, keptKey, keyDigest, keyKept, keyLive, markHolds, mirrorJobName, repoRootsMost, takenBack, versionId };
@@ -1,8 +1,9 @@
1
+ import { noRepoRoots } from "../protocol/objects/commit.mjs";
1
2
  import { checkChurn, decodeRecord, entryOf, project } from "./catalogue.mjs";
2
3
  import { afterCommit } from "./call-count.mjs";
3
4
  import { afterWrites, decodeRow, storeCall } from "./errors.mjs";
4
5
  import { listJobRow } from "./list-job.mjs";
5
- import { LooseTally, StatsTime } from "./records.mjs";
6
+ import { LooseTally, RepoRootsRow, StatsTime } from "./records.mjs";
6
7
  import { looseKey, maintainedKey, newChangeId, pushedKey, repoScope, selfKey } from "./scopes.mjs";
7
8
  import * as Effect from "effect/Effect";
8
9
  // src/store/repo-record.ts
@@ -15,6 +16,12 @@ const readRecord = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalI
15
16
  snapshot
16
17
  };
17
18
  });
19
+ /** The roots a read of `repoRootsKey` gave, `rows`: none when the repo has no row. */
20
+ const rootsOf = (rows) => {
21
+ const [row] = rows ?? [];
22
+ if (row === void 0) return Effect.succeed(noRepoRoots);
23
+ return Effect.map(decodeRow(RepoRootsRow, row, "The repo's roots"), ({ roots }) => new Set(roots));
24
+ };
18
25
  /**
19
26
  * The first of a repo write's two commits: its record, in its own scope, with `git.list` saved
20
27
  * beside it, so the catalogue's projection happens even if the second never does.
@@ -116,4 +123,4 @@ const repoStats = (record, refs, packs, times, readyBytes) => {
116
123
  if (times.maintained !== void 0) stats.maintainedAt = times.maintained;
117
124
  return stats;
118
125
  };
119
- export { commitRecord, decodeStats, looseRows, readRecord, repoStats, seenTimes, timeRow, writeRecord };
126
+ export { commitRecord, decodeStats, looseRows, readRecord, repoStats, rootsOf, seenTimes, timeRow, writeRecord };
@@ -43,7 +43,7 @@ const collections = {
43
43
  publicCreated: "public-created",
44
44
  /** In `git/repos`: the server's own keys, by use: `cursor`, which seals every list's cursor. */
45
45
  keys: "keys",
46
- /** In a repo's scope: its own record, `self`. */
46
+ /** In a repo's scope: its own record, `self`, and its roots, `roots`. */
47
47
  repo: "repo",
48
48
  /** In a repo's scope: each ref's `RefRow`, by its full name. */
49
49
  refs: "refs",
@@ -123,6 +123,14 @@ const selfKey = {
123
123
  id: "self"
124
124
  };
125
125
  /**
126
+ * A repo's roots, its `RepoRootsRow`, read with every open whose reads walk parents. Only an
127
+ * import's landing writes it, before its first ref page publishes; a repo with no row has none.
128
+ */
129
+ const repoRootsKey = {
130
+ collection: collections.repo,
131
+ id: "roots"
132
+ };
133
+ /**
126
134
  * The repo's prune mark: a new ID each time a prune drops objects. A push reads it first and
127
135
  * again at its commit, and fails if it moved, so no ref names an object a prune dropped (Q270).
128
136
  */
@@ -176,4 +184,4 @@ const jobRepo = (job) => {
176
184
  };
177
185
  /** A commit's own ID, for a change no caller's key names. */
178
186
  const newChangeId = () => randomText(16);
179
- export { catalogueScope, collections, forkId, jobRepo, looseKey, maintainedKey, newChangeId, newInternalId, prunedKey, pushedKey, pushedUnder, reachedKey, repoScope, scopeRepo, selfKey, topicScope, topicsScope };
187
+ export { catalogueScope, collections, forkId, jobRepo, looseKey, maintainedKey, newChangeId, newInternalId, prunedKey, pushedKey, pushedUnder, reachedKey, repoRootsKey, repoScope, scopeRepo, selfKey, topicScope, topicsScope };
@@ -3,5 +3,5 @@ import "../contracts/actors.mjs";
3
3
  import "../contracts/sync.mjs";
4
4
  import "../core/parts.mjs";
5
5
  import "effect/http/HttpClient";
6
- import { JobDefinition } from "@ref0/infra";
6
+ import { Job } from "@ref0/infra";
7
7
  import "effect/Context";
@@ -128,7 +128,7 @@ const importWith = /* @__PURE__ */ Effect.fnUntraced(function* (bound, input) {
128
128
  source.repo
129
129
  ],
130
130
  put: [importRow(startRow(bound, input, by))],
131
- jobs: [bound.importJob.job({
131
+ jobs: [bound.importJob.encodedJob({
132
132
  key: importJobKey,
133
133
  data
134
134
  })],
@@ -4,7 +4,6 @@ import { ImportJobData, MirrorJobData, Sync } from "../contracts/sync.mjs";
4
4
  import { SyncBase } from "../core/parts.mjs";
5
5
  import { withAudienceMemo } from "../core/ref-view.mjs";
6
6
  import { CallBudget } from "../store/call-count.mjs";
7
- import { gitJob } from "../store/job-try.mjs";
8
7
  import { importJobName, mirrorJobName } from "../store/records.mjs";
9
8
  import { importTryTimeout } from "../storage/receive-bounds.mjs";
10
9
  import { SyncState, importLimits } from "./bound.mjs";
@@ -39,8 +38,6 @@ const layerWith = (options, limits) => Layer.effectContext(Effect.gen(function*
39
38
  const base = yield* SyncBase;
40
39
  const registration = yield* register({ name: "sync" });
41
40
  const http = CallBudget.charged(yield* HttpClient.HttpClient);
42
- const importJob = gitJob(Import, () => importTry(bound), { onFailure: (_data, failure) => importFailed(bound, failure) });
43
- const mirrorJob = gitJob(Mirror, (data) => mirrorTry(bound, data));
44
41
  const bound = {
45
42
  needs: Context.add(base.needs, HttpClient.HttpClient, http),
46
43
  providers,
@@ -49,11 +46,11 @@ const layerWith = (options, limits) => Layer.effectContext(Effect.gen(function*
49
46
  ...limits,
50
47
  publishBatch: Math.min(limits.publishBatch, base.pushRefsMost)
51
48
  },
52
- importJob,
53
- mirrorJob
49
+ importJob: Import,
50
+ mirrorJob: Mirror
54
51
  };
55
- yield* registration.addJob(importJob);
56
- yield* registration.addJob(mirrorJob);
52
+ yield* registration.addJob(Import, () => importTry(bound), { onFailure: (_data, failure) => importFailed(bound, failure) });
53
+ yield* registration.addJob(Mirror, (data) => mirrorTry(bound, data));
57
54
  const run = (effect) => base.through(withAudienceMemo(Effect.provide(effect, bound.needs)));
58
55
  return Context.make(SyncState, bound).pipe(Context.add(Sync, {
59
56
  import: (input) => run(importWith(bound, input)),
@@ -106,7 +106,7 @@ const mirrorWith = /* @__PURE__ */ Effect.fnUntraced(function* (bound, input) {
106
106
  };
107
107
  const bytes = jsonBytes(mirrorRow(ref, largest));
108
108
  if (bytes > mirrorLimits.rowBytes) return yield* fail("INVALID_ARGUMENT", `The mirror of '${ref}' takes ${bytes} bytes: a mirror takes at most ${mirrorLimits.rowBytes}`, { hint: "Name a shorter destination or ref" });
109
- const job = bound.mirrorJob.job({
109
+ const job = bound.mirrorJob.encodedJob({
110
110
  key: ref,
111
111
  data: { ref }
112
112
  });
@@ -2,7 +2,7 @@ import { millis } from "../contracts/promises.mjs";
2
2
  import { hostCall, hostEffect } from "../auth/host-function.mjs";
3
3
  import { checkPublish } from "../queue/advance.mjs";
4
4
  import { advanceRow } from "../store/queue-jobs.mjs";
5
- import { gitJob } from "../store/job-try.mjs";
5
+ import { jobParts } from "../store/job-try.mjs";
6
6
  import { storeCall } from "../store/errors.mjs";
7
7
  import { untilAborted } from "../store/crossing.mjs";
8
8
  import { repoScope, topicScope } from "../store/scopes.mjs";
@@ -680,9 +680,9 @@ const topicJobs = (host) => {
680
680
  timeout: (host.prepare?.timeout ?? 0) + saveMargin
681
681
  });
682
682
  return [
683
- gitJob(AdvanceJob, (data) => overCore(host, data, (job) => advance(host, job))),
684
- gitJob(PrepareJob, (data) => overCore(host, data, (job) => prepareStep(host, job)), { onFailure: (data) => prepareFailed(host, data) }),
685
- gitJob(ReportTimeoutJob, (data) => overCore(host, data, (job) => reportTimeoutStep(host, job)))
683
+ jobParts(AdvanceJob, (data) => overCore(host, data, (job) => advance(host, job))),
684
+ jobParts(PrepareJob, (data) => overCore(host, data, (job) => prepareStep(host, job)), { onFailure: (data) => prepareFailed(host, data) }),
685
+ jobParts(ReportTimeoutJob, (data) => overCore(host, data, (job) => reportTimeoutStep(host, job)))
686
686
  ];
687
687
  };
688
688
  export { addMissing, block, inOrder, outOfTries, pollEvery, saysFailed, topicJobs };
@@ -42,7 +42,7 @@ const topicsRegistration = /* @__PURE__ */ Effect.fnUntraced(function* (registra
42
42
  remove: (id, input, by) => Effect.provideContext(acting(by, over(by).remove(id, input)), needs),
43
43
  report: (id, input, by) => Effect.provideContext(acting(by, over(by).report(id, input)), needs)
44
44
  };
45
- for (const job of topicJobs(host)) yield* registration.addJob(job);
45
+ for (const job of topicJobs(host)) yield* job(registration.addJob);
46
46
  yield* (yield* TopicsBase).attach(service);
47
47
  return Topics.of(service);
48
48
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ref0/git",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "private": false,
5
5
  "description": "Git hosting as a library: a server, a client and their merges",
6
6
  "license": "Apache-2.0",
@@ -62,12 +62,12 @@
62
62
  }
63
63
  },
64
64
  "dependencies": {
65
- "@ref0/infra": "0.8.0",
65
+ "@ref0/infra": "0.10.0",
66
66
  "pako": "2.1.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@effect/vitest": "4.1.7",
70
- "@ref0/xdiff-wasm": "0.8.0",
70
+ "@ref0/xdiff-wasm": "0.10.0",
71
71
  "effect": "4.1.7",
72
72
  "vite-plus": "1.8.0",
73
73
  "vitest": "5.1.1"