main
1// The push-outcome enumerator. Every cell of the space (push-outcome.space.js) is rendered, run through the real push
2// path (`push()` over a fake transport, no network) and compared with the table's expected outcome. No randomness: the
3// cells are the product of the axes, split across worker threads by index. Fails on any cell without an expected value
4// or whose outcome differs; prints cells explored / total. PUSH_SPACE_WORKERS sets the worker count.
5import { isMainThread, parentPort, workerData, Worker } from 'node:worker_threads';
6import { availableParallelism } from 'node:os';
7import * as space from './push-outcome.space.js';
8import { runPush, sameOutcome, label } from './harness.js';
10// The first factor (in this order) that makes a cell differ from a clean single-fault-free report: names a disagreement.
11export const cause = c => {
12 if (c.event.tag !== 'clean' && c.event.tag !== 'progress' && c.event.tag !== 'keepalive') return `event:${c.event.tag}`;
13 if (c.delivery.tag !== 'complete' && c.delivery.tag !== 'band1Split') return `delivery:${c.delivery.tag}`;
14 if (c.unpack.tag !== 'ok') return `unpack:${c.unpack.tag}`;
15 const tags = [...new Set(space.statuses(c).map(s => s.tag))].sort();
16 if (c.format.tag.endsWith('Options')) return `format:${c.format.tag}+${tags.join('+')}`;
17 return `statuses:${tags.join('+')}${c.atomic.tag === 'on' ? '/atomic' : ''}${c.commands.tag === 'deleteOnly' ? '/deleteOnly' : ''}`;
18};
20async function runShard(k, w) {
21 const out = { explored: 0, missing: 0, outcomes: {}, wrong: {}, samples: {} };
22 const todo = [];
23 const quick = process.env.PUSH_SPACE === 'quick';
24 Error.stackTraceLimit = 0; // speed: the stacks of the millions of expected errors are never read
25 out.census = space.walk(c => { if (quick && space.deviations(c) > space.QUICK_DEVIATIONS) return; if ((out.explored++ % w) === k) todo.push(c); });
26 out.total = out.explored;
27 out.explored = 0;
28 for (const c of todo) {
29 let want;
30 try { want = space.expected(c); } catch (e) { out.missing++; (out.samples.missing ??= []).push(`${space.cellId(c)}: ${e.message}`); continue; }
31 if (!want || !want.tag) { out.missing++; continue; }
32 const got = await runPush(space.render(c));
33 out.explored++;
34 out.outcomes[label(want)] = (out.outcomes[label(want)] ?? 0) + 1;
35 if (!sameOutcome(want, got)) {
36 const g = `${label(want)} -> ${label(got)} | ${cause(c)}`;
37 out.wrong[g] = (out.wrong[g] ?? 0) + 1;
38 const s = (out.samples[g] ??= []);
39 if (s.length < 2) s.push(`${space.cellId(c)} :: got ${JSON.stringify(got)}`);
40 }
41 }
42 return out;
43}
45if (!isMainThread) {
46 runShard(workerData.k, workerData.w).then(r => parentPort.postMessage(r));
47} else {
48 const { test } = await import('vitest');
49 const assert = (await import('node:assert/strict')).default;
51 // MUTATION=1 (vitest.stryker.config.ts): the two tests that are not about src/ are left out of the mutation run.
52 test('every tag of every axis has a meaning and a renderer (the match is exhaustive)', { skip: !!process.env.MUTATION }, () => {
53 for (const a of space.AXES) {
54 const tags = space.TAGS[a.name];
55 assert.deepEqual(Object.keys(space.MEANING[a.name]).sort(), [...tags].sort(), `MEANING.${a.name} covers exactly its tags`);
56 assert.equal(typeof space.RENDER[a.name], 'function', `RENDER.${a.name}`);
57 for (const v of a.variants) assert.ok(v.why && v.why.length > 8, `${a.name}.${v.tag} cites why`);
58 }
59 // the odd ref of a mixed report ranges over the same union as `status`
60 const odd = [...new Set(space.axis('spread').variants.filter(v => v.tag === 'mixed').map(v => v.odd.tag))].sort();
61 assert.deepEqual(odd, [...space.STATUS_TAGS].sort());
62 });
64 test('src/push.js and the space agree on git\'s unpack failure strings', async () => {
65 const { GIT_UNPACK_ERRORS } = await import('../../src/push.js');
66 assert.deepEqual([...GIT_UNPACK_ERRORS], space.GIT_UNPACK_ERRORS);
67 });
69 test('cells observed from git: git\'s bytes are the cell\'s rendering, ply\'s outcome is the table\'s, the server agrees', { timeout: 300_000, skip: !!process.env.MUTATION }, async () => {
70 const { observeAll } = await import('./push-outcome.observed.js');
71 const obs = await observeAll();
72 const ids = new Set();
73 for (const o of obs) {
74 ids.add(o.cellId);
75 assert.notEqual(o.bytesMatch, false, `${o.name}: git wrote bytes the cell does not render`);
76 assert.ok(o.eventMatch, `${o.name}: git's side-band extras ${JSON.stringify(o.sent)} are not event ${o.cell.event.tag}`);
77 assert.ok(sameOutcome(o.expected, o.got), `${o.name}: table ${JSON.stringify(o.expected)}, ply ${JSON.stringify(o.got)} (${o.error})`);
78 const all = o.cell.refs.n, moved = new Set(o.moved);
79 if (o.expected.tag === 'landed') assert.equal(moved.size, all, `${o.name}: landed but moved ${o.moved}`);
80 if (o.expected.tag === 'rejected') assert.equal(moved.size, 0, `${o.name}: rejected but moved ${o.moved}`);
81 if (o.expected.tag === 'partial') assert.deepEqual([...moved].sort(), [...o.expected.landed].sort(), `${o.name}: partial`);
82 }
83 const truth = obs.filter(o => o.expected.tag === 'ambiguous').map(o => `${o.name}: moved [${o.moved.join(', ')}]`);
84 console.log(` push-outcome: ${obs.length} git scenarios, ${ids.size} distinct cells observed from git; ambiguous cells' truth: ${truth.join('; ')}`);
85 });
87 // CPU-bound on 4 workers and shares the runner with the push-outcome-boundary slices, so it slows with the runner:
88 // 457 s of a 474 s file on main CI run 41908605477, and past the old 600 s bound on run 41920845654 (where the
89 // boundary file beside it was 36% slower too, 823 s vs 605 s, with no src change between). As for version-refname
90 // (#155), the bound is twice the shared CI time.
91 test('push outcome: every cell of the space through push(), against the table', { timeout: 1_200_000 }, async () => {
92 // PUSH_SPACE_WORKERS=0: every cell on this thread (the mutation run: Stryker's per-test coverage is recorded by the
93 // test process's main thread, so code reached only in a worker would count as uncovered).
94 const w = +(process.env.PUSH_SPACE_WORKERS ?? Math.min(4, availableParallelism()));
95 const t0 = performance.now();
96 const shards = w === 0 ? [await runShard(0, 1)] : await Promise.all(Array.from({ length: w }, (_, k) => new Promise((resolve, reject) => {
97 const wk = new Worker(new URL(import.meta.url), { workerData: { k, w } });
98 wk.once('message', resolve); wk.once('error', reject);
99 })));
100 const ms = performance.now() - t0;
101 const census = shards[0].census, total = shards[0].total;
102 assert.equal(Object.entries(census).filter(([k]) => k !== 'raw').reduce((n, [, v]) => n + v, 0), census.raw, 'the census accounts for every raw cell');
103 const sum = { explored: 0, missing: 0, outcomes: {}, wrong: {}, samples: {} };
104 for (const s of shards) {
105 sum.explored += s.explored; sum.missing += s.missing;
106 for (const [k, v] of Object.entries(s.outcomes)) sum.outcomes[k] = (sum.outcomes[k] ?? 0) + v;
107 for (const [k, v] of Object.entries(s.wrong)) sum.wrong[k] = (sum.wrong[k] ?? 0) + v;
108 for (const [k, v] of Object.entries(s.samples)) (sum.samples[k] ??= []).push(...v);
109 }
110 const wrong = Object.values(sum.wrong).reduce((a, b) => a + b, 0);
111 console.log(` push-outcome${process.env.PUSH_SPACE === 'quick' ? ` (quick: ≤ ${space.QUICK_DEVIATIONS} deviations, ${census.cells} cells in the space)` : ''}: cells explored ${sum.explored} / ${total} (raw product ${census.raw}) in ${(ms / 1000).toFixed(1)} s on ${w} workers; expected ${JSON.stringify(sum.outcomes)}; disagree ${wrong}`);
112 for (const [g, n] of Object.entries(sum.wrong).sort((a, b) => b[1] - a[1])) console.log(` ${String(n).padStart(8)} ${g}\n e.g. ${sum.samples[g][0]}`);
113 if (process.env.PUSH_SPACE !== 'quick') {
114 const doc = await import('../../scripts/space-md.mjs');
115 assert.equal(doc.current(), doc.block({ census, outcomes: sum.outcomes }), 'SPACE.md is stale: run node scripts/space-md.mjs --write');
116 }
117 assert.equal(sum.missing, 0, 'cells without an expected outcome');
118 assert.equal(sum.explored, total, 'every cell explored');
119 assert.equal(wrong, 0, 'cells whose outcome differs from the table');
120 });
121}
Diagnostics4 git calls · 35 ms
CallStatusSizeTime035 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=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 · hit7 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=38434 git.response.cache=HIT git.response.duration_ms=7 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.response.bytes=3426 git.response.cache=HIT git.response.duration_ms=25 git.fetch.wants=511464798771d75fbb9ae8fe44f347ffa7401e22 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=3426 git.pkt.payload.max=3405 git.sideband.band1.bytes=3404 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
- a5e2fe8c6d95f3c9
- Request
- f11fae9a…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format