@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
@@ -317,7 +317,7 @@ declare const WorkApiGroup_base: HttpApiGroup.HttpApiGroup<"work", HttpApiEndpoi
317
317
  readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
318
318
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
319
319
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
320
- 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>]>>;
320
+ 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>]>>;
321
321
  indexBytes: Schema.optionalKey<Schema.Number>;
322
322
  pushBytes: Schema.optionalKey<Schema.Number>;
323
323
  most: Schema.optionalKey<Schema.Number>;
@@ -409,7 +409,7 @@ declare const WorkApiGroup_base: HttpApiGroup.HttpApiGroup<"work", HttpApiEndpoi
409
409
  readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
410
410
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
411
411
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
412
- 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>]>>;
412
+ 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>]>>;
413
413
  indexBytes: Schema.optionalKey<Schema.Number>;
414
414
  pushBytes: Schema.optionalKey<Schema.Number>;
415
415
  most: Schema.optionalKey<Schema.Number>;
@@ -722,7 +722,7 @@ declare const WorkApiGroup_base: HttpApiGroup.HttpApiGroup<"work", HttpApiEndpoi
722
722
  readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
723
723
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
724
724
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
725
- 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>]>>;
725
+ 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>]>>;
726
726
  indexBytes: Schema.optionalKey<Schema.Number>;
727
727
  pushBytes: Schema.optionalKey<Schema.Number>;
728
728
  most: Schema.optionalKey<Schema.Number>;
@@ -814,7 +814,7 @@ declare const WorkApiGroup_base: HttpApiGroup.HttpApiGroup<"work", HttpApiEndpoi
814
814
  readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
815
815
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
816
816
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
817
- 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>]>>;
817
+ 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>]>>;
818
818
  indexBytes: Schema.optionalKey<Schema.Number>;
819
819
  pushBytes: Schema.optionalKey<Schema.Number>;
820
820
  most: Schema.optionalKey<Schema.Number>;
@@ -1127,7 +1127,7 @@ declare const WorkApiGroup_base: HttpApiGroup.HttpApiGroup<"work", HttpApiEndpoi
1127
1127
  readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
1128
1128
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
1129
1129
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
1130
- 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>]>>;
1130
+ 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>]>>;
1131
1131
  indexBytes: Schema.optionalKey<Schema.Number>;
1132
1132
  pushBytes: Schema.optionalKey<Schema.Number>;
1133
1133
  most: Schema.optionalKey<Schema.Number>;
@@ -1219,7 +1219,7 @@ declare const WorkApiGroup_base: HttpApiGroup.HttpApiGroup<"work", HttpApiEndpoi
1219
1219
  readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
1220
1220
  readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
1221
1221
  readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
1222
- 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>]>>;
1222
+ 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>]>>;
1223
1223
  indexBytes: Schema.optionalKey<Schema.Number>;
1224
1224
  pushBytes: Schema.optionalKey<Schema.Number>;
1225
1225
  most: Schema.optionalKey<Schema.Number>;
