@ref0/git 0.8.0 → 0.9.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 (94) 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/events.d.mts +70 -4
  4. package/dist/contracts/events.mjs +27 -3
  5. package/dist/contracts/git.d.mts +13 -3
  6. package/dist/contracts/objects.d.mts +18 -0
  7. package/dist/contracts/queue.d.mts +3 -2
  8. package/dist/contracts/queue.mjs +4 -2
  9. package/dist/core/ancestry.mjs +5 -4
  10. package/dist/core/index-job.mjs +23 -1
  11. package/dist/core/index-lost.d.mts +11 -0
  12. package/dist/core/index-lost.mjs +55 -0
  13. package/dist/core/objects/commit-writes.mjs +1 -1
  14. package/dist/core/objects/commits.mjs +10 -9
  15. package/dist/core/objects/merges.mjs +1 -1
  16. package/dist/core/objects/reading.mjs +28 -13
  17. package/dist/core/objects/trees.mjs +1 -1
  18. package/dist/core/parts.d.mts +7 -0
  19. package/dist/core/publish.mjs +9 -5
  20. package/dist/core/purge.mjs +16 -3
  21. package/dist/core/push.mjs +27 -11
  22. package/dist/core/repack.mjs +36 -14
  23. package/dist/core/view.d.mts +10 -1
  24. package/dist/core/view.mjs +15 -6
  25. package/dist/effect.d.mts +2 -3
  26. package/dist/effect.mjs +2 -3
  27. package/dist/engine/commits.mjs +4 -3
  28. package/dist/engine/merge-bases.mjs +5 -3
  29. package/dist/engine/merge.mjs +4 -3
  30. package/dist/engine/parts.d.mts +1 -0
  31. package/dist/engine/parts.mjs +1 -1
  32. package/dist/engine/walk.mjs +15 -11
  33. package/dist/http/core-parts.mjs +17 -8
  34. package/dist/index.d.mts +2 -2
  35. package/dist/lfs/objects.mjs +7 -4
  36. package/dist/lfs/upkeep.mjs +6 -5
  37. package/dist/lfs/upload-most.mjs +7 -1
  38. package/dist/protocol/bytes/streams.mjs +84 -2
  39. package/dist/protocol/diff/read.d.mts +1 -0
  40. package/dist/protocol/diff/read.mjs +5 -2
  41. package/dist/protocol/objects/commit.d.mts +7 -0
  42. package/dist/protocol/objects/commit.mjs +5 -1
  43. package/dist/queue/advance.mjs +39 -10
  44. package/dist/queue/host.d.mts +4 -0
  45. package/dist/queue/layer.mjs +4 -2
  46. package/dist/queue/limits.mjs +18 -2
  47. package/dist/queue/rows.mjs +2 -1
  48. package/dist/queue/trim.mjs +2 -2
  49. package/dist/rest/commits.d.mts +238 -238
  50. package/dist/rest/forks.d.mts +71 -71
  51. package/dist/rest/refs.d.mts +143 -143
  52. package/dist/rest/repos.d.mts +81 -81
  53. package/dist/rest/topics.d.mts +112 -112
  54. package/dist/rest/trees.d.mts +77 -77
  55. package/dist/rest/wire.d.mts +19 -1
  56. package/dist/rest/work.d.mts +39 -39
  57. package/dist/server/joined.d.mts +11 -5
  58. package/dist/server/joined.mjs +3 -2
  59. package/dist/server/registry.mjs +11 -5
  60. package/dist/server/server.mjs +16 -4
  61. package/dist/storage/index-bitmaps.mjs +16 -10
  62. package/dist/storage/index-build.mjs +61 -13
  63. package/dist/storage/index-graph.d.mts +1 -0
  64. package/dist/storage/index-graph.mjs +29 -5
  65. package/dist/storage/index-layers.d.mts +1 -0
  66. package/dist/storage/index-layers.mjs +5 -2
  67. package/dist/storage/index-reach.mjs +7 -5
  68. package/dist/storage/index-remap.mjs +5 -5
  69. package/dist/storage/index-visible.mjs +16 -5
  70. package/dist/storage/links.mjs +3 -3
  71. package/dist/storage/pack-order.d.mts +1 -0
  72. package/dist/storage/pack-order.mjs +18 -1
  73. package/dist/storage/prune-walk.mjs +5 -2
  74. package/dist/storage/prune.mjs +107 -37
  75. package/dist/storage/receive-bounds.mjs +3 -2
  76. package/dist/storage/visible.mjs +3 -2
  77. package/dist/storage/walk.d.mts +1 -0
  78. package/dist/storage/walk.mjs +9 -5
  79. package/dist/storage/wants.mjs +17 -11
  80. package/dist/store/call-count.d.mts +8 -0
  81. package/dist/store/call-count.mjs +15 -7
  82. package/dist/store/errors.d.mts +7 -1
  83. package/dist/store/errors.mjs +7 -1
  84. package/dist/store/job-try.mjs +3 -1
  85. package/dist/store/records.mjs +17 -2
  86. package/dist/store/repo-record.mjs +9 -2
  87. package/dist/store/scopes.mjs +10 -2
  88. package/dist/sync/bound.d.mts +1 -1
  89. package/dist/sync/import.mjs +1 -1
  90. package/dist/sync/layer.mjs +4 -7
  91. package/dist/sync/mirror.mjs +1 -1
  92. package/dist/topics/advance.mjs +4 -4
  93. package/dist/topics/layer.mjs +1 -1
  94. package/package.json +3 -3
@@ -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.9.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.9.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.9.0",
71
71
  "effect": "4.1.7",
72
72
  "vite-plus": "1.8.0",
73
73
  "vitest": "5.1.1"