@ref0/git 0.7.0 → 0.8.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 (191) hide show
  1. package/dist/access/private-refs.mjs +0 -2
  2. package/dist/auth/authorize.mjs +31 -24
  3. package/dist/auth/bridge.mjs +8 -8
  4. package/dist/auth/fences.d.mts +0 -1
  5. package/dist/auth/fences.mjs +1 -1
  6. package/dist/auth/grants.d.mts +0 -1
  7. package/dist/auth/grants.mjs +2 -2
  8. package/dist/auth/host-function.d.mts +1 -7
  9. package/dist/auth/host-function.mjs +38 -38
  10. package/dist/auth/identify.d.mts +0 -1
  11. package/dist/auth/identify.mjs +1 -1
  12. package/dist/auth/policy.d.mts +7 -4
  13. package/dist/auth/policy.mjs +13 -10
  14. package/dist/auth/token-rows.mjs +2 -5
  15. package/dist/auth/tokens-layer.d.mts +0 -2
  16. package/dist/auth/tokens-public.d.mts +3 -3
  17. package/dist/auth/tokens-public.mjs +4 -2
  18. package/dist/auth/tokens.d.mts +6 -1
  19. package/dist/auth/tokens.mjs +7 -1
  20. package/dist/client/client.d.mts +22 -15
  21. package/dist/client/client.mjs +31 -27
  22. package/dist/client/git-http.mjs +22 -5
  23. package/dist/client/local.mjs +1 -1
  24. package/dist/client/namespace.d.mts +2 -0
  25. package/dist/client/push-upload.d.mts +1 -0
  26. package/dist/client/push-upload.mjs +169 -2
  27. package/dist/client/remote-helper.mjs +2 -4
  28. package/dist/client/remote.mjs +37 -15
  29. package/dist/client/run-remote-helper.mjs +4 -4
  30. package/dist/client/transport.mjs +26 -19
  31. package/dist/contracts/actors.d.mts +57 -28
  32. package/dist/contracts/actors.mjs +38 -2
  33. package/dist/contracts/authorize.d.mts +21 -15
  34. package/dist/contracts/callers.mjs +40 -0
  35. package/dist/contracts/client.d.mts +16 -9
  36. package/dist/contracts/events.d.mts +12 -10
  37. package/dist/contracts/events.mjs +8 -6
  38. package/dist/contracts/files.d.mts +42 -42
  39. package/dist/contracts/forks.d.mts +0 -24
  40. package/dist/contracts/git-hooks.d.mts +217 -0
  41. package/dist/contracts/git-hooks.mjs +3 -1
  42. package/dist/contracts/grants.d.mts +46 -27
  43. package/dist/contracts/lfs.d.mts +17 -4
  44. package/dist/contracts/merges.d.mts +7 -7
  45. package/dist/contracts/objects.d.mts +20 -4
  46. package/dist/contracts/opaque.mjs +19 -1
  47. package/dist/contracts/operations.d.mts +8 -1
  48. package/dist/contracts/operations.mjs +209 -0
  49. package/dist/contracts/queue.d.mts +3 -3
  50. package/dist/contracts/queue.mjs +5 -18
  51. package/dist/contracts/remote.d.mts +13 -4
  52. package/dist/contracts/remote.mjs +3 -3
  53. package/dist/contracts/repos.d.mts +11 -40
  54. package/dist/contracts/repos.mjs +11 -10
  55. package/dist/contracts/result.d.mts +28 -11
  56. package/dist/contracts/result.mjs +32 -2
  57. package/dist/contracts/rules.d.mts +706 -46
  58. package/dist/contracts/rules.mjs +81 -2
  59. package/dist/contracts/server.d.mts +5 -275
  60. package/dist/contracts/services.d.mts +0 -3
  61. package/dist/contracts/services.mjs +1 -3
  62. package/dist/contracts/signin.d.mts +2 -2
  63. package/dist/contracts/signin.mjs +4 -5
  64. package/dist/contracts/sync.d.mts +1 -4
  65. package/dist/contracts/tokens.d.mts +29 -17
  66. package/dist/contracts/tokens.mjs +14 -3
  67. package/dist/contracts/topics.d.mts +38 -11
  68. package/dist/contracts/topics.mjs +8 -2
  69. package/dist/core/access.d.mts +0 -2
  70. package/dist/core/access.mjs +15 -4
  71. package/dist/core/events/deliver.mjs +19 -1
  72. package/dist/core/forks.mjs +30 -11
  73. package/dist/core/hooks/groups.d.mts +0 -1
  74. package/dist/core/hooks/groups.mjs +8 -9
  75. package/dist/core/loose-tally.mjs +46 -0
  76. package/dist/core/objects/writing.mjs +1 -0
  77. package/dist/core/promise.mjs +1 -15
  78. package/dist/core/purge.mjs +14 -9
  79. package/dist/core/push.mjs +13 -6
  80. package/dist/core/ref-view.mjs +14 -6
  81. package/dist/core/repack.mjs +19 -14
  82. package/dist/core/repo-info.mjs +8 -6
  83. package/dist/core/repos.mjs +1 -0
  84. package/dist/core/rules/check.mjs +10 -10
  85. package/dist/core/rules/context.d.mts +3 -1
  86. package/dist/core/rules/context.mjs +16 -13
  87. package/dist/core/rules/fetch.mjs +17 -23
  88. package/dist/core/tokens.mjs +2 -1
  89. package/dist/effect.d.mts +2 -4
  90. package/dist/effect.mjs +2 -4
  91. package/dist/engine/commits.mjs +19 -47
  92. package/dist/engine/failures.d.mts +1 -2
  93. package/dist/engine/failures.mjs +1 -3
  94. package/dist/engine/merge-base-walk.mjs +57 -142
  95. package/dist/engine/merge-bases.mjs +5 -5
  96. package/dist/engine/merge.mjs +16 -14
  97. package/dist/extend.d.mts +1 -2
  98. package/dist/extend.mjs +1 -2
  99. package/dist/http/core-parts.mjs +1 -2
  100. package/dist/http/handler.mjs +11 -31
  101. package/dist/http/parts.d.mts +0 -1
  102. package/dist/index.d.mts +28 -21
  103. package/dist/index.mjs +5 -2
  104. package/dist/lfs/base.d.mts +6 -3
  105. package/dist/lfs/base.mjs +2 -1
  106. package/dist/lfs/layer.d.mts +4 -3
  107. package/dist/lfs/layer.mjs +23 -9
  108. package/dist/lfs/objects.mjs +90 -41
  109. package/dist/lfs/pointers.mjs +69 -18
  110. package/dist/lfs/purge.mjs +6 -2
  111. package/dist/lfs/rows.mjs +24 -7
  112. package/dist/lfs/service.d.mts +6 -3
  113. package/dist/lfs/service.mjs +8 -2
  114. package/dist/lfs/upkeep.mjs +44 -26
  115. package/dist/lfs/upload-most.mjs +41 -0
  116. package/dist/lfs/uploaded.mjs +59 -0
  117. package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
  118. package/dist/protocol/bytes/text.mjs +6 -1
  119. package/dist/protocol/objects/fsck.mjs +6 -3
  120. package/dist/queue/advance.mjs +38 -8
  121. package/dist/queue/calls.mjs +4 -14
  122. package/dist/queue/lanes.mjs +1 -1
  123. package/dist/queue/rows.mjs +8 -0
  124. package/dist/queue/schedule.mjs +1 -1
  125. package/dist/queue/search.mjs +3 -4
  126. package/dist/rest/client-namespace.d.mts +2 -0
  127. package/dist/rest/client.d.mts +32 -8
  128. package/dist/rest/client.mjs +308 -382
  129. package/dist/rest/commits.d.mts +240 -240
  130. package/dist/rest/files.d.mts +18 -18
  131. package/dist/rest/forks.d.mts +45 -57
  132. package/dist/rest/handlers.mjs +2 -1
  133. package/dist/rest/listen.d.mts +8 -6
  134. package/dist/rest/listen.mjs +31 -75
  135. package/dist/rest/me.d.mts +2 -2
  136. package/dist/rest/merges.d.mts +7 -7
  137. package/dist/rest/refs.d.mts +139 -139
  138. package/dist/rest/repos.d.mts +54 -66
  139. package/dist/rest/tokens.d.mts +12 -12
  140. package/dist/rest/topics.d.mts +110 -110
  141. package/dist/rest/trees.d.mts +66 -66
  142. package/dist/rest/wire.d.mts +1 -1
  143. package/dist/rest.d.mts +1 -7
  144. package/dist/rest.mjs +1 -5
  145. package/dist/server/git-layer.d.mts +10 -2
  146. package/dist/server/git-layer.mjs +29 -10
  147. package/dist/server/joined.d.mts +1 -1
  148. package/dist/server/server.d.mts +0 -1
  149. package/dist/server/server.mjs +26 -45
  150. package/dist/signin/context.d.mts +0 -1
  151. package/dist/signin/context.mjs +5 -9
  152. package/dist/storage/clean-up.mjs +3 -1
  153. package/dist/storage/fsck.mjs +12 -2
  154. package/dist/storage/graph-rebuild.mjs +262 -0
  155. package/dist/storage/index-build.mjs +100 -12
  156. package/dist/storage/lfs-pointers.d.mts +5 -5
  157. package/dist/storage/lfs-pointers.mjs +37 -11
  158. package/dist/storage/loose.mjs +4 -1
  159. package/dist/storage/memory-budget.mjs +1 -1
  160. package/dist/storage/merge-fence.mjs +81 -19
  161. package/dist/storage/merge-most.mjs +1 -0
  162. package/dist/storage/merge-row.mjs +16 -4
  163. package/dist/storage/merge-stream.mjs +9 -6
  164. package/dist/storage/object-rows.mjs +17 -1
  165. package/dist/storage/pack-receive.mjs +10 -6
  166. package/dist/storage/packs.mjs +58 -27
  167. package/dist/storage/prune.mjs +68 -40
  168. package/dist/storage/ready.d.mts +1 -1
  169. package/dist/storage/ready.mjs +12 -3
  170. package/dist/storage/receive-state.mjs +1 -1
  171. package/dist/storage/repack-contained.mjs +22 -14
  172. package/dist/storage/repack.d.mts +1 -1
  173. package/dist/storage/repack.mjs +3 -2
  174. package/dist/storage/unpack.mjs +7 -0
  175. package/dist/store/call-count.d.mts +23 -3
  176. package/dist/store/call-count.mjs +36 -13
  177. package/dist/store/records.mjs +10 -4
  178. package/dist/store/repo-record.mjs +29 -12
  179. package/dist/store/scopes.mjs +6 -1
  180. package/dist/sync/import.mjs +14 -2
  181. package/dist/sync/layer.d.mts +5 -1
  182. package/dist/sync/layer.mjs +7 -2
  183. package/dist/sync/step.mjs +15 -15
  184. package/dist/topics/advance.mjs +7 -6
  185. package/dist/topics/members.mjs +38 -9
  186. package/package.json +3 -3
  187. package/dist/engine/merge-base-walk.d.mts +0 -3
  188. package/dist/server/routes.d.mts +0 -32
  189. package/dist/server/routes.mjs +0 -69
  190. package/dist/sync/bridge.d.mts +0 -6
  191. package/dist/sync/bridge.mjs +0 -29
