GitHubivarvong
ply
main
1// The push-ng space (push-ng.space.js): every rejection reason git v2.50.0's receive-pack writes × the failing command's
2// shape × atomic × refs. Every cell's report goes through push() over the fake transport and must give the class
3// table's outcome; every cell git can be made to write is observed from real git (push-ng.observed.js): git's bytes must
4// be the derived report, ply's outcome on them the table's, and the repository's refs must agree. SPACE.md's "Push ng
5// reasons" block is generated here (PUSH_NG_WRITE=1 rewrites it). PUSH_NG_ONLY=<reason tag> observes one reason.
6import { test } from 'vitest';
7import assert from 'node:assert/strict';
8import { readFileSync, writeFileSync } from 'node:fs';
9import * as space from './push-ng.space.js';
10import { runPush, sameOutcome, label } from './harness.js';
12const SPACE_MD = new URL('../../SPACE.md', import.meta.url);
13const START = '<!-- push-ng: generated by test/space/push-ng.test.js (PUSH_NG_WRITE=1); do not edit by hand -->';
14const END = '<!-- push-ng: end generated -->';
16test('the reason axis is git\'s list: every "reject" entry of git-manifest.json, each with a class and its reason', () => {
17 assert.equal(space.GIT_SOURCE.tag, 'v2.50.0');
18 assert.deepEqual(space.REASONS.map(r => r.id).sort(), space.MANIFEST_REJECTS.map(e => e.id).sort(), 'REASONS covers exactly the manifest\'s reject ids');
19 for (const r of space.REASONS) {
20 assert.ok(space.CLASSES.includes(r.cls), `${r.id}: class ${r.cls}`);
21 assert.ok(space.STAGES.includes(r.stage), `${r.id}: stage ${r.stage}`);
22 assert.ok(r.next?.length > 40, `${r.id}: says what a caller can safely do next`);
23 assert.ok(r.derived === undefined || r.derived.length > 30, `${r.id}: a derived reason says why it is not observed`);
24 assert.ok(Array.isArray(r.commands), `${r.id}: commands`);
25 }
26 // the consequences have no cell of their own; every other reason has cells
27 const census = {}; space.walk(c => { census[c.reason.tag] = (census[c.reason.tag] ?? 0) + 1; });
28 for (const v of space.axis('reason').variants) assert.ok(census[v.tag] > 0, `${v.tag} has cells`);
29});
31test('src/push.js and the space agree on git\'s unpack failure strings', async () => {
32 const { GIT_UNPACK_ERRORS } = await import('../../src/push.js');
33 assert.deepEqual([...GIT_UNPACK_ERRORS].sort(), space.REASONS.filter(r => r.stage === 'unpack').map(r => r.text).sort());
34});
36const outcomes = {};
37test('push ng: every cell through push(), against the class table', async () => {
38 Error.stackTraceLimit = 0;
39 const census = space.walk();
40 const wrong = [];
41 let n = 0;
42 for (const c of space.cells()) {
43 const want = space.expected(c), got = await runPush(space.render(c));
44 n++;
45 outcomes[label(want)] = (outcomes[label(want)] ?? 0) + 1;
46 if (!sameOutcome(want, got)) wrong.push(`${space.cellId(c)}: table ${label(want)}, ply ${label(got)}`);
47 }
48 Error.stackTraceLimit = 10;
49 console.log(` push-ng: cells ${n} (raw product ${census.raw}; impossible ${census.impossible.join(' + ')}); expected ${JSON.stringify(outcomes)}; disagree ${wrong.length}`);
50 for (const w of wrong.slice(0, 20)) console.log(` ${w}`);
51 assert.equal(n, census.cells);
52 assert.deepEqual(wrong, [], 'cells whose outcome differs from the table');
53});
55test('push ng: cells observed from git — git\'s report is the derived one, ply\'s outcome the table\'s, the refs agree', { timeout: 600_000 }, async () => {
56 const { observeAll } = await import('./push-ng.observed.js');
57 const only = process.env.PUSH_NG_ONLY;
58 const t0 = performance.now();
59 const { results, derived, rootUser, era, version } = await observeAll({ only });
60 const ms = performance.now() - t0;
61 const problems = [], truth = {};
62 for (const o of results) {
63 const want = space.expected(o.cell);
64 const derivedBytes = Buffer.from(space.reportBytes(space.gitReport(o.cell))).toString();
65 const gitBytes = Buffer.from(o.bytes).toString();
66 if (gitBytes !== derivedBytes) { problems.push(`${o.id}: git wrote ${JSON.stringify(gitBytes)}, derived ${JSON.stringify(derivedBytes)}`); continue; }
67 const got = await runPush({ commands: o.commands, opts: { sideband: false, reportV2: false, atomic: o.cell.atomic.tag === 'on', pushOptions: [] }, limits: { maxRefs: 8, maxReportLines: 16, maxPackBytes: 1 << 20 } }, { bytes: o.bytes, end: 'eof' });
68 if (!sameOutcome(want, got)) problems.push(`${o.id}: table ${label(want)}, ply ${label(got)}`);
69 const moved = new Set(o.moved), refs = o.commands.map(x => x.ref);
70 const wantMoved = want.tag === 'landed' ? refs : want.tag === 'partial' ? want.landed : want.tag === 'rejected' ? [] : null;
71 if (wantMoved && (wantMoved.length !== moved.size || !wantMoved.every(r => moved.has(r)))) problems.push(`${o.id}: ${label(want)} but git moved [${o.moved}]`);
72 if (want.tag === 'ambiguous') { const k = `${o.cell.reason.tag}: moved ${o.moved.length}/${refs.length}`; truth[k] = (truth[k] ?? 0) + 1; }
73 }
74 console.log(` push-ng: observed from git ${version} (era ${era}) ${results.length} cells in ${(ms / 1000).toFixed(1)} s, derived ${derived.length}${rootUser ? ' (root: permission recipes derived)' : ''}; ambiguous cells' truth: ${Object.entries(truth).map(([k, v]) => `${k} ×${v}`).join('; ')}`);
75 for (const p of problems.slice(0, 20)) console.log(` ${p}`);
76 assert.deepEqual(problems, []);
77 if (!only) assert.equal(results.length + derived.length, space.walk().cells);
78});
80test('SPACE.md\'s push-ng block is current', async t => {
81 if (process.env.PUSH_NG_ONLY) return t.skip('PUSH_NG_ONLY');
82 const { observableAnywhere: observable } = await import('./push-ng.observed.js');
83 const per = new Map();
84 space.walk(c => { const p = per.get(c.reason.tag) ?? { cells: 0, observed: 0, codes: new Set() }; p.cells++; if (observable(c)) p.observed++; p.codes.add(label(space.expected(c))); per.set(c.reason.tag, p); });
85 const census = space.walk();
86 const totalObserved = [...per.values()].reduce((a, p) => a + p.observed, 0);
87 const L = [START, ''];
88 L.push(`Axes: ${space.AXES.map(a => `${a.name}(${a.variants.length})`).join(' × ')} = ${census.raw} raw; ${census.cells} cells after the impossible ones (${space.IMPOSSIBLE.map((r, i) => `${census.impossible[i]}: ${r.why}`).join('; ')}).`, '');
89 L.push(`Observable from real git: **${totalObserved}** cells (git's report byte for byte = the derived one, ply's outcome = the table's, refs agree), each on the git of its era: v2.50 cells on git 2.50 (a laptop), v2.51+ cells on git >= 2.51 (CI: 2.56); a run observes its own era's cells and derives the rest. Derived from receive-pack.c only: **${census.cells - totalObserved}** (on a run as root, the two permission recipes are derived too).`, '');
90 L.push('| reason (receive-pack.c line) | class | ply outcomes over its cells | cells (observed) | what a caller can safely do next |', '|---|---|---|---|---|');
91 for (const r of space.REASONS) {
92 const tag = r.id.replace('receive-pack.c:reject:', '');
93 const p = per.get(tag);
94 const cells = p ? `${p.cells} (${p.observed})` : `— (${r.stage === 'none' ? 'a consequence: rides on other cells' : 'none'})`;
95 L.push(`| \`${r.text}\` (${r.line}${tag.endsWith('#2') ? ', 2nd site' : ''}) | ${r.cls} | ${p ? [...p.codes].sort().join(', ') : '—'} | ${cells} | ${r.next}${r.derived ? ` *Derived:* ${r.derived}.` : ''} |`);
96 }
97 L.push('', 'git >= 2.51 batched texts (era v2.51+, the non-atomic commit failure):', '', '| text | class | what a caller can safely do next |', '|---|---|---|');
98 for (const b of space.BATCHED) L.push(`| \`${b.text}\` | ${b.cls} | ${b.next} |`);
99 L.push('', END);
100 const block = L.join('\n');
101 const md = readFileSync(SPACE_MD, 'utf8');
102 const i = md.indexOf(START), j = md.indexOf(END);
103 if (process.env.PUSH_NG_WRITE) {
104 const next = i >= 0 ? md.slice(0, i) + block + md.slice(j + END.length) : `${md.trimEnd()}\n\n## Push ng reasons\n\nThe space of git's receive-pack rejection reasons (test/space/push-ng.space.js): every reason git v2.50.0 can write × the failing command's shape × atomic × refs. Each reason's class is data, justified by what a caller can safely do next; the report git writes for each cell is derived from receive-pack.c and checked byte for byte against real git where git can be made to write it (test/space/push-ng.observed.js).\n\n${block}\n`;
105 writeFileSync(SPACE_MD, next);
106 return;
107 }
108 assert.ok(i >= 0 && j > i, 'SPACE.md has no push-ng block: run PUSH_NG_WRITE=1 npx vitest run test/space/push-ng.test.js');
109 assert.equal(md.slice(i, j + END.length), block, 'SPACE.md push-ng block is stale: run PUSH_NG_WRITE=1 npx vitest run test/space/push-ng.test.js');
110});
Diagnostics7 git calls · 31 ms
CallStatusSizeTime031 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 · 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=5724 git.response.cache=HIT git.response.duration_ms=3 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:02001.4 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=1428 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=74d7bb09987bbe78a9c0ea8f43a1b5a4e079f538 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=1428 git.pkt.payload.max=1401 git.sideband.band1.bytes=1401 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=1401 git.pack.trailer=65ea1a3aeef333a80a2dfa3f441e629d90497e8eOpen pack map
fetch2003.3 KiB · hit19 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=18 git.response.bytes=3430 git.response.cache=HIT git.response.duration_ms=19 git.fetch.wants=324e86d791ad15cf024c21104b9abc1f1bb98c87 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=3430 git.pkt.payload.max=3403 git.sideband.band1.bytes=3403 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
- a5e2c19e8c2789da
- Request
- 8d1b08a2…
- 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