@zabaca/zbc 0.20.0 → 0.21.1
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/package.json +1 -1
- package/templates/apps/walgit/CONTEXT.md +37 -0
- package/templates/apps/walgit/README.md +193 -4
- package/templates/apps/walgit/e2e/harness.ts +2 -2
- package/templates/apps/walgit/e2e/scenarios.ts +302 -2
- package/templates/apps/walgit/package.json +5 -1
- package/templates/apps/walgit/registry.json +1 -1
- package/templates/apps/walgit/shared/browse.ts +733 -0
- package/templates/apps/walgit/shared/capabilities.ts +17 -0
- package/templates/apps/walgit/shared/container-env.ts +9 -0
- package/templates/apps/walgit/shared/landing.ts +8 -27
- package/templates/apps/walgit/shared/llms.ts +41 -0
- package/templates/apps/walgit/shared/mcp.ts +286 -0
- package/templates/apps/walgit/shared/policy.ts +21 -0
- package/templates/apps/walgit/shared/pooled.ts +31 -0
- package/templates/apps/walgit/shared/protocol.ts +140 -0
- package/templates/apps/walgit/shared/repo-list.ts +478 -0
- package/templates/apps/walgit/shared/store.ts +307 -0
- package/templates/apps/walgit/shared/telemetry.ts +79 -6
- package/templates/apps/walgit/shared/wal-index.ts +249 -0
- package/templates/apps/walgit/shared/web.ts +46 -0
- package/templates/apps/walgit/src/announce-main.ts +1 -1
- package/templates/apps/walgit/src/announce.ts +1 -1
- package/templates/apps/walgit/src/append-only.ts +5 -8
- package/templates/apps/walgit/src/browse.ts +230 -0
- package/templates/apps/walgit/src/cache.ts +4 -4
- package/templates/apps/walgit/src/compact.ts +6 -12
- package/templates/apps/walgit/src/delete-repo.ts +4 -3
- package/templates/apps/walgit/src/expire.ts +3 -3
- package/templates/apps/walgit/src/gc.ts +4 -3
- package/templates/apps/walgit/src/git.ts +127 -10
- package/templates/apps/walgit/src/hook-main.ts +1 -1
- package/templates/apps/walgit/src/http.ts +386 -3
- package/templates/apps/walgit/src/limits.ts +1 -1
- package/templates/apps/walgit/src/materialize.bench.ts +4 -10
- package/templates/apps/walgit/src/materialize.ts +11 -4
- package/templates/apps/walgit/src/orphans.ts +3 -3
- package/templates/apps/walgit/src/pending.ts +1 -1
- package/templates/apps/walgit/src/private.ts +1 -1
- package/templates/apps/walgit/src/proposals.ts +3 -3
- package/templates/apps/walgit/src/push-cert.ts +10 -1
- package/templates/apps/walgit/src/push.ts +11 -9
- package/templates/apps/walgit/src/reconcile.ts +4 -3
- package/templates/apps/walgit/src/server.ts +29 -2
- package/templates/apps/walgit/src/signers.ts +9 -3
- package/templates/apps/walgit/src/store-env.ts +8 -21
- package/templates/apps/walgit/src/store.ts +12 -241
- package/templates/apps/walgit/src/sync.ts +2 -2
- package/templates/apps/walgit/src/usage.ts +4 -18
- package/templates/apps/walgit/src/verify.ts +2 -2
- package/templates/apps/walgit/src/wal-index.ts +20 -239
- package/templates/apps/walgit/worker/index.ts +278 -1
- package/templates/apps/walgit/worker/mcp.ts +281 -0
- /package/templates/apps/walgit/{src → shared}/keys.ts +0 -0
- /package/templates/apps/walgit/{src → shared}/ulid.ts +0 -0
package/package.json
CHANGED
|
@@ -64,6 +64,31 @@ against a ref-less repository with a `packfile` section where the client demands
|
|
|
64
64
|
first push to a name printed `fatal:` before succeeding — which an agent reads as a refusal. Pushing
|
|
65
65
|
(`git-receive-pack`) is untouched, and the moment a repository holds one ref this path is never taken again.
|
|
66
66
|
|
|
67
|
+
## The web view
|
|
68
|
+
|
|
69
|
+
**Browse**:
|
|
70
|
+
Reading a repository in a browser: the list at `/repos`, and under it `/<name>` and `/<name>/tree/<ref>/<path>` (a directory), `/<name>/blob/<ref>/<path>` (a file), `/<name>/raw/<ref>/<path>` (its bytes) and `/<name>/commits/<ref>` (the history). One Advertised capability (`WALGIT_WEB`, `caps.web`), default off like every other. The list is a fold over Indexes and is answered at the **edge**, off the log, so it never wakes the container; a repository page needs git objects, which only the **Cache** holds, so it is answered by the container at `/_walgit/browse` and rendered at the edge. A Browse is a **read**: it never creates a name, and it is behind exactly the gate a clone is behind — the deployment credential, then the **Read Challenge** on a **Private** name.
|
|
71
|
+
_Avoid_: the UI, the website, the dashboard (it shows what the log holds; it operates nothing)
|
|
72
|
+
|
|
73
|
+
**Browse Ref**:
|
|
74
|
+
What a browse URL is allowed to name: an entry in `index.refs` — with `refs/heads/` or `refs/tags/` allowed to be left off — or a full forty-character oid. Never a `HEAD`, an abbreviation or a rev-parse expression: whatever is accepted reaches `git ls-tree`, `cat-file` or `git log` as an operand, and the **Index** rather than the **Cache** is what decides, because the disk is a cache. A branch name may contain slashes, so the URL remainder after the page kind is split by **longest ref prefix** — `feature/x/src` is the branch `feature/x` and the directory `src`. The same split serves all four kinds.
|
|
75
|
+
|
|
76
|
+
**Blob Cap**:
|
|
77
|
+
How much of a file a **Browse** will put on a page: 1 MiB (`BLOB_MAX_BYTES`, `shared/browse.ts`). Asked of git's object header BEFORE the content is read, so a file above it never reaches the container's memory — a bound on work, not on bytes shipped. Above the cap the page offers only the **Raw** link, and a file holding a NUL byte is reported binary and shown the same way: walgit has no text to show and will not invent one.
|
|
78
|
+
_Avoid_: max file size (it is a rendering rule, not a storage limit — `WALGIT_MAX_REPO_BYTES` is that)
|
|
79
|
+
|
|
80
|
+
**Raw**:
|
|
81
|
+
A blob's bytes, served as themselves at `/<name>/raw/<ref>/<path>`. Uncapped, because it is the answer FOR a file too large to render, and **typed by its content and never by its name**: text is `text/plain; charset=utf-8` with `nosniff`, anything else is an `application/octet-stream` attachment. That rule is the web view's load-bearing one — a repository holds whatever was pushed to it and walgit serves it from the same origin as every other walgit page, so a pushed `index.html` returned as HTML would be stored XSS against the deployment.
|
|
82
|
+
|
|
83
|
+
**History Cursor**:
|
|
84
|
+
How a reader pages through `op=log`: `?before=<full oid>`, fifty commits a page. The cursor is the LAST commit the previous page SHOWED rather than the first it did not, so a page is built only out of commits a reader has been handed — inclusive to git, exclusive to the reader, reconciled by dropping it (`src/browse.ts`). Anything but a full oid is `400` and never resolved against the **Cache**: unlike a **Browse Ref** or a path it is not a thing that might have existed.
|
|
85
|
+
|
|
86
|
+
**README** (walgit sense):
|
|
87
|
+
The first of `README`, `README.md`, `README.txt` at a tree ROOT, case-insensitively and in that order, carried with the listing and shown as escaped text under it. Never rendered: there is no markdown renderer here and no sanitiser walgit owns, and turning bytes somebody pushed into markup on walgit's own origin is the one thing the web view must not do.
|
|
88
|
+
|
|
89
|
+
**Default Branch** (walgit sense):
|
|
90
|
+
`main`, else `master`, else the first branch by name — computed from the **Index** and never from the Cache's `HEAD`, which on a node that has just **Materialized** is whatever `git init` left behind. A repository holding only tags has none, and that is `null` rather than a tag standing in for one.
|
|
91
|
+
|
|
67
92
|
## Ref events (ADR-0009)
|
|
68
93
|
|
|
69
94
|
**Ref Event**:
|
|
@@ -197,3 +222,15 @@ not exist at all on a deployment that does not offer Proposals. *Superseded* is
|
|
|
197
222
|
deliberately not reported: ADR-0018 admits it only if the same walk yields it
|
|
198
223
|
free, and it does not.
|
|
199
224
|
_Avoid_: list endpoint, PR list, the proposals API
|
|
225
|
+
|
|
226
|
+
## The MCP endpoint
|
|
227
|
+
|
|
228
|
+
**MCP Endpoint**:
|
|
229
|
+
`/_walgit/mcp` — a Model Context Protocol server over Streamable HTTP, answered at the edge on every deployment (`shared/mcp.ts`, transported by `worker/mcp.ts`). The rule that decides what belongs on it: **it carries only what the host can answer without the agent's disk** — `agentgit_status` (a name's existence, its Claim, its Reader List, its refs), `agentgit_watch` (block until a ref moves), `agentgit_provenance` (who signed the push that moved one), and the manual as the resource `agentgit://manual`. Accepting a Proposal, writing a credential helper and fetching into a clone act on a tree the host cannot see, so they stay client commands.
|
|
230
|
+
_Avoid_: "the API" — it is one more way to ask the questions the existing routes answer, not a second surface with its own answers.
|
|
231
|
+
|
|
232
|
+
**The gate is not copied**:
|
|
233
|
+
The MCP reads reach the host's own gated routes rather than re-deciding anything: `agentgit_status` and `agentgit_provenance` go through `PROVENANCE_PATH` (the deployment credential, then the Read Challenge on a Private name), and `agentgit_watch` subscribes to the **Fan-out** the way a **Watch** client does. A refusal is forwarded verbatim and is the *whole* answer — a Private name an unproven reader asked about leaks no refs, no existence and no lists alongside its 401, which is the property `info/refs` has.
|
|
234
|
+
|
|
235
|
+
**The watch cap**:
|
|
236
|
+
`agentgit_watch` holds a Worker request open, so the five-minute deadline is the **host's** and not the caller's: a longer `timeoutMs` is clamped, not honoured. Reaching it answers `{ timedOut: true }` — an answer, never an error — and calling again loses nothing, because a **Ref Event** is latest state and the next call is current state rather than a replay (ADR-0009).
|
|
@@ -32,12 +32,15 @@ by layer:
|
|
|
32
32
|
| `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 |
|
|
33
33
|
| `shared/telemetry.ts` | classifying a request and a refusal into the datapoint the Worker writes |
|
|
34
34
|
| `shared/landing.ts` | the HTML page a browser gets at `/`, rendered from the limits actually configured |
|
|
35
|
+
| `shared/repo-list.ts`, `shared/browse.ts` | the web view: the list at `/repos` off the log, and the repository pages over the container's browse endpoint |
|
|
36
|
+
| `src/browse.ts` | one level of a tree, read off the Cache with `ls-tree` — the one browse answer the log cannot give |
|
|
35
37
|
| `shared/container-env.ts` | which of the Worker's variables the container is told about, and a fingerprint of them |
|
|
36
38
|
| `worker/index.ts`, `wrangler.jsonc` | the Cloudflare Worker that proxies to the container, and forwards its environment |
|
|
37
39
|
| `shared/ref-cache.ts` | the fan-out's derived, in-memory copy of ref state — bounded, never authoritative |
|
|
38
40
|
| `worker/events-do.ts` | the Durable Object that holds the ref-event sockets — a shell over `shared/events.ts` |
|
|
39
|
-
| `
|
|
40
|
-
| `
|
|
41
|
+
| `shared/store.ts`, `shared/wal-index.ts` | the object-store adapter (`MemoryStore`, `S3Store`) and the `index.json` types and reader — both halves read the log |
|
|
42
|
+
| `shared/keys.ts`, `shared/ulid.ts` | the object-store key namespace: every prefix, every key builder, the parse back out of one, and the ULID a WAL key carries |
|
|
43
|
+
| `src/store.ts`, `src/wal-index.ts` | the container's half: `FileStore` on local disk, and the `index.json` compare-and-swap that publishes a push |
|
|
41
44
|
| `src/repo.ts` | repo addressing — the one place a client-supplied name becomes a path. Pure: string in, path out |
|
|
42
45
|
| `src/cache.ts` | provisioning the bare repo that path names: `git init`, the config walgit needs, the hooks |
|
|
43
46
|
| `src/http.ts`, `src/git-backend.ts`, `src/server.ts` | smart-HTTP, with `git http-backend` as a CGI child |
|
|
@@ -94,7 +97,7 @@ a write fails between them.
|
|
|
94
97
|
|
|
95
98
|
Each datapoint carries, as blobs: `kind` (`clone-advertise`, `clone`,
|
|
96
99
|
`push-advertise`, `push`, `instructions`, `landing`, `og-image`, `favicon`,
|
|
97
|
-
`provenance`, `health`, `other`), `outcome`
|
|
100
|
+
`list`, `provenance`, `health`, `other`), `outcome`
|
|
98
101
|
(`ok`/`reject`), `reject`, `repo`, `temperature` (`cold`/`warm`), `answered`
|
|
99
102
|
(`container`/`edge`), `bucket`; and as doubles: `status`, `ttfb_ms`, `total_ms`,
|
|
100
103
|
`bytes_served`, `bytes_received`, `cold`. The index is `kind`, so refusals — the
|
|
@@ -434,6 +437,191 @@ A repository is created on first contact: pushing to a name nobody has used
|
|
|
434
437
|
creates it, with `receive.unpackLimit=0` so even a tiny push is retained as a
|
|
435
438
|
packfile (what the WAL will upload).
|
|
436
439
|
|
|
440
|
+
### The MCP endpoint
|
|
441
|
+
|
|
442
|
+
`/_walgit/mcp` is a Model Context Protocol server over Streamable HTTP
|
|
443
|
+
(`shared/mcp.ts` builds it, `worker/mcp.ts` transports it), answered at the edge
|
|
444
|
+
on every deployment. An MCP client reaches it by URL — nothing to install,
|
|
445
|
+
nothing to spawn:
|
|
446
|
+
|
|
447
|
+
```bash
|
|
448
|
+
claude mcp add --transport http agentgit https://<worker-host>/_walgit/mcp
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
It carries only what the host can answer **without the agent's disk**:
|
|
452
|
+
|
|
453
|
+
| tool | what it answers |
|
|
454
|
+
| --- | --- |
|
|
455
|
+
| `agentgit_status` | does a name exist, is it claimed, is it private, and its refs |
|
|
456
|
+
| `agentgit_watch` | blocks until a ref moves; `{ ref, sha }` or `{ timedOut: true }`, capped at five minutes per call |
|
|
457
|
+
| `agentgit_provenance` | which key signed the push that moved a ref |
|
|
458
|
+
|
|
459
|
+
plus `agentgit://manual` as a resource — the same `renderLlms` output `/llms.txt`
|
|
460
|
+
serves, from the same capabilities.
|
|
461
|
+
|
|
462
|
+
The gate is the host's own and never a second copy: `status` and `provenance`
|
|
463
|
+
both go through the container's `PROVENANCE_PATH`, which already sits behind
|
|
464
|
+
exactly the credential a clone needs and already applies the Read Challenge for
|
|
465
|
+
a Private name, so an unproven reader is refused there and the refusal is
|
|
466
|
+
forwarded verbatim. `watch` subscribes to the ref-event Durable Object exactly
|
|
467
|
+
as a WebSocket client does, so the Reader List is judged by the same code that
|
|
468
|
+
judges a subscription — and it needs the event stream configured, saying so
|
|
469
|
+
where it is not.
|
|
470
|
+
|
|
471
|
+
Which means `status` and `provenance` **do** wake the container, and `status`
|
|
472
|
+
twice (the gated provenance read, then `REFS_PATH`). Refs are authoritative in
|
|
473
|
+
the Index, the Index is reachable only with the container's object-store
|
|
474
|
+
credentials, and the gate is the container's — an edge answer would need a
|
|
475
|
+
second verifier and a second reader, which is what
|
|
476
|
+
[ADR-0013](../../../../../docs/adr/0013-a-name-can-refuse-a-stranger-reading.md)
|
|
477
|
+
and [ADR-0007](../../../../../docs/adr/0007-walgit-object-storage-holds-the-log.md)
|
|
478
|
+
each refuse. The protocol itself, `agentgit_watch` and the manual are answered
|
|
479
|
+
at the edge and touch it not at all.
|
|
480
|
+
|
|
481
|
+
## The web view
|
|
482
|
+
|
|
483
|
+
`WALGIT_WEB=1` turns on a browse of what this deployment holds, and nothing is
|
|
484
|
+
served under it while the variable is unset — the path falls through to the
|
|
485
|
+
container, which does not route it, exactly as before the route existed. It is
|
|
486
|
+
an [Advertised capability](./CONTEXT.md) like every other: one field
|
|
487
|
+
(`caps.web`, `shared/capabilities.ts`), read once, and the route, the landing
|
|
488
|
+
page's footer link and `/llms.txt`'s section all come from it, so they cannot
|
|
489
|
+
describe three different deployments. The plain-text `GET /` says nothing about
|
|
490
|
+
it — that document is read by a model mid-task and is three bytes from its byte
|
|
491
|
+
budget.
|
|
492
|
+
|
|
493
|
+
`GET /repos` (`shared/repo-list.ts`) is answered **at the edge**, off the log:
|
|
494
|
+
one delimited LIST names every repository, then `index.json` is read per
|
|
495
|
+
repository with sixteen in flight, so a browse never wakes the container. A
|
|
496
|
+
browser (`Accept: text/html`) gets a page — one inline stylesheet, one inline
|
|
497
|
+
script whose whole job is a client-side name filter, a CSP that permits nothing
|
|
498
|
+
else, and `noindex` in both a header and the document — and anything else gets
|
|
499
|
+
JSON. Rows are last push descending, a hundred per page (`?page=2`), and carry
|
|
500
|
+
the name, last push, ref count, live bytes, whether the name is claimed, whether
|
|
501
|
+
it is Private and whether it is being removed. Past a thousand names the view
|
|
502
|
+
stops claiming recency: the order stays the store's (name order), only the
|
|
503
|
+
requested page's Indexes are read, and the page says so. An `index.json` that
|
|
504
|
+
cannot be read renders as the bare name with no facts — **no name the log holds
|
|
505
|
+
is ever omitted**, because a missing row is the one failure a reader cannot
|
|
506
|
+
detect.
|
|
507
|
+
|
|
508
|
+
With the capability on and no object store configured there is no log to list,
|
|
509
|
+
so the route answers `503` at the edge rather than proxying: falling through
|
|
510
|
+
would wake the container for a path it does not route, and a 404 would say the
|
|
511
|
+
view does not exist when what is missing is the bucket.
|
|
512
|
+
|
|
513
|
+
The gate is the host's own and never a second copy: `authorizedBy`
|
|
514
|
+
(`shared/credentials.ts`), the same function the event socket uses and the same
|
|
515
|
+
credential a clone presents, answered before the bucket is touched. On a
|
|
516
|
+
credentialed deployment a request with no credential is `401` with
|
|
517
|
+
`www-authenticate: Basic realm="walgit"`, so a browser prompts. `cache-control`
|
|
518
|
+
is `public, max-age=60` only where reads take no credential, `private, no-store`
|
|
519
|
+
otherwise, and `no-store` on every 401. A per-repository Reader List is *not*
|
|
520
|
+
this route's gate — read gating requires `WALGIT_PUBLIC`
|
|
521
|
+
([ADR-0013](../../../../../docs/adr/0013-a-name-can-refuse-a-stranger-reading.md)),
|
|
522
|
+
so on a public deployment a Private name is listed and marked Private while its
|
|
523
|
+
contents stay refused where they always were.
|
|
524
|
+
|
|
525
|
+
### A repository page
|
|
526
|
+
|
|
527
|
+
`/<name>` is the default branch's tree with the repository's refs, and
|
|
528
|
+
`/<name>/tree/<ref>/<path>` is any directory at any ref. Unlike the list these
|
|
529
|
+
cannot be answered off the log — a tree is git objects and the Index holds none
|
|
530
|
+
— so the edge asks the container's `GET /_walgit/browse?repo=&op=refs|tree&ref=`
|
|
531
|
+
and renders what comes back (`shared/browse.ts`). One round trip per page:
|
|
532
|
+
`op=tree` carries the ref list with it.
|
|
533
|
+
|
|
534
|
+
The container answers it **beside the Provenance Read and gated identically**:
|
|
535
|
+
the deployment credential, then the Read Challenge on a Private name
|
|
536
|
+
([ADR-0013](../../../../../docs/adr/0013-a-name-can-refuse-a-stranger-reading.md)),
|
|
537
|
+
so a browse gate is never a second authorization model. The Private gate is
|
|
538
|
+
asked *before* the Index, or the 404 a missing name produces would be an oracle
|
|
539
|
+
for which Private names a deployment holds; an Index that cannot be read is
|
|
540
|
+
treated as locked, exactly as a clone's is.
|
|
541
|
+
|
|
542
|
+
Four rules make the read safe and the answer honest:
|
|
543
|
+
|
|
544
|
+
- **A browse never creates a repository.** The Index is loaded first and a name
|
|
545
|
+
the log has no Index for is `404` — only then `ensureRepo` and `syncRepo`, so
|
|
546
|
+
the Cache is reconciled against the Index exactly as a clone's is and a cold
|
|
547
|
+
repository Materializes while the request waits.
|
|
548
|
+
- **A ref is an Index key or a full oid, and nothing else.** `refs/heads/` and
|
|
549
|
+
`refs/tags/` may be left off; `HEAD`, an abbreviated oid and `main^{}` are
|
|
550
|
+
not refs. A branch name may contain slashes, so the URL remainder after
|
|
551
|
+
`/tree/` is split by **longest ref prefix** against the Index — `feature/x`
|
|
552
|
+
resolves, and the segments after it are the path.
|
|
553
|
+
- **A path rejects `..` and a leading `-`.** Defence in depth beside
|
|
554
|
+
`src/git.ts`'s own fences, which is what actually keeps an untrusted segment
|
|
555
|
+
from becoming a git option.
|
|
556
|
+
- **The default branch is `main`, else `master`, else the first branch by
|
|
557
|
+
name** — computed from the Index and never from the Cache's `HEAD`, which is
|
|
558
|
+
whatever `init` left on a node that has just Materialized.
|
|
559
|
+
|
|
560
|
+
`ls-tree` is one level and never recursive: clicking into a directory is another
|
|
561
|
+
request, which is what pagination looks like when the tree is the index.
|
|
562
|
+
Symlinks render their target, gitlinks as `submodule @ <sha>`, and
|
|
563
|
+
`refs/walgit/*` is listed and browsable. The page carries the same `noindex` and
|
|
564
|
+
cache-control rules as the list and a CSP that permits no script at all — there
|
|
565
|
+
is none on it — and states `expires in N hours` from the Index where the
|
|
566
|
+
deployment sets a retention window. A **README** at the tree root rides with the
|
|
567
|
+
listing: the first of `README`, `README.md`, `README.txt` (case-insensitive, in
|
|
568
|
+
that order), shown as escaped text under the tree. There is no markdown renderer
|
|
569
|
+
and no sanitiser walgit owns, and pushed markup becoming markup on walgit's own
|
|
570
|
+
origin is precisely what this view must never do.
|
|
571
|
+
|
|
572
|
+
### A file, its bytes, and the history
|
|
573
|
+
|
|
574
|
+
`/<name>/blob/<ref>/<path>` is one file, `/<name>/raw/<ref>/<path>` is its bytes
|
|
575
|
+
and `/<name>/commits/<ref>` is the history — the same run-together remainder, the
|
|
576
|
+
same longest-prefix split, the same gate.
|
|
577
|
+
|
|
578
|
+
- **Blob** (`op=blob`). The size is asked of git's object header **before** the
|
|
579
|
+
content is read, so a file over **1 MiB** never reaches the container's
|
|
580
|
+
memory; the page then offers only the raw link. Under the cap the bytes are
|
|
581
|
+
read and sniffed: a **NUL byte** anywhere in them means binary, which shows a
|
|
582
|
+
size and a raw link rather than a guess at text. Otherwise the file is one
|
|
583
|
+
escaped, line-numbered row per line.
|
|
584
|
+
- **Raw** (`op=raw`). No cap — a download is what a file too big to render is
|
|
585
|
+
for — and **the type comes from the content, never from the extension**. Text
|
|
586
|
+
is `text/plain; charset=utf-8` with `X-Content-Type-Options: nosniff`;
|
|
587
|
+
anything else is `application/octet-stream` as an `attachment`. This is the
|
|
588
|
+
one rule the whole web view rests on: a repository holds whatever was pushed
|
|
589
|
+
to it, walgit serves it from the same origin as every other walgit page, and a
|
|
590
|
+
pushed `index.html` returned as HTML would be stored XSS against the
|
|
591
|
+
deployment. It is `text/plain`.
|
|
592
|
+
- **Commit log** (`op=log`). `git log -n 50` per page, with `?before=<full oid>`
|
|
593
|
+
as the cursor — the last commit the previous page *showed*, so a page is built
|
|
594
|
+
only from commits a reader has been given, and the container drops it from the
|
|
595
|
+
next page rather than repeating a row. A cursor that is not a full oid is
|
|
596
|
+
`400` (`invalid`), before git is asked anything: unlike a ref or a path it is
|
|
597
|
+
not a thing that might have existed.
|
|
598
|
+
|
|
599
|
+
Both bounds — one tree level, fifty commits — are bounds on work done on the
|
|
600
|
+
request path in the one container that is also serving pushes. A reader who
|
|
601
|
+
wants the whole history clones it, which is what walgit is.
|
|
602
|
+
|
|
603
|
+
`WALGIT_WEB` is on `CONTAINER_ENV`, which is what makes the browse endpoint
|
|
604
|
+
above possible at all: `caps.web` is read on both sides — at the edge to claim
|
|
605
|
+
the routes, in the container to decide whether `/_walgit/browse` exists — and a
|
|
606
|
+
capability the container was never told about would be one only the edge could
|
|
607
|
+
enforce. The cost is
|
|
608
|
+
the one that list buys everywhere else: **the deploy that first sets it changes
|
|
609
|
+
the environment fingerprint, so the Durable Object replaces the running
|
|
610
|
+
container once** on the next request (`reconcileEnv`, above).
|
|
611
|
+
|
|
612
|
+
What a browse COSTS, stated plainly: the list at `/repos` wakes nothing, and
|
|
613
|
+
every other page wakes the container exactly as a clone does — a tree, a file
|
|
614
|
+
and a log are git objects, only the Cache holds those, and a cold repository
|
|
615
|
+
Materializes first. A deployment running one always-warm instance serves browses
|
|
616
|
+
out of the same queue as pushes.
|
|
617
|
+
|
|
618
|
+
`/robots.txt`, `/favicon.ico`, `/llms.txt` and `/agentgit-og.png` are
|
|
619
|
+
short-circuited at the edge ahead of this route and of the repository pages that
|
|
620
|
+
will sit under it. The collision argument the other edge paths carry holds here
|
|
621
|
+
too and is worth stating in the other direction: a repository named `repos`,
|
|
622
|
+
`robots.txt` or `favicon.ico` keeps its clone URL — `/<name>.git/…` — and loses
|
|
623
|
+
only its bare browse URL.
|
|
624
|
+
|
|
437
625
|
## Deployment
|
|
438
626
|
|
|
439
627
|
Through the `cloudflare` module, never by hand — `zbc apply <env>`. The Worker
|
|
@@ -476,7 +664,8 @@ Optional instance configuration (plain env, not secrets): `WALGIT_APPEND_ONLY`,
|
|
|
476
664
|
`WALGIT_MAX_NEW_REPOS_PER_SOURCE`, `WALGIT_MAX_PUSHES_PER_SOURCE`,
|
|
477
665
|
`WALGIT_MAX_PUSH_BYTES_PER_SOURCE`, `WALGIT_RATE_WINDOW_SECONDS`,
|
|
478
666
|
`WALGIT_RETENTION_HOURS`,
|
|
479
|
-
`WALGIT_PUBLIC`, `WALGIT_SIGNER_LISTS`
|
|
667
|
+
`WALGIT_PUBLIC`, `WALGIT_SIGNER_LISTS`, `WALGIT_WEB` (the web view above) —
|
|
668
|
+
each unset means the behaviour is off
|
|
480
669
|
and `GET /` does not claim it. `WALGIT_EVENTS_URL` and `WALGIT_EVENTS_TOKEN` (a
|
|
481
670
|
secret) turn on the ref-event stream below, `WALGIT_PUSH_CERT_SEED` (a secret)
|
|
482
671
|
turns on signed pushes, and `WALGIT_PRIVATE_REPOS` (a secret) turns on read
|
|
@@ -18,9 +18,9 @@ import * as net from 'node:net'
|
|
|
18
18
|
import * as os from 'node:os'
|
|
19
19
|
import * as path from 'node:path'
|
|
20
20
|
|
|
21
|
-
import type { ObjectStore } from '../
|
|
21
|
+
import type { ObjectStore } from '../shared/store'
|
|
22
22
|
import { storeFromEnv } from '../src/store-env'
|
|
23
|
-
import { ulid } from '../
|
|
23
|
+
import { ulid } from '../shared/ulid'
|
|
24
24
|
import {
|
|
25
25
|
type Handshake,
|
|
26
26
|
type RefEvent,
|
|
@@ -20,9 +20,19 @@ import { compact } from '../src/compact'
|
|
|
20
20
|
import { collectGarbage } from '../src/gc'
|
|
21
21
|
import { materialize } from '../src/materialize'
|
|
22
22
|
import { resolveRepo } from '../src/repo'
|
|
23
|
-
import { loadIndex, type Provenance, type WalIndex } from '../
|
|
23
|
+
import { loadIndex, type Provenance, type WalIndex } from '../shared/wal-index'
|
|
24
24
|
import { fingerprintIn } from '../shared/provenance'
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
BROWSE_PATH,
|
|
27
|
+
CHALLENGE_PATH,
|
|
28
|
+
PROVENANCE_PATH,
|
|
29
|
+
REJECT_HEADER,
|
|
30
|
+
SERVED_HEADER,
|
|
31
|
+
SIGNERS_REF,
|
|
32
|
+
wantsBrowse,
|
|
33
|
+
} from '../shared/protocol'
|
|
34
|
+
import { browseResponse, type BrowseTreeAnswer } from '../shared/browse'
|
|
35
|
+
import { capabilitiesFrom } from '../shared/capabilities'
|
|
26
36
|
import { LATENCY_BASELINE, type LatencyCeiling } from './latency-baseline'
|
|
27
37
|
import {
|
|
28
38
|
EventsEndpoint,
|
|
@@ -1205,6 +1215,295 @@ const firstPushToAFreeName: Scenario = {
|
|
|
1205
1215
|
},
|
|
1206
1216
|
}
|
|
1207
1217
|
|
|
1218
|
+
/**
|
|
1219
|
+
* Scenario 12 — the web view: a real push, then the repository page.
|
|
1220
|
+
*
|
|
1221
|
+
* The browse endpoint is the one read that goes through git plumbing on the
|
|
1222
|
+
* Cache, so it is the one the unit tests cannot finish the argument about: they
|
|
1223
|
+
* stub `ls-tree`, and what a tree actually contains is a question only real git
|
|
1224
|
+
* answers. This pushes a fixture with nested directories on a branch whose name
|
|
1225
|
+
* contains a slash, then browses it over HTTP against the running node — and
|
|
1226
|
+
* then again from a node with an empty repos directory, which is the cold path
|
|
1227
|
+
* where the Cache has to be Materialized from the log before there is a tree to
|
|
1228
|
+
* read at all.
|
|
1229
|
+
*
|
|
1230
|
+
* The page is rendered by the very function the Worker renders it with
|
|
1231
|
+
* (`browseResponse`, `shared/browse.ts`), over the real container answer, so
|
|
1232
|
+
* the edge half is proved here and not only against a stub.
|
|
1233
|
+
*/
|
|
1234
|
+
const webBrowse: Scenario = {
|
|
1235
|
+
n: 12,
|
|
1236
|
+
name: 'Web browse — refs and a tree, over HTTP, warm and from a cold node',
|
|
1237
|
+
async run(run) {
|
|
1238
|
+
const node = await run.node('browse', { WALGIT_WEB: '1' })
|
|
1239
|
+
const repoId = run.repoId('browse')
|
|
1240
|
+
|
|
1241
|
+
const work = run.dir('browse-work')
|
|
1242
|
+
await gitOk(work, 'init', '--quiet', '--initial-branch=main', '.')
|
|
1243
|
+
await gitOk(work, 'config', 'user.email', 'e2e@walgit.test')
|
|
1244
|
+
await gitOk(work, 'config', 'user.name', 'walgit e2e')
|
|
1245
|
+
fs.mkdirSync(path.join(work, 'src/deep'), { recursive: true })
|
|
1246
|
+
fs.writeFileSync(path.join(work, 'src/index.ts'), 'export {}\n')
|
|
1247
|
+
fs.writeFileSync(path.join(work, 'src/deep/leaf.txt'), 'leaf\n')
|
|
1248
|
+
fs.writeFileSync(path.join(work, 'README.md'), 'fixture\n')
|
|
1249
|
+
// A file whose bytes are not text, and whose NAME says otherwise: the raw
|
|
1250
|
+
// read must choose its type from the content, never from the extension.
|
|
1251
|
+
fs.writeFileSync(path.join(work, 'logo.png'), Buffer.from([0x89, 0x50, 0x00, 0x4e, 0x47]))
|
|
1252
|
+
fs.writeFileSync(path.join(work, 'index.html'), '<h1>pushed markup</h1>\n')
|
|
1253
|
+
await gitOk(work, 'add', '-A')
|
|
1254
|
+
await gitOk(work, 'commit', '--quiet', '-m', 'fixture')
|
|
1255
|
+
const tip = (await gitOk(work, 'rev-parse', 'HEAD')).trim()
|
|
1256
|
+
|
|
1257
|
+
// Sixty commits, so one page of fifty is a page and a bit — the only way
|
|
1258
|
+
// to prove the cursor actually moves.
|
|
1259
|
+
for (let i = 0; i < 59; i++) {
|
|
1260
|
+
fs.writeFileSync(path.join(work, 'log.txt'), `${i}\n`)
|
|
1261
|
+
await gitOk(work, 'add', '-A')
|
|
1262
|
+
await gitOk(work, 'commit', '--quiet', '-m', `change ${i}`)
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
// A branch whose name contains a slash: the case a URL cannot resolve on
|
|
1266
|
+
// its own, and the whole reason the ref/path split is the Index's job.
|
|
1267
|
+
await gitOk(work, 'branch', 'feature/x')
|
|
1268
|
+
const pushed = await git(work, 'push', node.origin(repoId), 'main', 'feature/x')
|
|
1269
|
+
assert(pushed.status === 0, `push failed:\n${pushed.out}`)
|
|
1270
|
+
|
|
1271
|
+
/** One browse, as the edge makes it: the container's own endpoint. */
|
|
1272
|
+
const browse = async (where: WalgitNode, query: string) => {
|
|
1273
|
+
const res = await fetch(`http://127.0.0.1:${where.port}${BROWSE_PATH}${query}`, {
|
|
1274
|
+
headers: { authorization: `Bearer ${TOKEN}` },
|
|
1275
|
+
})
|
|
1276
|
+
const text = await res.text()
|
|
1277
|
+
assert(res.status === 200, `browse ${query} answered ${res.status}: ${text}`)
|
|
1278
|
+
return JSON.parse(text) as BrowseTreeAnswer
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
const root = await browse(node, `?repo=${repoId}&op=tree`)
|
|
1282
|
+
assert(
|
|
1283
|
+
root.defaultBranch === 'refs/heads/main',
|
|
1284
|
+
`default branch is ${root.defaultBranch}, expected refs/heads/main`,
|
|
1285
|
+
)
|
|
1286
|
+
assert(root.ref === 'refs/heads/main', `root read at ${root.ref}`)
|
|
1287
|
+
const rootNames = root.entries.map((entry) => entry.name).toSorted()
|
|
1288
|
+
assert(
|
|
1289
|
+
rootNames.join(' ') === 'README.md index.html log.txt logo.png src',
|
|
1290
|
+
`the root lists ${rootNames.join(' ')}`,
|
|
1291
|
+
)
|
|
1292
|
+
const src = root.entries.find((entry) => entry.name === 'src')
|
|
1293
|
+
assert(src?.kind === 'tree', `src is ${src?.kind}, expected tree`)
|
|
1294
|
+
// One level, never recursive: `src/index.ts` is inside `src`.
|
|
1295
|
+
assert(
|
|
1296
|
+
!rootNames.includes('index.ts'),
|
|
1297
|
+
`the root listed a file from inside src: ${rootNames.join(' ')}`,
|
|
1298
|
+
)
|
|
1299
|
+
|
|
1300
|
+
// `op=refs` answers the same repository without touching the Cache at all,
|
|
1301
|
+
// which is the half a page that only needs a ref list asks for.
|
|
1302
|
+
const refsOnly = await browse(node, `?repo=${repoId}&op=refs`)
|
|
1303
|
+
assert(
|
|
1304
|
+
refsOnly.refs.map((ref) => ref.name).join(' ') === 'refs/heads/feature/x refs/heads/main',
|
|
1305
|
+
`op=refs named ${refsOnly.refs.map((ref) => ref.name).join(' ')}`,
|
|
1306
|
+
)
|
|
1307
|
+
assert(
|
|
1308
|
+
(refsOnly as { entries?: unknown }).entries === undefined,
|
|
1309
|
+
'op=refs answered with a tree, which is the read it exists to avoid',
|
|
1310
|
+
)
|
|
1311
|
+
|
|
1312
|
+
// The branch with a slash in its name, and a directory under it, in the
|
|
1313
|
+
// one run-together remainder a browse URL carries.
|
|
1314
|
+
const deep = await browse(
|
|
1315
|
+
node,
|
|
1316
|
+
`?repo=${repoId}&op=tree&ref=${encodeURIComponent('feature/x/src/deep')}`,
|
|
1317
|
+
)
|
|
1318
|
+
assert(
|
|
1319
|
+
deep.ref === 'refs/heads/feature/x' && deep.path === 'src/deep',
|
|
1320
|
+
`split gave ${deep.ref} + ${deep.path}, expected refs/heads/feature/x + src/deep`,
|
|
1321
|
+
)
|
|
1322
|
+
assert(
|
|
1323
|
+
deep.entries.map((entry) => entry.name).join(' ') === 'leaf.txt',
|
|
1324
|
+
`src/deep lists ${deep.entries.map((entry) => entry.name).join(' ')}, expected leaf.txt`,
|
|
1325
|
+
)
|
|
1326
|
+
|
|
1327
|
+
// A name nobody has pushed to is 404, and browsing it creates nothing.
|
|
1328
|
+
const free = run.repoId('browse-free')
|
|
1329
|
+
const missing = await fetch(
|
|
1330
|
+
`http://127.0.0.1:${node.port}${BROWSE_PATH}?repo=${free}&op=tree`,
|
|
1331
|
+
{ headers: { authorization: `Bearer ${TOKEN}` } },
|
|
1332
|
+
)
|
|
1333
|
+
assert(missing.status === 404, `browsing a free name answered ${missing.status}`)
|
|
1334
|
+
assert(
|
|
1335
|
+
!fs.existsSync(path.join(node.reposDir, `${free}.git`)),
|
|
1336
|
+
`browsing the free name ${free} left a repository on disk`,
|
|
1337
|
+
)
|
|
1338
|
+
|
|
1339
|
+
// The page itself, rendered by the function the Worker renders it with,
|
|
1340
|
+
// over the answer the container just gave.
|
|
1341
|
+
const route = wantsBrowse('GET', `/${repoId}`)
|
|
1342
|
+
assert(route !== null, `/${repoId} is not a browse URL`)
|
|
1343
|
+
const page = await browseResponse(
|
|
1344
|
+
route,
|
|
1345
|
+
{ accept: 'text/html', before: null },
|
|
1346
|
+
{
|
|
1347
|
+
caps: capabilitiesFrom({ WALGIT_WEB: '1', WALGIT_PUBLIC: '1' }),
|
|
1348
|
+
ask: async (query) => {
|
|
1349
|
+
const res = await fetch(`http://127.0.0.1:${node.port}${BROWSE_PATH}${query}`, {
|
|
1350
|
+
headers: { authorization: `Bearer ${TOKEN}` },
|
|
1351
|
+
})
|
|
1352
|
+
return {
|
|
1353
|
+
status: res.status,
|
|
1354
|
+
text: await res.text(),
|
|
1355
|
+
contentType: res.headers.get('content-type') ?? '',
|
|
1356
|
+
served: res.headers.get(SERVED_HEADER) !== null,
|
|
1357
|
+
reject: res.headers.get(REJECT_HEADER) ?? '',
|
|
1358
|
+
challenges: [],
|
|
1359
|
+
}
|
|
1360
|
+
},
|
|
1361
|
+
},
|
|
1362
|
+
)
|
|
1363
|
+
assert(page.status === 200, `the page answered ${page.status}`)
|
|
1364
|
+
assert(
|
|
1365
|
+
page.body.includes(`<a href="/${repoId}/tree/main/src">src/</a>`),
|
|
1366
|
+
`the page has no link into src:\n${page.body}`,
|
|
1367
|
+
)
|
|
1368
|
+
assert(page.headers['x-robots-tag'] === 'noindex', 'the page is missing its noindex header')
|
|
1369
|
+
assert(
|
|
1370
|
+
(page.headers['content-security-policy'] ?? '').includes("default-src 'none'"),
|
|
1371
|
+
'the page is missing its CSP',
|
|
1372
|
+
)
|
|
1373
|
+
// The container answered it, which is what lets the edge classify a
|
|
1374
|
+
// refusal as the container's rather than as its own.
|
|
1375
|
+
assert(page.upstream.served, 'the browse answer carried no served stamp')
|
|
1376
|
+
|
|
1377
|
+
// ── The file, its bytes, the README and the history ─────────────────
|
|
1378
|
+
//
|
|
1379
|
+
// Everything below is the same container endpoint, over real git.
|
|
1380
|
+
|
|
1381
|
+
/** One browse answer, whatever op it is. */
|
|
1382
|
+
const ask = async (query: string) => {
|
|
1383
|
+
const res = await fetch(`http://127.0.0.1:${node.port}${BROWSE_PATH}${query}`, {
|
|
1384
|
+
headers: { authorization: `Bearer ${TOKEN}` },
|
|
1385
|
+
})
|
|
1386
|
+
return res
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
const blobRes = await ask(`?repo=${repoId}&op=blob&ref=main&path=src%2Findex.ts`)
|
|
1390
|
+
assert(blobRes.status === 200, `op=blob answered ${blobRes.status}`)
|
|
1391
|
+
const blob = (await blobRes.json()) as {
|
|
1392
|
+
text: string | null
|
|
1393
|
+
size: number
|
|
1394
|
+
binary: boolean
|
|
1395
|
+
oversize: boolean
|
|
1396
|
+
}
|
|
1397
|
+
assert(blob.text === 'export {}\n', `the file read as ${JSON.stringify(blob.text)}`)
|
|
1398
|
+
assert(blob.size === 10, `the file weighed ${blob.size}, expected 10`)
|
|
1399
|
+
assert(!blob.binary && !blob.oversize, 'a ten-byte source file was not plain text')
|
|
1400
|
+
|
|
1401
|
+
const binaryBlob = (await (
|
|
1402
|
+
await ask(`?repo=${repoId}&op=blob&ref=main&path=logo.png`)
|
|
1403
|
+
).json()) as {
|
|
1404
|
+
binary: boolean
|
|
1405
|
+
text: string | null
|
|
1406
|
+
}
|
|
1407
|
+
assert(binaryBlob.binary, 'a NUL-bearing file was not detected as binary')
|
|
1408
|
+
assert(binaryBlob.text === null, 'a binary file carried text')
|
|
1409
|
+
|
|
1410
|
+
// Raw: the type comes from the content. A pushed `index.html` is still
|
|
1411
|
+
// plain text, which is what keeps walgit's origin walgit's.
|
|
1412
|
+
const rawHtml = await ask(`?repo=${repoId}&op=raw&ref=main&path=index.html`)
|
|
1413
|
+
assert(
|
|
1414
|
+
rawHtml.headers.get('content-type') === 'text/plain; charset=utf-8',
|
|
1415
|
+
`a pushed index.html was served as ${rawHtml.headers.get('content-type')}`,
|
|
1416
|
+
)
|
|
1417
|
+
assert(
|
|
1418
|
+
rawHtml.headers.get('x-content-type-options') === 'nosniff',
|
|
1419
|
+
'a raw text file was not marked nosniff',
|
|
1420
|
+
)
|
|
1421
|
+
const rawBinary = await ask(`?repo=${repoId}&op=raw&ref=main&path=logo.png`)
|
|
1422
|
+
assert(
|
|
1423
|
+
rawBinary.headers.get('content-type') === 'application/octet-stream',
|
|
1424
|
+
`a binary file was served as ${rawBinary.headers.get('content-type')}`,
|
|
1425
|
+
)
|
|
1426
|
+
assert(
|
|
1427
|
+
(rawBinary.headers.get('content-disposition') ?? '').startsWith('attachment'),
|
|
1428
|
+
'a binary file was not an attachment',
|
|
1429
|
+
)
|
|
1430
|
+
const downloaded = new Uint8Array(await rawBinary.arrayBuffer())
|
|
1431
|
+
assert(
|
|
1432
|
+
downloaded.length === 5 && downloaded[0] === 0x89 && downloaded[2] === 0x00,
|
|
1433
|
+
`the downloaded bytes were ${Array.from(downloaded).join(',')}`,
|
|
1434
|
+
)
|
|
1435
|
+
|
|
1436
|
+
// The README rides with the root listing.
|
|
1437
|
+
const withReadme = await browse(node, `?repo=${repoId}&op=tree`)
|
|
1438
|
+
const readme = (withReadme as { readme?: { name: string; text: string } }).readme
|
|
1439
|
+
assert(readme?.name === 'README.md', `the root carried README ${readme?.name}`)
|
|
1440
|
+
assert(readme?.text === 'fixture\n', `the README read as ${JSON.stringify(readme?.text)}`)
|
|
1441
|
+
|
|
1442
|
+
// History, two pages of it. Sixty commits: fifty, then ten.
|
|
1443
|
+
const logPage = async (before?: string) => {
|
|
1444
|
+
const res = await ask(
|
|
1445
|
+
`?repo=${repoId}&op=log&ref=main${before === undefined ? '' : `&before=${before}`}`,
|
|
1446
|
+
)
|
|
1447
|
+
assert(res.status === 200, `op=log answered ${res.status}`)
|
|
1448
|
+
return (await res.json()) as { commits: { oid: string }[]; next: string | null }
|
|
1449
|
+
}
|
|
1450
|
+
const first = await logPage()
|
|
1451
|
+
assert(first.commits.length === 50, `the first page held ${first.commits.length}, expected 50`)
|
|
1452
|
+
assert(first.next !== null, 'a full first page named no next cursor')
|
|
1453
|
+
assert(
|
|
1454
|
+
first.commits[0]!.oid === (await gitOk(work, 'rev-parse', 'main')).trim(),
|
|
1455
|
+
'the history did not start at the tip',
|
|
1456
|
+
)
|
|
1457
|
+
const second = await logPage(first.next!)
|
|
1458
|
+
assert(
|
|
1459
|
+
second.commits.length === 10,
|
|
1460
|
+
`the second page held ${second.commits.length}, expected 10`,
|
|
1461
|
+
)
|
|
1462
|
+
assert(second.next === null, 'the end of a 60-commit history named a next page')
|
|
1463
|
+
// The cursor is exclusive to a reader: no commit appears on both pages.
|
|
1464
|
+
const firstOids = new Set(first.commits.map((entry) => entry.oid))
|
|
1465
|
+
assert(
|
|
1466
|
+
second.commits.every((entry) => !firstOids.has(entry.oid)),
|
|
1467
|
+
'a commit appeared on both pages of the history',
|
|
1468
|
+
)
|
|
1469
|
+
|
|
1470
|
+
// A cursor git would happily resolve but walgit will not read.
|
|
1471
|
+
const badCursor = await ask(`?repo=${repoId}&op=log&ref=main&before=HEAD`)
|
|
1472
|
+
assert(badCursor.status === 400, `a malformed cursor answered ${badCursor.status}`)
|
|
1473
|
+
|
|
1474
|
+
// A cold node: its own empty repos directory, the same log. Everything
|
|
1475
|
+
// above has to be true again, which it can only be by Materializing.
|
|
1476
|
+
const cold = await run.node('browse-cold', { WALGIT_WEB: '1' })
|
|
1477
|
+
assert(
|
|
1478
|
+
!fs.existsSync(path.join(cold.reposDir, `${repoId}.git`)),
|
|
1479
|
+
'the cold node started with the repository already on disk',
|
|
1480
|
+
)
|
|
1481
|
+
const coldRoot = await browse(cold, `?repo=${repoId}&op=tree`)
|
|
1482
|
+
assert(
|
|
1483
|
+
coldRoot.entries
|
|
1484
|
+
.map((entry) => entry.name)
|
|
1485
|
+
.toSorted()
|
|
1486
|
+
.join(' ') === 'README.md index.html log.txt logo.png src',
|
|
1487
|
+
`the cold node listed ${coldRoot.entries.map((entry) => entry.name).join(' ')}`,
|
|
1488
|
+
)
|
|
1489
|
+
assert(
|
|
1490
|
+
coldRoot.refs.some((ref) => ref.name === 'refs/heads/feature/x'),
|
|
1491
|
+
'the cold node did not name the slashed branch',
|
|
1492
|
+
)
|
|
1493
|
+
|
|
1494
|
+
return [
|
|
1495
|
+
`pushed ${tip.slice(0, 8)} on main and feature/x, then browsed /${repoId} over HTTP: ${rootNames.join(', ')}`,
|
|
1496
|
+
'op=refs named both branches without reading a tree',
|
|
1497
|
+
'the slashed branch and a nested directory resolved from one run-together URL remainder',
|
|
1498
|
+
`a browse of the free name ${free} answered 404 and created nothing on disk`,
|
|
1499
|
+
'a node with an empty repos directory served the same tree after materializing',
|
|
1500
|
+
'op=blob read a source file and detected a NUL-bearing one as binary',
|
|
1501
|
+
'raw chose text/plain for a pushed index.html and an octet-stream attachment for a PNG',
|
|
1502
|
+
'the root listing carried its README, and 60 commits paged 50 then 10 with no overlap',
|
|
1503
|
+
]
|
|
1504
|
+
},
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1208
1507
|
export const SCENARIOS: Scenario[] = [
|
|
1209
1508
|
durability,
|
|
1210
1509
|
noPhantomAcks,
|
|
@@ -1217,4 +1516,5 @@ export const SCENARIOS: Scenario[] = [
|
|
|
1217
1516
|
pushProvenance,
|
|
1218
1517
|
privateReads,
|
|
1219
1518
|
firstPushToAFreeName,
|
|
1519
|
+
webBrowse,
|
|
1220
1520
|
]
|
|
@@ -18,7 +18,11 @@
|
|
|
18
18
|
"deploy": "wrangler deploy"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"
|
|
21
|
+
"@hono/mcp": "^0.3.1",
|
|
22
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
23
|
+
"aws4fetch": "^1.0.20",
|
|
24
|
+
"hono": "^4.12.30",
|
|
25
|
+
"zod": "^4.4.3"
|
|
22
26
|
},
|
|
23
27
|
"devDependencies": {
|
|
24
28
|
"@cloudflare/containers": "^0.3.7",
|