@@ -0,0 +1,20 @@
1
+ import { Git } from "../contracts/git.mjs";
2
+ import { GitServer } from "../contracts/server.mjs";
3
+ import { NodeHandler, NodeMiddleware } from "../http/node.mjs";
4
+ import * as ManagedRuntime from "effect/ManagedRuntime";
5
+ /**
6
+ * What a Node host answers with: its runtime over `Git.layer`, or a `{ fetch }`, such as a server
7
+ * `createGitServer` made, until 2c-3b removes that form.
8
+ */
9
+ export type NodeAnswerer = Pick<GitServer, 'fetch'> | ManagedRuntime.ManagedRuntime<Git, unknown>;
10
+ /**
11
+ * A runtime over `Git.layer`, a Git server, or any `fetch`, as a `node:http` or `node:http2`
12
+ * listener or an Express route: `createServer(toNodeHandler(runtime))`, as `http/node.ts`'s
13
+ * `toNodeHandler` answers a `fetch`.
14
+ */
15
+ export declare const toNodeHandler: (answerer: NodeAnswerer) => NodeHandler;
16
+ /**
17
+ * A runtime over `Git.layer`, a Git server, or any `fetch`, beside an app's own routes, as an
18
+ * Express middleware, as `http/node.ts`'s `toNodeMiddleware` answers a `fetch`.
19
+ */
20
+ export declare const toNodeMiddleware: (answerer: NodeAnswerer, pathOf: (url: URL) => string | undefined) => NodeMiddleware;
@@ -0,0 +1,20 @@
1
+ import { toNodeHandler as toNodeHandler$1, toNodeMiddleware as toNodeMiddleware$1 } from "../http/node.mjs";
2
+ import { toFetch } from "./edge.mjs";
3
+ import * as ManagedRuntime from "effect/ManagedRuntime";
4
+ // src/server/edge-node.ts
5
+ /** Whether `answerer` is a runtime, as `NodeAnswerer` holds only runtimes over `Git`. */
6
+ const isRuntime = (answerer) => ManagedRuntime.isManagedRuntime(answerer);
7
+ /** A runtime answered through `Git.toFetch`, so a failed build answers `UNAVAILABLE` here too. */
8
+ const fetchOf = (answerer) => isRuntime(answerer) ? { fetch: toFetch(answerer) } : answerer;
9
+ /**
10
+ * A runtime over `Git.layer`, a Git server, or any `fetch`, as a `node:http` or `node:http2`
11
+ * listener or an Express route: `createServer(toNodeHandler(runtime))`, as `http/node.ts`'s
12
+ * `toNodeHandler` answers a `fetch`.
13
+ */
14
+ const toNodeHandler = (answerer) => toNodeHandler$1(fetchOf(answerer));
15
+ /**
16
+ * A runtime over `Git.layer`, a Git server, or any `fetch`, beside an app's own routes, as an
17
+ * Express middleware, as `http/node.ts`'s `toNodeMiddleware` answers a `fetch`.
18
+ */
19
+ const toNodeMiddleware = (answerer, pathOf) => toNodeMiddleware$1(fetchOf(answerer), pathOf);
20
+ export { toNodeHandler, toNodeMiddleware };
@@ -0,0 +1,10 @@
1
+ import { Git } from "../contracts/git.mjs";
2
+ import * as ManagedRuntime from "effect/ManagedRuntime";
3
+ /**
4
+ * A host's `fetch` over its runtime: each request is `Git.handle` on it, and the runtime builds
5
+ * once, on the first. A build that failed, which the runtime keeps, answers each request
6
+ * `UNAVAILABLE`, and a defect answers `INTERNAL`: it never rejects. A request's signal interrupts
7
+ * its route, and a client that went away gets an empty 499, as `openServer` answers one. The host
8
+ * owns the runtime and disposes of it; `toFetch` builds nothing.
9
+ */
10
+ export declare const toFetch: <E>(runtime: ManagedRuntime.ManagedRuntime<Git, E>) => (request: Request) => Promise<Response>;
@@ -0,0 +1,23 @@
1
+ import { handle } from "../contracts/git.mjs";
2
+ import { gitError } from "../contracts/result.mjs";
3
+ import { refusal } from "../http/answers.mjs";
4
+ import { unavailable } from "./lifecycle.mjs";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Cause from "effect/Cause";
7
+ import * as Exit from "effect/Exit";
8
+ // src/server/edge.ts
9
+ /**
10
+ * A host's `fetch` over its runtime: each request is `Git.handle` on it, and the runtime builds
11
+ * once, on the first. A build that failed, which the runtime keeps, answers each request
12
+ * `UNAVAILABLE`, and a defect answers `INTERNAL`: it never rejects. A request's signal interrupts
13
+ * its route, and a client that went away gets an empty 499, as `openServer` answers one. The host
14
+ * owns the runtime and disposes of it; `toFetch` builds nothing.
15
+ */
16
+ const toFetch = (runtime) => async (request) => {
17
+ const answer = await runtime.runPromiseExit(handle(request), { signal: request.signal });
18
+ if (Exit.isSuccess(answer)) return answer.value;
19
+ if (request.signal.aborted && Cause.hasInterruptsOnly(answer.cause)) return new Response(null, { status: 499 });
20
+ const build = await Effect.runPromiseExit(runtime.contextEffect);
21
+ return refusal(Exit.isFailure(build) ? unavailable(build.cause) : gitError("INTERNAL", "The server failed"));
22
+ };
23
+ export { toFetch };
@@ -107,7 +107,7 @@ const extendGit = (git, extension) => {
107
107
  hostCalls: () => attached.hostCalls,
108
108
  effectHostCalls: () => attached.effectHostCalls,
109
109
  access: (caller, repo, request) => extensionCall(attached.access(caller, repo), countOf(request)),
110
- effectAccess: (caller, repo, request) => effectCall(countedAs(attached.access(caller, repo), countOf(request))),
110
+ effectAccess: (caller, repo, request, internalId) => effectCall(countedAs(attached.access(caller, repo, internalId), countOf(request))),
111
111
  importState: (internalId) => effectCall(Effect.flatMap(store, (on) => importStateOf(on, internalId))),
112
112
  grantAgain: (resolver, input) => extensionCall(attached.grantAgain(resolver, input)),
113
113
  effectGrantAgain: (resolver, input) => effectCall(attached.grantAgain(resolver, input)),
@@ -2,17 +2,22 @@ import { Policy } from "../auth/policy.mjs";
2
2
  import { Authorize } from "../contracts/authorize.mjs";
3
3
  import { Events } from "../contracts/events.mjs";
4
4
  import { Git } from "../contracts/git.mjs";
5
+ import { PushUploadOptions } from "../contracts/push-uploads.mjs";
5
6
  import { Refs } from "../contracts/refs.mjs";
6
7
  import { RepoRecords } from "../contracts/repo-records.mjs";
7
8
  import { GitError } from "../contracts/result.mjs";
8
9
  import { CallServices, GitNeeds, GitServerOptions } from "../contracts/server.mjs";
9
10
  import { Objects, Storage } from "../core/objects/objects.mjs";
11
+ import { ServerSeam } from "../core/seam.mjs";
12
+ import { LfsBase } from "../lfs/base.mjs";
10
13
  import { QueueBase } from "../queue/host.mjs";
14
+ import { UploadsBase } from "./uploads.mjs";
15
+ import { BucketUploads } from "@ref0/infra";
11
16
  import * as Layer from "effect/Layer";
12
- /** `Git.layer`'s options: settings only (Q834, Q1006). */
13
- export interface GitOptions extends Pick<GitServerOptions, 'fetchLimits' | 'pushes' | 'basePath'> {}
17
+ /** `Git.layer`'s options: settings only (Q834, Q1006). Push uploads are `Git.layerUploads`'. */
18
+ export interface GitOptions extends Pick<GitServerOptions, 'fetchLimits' | 'basePath'> {}
14
19
  /** Core's services, which every feature may require and `Git.layer` provides. */
15
- export type CoreServices = Git | RepoRecords | Authorize | Refs | Objects | Events | CallServices | QueueBase;
20
+ export type CoreServices = Git | RepoRecords | Authorize | Refs | Objects | Events | CallServices | QueueBase | ServerSeam | LfsBase | UploadsBase;
16
21
  /** What `Git.layer` requires: infra's three, the host's `Policy`, and its objects (Q1006). */
17
22
  export type GitServices = GitNeeds | Policy | Storage;
18
23
  /**
@@ -20,4 +25,10 @@ export type GitServices = GitNeeds | Policy | Storage;
20
25
  * Layer claims a name and adds its hooks as it builds; a claim after the seal is a defect, and a
21
26
  * clash fails the build. `Bucket`, `Auth` and the rest of the host's services stay optional.
22
27
  */
23
- export declare const layer: <ROut = never, E = never, RIn = never>(options?: GitOptions, features?: Layer.Layer<ROut, E, RIn>) => Layer.Layer<CoreServices | ROut, GitError | E, GitServices | Exclude<RIn, CoreServices>>;
28
+ export declare const layer: <ROut = never, E = never, RIn = never>(options?: GitOptions, features?: Layer.Layer<ROut, E, RIn>) => Layer.Layer<CoreServices | ROut, GitError | E, GitServices | Exclude<RIn, CoreServices>>;
29
+ /**
30
+ * Push uploads, a feature of Git's own: a push whose pack is larger than `options.above` bytes may
31
+ * upload it to the host's bucket in parts, past the platform's request limit, through the routes
32
+ * under each repo's `push-uploads`. It requires `BucketUploads`, which signs and joins the parts.
33
+ */
34
+ export declare const layerUploads: (options: PushUploadOptions) => Layer.Layer<never, never, UploadsBase | BucketUploads.BucketUploads>;
@@ -4,9 +4,12 @@ import { Policy } from "../auth/policy.mjs";
4
4
  import { Git } from "../contracts/git.mjs";
5
5
  import { Rules } from "../contracts/rules.mjs";
6
6
  import { IndexedStorage, Storage } from "../core/objects/objects.mjs";
7
+ import { ServerSeam, seamOf } from "../core/seam.mjs";
7
8
  import { refusal } from "../http/answers.mjs";
8
9
  import { gitPathOf, normalBase } from "../http/paths.mjs";
9
10
  import { openServer } from "./server.mjs";
11
+ import { attachUploads } from "./uploads.mjs";
12
+ import { BucketUploads } from "@ref0/infra";
10
13
  import * as Effect from "effect/Effect";
11
14
  import * as Context from "effect/Context";
12
15
  import * as Option from "effect/Option";
@@ -64,6 +67,8 @@ const core = (options) => Layer.effectContext(Effect.gen(function* () {
64
67
  rules
65
68
  }, deciders, "later")), (made) => Effect.promise(() => made.server.close()));
