Artifactspublic-v0

ply

main
ply4 git calls42 ms40 KiB3 cachedprotocol v2
86 lines5.5 KiBRaw
1// Real git-produced packs for the pack-cut space. Every pack is written by `git pack-objects` (git's own writer), never
2// by ply: a cell that cuts or corrupts one starts from bytes an honest server sends. Built once per process in a temp
3// repository; the objects are fixed text, so the packs are the same bytes on every run of the same git.
4import { execFileSync } from 'node:child_process';
5import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
6import { tmpdir } from 'node:os';
7import { join } from 'node:path';
9const ENV = { ...process.env, GIT_AUTHOR_NAME: 'ply', GIT_AUTHOR_EMAIL: 'ply@example.com', GIT_COMMITTER_NAME: 'ply', GIT_COMMITTER_EMAIL: 'ply@example.com', GIT_AUTHOR_DATE: '1700000000 +0000', GIT_COMMITTER_DATE: '1700000000 +0000', GIT_CONFIG_NOSYSTEM: '1', HOME: tmpdir() };
11export function git(dir, args, input) {
12 return execFileSync('git', args, { cwd: dir, env: ENV, input, maxBuffer: 1 << 28 });
14const line = (dir, args, input) => git(dir, args, input).toString().trim();
16// A blob that slides one block of pseudo-random lines per version (v_i = B_i..B_i+3): each version is closest to its
17// neighbour, so pack-objects deltas the four versions into an OFS chain.
18const lcg = seed => () => (seed = (seed * 1103515245 + 12345) % 2147483648);
19const block = (seed, n) => { const r = lcg(seed); return Array.from({ length: n }, () => `${r().toString(36)} ${r().toString(36)}\n`).join(''); };
20const text = i => Array.from({ length: 4 }, (_, k) => block(i + k + 1, 40)).join('');
22export function buildPacks() {
23 const dir = mkdtempSync(join(tmpdir(), 'ply-pack-cut-'));
24 try {
25 git(dir, ['init', '-q', '-b', 'main']);
26 git(dir, ['config', 'pack.compression', '9']);
27 const v = [];
28 for (let i = 0; i < 4; i++) {
29 writeFileSync(join(dir, 'f.txt'), text(i));
30 writeFileSync(join(dir, 'g.txt'), `small ${i}\n`);
31 git(dir, ['add', '.']);
32 git(dir, ['commit', '-q', '-m', `v${i}`]);
33 v.push(line(dir, ['rev-parse', 'HEAD']));
34 }
35 git(dir, ['tag', '-a', '-m', 'annotated', 't1', v[0]]);
36 const oid = rev => line(dir, ['rev-parse', rev]);
37 const objs = {
38 commit: v[0], tree: oid(`${v[0]}^{tree}`), blob: oid(`${v[0]}:g.txt`), tag: oid('t1'),
39 big1: oid(`${v[0]}:f.txt`), big2: oid(`${v[1]}:f.txt`), big3: oid(`${v[2]}:f.txt`), big4: oid(`${v[3]}:f.txt`),
40 };
41 const pack = (oids, args = []) => new Uint8Array(git(dir, ['pack-objects', '--stdout', '-q', ...args], `${oids.join('\n')}\n`));
42 const packs = {
43 // non-delta, one object of each type (commit, tree, blob, tag): what a full pack of distinct small objects is
44 full: { bytes: pack([objs.commit, objs.tree, objs.blob, objs.big1, objs.tag], ['--no-reuse-delta', '--window=0']), want: objs.commit, kind: 'non-delta, every type' },
45 // OFS_DELTA: one base and one delta (pack-objects --delta-base-offset, as upload-pack asks with ofs-delta)
46 ofs: { bytes: pack([objs.big1, objs.big2], ['--delta-base-offset', '--no-reuse-delta']), want: objs.big2, kind: 'OFS_DELTA' },
47 // REF_DELTA: the same objects without ofs-delta
48 ref: { bytes: pack([objs.big1, objs.big2], ['--no-reuse-delta']), want: objs.big2, kind: 'REF_DELTA' },
49 // an OFS chain three deep
50 chain: { bytes: pack([objs.big1, objs.big2, objs.big3, objs.big4], ['--delta-base-offset', '--no-reuse-delta', '--depth=50']), want: objs.big4, kind: 'OFS chain' },
51 // a thin pack: REF_DELTA against a base the pack does not carry (fetch with thin-pack)
52 thin: { bytes: new Uint8Array(git(dir, ['pack-objects', '--stdout', '-q', '--thin', '--revs', '--no-reuse-delta'], `${v[1]}\n^${v[0]}\n`)), want: v[1], kind: 'thin REF_DELTA', external: true },
53 };
54 // single-object packs: what a tree:0 / one-want fetch returns (the streamed spStep path)
55 const single = {};
56 for (const t of ['commit', 'tree', 'blob', 'tag']) single[t] = { bytes: pack([objs[t]]), want: objs[t], type: t };
57 // the thin pack's external bases, as {type, data} by oid
58 const bases = new Map();
59 for (const o of [objs.big1, objs.blob, oid(`${v[0]}^{tree}`), v[0]]) bases.set(o, { type: line(dir, ['cat-file', '-t', o]), data: new Uint8Array(git(dir, ['cat-file', line(dir, ['cat-file', '-t', o]), o])) });
60 const version = line(dir, ['version']);
61 return { packs, single, objs, bases, version };
62 } finally { rmSync(dir, { recursive: true, force: true }); }
65// git index-pack --strict on the bytes, as the oracle: { ok, msg }. In a scratch repository that holds the thin
66// pack's bases, so --fix-thin can complete a thin pack the way a receiving git would.
67export function indexPackOracle() {
68 const dir = mkdtempSync(join(tmpdir(), 'ply-pack-oracle-'));
69 git(dir, ['init', '-q', '--bare']);
70 let n = 0;
71 return {
72 dir,
73 run(bytes, { thin = false } = {}) {
74 const f = join(dir, `c${n++ % 4}.pack`);
75 if (!thin) writeFileSync(f, bytes);
76 try {
77 // --fix-thin needs --stdin (it appends the bases to a pack it writes into the repository)
78 if (thin) execFileSync('git', ['index-pack', '--stdin', '--strict', '--fix-thin'], { cwd: dir, env: ENV, input: bytes, stdio: ['pipe', 'pipe', 'pipe'] });
79 else execFileSync('git', ['index-pack', '--strict', '-o', `${f}.idx`, f], { cwd: dir, env: ENV, stdio: ['ignore', 'pipe', 'pipe'] });
80 return { ok: true, msg: '' };
81 } catch (e) { return { ok: false, msg: String(e.stderr ?? '').trim().split('\n').pop() }; }
82 },
83 seed(bytes) { git(dir, ['index-pack', '--stdin', '--strict'], bytes); },
84 close() { rmSync(dir, { recursive: true, force: true }); },
85 };
Diagnostics4 git calls · 42 ms
CallStatusSizeTime042 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200145 B · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=145
git.response.cache=HIT
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=145
git.pkt.payload.max=76
git.ls_refs.count=2
git.ls_refs.head=refs/heads/main
fetchblob:none · deepen 1020038 KiB · hit7 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=32
git.response.bytes=38434
git.response.cache=HIT
git.response.duration_ms=7
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=19912563f540228593df0c489082e5e2508e21e4
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=6
git.pkt.data=4
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=38434
git.pkt.payload.max=38339
git.sideband.band1.bytes=38338
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=63
git.pack.bytes=38338
git.pack.ofs_delta=0
git.pack.ref_delta=8
git.pack.chain.max=8
git.pack.trailer=0bc36ab7adf82d3109177f11f1ea93f1ce071f77
git.pack.full=55
Open pack map
fetch2002.2 KiB · hit32 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2268
git.response.cache=HIT
git.response.duration_ms=32
git.fetch.wants=aac2e17f1dfad4bb58d9790ae7bc2f0cbcd216b7
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=2268
git.pkt.payload.max=2247
git.sideband.band1.bytes=2246
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply.git
Ref
refs/heads/main
Commit
19912563f540228593df0c489082e5e2508e21e4
cf-ray
a5e35552d8c8994c
Request
2c8e276a…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format