@@ -7,12 +7,23 @@ import * as Schema from "effect/Schema";
7
7
  import * as Context from "effect/Context";
8
8
  // src/contracts/tokens.ts
9
9
  const TokenId = Schema.String;
10
- /** Each scope a token can have, a ceiling `authorize` can narrow: `read`, then `report`, then `write`. */
11
- const tokenScopes = [
10
+ /**
11
+ * The scopes a grant may hold, a sign-in's or an extension's, and what Git's ceiling on a repo
12
+ * answers: `read`, then `report`, then `write`.
13
+ */
14
+ const grantScopes = [
12
15
  "read",
13
16
  "report",
14
17
  "write"
15
18
  ];
19
+ const GrantScope = /* @__PURE__ */ Schema.Literals(grantScopes);
20
+ /**
21
+ * Each scope a token can have, a ceiling `authorize` can narrow: the grant scopes, then `admin`.
22
+ * An `admin` token reaches every operation kind, as a host's own sign-in does, and covers only
23
+ * the whole host, `{ prefix: '' }`. Its ceiling never opens past the host's `Policy`: a policy
24
+ * that doesn't accept `admin` refuses it, as `Policy.signedIn` does.
25
+ */
26
+ const tokenScopes = [...grantScopes, "admin"];
16
27
  const TokenScope = /* @__PURE__ */ Schema.Literals(tokenScopes);
17
28
  const repoCoverage = {
18
29
  repo: RepoName,
@@ -103,4 +114,4 @@ const list = (target, input) => Effect.flatMap(Effect.service(Tokens), (tokens)
103
114
  const get = (token, input) => Effect.flatMap(Effect.service(Tokens), (tokens) => tokens.get(token, input));
104
115
  const revoke = (token, input) => Effect.flatMap(Effect.service(Tokens), (tokens) => tokens.revoke(token, input));
105
116
  const revokeKey = (target, key, input) => Effect.flatMap(Effect.service(Tokens), (tokens) => tokens.revokeKey(target, key, input));
106
- export { CreatedToken, PrefixTarget, TokenCoverage, TokenCreate, TokenFields, TokenId, TokenInfo, TokenKey, TokenList, TokenRecord, TokenScope, TokenState, TokenTarget, Tokens, create, get, list, revoke, revokeKey, tokenScopes, tokenStates };
117
+ export { CreatedToken, GrantScope, PrefixTarget, TokenCoverage, TokenCreate, TokenFields, TokenId, TokenInfo, TokenKey, TokenList, TokenRecord, TokenScope, TokenState, TokenTarget, Tokens, create, get, grantScopes, list, revoke, revokeKey, tokenScopes, tokenStates };
@@ -187,22 +187,47 @@ export interface TopicCalls {
187
187
  report(topic: TopicId, input: TopicReportInput): Promise<ReportResult>;
188
188
  }
189
189
  /** What the topic report and `prepare` are asked about. */
190
- export interface TopicReportQuestion {
191
- readonly topic: TopicId;
192
- readonly entries: readonly TopicEntry[];
193
- }
194
- export interface PrepareInput extends TopicReportQuestion {
195
- readonly candidates: readonly TopicCandidate[];
190
+ export declare const TopicReportQuestion: Schema.Struct<{
191
+ readonly topic: Schema.String;
192
+ readonly entries: Schema.$Array<Schema.Struct<{
193
+ readonly repo: Schema.String;
194
+ readonly target: Schema.String;
195
+ readonly entry: Schema.String;
196
+ readonly key: Schema.String;
197
+ readonly source: Schema.String;
198
+ readonly head: Schema.String;
199
+ }>>;
200
+ }>;
201
+ export type TopicReportQuestion = typeof TopicReportQuestion.Type;
202
+ export declare const PrepareInput: Schema.Struct<{
203
+ readonly topic: Schema.String;
204
+ readonly entries: Schema.$Array<Schema.Struct<{
205
+ readonly repo: Schema.String;
206
+ readonly target: Schema.String;
207
+ readonly entry: Schema.String;
208
+ readonly key: Schema.String;
209
+ readonly source: Schema.String;
210
+ readonly head: Schema.String;
211
+ }>>;
212
+ readonly candidates: Schema.$Array<Schema.Struct<{
213
+ readonly repo: Schema.String;
214
+ readonly target: Schema.String;
215
+ readonly candidate: Schema.String;
216
+ readonly ref: Schema.String;
217
+ readonly commit: Schema.String;
218
+ }>>;
196
219
  /** The set key of these exact candidates: the same for the same set, whatever the call's try. */
197
- readonly key: string;
220
+ readonly key: Schema.String;
198
221
  /** This call's try, from 1: a try the server died in runs again. Not a topic's attempt (Q624). */
199
- readonly attempt: number;
200
- }
222
+ readonly attempt: Schema.Number;
223
+ }>;
224
+ export type PrepareInput = typeof PrepareInput.Type;
201
225
  /**
202
226
  * Called once a set has passed, while every target is reserved, before the publish decision: it
203
227
  * must be repeatable and reversible, since `topics.remove` may let go of the targets while it runs,
204
228
  * and its answer then counts for nothing. An accept lets the topic decide; a reject fails it
205
- * `prepare-rejected`, and a throw or a timeout `host-error`, both final (Q648).
229
+ * `prepare-rejected`, and a throw, a timeout or an answer that is neither `accept()` nor
230
+ * `reject()` `host-error`, all final (Q648).
206
231
  * A typed `GitError` failure also ends as `host-error`; a timeout interrupts the Effect.
207
232
  *
208
233
  * The call is never made again once it answered, a throw or a timeout included: only a call the
@@ -237,7 +262,9 @@ export interface TopicsLayerOptions {
237
262
  * How long a topic that holds no target yet waits for its first, from when it first waits: 1
238
263
  * millisecond to 365 days, and no longer than `timeout`. By default it's the shorter of 2 hours
239
264
  * and `timeout`, so with a `timeout` of 30 minutes a topic waits 30 minutes at most. Past it,
240
- * the topic fails `timeout`, naming what it waited for.
265
+ * the topic fails `timeout`, naming what it waited for. Halfway, a member freezes the target it
266
+ * waits on: its queue opens nothing new in another lane or at a higher priority, so the target
267
+ * drains of what's open.
241
268
  */
242
269
  readonly waitTimeout?: Duration;
243
270
  }
@@ -1,4 +1,4 @@
1
- import { Oid, RefName, RepoName } from "./ids.mjs";
1
+ import { Oid, RefName, RepoName, TopicId } from "./ids.mjs";
2
2
  import { Judged } from "./queue.mjs";
3
3
  import * as Schema from "effect/Schema";
4
4
  // src/contracts/topics.ts
@@ -109,4 +109,10 @@ const Topic = /* @__PURE__ */ Schema.Struct({
109
109
  failure: Schema.optionalKey(TopicFailure),
110
110
  waitingOn: Schema.optionalKey(TopicWait)
111
111
  });
112
- export { Topic, TopicCandidate, TopicEntry, TopicEntryInput, TopicFailure, TopicFailureReason, TopicMergedEntry, TopicState, TopicTarget, TopicWait };
112
+ /** What the topic report and `prepare` are asked about. */
113
+ const TopicReportQuestion = /* @__PURE__ */ Schema.Struct({
114
+ topic: TopicId,
115
+ entries: Schema.Array(TopicEntry)
116
+ });
117
+ ({ ...TopicReportQuestion.fields }), Schema.Array(TopicCandidate), Schema.String, Schema.Number;
118
+ export { Topic, TopicCandidate, TopicEntry, TopicEntryInput, TopicFailure, TopicFailureReason, TopicMergedEntry, TopicReportQuestion, TopicState, TopicTarget, TopicWait };
@@ -6,7 +6,6 @@ import "../contracts/operations.mjs";
6
6
  import "../contracts/result.mjs";
7
7
  import { PushRule } from "../contracts/rules.mjs";
8
8
  import "../contracts/authorize.mjs";
9
- import { HostReports } from "../auth/host-function.mjs";
10
9
  import { HookGroup } from "./hooks/groups.mjs";
11
10
  import { Ordered } from "./hooks/order.mjs";
12
11
  import { RegisteredCheck } from "./rules/context.mjs";
@@ -21,7 +20,6 @@ import { JobInput, Moment, Read } from "@ref0/infra";
21
20
  * `Rules`, and the host's hook groups, where their refusals and failures are told.
22
21
  */
23
22
  export interface PushChecks {
24
- readonly reports: HostReports;
25
23
  readonly added?: () => readonly PushRule[];
26
24
  /**
27
25
  * The checks after the host's rules, by band then registration name: each registration's push check, and LFS's
@@ -4,6 +4,7 @@ import { entryOf, nameOf, namedRecordOf, redirectOf, resolveRepo } from "../stor
4
4
  import { afterWrites, isLimitRefusal } from "../store/errors.mjs";
5
5
  import { readRecord } from "../store/repo-record.mjs";
6
6
  import { collections } from "../store/scopes.mjs";
7
+ import { readyKey } from "../storage/ready.mjs";
7
8
  import { liveReceipt, matchedReceipt, receiptReads } from "./receipts.mjs";
8
9
  import { rebuildDue } from "./ref-index.mjs";
9
10
  import { CoreParts } from "./parts.mjs";
@@ -39,11 +40,15 @@ const indexDeleteJobs = (core) => core.indexJobRow === void 0 ? [] : [core.index
39
40
  const purgeJobs = (core, at) => core.purgeJobRow === void 0 ? [] : [core.purgeJobRow(at)];
40
41
  /** The `git.ref-index` row a commit over `record` saves: one while its stamp is stale. */
41
42
  const refIndexJobs = (core, record) => core.refIndexJobRow !== void 0 && rebuildDue(core.refIndex, record) ? [core.refIndexJobRow()] : [];
42
- /** The reads `RepoInfo`'s stats are counted from, after a repo's `self`. */
43
+ /**
44
+ * The reads `RepoInfo`'s stats are counted from, after a repo's `self`: its refs, its packs, its
45
+ * `stats` times and its ready shallow pack's row.
46
+ */
43
47
  const statsReads = [
44
48
  { collection: collections.refs },
45
49
  { collection: collections.packs },
46
- { collection: collections.stats }
50
+ { collection: collections.stats },
51
+ readyKey
47
52
  ];
48
53
  /**
49
54
  * The repo `operation` names, read with `reads`, once `authorize` lets `caller` do it. A name with
@@ -83,6 +88,11 @@ const sizedRead = (read, check) => Effect.catchIf(read, isLimitRefusal, (error)
83
88
  * so the open answers as for one, asking `authorize` without the repo there (Q705).
84
89
  */
85
90
  const pinnedTo = (resolved, name, internalId) => internalId === void 0 ? resolved : Effect.flatMap(resolved, (repo) => repo.internalId === internalId ? Effect.succeed(repo) : fail("NOT_FOUND", `No repo '${name}'`));
91
+ /**
92
+ * The repo `name` names while it's still `internalId`, else `NOT_FOUND`: no `authorize`, for a
93
+ * check inside a call that asked it already, as a push's rules are.
94
+ */
95
+ const resolvedAs = (name, internalId) => Effect.flatMap(Effect.service(CoreParts), ({ store }) => pinnedTo(resolveRepo(store, name, []), name, internalId));
86
96
  /** `operation`'s repo read with `reads`, refused for size only to a caller who may open its record. */
87
97
  const sizedOpen = (caller, operation, reads, internalId) => sizedRead(Effect.flatMap(Effect.service(CoreParts), ({ store }) => pinnedTo(resolveRepo(store, operation.repo, reads), operation.repo, internalId)), openRepo(caller, operation, [], internalId));
88
98
  /**
@@ -220,7 +230,8 @@ const keyedRecord = /* @__PURE__ */ Effect.fnUntraced(function* (store, name, ke
220
230
  return {
221
231
  kind: "answered",
222
232
  receipt: yield* matchedReceipt(live, kept),
223
- repo
233
+ repo,
234
+ deleted: record.deleted === true
224
235
  };
225
236
  }
226
237
  return {
@@ -267,4 +278,4 @@ const contended = () => fail("UNAVAILABLE", "Too many writes reached this repo a
267
278
  * it back before it sends the same call again (#1462).
268
279
  */
269
280
  const contendedAfterWrites = () => Effect.fail(afterWrites(gitError("UNAVAILABLE", "Too many writes reached this repo at once")));
270
- export { alreadyExists, callerFor, confirmed, contended, contendedAfterWrites, headOf, hiddenCodes, indexDeleteJobs, indexJobs, keyedRecord, liveAsAsked, nameMoved, openFor, openKeyed, openRepo, purgeJobs, readableRedirect, refIndexJobs, repoAccess, sizedRead, statsReads, unlessHidden };
281
+ export { alreadyExists, callerFor, confirmed, contended, contendedAfterWrites, headOf, hiddenCodes, indexDeleteJobs, indexJobs, keyedRecord, liveAsAsked, nameMoved, openFor, openKeyed, openRepo, purgeJobs, readableRedirect, refIndexJobs, repoAccess, resolvedAs, sizedRead, statsReads, unlessHidden };
@@ -700,6 +700,24 @@ const sameJob = (a, b) => a.name === b.name && a.key === b.key;
700
700
  /** Whether `job` is a scope's job of a delivery, `git.deliver.<name>`. */
701
701
  const isDeliverJob = (job) => deliveryOf(job.name) !== void 0 && job.key === "deliver";
702
702
  /**
703
+ * Whether `job`'s delivery has sent the event at `seq` in `scope`: its newest cursor row is at
704
+ * `seq` or past it, or the event is gone, which a trim deletes only once every delivery has passed
705
+ * it and a purge only once none holds it. Else one with no cursor row yet has sent none, and a
706
+ * job no delivery's sends nothing.
707
+ */
708
+ const sentThrough = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope, job, seq) {
709
+ const delivery = deliveryOf(job.name);
710
+ if (delivery === void 0) return false;
711
+ const event = {
712
+ collection: outboxCollections.events,
713
+ id: eventId(seq)
714
+ };
715
+ const [cursorRows, eventRows = []] = (yield* storeCall(() => store.read(scope, [cursorRead(delivery), event]))).results;
716
+ if (eventRows.length === 0) return true;
717
+ const cursor = yield* decodeCursor(cursorRows);
718
+ return cursor !== void 0 && cursor.seq >= seq;
719
+ });
720
+ /**
703
721
  * A discard's event that has gone since it read the cursor: `delivery` passed it, by a retry, and
704
722
  * a trim deleted it, so there is nothing to skip. A trim deletes only events every delivery has
705
723
  * passed, so one gone that the cursor hasn't passed is `DATA_LOSS`.
@@ -858,4 +876,4 @@ const deliveryJob = (parts, log, delivery) => {
858
876
  const onFailure = workFailed(log, parts.now, tried);
859
877
  return gitJob(DeliverJob, handler, { onFailure });
860
878
  };
861
- export { DeliverData, checkDeliveries, checkDeliveryTimeout, defaultDeliverRetry, deliverJobKey, deliverJobName, deliverTry, deliveryLog, drainCeiling, isDeliverJob, keptFor, notFailed, skipFailed, workFailed };
879
+ export { DeliverData, checkDeliveries, checkDeliveryTimeout, defaultDeliverRetry, deliverJobKey, deliverJobName, deliverTry, deliveryLog, drainCeiling, isDeliverJob, keptFor, notFailed, sentThrough, skipFailed, workFailed };
@@ -3,6 +3,7 @@ import { fail } from "../contracts/result.mjs";
3
3
  import { objectsFace, oneShotReads } from "../storage/calls.mjs";
4
4
  import { indexRowKey, isPackId, objectCollections } from "../storage/layout.mjs";
5
5
  import { noLfsPointers } from "../storage/lfs-pointers.mjs";
6
+ import { noRows } from "../storage/object-rows.mjs";
6
7
  import { holdingsOf, swapsOf } from "../storage/repack.mjs";
7
8
  import { SwapsSettled, holdingKey, swapsKey } from "../storage/swap-walk.mjs";
8
9
  import { ApartRow, apartAfter, apartKey } from "../storage/repack-contained.mjs";
@@ -14,11 +15,12 @@ import { appendEvents, decodeOutbox, dropUnconfirmed, emptyOutbox, outboxReads,
14
15
  import { keptKey } from "../store/records.mjs";
15
16
  import { WholeRepo, refBytesOf, storesPeel, wholeRef, wholeRefs } from "../store/ref-rows.mjs";
16
17
  import { peeledAll } from "../storage/wants.mjs";
17
- import { commitRecord, decodeTimes, readRecord, timeRow, writeRecord } from "../store/repo-record.mjs";
18
+ import { commitRecord, decodeStats, looseRows, readRecord, timeRow, writeRecord } from "../store/repo-record.mjs";
18
19
  import { afterCommit } from "../store/call-count.mjs";
19
20
  import { listBound } from "../store/cursor-seal.mjs";
20
21
  import { settleName } from "../store/settle.mjs";
21
- import { collections, newChangeId, newInternalId, pushedKey, repoScope, selfKey } from "../store/scopes.mjs";
22
+ import { rowsPut } from "./loose-tally.mjs";
23
+ import { collections, looseKey, newChangeId, newInternalId, pushedKey, repoScope, selfKey } from "../store/scopes.mjs";
22
24
  import { alreadyExists, callerFor, contended, contendedAfterWrites, hiddenCodes, indexJobs, keyedRecord, nameMoved, openKeyed, openRepo, refIndexJobs, repoAccess, sizedRead, statsReads, unlessHidden } from "./access.mjs";
23
25
  import { infoReads, repoInfo } from "./repo-info.mjs";
24
26
  import { kindsOf } from "./ancestry.mjs";
@@ -42,7 +44,7 @@ import { jsonBytes, limits } from "@ref0/infra";
42
44
  * (`seenSource`): the packs are shared whole, and its reads by ID follow its own tips' reach.
43
45
  */
44
46
  const forkWhole = /* @__PURE__ */ WholeRepo.mint();
45
- /** A fork's `index` row as `repoInfo` reads it, by its place after `statsReads`'. */
47
+ /** A fork's `index` row as `repoInfo` reads it, by its place after `statsReads`' four. */
46
48
  const indexRowsOf = (rows) => rows.indexRow === void 0 ? [] : [rows.indexRow];
47
49
  const refsRead = { collection: collections.refs };
48
50
  const packsRead = { collection: collections.packs };
@@ -641,9 +643,11 @@ const forkCalls = (bound) => {
641
643
  const listing = new Set(read.listed.packs.map((pack) => pack.id));
642
644
  const covered = read.listed.packs.flatMap(({ id }) => isPackId(id) ? [leavingKey(id)] : []);
643
645
  const pushed = read.refs.length === 0 ? [] : [timeRow(pushedKey, void 0, at)];
646
+ const loose = looseRows(void 0, rowsPut(objects));
644
647
  const rows = [
645
648
  ...forkRows(core.refIndex, read, objects),
646
649
  ...pushed,
650
+ ...loose,
647
651
  ...unlisted(marked, listing, at)
648
652
  ];
649
653
  const created = {
@@ -695,7 +699,7 @@ const forkCalls = (bound) => {
695
699
  if (written.outcome === "won") return yield* afterCommit(repoInfo(caller, internalId, record, [
696
700
  read.refs,
697
701
  read.packs,
698
- pushed
702
+ [...pushed, ...loose]
699
703
  ]));
700
704
  const dropped = dropUnconfirmed(appended.head);
701
705
  const aside = commitRecord(store, internalId, {
@@ -856,7 +860,7 @@ const forkCalls = (bound) => {
856
860
  repo: name
857
861
  }), hiddenFork);
858
862
  if (record === void 0 || record.deleted === true) return yield* fail("NOT_FOUND", `No repo '${fork}'`);
859
- const [, refRows = [], packRows = [], timeRows = [], leavingRows = [], coverRows = [], indexRows = [], apartRows = [], swapsRows = []] = snapshot.results;
863
+ const [, refRows = [], packRows = [], timeRows = [], readyRows = [], leavingRows = [], coverRows = [], indexRows = [], apartRows = [], swapsRows = []] = snapshot.results;
860
864
  const [headRows = [], cursorRows = [], ...afterOutbox] = snapshot.results.slice(1 + reads.length);
861
865
  const keyed = receiptReads(kept).length;
862
866
  yield* fence.check(afterOutbox.slice(keyed));
@@ -896,6 +900,7 @@ const forkCalls = (bound) => {
896
900
  refRows,
897
901
  packRows,
898
902
  timeRows,
903
+ readyRows,
899
904
  leavingRows,
900
905
  coverRows,
901
906
  apartRows,
@@ -1000,10 +1005,14 @@ const forkCalls = (bound) => {
1000
1005
  ...lacked,
1001
1006
  ...unlisted(shared, covered, into.at),
1002
1007
  ...swapped,
1003
- ...apartAfter(found, { remove }),
1008
+ ...apartAfter(found, {
1009
+ remove,
1010
+ rows: noRows
1011
+ }),
1004
1012
  ...swapsAfter(/* @__PURE__ */ new Set([...kept, ...source.listed.packs.map(({ id }) => id)]), swapsBefore, into.walks)
1005
1013
  ],
1006
- delete: [...added.flatMap(({ id }) => isPackId(id) ? [leavingKey(id)] : []), ...held.flatMap(({ key, pack }) => key.collection === objectCollections.cover && adding.has(pack) ? [key] : [])]
1014
+ delete: [...added.flatMap(({ id }) => isPackId(id) ? [leavingKey(id)] : []), ...held.flatMap(({ key, pack }) => key.collection === objectCollections.cover && adding.has(pack) ? [key] : [])],
1015
+ rows: rowsPut(lacked)
1007
1016
  },
1008
1017
  bytes: added.reduce((sum, pack) => sum + pack.bytes, 0),
1009
1018
  objects: added.reduce((sum, pack) => sum + pack.objects, 0),
@@ -1042,7 +1051,7 @@ const forkCalls = (bound) => {
1042
1051
  const read = yield* forkTry(fork, caller, internalId, kept, (target, record) => authorizeSync(caller, target, record));
1043
1052
  if (read === void 0) continue;
1044
1053
  const { record, snapshot, name, outbox, rows } = read;
1045
- const { refRows, packRows, timeRows, leavingRows } = rows;
1054
+ const { refRows, packRows, timeRows, readyRows, leavingRows } = rows;
1046
1055
  const receipt = yield* heldReceipt(read.receipts, kept);
1047
1056
  if (receipt !== void 0) return yield* repoAnswer(receipt);
1048
1057
  const named = {
@@ -1068,6 +1077,7 @@ const forkCalls = (bound) => {
1068
1077
  refRows,
1069
1078
  packRows,
1070
1079
  timeRows,
1080
+ readyRows,
1071
1081
  indexRowsOf(rows)
1072
1082
  ]);
1073
1083
  const left = unlisted(shared, /* @__PURE__ */ new Set([...listing, ...leavingRows.map(({ id }) => id)]), at);
@@ -1165,13 +1175,19 @@ const forkCalls = (bound) => {
1165
1175
  value: { oid: to }
1166
1176
  }];
1167
1177
  const listedRows = [...packRows.filter(({ id }) => !removing.has(id)), ...added.map(packRow)];
1168
- const times = yield* decodeTimes(timeRows);
1178
+ const times = yield* decodeStats(timeRows);
1169
1179
  const pushed = timeRow(pushedKey, times.pushed, at);
1170
- const timed = [...timeRows.filter(({ id }) => id !== pushedKey.id), pushed];
1180
+ const loose = looseRows(times.loose, received.change.rows);
1181
+ const timed = [
1182
+ ...timeRows.filter(({ id }) => id !== pushedKey.id && (loose.length === 0 || id !== looseKey.id)),
1183
+ pushed,
1184
+ ...loose
1185
+ ];
1171
1186
  const info = yield* repoInfo(caller, internalId, named, [
1172
1187
  moved,
1173
1188
  listedRows,
1174
1189
  timed,
1190
+ readyRows,
1175
1191
  indexRowsOf(rows)
1176
1192
  ]);
1177
1193
  const keptWrites = receiptWrites(kept, repoKept(info), core.repackJobRow);
@@ -1204,6 +1220,7 @@ const forkCalls = (bound) => {
1204
1220
  put: leavingLate([
1205
1221
  ...decision.change.put,
1206
1222
  pushed,
1223
+ ...loose,
1207
1224
  ...keptWrites.put,
1208
1225
  ...appended.put
1209
1226
  ], late),
@@ -1307,9 +1324,11 @@ const forkCalls = (bound) => {
1307
1324
  return answer.kind === "error" ? yield* Effect.fail(answer.error) : fetched;
1308
1325
  }
1309
1326
  const late = (yield* Clock$1.currentTimeMillis) - at;
1327
+ const times = yield* decodeStats(rows.timeRows);
1328
+ const loose = looseRows(times.loose, received.change.rows);
1310
1329
  const change = {
1311
1330
  ...decision.change,
1312
- put: leavingLate(decision.change.put, late),
1331
+ put: [...leavingLate(decision.change.put, late), ...loose],
1313
1332
  jobs: [core.repackJobRow()]
1314
1333
  };
1315
1334
  yield* checkChange(source.name, change);
@@ -1,4 +1,3 @@
1
- import "../../auth/host-function.mjs";
2
1
  import { Git } from "../../contracts/git.mjs";
3
2
  import { GroupOptions, Handlers, HookPoint, PushCheckHandler } from "../../contracts/git-hooks.mjs";
4
3
  import "../../contracts/ids.mjs";
@@ -1,8 +1,8 @@
1
- import { hostEffect, rejectedError, reportRefusal } from "../../auth/host-function.mjs";
1
+ import { hostEffect, logRefusal, rejectedError } from "../../auth/host-function.mjs";
2
2
  import { register } from "../../contracts/git.mjs";
3
3
  import { handlersOf } from "../../contracts/git-hooks.mjs";
4
4
  import { millis } from "../../contracts/promises.mjs";
5
- import { checkedAnswer, pushContextOf } from "../rules/context.mjs";
5
+ import { checkedAnswer, plainAnswer, pushContextOf } from "../rules/context.mjs";
6
6
  import * as Effect from "effect/Effect";
7
7
  import * as Layer from "effect/Layer";
8
8
  // src/core/hooks/groups.ts
@@ -41,7 +41,7 @@ const group = (name, ...input) => Layer.effectDiscard(Effect.gen(function* () {
41
41
  * checks before left, unless none is left, or an atomic push already lost one. The first refusal,
42
42
  * failure or run past its timeout is the answer, which refuses every ref; `undefined` lets it on.
43
43
  */
44
- const runHookGroups = /* @__PURE__ */ Effect.fnUntraced(function* (reports, groups, checking, write) {
44
+ const runHookGroups = /* @__PURE__ */ Effect.fnUntraced(function* (groups, checking, write) {
45
45
  const left = write.updates.filter((update) => !write.refused.has(update.ref));
46
46
  const lost = left.length < write.updates.length;
47
47
  if (left.length === 0 || write.atomic && lost) return void 0;
@@ -58,14 +58,13 @@ const runHookGroups = /* @__PURE__ */ Effect.fnUntraced(function* (reports, grou
58
58
  label,
59
59
  timeout: handler.timeout
60
60
  };
61
- const call = hostEffect(reports, "hooks", about, checkedAnswer(label, () => check(input)), options);
62
- const refusal = yield* Effect.match(call, {
63
- onFailure: (error) => error,
61
+ const call = hostEffect("hooks", about, checkedAnswer(label, plainAnswer, () => check(input)), options);
62
+ const refusal = yield* Effect.matchEffect(call, {
63
+ onFailure: (error) => Effect.succeed(error),
64
64
  onSuccess: (answer) => {
65
- if (answer.kind === "accept") return void 0;
65
+ if (answer.kind === "accept") return Effect.succeed(void 0);
66
66
  const error = rejectedError(answer);
67
- reportRefusal(reports, "hooks", about, error);
68
- return error;
67
+ return Effect.as(logRefusal("hooks", about, error), error);
69
68
  }
70
69
  });
71
70
  if (refusal !== void 0) return refusal;
@@ -0,0 +1,46 @@
1
+ import { objectCollections } from "../storage/layout.mjs";
2
+ import { storeCall } from "../store/errors.mjs";
3
+ import { rowBytes } from "../store/outbox.mjs";
4
+ import { repoScope } from "../store/scopes.mjs";
5
+ import * as Effect from "effect/Effect";
6
+ import { limits } from "@ref0/infra";
7
+ // src/core/loose-tally.ts
8
+ /**
9
+ * How `change` moves the repo's object rows committed at `version`: its `rows`, less each object
10
+ * row it puts that the repo holds already, which the put only writes again (#2237). Each row is
11
+ * counted by its ID, a store read of `limits.counts` at a time: `undefined` when one answers past
12
+ * `version`, since a commit that expects it then misses anyway, and its next try counts again.
13
+ */
14
+ const rowsAtCommit = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, change, version) {
15
+ const puts = (change.put ?? []).filter((row) => row.collection === objectCollections.objects);
16
+ const scope = repoScope(internalId);
17
+ let objects = change.rows.objects;
18
+ let bytes = change.rows.bytes;
19
+ for (let at = 0; at < puts.length; at += limits.counts) {
20
+ const batch = puts.slice(at, at + limits.counts);
21
+ const counts = batch.map((row) => ({
22
+ collection: row.collection,
23
+ prefix: row.id
24
+ }));
25
+ const snapshot = yield* storeCall(() => store.read(scope, [], counts));
26
+ if (snapshot.version !== version) return void 0;
27
+ for (const [index, row] of batch.entries()) {
28
+ if ((snapshot.counts[index] ?? 0) === 0) continue;
29
+ objects -= 1;
30
+ bytes -= rowBytes(row);
31
+ }
32
+ }
33
+ return {
34
+ objects,
35
+ bytes
36
+ };
37
+ });
38
+ /** `rows`' object rows as `ObjectsChange.rows` counts a put of them: each as new. */
39
+ const rowsPut = (rows) => rows.reduce((moved, row) => row.collection === objectCollections.objects ? {
40
+ objects: moved.objects + 1,
41
+ bytes: moved.bytes + rowBytes(row)
42
+ } : moved, {
43
+ objects: 0,
44
+ bytes: 0
45
+ });
46
+ export { rowsAtCommit, rowsPut };
@@ -200,6 +200,7 @@ const objectWrite = (write) => Effect.scoped(Effect.gen(function* () {
200
200
  },
201
201
  repo: access
202
202
  })), input.internalId);
203
+ if (keyed?.kind === "answered" && keyed.deleted) return yield* fail("NOT_FOUND", `No repo '${repo}'`);
203
204
  if (keyed?.kind === "answered") {
204
205
  const { oid, published, renamesSkipped } = yield* objectAnswer(keyed.receipt);
205
206
  const object = () => readMade(keyed.repo, oid);
@@ -1,4 +1,3 @@
1
- import { noScope } from "../store/call-count.mjs";
2
1
  import { answerSpent } from "../store/errors.mjs";
3
2
  import * as Effect from "effect/Effect";
4
3
  import * as Schema from "effect/Schema";
@@ -36,19 +35,6 @@ const guardedCall = (through) => (effect) => through(answerSpent(effect));
36
35
  /** `calls`, each a seam's call that `guardedCall` runs `through` the server's door. */
37
36
  const guardedCalls = (calls, through) => aroundCalls(calls, guardedCall(through));
38
37
  /**
39
- * The Promise surface over `calls` for a host's code, each call its Effect twin run by `run` with
40
- * the input's `signal`, in no request's scope: a host's own calls count into none. Every call here
41
- * answers a `Result`, which `EffectCalls` turns into the error channel.
42
- */
43
- const promiseCalls = (calls, run) => {
44
- const entries = Object.entries(calls).map(([name, value]) => {
45
- if (!isCall(value)) return [name, promiseCalls(value, run)];
46
- const call = (...args) => run(value(...args), noScope, signalOf(args));
47
- return [name, call];
48
- });
49
- return Object.fromEntries(entries);
50
- };
51
- /**
52
38
  * Each group `names` holds, each call in it answering `call` with the group's name, its own and its
53
39
  * arguments: a server's calls, made before its runtime is built.
54
40
  */
@@ -85,4 +71,4 @@ const callOf = (calls, group, name) => {
85
71
  if (!isCall(found)) throw new TypeError(`The server has no call ${group}.${name}`);
86
72
  return found;
87
73
  };
88
- export { aroundCalls, callOf, callOrMissing, guardedCall, guardedCalls, heldGroup, lazyGroups, noDoor, promiseCalls, providedCalls, signalOf };
74
+ export { aroundCalls, callOf, callOrMissing, guardedCall, guardedCalls, heldGroup, lazyGroups, noDoor, providedCalls, signalOf };
@@ -7,7 +7,7 @@ import { gitJob, repoTry } from "../store/job-try.mjs";
7
7
  import { outboxCollections } from "../store/outbox.mjs";
8
8
  import { readRecord } from "../store/repo-record.mjs";
9
9
  import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
10
- import { isDeliverJob } from "./events/deliver.mjs";
10
+ import { isDeliverJob, sentThrough } from "./events/deliver.mjs";
11
11
  import { indexJobName } from "./index-job.mjs";
12
12
  import * as Effect from "effect/Effect";
13
13
  import * as Schema from "effect/Schema";
@@ -46,10 +46,11 @@ const purgeLargePage = /* @__PURE__ */ Math.floor(limits.answerBytes / limits.va
46
46
  * The jobs whose work a purge waits for, while one is waiting, running or failed in the repo's
47
47
  * scope: git.repack's moves its packs' bytes out and runs its upkeep's, git.index's deleted round
48
48
  * deletes its index's files, and each delivery's, `git.deliver.<name>`, sends `repo.deleted`. A
49
- * failed one holds the purge until a host retries or discards it. A new job that deletes a repo's
50
- * bytes joins this list, or its check below. Every
51
- * other job ends on the record the purge deletes last: git.list's projection the purge runs itself
52
- * before it.
49
+ * failed one holds the purge until a host retries or discards it. A delivery's waiting job that
50
+ * has sent `repo.deleted` holds it no longer, since it waits only to trim events the purge
51
+ * deletes itself. A new job that deletes a repo's bytes joins this list, or its check below.
52
+ * Every other job ends on the record the purge deletes last: git.list's projection the purge runs
53
+ * itself before it.
53
54
  */
54
55
  const drainJobs = /* @__PURE__ */ new Set([repackJobName, indexJobName]);
55
56
  /**
@@ -121,16 +122,19 @@ const relookFor = (item, at) => {
121
122
  };
122
123
  /**
123
124
  * When a purge at `at` looks again for the drain jobs and deliveries waiting, running or failed in
124
- * `scope`, the soonest of theirs: none when none is left. A page of its jobs at a time.
125
+ * `scope`, the soonest of theirs: none when none is left. A page of its jobs at a time. `deleted`
126
+ * is `repo.deleted`'s `seq`, past which a waiting delivery holds nothing; with none, each holds.
125
127
  */
126
- const draining = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope, at) {
128
+ const draining = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope, at, deleted) {
127
129
  let after;
128
130
  let soonest;
129
131
  for (;;) {
130
132
  const page = after === void 0 ? {} : { page: { after } };
131
133
  const listing = yield* storeCall(() => store.list(scope, page));
132
134
  for (const item of listing.items) {
133
- if (!drainJobs.has(item.name) && !isDeliverJob(item)) continue;
135
+ const delivery = isDeliverJob(item);
136
+ if (!drainJobs.has(item.name) && !delivery) continue;
137
+ if (delivery && item.state === "waiting" && deleted !== void 0 && (yield* sentThrough(store, scope, item, deleted))) continue;
134
138
  const relook = relookFor(item, at);
135
139
  soonest = soonest === void 0 ? relook : Math.min(soonest, relook);
136
140
  }
@@ -237,7 +241,8 @@ const purgeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, int
237
241
  ...again,
238
242
  at: at + purgeBackstop
239
243
  };
240
- const drain = yield* draining(store, scope, at);
244
+ const deleted = record.nextSeq === void 0 ? void 0 : record.nextSeq - 1;
245
+ const drain = yield* draining(store, scope, at, deleted);
241
246
  if (drain !== void 0) return {
242
247
  ...again,
243
248
  at: drain
@@ -10,9 +10,10 @@ import { noLfsPointers } from "../storage/lfs-pointers.mjs";
10
10
  import { isShallowRoot } from "../storage/links.mjs";
11
11
  import { isAwaitingRepack } from "../storage/repack-backlog.mjs";
12
12
  import { allottedRows } from "../storage/allotted.mjs";
13
- import { gitObjectOf, objectOfRow, receivedRows } from "../storage/object-rows.mjs";
13
+ import { gitObjectOf, noRows, objectOfRow, receivedRows } from "../storage/object-rows.mjs";
14
14
  import { pruneClearedKey } from "../storage/prune.mjs";
15
15
  import { abandonOwn } from "../storage/quarantine.mjs";
16
+ import { readyBytesOf, readyKey } from "../storage/ready.mjs";
16
17
  import { QuarantineRow, decodeHeld } from "../storage/rows.mjs";
17
18
  import { bestEffort, decodeRow, fromInfra, storeCall } from "../store/errors.mjs";
18
19
  import { callScope } from "../store/call-count.mjs";
@@ -23,9 +24,10 @@ import { sliceOf } from "../protocol/wire/push-limits.mjs";
23
24
  import { pushCounts } from "./events/seen.mjs";
24
25
  import { refViewIn } from "./ref-view.mjs";
25
26
  import { appendEvents, decodeOutbox, firstSeq, outboxReads, repoEnvelope } from "../store/outbox.mjs";
27
+ import { rowsAtCommit } from "./loose-tally.mjs";
26
28
  import { MirrorRow } from "./mirror-rows.mjs";
27
29
  import { PrunedMark, mirrorJobName } from "../store/records.mjs";
28
- import { decodeTimes, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
30
+ import { decodeStats, looseRows, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
29
31
  import { advanceRow } from "../store/queue-jobs.mjs";
30
32
  import { liveReservations, reservedTarget } from "../store/reservations.mjs";
31
33
  import { settleName } from "../store/settle.mjs";
@@ -429,6 +431,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
429
431
  cruftRead,
430
432
  indexRowKey,
431
433
  reachedKey,
434
+ readyKey,
432
435
  ...own,
433
436
  ...keyed,
434
437
  ...targets,
@@ -445,7 +448,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
445
448
  ], rowCounts);
446
449
  if (record === void 0 || record.deleted === true) return yield* fail("NOT_FOUND", `No repo '${repo.name}'`);
447
450
  const [, refRows = [], headRows = [], cursorRows = [], packRows = [], ...more] = snapshot.results;
448
- const [markRows = [], timeRows = [], cruftRows = [], indexRows = [], reachedRows = [], ...rest] = more;
451
+ const [markRows = [], timeRows = [], cruftRows = [], indexRows = [], reachedRows = [], readyRows = [], ...rest] = more;
449
452
  const receipt = yield* heldReceipt(rest.slice(own.length, own.length + keyed.length), kept);
450
453
  if (receipt === void 0 && (yield* markOf(markRows)) !== mark) return yield* fail("UNAVAILABLE", "The repo was pruned during the push", { hint: "Push again" });
451
454
  const targeted = rest.slice(own.length + keyed.length, own.length + keyed.length + targets.length);
@@ -464,7 +467,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
464
467
  const mirrorRows = rest.slice(guardedAt + unchanged.length).flat();
465
468
  const changed = unchanged.some((row, at) => !Equal.equals(row.value, now[at]?.[0]?.value));
466
469
  const packs = yield* decodePacks(packRows);
467
- const times = yield* decodeTimes(timeRows);
470
+ const times = yield* decodeStats(timeRows);
468
471
  const [ownRow] = own.length === 0 ? [] : rest[0] ?? [];
469
472
  const refs = yield* wholeRefs(pushWhole, refRows);
470
473
  const outbox = yield* decodeOutbox([headRows, cursorRows]);
@@ -499,7 +502,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
499
502
  tips: /* @__PURE__ */ new Map(),
500
503
  revoked: revoked !== void 0
501
504
  };
502
- const stats = repoStats(record, refs.size, packs, times);
505
+ const stats = repoStats(record, refs.size, packs, times, yield* readyBytesOf(readyRows));
503
506
  const [indexRow] = indexRows;
504
507
  return {
505
508
  read,
@@ -526,7 +529,7 @@ const settingsOf = (record) => ({
526
529
  const runChecks = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, facts) {
527
530
  const context = checking(input);
528
531
  const ruled = yield* registeredAfter(checks, input, yield* runPushRules(checks, input, context));
529
- const whole = yield* runHookGroups(checks.reports, checks.groups?.() ?? [], context, {
532
+ const whole = yield* runHookGroups(checks.groups?.() ?? [], context, {
530
533
  atomic: input.atomic,
531
534
  updates: ruled.updates,
532
535
  refused: ruled.refused
@@ -1118,12 +1121,16 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
1118
1121
  const kept = receiptWrites(key, answers.kept(final), core.repackJobRow);
1119
1122
  const woken = shown.filter((move) => queued.has(move.ref)).map((move) => advanceRow(move.ref));
1120
1123
  const pushed = pushedRows(core.access, shown, times, at);
1124
+ const moved = received === void 0 || !planned.moves ? noRows : yield* rowsAtCommit(store, listed.repo, received.change, read.version);
1125
+ if (moved === void 0) continue;
1126
+ const loose = looseRows(times.loose, moved);
1121
1127
  const body = {
1122
1128
  id,
1123
1129
  expect: planned.expect,
1124
1130
  put: [
1125
1131
  ...change.put,
1126
1132
  ...pushed,
1133
+ ...loose,
1127
1134
  ...kept.put,
1128
1135
  ...also?.put ?? [],
1129
1136
  ...appended.put,