@ref0/git 0.4.0 → 0.6.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 (167) hide show
  1. package/dist/access/private-refs.mjs +3 -4
  2. package/dist/auth/authorize.mjs +9 -4
  3. package/dist/auth/identify.d.mts +5 -3
  4. package/dist/auth/tokens.mjs +12 -11
  5. package/dist/client/local.mjs +2 -0
  6. package/dist/client/slice-push.d.mts +1 -1
  7. package/dist/contracts/access.d.mts +6 -2
  8. package/dist/contracts/authorize.d.mts +14 -10
  9. package/dist/contracts/events.d.mts +32 -5
  10. package/dist/contracts/events.mjs +14 -3
  11. package/dist/contracts/git.d.mts +68 -3
  12. package/dist/contracts/grants.d.mts +6 -1
  13. package/dist/contracts/lfs.d.mts +5 -2
  14. package/dist/contracts/objects.d.mts +7 -2
  15. package/dist/contracts/promises.d.mts +2 -14
  16. package/dist/contracts/push-uploads.d.mts +1 -1
  17. package/dist/contracts/queue.d.mts +15 -7
  18. package/dist/contracts/refs.d.mts +1 -1
  19. package/dist/contracts/result.d.mts +9 -5
  20. package/dist/contracts/result.mjs +5 -0
  21. package/dist/contracts/server.d.mts +13 -6
  22. package/dist/contracts/work.d.mts +1 -1
  23. package/dist/core/access.mjs +17 -1
  24. package/dist/core/call-names.d.mts +3 -1
  25. package/dist/core/claim-rows.d.mts +4 -0
  26. package/dist/core/claim-rows.mjs +53 -0
  27. package/dist/core/events/deliver.d.mts +12 -0
  28. package/dist/core/events/deliver.mjs +367 -145
  29. package/dist/core/events/seen.mjs +17 -3
  30. package/dist/core/forks.mjs +82 -20
  31. package/dist/core/hooks/post-receive.mjs +20 -17
  32. package/dist/core/index-job.mjs +23 -17
  33. package/dist/core/parts.d.mts +6 -0
  34. package/dist/core/purge.d.mts +8 -0
  35. package/dist/core/purge.mjs +16 -21
  36. package/dist/core/push-decide.mjs +26 -4
  37. package/dist/core/push.mjs +57 -20
  38. package/dist/core/ref-index-job.mjs +9 -14
  39. package/dist/core/ref-index.d.mts +1 -0
  40. package/dist/core/ref-index.mjs +28 -8
  41. package/dist/core/ref-view.mjs +14 -9
  42. package/dist/core/refs.mjs +13 -11
  43. package/dist/core/repack.d.mts +2 -1
  44. package/dist/core/repack.mjs +66 -118
  45. package/dist/core/repos.mjs +5 -5
  46. package/dist/core/rules/check.mjs +7 -6
  47. package/dist/core/rules/context.d.mts +1 -1
  48. package/dist/core/seam.d.mts +56 -9
  49. package/dist/core/seam.mjs +7 -1
  50. package/dist/core/still-takes.mjs +75 -0
  51. package/dist/core/view.d.mts +1 -0
  52. package/dist/core/view.mjs +8 -9
  53. package/dist/core/work.mjs +1 -1
  54. package/dist/extend.d.mts +2 -1
  55. package/dist/http/core-parts.mjs +19 -11
  56. package/dist/http/handler.mjs +2 -2
  57. package/dist/http/node.d.mts +2 -23
  58. package/dist/http/parts.d.mts +1 -0
  59. package/dist/http/push-uploads.d.mts +10 -2
  60. package/dist/http/push-uploads.mjs +31 -34
  61. package/dist/http/receive-pack.mjs +5 -3
  62. package/dist/http/upload-pack.mjs +2 -2
  63. package/dist/index.d.mts +11 -7
  64. package/dist/index.mjs +5 -3
  65. package/dist/lfs/base.d.mts +32 -0
  66. package/dist/lfs/base.mjs +8 -0
  67. package/dist/lfs/calls.mjs +21 -12
  68. package/dist/lfs/layer.d.mts +27 -0
  69. package/dist/lfs/layer.mjs +64 -0
  70. package/dist/lfs/locks.mjs +13 -27
  71. package/dist/lfs/namespace.d.mts +2 -0
  72. package/dist/lfs/objects.d.mts +23 -4
  73. package/dist/lfs/objects.mjs +65 -81
  74. package/dist/lfs/pointers.mjs +8 -6
  75. package/dist/lfs/public.d.mts +5 -0
  76. package/dist/lfs/public.mjs +8 -0
  77. package/dist/lfs/purge.mjs +19 -25
  78. package/dist/lfs/rows.mjs +22 -10
  79. package/dist/lfs/service.d.mts +9 -4
  80. package/dist/lfs/service.mjs +3 -12
  81. package/dist/lfs/upkeep.mjs +34 -49
  82. package/dist/node.d.mts +3 -2
  83. package/dist/node.mjs +1 -1
  84. package/dist/protocol/wire/advertisement.d.mts +4 -10
  85. package/dist/protocol/wire/advertisement.mjs +16 -12
  86. package/dist/protocol/wire/lines.d.mts +14 -2
  87. package/dist/protocol/wire/lines.mjs +32 -21
  88. package/dist/protocol/wire/v2.d.mts +4 -15
  89. package/dist/protocol/wire/v2.mjs +16 -14
  90. package/dist/queue/advance.mjs +78 -55
  91. package/dist/queue/calls.mjs +4 -2
  92. package/dist/queue/commit.mjs +20 -13
  93. package/dist/queue/host.d.mts +2 -2
  94. package/dist/queue/layer.d.mts +4 -2
  95. package/dist/queue/layer.mjs +8 -3
  96. package/dist/queue/limits.mjs +36 -6
  97. package/dist/queue/rows.mjs +14 -5
  98. package/dist/queue/state.mjs +19 -5
  99. package/dist/queue/steps.mjs +10 -4
  100. package/dist/queue/trim.mjs +284 -0
  101. package/dist/rest/blobs.d.mts +19 -19
  102. package/dist/rest/caller.d.mts +4 -4
  103. package/dist/rest/commits.d.mts +96 -96
  104. package/dist/rest/errors.d.mts +2 -2
  105. package/dist/rest/events.d.mts +2 -2
  106. package/dist/rest/files.d.mts +54 -54
  107. package/dist/rest/forks.d.mts +87 -87
  108. package/dist/rest/handler.mjs +13 -5
  109. package/dist/rest/layer.d.mts +14 -0
  110. package/dist/rest/layer.mjs +52 -0
  111. package/dist/rest/me.d.mts +2 -2
  112. package/dist/rest/merges.d.mts +2 -2
  113. package/dist/rest/namespace.d.mts +2 -0
  114. package/dist/rest/queue.d.mts +208 -208
  115. package/dist/rest/refs.d.mts +131 -131
  116. package/dist/rest/repos.d.mts +12 -12
  117. package/dist/rest/tags.d.mts +70 -70
  118. package/dist/rest/tokens.d.mts +23 -23
  119. package/dist/rest/topics.d.mts +111 -111
  120. package/dist/rest/trees.d.mts +57 -57
  121. package/dist/rest/wire.d.mts +2 -0
  122. package/dist/rest/wire.mjs +2 -2
  123. package/dist/rest/work.d.mts +6 -6
  124. package/dist/server/edge-node.d.mts +20 -0
  125. package/dist/server/edge-node.mjs +20 -0
  126. package/dist/server/edge.d.mts +10 -0
  127. package/dist/server/edge.mjs +23 -0
  128. package/dist/server/extension.mjs +1 -1
  129. package/dist/server/git-layer.d.mts +15 -4
  130. package/dist/server/git-layer.mjs +13 -2
  131. package/dist/server/git-namespace.d.mts +5 -4
  132. package/dist/server/git-namespace.mjs +6 -3
  133. package/dist/server/registry.d.mts +3 -0
  134. package/dist/server/registry.mjs +58 -7
  135. package/dist/server/server.d.mts +3 -0
  136. package/dist/server/server.mjs +81 -39
  137. package/dist/server/uploads.d.mts +14 -0
  138. package/dist/server/uploads.mjs +15 -0
  139. package/dist/storage/calls.d.mts +7 -8
  140. package/dist/storage/calls.mjs +14 -14
  141. package/dist/storage/clean-up.mjs +59 -29
  142. package/dist/storage/host-bucket.mjs +16 -1
  143. package/dist/storage/index-build.d.mts +1 -1
  144. package/dist/storage/layout.mjs +5 -0
  145. package/dist/storage/merge.d.mts +1 -1
  146. package/dist/storage/push-uploads.mjs +12 -16
  147. package/dist/storage/quarantine.d.mts +1 -1
  148. package/dist/storage/quarantine.mjs +51 -12
  149. package/dist/storage/receive-bounds.d.mts +1 -1
  150. package/dist/storage/repack-job.d.mts +1 -1
  151. package/dist/storage/repack-job.mjs +7 -14
  152. package/dist/storage/rows.mjs +42 -3
  153. package/dist/storage/runs.d.mts +1 -1
  154. package/dist/store/job-try.mjs +26 -0
  155. package/dist/store/list-job.mjs +22 -16
  156. package/dist/store/outbox.mjs +38 -12
  157. package/dist/store/promises.d.mts +6 -1
  158. package/dist/store/promises.mjs +74 -89
  159. package/dist/store/queue-jobs.mjs +22 -1
  160. package/dist/store/scopes.mjs +0 -10
  161. package/dist/sync/mirror.d.mts +1 -1
  162. package/dist/sync/mirror.mjs +1 -1
  163. package/dist/sync/publish.mjs +12 -7
  164. package/dist/sync/step.mjs +4 -0
  165. package/package.json +3 -3
  166. package/dist/lfs/repo.mjs +0 -42
  167. package/dist/storage/promise-calls.mjs +0 -29
