Part of #237.
A full clone of flagon-io/g1t from g1t.sh is 134 MB and takes 38 s. From GitHub it is 34 MB and 3 s, for the same objects. g1t relays Cloudflare Artifacts' packs byte for byte, they are barely deltified, and Artifacts gives us no setting to change that. This serves reads with git's own upload-pack from a well-packed mirror. On the first sync of this repository the mirror ends as one 22 MB pack with a bitmap.
How it fits together
MODE=gitedgein the runner binary (crates/runner/src/gitedge.rs): a small HTTP server (tiny_http, MIT/Apache, pure Rust).POST /syncfetches from Artifacts into a bare mirror. The token goes through git's environment config and never appears in argv or logs. The fetch is--atomic.- After the first fetch it runs
repack -adf --write-bitmap-index; after later fetches it repacks when there are more than 8 packs. - It serves
info/refsandgit-upload-packthroughgit http-backend, only for the exact refs version it is asked about (x-g1t-edge-version), and answers409 x-g1t-edge: behindotherwise, including while a sync is changing refs. receive-pack is refused with 403.
GitEdgecontainer class (services/runner): one container per repository, the same image,standard-2,sleepAfter30 minutes.- A cold container answers
503 x-g1t-edge: coldat once and starts in the background. - It registers no outbound handlers, so its fetches go straight to Artifacts.
- The abuse watch is off, since it runs no one's code.
- A cold container answers
- Routing in the repos service (
services/repos/src/git_edge.rs): for the repositoriesGIT_EDGEnames (onlyflagon-io/g1tto start), upload-pack reads go to the edge after authorization, limits and a clone-cache miss.- Anything but a 200 goes to Artifacts exactly as before, and the edge is told to sync. It is also told after every push.
- Edge answers get the same HEAD and negotiation handling as Artifacts' answers, are filled into the clone cache, and are not metered as store operations.
Artifacts stays the source of truth: pushes are untouched, and the edge never answers for refs older than g1t has recorded.
Tests
cargo test -p g1t-runner --test gitedge: real git against the server.- Clones over protocol v2 and v0 are equal to the source, with fsck;
--depth 1and--filter=blob:nonework. - An incremental fetch after a second sync sends haves.
- Wrong or missing versions get 409; receive-pack gets 403.
- A failed sync keeps serving; syncs queue latest-wins; the token never appears in the output.
- Passes on Windows and in a Linux container.
- Clones over protocol v2 and v0 are equal to the source, with fsck;
services/runner:npm test102 pass (10 new), and the typecheck is clean.cargo test -p g1t-repos: 373 pass.npm run test:deploy: 101 pass;manifest --checkis consistent.
Known limits (follow-ups on #237)
- A container that sleeps loses its disk, so its next start re-clones from Artifacts in the background (about 17 s locally for this repository), with reads falling back meanwhile. Keeping the mirror in R2 would make cold starts a download.
- The first sync after a push takes seconds, so a clone that comes right behind it falls back.
Deploy order doesn't matter: without the runner's route, the repos service just falls back.