GitHubivarvong
ply
main
1// The large differential campaign of the tree-entry name checks (#207): src/validate.ts against the version before it
2// (test/oracle/dotnames-ref.ts), on isDotGitName, isDotFileName × 4 and checkoutPathRefusal's isHfsDot(.gitmodules).
3// node --import ./test/ts-resolve.mjs test/fuzz/dotnames.mjs [--n 10000000] [--seed 207] [--stage all|exhaustive|targeted|random]
4// Stages: every byte string up to 3 bytes (16.8 M); every string up to 4 bytes over 38 bytes (FOUR); every spelling × head ×
5// tail with its truncations, substitutions by the alphabet, deletions, doublings and ignorables inserted; random names
6// from spelling fragments. Prints each stage's count, how many names spell something (so a green run is known not to be
7// vacuous), and the first disagreement as hex bytes.
8// Stage `git` is the one whose oracle is not ply: every --git-stride-th targeted name and the first --git-n random
9// names of the seed, each a one-entry symlink tree judged by `git fsck --strict` (test/fuzz/git-names.mjs), against
10// src/validate.ts. The other stages compare src with the pre-#207 ply and prove only that the rewrite changed nothing.
11// node --import ./test/ts-resolve.mjs test/fuzz/dotnames.mjs --stage git [--git-n 20000] [--git-stride 997] [--seed 207]
12import { ALPHABET, ALL_BYTES, exhaustive, targeted, rng, randomName, judge, hfsGitmodules, verdicts } from '../dotnames-corpus.js';
13import { gitNameVerdicts, MSG_IDS } from './git-names.mjs';
15const args = Object.fromEntries(process.argv.slice(2).map((a, i, arr) => (a.startsWith('--') ? [a.slice(2), arr[i + 1] ?? true] : [])).filter(x => x.length));
16const N = Number(args.n ?? 10_000_000), SEED = Number(args.seed ?? 207), STAGE = args.stage ?? 'all';
17const GIT_N = Number(args['git-n'] ?? 20_000), GIT_STRIDE = Number(args['git-stride'] ?? 997);
18console.log(`dotnames: seed=${SEED} n=${N} stage=${STAGE} git-n=${GIT_N} git-stride=${GIT_STRIDE}`);
19let failed = false;
20const stage = (name, names) => {
21 if (STAGE !== 'all' && !name.startsWith(STAGE)) return;
22 const t0 = Date.now();
23 const stats = { n: 0, hits: 0 };
24 const bad = judge(names, stats);
25 console.log(`${name.padEnd(26)} ${String(stats.n).padStart(11)} names ${String(stats.hits).padStart(9)} spell something ${((Date.now() - t0) / 1000).toFixed(1)} s${bad ? ` DISAGREE ${JSON.stringify(bad)}` : ''}`);
26 if (bad) failed = true;
27};
28stage('exhaustive all bytes ≤ 3', exhaustive(ALL_BYTES, 3));
29// 4 bytes reach `.git`, `~1`+tail and an ignorable + `.`: the separators, `~`, digits at the range edges, the letters of
30// git and of the short names, and the UTF-8 bytes of the ignorables and their neighbours
31const FOUR = Uint8Array.from([0x00, 0x20, 0x2e, 0x2f, 0x3a, 0x5c, 0x7e, 0x30, 0x31, 0x34, 0x35, 0x39, 0x67, 0x69, 0x74, 0x47, 0x49, 0x54, 0x6d, 0x4d, 0x37, 0x65, 0x62, 0x61, 0x78, 0x80, 0x81, 0x8c, 0x8f, 0xae, 0xbb, 0xbf, 0xc2, 0xe2, 0xed, 0xef, 0xf0, 0xff]);
32stage(`exhaustive alphabet(${FOUR.length}) ≤ 4`, exhaustive(FOUR, 4));
33stage('targeted', targeted());
34const r = rng(SEED);
35stage(`random seed ${SEED}`, (function* () { for (let i = 0; i < N; i++) yield randomName(r); })());
36if (STAGE === 'all' || STAGE === 'hfs') {
37 let asked = 0, hits = 0, bad = null;
38 for (const b of targeted(undefined, undefined, ALPHABET.subarray(0, 24))) {
39 const v = hfsGitmodules(b);
40 if (v === null) continue;
41 asked++; if (v.want) hits++;
42 if (v.got !== v.want) { bad = [...b].map(x => x.toString(16)).join(' '); break; }
43 }
44 console.log(`hfs .gitmodules (checkout) ${String(asked).padStart(11)} names ${String(hits).padStart(9)} spell something${bad ? ` DISAGREE ${bad}` : ''}`);
45 if (bad) failed = true;
46}
47if (STAGE === 'all' || STAGE === 'git') {
48 const t0 = Date.now();
49 const names = [];
50 let k = 0;
51 // 997 is prime, so the sample is not the same position of every base's run of variants
52 for (const b of targeted()) if (k++ % GIT_STRIDE === 0) names.push(b);
53 const rg = rng(SEED);
54 for (let i = 0; i < GIT_N; i++) names.push(randomName(rg));
55 const git = gitNameVerdicts(names);
56 let judged = 0, hits = 0, bad = null;
57 for (let i = 0; i < names.length; i++) {
58 const want = git[i];
59 if (want === null) continue;
60 judged++; if (want !== '00000') hits++;
61 const got = verdicts(names[i], 'src');
62 if (got !== want && !bad) bad = { bytes: [...names[i]].map(x => x.toString(16).padStart(2, '0')).join(' '), git: want, ply: got, order: MSG_IDS.join(',') };
63 }
64 console.log(`${'git fsck --strict'.padEnd(26)} ${String(judged).padStart(11)} names ${String(hits).padStart(9)} spell something ${((Date.now() - t0) / 1000).toFixed(1)} s${bad ? ` DISAGREE ${JSON.stringify(bad)}` : ''}`);
65 // a green run with nothing judged, or nothing git objects to, proves nothing
66 if (judged === 0 || hits === 0) { console.log('git stage is vacuous: no name judged, or none that git flags'); failed = true; }
67 if (bad) failed = true;
68}
69if (failed) {
70 console.log(`FAIL dotnames seed=${SEED} replay: node --import ./test/ts-resolve.mjs test/fuzz/dotnames.mjs --seed ${SEED} --n ${N} --stage ${STAGE} --git-n ${GIT_N} --git-stride ${GIT_STRIDE}`);
71 process.exit(1);
72}
Diagnostics7 git calls · 131 ms
CallStatusSizeTime0131 ms
discover200191 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=191 git.server.agent=git/github-9922ec520325-Linux git.server.object_format=sha1 git.server.caps=agent ls-refs fetch server-option object-format git.server.fetch=shallow wait-for-done filter git.protocol.version=2 git.pkt.frames=9 git.pkt.data=7 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=191 git.pkt.payload.max=36
ls-refs20012 KiB · 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=11990 git.response.cache=HIT git.response.duration_ms=2 git.protocol.version=2 git.pkt.frames=152 git.pkt.data=151 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=11990 git.pkt.payload.max=122 git.ls_refs.count=151 git.ls_refs.head=refs/heads/main
fetchtree:0 · deepen 102004.2 KiB · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=4347 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 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=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=4347 git.pkt.payload.max=4247 git.sideband.band1.bytes=4247 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=10 git.pack.bytes=4247 git.pack.ofs_delta=0 git.pack.ref_delta=0 git.pack.chain.max=0 git.pack.trailer=a6caf8e129bea82c9bae4cbc7c130c9205add400 git.pack.full=10Open pack map
fetchtree:0200919 B · 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=919 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=800d30ba8923860bfc460ca884b7f9ba22083588 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=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=919 git.pkt.payload.max=892 git.sideband.band1.bytes=892 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=892 git.pack.trailer=5323b9266eea5ded637285d1c5320699f12be76eOpen pack map
fetchtree:02005.6 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=5724 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=58fabb6768b3f737ee9cd8bac647bdc27405fb4d 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=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=5724 git.pkt.payload.max=5697 git.sideband.band1.bytes=5697 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=5697 git.pack.trailer=be7e0453974a5fe832f9065a33bb7e3434c10e9bOpen pack map
fetchtree:0200853 B · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=853 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=fb781d4e4fd58ededa1f1078d937de6f4b1316a2 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=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=853 git.pkt.payload.max=826 git.sideband.band1.bytes=826 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=826 git.pack.trailer=c89bc485f6ad08d875fc515f3fdd69897096847bOpen pack map
fetch2002.2 KiB119 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=119 git.response.bytes=2250 git.response.cache=MISS git.response.duration_ms=119 git.fetch.wants=c0668673b8d78460aafc4cc0337e72db39ea7d0e 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=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=2250 git.pkt.payload.max=2223 git.sideband.band1.bytes=2223 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://github.com/ivarvong/ply
- Ref
- refs/heads/main
- Commit
- 19912563f540228593df0c489082e5e2508e21e4
- cf-ray
- a5e2c0680b3b89da
- Request
- 3af00f74…
- Protocol
- v2 · sha1
- Agent
- git/github-9922ec520325-Linux
- Filter
- advertised
- Fetch
- shallow wait-for-done filter
- Capabilities
- agent ls-refs fetch server-option object-format