@ref0/git 0.11.0 → 0.12.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 (62) hide show
  1. package/dist/access/private-refs.mjs +5 -4
  2. package/dist/contracts/forks.d.mts +3 -2
  3. package/dist/contracts/git.d.mts +23 -5
  4. package/dist/contracts/result.d.mts +7 -5
  5. package/dist/contracts/result.mjs +7 -5
  6. package/dist/contracts/sync.d.mts +11 -0
  7. package/dist/core/access.d.mts +1 -0
  8. package/dist/core/access.mjs +10 -11
  9. package/dist/core/asked.mjs +30 -0
  10. package/dist/core/events/deliver.d.mts +1 -0
  11. package/dist/core/events/deliver.mjs +5 -1
  12. package/dist/core/forks.mjs +39 -13
  13. package/dist/core/imports.mjs +9 -4
  14. package/dist/core/objects/reading.mjs +17 -9
  15. package/dist/core/parts.d.mts +2 -1
  16. package/dist/core/push.mjs +11 -8
  17. package/dist/core/refs.mjs +6 -3
  18. package/dist/core/registered-rows.d.mts +1 -0
  19. package/dist/core/registered-rows.mjs +7 -5
  20. package/dist/core/repack.mjs +5 -3
  21. package/dist/core/saved-caller-views.d.mts +18 -0
  22. package/dist/core/saved-caller-views.mjs +17 -4
  23. package/dist/core/saved-callers-public.d.mts +3 -3
  24. package/dist/core/saved-callers-public.mjs +3 -2
  25. package/dist/core/saved-callers.d.mts +7 -0
  26. package/dist/extend.d.mts +2 -1
  27. package/dist/extend.mjs +2 -1
  28. package/dist/http/push-uploads.mjs +6 -3
  29. package/dist/lfs/locks.mjs +14 -9
  30. package/dist/lfs/objects.mjs +27 -20
  31. package/dist/queue/calls.mjs +21 -1
  32. package/dist/rest/blobs.d.mts +15 -15
  33. package/dist/rest/commits.d.mts +191 -191
  34. package/dist/rest/files.d.mts +70 -70
  35. package/dist/rest/forks.d.mts +72 -72
  36. package/dist/rest/layer.mjs +8 -1
  37. package/dist/rest/queue.d.mts +212 -212
  38. package/dist/rest/refs.d.mts +148 -148
  39. package/dist/rest/repos.d.mts +47 -47
  40. package/dist/rest/tags.d.mts +76 -76
  41. package/dist/rest/tokens.d.mts +101 -101
  42. package/dist/rest/topics.d.mts +112 -112
  43. package/dist/rest/trees.d.mts +73 -73
  44. package/dist/rest/work.d.mts +39 -39
  45. package/dist/server/git-namespace.d.mts +3 -3
  46. package/dist/server/server.mjs +6 -4
  47. package/dist/storage/memory-budget.mjs +128 -6
  48. package/dist/storage/merge-cut.mjs +5 -4
  49. package/dist/storage/pack-reads.mjs +239 -27
  50. package/dist/storage/prune-seen.mjs +11 -6
  51. package/dist/storage/prune-walk.mjs +168 -68
  52. package/dist/storage/quarantine.mjs +2 -0
  53. package/dist/store/repo-record.d.mts +25 -0
  54. package/dist/store/repo-record.mjs +55 -1
  55. package/dist/sync/github.mjs +10 -1
  56. package/dist/sync/import.mjs +3 -2
  57. package/dist/sync/mirror.mjs +24 -17
  58. package/dist/sync/said.mjs +204 -0
  59. package/dist/sync/step.mjs +8 -8
  60. package/dist/sync/tries.mjs +34 -18
  61. package/dist/topics/advance.mjs +10 -3
  62. package/package.json +3 -3