66
69
  const built = yield* opened.built;
70
+ const seam = seamOf(opened.server);
71
+ if (seam === void 0) return yield* Effect.die(/* @__PURE__ */ new Error("A Git server with no seam"));
67
72
  const base = normalBase(options.basePath ?? "");
68
73
  const claimed = (bands, request) => {
69
74
  const path = gitPathOf(new URL(request.url), base);
@@ -86,7 +91,7 @@ const core = (options) => Layer.effectContext(Effect.gen(function* () {
86
91
  handle: (request) => Effect.map(route(request), (answer) => Option.getOrElse(answer, () => new Response("Not found", { status: 404 }))),
87
92
  identify: (request) => bound(request, (signalled) => Effect.flatMap(Effect.promise(() => opened.server.identify(signalled)), (result) => result.kind === "success" ? Effect.succeed(result.value) : Effect.fail(result.error)))
88
93
  });
89
- return built.services.pipe(Context.add(Git, git), Context.add(Seal, opened.seal));
94
+ return built.services.pipe(Context.add(Git, git), Context.add(ServerSeam, seam), Context.add(Seal, opened.seal));
90
95
  }));
91
96
  /** The last step: seals the registry once every feature has claimed, and registers their jobs. */
92
97
  const sealing = () => Layer.effectContext(Effect.gen(function* () {
@@ -104,4 +109,10 @@ const layer = (options = {}, features) => {
104
109
  const built = Layer.provideMerge(added, core(options));
105
110
  return Layer.provide(sealing(), built);
106
111
  };
107
- export { layer };
112
+ /**
113
+ * Push uploads, a feature of Git's own: a push whose pack is larger than `options.above` bytes may
114
+ * upload it to the host's bucket in parts, past the platform's request limit, through the routes
115
+ * under each repo's `push-uploads`. It requires `BucketUploads`, which signs and joins the parts.
116
+ */
117
+ const layerUploads = (options) => Layer.effectDiscard(Effect.andThen(Effect.service(BucketUploads.BucketUploads), attachUploads(options)));
118
+ export { layer, layerUploads };
@@ -1,6 +1,7 @@
1
- import { Claim, ClaimInput, Git, Hook, PushCheck, PushCheckAnswer, PushCheckInput, RefRefusal, Route, RouteMethod, RouteRequest, Upkeep, UpkeepStep, claim, handle, host, identify, isHost, route } from "../contracts/git.mjs";
2
- import { CoreServices, GitOptions, GitServices, layer } from "./git-layer.mjs";
1
+ import { Claim, ClaimInput, ClaimRows, ClaimSnapshot, ClaimWrites, Git, Hook, Purge, PurgeStep, PushCheck, PushCheckAnswer, PushCheckInput, RefOwner, RefRefusal, Route, RouteMethod, RouteRequest, Upkeep, UpkeepStep, claim, handle, host, identify, isHost, route } from "../contracts/git.mjs";
2
+ import { CoreServices, GitOptions, GitServices, layer, layerUploads } from "./git-layer.mjs";
3
+ import { toFetch } from "./edge.mjs";
3
4
  declare namespace git_namespace_d_exports {
4
- export { Claim, ClaimInput, CoreServices, Git, GitOptions, GitServices, Hook, PushCheck, PushCheckAnswer, PushCheckInput, RefRefusal, Route, RouteMethod, RouteRequest, Upkeep, UpkeepStep, claim, handle, host, identify, isHost, layer, route };
5
+ export { Claim, ClaimInput, ClaimRows, ClaimSnapshot, ClaimWrites, CoreServices, Git, GitOptions, GitServices, Hook, Purge, PurgeStep, PushCheck, PushCheckAnswer, PushCheckInput, RefOwner, RefRefusal, Route, RouteMethod, RouteRequest, Upkeep, UpkeepStep, claim, handle, host, identify, isHost, layer, layerUploads, route, toFetch };
5
6
  }
6
- export { Claim, ClaimInput, CoreServices, Git, GitOptions, GitServices, Hook, PushCheck, PushCheckAnswer, PushCheckInput, RefRefusal, Route, RouteMethod, RouteRequest, Upkeep, UpkeepStep, claim, git_namespace_d_exports, handle, host, identify, isHost, layer, route };
7
+ export { Claim, ClaimInput, ClaimRows, ClaimSnapshot, ClaimWrites, CoreServices, Git, GitOptions, GitServices, Hook, Purge, PurgeStep, PushCheck, PushCheckAnswer, PushCheckInput, RefOwner, RefRefusal, Route, RouteMethod, RouteRequest, Upkeep, UpkeepStep, claim, git_namespace_d_exports, handle, host, identify, isHost, layer, layerUploads, route, toFetch };
@@ -1,6 +1,7 @@
1
1
  import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
2
2
  import { Git, claim, handle, host, identify, isHost, route } from "../contracts/git.mjs";
3
- import { layer } from "./git-layer.mjs";
3
+ import { layer, layerUploads } from "./git-layer.mjs";
4
+ import { toFetch } from "./edge.mjs";
4
5
  // src/server/git-namespace.ts
5
6
  var git_namespace_exports = /* @__PURE__ */ __exportAll({
6
7
  Git: () => Git,
@@ -10,6 +11,8 @@ var git_namespace_exports = /* @__PURE__ */ __exportAll({
10
11
  identify: () => identify,
11
12
  isHost: () => isHost,
12
13
  layer: () => layer,
13
- route: () => route
14
+ layerUploads: () => layerUploads,
15
+ route: () => route,
16
+ toFetch: () => toFetch
14
17
  });
15
- export { Git, claim, git_namespace_exports, handle, host, identify, isHost, layer, route };
18
+ export { Git, claim, git_namespace_exports, handle, host, identify, isHost, layer, layerUploads, route, toFetch };
@@ -1,9 +1,12 @@
1
1
  import "../contracts/git.mjs";
2
2
  import "../contracts/grants.mjs";
3
+ import "../core/claim-rows.mjs";
4
+ import "../core/purge.mjs";
3
5
  import "../contracts/result.mjs";
4
6
  import "../contracts/rules.mjs";
5
7
  import "../core/hooks/order.mjs";
6
8
  import "../core/repack.mjs";
7
9
  import "../core/rules/context.mjs";
10
+ import "../protocol/wire/lines.mjs";
8
11
  import { JobDefinition } from "@ref0/infra";
9
12
  import "effect/Effect";
@@ -1,12 +1,24 @@
1
+ import { claimRows } from "../core/claim-rows.mjs";
2
+ import { isRefName } from "../core/names.mjs";
1
3
  import { gitError } from "../contracts/result.mjs";
2
4
  import { bandRank, byOrder, orderedOf } from "../core/hooks/order.mjs";
3
5
  import { upkeepsOf } from "../core/repack.mjs";
6
+ import { gitsOwnRefs, registeredRow } from "../protocol/wire/lines.mjs";
4
7
  import { answersMethod, bySpecificity, matchPath, routePath } from "./route-match.mjs";
5
8
  import * as Effect from "effect/Effect";
6
9
  // src/server/registry.ts
7
10
  const sealedDefect = () => /* @__PURE__ */ new Error("Git's registry is sealed");
8
11
  /** A clash, as the build fails with it. */
9
12
  const clash = (message) => gitError("FAILED_PRECONDITION", message);
13
+ /** A registered prefix's owner, made once, here: the very one its claim moves the prefix as. */
14
+ const ownerOf = (owner, prefix) => Object.freeze({
15
+ prefix,
16
+ owner
17
+ });
18
+ /** Whether a ref could be under both `a` and `b`: one starts the other. */
19
+ const overlaps = (a, b) => a.startsWith(b) || b.startsWith(a);
20
+ /** Where a registered prefix can't be: branches and tags are every caller's. */
21
+ const everyones = ["refs/heads/", "refs/tags/"];
10
22
  /** A claim's push check as the push runs it: on the refs no check before it refused. */
11
23
  const claimedCheck = (check) => (input, updates) => Effect.map(check({
12
24
  repo: {
@@ -38,9 +50,13 @@ const openRegistry = () => {
38
50
  const rules = [];
39
51
  const checks = [];
40
52
  const upkeeps = [];
53
+ const purges = [];
54
+ let rowsBase;
41
55
  const grants = [];
42
56
  const routes = [];
43
57
  const routeKeys = /* @__PURE__ */ new Set();
58
+ const claimed = [];
59
+ let hidden = gitsOwnRefs;
44
60
  const jobClash = (job) => {
45
61
  if (jobs.has(job.name)) return clash(`A job is named '${job.name}' already`);
46
62
  jobs.set(job.name, job);
@@ -65,9 +81,19 @@ const openRegistry = () => {
65
81
  }
66
82
  });
67
83
  };
68
- const nameClash = (name) => {
84
+ const prefixClash = (name, prefix) => {
85
+ if (!prefix.startsWith("refs/") || !prefix.endsWith("/") || !isRefName(`${prefix}x`)) return clash(`${name}'s refs '${prefix}' aren't a ref prefix, such as 'refs/${name}/'`);
86
+ const branches = everyones.find((one) => overlaps(prefix, one));
87
+ if (branches !== void 0) return clash(`${name}'s refs '${prefix}' meet ${branches}`);
88
+ const taken = [...gitsOwnRefs, ...claimed].find((row) => overlaps(prefix, row.owner.prefix));
89
+ if (taken !== void 0) return clash(`${name}'s refs '${prefix}' meet ${taken.owner.owner}'s ${taken.owner.prefix}`);
90
+ if (claimed.length >= 8) return clash(`Git's registry takes at most 8 registered prefixes`);
91
+ };
92
+ const claimClash = (name, refs) => {
69
93
  if (names.has(name)) return clash(`Git's registry has a claim named '${name}' already`);
70
- names.add(name);
94
+ const found = refs === void 0 ? void 0 : prefixClash(name, refs);
95
+ if (found === void 0) names.add(name);
96
+ return found;
71
97
  };
72
98
  const adding = (add) => Effect.suspend(() => {
73
99
  if (sealed) return Effect.die(sealedDefect());
@@ -82,11 +108,14 @@ const openRegistry = () => {
82
108
  };
83
109
  const claim = (input) => Effect.suspend(() => {
84
110
  if (sealed) return Effect.die(sealedDefect());
85
- const found = nameClash(input.name);
111
+ const { name, refs } = input;
112
+ const found = claimClash(name, refs);
86
113
  if (found !== void 0) return Effect.fail(found);
87
- const { name } = input;
114
+ const owner = refs === void 0 ? void 0 : ownerOf(name, refs);
115
+ if (owner !== void 0) claimed.push(registeredRow(owner));
88
116
  const made = {
89
117
  name,
118
+ rows: claimRows(name, () => rowsBase),
90
119
  addPushCheck: (check) => adding(() => {
91
120
  const entry = orderedOf(name, check);
92
121
  checks.push({
@@ -97,6 +126,9 @@ const openRegistry = () => {
97
126
  addUpkeep: (step) => adding(() => {
98
127
  upkeeps.push(orderedOf(name, step));
99
128
  }),
129
+ addPurge: (step) => adding(() => {
130
+ purges.push(orderedOf(name, step));
131
+ }),
100
132
  addRoute: (route) => adding(() => routeClash(name, route)),
101
133
  addJob: (definition) => adding(() => {
102
134
  if (!definition.name.startsWith(`${name}.`)) return clash(`${name}'s jobs are named '${name}.…': got '${definition.name}'`);
@@ -106,10 +138,14 @@ const openRegistry = () => {
106
138
  }),
107
139
  addGrant: (resolver) => adding(() => grantClash(name, resolver))
108
140
  };
109
- return Effect.succeed(made);
141
+ return Effect.succeed(owner === void 0 ? made : {
142
+ ...made,
143
+ owner
144
+ });
110
145
  });
111
- const bridge = (name) => {
112
- now(() => nameClash(name));
146
+ const bridge = (name, refs) => {
147
+ now(() => claimClash(name, refs));
148
+ if (refs !== void 0) claimed.push(registeredRow(ownerOf(name, refs)));
113
149
  const knowJobs = (added) => {
114
150
  const taken = added.find((job, index) => jobs.has(job.name) || added.findIndex((one) => one.name === job.name) !== index);
115
151
  if (taken !== void 0) now(() => clash(`A job is named '${taken.name}' already`));
@@ -136,8 +172,10 @@ const openRegistry = () => {
136
172
  claim,
137
173
  bridge,
138
174
  jobOf: (job) => jobs.get(job),
175
+ hiddenRefs: () => hidden,
139
176
  seal: () => Effect.suspend(() => {
140
177
  sealed = true;
178
+ hidden = [...gitsOwnRefs, ...claimed];
141
179
  const [first] = clashes;
142
180
  return first === void 0 ? Effect.succeed([...pending]) : Effect.fail(first);
143
181
  }),
@@ -147,6 +185,19 @@ const openRegistry = () => {
147
185
  repo,
148
186
  at
149
187
  })))(store, repo, at),
188
+ purge: Effect.fnUntraced(function* (_store, repo) {
189
+ for (const { handler } of ordered(purges)) {
190
+ const step = yield* handler({ repo });
191
+ if (step !== "done") return step;
192
+ }
193
+ return "done";
194
+ }),
195
+ bindRows: (base) => {
196
+ rowsBase = base;
197
+ },
198
+ addCheck: (check) => adding(() => {
199
+ checks.push(check);
200
+ }),
150
201
  grants: () => ordered(grants).map(({ handler }) => handler),
151
202
  routeOf: (bands, request, path) => {
152
203
  const byPath = routes.filter((one) => bands.has(one.band)).sort((a, b) => bandRank[a.band] - bandRank[b.band] || bySpecificity(a.handler.path, b.handler.path) || byOrder(a, b));
@@ -10,7 +10,10 @@ import "../auth/auth.mjs";
10
10
  import "../auth/host-function.mjs";
11
11
  import "../auth/identify.mjs";
12
12
  import "../auth/policy.mjs";
13
+ import "../core/events/deliver.mjs";
13
14
  import "../contracts/events.mjs";
15
+ import "../lfs/base.mjs";
16
+ import "./uploads.mjs";
14
17
  import "../http/handler.mjs";
15
18
  import "../queue/host.mjs";
16
19
  import "./extension.mjs";