@zabaca/zbc 0.12.0 → 0.13.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.
- package/CHANGELOG.md +63 -0
- package/package.json +2 -1
- package/templates/apps/inbox/package.json +1 -1
- package/templates/apps/walgit/CONTEXT.md +135 -0
- package/templates/apps/walgit/Dockerfile +40 -18
- package/templates/apps/walgit/README.md +518 -55
- package/templates/apps/walgit/e2e/README.md +100 -6
- package/templates/apps/walgit/e2e/harness.ts +262 -1
- package/templates/apps/walgit/e2e/live.ts +588 -0
- package/templates/apps/walgit/e2e/scenarios.ts +367 -5
- package/templates/apps/walgit/e2e/suite.ts +5 -5
- package/templates/apps/walgit/examples/watch.ts +209 -0
- package/templates/apps/walgit/package.json +12 -3
- package/templates/apps/walgit/registry.json +6 -11
- package/templates/apps/walgit/shared/capabilities.ts +189 -0
- package/templates/apps/walgit/shared/container-env.ts +114 -0
- package/templates/apps/walgit/shared/credentials.ts +81 -0
- package/templates/apps/walgit/shared/events.ts +277 -0
- package/templates/apps/walgit/shared/landing.ts +1241 -0
- package/templates/apps/walgit/shared/llms.ts +463 -0
- package/templates/apps/walgit/shared/outbox.ts +266 -0
- package/templates/apps/walgit/shared/policy.ts +59 -0
- package/templates/apps/walgit/shared/protocol.ts +197 -0
- package/templates/apps/walgit/shared/provenance.ts +154 -0
- package/templates/apps/walgit/shared/ref-cache.ts +181 -0
- package/templates/apps/walgit/shared/telemetry.ts +219 -0
- package/templates/apps/walgit/src/announce-main.ts +37 -0
- package/templates/apps/walgit/src/announce.ts +98 -0
- package/templates/apps/walgit/src/append-only.ts +112 -0
- package/templates/apps/walgit/src/cache.ts +172 -0
- package/templates/apps/walgit/src/cli.ts +493 -0
- package/templates/apps/walgit/src/compact.ts +25 -23
- package/templates/apps/walgit/src/delete-repo.ts +237 -0
- package/templates/apps/walgit/src/expire.ts +248 -0
- package/templates/apps/walgit/src/gc.ts +8 -16
- package/templates/apps/walgit/src/git-backend.ts +29 -0
- package/templates/apps/walgit/src/git.ts +78 -0
- package/templates/apps/walgit/src/hook-main.ts +259 -17
- package/templates/apps/walgit/src/hooks.ts +4 -3
- package/templates/apps/walgit/src/http.ts +237 -45
- package/templates/apps/walgit/src/instructions.ts +240 -0
- package/templates/apps/walgit/src/keys.ts +126 -0
- package/templates/apps/walgit/src/limits.ts +158 -0
- package/templates/apps/walgit/src/materialize.bench.ts +10 -10
- package/templates/apps/walgit/src/materialize.ts +48 -40
- package/templates/apps/walgit/src/mkdir-lock.ts +66 -0
- package/templates/apps/walgit/src/orphans.ts +2 -5
- package/templates/apps/walgit/src/pending.ts +201 -0
- package/templates/apps/walgit/src/push-cert.ts +254 -0
- package/templates/apps/walgit/src/push.ts +233 -46
- package/templates/apps/walgit/src/reconcile.ts +5 -8
- package/templates/apps/walgit/src/repo.ts +22 -77
- package/templates/apps/walgit/src/server.ts +148 -26
- package/templates/apps/walgit/src/signers.ts +577 -0
- package/templates/apps/walgit/src/store-env.ts +5 -4
- package/templates/apps/walgit/src/store.ts +47 -24
- package/templates/apps/walgit/src/usage.ts +404 -0
- package/templates/apps/walgit/src/verify.ts +171 -0
- package/templates/apps/walgit/src/wal-index.ts +189 -11
- package/templates/apps/walgit/tsconfig.json +8 -2
- package/templates/apps/walgit/tsconfig.worker.json +24 -0
- package/templates/apps/walgit/worker/events-do.ts +259 -0
- package/templates/apps/walgit/worker/index.ts +572 -0
- package/templates/apps/walgit/wrangler.jsonc +95 -0
- package/templates/apps/warehouse/package.json +1 -1
- package/templates/infra/modules/cloudflare/index.ts +77 -6
- package/templates/infra/modules/fly/index.ts +150 -10
- package/templates/infra/modules/turso/index.ts +43 -3
- package/templates/infra/package.json +1 -1
- package/templates/apps/walgit/entrypoint.sh +0 -59
- package/templates/apps/walgit/fly.toml +0 -52
- package/templates/apps/walgit/src/ssh-shell.ts +0 -36
- package/templates/apps/walgit/sshd_config +0 -38
|
@@ -8,20 +8,176 @@ deleted at any time and rebuilt from the log. See
|
|
|
8
8
|
## What works today
|
|
9
9
|
|
|
10
10
|
The **front door**, the **storage layer**, the **push path** that joins them, and
|
|
11
|
-
the **garbage collection** that keeps the log from growing without bound
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
the **garbage collection** that keeps the log from growing without bound.
|
|
12
|
+
|
|
13
|
+
walgit is one service in **three directories**, and the split is by runtime, not
|
|
14
|
+
by layer:
|
|
15
|
+
|
|
16
|
+
- **`src/`** — the container process. Runs under bun, touches the disk, runs git.
|
|
17
|
+
- **`worker/`** — the Cloudflare Worker. The two modules that genuinely need the
|
|
18
|
+
Workers runtime, and nothing else.
|
|
19
|
+
- **`shared/`** — the runtime-neutral kernel. **`shared/` imports no runtime, and
|
|
20
|
+
both halves may import it.** It is the only directory in both TypeScript
|
|
21
|
+
programs (`tsconfig.json` and `tsconfig.worker.json`), which is what makes that
|
|
22
|
+
rule something the build fails on rather than a comment. See
|
|
23
|
+
`docs/adr/0010-walgit-shared-kernel.md` in the zbc repository.
|
|
24
|
+
|
|
25
|
+
| | |
|
|
26
|
+
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
27
|
+
| `shared/protocol.ts` | the wire contract: header names, internal paths, the smart-HTTP grammar, the repo-id and ref-name grammars, the zero oid, the refusal vocabulary |
|
|
28
|
+
| `shared/credentials.ts` | reading a credential off the wire: the two auth forms, the token list, the constant-time compare |
|
|
29
|
+
| `shared/policy.ts` | reading a limit from the environment, and saying what it is — so the cap stated and the cap enforced are one number |
|
|
30
|
+
| `shared/events.ts`, `shared/outbox.ts` | the ref-event protocol and the per-ref coalesce window that bounds a subscriber's message rate — every decision, pure |
|
|
31
|
+
| `shared/telemetry.ts` | classifying a request and a refusal into the datapoint the Worker writes |
|
|
32
|
+
| `shared/landing.ts` | the HTML page a browser gets at `/`, rendered from the limits actually configured |
|
|
33
|
+
| `shared/container-env.ts` | which of the Worker's variables the container is told about, and a fingerprint of them |
|
|
34
|
+
| `worker/index.ts`, `wrangler.jsonc` | the Cloudflare Worker that proxies to the container, and forwards its environment |
|
|
35
|
+
| `shared/ref-cache.ts` | the fan-out's derived, in-memory copy of ref state — bounded, never authoritative |
|
|
36
|
+
| `worker/events-do.ts` | the Durable Object that holds the ref-event sockets — a shell over `shared/events.ts` |
|
|
37
|
+
| `src/store.ts`, `src/wal-index.ts` | the object-store adapter and the `index.json` compare-and-swap |
|
|
38
|
+
| `src/keys.ts` | the object-store key namespace: every prefix, every key builder, and the parse back out of one |
|
|
39
|
+
| `src/repo.ts` | repo addressing — the one place a client-supplied name becomes a path. Pure: string in, path out |
|
|
40
|
+
| `src/cache.ts` | provisioning the bare repo that path names: `git init`, the config walgit needs, the hooks |
|
|
41
|
+
| `src/http.ts`, `src/git-backend.ts`, `src/server.ts` | smart-HTTP, with `git http-backend` as a CGI child |
|
|
42
|
+
| `src/push.ts`, `src/hooks.ts`, `src/hook-main.ts` | the push path: upload at `pre-receive`, publish under CAS at `reference-transaction` |
|
|
43
|
+
| `src/announce.ts` | telling subscribers a push landed, from `post-receive` — after it is durable, and never able to fail it |
|
|
44
|
+
| `src/pending.ts` | the hand-off between the two hook processes of one push, keyed by `git-receive-pack` pid |
|
|
45
|
+
| `src/reconcile.ts`, `src/sync.ts` | force the local cache to match the log, on every access |
|
|
46
|
+
| `src/orphans.ts` | the packs a rejected push leaves behind, found by diffing the log |
|
|
47
|
+
| `src/materialize.ts` | rebuild a repo from the log alone, on a disk that holds nothing |
|
|
48
|
+
| `src/compact.ts` | collapse the log to one entry, under a per-repo lease |
|
|
49
|
+
| `src/gc.ts` | delete superseded and orphaned objects, a grace period later |
|
|
50
|
+
| `src/delete-repo.ts` | remove a whole repository: tombstone, wait, then index-first deletion |
|
|
51
|
+
| `src/expire.ts` | decide WHICH repositories go: idle since their last push, past the window |
|
|
52
|
+
| `src/limits.ts` | the push-size and repository-total caps, refused in `pre-receive` before anything is uploaded |
|
|
53
|
+
| `src/signers.ts` | the Signer List a repository holds, resolved in `pre-receive` beside the size caps and re-asked at the publish |
|
|
54
|
+
| `src/usage.ts` | what the log says this service holds, folded out of the indexes |
|
|
55
|
+
| `src/instructions.ts` | the plain-text `GET /` — the whole API surface, rendered from the limits actually enforced |
|
|
56
|
+
| `src/verify.ts`, `src/cli.ts` | the operator CLI: inspect, rebuild, verify, reclaim |
|
|
57
|
+
| `src/git.ts`, `src/mkdir-lock.ts` | the two shared primitives: running a git plumbing command, and locking with `mkdir` |
|
|
58
|
+
|
|
59
|
+
## The operator CLI
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
walgit serve # run the git front end (smart-HTTP)
|
|
63
|
+
walgit materialize <repo_id> [path] # rebuild a repo from the write-ahead log
|
|
64
|
+
walgit verify <repo_id> [path] # check local state against index.json
|
|
65
|
+
walgit gc <repo_id...> # reclaim superseded and orphaned objects (dry run)
|
|
66
|
+
walgit compact <repo_id> [path] # repack the log into one entry, now
|
|
67
|
+
walgit delete <repo_id...> # remove repositories entirely (dry run)
|
|
68
|
+
walgit usage [--since 24h] [--top 10] # what the log says this service holds
|
|
69
|
+
walgit expire [repo_id...] # collect repos idle past the window (dry run)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`usage` is the one command that needs nothing but bucket credentials — no repos
|
|
73
|
+
directory, no local cache, no running node — because the log is already a usage
|
|
74
|
+
ledger: every entry carries a `size` and a `ts`, so repository count, bytes
|
|
75
|
+
stored, the largest repositories and push volume over time are all derivable
|
|
76
|
+
with no instrumentation and nothing to keep in sync. It is strictly read-only,
|
|
77
|
+
which matters because it is run at exactly the moment a command that also
|
|
78
|
+
repairs things would be dangerous. It reports **pushes and storage only** — a
|
|
79
|
+
clone leaves no trace in the log at all, and an approximation invented here
|
|
80
|
+
would read as a measurement.
|
|
81
|
+
|
|
82
|
+
### The other half: what the log cannot see
|
|
83
|
+
|
|
84
|
+
`usage` answers everything the log records. The gap is structural — a clone
|
|
85
|
+
writes nothing to it — so the Worker in front of the container counts the rest
|
|
86
|
+
and writes one Analytics Engine datapoint per request to the `walgit_requests`
|
|
87
|
+
dataset (`shared/telemetry.ts`, bound as `WALGIT_METRICS` in `wrangler.jsonc`).
|
|
88
|
+
Nothing is duplicated across the two: storage, repository count and push volume
|
|
89
|
+
come from the log only, because two records of one fact disagree the first time
|
|
90
|
+
a write fails between them.
|
|
91
|
+
|
|
92
|
+
Each datapoint carries, as blobs: `kind` (`clone-advertise`, `clone`,
|
|
93
|
+
`push-advertise`, `push`, `instructions`, `health`, `other`), `outcome`
|
|
94
|
+
(`ok`/`reject`), `reject`, `repo`, `temperature` (`cold`/`warm`), `answered`
|
|
95
|
+
(`container`/`edge`); and as doubles: `status`, `ttfb_ms`, `total_ms`,
|
|
96
|
+
`bytes_served`, `bytes_received`, `cold`. The index is `kind`, so refusals — the
|
|
97
|
+
rare thing an operator is hunting — are sampled independently of clones, the
|
|
98
|
+
loud thing.
|
|
99
|
+
|
|
100
|
+
Refusals are counted **by kind**, never as an error rate, because the kinds mean
|
|
101
|
+
different things: `size-cap` (abuse or a misconfigured client), `collision` (a
|
|
102
|
+
product signal about naming), `unauthorized`, `not-found`, `unavailable`, and
|
|
103
|
+
`edge`. `edge` is a **bug signal**: walgit refusing things itself, with an
|
|
104
|
+
explanation an agent can act on, is the product, so a refusal made in front of
|
|
105
|
+
it should be zero. It is detectable because the container stamps every response
|
|
106
|
+
it produces (`x-walgit-served`) and names its own refusals (`x-walgit-reject`);
|
|
107
|
+
both headers are stripped before the response reaches the client.
|
|
108
|
+
|
|
109
|
+
What is deliberately **not** recorded: no IP, no user agent, no credential, no
|
|
110
|
+
request or repository content. Repository names are recorded — every repository
|
|
111
|
+
on a public walgit is world-readable by construction, and without the name a
|
|
112
|
+
traffic spike cannot be told apart from a hundred quiet repositories.
|
|
113
|
+
|
|
114
|
+
The measurement is off the serving path: bytes and total time are counted in a
|
|
115
|
+
pass-through transform that forwards each chunk as it measures it, and the
|
|
116
|
+
datapoint is written under `waitUntil` after the client already has its
|
|
117
|
+
response. A deployment without the binding records nothing and serves exactly
|
|
118
|
+
as before.
|
|
119
|
+
|
|
120
|
+
Query it with the [Analytics Engine SQL API](https://developers.cloudflare.com/analytics/analytics-engine/sql-api/):
|
|
121
|
+
|
|
122
|
+
```sql
|
|
123
|
+
SELECT blob1 AS kind, blob3 AS reject, count() AS n, sum(double4) AS bytes_served
|
|
124
|
+
FROM walgit_requests WHERE timestamp > now() - INTERVAL '24' HOUR GROUP BY kind, reject
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
It runs where the app's environment is — inside the container, or anywhere the
|
|
128
|
+
same `WALGIT_*` variables are set:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
bun src/cli.ts verify myrepo
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Credentials come from `src/store-env.ts`**, the same reader the server and both
|
|
135
|
+
hook processes use. There is deliberately no `~/.walgit/config`: a second configuration path is a second thing to be wrong
|
|
136
|
+
about, and it would drift from the one the app actually reads.
|
|
137
|
+
|
|
138
|
+
**Every command is a thin front over the functions the server calls** —
|
|
139
|
+
`materialize`, `reconcile`, `findOrphans`, `collectUsage`. That is what makes `verify`
|
|
140
|
+
trustworthy: a command-line reimplementation of "is this disk current?" would
|
|
141
|
+
answer for itself rather than for the server.
|
|
142
|
+
|
|
143
|
+
Exit codes are meant to be branched on: `0` success, `1` a divergence the
|
|
144
|
+
command was asked to detect, `2` misuse (unknown command, bad argument, missing
|
|
145
|
+
configuration).
|
|
146
|
+
|
|
147
|
+
`verify` is read-only, which is the whole point — `sync.ts` answers the same
|
|
148
|
+
question on every access and immediately repairs what it finds, so by the time
|
|
149
|
+
an operator asks, the evidence is gone. It reports four independent
|
|
150
|
+
disagreements, because they have different repairs: diverged refs (reconcile),
|
|
151
|
+
refs whose object this repo does not have (replay the WAL), WAL entries above
|
|
152
|
+
the frontier whose pack is absent, and a `walgit-materializing` marker — a
|
|
153
|
+
restore that died partway can leave refs that look perfect on a truncated repo.
|
|
154
|
+
|
|
155
|
+
`gc` reclaims both kinds of garbage — entries a compaction superseded, and the
|
|
156
|
+
packs rejected pushes leave behind. It **only reports unless given `--yes`**,
|
|
157
|
+
and it never collects an object younger than `--min-age` (default 60 minutes,
|
|
158
|
+
`WALGIT_GC_GRACE_MS`): the push path uploads a pack _before_ it publishes it, so
|
|
159
|
+
inside that window a perfectly good pack is indistinguishable from a rejected
|
|
160
|
+
one, and deleting it would fail a push that was about to succeed. The age comes
|
|
161
|
+
from the ULID in the key, so it costs no extra round trip — and an object whose
|
|
162
|
+
age cannot be read is left alone. There is no collect-everything mode: a `LIST`
|
|
163
|
+
of the whole bucket would name repos this node never served, and the blast
|
|
164
|
+
radius of a wrong guess is objects deleted from the source of truth.
|
|
165
|
+
|
|
166
|
+
`delete` removes repositories on purpose, which is why it is the most cautious
|
|
167
|
+
command here: it **only reports unless given `--yes`**, and even then the first
|
|
168
|
+
run does not delete — it writes a `deletion` marker into `index.json` and the
|
|
169
|
+
objects survive until `--grace` minutes have passed (default 60,
|
|
170
|
+
`WALGIT_DELETE_GRACE_MS`). A second run after that deadline collects. Asking
|
|
171
|
+
twice inside the window does not restart the clock, and deleting a repository
|
|
172
|
+
that is not there is a no-op rather than an error.
|
|
173
|
+
|
|
174
|
+
`compact` forces a compaction rather than waiting for
|
|
175
|
+
`WALGIT_COMPACTION_THRESHOLD` pushes to trigger one — for the repo whose restore
|
|
176
|
+
is already slow because its log is already long. It takes the same per-repo
|
|
177
|
+
lease the automatic path does, so forcing one while a node is mid-compaction
|
|
178
|
+
reports the holder instead of racing it. `--force=false` inverts it into a
|
|
179
|
+
question: it respects the threshold and says how far off the repo is, without
|
|
180
|
+
causing anything.
|
|
25
181
|
|
|
26
182
|
## The push path
|
|
27
183
|
|
|
@@ -60,10 +216,10 @@ runs `git init --bare`, downloads every WAL entry above `compaction_frontier` in
|
|
|
60
216
|
seq order, drops each `.pack`/`.idx` pair straight into `objects/pack/`, and
|
|
61
217
|
writes `packed-refs` from `index.json.refs` in one shot.
|
|
62
218
|
|
|
63
|
-
**It is not disaster recovery — it is the normal path.** The
|
|
64
|
-
|
|
65
|
-
next access rebuilds it. The restore path is
|
|
66
|
-
rather than only in a crisis.
|
|
219
|
+
**It is not disaster recovery — it is the normal path.** The container sleeps
|
|
220
|
+
when idle and its disk is wiped completely on every restart, so an idle repo
|
|
221
|
+
loses its cache routinely and the next access rebuilds it. The restore path is
|
|
222
|
+
therefore exercised continuously rather than only in a crisis.
|
|
67
223
|
|
|
68
224
|
`src/sync.ts` decides which of the two repairs an access needs, and a warm disk
|
|
69
225
|
pays for neither:
|
|
@@ -90,25 +246,25 @@ reading as a valid-but-truncated repo.
|
|
|
90
246
|
### What it costs
|
|
91
247
|
|
|
92
248
|
Measured with `bun run bench:materialize` (macOS arm64, `FileStore` on local
|
|
93
|
-
disk, 15 runs per size). Replay only — **
|
|
249
|
+
disk, 15 runs per size). Replay only — **cold start is not in these numbers**.
|
|
94
250
|
Each size is measured twice: over the raw log, and over the same repository
|
|
95
251
|
after compaction.
|
|
96
252
|
|
|
97
253
|
| WAL entries | raw p50 | raw p99 | compacted p50 | entries replayed |
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
|
|
|
101
|
-
|
|
|
102
|
-
|
|
|
254
|
+
| ----------: | ------: | ------: | ------------: | ---------------: |
|
|
255
|
+
| 1 | 36 ms | 41 ms | 36 ms | 1 |
|
|
256
|
+
| 10 | 40 ms | 43 ms | 35 ms | 1 |
|
|
257
|
+
| 50 | 57 ms | 65 ms | 36 ms | 1 |
|
|
258
|
+
| 200 | 125 ms | 134 ms | 36 ms | 1 |
|
|
103
259
|
|
|
104
260
|
The right-hand column is the point: raw restore is linear in push count, and a
|
|
105
261
|
compacted restore at 200 pushes is indistinguishable from one at 20, because it
|
|
106
262
|
replays one entry either way.
|
|
107
263
|
|
|
108
264
|
Deliberately **two numbers, not one**. The design's "cold materialize under two
|
|
109
|
-
seconds" was written for an always-on NVMe node;
|
|
110
|
-
|
|
111
|
-
separately or a regression cannot be attributed to either half.
|
|
265
|
+
seconds" was written for an always-on NVMe node; here a client also pays
|
|
266
|
+
container cold start, measured at a median of 1.77 s (spread 0.93–6.45 s) in the
|
|
267
|
+
Containers spike. Gate them separately or a regression cannot be attributed to either half.
|
|
112
268
|
|
|
113
269
|
The materialize number is a **control loop, not a pass/fail gate**: it is linear
|
|
114
270
|
in entry count, so exceeding the target means the WAL is replaying too many
|
|
@@ -132,7 +288,7 @@ from the index after it, produce byte-identical history.
|
|
|
132
288
|
Three things make it safe:
|
|
133
289
|
|
|
134
290
|
- **A lease, not optimism.** `repos/{id}/compaction.lease` is taken under a
|
|
135
|
-
compare-and-swap and expires, so a
|
|
291
|
+
compare-and-swap and expires, so a container stopped mid-repack cannot wedge
|
|
136
292
|
compaction for that repository forever. Two nodes repacking at once would both
|
|
137
293
|
upload a full copy and the loser's CAS would tombstone entries the winner's
|
|
138
294
|
pack does not contain.
|
|
@@ -172,35 +328,122 @@ is gone, which is a broken repository rather than a recoverable one.
|
|
|
172
328
|
The asymmetry throughout: over-retaining costs storage, under-retaining loses
|
|
173
329
|
data with no error anywhere.
|
|
174
330
|
|
|
331
|
+
## Deleting a repository
|
|
332
|
+
|
|
333
|
+
`src/delete-repo.ts` is the one thing that destroys data on purpose, and it
|
|
334
|
+
inherits the collector's discipline rather than inventing a faster one.
|
|
335
|
+
|
|
336
|
+
It is **deferred**: the first request tombstones the repository by writing a
|
|
337
|
+
`deletion` marker into `index.json`, and only a later call — past
|
|
338
|
+
`WALGIT_DELETE_GRACE_MS` — removes anything. A clone that read the index a
|
|
339
|
+
moment before the request is still downloading the packs it names, and the
|
|
340
|
+
grace period is what stops it being cut off mid-transfer. The knob is its own
|
|
341
|
+
rather than the collector's, because expiry and compaction have unrelated
|
|
342
|
+
timescales.
|
|
343
|
+
|
|
344
|
+
Collection then deletes **`index.json` first** and the objects it names second.
|
|
345
|
+
A crash between the two leaves objects that nothing references — exactly what
|
|
346
|
+
`findOrphans` discovers and `gc` reclaims — instead of an index naming an
|
|
347
|
+
object that is gone. The cached bare repo on disk goes last, because a cache
|
|
348
|
+
left behind is reclaimable and a half-deleted log is not.
|
|
349
|
+
|
|
350
|
+
Deciding _which_ repositories go — expiry — is not this file's business. It
|
|
351
|
+
takes a repo id.
|
|
352
|
+
|
|
353
|
+
## Expiring idle repositories
|
|
354
|
+
|
|
355
|
+
`src/expire.ts` is that decision, and on a free, world-writable instance it is
|
|
356
|
+
the **only** removal path — the reason refs can be append-only without storage
|
|
357
|
+
growing without bound. Nothing inside the window can be destroyed; everything
|
|
358
|
+
leaves at the end of it.
|
|
359
|
+
|
|
360
|
+
Idle means the time of the **last push**, never the last access:
|
|
361
|
+
|
|
362
|
+
- It is free. The newest WAL entry's `ts` is already in `index.json`, so the
|
|
363
|
+
signal costs no write and no instrumentation.
|
|
364
|
+
- It cannot be gamed. A last-access would mean a write on every clone, through
|
|
365
|
+
an endpoint deliberately left unauthenticated — a daily `git clone` from a
|
|
366
|
+
cron job could pin any repository alive forever.
|
|
367
|
+
|
|
368
|
+
The window is `WALGIT_RETENTION_HOURS`, **the same variable `GET /` renders its
|
|
369
|
+
retention promise from**, so the page cannot claim a window the sweeper does not
|
|
370
|
+
enforce. Unset means expiry is off entirely, and `walgit expire` then says so and
|
|
371
|
+
does nothing — not even a `LIST`.
|
|
372
|
+
|
|
373
|
+
`decideExpiry` is pure and every branch it cannot prove resolves toward RETAIN:
|
|
374
|
+
an index with no entries is not "infinitely old", a timestamp that will not parse
|
|
375
|
+
is not "long ago", and one in the future is clock skew rather than staleness.
|
|
376
|
+
Over-retaining costs storage; under-retaining deletes somebody's work with no
|
|
377
|
+
error anywhere.
|
|
378
|
+
|
|
379
|
+
Collection is delegated to `delete-repo.ts`, so an expired repository is
|
|
380
|
+
tombstoned and collected a grace period later exactly like one deleted by hand.
|
|
381
|
+
Dry run is the default; `--yes` acts.
|
|
382
|
+
|
|
383
|
+
What runs it on a timer is the **deployment's** business. On Cloudflare that is
|
|
384
|
+
a Cron Trigger (`wrangler.jsonc` → `triggers.crons`, hourly) firing the Worker's
|
|
385
|
+
`scheduled` handler, which POSTs `/_walgit/expire` to the container and logs the
|
|
386
|
+
report. The timer lives out there rather than as an interval inside the
|
|
387
|
+
container because the container SLEEPS when idle — an internal timer would stop
|
|
388
|
+
firing at exactly the moment nothing is keeping it awake, which is precisely the
|
|
389
|
+
state a repository has to be in to be collectable.
|
|
390
|
+
|
|
391
|
+
That endpoint deletes repositories and the container is world-reachable, so it
|
|
392
|
+
is reachable only by the Worker: the request must carry `x-walgit-internal: 1`,
|
|
393
|
+
and the Worker STRIPS that header from every request it proxies from a client
|
|
394
|
+
before forwarding it. "The Worker asked" is therefore unforgeable from outside,
|
|
395
|
+
with no second credential invented for a service whose whole point is not having
|
|
396
|
+
one. Anything else gets the same 404 as any other unroutable path. An instance
|
|
397
|
+
with no `WALGIT_RETENTION_HOURS` exposes no sweep endpoint at all, so the cron
|
|
398
|
+
logs a 404 and collects nothing — correct for an instance that never promised a
|
|
399
|
+
retention window.
|
|
400
|
+
|
|
175
401
|
## How a client reaches it
|
|
176
402
|
|
|
177
403
|
```bash
|
|
178
|
-
#
|
|
179
|
-
git clone
|
|
180
|
-
|
|
181
|
-
# smart-HTTP — the token is sent as the Basic-auth password
|
|
182
|
-
git clone https://walgit:$WALGIT_TOKEN@<app>.fly.dev/myrepo.git
|
|
404
|
+
# smart-HTTP is the only transport; the token is sent as the Basic-auth password
|
|
405
|
+
git clone https://walgit:$WALGIT_TOKEN@<worker-host>/myrepo.git
|
|
183
406
|
```
|
|
184
407
|
|
|
408
|
+
There is no SSH. It was removed when walgit moved onto a Cloudflare Container:
|
|
409
|
+
SSH needs raw inbound TCP, which is what put the app on a Fly machine with a
|
|
410
|
+
dedicated IPv4 in the first place ([ADR-0006](../../../../../docs/adr/0006-fly-returns-as-a-deploy-module.md)),
|
|
411
|
+
and no Cloudflare product delivers it. Every client that could hold a key can
|
|
412
|
+
hold a token.
|
|
413
|
+
|
|
185
414
|
A repository is created on first contact: pushing to a name nobody has used
|
|
186
415
|
creates it, with `receive.unpackLimit=0` so even a tiny push is retained as a
|
|
187
416
|
packfile (what the WAL will upload).
|
|
188
417
|
|
|
189
418
|
## Deployment
|
|
190
419
|
|
|
191
|
-
Through the `
|
|
192
|
-
|
|
193
|
-
|
|
420
|
+
Through the `cloudflare` module, never by hand — `zbc apply <env>`. The Worker
|
|
421
|
+
(`worker/index.ts`) is a thin proxy in front of a Durable-Object-bound Container
|
|
422
|
+
running this package's Dockerfile; `wrangler deploy` builds the image, so Docker
|
|
423
|
+
must be running at apply time and the account must be on a Workers Paid plan
|
|
424
|
+
with Containers enabled. Set `immediateContainerRollout: true` on the instance —
|
|
425
|
+
wrangler's gradual default never drains a single always-warm container, so a
|
|
426
|
+
redeployed image silently never takes effect until it idle-sleeps.
|
|
427
|
+
|
|
428
|
+
The container reads its configuration from environment variables the **Worker**
|
|
429
|
+
forwards (`CONTAINER_ENV` in `shared/container-env.ts`): `wrangler secret put`
|
|
430
|
+
reaches the Worker and stops there, so a secret that is not in that list never
|
|
431
|
+
arrives.
|
|
432
|
+
|
|
433
|
+
It reads them **once, at container start** — a running process's environment
|
|
434
|
+
cannot be changed, so re-reading `process.env` per request would return the same
|
|
435
|
+
value. `immediateContainerRollout` does not help either: a deploy that changes
|
|
436
|
+
only vars produces no new container image for it to roll. So the Durable Object
|
|
437
|
+
fingerprints the environment it would boot with, keeps that fingerprint in its
|
|
438
|
+
own storage, and destroys the running container the first time the two differ
|
|
439
|
+
(`reconcileEnv`). Changing a forwarded variable therefore costs one container
|
|
440
|
+
restart on the first request after the deploy, and takes effect immediately —
|
|
441
|
+
where previously the Worker picked it up and the container kept the old value
|
|
442
|
+
for as long as traffic kept it awake.
|
|
443
|
+
|
|
444
|
+
Secrets the app needs (in the environment's `secrets.yaml`, wired as the
|
|
445
|
+
cloudflare instance's `workerSecrets`):
|
|
194
446
|
|
|
195
|
-
Secrets the app needs (in the environment's `secrets.yaml`):
|
|
196
|
-
|
|
197
|
-
- `WALGIT_SSH_HOST_KEY` — an ed25519 **private** key
|
|
198
|
-
(`ssh-keygen -t ed25519 -f walgit_host -N ''`). It is a secret rather than a
|
|
199
|
-
generated-at-boot file because the container filesystem does not survive a
|
|
200
|
-
machine stop, and this machine stops whenever it is idle — a regenerated host
|
|
201
|
-
key would trip every client's man-in-the-middle warning.
|
|
202
|
-
- `WALGIT_SSH_AUTHORIZED_KEYS` — newline-separated **public** keys. Each is
|
|
203
|
-
written into `authorized_keys` pinned to the forced command.
|
|
204
447
|
- `WALGIT_HTTP_TOKENS` — comma-separated bearer tokens (comma-separated so a
|
|
205
448
|
credential can be rotated without a window where neither works).
|
|
206
449
|
- `WALGIT_S3_ENDPOINT`, `WALGIT_S3_BUCKET`, `WALGIT_S3_ACCESS_KEY_ID`,
|
|
@@ -209,16 +452,237 @@ Secrets the app needs (in the environment's `secrets.yaml`):
|
|
|
209
452
|
its local cache and **refuses every push**. `WALGIT_STORE_DIR` substitutes a
|
|
210
453
|
local directory for the bucket, which is for development and tests only.
|
|
211
454
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
455
|
+
Optional instance configuration (plain env, not secrets): `WALGIT_APPEND_ONLY`,
|
|
456
|
+
`WALGIT_MAX_PUSH_BYTES`, `WALGIT_MAX_REPO_BYTES`, `WALGIT_RETENTION_HOURS`,
|
|
457
|
+
`WALGIT_PUBLIC`, `WALGIT_SIGNER_LISTS` — each unset means the behaviour is off
|
|
458
|
+
and `GET /` does not claim it. `WALGIT_EVENTS_URL` and `WALGIT_EVENTS_TOKEN` (a
|
|
459
|
+
secret) turn on the ref-event stream below, and `WALGIT_PUSH_CERT_SEED` (a
|
|
460
|
+
secret) turns on signed pushes.
|
|
461
|
+
|
|
462
|
+
For the three boolean flags — `WALGIT_APPEND_ONLY`, `WALGIT_PUBLIC` and
|
|
463
|
+
`WALGIT_SIGNER_LISTS` — **on means `1` or `true`, and nothing else**
|
|
464
|
+
(`flagEnabled`, `shared/policy.ts`). An unrecognised value (`yes`, `on`, `TRUE`)
|
|
465
|
+
reads as off, which for `WALGIT_PUBLIC` means a token-gated host. The others are
|
|
466
|
+
not booleans: the three size and retention limits are read as positive numbers
|
|
467
|
+
and the rest are values in their own right, unset meaning the behaviour is off.
|
|
468
|
+
|
|
469
|
+
All of them are read in one place — `capabilitiesFrom`
|
|
470
|
+
(`shared/capabilities.ts`) — which is what the three agent-facing documents are
|
|
471
|
+
rendered from and what every decision about whether a credential is required
|
|
472
|
+
reads. So `GET /` and `/llms.txt` cannot claim public access the front door does
|
|
473
|
+
not grant, or the reverse.
|
|
474
|
+
|
|
475
|
+
`WALGIT_SIGNER_LISTS=1` lets a repository name the keys allowed to push to it
|
|
476
|
+
(docs/adr/0012 in the zbc repository): a commit on `refs/walgit/signers` whose
|
|
477
|
+
tree holds a `signers` file, one `SHA256:…` fingerprint per line. While a
|
|
478
|
+
repository has one, a push not signed by a listed key is **refused** — and the
|
|
479
|
+
list that judges a push is the one that stood before it, so a push moving the
|
|
480
|
+
list and a branch together installs a list that applies from the next push. A
|
|
481
|
+
repository with no list refuses nothing, which is every repository until someone
|
|
482
|
+
writes one; reads are never gated, and pushing a list that is empty or that
|
|
483
|
+
walgit cannot read is refused on any repository, claimed or not.
|
|
484
|
+
|
|
485
|
+
**Turn it on beside `WALGIT_PUSH_CERT_SEED`, never without it.** The seed is
|
|
486
|
+
what makes `git-receive-pack` advertise certificates at all, so with no seed
|
|
487
|
+
every push to a repository holding a list is refused as unsigned and no client
|
|
488
|
+
can sign its way out — that repository is unpushable until the seed is set.
|
|
489
|
+
Turn the flag on *before* anyone writes a list, too: the copy of the list the
|
|
490
|
+
refusal reads out of `index.json` is maintained only while the flag is on, so a
|
|
491
|
+
list pushed while it was off is not enforced until its ref is pushed again.
|
|
492
|
+
|
|
493
|
+
There is no recovery path for a lost key, and none is planned. List two keys.
|
|
494
|
+
|
|
495
|
+
The container sleeps when idle and the next request wakes it — one regime,
|
|
496
|
+
median 1.77 s, spread 0.93–6.45 s, and a ten-minute idle measures the same. Its
|
|
497
|
+
10.67 GiB disk is **wiped completely on every restart**, which is exactly the
|
|
498
|
+
assumption the cache-and-log design was written against, so there is no volume
|
|
499
|
+
and nothing to mount.
|
|
500
|
+
|
|
501
|
+
Trap worth knowing when tearing one down: `wrangler delete` on the Worker does
|
|
502
|
+
**not** delete its container application. That needs a separate
|
|
503
|
+
`wrangler containers delete`, or the instances stay live.
|
|
504
|
+
|
|
505
|
+
## Append-only refs
|
|
506
|
+
|
|
507
|
+
`WALGIT_APPEND_ONLY=1` makes every repository on the instance append-only: a
|
|
508
|
+
push may create a ref or fast-forward one, and may never delete or rewrite one.
|
|
509
|
+
It is **off by default** — a private instance may want force-push — and it is
|
|
510
|
+
instance configuration, so turning it on covers repositories that already exist.
|
|
511
|
+
|
|
512
|
+
It is enforced twice. `receive.denyNonFastForwards` and `receive.denyDeletes`
|
|
513
|
+
are set on the bare repo as a backstop that no bug in this code can bypass. The
|
|
514
|
+
refusal a client actually reads comes earlier, from `pre-receive`
|
|
515
|
+
(`src/append-only.ts`), and that earliness buys the two things git's own message
|
|
516
|
+
cannot: the wording — `denying non-fast-forward refs/heads/main` tells an agent
|
|
517
|
+
neither what walgit is nor what to do instead — and the object-store write, since
|
|
518
|
+
git refuses only _after_ `pre-receive`, by which point the pack for a doomed push
|
|
519
|
+
has already been uploaded and left for `findOrphans` to reclaim.
|
|
520
|
+
|
|
521
|
+
The check is git's own fast-forward test (`merge-base --is-ancestor`) over the
|
|
522
|
+
objects sitting in the quarantine. Unrelated history fails it, which is the
|
|
523
|
+
intended answer: pushing a fresh repo over an existing name would drop every
|
|
524
|
+
commit the branch holds today. The message names the repository, states the
|
|
525
|
+
rule, and offers a free name (`<repo>-<8 hex>`) to push to instead — a wave of
|
|
526
|
+
agents on near-identical prompts all reach for `test`, and this message is the
|
|
527
|
+
first thing walgit ever says to most of them.
|
|
528
|
+
|
|
529
|
+
## Size limits
|
|
530
|
+
|
|
531
|
+
`WALGIT_MAX_PUSH_BYTES` caps a single push; `WALGIT_MAX_REPO_BYTES` caps what
|
|
532
|
+
one repository holds in total. Both are **unset by default** — an instance opts
|
|
533
|
+
in, and an instance that does not set them enforces nothing and claims nothing.
|
|
534
|
+
`GET /` states each cap it enforces, rendered from the same `Capabilities`
|
|
535
|
+
(`shared/capabilities.ts`) the hook takes its limits from, so the page cannot
|
|
536
|
+
promise a limit the push path does not hold.
|
|
537
|
+
|
|
538
|
+
The refusal happens in `pre-receive` (`src/limits.ts`), where the pack is
|
|
539
|
+
sitting in the quarantine at a known size and nothing has been written to the
|
|
540
|
+
object store. That earliness is the whole feature. `http.postBuffer` defaults to
|
|
541
|
+
1 MiB, so every real push is chunked, and a chunked body is uploaded IN FULL
|
|
542
|
+
before a proxy can answer: measured against Fly, 99 MiB passes and 100 MiB is
|
|
543
|
+
refused only after all 104,879,625 bytes have gone up — 37 s of upload to be
|
|
544
|
+
told `RPC failed; HTTP 413` and `unexpected disconnect`, which reads like a
|
|
545
|
+
dropped network and gets retried. A documented cap must therefore sit under the
|
|
546
|
+
**chunked** cutoff, not the `Content-Length` one (which 413s at 101 MiB after
|
|
547
|
+
~2 MB): ~99 MiB is the safe ceiling for the public instance, with a repository
|
|
548
|
+
total of ~250 MB.
|
|
549
|
+
|
|
550
|
+
The repository total needs no new state. Every WAL entry carries its `size`, so
|
|
551
|
+
the total is a sum over the entries above the compaction frontier — the live
|
|
552
|
+
ones. Superseded entries are excluded on purpose: `gc.ts` deletes them, and
|
|
553
|
+
counting them would charge a repository twice for history it holds once, so a
|
|
554
|
+
repository that compacted itself would appear to have grown.
|
|
555
|
+
|
|
556
|
+
The two refusals say different things, because they are different problems. Too
|
|
557
|
+
big a push is one client sending too much at once and can be split; a full
|
|
558
|
+
repository is many small pushes that were each fine, and splitting will not help
|
|
559
|
+
— that one names a fresh repository instead. Both state the cap and the actual
|
|
560
|
+
size in bytes as well as units, and both say the push was not a network failure,
|
|
561
|
+
because the message they replace is one an agent retries.
|
|
562
|
+
|
|
563
|
+
`receive.maxInputSize` is set as a backstop, at **twice** the cap rather than at
|
|
564
|
+
it. git hands that value to `index-pack`, which fails while the pack is still
|
|
565
|
+
being read — before `pre-receive` runs — so a backstop set to the cap would win
|
|
566
|
+
every race and every client would read `fatal: pack exceeds maximum allowed
|
|
567
|
+
size` instead of walgit's message. At twice the cap the hook owns every refusal
|
|
568
|
+
a real client can provoke, and git still bounds a pack far enough past the cap
|
|
569
|
+
that a bug in the hook is the likelier explanation.
|
|
570
|
+
|
|
571
|
+
## Signed pushes
|
|
572
|
+
|
|
573
|
+
`WALGIT_PUSH_CERT_SEED` makes the host willing to receive `git push
|
|
574
|
+
--signed=yes`. A push certificate is a claim about _who moved this ref_, signed
|
|
575
|
+
by the pusher and carrying a nonce this server issued — and it is a
|
|
576
|
+
`receive-pack` capability, not a transport feature, so it works over smart-HTTP
|
|
577
|
+
with no SSH anywhere ([ADR-0011](../../../../../docs/adr/0011-walgit-records-who-pushed-and-refuses-nothing.md)).
|
|
578
|
+
|
|
579
|
+
git advertises the capability if and only if the receiving repository has
|
|
580
|
+
`receive.certNonceSeed` set, which `ensureBareRepo` writes from that variable on
|
|
581
|
+
every access — so a repository rebuilt from the log inherits it. With no seed
|
|
582
|
+
configured a client asking for `--signed=yes` is refused by its **own** git
|
|
583
|
+
(`fatal: the receiving end does not support --signed push`) before a byte
|
|
584
|
+
reaches the network, which is the right answer for a deployment that has not
|
|
585
|
+
turned this on.
|
|
586
|
+
|
|
587
|
+
The seed is configuration and is never generated: the nonce is derived from it,
|
|
588
|
+
a client holds one across the round trip, and the container's disk is wiped on
|
|
589
|
+
every restart — a seed minted at boot would reject every certificate in flight.
|
|
590
|
+
|
|
591
|
+
`receive.certNonceSlop` is written beside the seed, at **300 seconds**, and it
|
|
592
|
+
is not optional. git derives the nonce from the seed and _the unix second it was
|
|
593
|
+
minted in_, and a push over smart-HTTP is two requests: the advertisement mints
|
|
594
|
+
a nonce, and the push is a second process that minted its own. The two match as
|
|
595
|
+
strings only when both landed inside the same second, so git falls back to
|
|
596
|
+
asking how stale the client's nonce is — against a window that defaults to zero.
|
|
597
|
+
Unset, every round trip that crosses a second boundary reports
|
|
598
|
+
`GIT_PUSH_CERT_NONCE_STATUS=SLOP`, walgit establishes no Signer, and a
|
|
599
|
+
repository held by a Signer List refuses its own owner. The window is also the
|
|
600
|
+
replay window for a captured certificate, which is why it is five minutes and
|
|
601
|
+
not five hours.
|
|
602
|
+
|
|
603
|
+
An unsigned push is unaffected either way — `--signed=if-asked` is therefore safe
|
|
604
|
+
to pass unconditionally, to this host or any other. What walgit does with a
|
|
605
|
+
certificate it can verify is
|
|
606
|
+
[ADR-0011](../../../../../docs/adr/0011-walgit-records-who-pushed-and-refuses-nothing.md)
|
|
607
|
+
(record the Signer, refuse nothing) and
|
|
608
|
+
[ADR-0012](../../../../../docs/adr/0012-a-name-can-refuse-a-stranger.md) (a
|
|
609
|
+
repository holding a Signer List refuses a push it cannot attribute to a listed
|
|
610
|
+
key).
|
|
611
|
+
|
|
612
|
+
## Ref events
|
|
613
|
+
|
|
614
|
+
An agent working in a sandbox cannot be told anything: it has no ingress, no
|
|
615
|
+
stable address and often no listening port, so a webhook has nowhere to go.
|
|
616
|
+
Every agent therefore pays a background tax — _is my local main still current?_
|
|
617
|
+
— one fetch and one slice of context at a time, and almost every answer is
|
|
618
|
+
"nothing changed". The stream inverts the direction: the client dials out once
|
|
619
|
+
and is told.
|
|
620
|
+
|
|
621
|
+
Set both `WALGIT_EVENTS_URL` (this deployment's own public origin) and
|
|
622
|
+
`WALGIT_EVENTS_TOKEN` (a shared secret, in `workerSecrets`) to turn it on. With
|
|
623
|
+
either unset there is no endpoint at all — a subscriber gets the same 404 as for
|
|
624
|
+
any other path that does not exist.
|
|
625
|
+
|
|
626
|
+
```
|
|
627
|
+
# one outbound WebSocket, the same credential a clone needs
|
|
628
|
+
→ {"watch":[{"repo":"my-thing","refs":["refs/heads/main"]}]}
|
|
629
|
+
← {"ok":true,"refs":[{"repo":"my-thing","ref":"refs/heads/main","sha":"9f2c…"}]}
|
|
630
|
+
← {"repo":"my-thing","ref":"refs/heads/main","sha":"0ab7…"}
|
|
631
|
+
← {"repo":"my-thing","ref":"refs/heads/main","sha":null}
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
Omit `refs` to watch every ref in a repository; `sha: null` is a deletion. The
|
|
635
|
+
handshake answers with current state read from `index.json`, so connect and
|
|
636
|
+
catch-up are one operation and there is no window between them in which a push
|
|
637
|
+
is missed by both.
|
|
638
|
+
|
|
639
|
+
Events are **latest state, not a log**: no cursor, no `since`, no sequence
|
|
640
|
+
number anywhere on the wire. A reconnecting subscriber gets current state, which
|
|
641
|
+
is the only answer a client asking "is my main current?" can act on — replay
|
|
642
|
+
would be a second source of truth beside the Index.
|
|
643
|
+
|
|
644
|
+
The push path announces from `post-receive` (`src/announce.ts`), which git runs
|
|
645
|
+
only once the ref transaction committed — that is, only once the
|
|
646
|
+
compare-and-swap on `index.json` won. A push that lost it is rejected and never
|
|
647
|
+
reaches that hook, so nobody is ever told about a push that then lost. The
|
|
648
|
+
announcement is authenticated with `WALGIT_EVENTS_TOKEN`, bounded to two
|
|
649
|
+
seconds, and every failure is logged and swallowed: a notification outage must
|
|
650
|
+
never be the reason a push fails.
|
|
651
|
+
|
|
652
|
+
Subscribing takes exactly the credential a read takes — an event is a strict
|
|
653
|
+
subset of what a clone hands over — so a public deployment has a public stream.
|
|
654
|
+
Sockets are held by a Durable Object using the hibernation API, so watching a
|
|
655
|
+
quiet repository costs storage rather than duration.
|
|
656
|
+
|
|
657
|
+
A socket gets **at most one message per repository-and-ref per 250 ms**. The
|
|
658
|
+
first move of a ref goes out the moment it lands; a second inside that window
|
|
659
|
+
replaces the one already queued rather than joining it, so a branch pushed to
|
|
660
|
+
five times in a second is five pushes and one or two messages, each carrying the
|
|
661
|
+
sha at the time it was sent. Nothing here observes the reader — the Workers
|
|
662
|
+
runtime gives a Worker no way to see a socket's backlog — so the bound is the
|
|
663
|
+
rate, which is sound only because events are latest state: the sha you receive
|
|
664
|
+
when the window elapses is the one you would have converged to anyway. The cost
|
|
665
|
+
is that a push can reach a subscriber up to half a second late when its ref is
|
|
666
|
+
already moving.
|
|
215
667
|
|
|
216
668
|
## Authorization, today
|
|
217
669
|
|
|
218
|
-
One trust boundary: any
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
670
|
+
One trust boundary: any HTTP token can read and write any repository. Per-repo
|
|
671
|
+
authorization is deferred until the repo namespace exists in the WAL — the
|
|
672
|
+
`tokens` list is the seam it plugs into.
|
|
673
|
+
|
|
674
|
+
`WALGIT_PUBLIC` removes that boundary entirely: reads, writes and ref-event
|
|
675
|
+
subscriptions all serve anyone, with no credential. It is an **explicit opt-in
|
|
676
|
+
and not the absence of tokens** — with neither configured the container refuses
|
|
677
|
+
to boot, so a deployment that loses its secrets fails closed instead of opening
|
|
678
|
+
to the world.
|
|
679
|
+
|
|
680
|
+
Three places decide whether a credential is needed — the container's git auth
|
|
681
|
+
(`src/http.ts`), the edge's socket auth (`worker/index.ts`) and the boot refusal
|
|
682
|
+
— and all three read `caps.publicAccess`. They used to read the variable
|
|
683
|
+
themselves, two of them accepting only `1` while `/llms.txt` accepted `true` as
|
|
684
|
+
well, so a host spelling it `true` told an agent no credential was needed and
|
|
685
|
+
then answered 401 to every clone.
|
|
222
686
|
|
|
223
687
|
## Tests
|
|
224
688
|
|
|
@@ -226,9 +690,8 @@ seams they plug into.
|
|
|
226
690
|
bun test src
|
|
227
691
|
```
|
|
228
692
|
|
|
229
|
-
Includes end-to-end clone/push/fetch
|
|
230
|
-
client
|
|
231
|
-
with a stand-in for `ssh` itself — a cold-materialize suite that builds a repo
|
|
693
|
+
Includes end-to-end clone/push/fetch through a real server against a real `git`
|
|
694
|
+
client, a cold-materialize suite that builds a repo
|
|
232
695
|
with 100 pushes across 5 branches and 3 tags, deletes its disk, and asserts the
|
|
233
696
|
rebuilt repo matches a reference clone on refs, reachable history and `git
|
|
234
697
|
fsck`, a compaction suite that repacks a 40-push log and asserts history is
|