Artifactspublic-v0

ply

main
ply4 git calls309 ms40 KiB2 cachedprotocol v2
66 lines5.3 KiBRaw
1// The diff under the merge, hunk by hunk against `git diff --histogram --no-indent-heuristic -U1` (changed lines rebuilt from the hunk bodies) — a stronger oracle than
2// merge verdicts for the Myers fallback's heuristics (snake sampling past cost 256, the mxcost cutoff), which only fire on
3// big, heavily edited, low-variety regions. --rediff skip models git releases without the compaction re-diff (the 2.43 oracle here).
4// node test/fuzz/diffscript.mjs [--n 200] [--seed 1] [--snake|--huge] [--rediff skip]
5import { spawnSync } from 'node:child_process';
6import { mkdtempSync, writeFileSync, rmSync } from 'node:fs';
7import { tmpdir } from 'node:os';
8import { join } from 'node:path';
9import { Rng } from './prng.js';
10import { records, classifier, diffScript } from '../../src/linemerge.js';
11import { LIMIT_MERGE_WORK } from '../../src/limits.js';
12let refused = 0;
14import { oracleRediff } from '../gitversion.js';
15const REDIFF = process.argv.includes('--rediff') ? process.argv[process.argv.indexOf('--rediff') + 1] : oracleRediff(); // default: whatever the oracle git does
16const GIT_BIN = process.env.GIT_BIN ?? 'git'; // GIT_BIN=/path/to/git: judge against another git build
17const arg = (k, d) => { const i = process.argv.indexOf(`--${k}`); return i < 0 ? d : +process.argv[i + 1]; };
18const N = arg('n', 200), SEED = arg('seed', 1), SNAKE = process.argv.includes('--snake'), HUGE = process.argv.includes('--huge'); // --huge: ndiags ≥ 65536 so mxcost > 256 and the snake heuristic can fire
19const dir = mkdtempSync(join(tmpdir(), 'ds-'));
20const counts = { same: 0, differ: 0, undecided: 0 }; const bad = [];
21const rng0 = new Rng(SEED);
22for (let c = 0; c < N; c++) {
23 const rng = new Rng(rng0.u32());
24 const vocab = Array.from({ length: rng.int(1, 6) }, (_, i) => `v${i}\n`);
25 const n = HUGE ? rng.int(34000, 40000) : SNAKE ? rng.int(3000, 8000) : rng.int(50, 3000);
26 // --snake: long runs (snakes > 20) with many edits (cost > 256), where xdl_split samples diagonals heuristically
27 const a = SNAKE || HUGE ? Array.from({ length: n }, (_, i) => vocab[Math.floor(i / rng.int(25, 40)) % vocab.length]) : Array.from({ length: n }, () => rng.pick(vocab));
28 const b = a.slice(); const edits = HUGE ? rng.int(400, 3000) : SNAKE ? rng.int(300, 900) : rng.int(1, Math.max(2, n >> rng.int(1, 5)));
29 for (let k = 0; k < edits; k++) { const at = rng.int(0, b.length); const kind = rng.int(0, 2); if (kind === 0) b.splice(at, rng.int(1, 4)); else if (kind === 1) b.splice(at, 0, ...Array.from({ length: rng.int(1, 4) }, () => (rng.int(0, 3) ? rng.pick(vocab) : `n${rng.int(0, 9)}\n`))); else b[at] = rng.pick(vocab); }
30 const A = a.join(''), B = b.join('');
31 writeFileSync(join(dir, 'a'), A); writeFileSync(join(dir, 'b'), B);
32 // -U1, not -U0: with zero context xdi_diff runs trim_common_tail first (a merge never does), which moves where a pure
33 // insertion inside a run of identical lines lands. Changed lines are rebuilt from the hunk bodies.
34 const g = spawnSync(GIT_BIN, ['diff', '--no-index', '--no-color', '--histogram', '--no-indent-heuristic', '-U1', 'a', 'b'], { cwd: dir, maxBuffer: 1 << 26 }).stdout.toString();
35 const gitCh = { a: [], b: [] }; let la = 0, lb = 0, inHunk = false;
36 for (const line of g.split('\n')) {
37 const h = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/.exec(line);
38 if (h) { inHunk = true; la = h[2] === '0' ? +h[1] : +h[1] - 1; lb = h[4] === '0' ? +h[3] : +h[3] - 1; continue; } // 0-based next line
39 if (!inHunk) continue;
40 if (line[0] === '-') gitCh.a.push(la++); else if (line[0] === '+') gitCh.b.push(lb++); else if (line[0] === ' ') { la++; lb++; }
41 }
42 const cl = classifier(); const enc = s => new TextEncoder().encode(s);
43 let ours;
44 const ra = records(enc(A), cl), rb = records(enc(B), cl), meter = { steps: 0 };
45 const sc = diffScript(ra, rb, { rediff: REDIFF, meter });
46 if (!sc.ok) {
47 // A refusal passes only under a documented rule: --rediff undecided (the compaction re-diff), or the step budget
48 // (limits.ts), proven spent by the meter against the limit's own arithmetic. Anything else fails the run.
49 const budget = LIMIT_MERGE_WORK;
50 const ruled = (REDIFF === 'undecided' && sc.error.detail === 'compaction needs the classic-diff fallback') || (sc.error.detail === 'line diff step budget exceeded' && meter.steps > budget);
51 counts.undecided++;
52 if (!ruled) { refused++; if (refused <= 3) console.log(`REFUSED case ${c}: ${sc.error.detail} after ${meter.steps} steps (budget ${budget})`); }
53 continue;
54 }
55 { const oa = [], ob = [];
56 for (const x of [...sc.value].sort((p, q) => p.i1 - q.i1)) { for (let k = 0; k < x.chg1; k++) oa.push(x.i1 + k); for (let k = 0; k < x.chg2; k++) ob.push(x.i2 + k); }
57 ours = { a: oa, b: ob }; }
58 const gh = gitCh;
59 const same = JSON.stringify(ours) === JSON.stringify(gh);
60 counts[same ? 'same' : 'differ']++;
61 if (!same && bad.length < 3) { bad.push(c); console.log(`case ${c}: n=${n} vocab=${vocab.length} edits=${edits}\n git : ${JSON.stringify(gh).slice(0, 300)}\n ours: ${JSON.stringify(ours).slice(0, 300)}`); }
63rmSync(dir, { recursive: true, force: true });
64console.log(`${N} diffs (seed ${SEED}, rediff ${REDIFF}): ${JSON.stringify(counts)}`);
65// a refusal is not a pass: a diff that always declines would otherwise differ from nothing
66if (counts.differ || refused) { if (refused) console.log(`${refused} refused with no documented rule`); process.exit(1); }
Diagnostics4 git calls · 309 ms
CallStatusSizeTime0309 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=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=304
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
fetch2002.4 KiB304 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2493
git.response.cache=MISS
git.response.duration_ms=304
git.fetch.wants=4b8467c0ec706b8e8756541350fb17aad156ae4a
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=2493
git.pkt.payload.max=2472
git.sideband.band1.bytes=2471
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
a5e250b30b60b071
Request
47124ce0…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format