Artifactspublic-v0

ply

main
ply4 git calls43 ms41 KiB3 cachedprotocol v2
137 lines8.3 KiBRaw
1// Case generators over the combinatorial product space. Each knob has named classes so the
2// steering loop can ask for a specific region of the space by name.
3import { indexOfBytes } from '../../src/bytes.js';
5const te = new TextEncoder();
6export const KNOBS = {
7 blob: ['empty', 'tiny', 'text', 'random', 'repetitive', 'boundary', 'big', 'binaryish'],
8 pos: ['start', 'end', 'middle', 'chunk16k', 'chunk32k', 'chunk64k', 'random'],
9 find: ['one', 'short', 'medium', 'over127', 'long'],
10 replace: ['empty', 'same', 'shorter', 'longer', 'over127', 'huge', 'identical'],
11 compression: ['0', '1', '6', '9', '-1'],
12 depth: ['1', '2', '3', '4', '6', '10'],
13 outcome: ['ok', 'zero_matches', 'two_matches', 'missing_path', 'not_a_file', 'cas_conflict'],
14 siblings: ['none', 'few', 'many', 'sortedge'],
15 history: ['1', '2', '5'],
16 mode: ['100644', '100755'],
17 server: ['loose', 'packed', 'bitmap', 'midx-bitmap', 'mixed'],
18};
20const VOCAB = 'the quick brown fox jumps over lazy dog lorem ipsum dolor sit amet git pack delta inflate huffman'.split(' ');
21const SORT_EDGE_NAMES = ['a', 'a-b', 'a.b', 'a0', 'a_b', 'ab', 'A', 'a~', 'z', 'é', 'a b', 'a--', 'a.', '-a', '.hidden', 'ä', '한글', '🚀', '\ufeffREADME'];
22const BOUNDARY_SIZES = [127, 128, 255, 256, 4095, 4096, 16383, 16384, 16385, 32767, 32768, 32769, 65535, 65536, 65537, 131072];
24export function genBlob(rng, cls) {
25 switch (cls) {
26 case 'empty': return new Uint8Array(0);
27 case 'tiny': return te.encode(Array.from({ length: rng.int(1, 12) }, () => rng.pick(VOCAB)).join(' '));
28 case 'text': return genText(rng, rng.int(100, 20000));
29 case 'random': return rng.bytes(rng.int(1, 40000));
30 case 'repetitive': { const pat = rng.pick([te.encode('ab'), rng.bytes(rng.int(1, 300)), te.encode('line of text\n')]); const n = rng.int(1000, 120000); const out = new Uint8Array(n); for (let i = 0; i < n; i++) out[i] = pat[i % pat.length]; return out; }
31 case 'boundary': { const n = rng.pick(BOUNDARY_SIZES); return rng.bool(0.6) ? genText(rng, n) : rng.bytes(n); }
32 case 'big': return genText(rng, rng.int(200000, 1500000));
33 case 'binaryish': { const n = rng.int(500, 60000); const out = new Uint8Array(n); for (let i = 0; i < n; i++) out[i] = rng.bool(0.7) ? 0 : rng.u32() & 0xff; return out; }
34 default: throw new Error(`blob class ${cls}`);
35 }
37function genText(rng, n) {
38 const parts = []; let len = 0;
39 while (len < n) { const w = rng.pick(VOCAB) + (rng.bool(0.15) ? '\n' : ' '); parts.push(w); len += w.length; }
40 return te.encode(parts.join('')).subarray(0, n);
43export function genFind(rng, cls) {
44 const n = { one: 1, short: rng.int(2, 16), medium: rng.int(17, 100), over127: rng.int(128, 200), long: rng.int(300, 2000) }[cls];
45 // bytes outside the text vocab so uniqueness is likely; some fully random
46 return rng.bool(0.5) ? Uint8Array.from({ length: n }, () => 0xc0 + (rng.u32() % 50)) : rng.bytes(n);
48export function genReplace(rng, cls, find) {
49 switch (cls) {
50 case 'empty': return new Uint8Array(0);
51 case 'same': return rng.bytes(find.length);
52 case 'shorter': return rng.bytes(rng.int(0, Math.max(0, find.length - 1)));
53 case 'longer': return rng.bytes(find.length + rng.int(1, 50));
54 case 'over127': return rng.bytes(rng.int(128, 400));
55 case 'huge': return rng.bytes(rng.int(1000, 70000));
56 case 'identical': return find.slice();
57 }
60// Place find into blob at a position class; returns new blob + offset (exactly one occurrence guaranteed).
61export function placeFind(rng, blob, find, posCls) {
62 const L = blob.length;
63 let off;
64 switch (posCls) {
65 case 'start': off = 0; break;
66 case 'end': off = L; break;
67 case 'middle': off = L >> 1; break;
68 case 'chunk16k': off = chunkStraddle(rng, L, 16384, find.length); break;
69 case 'chunk32k': off = chunkStraddle(rng, L, 32768, find.length); break;
70 case 'chunk64k': off = chunkStraddle(rng, L, 65536, find.length); break;
71 default: off = rng.int(0, L);
72 }
73 const out = new Uint8Array(L + find.length);
74 out.set(blob.subarray(0, off)); out.set(find, off); out.set(blob.subarray(off), off + find.length);
75 return { blob: out, off };
77function chunkStraddle(rng, L, boundary, n) {
78 const k = Math.max(1, Math.floor(L / boundary));
79 const b = boundary * rng.int(1, k);
80 return Math.max(0, Math.min(L, b - rng.int(1, Math.max(1, n - 1))));
82export const countOccurrences = (hay, needle) => { let c = 0, i = 0; while ((i = indexOfBytes(hay, needle, i)) >= 0) { c++; i += Math.max(1, needle.length); } return c; };
84export function genPath(rng, depthCls, siblingsCls) {
85 const depth = parseInt(depthCls, 10);
86 const name = () => (siblingsCls === 'sortedge' ? rng.pick(SORT_EDGE_NAMES) : rng.pick(['src', 'lib', 'pkg', 'a', 'b', 'deep', 'x-y', 'n.m']) + (rng.bool(0.5) ? rng.int(0, 9) : ''));
87 const dirs = Array.from({ length: depth - 1 }, name);
88 return [...dirs, (siblingsCls === 'sortedge' ? rng.pick(SORT_EDGE_NAMES) : 'f' + rng.int(0, 999)) + rng.pick(['.txt', '.js', '', '.bin'])].join('/');
91export function genSiblings(rng, cls, path) {
92 const n = { none: 0, few: rng.int(1, 4), many: rng.int(10, 40), sortedge: rng.int(6, 14) }[cls];
93 const files = {};
94 const comps = path.split('/');
95 for (let i = 0; i < n; i++) {
96 const depth = rng.int(0, comps.length - 1);
97 const base = comps.slice(0, depth);
98 let nm = cls === 'sortedge' ? rng.pick(SORT_EDGE_NAMES) : 's' + rng.int(0, 9999);
99 const asDir = rng.bool(0.3);
100 const p = [...base, nm, ...(asDir ? ['inner' + rng.int(0, 9)] : [])].join('/');
101 const clash = (x, y) => x === y || x.startsWith(y + '/') || y.startsWith(x + '/');
102 if (clash(p, path) || Object.keys(files).some(q => clash(p, q))) continue;
103 const kind = rng.weighted([['file', 8], ['exec', 1], ['symlink', 1]]);
104 files[p] = kind === 'symlink' ? { symlink: rng.pick(['../x', 'f0.txt', '/dev/null']) } : { mode: kind === 'exec' ? '100755' : '100644', data: genBlob(rng, rng.pick(['tiny', 'text', 'random', 'empty'])) };
105 }
106 return files;
109// A complete case spec. hints: partial {knob: class} to steer.
110export function genCase(seedRng, hints = {}) {
111 const rng = seedRng;
112 const pick = k => hints[k] ?? rng.pick(KNOBS[k]);
113 const c = { blob: pick('blob'), pos: pick('pos'), find: pick('find'), replace: pick('replace'), compression: pick('compression'), depth: pick('depth'), outcome: pick('outcome'), siblings: pick('siblings'), history: pick('history'), mode: pick('mode'), server: pick('server') };
114 const path = genPath(rng, c.depth, c.siblings);
115 let find = genFind(rng, c.find);
116 const replace = genReplace(rng, c.replace, find);
117 let blob = genBlob(rng, c.blob);
118 let off = -1;
119 // ensure baseline has zero occurrences, then place per outcome
120 for (let tries = 0; countOccurrences(blob, find) > 0 && tries < 20; tries++) find = genFind(rng, c.find);
121 if (countOccurrences(blob, find) > 0) blob = genBlob(rng, 'random');
122 if (c.outcome !== 'zero_matches') { ({ blob, off } = placeFind(rng, blob, find, c.pos)); }
123 if (c.outcome === 'two_matches') { ({ blob } = placeFind(rng, blob, find, 'random')); }
124 const occurrences = countOccurrences(blob, find);
125 if (occurrences === 1) off = indexOfBytes(blob, find); // overlapping placements can collapse; truth is what the scanner will see
126 const files = { ...genSiblings(rng, c.siblings, path) };
127 let editPath = path;
128 if (c.outcome === 'missing_path') editPath = path + '.missing';
129 if (c.outcome === 'not_a_file') { const comps = path.split('/'); editPath = comps.length > 1 ? comps.slice(0, -1).join('/') : path; if (comps.length === 1) files[path + '/inner'] = { mode: '100644', data: new Uint8Array(0) }; }
130 if (!(c.outcome === 'not_a_file' && path.split('/').length === 1)) files[path] = { mode: c.mode, data: blob };
131 const same = find.length === replace.length && find.every((b, i) => b === replace[i]);
132 const matchOutcome = occurrences !== 1 ? 'match_count' : same ? 'noop' : 'ok';
133 // a single injected race is absorbed by editFile's one internal retry: the caller sees 'ok' on attempt 1 (run.mjs checks the
134 // attempt-0 root failed with cas_conflict and the retry's parent is the racer's commit)
135 const expected = ['ok', 'zero_matches', 'two_matches'].includes(c.outcome) ? matchOutcome : c.outcome === 'cas_conflict' ? matchOutcome : 'not_found';
136 return { knobs: c, path, editPath, find, replace, blob, off, occurrences, files, expected, compression: parseInt(c.compression, 10), history: parseInt(c.history, 10) };
Diagnostics4 git calls · 43 ms
CallStatusSizeTime043 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
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 · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=145
git.response.cache=HIT
git.response.duration_ms=2
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 · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=38434
git.response.cache=HIT
git.response.duration_ms=2
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
fetch2003.2 KiB · hit39 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=39
git.response.bytes=3252
git.response.cache=HIT
git.response.duration_ms=39
git.fetch.wants=8e1e5115007fe220e8d8f60e617fb249b34b01ff
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=3252
git.pkt.payload.max=3231
git.sideband.band1.bytes=3230
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
a5e2cf91cc7fefad
Request
7f3b488d…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format