@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
@@ -1,7 +1,6 @@
1
1
  import { isRefName } from "../core/names.mjs";
2
2
  import { fullPattern, isClassedPattern, refMatcher, refusedGlob } from "../core/rules/patterns.mjs";
3
3
  import { isWellFormed } from "../protocol/bytes/text.mjs";
4
- import { hiddenRefs, hiddenUnder } from "../protocol/wire/lines.mjs";
5
4
  import { byBytes } from "@ref0/infra";
6
5
  // src/access/private-refs.ts
7
6
  const compiled = (pattern) => {
@@ -146,9 +145,8 @@ const privateRefs = (patterns) => {
146
145
  if (patterns.length === 0 || patterns.some((pattern) => pattern.length === 0)) throw new TypeError("privateRefs takes the patterns of the refs to hide: got none, or an empty one");
147
146
  if (patterns.length > 64) throw new TypeError(`privateRefs takes at most 64 patterns: got ${patterns.length}`);
148
147
  const all = patterns.map(compiled);
149
- const gitsOwn = hiddenRefs.map((hidden) => compiled(`${hidden.prefix}**`));
150
148
  const patternOf = (ref) => all.find((one) => one.matches(ref))?.pattern;
151
- const refViewOf = (audience) => {
149
+ const refViewOf = (audience, gitsPrefixes) => {
152
150
  const read = new Set(audience.read ?? []);
153
151
  const publish = new Set(audience.publish ?? []);
154
152
  const publishes = (pattern) => publish.has(pattern);
@@ -160,8 +158,9 @@ const privateRefs = (patterns) => {
160
158
  publishes
161
159
  };
162
160
  }
161
+ const gitsOwn = gitsPrefixes.map((prefix) => compiled(`${prefix}**`));
163
162
  const sees = (ref) => {
164
- if (hiddenUnder(ref) !== void 0) return false;
163
+ if (gitsPrefixes.some((prefix) => ref.startsWith(prefix))) return false;
165
164
  const pattern = patternOf(ref);
166
165
  return pattern === void 0 || read.has(pattern);
167
166
  };
@@ -87,9 +87,13 @@ const credentialOf = (hosts, grants, caller, about) => {
87
87
  if (grant === void 0) return void 0;
88
88
  return {
89
89
  scope: grant.scope,
90
- reaches: (name) => name === void 0 ? Effect.succeed(false) : hostCall(hosts, "grants", about, (signal) => grant.reaches({
90
+ reaches: (name, internalId) => name === void 0 ? Effect.succeed(false) : hostCall(hosts, "grants", about, (signal) => grant.reaches(internalId === void 0 ? {
91
91
  repo: name,
92
92
  signal
93
+ } : {
94
+ repo: name,
95
+ internalId,
96
+ signal
93
97
  }))
94
98
  };
95
99
  };
@@ -115,15 +119,16 @@ const ceilingOf = /* @__PURE__ */ Effect.fnUntraced(function* (hosts, grants, {
115
119
  * The ceiling Git's calls apply to `caller` on `repo` (Q251): its token's scope when the token
116
120
  * covers the repo, its grant's when the grant reaches it, and `undefined` when either doesn't. A
117
121
  * caller with neither meets no ceiling of Git's, so it answers `'write'`, and the host's
118
- * `authorize` alone decides. A repo token is checked against the repo now under the name.
122
+ * `authorize` alone decides. A repo token is checked against `internalId`, the repo the caller
123
+ * holds the name to, or without it the repo now under the name.
119
124
  */
120
- const accessOf = /* @__PURE__ */ Effect.fnUntraced(function* (hosts, grants, store, caller, repo) {
125
+ const accessOf = /* @__PURE__ */ Effect.fnUntraced(function* (hosts, grants, store, caller, repo, pinned) {
121
126
  const credential = credentialOf(hosts, grants, caller, {
122
127
  repo,
123
128
  actor: caller.actor
124
129
  });
125
130
  if (credential === void 0) return "write";
126
- const internalId = caller.token === void 0 ? void 0 : yield* internalIdOf(store, repo).pipe(Effect.catch((error) => error.code === "NOT_FOUND" ? Effect.succeed(void 0) : Effect.fail(error)));
131
+ const internalId = pinned !== void 0 || caller.token === void 0 ? pinned : yield* internalIdOf(store, repo).pipe(Effect.catch((error) => error.code === "NOT_FOUND" ? Effect.succeed(void 0) : Effect.fail(error)));
127
132
  return (yield* credential.reaches(repo, internalId)) ? credential.scope : void 0;
128
133
  });
129
134
  /**
@@ -1,9 +1,11 @@
1
1
  import "../contracts/promises.mjs";
2
- import "../contracts/actors.mjs";
2
+ import { Caller } from "../contracts/actors.mjs";
3
3
  import "../contracts/grants.mjs";
4
- import "../contracts/result.mjs";
4
+ import { GitError } from "../contracts/result.mjs";
5
5
  import "../contracts/tokens.mjs";
6
6
  import "./auth.mjs";
7
7
  import "./grants.mjs";
8
8
  import "./host-function.mjs";
9
- import "effect/Effect";
9
+ import * as Effect from "effect/Effect";
10
+ /** Who sent a request: its `Caller`, or `UNAUTHENTICATED` for a credential no one knows. */
11
+ export type Identify = (request: Request) => Effect.Effect<Caller, GitError>;
@@ -1,7 +1,7 @@
1
+ import { madeJob } from "../store/job-try.mjs";
1
2
  import { fail } from "../contracts/result.mjs";
2
3
  import { resolveRepo } from "../store/catalogue.mjs";
3
4
  import { decodeRow, storeCall } from "../store/errors.mjs";
4
- import { runJobTry } from "../store/crossing.mjs";
5
5
  import { appendEvents, decodeOutbox, outboxReads } from "../store/outbox.mjs";
6
6
  import { checkWriteKey } from "../store/records.mjs";
7
7
  import { collections, newChangeId } from "../store/scopes.mjs";
@@ -9,7 +9,7 @@ import { settleName } from "../store/settle.mjs";
9
9
  import { longActorId } from "./authorize.mjs";
10
10
  import { TokenRow, readToken, tokenKey, tokenRecord, tokenState } from "./token-rows.mjs";
11
11
  import { hashSecret, newSecret, newTokenId, placeScope, tokenText } from "./token-text.mjs";
12
- import { defineJob } from "@ref0/infra";
12
+ import { CurrentJob, Job } from "@ref0/infra";
13
13
  import * as Schema from "effect/Schema";
14
14
  import * as Effect from "effect/Effect";
15
15
  import * as Random from "effect/Random";
@@ -368,18 +368,19 @@ const cleanupScope = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope,
368
368
  at: Math.max(now, expiryOf(next) + keptAfterExpiry)
369
369
  };
370
370
  });
371
- /** `git.tokens.cleanup`'s try, on the server's clock. */
372
- const cleanupHandler = (now) => (job, context) => runJobTry(Effect.flatMap(now, (at) => cleanupScope(context.store, job.scope, at)));
373
- /** `git.tokens.cleanup`, on the server's clock. */
374
- const tokenCleanupJob = (now) => defineJob({
375
- name: tokenCleanupName,
376
- schema: Schema.toStandardSchemaV1(Schema.Struct({})),
371
+ const TokenCleanupJob = /* @__PURE__ */ Job.make(tokenCleanupName, {
372
+ payload: Schema.Struct({}),
377
373
  retry: {
378
374
  limit: 10,
379
375
  delay: "1 second",
380
376
  backoff: "exponential",
381
377
  maxDelay: "5 minutes"
382
- },
383
- handler: cleanupHandler(now)
378
+ }
384
379
  });
385
- export { cleanupHandler, isPrefixTarget, keptAfterExpiry, maxTokenLife, readTarget, tokenCalls, tokenCleanupJob, tokenCleanupName, tokenExpiry, tokenParties, tokens };
380
+ /** `git.tokens.cleanup`, on the server's clock: each try one batch in its scope. */
381
+ const tokenCleanupJob = (now) => madeJob(TokenCleanupJob.definition(() => Effect.flatMap(Effect.all([
382
+ now,
383
+ CurrentJob.store,
384
+ CurrentJob.current
385
+ ]), ([at, store, job]) => cleanupScope(store, job.scope, at))));
386
+ export { isPrefixTarget, keptAfterExpiry, maxTokenLife, readTarget, tokenCalls, tokenCleanupJob, tokenCleanupName, tokenExpiry, tokenParties, tokens };
@@ -14,6 +14,7 @@ import { Objects } from "../core/objects/objects.mjs";
14
14
  import { Authorize } from "../contracts/authorize.mjs";
15
15
  import { refCalls } from "../core/refs.mjs";
16
16
  import { cursorSeal } from "../store/cursor-seal.mjs";
17
+ import { gitsOwnRefs } from "../protocol/wire/lines.mjs";
17
18
  import { noRepackRetry, repackJob, repackJobRow } from "../core/repack.mjs";
18
19
  import { defaultBranch, newRepoRecord } from "../core/repos.mjs";
19
20
  import { Changes } from "../core/changes.mjs";
@@ -116,6 +117,7 @@ const localLayer = (options) => Layer.effect(Local, Effect.gen(function* () {
116
117
  reads: [],
117
118
  check: () => Effect.void
118
119
  }),
120
+ hiddenRefs: () => gitsOwnRefs,
119
121
  grants: heldGrants(),
120
122
  checks: { reports: {} },
121
123
  repackJobRow: (at) => repackJobRow(repack, at),
@@ -68,7 +68,7 @@ export declare const pushSlices: (push: {
68
68
  };
69
69
  }[];
70
70
  };
71
- reason: "ambiguous" | "atomic-partner" | "awaiting-index" | "body-ended" | "boundary-not-in-pack" | "busy" | "call-budget" | "candidate-cancelled" | "candidate-superseded" | "changed-while-checked" | "cursor-expired" | "delta-too-large" | "diff-limit" | "diverged" | "entry-gone" | "entry-unpublishable" | "events-undelivered" | "events-waiting" | "fetch-plan-too-large" | "files-refused" | "fsck" | "graph-length" | "history-not-imported" | "import-cancelled" | "importing" | "key-reused" | "link-wrong-type" | "may-have-saved" | "merge-conflict" | "merge-incomplete" | "merges-off" | "name-churn" | "newer-format" | "no-copy-rows" | "no-queue" | "no-topics" | "not-a-fork" | "object-missing" | "object-too-large" | "ofs-delta" | "own-repo" | "packs-awaiting-repack" | "provider-unknown" | "prune-walk-too-large" | "queue-full" | "rate-limited" | "ref-conflict" | "remote-refused" | "response-too-large" | "shallow-root" | "shallow-upload" | "stage-gone" | "sync-unbound" | "tag-target-missing" | "too-many-gitmodules-and-gitattributes" | "too-many-parents" | "too-many-pointers" | "too-many-short-ids" | "too-many-store-calls" | "too-many-writes" | "unrelated-histories" | "unsupported-attribute" | "unsupported-virtual-base" | "walk-limit" | undefined;
71
+ reason: "ambiguous" | "atomic-partner" | "awaiting-index" | "body-ended" | "boundary-not-in-pack" | "busy" | "call-budget" | "candidate-cancelled" | "candidate-superseded" | "changed-while-checked" | "cursor-expired" | "delta-too-large" | "diff-limit" | "diverged" | "entry-gone" | "entry-unpublishable" | "events-undelivered" | "events-waiting" | "fetch-plan-too-large" | "files-refused" | "fsck" | "graph-length" | "history-not-imported" | "import-cancelled" | "importing" | "key-reused" | "link-wrong-type" | "may-have-saved" | "merge-conflict" | "merge-incomplete" | "merges-off" | "name-churn" | "newer-format" | "no-copy-rows" | "no-queue" | "no-topics" | "not-a-fork" | "object-missing" | "object-too-large" | "ofs-delta" | "own-repo" | "packs-awaiting-repack" | "provider-unknown" | "prune-walk-too-large" | "queue-full" | "queue-targets-full" | "rate-limited" | "ref-conflict" | "remote-refused" | "response-too-large" | "shallow-root" | "shallow-upload" | "stage-gone" | "sync-unbound" | "tag-target-missing" | "too-many-gitmodules-and-gitattributes" | "too-many-parents" | "too-many-pointers" | "too-many-short-ids" | "too-many-store-calls" | "too-many-writes" | "unrelated-histories" | "unsupported-attribute" | "unsupported-virtual-base" | "walk-limit" | undefined;
72
72
  };
73
73
  } | {
74
74
  refusal?: never;
@@ -109,6 +109,10 @@ export interface AccessOption {
109
109
  * so list a narrower pattern before a wider one that also matches its refs.
110
110
  */
111
111
  readonly patternOf: (ref: RefName) => RefName | undefined;
112
- /** The refs a caller sees, given `authorize`'s answer, already checked against `patterns`. */
113
- readonly refViewOf: (audience: RefAudience) => RefView;
112
+ /**
113
+ * The refs a caller sees, given `authorize`'s answer, already checked against `patterns`, and
114
+ * `hidden`, Git's own prefixes, `refs/import/` and each registered prefix, whose refs only a
115
+ * whole caller sees.
116
+ */
117
+ readonly refViewOf: (audience: RefAudience, hidden: readonly string[]) => RefView;
114
118
  }
@@ -1,14 +1,14 @@
1
1
  import { RefAudience } from "./access.mjs";
2
2
  import { Caller, RepoAccess } from "./actors.mjs";
3
3
  import { GrantAgainRequest } from "./grants.mjs";
4
- import { RefName, RepoName } from "./ids.mjs";
4
+ import { InternalRepoId, RefName, RepoName } from "./ids.mjs";
5
5
  import { Operation } from "./operations.mjs";
6
6
  import { GitError } from "./result.mjs";
7
7
  import { TokenScope } from "./tokens.mjs";
8
8
  import * as Effect from "effect/Effect";
9
9
  import * as Context from "effect/Context";
10
10
  declare namespace authorize_d_exports {
11
- export { Authorize, AuthorizeRequest, audience, ceiling, check, grantAgain, grantOf };
11
+ export { Authorize, AuthorizeRequest, CeilingInput, audience, ceiling, check, grantAgain, grantOf };
12
12
  }
13
13
  /** What `check` is asked: who acts, what they do, and the repo it names, when it names one. */
14
14
  export interface AuthorizeRequest {
@@ -17,6 +17,16 @@ export interface AuthorizeRequest {
17
17
  /** The repo the operation names: the host decides on `name`, and core holds `internalId`. */
18
18
  readonly repo?: RepoAccess;
19
19
  }
20
+ /**
21
+ * What `ceiling` is asked: who acts and the repo's name, with `internalId` when the caller already
22
+ * holds which repo the name is, so the ceiling is the one on that repo, never one a rename gave the
23
+ * name to meanwhile, and Git reads no catalogue to find it.
24
+ */
25
+ export interface CeilingInput {
26
+ readonly caller: Caller;
27
+ readonly repo: RepoName;
28
+ readonly internalId?: InternalRepoId;
29
+ }
20
30
  declare const Authorize_base: Context.ServiceClass<Authorize, "@ref0/git/Authorize", {
21
31
  /** Nothing when `request.caller` may do `request.operation`, else the refusal. */
22
32
  readonly check: (request: AuthorizeRequest) => Effect.Effect<void, GitError>;
@@ -31,10 +41,7 @@ declare const Authorize_base: Context.ServiceClass<Authorize, "@ref0/git/Authori
31
41
  * its grant's when the grant reaches it, `undefined` when either doesn't, and `'write'` for a
32
42
  * caller with neither. As `ExtendedGit.access` does today.
33
43
  */
34
- readonly ceiling: (input: {
35
- readonly caller: Caller;
36
- readonly repo: RepoName;
37
- }) => Effect.Effect<TokenScope | undefined, GitError>;
44
+ readonly ceiling: (input: CeilingInput) => Effect.Effect<TokenScope | undefined, GitError>;
38
45
  /** The resolver and grant that gave `caller`, if a grant did. As `ExtendedGit.grantOf` does today. */
39
46
  readonly grantOf: (caller: Caller) => {
40
47
  readonly resolver: string;
@@ -62,10 +69,7 @@ export declare const audience: (input: {
62
69
  readonly repo: RepoAccess;
63
70
  readonly patterns: readonly RefName[];
64
71
  }) => Effect.Effect<RefAudience, GitError, Authorize>;
65
- export declare const ceiling: (input: {
66
- readonly caller: Caller;
67
- readonly repo: RepoName;
68
- }) => Effect.Effect<"read" | "report" | "write" | undefined, GitError, Authorize>;
72
+ export declare const ceiling: (input: CeilingInput) => Effect.Effect<"read" | "report" | "write" | undefined, GitError, Authorize>;
69
73
  export declare const grantOf: (caller: Caller) => Effect.Effect<{
70
74
  readonly resolver: string;
71
75
  readonly id: string;
@@ -163,10 +163,20 @@ export declare const RefPush: Schema.Struct<{
163
163
  readonly at: Schema.Int;
164
164
  readonly of: Schema.Int;
165
165
  }>>;
166
+ /**
167
+ * The push's options as it sent them, in order, `ref0-slice` and `allow-files` included, the
168
+ * same on each `ref.updated` of the write. A push that sent none, and a write of `refs.update`,
169
+ * the queue, an import or a fork, has none. Only the host's handler gets them: Git hands push
170
+ * options to its server's hooks alone, so the event stream sends every event without them.
171
+ */
172
+ readonly options: Schema.optionalKey<Schema.$Array<Schema.String>>;
166
173
  }>;
167
174
  export type RefPush = typeof RefPush.Type;
168
175
  /**
169
- * Each ref a write moved, with the same `push` as the others that write moved. `filesAllowed`:
176
+ * Each ref a write moved, with the same `push` as the others that write moved. `kind`: how the ref
177
+ * moved, as the push's checks found it. `force` is a move they didn't show to be a fast-forward,
178
+ * which a clock-cut walk may leave one, so a consumer that needs it exact walks the objects itself.
179
+ * `filesAllowed`:
170
180
  * the files the ref's `Rules.files` rules refuse that `authorize` let through, for a push with
171
181
  * `-o allow-files`: each rule's, in the order the rules ran, the first refused first, each once.
172
182
  * `bypassed`: the `Rules.protect` and `Rules.lock` rules `authorize` lifted for this move, by name,
@@ -185,6 +195,7 @@ export declare const RefUpdated: Schema.Struct<{
185
195
  readonly internalId: Schema.TemplateLiteral<readonly ["r_", Schema.String]>;
186
196
  readonly token: Schema.optionalKey<Schema.String>;
187
197
  readonly type: Schema.Literal<"ref.updated">;
198
+ readonly kind: Schema.Literals<readonly ["create", "fast-forward", "force", "delete"]>;
188
199
  readonly push: Schema.Struct<{
189
200
  readonly id: Schema.String;
190
201
  readonly branches: Schema.Int;
@@ -202,6 +213,13 @@ export declare const RefUpdated: Schema.Struct<{
202
213
  readonly at: Schema.Int;
203
214
  readonly of: Schema.Int;
204
215
  }>>;
216
+ /**
217
+ * The push's options as it sent them, in order, `ref0-slice` and `allow-files` included, the
218
+ * same on each `ref.updated` of the write. A push that sent none, and a write of `refs.update`,
219
+ * the queue, an import or a fork, has none. Only the host's handler gets them: Git hands push
220
+ * options to its server's hooks alone, so the event stream sends every event without them.
221
+ */
222
+ readonly options: Schema.optionalKey<Schema.$Array<Schema.String>>;
205
223
  }>;
206
224
  readonly filesAllowed: Schema.optionalKey<Schema.$Array<Schema.String>>;
207
225
  readonly bypassed: Schema.optionalKey<Schema.$Array<Schema.String>>;
@@ -455,6 +473,7 @@ export declare const RepoEvent: Schema.Union<readonly [Schema.Union<readonly [Sc
455
473
  readonly internalId: Schema.TemplateLiteral<readonly ["r_", Schema.String]>;
456
474
  readonly token: Schema.optionalKey<Schema.String>;
457
475
  readonly type: Schema.Literal<"ref.updated">;
476
+ readonly kind: Schema.Literals<readonly ["create", "fast-forward", "force", "delete"]>;
458
477
  readonly push: Schema.Struct<{
459
478
  readonly id: Schema.String;
460
479
  readonly branches: Schema.Int;
@@ -472,6 +491,13 @@ export declare const RepoEvent: Schema.Union<readonly [Schema.Union<readonly [Sc
472
491
  readonly at: Schema.Int;
473
492
  readonly of: Schema.Int;
474
493
  }>>;
494
+ /**
495
+ * The push's options as it sent them, in order, `ref0-slice` and `allow-files` included, the
496
+ * same on each `ref.updated` of the write. A push that sent none, and a write of `refs.update`,
497
+ * the queue, an import or a fork, has none. Only the host's handler gets them: Git hands push
498
+ * options to its server's hooks alone, so the event stream sends every event without them.
499
+ */
500
+ readonly options: Schema.optionalKey<Schema.$Array<Schema.String>>;
475
501
  }>;
476
502
  readonly filesAllowed: Schema.optionalKey<Schema.$Array<Schema.String>>;
477
503
  readonly bypassed: Schema.optionalKey<Schema.$Array<Schema.String>>;
@@ -1431,12 +1457,13 @@ export type FeedItem = {
1431
1457
  readonly after: number;
1432
1458
  };
1433
1459
  /**
1434
- * How a server writes events: `deliverJob` is the scope's one `git.deliver` row, due now, saved
1435
- * with each write that adds events. A server whose host passed no `events` has none, and writes
1436
- * no events.
1460
+ * How a server writes events: `deliverJobs` are the scope's job of each delivery, its
1461
+ * `git.deliver.<name>`, due now, saved with each write that adds events, and `deliveries` their
1462
+ * names. A server whose host passed no `events` has none, and writes no events.
1437
1463
  */
1438
1464
  export interface EventLog {
1439
- readonly deliverJob: () => JobInput;
1465
+ readonly deliveries: readonly string[];
1466
+ readonly deliverJobs: () => readonly JobInput[];
1440
1467
  }
1441
1468
  /** What `Events` holds: core's own log, until the deliveries bring its public members (2a2-D2). */
1442
1469
  export interface EventsService {
@@ -2,7 +2,7 @@ import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
2
2
  import { ActorId } from "./actors.mjs";
3
3
  import { InternalRepoId, Oid, RefName, RepoName, TopicId } from "./ids.mjs";
4
4
  import { CandidateCloseReason, CandidateId, EntryFailureReason, EntryId, HoldId, Judged, Report, ReportDetails } from "./queue.mjs";
5
- import { RefEdit, RefSource } from "./refs.mjs";
5
+ import { RefEdit, RefSource, RefUpdateKind } from "./refs.mjs";
6
6
  import { Moment as Moment$1 } from "./repos.mjs";
7
7
  import { TokenId, TokenScope } from "./tokens.mjs";
8
8
  import { TopicCandidate, TopicEntry, TopicFailure, TopicMergedEntry } from "./topics.mjs";
@@ -147,10 +147,20 @@ const RefPush = /* @__PURE__ */ Schema.Struct({
147
147
  slice: Schema.optionalKey(Schema.Struct({
148
148
  at: Schema.Int,
149
149
  of: Schema.Int
150
- }))
150
+ })),
151
+ /**
152
+ * The push's options as it sent them, in order, `ref0-slice` and `allow-files` included, the
153
+ * same on each `ref.updated` of the write. A push that sent none, and a write of `refs.update`,
154
+ * the queue, an import or a fork, has none. Only the host's handler gets them: Git hands push
155
+ * options to its server's hooks alone, so the event stream sends every event without them.
156
+ */
157
+ options: Schema.optionalKey(Schema.Array(Schema.String))
151
158
  });
152
159
  /**
153
- * Each ref a write moved, with the same `push` as the others that write moved. `filesAllowed`:
160
+ * Each ref a write moved, with the same `push` as the others that write moved. `kind`: how the ref
161
+ * moved, as the push's checks found it. `force` is a move they didn't show to be a fast-forward,
162
+ * which a clock-cut walk may leave one, so a consumer that needs it exact walks the objects itself.
163
+ * `filesAllowed`:
154
164
  * the files the ref's `Rules.files` rules refuse that `authorize` let through, for a push with
155
165
  * `-o allow-files`: each rule's, in the order the rules ran, the first refused first, each once.
156
166
  * `bypassed`: the `Rules.protect` and `Rules.lock` rules `authorize` lifted for this move, by name,
@@ -160,6 +170,7 @@ const RefUpdated = /* @__PURE__ */ Schema.Struct({
160
170
  ...RepoEnvelope.fields,
161
171
  ...RefEdit.fields,
162
172
  type: Schema.Literal("ref.updated"),
173
+ kind: RefUpdateKind,
163
174
  push: RefPush,
164
175
  filesAllowed: Schema.optionalKey(Schema.Array(Schema.String)),
165
176
  bypassed: Schema.optionalKey(Schema.Array(Schema.String))
@@ -1,11 +1,11 @@
1
1
  import { Caller } from "./actors.mjs";
2
2
  import { TreeChange } from "./engine.mjs";
3
3
  import { GrantResolver } from "./grants.mjs";
4
- import { InternalRepoId, RefName } from "./ids.mjs";
4
+ import { InternalRepoId, RefName, RepoName } from "./ids.mjs";
5
5
  import { RefUpdate } from "./refs.mjs";
6
6
  import { PinnedRepo } from "./repos.mjs";
7
7
  import { GitError } from "./result.mjs";
8
- import { JobDefinition, Moment } from "@ref0/infra";
8
+ import { Committed, JobDefinition, Key, Moment, Read, Row } from "@ref0/infra";
9
9
  import * as Effect from "effect/Effect";
10
10
  import * as Context from "effect/Context";
11
11
  import * as Option from "effect/Option";
@@ -18,10 +18,25 @@ import * as Option from "effect/Option";
18
18
  export declare const host: Caller;
19
19
  /** Whether `caller` is `host` itself, the one value that is. */
20
20
  export declare const isHost: (caller: Caller | undefined) => boolean;
21
- /** What a feature claims as `Git.layer` builds: its name, the prefix of its jobs. */
21
+ /** What a feature claims as `Git.layer` builds: its name, the prefix of its jobs, and its refs. */
22
22
  export interface ClaimInput {
23
23
  /** The owner's name, such as `queue`: its jobs' prefix, and its hooks' order in a band. */
24
24
  readonly name: string;
25
+ /**
26
+ * A registered prefix, such as `refs/queue/`: a ref under it only the claim moves, and only a
27
+ * caller who reads every private pattern sees. No two claims' prefixes overlap, none overlaps
28
+ * Git's own `refs/import/`, and none is under `refs/heads/` or `refs/tags/`.
29
+ */
30
+ readonly refs?: `refs/${string}/`;
31
+ }
32
+ /**
33
+ * What only a registered prefix's owner holds: it moves the prefix's refs, which no one else sees.
34
+ * Only Git's registry makes one, as a claim's `owner`: a copy of it owns nothing.
35
+ */
36
+ export interface RefOwner {
37
+ readonly prefix: `refs/${string}/`;
38
+ /** The claim's name, such as `queue`. */
39
+ readonly owner: string;
25
40
  }
26
41
  /** A claim's hook is a function, or one with its order, as Vite's are (Q3). */
27
42
  export type Hook<F> = F | {
@@ -59,6 +74,52 @@ export type Upkeep = (input: {
59
74
  readonly repo: InternalRepoId;
60
75
  readonly at: Moment;
61
76
  }) => Effect.Effect<UpkeepStep, GitError>;
77
+ /** A step of a claim's purge: `did` when it deleted some, `waits` while what it ends stands, `done`. */
78
+ export type PurgeStep = 'did' | 'waits' | 'done';
79
+ /**
80
+ * A step of a claim's purge of a deleted repo, in `git.purge`, before core's rows go: its rows,
81
+ * and what they name outside the store, such as a bucket's keys. Core's own steps run once every
82
+ * claim's answers `done`.
83
+ */
84
+ export type Purge = (input: {
85
+ readonly repo: InternalRepoId;
86
+ }) => Effect.Effect<PurgeStep, GitError>;
87
+ /** A claim's rows as one read found them: the repo's version, and each read's rows in order. */
88
+ export interface ClaimSnapshot {
89
+ readonly version: number;
90
+ readonly results: readonly (readonly Row[])[];
91
+ }
92
+ /** One write to a claim's rows in a repo. */
93
+ export interface ClaimWrites {
94
+ readonly put?: readonly Row[];
95
+ readonly delete?: readonly Key[];
96
+ /** When the repo's upkeep runs next, in `git.repack`: the claim's upkeep steps then. */
97
+ readonly wake?: Moment;
98
+ }
99
+ /**
100
+ * A claim's rows in each repo's scope: collections under `<claim name>/`, and nothing else. A read
101
+ * or a write of another collection, the repo's own record, refs, objects or another claim's, is a
102
+ * defect.
103
+ */
104
+ export interface ClaimRows {
105
+ /** `reads` at one version of `repo`'s scope. */
106
+ readonly read: (repo: InternalRepoId, reads: readonly Read[]) => Effect.Effect<ClaimSnapshot, GitError>;
107
+ /**
108
+ * `reads` for `caller`'s write to `repo`, read with its record and the caller's grant fence at
109
+ * one version, so a commit at that version fails once the repo's deleted or the grant revoked.
110
+ * A deleted repo is `NOT_FOUND`, and a revoked grant the fence's refusal.
111
+ */
112
+ readonly readFenced: (caller: Caller, repo: {
113
+ readonly internalId: InternalRepoId;
114
+ readonly name: RepoName;
115
+ }, reads: readonly Read[]) => Effect.Effect<ClaimSnapshot, GitError>;
116
+ /** The repo `repo` was forked from, by its record, while it's kept: `undefined` for none. */
117
+ readonly source: (repo: InternalRepoId) => Effect.Effect<InternalRepoId | undefined, GitError>;
118
+ /** One commit at `at`, a version read: one since moved it fails, `ok: false`. */
119
+ readonly commit: (repo: InternalRepoId, at: number, writes: ClaimWrites) => Effect.Effect<Committed, GitError>;
120
+ /** Rows at keys none holds, outside the version: a key held fails `ALREADY_EXISTS`. */
121
+ readonly add: (repo: InternalRepoId, writes: Omit<ClaimWrites, 'delete'>) => Effect.Effect<void, GitError>;
122
+ }
62
123
  /** What a route's handler is given: the request, and the path's `:name` parts, decoded. */
63
124
  export interface RouteRequest {
64
125
  readonly request: Request;
@@ -78,8 +139,12 @@ export interface Route {
78
139
  /** What a claim adds to Git as `Git.layer` builds. An addition after the seal is a defect. */
79
140
  interface Claim$1 {
80
141
  readonly name: string;
142
+ /** The claim's registered prefix's owner, when it claimed `refs`. */
143
+ readonly owner?: RefOwner;
144
+ readonly rows: ClaimRows;
81
145
  readonly addPushCheck: (check: Hook<PushCheck>) => Effect.Effect<void>;
82
146
  readonly addUpkeep: (step: Hook<Upkeep>) => Effect.Effect<void>;
147
+ readonly addPurge: (step: Hook<Purge>) => Effect.Effect<void>;
83
148
  readonly addRoute: (route: Hook<Route>) => Effect.Effect<void>;
84
149
  /** A job named `<claim name>.<job>`: infra's `JobDefinition`, as `JobQueue.register` takes. */
85
150
  readonly addJob: (definition: JobDefinition) => Effect.Effect<void>;
@@ -1,5 +1,5 @@
1
1
  import { ActorId, CallInput, Credentials, NamedActor } from "./actors.mjs";
2
- import { RepoName } from "./ids.mjs";
2
+ import { InternalRepoId, RepoName } from "./ids.mjs";
3
3
  import { Awaitable } from "./result.mjs";
4
4
  import { TokenScope } from "./tokens.mjs";
5
5
  export interface GrantInput extends CallInput {
@@ -7,8 +7,13 @@ export interface GrantInput extends CallInput {
7
7
  readonly request: Request;
8
8
  readonly signal: AbortSignal;
9
9
  }
10
+ /**
11
+ * `internalId`: which repo `repo` names, when Git holds it: decide by it, since a rename can give
12
+ * the name to another repo while a request runs.
13
+ */
10
14
  export interface GrantReachInput extends CallInput {
11
15
  readonly repo: RepoName;
16
+ readonly internalId?: InternalRepoId;
12
17
  readonly signal: AbortSignal;
13
18
  }
14
19
  /**
@@ -4,7 +4,10 @@ import "./objects.mjs";
4
4
  import { RepoInput } from "./repos.mjs";
5
5
  import { Bytes } from "./object-values.mjs";
6
6
  import { Result } from "./result.mjs";
7
- /** Turns on Git LFS: `lfs()`, from `@ref0/git`. A bucket alone turns nothing on. */
7
+ /**
8
+ * Turns on Git LFS: `lfs()`, from `@ref0/git`, which `createGitServer` builds `Lfs.layer()` for. A
9
+ * bucket alone turns nothing on.
10
+ */
8
11
  export interface LfsFeature {
9
12
  readonly kind: 'lfs';
10
13
  }
@@ -25,7 +28,7 @@ export interface LfsCalls {
25
28
  /**
26
29
  * An object the repo lists, or a source up its fork chain does, for a caller who may read the
27
30
  * repo: the read refusal for any other. `NOT_FOUND` for an object none lists, of another `size`,
28
- * or on a server without `lfs()`; `DATA_LOSS` for a listed object whose bytes are gone. `signal`
31
+ * or on a server without `Lfs.layer()`; `DATA_LOSS` for a listed object whose bytes are gone. `signal`
29
32
  * aborted cancels the bucket's stream.
30
33
  */
31
34
  readonly get: (repo: RepoName, input: LfsGetInput) => Promise<Result<LfsObject>>;
@@ -7,7 +7,7 @@ import { RepoStats } from "./repos.mjs";
7
7
  import { GitError, Result } from "./result.mjs";
8
8
  import { EffectCalls } from "./services.mjs";
9
9
  import { GitStore, Holding, Listed, Pack } from "./store.mjs";
10
- import { Bucket, CallLimits, Key, Listing, Moment, Page, Row } from "@ref0/infra";
10
+ import { Bucket, BucketLinks, BucketUploads, CallLimits, Key, Listing, Moment, Page, Row } from "@ref0/infra";
11
11
  import * as Effect from "effect/Effect";
12
12
  export interface EffectiveLimits {
13
13
  readonly objects: number;
@@ -277,7 +277,8 @@ export interface Allotment {
277
277
  }
278
278
  /**
279
279
  * A receive's staged objects, not yet visible. `quarantine` is the push's own row, there only when
280
- * the change adds a pack: rows alone are written in the push's commit, so nothing outlives it. It
280
+ * the change adds a pack: rows alone are written in the push's commit, so nothing outlives it, and
281
+ * a push whose commit doesn't list its pack commits the row abandoned as it answers. It
281
282
  * keeps no list of the pack's objects: `packs()` lets go of its receive's object list before it
282
283
  * answers, so the checks after it, `Rules.files`' walk among them, run in those bytes.
283
284
  */
@@ -553,6 +554,10 @@ export interface ObjectsStep {
553
554
  }
554
555
  /** Infra's bucket, as the Effect service the objects call. */
555
556
  type Bucket$1 = Bucket.Bucket['Service'];
557
+ /** Infra's signed links, as the Effect service LFS's actions call. */
558
+ export type Links = BucketLinks.BucketLinks['Service'];
559
+ /** Infra's multipart uploads, as the Effect service push uploads call. */
560
+ export type Uploads = BucketUploads.BucketUploads['Service'];
556
561
  /**
557
562
  * What a server opens its objects over, once: Git's store, the adapter's bucket as the service, and
558
563
  * its clock and `fetchLimits`, past which `fetch` refuses a fetch's own limits.
@@ -1,4 +1,4 @@
1
- import { Addition, CallOptions, Change, Claim, ClaimRequest, ClaimResult, Committed, Count, DeleteBatch, DeleteManyOptions, JobCounts, JobDefinition, JobItem, JobListRequest, JobRef, Listing, Moment, Multipart, Outcome, Page, ProgressStored, ProgressWrite, PutOptions, Range, Read, RetryInput, RunResult, Scope, Settled, Snapshot, Stored, UrlOptions, Watch, WatchedRow } from "@ref0/infra";
1
+ import { Addition, Change, Claim, ClaimRequest, ClaimResult, Committed, Count, JobCounts, JobDefinition, JobItem, JobListRequest, JobRef, Listing, Moment, Outcome, ProgressStored, ProgressWrite, Read, RetryInput, RunResult, Scope, Settled, Snapshot, Watch, WatchedRow } from "@ref0/infra";
2
2
  import * as EffectDuration from "effect/Duration";
3
3
  /** Records: the truth, as `Records.Records` gives them. */
4
4
  export interface RecordStore {
@@ -26,18 +26,6 @@ interface JobQueue$1 {
26
26
  retry(scope: Scope, job: JobRef): Promise<void>;
27
27
  discard(scope: Scope, job: JobRef): Promise<void>;
28
28
  }
29
- /** Files by key, as `Bucket.Bucket` gives them. */
30
- interface Bucket$1 {
31
- /** How a body of unknown length goes up, and the calls each put makes past its parts (Q829). */
32
- readonly multipart: Multipart;
33
- put(key: string, body: ReadableStream<Uint8Array>, options?: PutOptions & CallOptions): Promise<Stored>;
34
- read(key: string, range?: Range, options?: CallOptions): Promise<ReadableStream<Uint8Array> | undefined>;
35
- delete(key: string, options?: CallOptions): Promise<void>;
36
- readonly deleteBatch: DeleteBatch;
37
- deleteMany(keys: ReadonlyArray<string>, options?: DeleteManyOptions & CallOptions): Promise<void>;
38
- list(prefix: string, page?: Page, options?: CallOptions): Promise<Listing<Stored>>;
39
- url?(key: string, options: UrlOptions & CallOptions): Promise<string>;
40
- }
41
29
  /** The runtime's `Clock`, as a promise: leases and due times are compared on it. */
42
30
  export interface Clock {
43
31
  now(): Moment;
@@ -46,4 +34,4 @@ export interface Clock {
46
34
  }
47
35
  /** A length of time: milliseconds, or Effect's words for one, such as `'30 seconds'`. */
48
36
  export type Duration = EffectDuration.Input;
49
- export { Bucket$1 as Bucket, JobQueue$1 as JobQueue };
37
+ export { JobQueue$1 as JobQueue };
@@ -6,7 +6,7 @@ export interface PushOptions {
6
6
  /**
7
7
  * A push whose pack is larger than `above` bytes may upload it to the bucket in parts, past the
8
8
  * platform's request limit. The server advertises it as `push-upload=<above>`, and only when its
9
- * bucket is a `SignedUpload`.
9
+ * adapter gives `BucketUploads`.
10
10
  */
11
11
  export interface PushUploadOptions {
12
12
  readonly above: number;