@@ -3,7 +3,7 @@ import { joinedBytes } from "../bytes/joined.mjs";
3
3
  import { isOid, quoted } from "../bytes/text.mjs";
4
4
  import { delimPkt, pktText, readPkt } from "../framing/pkt-line.mjs";
5
5
  import { AdvertisedRef, headOf, pastServiceLine, servedHead } from "./advertisement.mjs";
6
- import { byName, decoded, isWord, listsRef, readSection, refusedText, textLines, unwritable } from "./lines.mjs";
6
+ import { byName, decoded, gitsOwnRefs, isWord, listsRef, readSection, refusedText, textLines, unwritable } from "./lines.mjs";
7
7
  import * as Schema from "effect/Schema";
8
8
  import * as Effect from "effect/Effect";
9
9
  import * as Result from "effect/Result";
@@ -110,24 +110,19 @@ const readLsRefs = (request) => decoded("ls-refs", () => {
110
110
  const peeledAs = (asked) => (oid) => asked.peel && oid !== void 0 ? ` peeled:${oid}` : "";
111
111
  /** `ls-refs`'s `HEAD` line, when `asked` lists it, as `encodeLsRefs` says. */
112
112
  const headLines = (served, asked) => {
113
- if (!listsRef("HEAD", asked.prefixes)) return [];
113
+ if (!listsRef([], "HEAD", asked.prefixes)) return [];
114
114
  const head = headOf(served);
115
115
  const target = asked.symrefs ? ` symref-target:${served.head}` : "";
116
116
  if (head !== void 0) return [`${head.oid} HEAD${target}${peeledAs(asked)(head.peeled)}\n`];
117
117
  return asked.unborn && asked.symrefs && served.head !== void 0 ? [`unborn HEAD${target}\n`] : [];
118
118
  };
119
- /**
120
- * `ls-refs`'s answer, as Git's: `HEAD` first when it resolves, or `unborn HEAD` when it doesn't
121
- * and both `unborn` and `symrefs` were asked, then each listed ref in Git's order, each line
122
- * `<oid> <name>`, with `symref-target:` for `HEAD` and `peeled:` for an annotated tag as asked,
123
- * then a flush.
124
- */
125
- const encodeLsRefs = /* @__PURE__ */ Effect.fnUntraced(function* (served, asked) {
119
+ /** `ls-refs`'s answer, as `encodeLsRefs` says, past `table`'s hidden prefixes. */
120
+ const lsRefsOf = /* @__PURE__ */ Effect.fnUntraced(function* (served, asked, table) {
126
121
  const listing = {};
127
122
  const headRef = headOf(served);
128
123
  if (served.head !== void 0) listing.head = served.head;
129
124
  if (headRef !== void 0) listing.headRef = headRef;
130
- const lines = lsRefsPages(listing, asked);
125
+ const lines = lsRefsPages(listing, asked, table);
131
126
  const refs = served.refs.toSorted((a, b) => byName(a.name, b.name));
132
127
  return joinedBytes([
133
128
  yield* lines.start,
@@ -136,10 +131,17 @@ const encodeLsRefs = /* @__PURE__ */ Effect.fnUntraced(function* (served, asked)
136
131
  ]);
137
132
  });
138
133
  /**
134
+ * `ls-refs`'s answer, as Git's: `HEAD` first when it resolves, or `unborn HEAD` when it doesn't
135
+ * and both `unborn` and `symrefs` were asked, then each listed ref in Git's order, each line
136
+ * `<oid> <name>`, with `symref-target:` for `HEAD` and `peeled:` for an annotated tag as asked,
137
+ * then a flush. It hides only Git's own `refs/import/`: a server hides each claim's prefix too.
138
+ */
139
+ const encodeLsRefs = (served, asked) => lsRefsOf(served, asked, gitsOwnRefs);
140
+ /**
139
141
  * `ls-refs`'s answer, as `encodeLsRefs` writes it, a page at a time (Q884): `HEAD`'s line, each
140
- * page's refs that `asked` lists, then the flush.
142
+ * page's refs that `asked` lists past `table`'s hidden prefixes, then the flush.
141
143
  */
142
- const lsRefsPages = (listed, asked) => {
144
+ const lsRefsPages = (listed, asked, table) => {
143
145
  const peeled = peeledAs(asked);
144
146
  const served = servedHead(listed);
145
147
  const lines = (names, written) => {
@@ -148,7 +150,7 @@ const lsRefsPages = (listed, asked) => {
148
150
  };
149
151
  return {
150
152
  start: Effect.suspend(() => lines(served.head === void 0 ? [] : [served.head], () => headLines(served, asked))),
151
- page: (refs) => Effect.suspend(() => lines(refs.map((ref) => ref.name), () => refs.filter((ref) => listsRef(ref.name, asked.prefixes)).map((ref) => `${ref.oid} ${ref.name}${peeled(ref.peeled)}\n`))),
153
+ page: (refs) => Effect.suspend(() => lines(refs.map((ref) => ref.name), () => refs.filter((ref) => listsRef(table, ref.name, asked.prefixes)).map((ref) => `${ref.oid} ${ref.name}${peeled(ref.peeled)}\n`))),
152
154
  end: textLines([], true)
153
155
  };
154
156
  };
@@ -257,4 +259,4 @@ const readLsRefsAnswer = (bytes) => decoded("ls-refs answer", () => {
257
259
  refs
258
260
  });
259
261
  });
260
- export { LsRefs, LsRefsAnswer, V2Advertised, V2Command, V2Request, encodeLsRefs, encodeV2Capabilities, encodeV2Request, lsRefsArguments, lsRefsPages, maxPrefixes, readLsRefs, readLsRefsAnswer, readV2Capabilities, readV2Request, v2Capabilities };
262
+ export { LsRefs, LsRefsAnswer, V2Advertised, V2Command, V2Request, encodeLsRefs, encodeV2Capabilities, encodeV2Request, lsRefsArguments, lsRefsOf, lsRefsPages, maxPrefixes, readLsRefs, readLsRefsAnswer, readV2Capabilities, readV2Request, v2Capabilities };
@@ -15,7 +15,7 @@ import { handingOn } from "../protocol/packs/writer.mjs";
15
15
  import { memoryPack } from "../storage/fetch.mjs";
16
16
  import { gitObjectOf } from "../storage/object-rows.mjs";
17
17
  import { decodeRow } from "../store/errors.mjs";
18
- import { runJobTry } from "../store/crossing.mjs";
18
+ import { madeJob } from "../store/job-try.mjs";
19
19
  import { readRecord } from "../store/repo-record.mjs";
20
20
  import { isLive, liveState } from "../store/reservations.mjs";
21
21
  import { collections, jobRepo } from "../store/scopes.mjs";
@@ -24,24 +24,26 @@ import { queueWrite } from "./commit.mjs";
24
24
  import { queueRef } from "./ids.mjs";
25
25
  import { askCallers, callerKey, callersOf, entryEnvelope } from "./callers.mjs";
26
26
  import { CandidateRow } from "./rows.mjs";
27
- import { queueLimits } from "./limits.mjs";
27
+ import { queueTrimJob } from "./trim.mjs";
28
+ import { queueJobRetry, queueLimits } from "./limits.mjs";
28
29
  import { lanesOf, opensAlone, placeOf, placed } from "./lanes.mjs";
29
30
  import { concurrencyOf, roomFor, schedulesOf } from "./schedule.mjs";
30
31
  import { blameGroup, failEntries, groupsOf, openSearched, passGroup, reportDetails, splitGroup, splitMost, startSearch } from "./search.mjs";
31
32
  import { QueuePlan, entryNotes, loadTarget, openHolds, orderOf, storedId } from "./state.mjs";
32
33
  import { AdvanceData, CandidateData, advanceName, buildName, buildRow, timeoutName, timeoutRow } from "../store/queue-jobs.mjs";
33
34
  import { addTargetHold, advanceAfter, closeAll, closeCandidate, endEntry, entryOf, isOpen, movedOutside, releaseHold, removeEntry, stackOf, workHolds } from "./steps.mjs";
34
- import { defineJob } from "@ref0/infra";
35
+ import { CurrentJob, Job } from "@ref0/infra";
35
36
  import * as Schema from "effect/Schema";
36
37
  import * as Effect from "effect/Effect";
37
38
  import * as Predicate from "effect/Predicate";
38
39
  import * as Clock$1 from "effect/Clock";
39
40
  // src/queue/advance.ts
40
41
  /**
41
- * The queue's three jobs. `queue.advance`, one per target, moves it on a step at a time: a
42
+ * The queue's jobs. `queue.advance`, one per target, moves it on a step at a time: a
42
43
  * tip moved by anything but the queue restarts its candidates, a passed candidate publishes, a
43
44
  * failed one fails its entries, and with none open the next entry opens one. `queue.build`
44
45
  * writes a candidate's commits; `queue.report-timeout` closes one whose report is late.
46
+ * `queue.trim`, one per repo, in `trim.ts`, deletes what ended long ago.
45
47
  */
46
48
  /** Steps one advance run takes before it asks for another, due now, for the rest. */
47
49
  const stepsMost = 10;
@@ -53,10 +55,18 @@ const liftedStep = {
53
55
  moved: true,
54
56
  lifted: true
55
57
  };
56
- /**
57
- * `step` over the server's services for one try of its job: its parts over the try's fenced store,
58
- * and the `Authorize` it decides with. A plan's write runs as host code or not, as `pushPlan` says.
59
- */
58
+ /** `run` over the try's job, given `data`, and its store and signal, from `CurrentJob`. */
59
+ const queueTry = (data, run) => Effect.flatMap(Effect.all([
60
+ CurrentJob.current,
61
+ CurrentJob.store,
62
+ CurrentJob.signal
63
+ ]), ([job, store, signal]) => run({
64
+ ...job,
65
+ data
66
+ }, {
67
+ store,
68
+ signal
69
+ }));
60
70
  const overCore = (host, context, step) => Effect.provideContext(overStore(context.store)(step), host.needs);
61
71
  /** A plan's write by the queue itself, its rules skipped: the calls that led to it were checked. */
62
72
  const queueOwn = (context, plan, answer) => ({
@@ -130,6 +140,28 @@ const publishPlan = (state, now, id, row, commit, judged, callers) => {
130
140
  });
131
141
  return plan;
132
142
  };
143
+ /** A bisect's key: its failed candidate, its entries and the most its groups may name. */
144
+ const groupsKey = (id, entries, most) => JSON.stringify([
145
+ id,
146
+ most,
147
+ entries
148
+ ]);
149
+ /**
150
+ * `groupsOf`, but once per try for a candidate, its entries and its most: a step planned again
151
+ * after its write found the version moved, by any write in the repo, takes the groups the host
152
+ * gave, as it saw the lane then, so the host's `bisect` and `onError` hear of it once.
153
+ */
154
+ const triedGroups = (tried, state, options, id, candidate, most) => {
155
+ const key = groupsKey(id, candidate.entries, most);
156
+ if (tried.groups?.key === key) return Effect.succeed(tried.groups.groups);
157
+ return Effect.map(groupsOf(state, options, id, candidate, most), (groups) => {
158
+ tried.groups = {
159
+ key,
160
+ groups
161
+ };
162
+ return groups;
163
+ });
164
+ };
133
165
  /**
134
166
  * A link's key: the SHA-256 of the commit it links onto and the entry as the host's `merge` sees
135
167
  * it, its head, priority, meta and report among it, so a change to any of them links again.
@@ -172,7 +204,7 @@ const askedPlan = /* @__PURE__ */ Effect.fnUntraced(function* (host, context, st
172
204
  * its one entry, or a recheck's all, `interaction`; else its bisect starts, while the target has
173
205
  * room for one, and with none its entries wait again, none failed.
174
206
  */
175
- const failedPlan = /* @__PURE__ */ Effect.fnUntraced(function* (state, now, options, { id, candidate }) {
207
+ const failedPlan = /* @__PURE__ */ Effect.fnUntraced(function* (state, now, options, tried, { id, candidate }) {
176
208
  const plan = new QueuePlan(state, now);
177
209
  const details = reportDetails(candidate.report);
178
210
  const blame = candidate.blame ?? [];
@@ -180,17 +212,23 @@ const failedPlan = /* @__PURE__ */ Effect.fnUntraced(function* (state, now, opti
180
212
  if (blame.length > 0 || entries.length === 1) failEntries(plan, id, blame.length > 0 ? blame : entries, "reported", details);
181
213
  else if (candidate.recheck === true) failEntries(plan, id, entries, "interaction", details);
182
214
  else if ((state.row.searches ?? []).length >= queueLimits.searches) closeCandidate(plan, id, "failed");
183
- else startSearch(plan, id, yield* groupsOf(state, options, id, candidate, 2 * entries.length));
215
+ else {
216
+ const most = 2 * entries.length;
217
+ startSearch(plan, id, yield* triedGroups(tried, state, options, id, candidate, most));
218
+ }
184
219
  return plan;
185
220
  });
186
221
  /** The plan for a bisect group's report: a pass, a failure of what it blamed or held, or a split. */
187
- const judgedPlan = /* @__PURE__ */ Effect.fnUntraced(function* (state, now, options, { id, candidate }) {
222
+ const judgedPlan = /* @__PURE__ */ Effect.fnUntraced(function* (state, now, options, tried, { id, candidate }) {
188
223
  const plan = new QueuePlan(state, now);
189
224
  const blame = candidate.blame ?? [];
190
225
  const { entries } = candidate;
191
226
  if (candidate.report?.verdict === "pass") passGroup(plan, id);
192
227
  else if (blame.length > 0 || entries.length === 1) blameGroup(plan, id, blame.length > 0 ? blame : entries, reportDetails(candidate.report));
193
- else splitGroup(plan, id, yield* groupsOf(state, options, id, candidate, splitMost(plan, id)));
228
+ else {
229
+ const most = splitMost(plan, id);
230
+ splitGroup(plan, id, yield* triedGroups(tried, state, options, id, candidate, most));
231
+ }
194
232
  return plan;
195
233
  });
196
234
  /**
@@ -245,12 +283,12 @@ const advanceStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, context,
245
283
  const stack = opened(stackOf(state));
246
284
  const failed = stack.find(({ candidate }) => candidate.report?.verdict === "fail");
247
285
  if (failed !== void 0) {
248
- const plan = yield* failedPlan(state, now, options, failed);
286
+ const plan = yield* failedPlan(state, now, options, tried, failed);
249
287
  return queueOwn(context, plan, againStep);
250
288
  }
251
289
  const judged = opened(row.open).find(({ candidate }) => candidate.group !== void 0 && candidate.report !== void 0);
252
290
  if (judged !== void 0) {
253
- const plan = yield* judgedPlan(state, now, options, judged);
291
+ const plan = yield* judgedPlan(state, now, options, tried, judged);
254
292
  return queueOwn(context, plan, againStep);
255
293
  }
256
294
  const { reserved } = row;
@@ -1020,7 +1058,7 @@ const batchTooSlow = (seconds) => /* @__PURE__ */ new Error(`This batch's try ra
1020
1058
  * none, where `then`'s `repo.work.failed` alone says so. `more` adds to the plan, as `unbatch`
1021
1059
  * does, and a batch it closed on a try's timeout reaches `then` as `batchTooSlow`.
1022
1060
  */
1023
- const holdOnFailure = (host, stateOf, then, more) => async (job, failure, context) => {
1061
+ const holdOnFailure = (host, stateOf, then, more) => (data, failure) => queueTry(data, (job, context) => {
1024
1062
  let unbatched = false;
1025
1063
  const hold = Effect.gen(function* () {
1026
1064
  const done = {
@@ -1048,24 +1086,30 @@ const holdOnFailure = (host, stateOf, then, more) => async (job, failure, contex
1048
1086
  if (full && !unbatched) return done;
1049
1087
  return queueOwn(context, plan, idleStep);
1050
1088
  });
1051
- try {
1052
- await runJobTry(overCore(host, context, queueWrite(hold)));
1053
- } finally {
1089
+ const passed = Effect.suspend(() => {
1054
1090
  const { error, timeout } = failure;
1055
1091
  const timedOut = error instanceof DOMException && error.name === "TimeoutError";
1056
- await then?.(job, unbatched && timeout !== void 0 && timedOut ? {
1092
+ const passing = unbatched && timeout !== void 0 && timedOut ? {
1057
1093
  ...failure,
1058
1094
  error: batchTooSlow(timeout / 1e3)
1059
- } : failure, context);
1060
- }
1061
- };
1062
- /** The queue's jobs' retry: a try that fails, as a `contended` write does, runs again after `delay`. */
1063
- const queueJobRetry = {
1064
- limit: 10,
1065
- delay: "1 second",
1066
- backoff: "exponential",
1067
- maxDelay: "5 minutes"
1068
- };
1095
+ } : failure;
1096
+ return then === void 0 ? Effect.void : then(data, passing);
1097
+ });
1098
+ return Effect.flatMap(Effect.exit(overCore(host, context, queueWrite(hold))), (held) => Effect.andThen(passed, held));
1099
+ });
1100
+ /** The queue's jobs, as `queueJobs` runs them over a host. */
1101
+ const AdvanceJob = /* @__PURE__ */ Job.make(advanceName, {
1102
+ payload: AdvanceData,
1103
+ retry: queueJobRetry
1104
+ });
1105
+ const BuildJob = /* @__PURE__ */ Job.make(buildName, {
1106
+ payload: CandidateData,
1107
+ retry: queueJobRetry
1108
+ });
1109
+ const TimeoutJob = /* @__PURE__ */ Job.make(timeoutName, {
1110
+ payload: CandidateData,
1111
+ retry: queueJobRetry
1112
+ });
1069
1113
  /**
1070
1114
  * The queue's jobs over `host`, which `createGitServer` registers beside its own, each passing its
1071
1115
  * last failure on to `onFailure` once it holds its target.
@@ -1076,31 +1120,10 @@ const queueJobs = (host, onFailure) => {
1076
1120
  const targetOf = (job, context) => loadTarget(context.store, jobRepo(job), job.data.target);
1077
1121
  const candidateOf = (job, context) => loadCandidate(context, jobRepo(job), job.data.candidate).pipe(Effect.map((loaded) => loaded?.state));
1078
1122
  return [
1079
- defineJob({
1080
- name: advanceName,
1081
- schema: Schema.toStandardSchemaV1(AdvanceData),
1082
- retry: queueJobRetry,
1083
- handler: (job, context) => runJobTry(overCore(host, context, advance(host, job, context))),
1084
- onFailure: holdOnFailure(host, targetOf, onFailure, unbatch)
1085
- }),
1086
- defineJob({
1087
- name: buildName,
1088
- schema: Schema.toStandardSchemaV1(CandidateData),
1089
- retry: queueJobRetry,
1090
- handler: async (job, context) => {
1091
- await runJobTry(overCore(host, context, build(job, context)));
1092
- },
1093
- onFailure: holdOnFailure(host, candidateOf, onFailure)
1094
- }),
1095
- defineJob({
1096
- name: timeoutName,
1097
- schema: Schema.toStandardSchemaV1(CandidateData),
1098
- retry: queueJobRetry,
1099
- handler: async (job, context) => {
1100
- await runJobTry(overCore(host, context, timeout(job, context)));
1101
- },
1102
- onFailure: holdOnFailure(host, candidateOf, onFailure)
1103
- })
1123
+ queueTrimJob(host, onFailure),
1124
+ madeJob(AdvanceJob.definition((data) => queueTry(data, (job, context) => overCore(host, context, advance(host, job, context))), { onFailure: holdOnFailure(host, targetOf, onFailure, unbatch) })),
1125
+ madeJob(BuildJob.definition((data) => queueTry(data, (job, context) => Effect.asVoid(overCore(host, context, build(job, context)))), { onFailure: holdOnFailure(host, candidateOf, onFailure) })),
1126
+ madeJob(TimeoutJob.definition((data) => queueTry(data, (job, context) => Effect.asVoid(overCore(host, context, timeout(job, context)))), { onFailure: holdOnFailure(host, candidateOf, onFailure) }))
1104
1127
  ];
1105
1128
  };
1106
- export { queueJobRetry, queueJobs };
1129
+ export { queueJobs };
@@ -21,7 +21,7 @@ import { refuseLive, reservedTarget, topicMember } from "../store/reservations.m
21
21
  import { collections, repoScope } from "../store/scopes.mjs";
22
22
  import { checkBytes, queueFull, queueLimits } from "./limits.mjs";
23
23
  import { fromReceipt, keptAnswer, queueWrite } from "./commit.mjs";
24
- import { buildRow } from "../store/queue-jobs.mjs";
24
+ import { buildRow, trimRow } from "../store/queue-jobs.mjs";
25
25
  import { branchRef, queueIdParts, queueRef, shortTarget } from "./ids.mjs";
26
26
  import { checkedLanes, isPinned } from "./lanes.mjs";
27
27
  import { candidatePage, entryPage, holdPage } from "./pages.mjs";
@@ -550,6 +550,7 @@ const addWrite = (caller, opened, laned, topic) => queueWrite(Effect.gen(functio
550
550
  if ("error" in laned) {
551
551
  row.state = "failed";
552
552
  row.failure = "host-error";
553
+ row.ended = plan.now;
553
554
  } else if (held(plan, row)) row.state = "held";
554
555
  plan.setEntry(id, row);
555
556
  const joins = () => plan.event((envelope) => {
@@ -582,6 +583,7 @@ const addWrite = (caller, opened, laned, topic) => queueWrite(Effect.gen(functio
582
583
  error: laned.error
583
584
  }));
584
585
  if (place !== void 0) advanceAfter(plan);
586
+ if (!plan.addsTarget) plan.jobs.push(trimRow(plan.now + queueLimits.kept));
585
587
  return {
586
588
  ...writeAs(caller, opened.name, plan),
587
589
  answer
@@ -1202,7 +1204,7 @@ const reviveEntries = /* @__PURE__ */ Effect.fnUntraced(function* (plan, candida
1202
1204
  for (const [id, row] of revivable(plan, candidate)) {
1203
1205
  if (plan.state.keys.get(row.key)?.latest !== id) continue;
1204
1206
  if (plan.row.order.length >= queueLimits.openEntries) return yield* queueFull("open entries", queueLimits.openEntries);
1205
- const { failure: _failure, place: kept, ...rest } = row;
1207
+ const { failure: _failure, place: kept, ended: _ended, ...rest } = row;
1206
1208
  const place = {
1207
1209
  entry: id,
1208
1210
  key: row.key,
@@ -7,6 +7,7 @@ import { bestEffort, storeCall } from "../store/errors.mjs";
7
7
  import { readRecord } from "../store/repo-record.mjs";
8
8
  import { topicScope } from "../store/scopes.mjs";
9
9
  import { topicAdvanceRow } from "../store/topic-jobs.mjs";
10
+ import { trimRow } from "../store/queue-jobs.mjs";
10
11
  import { queueLimits, targetsFull } from "./limits.mjs";
11
12
  import { noteAlone } from "./state.mjs";
12
13
  import { CoreParts, asHost } from "../core/parts.mjs";
@@ -56,7 +57,7 @@ const pushPlan = (planned) => {
56
57
  put: plan.rows(),
57
58
  delete: [],
58
59
  events: (envelope, first) => plan.eventsAt(envelope, first),
59
- jobs: plan.jobs
60
+ jobs: plan.addsTarget ? [...plan.jobs, trimRow(plan.now + queueLimits.kept)] : plan.jobs
60
61
  };
61
62
  if (unchanged !== void 0) writes.unchanged = unchanged;
62
63
  const unfenced = writes.put.find((row) => unchanged !== void 0 && !unchanged.some(({ collection, id }) => collection === row.collection && id === row.id));
@@ -77,18 +78,24 @@ const pushPlan = (planned) => {
77
78
  if (plan.publishes.size > 0) request.publishes = plan.publishes;
78
79
  if (planned.signal !== void 0) request.signal = planned.signal;
79
80
  if (planned.queued !== void 0) request.queued = planned.queued;
80
- const pushed = pushWith(request, {
81
- answer: () => Effect.succeed(planned.answer),
82
- kept: (answer) => ({
83
- kind: "queue",
84
- answer: asJson(answer)
85
- }),
86
- held: (receipt) => kept === void 0 ? fail("INTERNAL", "A queue write with no key found a receipt") : fromReceipt(kept.answer, receipt),
87
- committed: (answer, revision) => "revision" in answer ? {
88
- ...answer,
89
- revision
90
- } : answer
91
- }, kept?.key);
81
+ const pushed = CoreParts.use((core) => {
82
+ const owner = core.hiddenRefs().find((hidden) => hidden.owner.owner === "queue")?.owner;
83
+ return pushWith(owner === void 0 ? request : {
84
+ ...request,
85
+ as: owner
86
+ }, {
87
+ answer: () => Effect.succeed(planned.answer),
88
+ kept: (answer) => ({
89
+ kind: "queue",
90
+ answer: asJson(answer)
91
+ }),
92
+ held: (receipt) => kept === void 0 ? fail("INTERNAL", "A queue write with no key found a receipt") : fromReceipt(kept.answer, receipt),
93
+ committed: (answer, revision) => "revision" in answer ? {
94
+ ...answer,
95
+ revision
96
+ } : answer
97
+ }, kept?.key);
98
+ });
92
99
  return planned.host ? asHost(pushed) : pushed;
93
100
  };
94
101
  /**
@@ -1,3 +1,4 @@
1
+ import { WorkFailed } from "../core/events/deliver.mjs";
1
2
  import "../contracts/promises.mjs";
2
3
  import { Caller } from "../contracts/actors.mjs";
3
4
  import { GrantAgainRequest } from "../contracts/grants.mjs";
@@ -5,7 +6,6 @@ import { RepoName } from "../contracts/ids.mjs";
5
6
  import { MergeQueueOptions } from "../contracts/queue.mjs";
6
7
  import { GitError } from "../contracts/result.mjs";
7
8
  import { QueueNeeds } from "../core/parts.mjs";
8
- import { JobFailureHandler } from "@ref0/infra";
9
9
  import * as Effect from "effect/Effect";
10
10
  import * as Context from "effect/Context";
11
11
  /**
@@ -24,7 +24,7 @@ export interface QueueHost {
24
24
  declare const QueueBase_base: Context.ServiceClass<QueueBase, "@ref0/git/queue/QueueBase", {
25
25
  readonly needs: Context.Context<QueueNeeds>;
26
26
  readonly grantAgain: QueueHost['grantAgain'];
27
- readonly onFailure: JobFailureHandler | undefined;
27
+ readonly onFailure: WorkFailed | undefined;
28
28
  readonly attach: (host: QueueHost) => Effect.Effect<void>;
29
29
  }>;
30
30
  /**
@@ -6,8 +6,10 @@ import { Merges } from "../core/merge-parts.mjs";
6
6
  import { QueueBase } from "./host.mjs";
7
7
  import * as Layer from "effect/Layer";
8
8
  /**
9
- * The merge queue, a feature over core: it claims `queue`, adds its three jobs, and gives core its
10
- * host for `git push -o queue`. It merges through `Merges.layer`, which the host provides beside
9
+ * The merge queue, a feature over core: it claims `queue` and its prefix, `refs/queue/`, adds its
10
+ * three jobs, and gives core its host for `git push -o queue`. Its candidates live under the
11
+ * prefix, which only the queue moves and no caller but a whole one lists; a host that turns the
12
+ * queue on hides whatever refs a push left there before, as they are. It merges through `Merges.layer`, which the host provides beside
11
13
  * it. `options` are one queue every repo has, checked now, so a bad one throws a `TypeError` as
12
14
  * `MergeQueue.layer` is called, or a function of the repo, whose answers are checked as they come.
13
15
  */
@@ -29,8 +29,10 @@ const queueService = (host) => {
29
29
  };
30
30
  };
31
31
  /**
32
- * The merge queue, a feature over core: it claims `queue`, adds its three jobs, and gives core its
33
- * host for `git push -o queue`. It merges through `Merges.layer`, which the host provides beside
32
+ * The merge queue, a feature over core: it claims `queue` and its prefix, `refs/queue/`, adds its
33
+ * three jobs, and gives core its host for `git push -o queue`. Its candidates live under the
34
+ * prefix, which only the queue moves and no caller but a whole one lists; a host that turns the
35
+ * queue on hides whatever refs a push left there before, as they are. It merges through `Merges.layer`, which the host provides beside
34
36
  * it. `options` are one queue every repo has, checked now, so a bad one throws a `TypeError` as
35
37
  * `MergeQueue.layer` is called, or a function of the repo, whose answers are checked as they come.
36
38
  */
@@ -41,7 +43,10 @@ const layer = (options) => {
41
43
  const parts = yield* mergePartsOption;
42
44
  if (Option.isNone(parts)) return yield* Effect.die(/* @__PURE__ */ new TypeError("Merges.layer gives MergeParts beside Merges"));
43
45
  const base = yield* QueueBase;
44
- const claim$1 = yield* claim({ name: "queue" });
46
+ const claim$1 = yield* claim({
47
+ name: "queue",
48
+ refs: "refs/queue/"
49
+ });
45
50
  const host = {
46
51
  needs: Context.add(base.needs, MergeParts, parts.value),
47
52
  grantAgain: base.grantAgain,
@@ -1,6 +1,15 @@
1
1
  import { fail } from "../contracts/result.mjs";
2
2
  import * as Effect from "effect/Effect";
3
3
  // src/queue/limits.ts
4
+ /** The queue's jobs' retry: a try that fails, as a `contended` write does, runs again after `delay`. */
5
+ const queueJobRetry = {
6
+ limit: 10,
7
+ delay: "1 second",
8
+ backoff: "exponential",
9
+ maxDelay: "5 minutes"
10
+ };
11
+ /** A day, in milliseconds. */
12
+ const day = 864e5;
4
13
  /**
5
14
  * The queue's caps (Q411). Every write of a target reads its whole state in one store read, which
6
15
  * infra refuses past 16 MiB, and commits what it changed in one commit, refused past 8 MiB. So
@@ -52,10 +61,28 @@ import * as Effect from "effect/Effect";
52
61
  const queueLimits = {
53
62
  /**
54
63
  * Targets a repo's queues hold, each a branch it queued onto, whose first write is refused past
55
- * them as `queue-full`: a push wakes one `git.queue.advance` a target it moves, so these stay
56
- * within the 2,000 writes `pushOtherWrites` leaves (Q1117). No write deletes a target's row.
64
+ * them as `queue-targets-full`: a push wakes one `git.queue.advance` a target it moves, so these stay
65
+ * within the 2,000 writes `pushOtherWrites` leaves (Q1117). An idle target's row counts until
66
+ * `queue.trim` deletes it, `kept` after it went idle.
57
67
  */
58
68
  targets: 100,
69
+ /**
70
+ * How long `queue.trim` keeps what's ended, from when it ended (Q1128): an entry merged, failed
71
+ * or removed, with its `meta` and its key's row; a closed candidate, with its report, once none
72
+ * of its entries is left; a released hold; and an idle target's row, with its last outcomes.
73
+ * Past it, `get`, `candidate`, `retry` and the writes by ID answer `NOT_FOUND`.
74
+ */
75
+ kept: 14 * day,
76
+ /** How long `queue.trim` waits after a pass that found rows before it looks again. */
77
+ sweepEvery: day,
78
+ /**
79
+ * The entries, candidates or holds one step of `queue.trim` reads, and deletes at most: 100
80
+ * candidates of 40 KiB each are 4 MiB, beside the record. A step over candidates reads their
81
+ * entries again, up to `candidateEntries` of them, under 3.5 MiB.
82
+ */
83
+ trimPage: 100,
84
+ /** The targets' rows one step of `queue.trim` reads: a live one is up to 850 KiB. */
85
+ trimTargets: 10,
59
86
  /** Open entries a target holds: past them, `add` is `RESOURCE_EXHAUSTED`, `queue-full`. */
60
87
  openEntries: 1e3,
61
88
  /** Open holds a target holds, its own and its keys': past them, a hold is `queue-full`. */
@@ -102,9 +129,12 @@ const checkBytes = (field, value, most) => {
102
129
  };
103
130
  /** `RESOURCE_EXHAUSTED`, `queue-full`: a target holding as many of `what` as it may. */
104
131
  const queueFull = (what, most) => fail("RESOURCE_EXHAUSTED", `The queue holds ${most} ${what}, as many as it may`, { context: { reason: "queue-full" } });
105
- /** `RESOURCE_EXHAUSTED`, `queue-full`: a repo whose queues hold `queueLimits.targets` already. */
132
+ /**
133
+ * `RESOURCE_EXHAUSTED`, `queue-targets-full`: a repo whose queues hold `queueLimits.targets`
134
+ * already, idle ones among them till `queue.trim` deletes their rows.
135
+ */
106
136
  const targetsFull = () => fail("RESOURCE_EXHAUSTED", `The repo's queues hold ${queueLimits.targets} targets, as many as it may`, {
107
- hint: `Queue onto a branch the repo queued onto before: it keeps each of its ${queueLimits.targets} targets`,
108
- context: { reason: "queue-full" }
137
+ hint: `Queue onto a branch the repo queues onto now, or wait: a target's row goes ${queueLimits.kept / day} days after its queue went idle`,
138
+ context: { reason: "queue-targets-full" }
109
139
  });
110
- export { checkBytes, jsonSize, queueFull, queueLimits, targetsFull };
140
+ export { checkBytes, jsonSize, queueFull, queueJobRetry, queueLimits, targetsFull };
@@ -64,6 +64,9 @@ const PlaceRow = /* @__PURE__ */ Schema.Struct({
64
64
  * candidate merged, `b` for one its report failed and `c` for one closed otherwise; `previous`: the `concurrency` last asked.
65
65
  * `reserved`: the topic holding the target, at its attempt, which refuses every other writer while
66
66
  * that attempt is live, the queue's own publish and `restart` among them (Q557), `since` it took it.
67
+ * `idle`: when the row was put with nothing open, held, searched or reserved, which every later
68
+ * put of an idle row keeps, and one that isn't drops: `queue.trim` deletes it `queueLimits.kept`
69
+ * after.
67
70
  */
68
71
  const TargetRow = /* @__PURE__ */ Schema.Struct({
69
72
  order: Schema.Array(PlaceRow),
@@ -79,7 +82,8 @@ const TargetRow = /* @__PURE__ */ Schema.Struct({
79
82
  reserved: Schema.optionalKey(Schema.Struct({
80
83
  ...Reservation.fields,
81
84
  since: Schema.Int
82
- }))
85
+ })),
86
+ idle: Schema.optionalKey(Schema.Finite)
83
87
  });
84
88
  /**
85
89
  * An entry. Its `meta`, when it has one, is a row of its own, which no write of the target reads;
@@ -134,7 +138,9 @@ const EntryRow = /* @__PURE__ */ Schema.Struct({
134
138
  joined: Schema.Int,
135
139
  since: Schema.Finite,
136
140
  jumped: Schema.optionalKey(Schema.Int)
137
- }))
141
+ })),
142
+ /** When it merged, failed or was removed, which `queue.trim` counts `queueLimits.kept` from. */
143
+ ended: Schema.optionalKey(Schema.Finite)
138
144
  });
139
145
  /**
140
146
  * A failed candidate's bisect: its groups not yet judged, each with the candidate open for it once
@@ -193,11 +199,13 @@ const CandidateRow = /* @__PURE__ */ Schema.Struct({
193
199
  landed: Schema.optionalKey(Schema.Struct({
194
200
  tip: Schema.NullOr(Schema.String),
195
201
  commit: Schema.String
196
- }))
202
+ })),
203
+ /** When it closed, or its bisect ended after: what `queue.trim` counts `queueLimits.kept` from. */
204
+ ended: Schema.optionalKey(Schema.Finite)
197
205
  });
198
206
  /**
199
207
  * An entry's hold names its `key` too, which it follows, and a `work-failed` hold the queue job it
200
- * waits on, with the claim it last failed under; `released` once it's let go.
208
+ * waits on, with the claim it last failed under; `released` once it's let go, `ended` when.
201
209
  */
202
210
  const HoldRow = /* @__PURE__ */ Schema.Struct({
203
211
  target: Schema.String,
@@ -209,6 +217,7 @@ const HoldRow = /* @__PURE__ */ Schema.Struct({
209
217
  key: Schema.String,
210
218
  claim: Schema.Int
211
219
  })),
212
- released: Schema.optionalKey(Schema.Literal(true))
220
+ released: Schema.optionalKey(Schema.Literal(true)),
221
+ ended: Schema.optionalKey(Schema.Finite)
213
222
  });
214
223
  export { CandidateRow, CounterRow, EntryRow, HoldRow, KeyRow, MetaRow, PlaceRow, ReportRow, SearchRow, TargetRow };
@@ -41,6 +41,17 @@ const named = (row, reading) => ({
41
41
  });
42
42
  /** The IDs of a target's open holds: its own, then each key's. */
43
43
  const openHolds = (row) => [...row.holds, ...Object.values(row.keyHolds).flat()];
44
+ /**
45
+ * A target's row as it's put: `idle` since the first put that left it with nothing open, held,
46
+ * searched or reserved, and no `idle` once it has any.
47
+ */
48
+ const idleStamped = (row, now) => {
49
+ const { idle, ...rest } = row;
50
+ return row.order.length > 0 || row.open.length > 0 || openHolds(row).length > 0 || (row.searches ?? []).length > 0 || row.reserved !== void 0 ? rest : {
51
+ ...rest,
52
+ idle: idle ?? now
53
+ };
54
+ };
44
55
  const idReads = (collection, ids) => ids.map((id) => ({
45
56
  collection,
46
57
  id
@@ -251,11 +262,14 @@ var QueuePlan = class {
251
262
  });
252
263
  for (const changed of this.#changed) {
253
264
  const [kind, id = ""] = changed.split(/:(.*)/s);
254
- if (kind === "target") put.push({
255
- collection: collections.queueTargets,
256
- id: this.state.target,
257
- value: this.#row
258
- });
265
+ if (kind === "target") {
266
+ const value = idleStamped(this.#row, this.now);
267
+ put.push({
268
+ collection: collections.queueTargets,
269
+ id: this.state.target,
270
+ value
271
+ });
272
+ }
259
273
  if (kind === "e") put.push({
260
274
  collection: collections.queueEntries,
261
275
  id,
@@ -110,7 +110,8 @@ const closeCandidate = (plan, id, reason, extra = {}) => {
110
110
  const closed = {
111
111
  ...open,
112
112
  state: "closed",
113
- reason
113
+ reason,
114
+ ended: plan.now
114
115
  };
115
116
  if (extra.report !== void 0) closed.report = extra.report;
116
117
  plan.setCandidate(id, closed);
@@ -143,7 +144,10 @@ const endSearch = (plan, failed) => {
143
144
  const row = plan.candidates.get(failed);
144
145
  if (row?.search === void 0) return;
145
146
  const { search, ...ended } = row;
146
- plan.setCandidate(failed, ended);
147
+ plan.setCandidate(failed, {
148
+ ...ended,
149
+ ended: plan.now
150
+ });
147
151
  plan.setTarget({
148
152
  ...plan.row,
149
153
  searches: (plan.row.searches ?? []).filter((open) => open !== failed)
@@ -210,7 +214,8 @@ const endEntry = (plan, id, state, extra = {}) => {
210
214
  plan.setEntry(id, {
211
215
  ...rest,
212
216
  state,
213
- ...extra
217
+ ...extra,
218
+ ended: plan.now
214
219
  });
215
220
  plan.setTarget({
216
221
  ...plan.row,
@@ -297,7 +302,8 @@ const releaseKey = (plan, key, hold) => {
297
302
  const releaseHold = (plan, hold, row) => {
298
303
  plan.setHold(hold, {
299
304
  ...row,
300
- released: true
305
+ released: true,
306
+ ended: plan.now
301
307
  });
302
308
  if (row.key === void 0) plan.setTarget({
303
309
  ...plan.row,