@@ -0,0 +1,204 @@
1
+ import { cutWords, utf8 } from "../protocol/bytes/text.mjs";
2
+ import * as Option from "effect/Option";
3
+ import * as Schema from "effect/Schema";
4
+ import * as Result from "effect/Result";
5
+ import * as Base64 from "effect/encoding/Base64";
6
+ import * as Base64Url from "effect/encoding/Base64Url";
7
+ // src/sync/said.ts
8
+ /**
9
+ * What a remote said that its provider marks safe to keep: the named top-level string fields of a
10
+ * refusal's JSON body, such as GitHub's `message`, and nothing else of it. The text is made one
11
+ * line, every credential-shaped string in it redacted, then cut to `saidMost`, so a cut never
12
+ * leaves part of a token no pattern still matches. A remote's or a gateway's words may echo the
13
+ * request's credential, which is why the rest stays dropped.
14
+ */
15
+ /** The most of a refusal's body read for its fields: a longer body is cancelled there, unread. */
16
+ const saidBytesMost = 4096;
17
+ const marker = "[redacted]";
18
+ /** A username shorter than this is redacted only inside its credential, not alone, as `x-` isn't. */
19
+ const nameAloneLeast = 8;
20
+ /**
21
+ * Strings shaped as credentials, whoever's they are: GitHub's token prefixes, Git's own `gt_`
22
+ * tokens, an authorization scheme and its value, a JWT, a URL's userinfo, and any run of 32 or more
23
+ * base64, base64url or hex characters. That last one takes a commit's 40-hex ID too, on purpose:
24
+ * GitHub's older tokens are 40 hex characters, and look the same.
25
+ */
26
+ const credentialPatterns = [
27
+ [/\b(?:gh[pousr]_|github_pat_)[A-Za-z0-9_]+/g, marker],
28
+ [/\bgt_[\w.~-]+/g, marker],
29
+ [/\b(Bearer|Basic)\s+[^\s"',;]+/gi, `$1 ${marker}`],
30
+ [/\b(token)\s+[\w.~+/=-]{16,}/gi, `$1 ${marker}`],
31
+ [/\beyJ[\w-]*\.[\w-]*\.[\w-]*/g, marker],
32
+ [/\b([a-z][a-z0-9+.-]*:\/\/)[^\s/@]*@/gi, `$1${marker}@`],
33
+ [/[A-Za-z0-9+/_=-]{32,}/g, marker]
34
+ ];
35
+ /** `text` as one line: each run of whitespace and control characters one space. */
36
+ const oneLine = (text) => text.replace(/[\s\p{Cc}]+/gu, " ");
37
+ /** `text` as base64 and base64url, padded and not, as a remote may encode a credential's part. */
38
+ const base64Forms = (text) => {
39
+ const bytes = utf8(text);
40
+ const padded = Base64.encode(bytes);
41
+ return [
42
+ padded,
43
+ padded.replace(/=+$/, ""),
44
+ Base64Url.encode(bytes)
45
+ ];
46
+ };
47
+ /**
48
+ * `secret` as a remote may echo it: as it is, escaped as JSON, as one line, as a kept text is
49
+ * made, and in base64. Its percent-encodings, in any spelling, are `spelledAs`'s.
50
+ */
51
+ const formsOf = (secret) => [
52
+ secret,
53
+ JSON.stringify(secret).slice(1, -1),
54
+ oneLine(secret),
55
+ ...base64Forms(secret)
56
+ ];
57
+ /** The parts of a Basic credential, `user:pass`, from its base64: none when it isn't one. */
58
+ const basicParts = (encoded) => {
59
+ const decoded = Base64.decodeString(encoded);
60
+ if (Result.isFailure(decoded)) return [];
61
+ const pair = decoded.success;
62
+ const colon = pair.indexOf(":");
63
+ if (colon < 0) return [pair];
64
+ const name = pair.slice(0, colon);
65
+ return [
66
+ pair,
67
+ pair.slice(colon + 1),
68
+ ...name.length >= nameAloneLeast ? [name] : []
69
+ ];
70
+ };
71
+ /** `text` percent-decoded, or as it is when it isn't valid percent-encoding. */
72
+ const decoded = (text) => {
73
+ try {
74
+ return decodeURIComponent(text);
75
+ } catch {
76
+ return text;
77
+ }
78
+ };
79
+ /**
80
+ * Every form the credential `request` carries may take in a remote's words: its `authorization`
81
+ * header whole, the value after its scheme, a Basic value's `user:pass`, its password and a
82
+ * username of `nameAloneLeast` or more, and the userinfo of its URL, each in `formsOf`'s forms.
83
+ * Longest first, so a whole header goes before its parts.
84
+ */
85
+ const requestSecrets = (request) => {
86
+ const parts = [];
87
+ const header = request.headers.get("authorization");
88
+ if (header !== null) {
89
+ const [scheme = "", value = ""] = header.trim().split(/\s+/, 2);
90
+ parts.push(header, value);
91
+ if (scheme.toLowerCase() === "basic") parts.push(...basicParts(value));
92
+ }
93
+ const url = URL.parse(request.url);
94
+ if (url !== null) {
95
+ parts.push(decoded(url.password), url.password);
96
+ if (url.username.length >= nameAloneLeast) parts.push(decoded(url.username));
97
+ }
98
+ const forms = parts.filter((part) => part !== "").flatMap(formsOf);
99
+ return [...new Set(forms)].toSorted((a, b) => b.length - a.length);
100
+ };
101
+ /** A hex digit in either case. */
102
+ const hexEither = (digit) => /[a-f]/i.test(digit) ? `[${digit.toLowerCase()}${digit.toUpperCase()}]` : digit;
103
+ /**
104
+ * A pattern of `secret` in any spelling a URL's percent-encoding gives it: each character as it
105
+ * is, or as its UTF-8 bytes percent-encoded in either case of hex, a space as `+` too.
106
+ */
107
+ const spelledAs = (secret) => {
108
+ const characters = Array.from(secret).map((character) => {
109
+ const literal = character.replace(/[.*+?^${}()|[\]\\/-]/g, "\\$&");
110
+ const bytes = [...utf8(character)].map((byte) => `%${byte.toString(16).padStart(2, "0").split("").map(hexEither).join("")}`);
111
+ const space = character === " " ? ["\\+"] : [];
112
+ return `(?:${[
113
+ literal,
114
+ bytes.join(""),
115
+ ...space
116
+ ].join("|")})`;
117
+ });
118
+ return new RegExp(characters.join(""), "g");
119
+ };
120
+ /** `text` with each of `secrets`, in any percent spelling, then each credential shape, redacted. */
121
+ const redacted = (text, secrets) => {
122
+ const plain = secrets.reduce((words, secret) => words.replace(spelledAs(secret), marker), text);
123
+ return credentialPatterns.reduce((words, [pattern, by]) => words.replace(pattern, by), plain);
124
+ };
125
+ /** A refusal's JSON body: an object, any value under each key. */
126
+ const decodeRefusal = /* @__PURE__ */ Schema.decodeOption(Schema.fromJsonString(Schema.Record(Schema.String, Schema.Json)));
127
+ const isText = /* @__PURE__ */ Schema.is(Schema.String);
128
+ /**
129
+ * The kept text of `text`, a refusal's JSON body: its `fields`' string values in their order,
130
+ * joined, made one line, redacted and cut to `saidMost`. `undefined` when no field holds text, or
131
+ * when a secret still shows once redacted, as one inside the marker would.
132
+ */
133
+ const keptSaid = (text, fields, secrets) => {
134
+ const body = Option.getOrElse(decodeRefusal(text), () => ({}));
135
+ const texts = fields.flatMap((field) => {
136
+ const value = Object.hasOwn(body, field) ? body[field] : void 0;
137
+ return isText(value) ? [value] : [];
138
+ });
139
+ const line = oneLine(texts.join("; ")).trim();
140
+ if (line === "") return void 0;
141
+ const kept = cutWords(redacted(line, secrets), 256).trim();
142
+ if (kept === "" || secrets.some((secret) => kept.includes(secret))) return void 0;
143
+ return kept;
144
+ };
145
+ /**
146
+ * A provider's own call refused, such as GitHub's mint of a token: its message names the call and
147
+ * the status, and `said` what the refusal's marked fields kept, as `saidOf` keeps them.
148
+ */
149
+ var ProviderRefused = class extends Error {
150
+ said;
151
+ constructor(message, said) {
152
+ super(message);
153
+ this.said = said;
154
+ }
155
+ };
156
+ /** Whether `response` is JSON, as `application/json` or a `+json` type. */
157
+ const isJson = (response) => {
158
+ const type = (response.headers.get("content-type") ?? "").split(";", 1)[0]?.trim() ?? "";
159
+ return type === "application/json" || /^application\/[\w.-]+\+json$/.test(type);
160
+ };
161
+ /**
162
+ * The start of `body`, at most `saidBytesMost` bytes, or `undefined` past it or once `signal`
163
+ * aborts, which cancels a read that waits: a refusal that stalls never holds its try. Cancelled
164
+ * after, either way.
165
+ */
166
+ const bodyStart = async (body, signal) => {
167
+ const reader = body.getReader();
168
+ const stop = () => {
169
+ reader.cancel(signal.reason).catch(() => void 0);
170
+ };
171
+ const decoder = new TextDecoder();
172
+ let text = "";
173
+ let bytes = 0;
174
+ signal.addEventListener("abort", stop, { once: true });
175
+ try {
176
+ while (!signal.aborted) {
177
+ const piece = await reader.read();
178
+ if (piece.done) return signal.aborted ? void 0 : text + decoder.decode();
179
+ bytes += piece.value.byteLength;
180
+ if (bytes > 4096) return void 0;
181
+ text += decoder.decode(piece.value, { stream: true });
182
+ }
183
+ return;
184
+ } finally {
185
+ signal.removeEventListener("abort", stop);
186
+ reader.cancel().catch(() => void 0);
187
+ reader.releaseLock();
188
+ }
189
+ };
190
+ /**
191
+ * What the refusal `response` to `request` said in `fields`, as `keptSaid` keeps it: its body read
192
+ * only when it's JSON and some field is marked, until `request`'s signal aborts, and always
193
+ * dropped after. A failed or stopped read keeps nothing.
194
+ */
195
+ const saidOf = async (request, response, fields) => {
196
+ if (fields.length === 0 || response.body === null || !isJson(response)) {
197
+ await response.body?.cancel().catch(() => void 0);
198
+ return;
199
+ }
200
+ const text = await bodyStart(response.body, request.signal).catch(() => void 0);
201
+ if (text === void 0) return void 0;
202
+ return keptSaid(text, fields, requestSecrets(request));
203
+ };
204
+ export { ProviderRefused, keptSaid, requestSecrets, saidBytesMost, saidOf };
@@ -22,7 +22,7 @@ import { StoredRepo } from "../store/records.mjs";
22
22
  import { newChangeId, repoScope, selfKey } from "../store/scopes.mjs";
23
23
  import { asSync } from "./bound.mjs";
24
24
  import { ImportRow, cancelKey, cutKey, cutRow, failedHint, failedRow, importEndDeletes, importKey, importRow, readImport, readTipPages, stoppedTry, tipPageKey, tipPageRow, tipPagesOf, tipRowBytes } from "../core/imports.mjs";
25
- import { ForGood, SyncTryError, forGood, fromRemote, httpOf, openedFor, remoteOf, syncObjects, thrownOf, tried } from "./tries.mjs";
25
+ import { ForGood, SyncTryError, forGood, fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, syncObjects, thrownOf, tried } from "./tries.mjs";
26
26
  import { currentRepo } from "../store/job-try.mjs";
27
27
  import { CoreParts, ObjectsParts, overStore } from "../core/parts.mjs";
28
28
  import { importOwner } from "../protocol/wire/lines.mjs";
@@ -172,7 +172,7 @@ const remoteRefused = (remote, message) => {
172
172
  * A failure to read the remote's advertisement: its own `ERR` refusal, by its reason, ends the
173
173
  * import, since every try meets it; any other is the remote's, tried again.
174
174
  */
175
- const advertisedFrom = (remote, call) => (error) => error.code === "FAILED_PRECONDITION" && error.context?.reason === "remote-refused" ? new ForGood({ error: remoteRefused(remote, error.message) }) : fromRemote(call)(error);
175
+ const advertisedFrom = (remote, call, heard) => (error) => error.code === "FAILED_PRECONDITION" && error.context?.reason === "remote-refused" ? new ForGood({ error: remoteRefused(remote, error.message) }) : fromRemote(call, heard)(error);
176
176
  /** `context.progress`, which a claim taken again refuses: the sample's dropped, and the try goes on. */
177
177
  const report = (context, phase, row) => context.progress({
178
178
  phase,
@@ -269,13 +269,13 @@ const pullTips = (refs, own, limits) => {
269
269
  */
270
270
  const listTips = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, row, remote) {
271
271
  yield* report(attempt.context, "fetch", row);
272
- const http = yield* httpOf(remote);
272
+ const { http, heard } = yield* httpOf(remote, keptFieldsOf(attempt.bound, row.source));
273
273
  const listed = Effect.flatMap(discover(http), (upload) => remoteRefsAndHeadOf(http, upload, [
274
274
  "refs/heads/",
275
275
  "refs/tags/",
276
276
  "refs/pull/"
277
277
  ]));
278
- const { refs: listing, head } = yield* Effect.mapError(listed, advertisedFrom(remote, "list its branches and tags"));
278
+ const { refs: listing, head } = yield* Effect.mapError(listed, advertisedFrom(remote, "list its branches and tags", heard));
279
279
  const refs = new Map([...listing].filter(([ref]) => !ref.startsWith("refs/pull/")));
280
280
  const unnamed = [...refs.keys()].find((ref) => !isRefName(ref));
281
281
  if (unnamed !== void 0) return yield* forGood(unnamedTip(unnamed));
@@ -386,8 +386,8 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
386
386
  if (opened === void 0) return void 0;
387
387
  const objects = objectsFace(syncObjects(yield* ObjectsParts));
388
388
  yield* report(context, "fetch", row);
389
- const http = yield* httpOf(remote);
390
- const upload = yield* Effect.mapError(discover(http), advertisedFrom(remote, "advertise its refs"));
389
+ const { http, heard } = yield* httpOf(remote, keptFieldsOf(bound, row.source));
390
+ const upload = yield* Effect.mapError(discover(http), advertisedFrom(remote, "advertise its refs", heard));
391
391
  const shallow = yield* deepens(upload);
392
392
  const wanted = row.deepest + row.step;
393
393
  const request = {
@@ -407,7 +407,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
407
407
  listed: opened.listed,
408
408
  tips: [...new Set(opened.refs.values())],
409
409
  held: row.deepest > 0 ? tips : []
410
- }).pipe(Effect.mapError(fromRemote("negotiate a fetch")));
410
+ }).pipe(Effect.mapError(fromRemote("negotiate a fetch", heard)));
411
411
  yield* report(context, "receive", row);
412
412
  const { pack } = negotiated;
413
413
  const { stream, seen } = counted(pack.bytes, most);
@@ -476,7 +476,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
476
476
  });
477
477
  const pushed = yield* Effect.result(sent.pipe(Effect.mapError((error) => {
478
478
  const failure = pack.failure();
479
- return failure === void 0 ? error : fromRemote("send its pack")(failure);
479
+ return failure === void 0 ? error : fromRemote("send its pack", heard)(failure);
480
480
  }), Effect.onInterrupt(() => Effect.sync(() => {
481
481
  stopped.abort();
482
482
  pack.cancel();
@@ -10,6 +10,8 @@ import { answerSpent } from "../store/errors.mjs";
10
10
  import { decodePacks } from "../store/git-store.mjs";
11
11
  import { WholeRepo, wholeRefs } from "../store/ref-rows.mjs";
12
12
  import { collections } from "../store/scopes.mjs";
13
+ import { ProviderRefused, saidOf } from "./said.mjs";
14
+ import { quoted } from "../protocol/bytes/text.mjs";
13
15
  import { responseToWeb } from "./http.mjs";
14
16
  import { callLimitIn, spentRefusalOf, tryUnlessSpent } from "../contracts/calls-spent.mjs";
15
17
  import * as Effect from "effect/Effect";
@@ -70,7 +72,10 @@ const unknownProvider = (name) => gitError("INVALID_ARGUMENT", `No provider name
70
72
  hostHint: `Pass the '${name}' provider to Sync.layer`,
71
73
  context: { reason: "provider-unknown" }
72
74
  });
73
- const providerFailed = (name) => gitError("UNAVAILABLE", `The '${name}' provider made no remote for this try`, { hint: "The job tries again" });
75
+ /** `message`, then what a refusal said when its provider kept some of it, quoted. */
76
+ const withSaid = (message, said) => said === void 0 ? message : `${message}. Its refusal said: ${quoted(said)}`;
77
+ /** A provider that threw: what its own call's refusal said when it kept some, else nothing of it. */
78
+ const providerFailed = (name, cause) => gitError("UNAVAILABLE", withSaid(`The '${name}' provider made no remote for this try`, cause instanceof ProviderRefused ? cause.said : void 0), { hint: "The job tries again" });
74
79
  /**
75
80
  * The provider's remote for this try: a provider that has gone since fails the job for good,
76
81
  * naming it, and one that throws fails this try with a message that names no secret.
@@ -79,43 +84,54 @@ const remoteOf = /* @__PURE__ */ Effect.fnUntraced(function* (bound, source, sig
79
84
  const { provider: name, repo } = source;
80
85
  const provider = bound.providers.get(name);
81
86
  if (provider === void 0) return yield* forGood(unknownProvider(name));
82
- return yield* tryUnlessSpent(() => provider.remote(repo, access, signal), () => providerFailed(name));
87
+ return yield* tryUnlessSpent(() => provider.remote(repo, access, signal), (cause) => providerFailed(name, cause));
83
88
  });
84
89
  /**
85
- * `send`, each refusal's body dropped: its text is the remote's, or a gateway's, which may echo the
86
- * request's credential, and a try's error is kept where the job's readers see it.
90
+ * `send`, each refusal's body dropped once `heard` keeps what its provider's `fields` said: the
91
+ * rest is the remote's text, or a gateway's, which may echo the request's credential, and a try's
92
+ * error is kept where the job's readers see it.
87
93
  */
88
- const bodiless = (send) => async (request) => {
94
+ const bodiless = (send, fields, heard) => async (request) => {
89
95
  const response = await send(request);
96
+ heard.said = void 0;
90
97
  if (response.status < 400) return response;
91
- await response.body?.cancel();
98
+ heard.said = await saidOf(request, response, fields);
92
99
  return new Response(null, {
93
100
  status: response.status,
94
101
  headers: response.headers
95
102
  });
96
103
  };
97
104
  /**
98
- * A failure of a call to the remote, kept by its code and context alone: its message may be the
99
- * remote's own text, as an `ERR` line or a status report sent with 200 is, which may echo the
100
- * credential, as a refusal's body may. A spent call bound's refusal, as a read of the repo's own
101
- * objects or a host's transport met the platform's cap, is no failure of the remote's: it stays
102
- * the bound's own (#1083).
105
+ * A failure of a call to the remote, kept by its code and context, and what `heard` kept of the
106
+ * refusal it met: its own message may be the remote's text, as an `ERR` line or a status report
107
+ * sent with 200 is, which may echo the credential, as a refusal's body may. A spent call bound's
108
+ * refusal, as a read of the repo's own objects or a host's transport met the platform's cap, is no
109
+ * failure of the remote's: it stays the bound's own (#1083).
103
110
  */
104
- const fromRemote = (call) => (error) => spentRefusalOf(error) ?? gitErrorFrom(error, {
105
- message: `The remote failed to ${call} (${error.code})`,
111
+ const fromRemote = (call, heard) => (error) => spentRefusalOf(error) ?? gitErrorFrom(error, {
112
+ message: withSaid(`The remote failed to ${call} (${error.code})`, heard.said),
106
113
  hint: "The job tries again"
107
114
  });
108
- /** The client's smart HTTP to `remote`, with its credentials and transport. */
109
- const httpOf = /* @__PURE__ */ Effect.fnUntraced(function* (remote) {
115
+ /** The fields of a refusal's JSON body `source`'s provider marks safe to keep: none it doesn't. */
116
+ const keptFieldsOf = (bound, source) => bound.providers.get(source.provider)?.keptFields ?? [];
117
+ /**
118
+ * The client's smart HTTP to `remote`, with its credentials and transport, and what its refusals
119
+ * said in `fields`, as `bodiless` keeps it.
120
+ */
121
+ const httpOf = /* @__PURE__ */ Effect.fnUntraced(function* (remote, fields) {
110
122
  const client = yield* HttpClient.HttpClient;
111
123
  const context = yield* Effect.context();
124
+ const heard = { said: void 0 };
112
125
  const send = (request) => runnerIn(context)(client.execute(HttpClientRequest.fromWeb(request)).pipe(Effect.flatMap(responseToWeb)), request.signal);
113
126
  const options = {
114
127
  url: remote.url,
115
- transport: bodiless(remote.transport ?? send)
128
+ transport: bodiless(remote.transport ?? send, fields, heard)
116
129
  };
117
130
  if (remote.credentials !== void 0) options.credentials = remote.credentials;
118
- return gitHttp(options);
131
+ return {
132
+ http: gitHttp(options),
133
+ heard
134
+ };
119
135
  });
120
136
  const refsRead = { collection: collections.refs };
121
137
  const packsRead = { collection: collections.packs };
@@ -148,4 +164,4 @@ const openedFor = /* @__PURE__ */ Effect.fnUntraced(function* (caller, internalI
148
164
  refs
149
165
  };
150
166
  });
151
- export { ForGood, SyncTryError, forGood, fromRemote, httpOf, openedFor, remoteOf, syncObjects, syncRetry, syncTryError, syncWhole, thrownOf, tried, unknownProvider };
167
+ export { ForGood, SyncTryError, forGood, fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, syncObjects, syncRetry, syncTryError, syncWhole, thrownOf, tried, unknownProvider };
@@ -4,15 +4,16 @@ import { checkPublish } from "../queue/advance.mjs";
4
4
  import { advanceRow } from "../store/queue-jobs.mjs";
5
5
  import { jobParts } from "../store/job-try.mjs";
6
6
  import { storeCall } from "../store/errors.mjs";
7
+ import { heldAdd } from "../store/repo-record.mjs";
7
8
  import { untilAborted } from "../store/crossing.mjs";
8
- import { repoScope, topicScope } from "../store/scopes.mjs";
9
+ import { topicScope } from "../store/scopes.mjs";
9
10
  import { CandidateSetData, PrepareData, TopicAdvanceData, prepareName, prepareRow, reportTimeoutName, reportTimeoutRow, topicAdvanceName, topicAdvanceRow } from "../store/topic-jobs.mjs";
10
11
  import { projectTopic } from "./directory.mjs";
11
12
  import { TopicsHost, saveMargin } from "./host.mjs";
12
13
  import { addMember, candidateAt, memberRead, releaseMember, reserveMember } from "./members.mjs";
13
14
  import { unwaited } from "./rows.mjs";
14
15
  import { commitTopic, currentSet, durationWords, entriesOf, failureOf, readTopic, setKeyOf, topicOf } from "./topic.mjs";
15
- import { QueueParts, overStore } from "../core/parts.mjs";
16
+ import { ObjectsParts, QueueParts, overStore } from "../core/parts.mjs";
16
17
  import { checkedAnswer, plainAnswer } from "../core/rules/context.mjs";
17
18
  import * as Clock$1 from "effect/Clock";
18
19
  import * as Effect from "effect/Effect";
@@ -412,6 +413,12 @@ const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read,
412
413
  const afterDecision = /* @__PURE__ */ Effect.fnUntraced(function* (read) {
413
414
  const { row } = read;
414
415
  const reads = yield* Effect.forEach(row.members, (member) => memberRead(member));
416
+ const { records } = (yield* TopicsHost).queue;
417
+ const queueStore = {
418
+ read: (scope, wanted) => storeCall(records.read(scope, wanted)),
419
+ add: (scope, addition) => storeCall(records.add(scope, addition))
420
+ };
421
+ const { fetchLimits } = yield* ObjectsParts;
415
422
  const merged = [];
416
423
  let refused;
417
424
  for (const [index, member] of row.members.entries()) {
@@ -435,7 +442,7 @@ const afterDecision = /* @__PURE__ */ Effect.fnUntraced(function* (read) {
435
442
  continue;
436
443
  }
437
444
  const jobs = [advanceRow(member.target)];
438
- yield* storeCall((yield* TopicsHost).queue.records.add(repoScope(member.internalId), { jobs }));
445
+ if (!(yield* heldAdd(queueStore, member.internalId, fetchLimits, { jobs }).pipe(Effect.as(true), Effect.catchTag("RepoGone", () => Effect.succeed(false))))) refused ??= member;
439
446
  }
440
447
  if (refused !== void 0) {
441
448
  const { repo, entry } = refused;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ref0/git",
3
- "version": "0.11.0",
3
+ "version": "0.12.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.11.0",
65
+ "@ref0/infra": "0.12.0",
66
66
  "pako": "2.1.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@effect/vitest": "4.1.7",
70
- "@ref0/xdiff-wasm": "0.11.0",
70
+ "@ref0/xdiff-wasm": "0.12.0",
71
71
  "effect": "4.1.7",
72
72
  "vite-plus": "1.8.0",
73
73
  "vitest": "5.1.1"