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});
Diagnostics4 git calls · 30 ms
CallStatusSizeTime030 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs 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 · 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=55Open pack map
fetch2003.3 KiB · hit25 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=25 git.response.bytes=3430 git.response.cache=HIT git.response.duration_ms=25 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=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=3430 git.pkt.payload.max=3409 git.sideband.band1.bytes=3408 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
- a5e2d7f4e9d514c2
- Request
- 21dd504b…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format