@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
@@ -320,8 +320,10 @@ export type QueueKeys = 'once' | 'reusable';
320
320
  * true`, while it's open and once it's merged, so an add sent again after its answer was lost
321
321
  * never queues a head its key merged. After a failure or a removal the add queues a new entry,
322
322
  * and after a merge, with a new head, as the queue's `keys` says. Past 1,000 open entries on the
323
- * target, `add` is `RESOURCE_EXHAUSTED`, reason `queue-full`, and so is an add onto a new target
324
- * once the repo's queues hold 100. `jump` puts it first and rebuilds the candidates behind it.
323
+ * target, `add` is `RESOURCE_EXHAUSTED`, reason `queue-full`, and an add onto a new target once
324
+ * the repo's queues hold 100 is reason `queue-targets-full`. `jump` puts it first and rebuilds the candidates behind it.
325
+ * 14 days after an entry ended, `queue.trim` deletes it, and with it what its key remembers of it:
326
+ * an add of that key and head queues a new entry then, under `keys: 'once'` too.
325
327
  */
326
328
  export interface QueueAddInput extends WriteInput, Omit<EntryFields, 'key'>, Pick<RepoInput, 'internalId'> {
327
329
  readonly key: string;
@@ -454,8 +456,8 @@ export type CandidatesResult = Result<Listing<Candidate>>;
454
456
  * the same verdict again is `repeat: true`, another verdict `ALREADY_EXISTS` with the one that
455
457
  * stands, and one for a closed candidate `FAILED_PRECONDITION` with `candidate-superseded`,
456
458
  * `candidate-cancelled` or `entry-gone`. A target holds 1,000 open entries and 1,000 open holds:
457
- * past them, `add` or `hold` is `RESOURCE_EXHAUSTED`, reason `queue-full`, as either is onto a new
458
- * target once the repo's queues hold 100 targets, idle ones too. A hold's `reason` is
459
+ * past them, `add` or `hold` is `RESOURCE_EXHAUSTED`, reason `queue-full`, and either onto a new target
460
+ * once the repo's queues hold 100 targets, idle ones too, is reason `queue-targets-full`. A hold's `reason` is
459
461
  * 1 KiB at most. Under `access`, an entry whose target or source the caller can't see, a hold of
460
462
  * such a target or entry, and a candidate to a caller who doesn't see every ref, answer as missing,
461
463
  * a hidden target lists nothing, and `add`, `hold` and `restart` naming one are `NOT_ALLOWED`, as a
@@ -471,7 +473,7 @@ export interface MergeQueueCalls {
471
473
  * The last hold on an entry released sends it to the back. A `work-failed` hold's release retries
472
474
  * the job it names: while that job runs, its failure perhaps not yet settled, or once it failed
473
475
  * again since the release read it, the release is `UNAVAILABLE` and the hold stays, so release it
474
- * again.
476
+ * again. 14 days after its release, `queue.trim` deletes a hold, and it's `NOT_FOUND`.
475
477
  */
476
478
  readonly release: (hold: HoldId, input: WriteInput) => Promise<ReleaseResult>;
477
479
  /**
@@ -485,11 +487,16 @@ export interface MergeQueueCalls {
485
487
  * failed comes back to its old place, waiting, `queue.entry.retried`, while it's still its key's
486
488
  * newest entry on the target: one whose key took an entry since, open, merged, failed or
487
489
  * removed, stays failed. One with no entry left is `FAILED_PRECONDITION`, reason `entry-gone`,
488
- * and one on a target deleted since is `FAILED_PRECONDITION`, as `restart` is.
490
+ * and one on a target deleted since is `FAILED_PRECONDITION`, as `restart` is. One `queue.trim`
491
+ * deleted, 14 days after it closed and its entries went, is `NOT_FOUND`.
489
492
  */
490
493
  readonly retry: (candidate: CandidateId, input: WriteInput) => Promise<RetryResult>;
491
494
  /** Closes the target's open candidates and builds them again under new IDs. */
492
495
  readonly restart: (repo: RepoName, input: QueueTargetInput) => Promise<RestartResult>;
496
+ /**
497
+ * One entry, open or ended. One that merged, failed or was removed 14 days ago is `NOT_FOUND`:
498
+ * `queue.trim` deleted it, and each other write by its ID is `NOT_FOUND` too.
499
+ */
493
500
  readonly get: (entry: EntryId, input: ActorInput) => Promise<EntryResult>;
494
501
  /**
495
502
  * A target's entries in the order they're tried in. A page's `next` names where it ended in that
@@ -517,7 +524,8 @@ export interface MergeQueueCalls {
517
524
  /**
518
525
  * One candidate, open or closed. A closed one keeps its base, entries, commit, report and
519
526
  * `reason`, and has no `ref`. Under `access`, one is `NOT_FOUND` to a caller who doesn't see
520
- * every ref, as an ID that names nothing is.
527
+ * every ref, as an ID that names nothing is. 14 days after it closed, once none of its entries
528
+ * is left, `queue.trim` deletes it, with its report, and it's `NOT_FOUND`.
521
529
  */
522
530
  readonly candidate: (candidate: CandidateId, input: ActorInput) => Promise<CandidateResult>;
523
531
  }
@@ -182,7 +182,7 @@ export declare const RefOutcome: Schema.Union<readonly [Schema.Struct<{
182
182
  readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
183
183
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
184
184
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
185
- reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
185
+ reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
186
186
  indexBytes: Schema.optionalKey<Schema.Number>;
187
187
  pushBytes: Schema.optionalKey<Schema.Number>;
188
188
  most: Schema.optionalKey<Schema.Number>;
@@ -92,6 +92,10 @@ export declare const PreconditionContext: Schema.StructWithRest<Schema.Struct<{
92
92
  }>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>;
93
93
  export type PreconditionContext = typeof PreconditionContext.Type;
94
94
  /**
95
+ * `queue-full` is a queue target holding as many open entries, or open holds, as it may: a later
96
+ * add or hold may fit once one leaves. `queue-targets-full` is a write onto a new target once the
97
+ * repo's queues hold as many targets as they may, which no leave mends: queue onto one it holds.
98
+ *
95
99
  * `prune-walk-too-large` is upkeep's prune pass, refused at one of three bounds its message names:
96
100
  * - its walk's history past `pruneCommitsMost`, 1,000,000 commits and tags, which no option
97
101
  * raises: only deleting refs, till what the rest reach is under it, mends it;
@@ -108,14 +112,14 @@ export type PreconditionContext = typeof PreconditionContext.Type;
108
112
  * before the row than one run reads, and
109
113
  * `work.retry(repo, { name: 'git.repack', key: 'prune' })` runs the pass at once.
110
114
  */
111
- export declare const ResourceReason: Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>;
115
+ export declare const ResourceReason: Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>;
112
116
  /**
113
117
  * A push refused `too-large` by the repo's pack indexes it reads: those indexes' bytes in
114
118
  * `indexBytes`, the push's own beside them in `pushBytes`, and the most the server's memory could
115
119
  * give it in `most`.
116
120
  */
117
121
  export declare const ResourceContext: Schema.StructWithRest<Schema.Struct<{
118
- reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
122
+ reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
119
123
  indexBytes: Schema.optionalKey<Schema.Number>;
120
124
  pushBytes: Schema.optionalKey<Schema.Number>;
121
125
  most: Schema.optionalKey<Schema.Number>;
@@ -192,7 +196,7 @@ export declare const gitErrorContexts: {
192
196
  tip: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
193
197
  }>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>;
194
198
  readonly RESOURCE_EXHAUSTED: Schema.StructWithRest<Schema.Struct<{
195
- reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
199
+ reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
196
200
  indexBytes: Schema.optionalKey<Schema.Number>;
197
201
  pushBytes: Schema.optionalKey<Schema.Number>;
198
202
  most: Schema.optionalKey<Schema.Number>;
@@ -286,7 +290,7 @@ export declare const GitErrorBody: Schema.Union<(Schema.Struct<{
286
290
  readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
287
291
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
288
292
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
289
- reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
293
+ reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
290
294
  indexBytes: Schema.optionalKey<Schema.Number>;
291
295
  pushBytes: Schema.optionalKey<Schema.Number>;
292
296
  most: Schema.optionalKey<Schema.Number>;
@@ -309,7 +313,7 @@ export declare const GitErrorBody: Schema.Union<(Schema.Struct<{
309
313
  }>)[]>;
310
314
  export type GitErrorBody = typeof GitErrorBody.Type;
311
315
  /** Every reason a refusal names, each once, by code: what `ref0-push-reasons` tells. */
312
- declare const refusalReasonLists: readonly [Schema.Literals<readonly ["ofs-delta", "fsck", "provider-unknown", "body-ended", "link-wrong-type", "tag-target-missing", "object-missing", "boundary-not-in-pack", "too-many-short-ids", "too-many-parents"]>, Schema.Literals<readonly ["files-refused", "entry-unpublishable"]>, Schema.Literals<readonly ["key-reused"]>, Schema.Literals<readonly ["no-queue", "no-topics", "ambiguous"]>, Schema.Literals<readonly ["cursor-expired", "diverged", "merge-conflict", "candidate-superseded", "candidate-cancelled", "entry-gone", "ref-conflict", "newer-format", "changed-while-checked", "unsupported-attribute", "unrelated-histories", "unsupported-virtual-base", "own-repo", "not-a-fork", "no-copy-rows", "shallow-root", "shallow-upload", "sync-unbound", "import-cancelled", "importing", "history-not-imported", "stage-gone", "remote-refused", "atomic-partner", "merges-off"]>, Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes"]>, Schema.Literals<readonly ["graph-length", "merge-incomplete"]>];
316
+ declare const refusalReasonLists: readonly [Schema.Literals<readonly ["ofs-delta", "fsck", "provider-unknown", "body-ended", "link-wrong-type", "tag-target-missing", "object-missing", "boundary-not-in-pack", "too-many-short-ids", "too-many-parents"]>, Schema.Literals<readonly ["files-refused", "entry-unpublishable"]>, Schema.Literals<readonly ["key-reused"]>, Schema.Literals<readonly ["no-queue", "no-topics", "ambiguous"]>, Schema.Literals<readonly ["cursor-expired", "diverged", "merge-conflict", "candidate-superseded", "candidate-cancelled", "entry-gone", "ref-conflict", "newer-format", "changed-while-checked", "unsupported-attribute", "unrelated-histories", "unsupported-virtual-base", "own-repo", "not-a-fork", "no-copy-rows", "shallow-root", "shallow-upload", "sync-unbound", "import-cancelled", "importing", "history-not-imported", "stage-gone", "remote-refused", "atomic-partner", "merges-off"]>, Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes"]>, Schema.Literals<readonly ["graph-length", "merge-incomplete"]>];
313
317
  /** A refusal's reason, of every code whose context names one. */
314
318
  export type RefusalReason = (typeof refusalReasonLists)[number]['Type'];
315
319
  export interface GitErrorFields {
@@ -167,6 +167,10 @@ const PreconditionContext = contextOf({
167
167
  tip: Schema.optionalKey(BodyText)
168
168
  });
169
169
  /**
170
+ * `queue-full` is a queue target holding as many open entries, or open holds, as it may: a later
171
+ * add or hold may fit once one leaves. `queue-targets-full` is a write onto a new target once the
172
+ * repo's queues hold as many targets as they may, which no leave mends: queue onto one it holds.
173
+ *
170
174
  * `prune-walk-too-large` is upkeep's prune pass, refused at one of three bounds its message names:
171
175
  * - its walk's history past `pruneCommitsMost`, 1,000,000 commits and tags, which no option
172
176
  * raises: only deleting refs, till what the rest reach is under it, mends it;
@@ -199,6 +203,7 @@ const ResourceReason = /* @__PURE__ */ Schema.Literals([
199
203
  "events-waiting",
200
204
  "name-churn",
201
205
  "queue-full",
206
+ "queue-targets-full",
202
207
  "too-many-gitmodules-and-gitattributes",
203
208
  "prune-walk-too-large"
204
209
  ]);
@@ -1,4 +1,4 @@
1
- import { Bucket as Bucket$1, Clock, Duration, Store } from "./promises.mjs";
1
+ import { Clock, Duration, Store } from "./promises.mjs";
2
2
  import { AccessOption } from "./access.mjs";
3
3
  import { Authorize } from "./authorize.mjs";
4
4
  import { Actor, ActorInput, Caller, GitAuth, GitAuthorize } from "./actors.mjs";
@@ -11,7 +11,7 @@ import { GrantAgainRequest, GrantResolver } from "./grants.mjs";
11
11
  import { InternalRepoId, RepoName } from "./ids.mjs";
12
12
  import { LfsCalls, LfsFeature } from "./lfs.mjs";
13
13
  import { MergeCalls } from "./merges.mjs";
14
- import { EffectiveLimits, IndexedObjectsFactory, ObjectsFactory } from "./objects.mjs";
14
+ import { Bucket as Bucket$1, EffectiveLimits, IndexedObjectsFactory, ObjectsFactory } from "./objects.mjs";
15
15
  import { MergeQueueCalls, MergeQueueLayerOptions, QueueKeys } from "./queue.mjs";
16
16
  import { Operation } from "./operations.mjs";
17
17
  import { PushOptions } from "./push-uploads.mjs";
@@ -92,7 +92,7 @@ export interface GitServerOptions<A extends GitAdapter = GitAdapter> {
92
92
  */
93
93
  readonly queue?: MergeQueueLayerOptions;
94
94
  /**
95
- * `lfs()`: Git LFS's API under `info/lfs`, its upkeep, its pointer check and `git.lfs.get`,
95
+ * `lfs()`: `Lfs.layer()`, Git LFS's API under `info/lfs`, its upkeep, purge and pointer check,
96
96
  * with its objects in the adapter's bucket. Without it, a server with a bucket has no LFS.
97
97
  */
98
98
  readonly lfs?: LfsFeature;
@@ -206,7 +206,11 @@ export interface GitExtension {
206
206
  */
207
207
  readonly bind?: (adapter: BoundAdapter) => void;
208
208
  }
209
- /** The adapter as `GitExtension.bind` takes it: the bridge's promise shapes. */
209
+ /**
210
+ * The adapter as `GitExtension.bind` takes it: the store and clock as the bridge's promise shapes,
211
+ * and the bucket as infra's `Bucket` service, through the server's door, each call charged by the
212
+ * `bucketCall` that makes it (Q1114).
213
+ */
210
214
  export interface BoundAdapter {
211
215
  readonly store: Store;
212
216
  readonly bucket: Bucket$1 | undefined;
@@ -300,8 +304,11 @@ export interface ExtendedGit {
300
304
  * Given `request`, its calls count into it, as `callsFor`'s do.
301
305
  */
302
306
  readonly access: (caller: Caller, repo: RepoName, request?: GitRequest) => Promise<TokenScope | undefined>;
303
- /** `access` as an Effect, as `effectInternalId` is `internalId`'s. */
304
- readonly effectAccess: (caller: Caller, repo: RepoName, request?: GitRequest) => Effect.Effect<TokenScope | undefined, GitError>;
307
+ /**
308
+ * `access` as an Effect, as `effectInternalId` is `internalId`'s. Given `internalId`, the repo
309
+ * the caller holds `repo` to, the ceiling is on that repo, and no catalogue read finds it.
310
+ */
311
+ readonly effectAccess: (caller: Caller, repo: RepoName, request?: GitRequest, internalId?: InternalRepoId) => Effect.Effect<TokenScope | undefined, GitError>;
305
312
  /**
306
313
  * Where the repo's `git.sync.import` stands, `undefined` for a repo no import made, read as
307
314
  * `effectRepo` reads, through the door and into a provided `CallBudget`, with no caller: the
@@ -62,7 +62,7 @@ export declare const WorkWrite: Schema.Struct<{
62
62
  readonly requestKey: Schema.optionalKey<Schema.String>;
63
63
  }>;
64
64
  export type WorkWrite = typeof WorkWrite.Type;
65
- export interface WorkListInput extends ActorInput, JobListRequest, Pick<RepoInput, 'internalId'> {}
65
+ export interface WorkListInput extends ActorInput, Omit<JobListRequest, 'name'>, Pick<RepoInput, 'internalId'> {}
66
66
  /**
67
67
  * `key` names the job; `requestKey` makes the write safe to send again: sent again within 24
68
68
  * hours with the same input, it answers success, and with other input `ALREADY_EXISTS` with
@@ -57,6 +57,22 @@ const openRepo = /* @__PURE__ */ Effect.fnUntraced(function* (caller, operation,
57
57
  return yield* authorized(caller, operation, resolved);
58
58
  });
59
59
  /**
60
+ * The repo, once `authorize` lets the caller fetch it, or push to it. A push's refusal, whatever
61
+ * its code, is told only to a caller that may read the repo, as receive's is. With `internalId`,
62
+ * a name that holds another repo is as one with none, as `openRepo` says (Q705).
63
+ */
64
+ const openFor = (caller, repo, writing, internalId) => writing ? openRepo(caller, {
65
+ kind: "push",
66
+ repo,
67
+ updates: []
68
+ }, [], internalId).pipe(Effect.catch((refused) => Effect.andThen(openRepo(caller, {
69
+ kind: "read",
70
+ repo
71
+ }, [], internalId), Effect.fail(refused)))) : openRepo(caller, {
72
+ kind: "fetch",
73
+ repo
74
+ }, [], internalId);
75
+ /**
60
76
  * `read`, refused for size only once `check` passes: a caller `check` refuses gets its refusal
61
77
  * instead, so a repo too large for one read tells its size to no one who may not read it.
62
78
  */
@@ -228,4 +244,4 @@ const contended = () => fail("UNAVAILABLE", "Too many writes reached this repo a
228
244
  * it back before it sends the same call again (#1462).
229
245
  */
230
246
  const contendedAfterWrites = () => Effect.fail(afterWrites(gitError("UNAVAILABLE", "Too many writes reached this repo at once")));
231
- export { alreadyExists, callerFor, contended, contendedAfterWrites, headOf, hiddenCodes, indexDeleteJobs, indexJobs, keyedRecord, nameMoved, openKeyed, openRepo, purgeJobs, readableRedirect, refIndexJobs, repoAccess, sizedRead, statsReads, unlessHidden };
247
+ export { alreadyExists, callerFor, contended, contendedAfterWrites, headOf, hiddenCodes, indexDeleteJobs, indexJobs, keyedRecord, nameMoved, openFor, openKeyed, openRepo, purgeJobs, readableRedirect, refIndexJobs, repoAccess, sizedRead, statsReads, unlessHidden };
@@ -1 +1,3 @@
1
- import "../contracts/server.mjs";
1
+ import { ServerCalls } from "../contracts/server.mjs";
2
+ /** The groups a server has: `tokens`, `queue` and `topics` only with their options. */
3
+ export type CallNames = Partial<Record<keyof ServerCalls, readonly string[]>>;
@@ -0,0 +1,4 @@
1
+ import "../contracts/git.mjs";
2
+ import "../contracts/promises.mjs";
3
+ import "../auth/fences.mjs";
4
+ import { JobInput, Moment } from "@ref0/infra";
@@ -0,0 +1,53 @@
1
+ import { fail } from "../contracts/result.mjs";
2
+ import { storeCall } from "../store/errors.mjs";
3
+ import { readRecord } from "../store/repo-record.mjs";
4
+ import { newChangeId, repoScope } from "../store/scopes.mjs";
5
+ import * as Effect from "effect/Effect";
6
+ // src/core/claim-rows.ts
7
+ const unbound = (name) => /* @__PURE__ */ new Error(`${name}'s rows were used before Git.layer wired its store`);
8
+ /**
9
+ * Claim `name`'s rows: collections under `<name>/` in each repo's scope, over `base` once the
10
+ * wiring binds it. A read or a write of any other collection is a defect, so a claim never meets
11
+ * the repo's record, refs, objects or another claim's rows.
12
+ */
13
+ const claimRows = (name, base) => {
14
+ const prefix = `${name}/`;
15
+ const outside = (touched) => touched.find((one) => !one.collection.startsWith(prefix));
16
+ const within = (touched, run) => Effect.suspend(() => {
17
+ const stray = outside(touched);
18
+ if (stray !== void 0) return Effect.die(/* @__PURE__ */ new TypeError(`${name}'s rows are under '${prefix}': got '${stray.collection}'`));
19
+ const bound = base();
20
+ return bound === void 0 ? Effect.die(unbound(name)) : run(bound);
21
+ });
22
+ const jobsOf = (bound, writes) => writes.wake === void 0 ? [] : [bound.repackJobRow(writes.wake)];
23
+ return {
24
+ read: (repo, reads) => within(reads, (bound) => Effect.map(storeCall(() => bound.store.read(repoScope(repo), [...reads])), ({ version, results }) => ({
25
+ version,
26
+ results
27
+ }))),
28
+ readFenced: (caller, repo, reads) => within(reads, (bound) => Effect.gen(function* () {
29
+ const fence = bound.fences(caller, repo);
30
+ const { record, snapshot } = yield* readRecord(bound.store, repo.internalId, [...reads, ...fence.reads]);
31
+ if (record === void 0 || record.deleted === true) return yield* fail("NOT_FOUND", `No repo '${repo.name}'`);
32
+ const results = snapshot.results.slice(1);
33
+ yield* fence.check(results.slice(reads.length));
34
+ return {
35
+ version: snapshot.version,
36
+ results: results.slice(0, reads.length)
37
+ };
38
+ })),
39
+ source: (repo) => within([], (bound) => Effect.map(readRecord(bound.store, repo), ({ record }) => record?.fork?.upstreamInternalId)),
40
+ commit: (repo, at, writes) => within([...writes.put ?? [], ...writes.delete ?? []], (bound) => storeCall(() => bound.store.commit(repoScope(repo), {
41
+ id: newChangeId(),
42
+ expect: at,
43
+ put: [...writes.put ?? []],
44
+ delete: [...writes.delete ?? []],
45
+ jobs: jobsOf(bound, writes)
46
+ }))),
47
+ add: (repo, writes) => within(writes.put ?? [], (bound) => storeCall(() => bound.store.add(repoScope(repo), {
48
+ put: [...writes.put ?? []],
49
+ jobs: jobsOf(bound, writes)
50
+ })))
51
+ };
52
+ };
53
+ export { claimRows };
@@ -0,0 +1,12 @@
1
+ import "../../contracts/events.mjs";
2
+ import "../../contracts/promises.mjs";
3
+ import { GitError } from "../../contracts/result.mjs";
4
+ import "../../store/outbox.mjs";
5
+ import { CurrentJob, Failure, Job, JobDefinition, JobInput, JobRef, Moment, Retry, Row, Scope } from "@ref0/infra";
6
+ import "effect/Schema";
7
+ import * as Effect from "effect/Effect";
8
+ /**
9
+ * A job's `onFailure` that writes `repo.work.failed`, as `workFailed` makes it: any job's, since
10
+ * it reads the job from `CurrentJob` and not its data.
11
+ */
12
+ export type WorkFailed = <Data>(data: Data, failure: Failure) => Effect.Effect<void, GitError, CurrentJob.CurrentJob>;