Artifactspublic-v0

ply

main
ply4 git calls28 ms40 KiB2 cachedprotocol v2
121 lines7.4 KiBRaw
1// Generates the machine-checked parts of SPACE.md: the "Fsck tree entries" section from test/space/fsck-tree.space.js
2// (checked by test/space/fsck-tree.test.js), and the "Push outcome" section from test/space/push-outcome.space.js:
3// the axes (tagged unions) and their variants, the product size, the impossible and collapsed cells, the cell count,
4// the expected outcomes, and the cells observed from git. test/space/push-outcome.test.js fails if SPACE.md drifts.
5// node scripts/space-md.mjs print the block
6// node scripts/space-md.mjs --write rewrite it in SPACE.md
7import { readFileSync, writeFileSync } from 'node:fs';
8import { fileURLToPath } from 'node:url';
9import * as space from '../test/space/push-outcome.space.js';
10import { SCENARIOS, cellOf } from '../test/space/push-outcome.observed.js';
11import * as fsckTree from '../test/space/fsck-tree.space.js';
12import * as adv from '../test/space/advertisement.space.js';
14export const START = '<!-- push-outcome: generated by scripts/space-md.mjs; do not edit by hand -->';
15export const END = '<!-- push-outcome: end generated -->';
16const SPACE_MD = fileURLToPath(new URL('../SPACE.md', import.meta.url));
18const payload = v => Object.entries(v).filter(([k]) => !['tag', 'why', 'n'].includes(k)).map(([k, x]) => `${k}=${typeof x === 'object' ? x.tag : JSON.stringify(x)}`).join(', ');
19const label = o => (o.tag === 'rejected' || o.tag === 'preSend' ? `${o.tag}(${o.code})` : o.tag);
21export function observedCells() {
22 const by = new Map();
23 for (const [name, spec] of SCENARIOS) { const id = space.cellId(cellOf(spec)); by.set(id, [...(by.get(id) ?? []), name]); }
24 return by;
27export function census() {
28 const outcomes = {};
29 const c = space.walk(cell => { const k = label(space.expected(cell)); outcomes[k] = (outcomes[k] ?? 0) + 1; });
30 return { census: c, outcomes };
33export function block({ census: c, outcomes }) {
34 const L = [START, ''];
35 L.push('### Axes (tagged unions)', '');
36 for (const a of space.AXES) {
37 if (a.name === 'spread') {
38 L.push(`**${a.name}** — ${a.doc} (${a.variants.length} variants)`, '');
39 L.push('- `uniform` — every ref has `status`');
40 L.push(`- \`mixed\` — at ∈ {0, 1, 2} × odd ∈ the ${space.STATUS_TAGS.length} \`status\` tags: ${a.variants.length - 1} variants (the odd ref's status overrides \`status\` for ref \`at\`)`, '');
41 continue;
42 }
43 L.push(`**${a.name}** — ${a.doc} (${a.variants.length} variants)`, '');
44 for (const v of a.variants) L.push(`- \`${v.tag}\`${payload(v) ? ` (${payload(v)})` : ''} — ${v.why}`);
45 L.push('');
46 }
47 L.push('### Product', '');
48 L.push(`Raw product: ${space.AXES.map(a => `${a.variants.length}`).join(' × ')} = **${c.raw.toLocaleString('en-US')}** (${space.AXES.map(a => a.name).join(' × ')}).`, '');
49 L.push('| removed | why | raw cells |', '|---|---|---:|');
50 space.IMPOSSIBLE.forEach((r, i) => L.push(`| impossible | ${r.why} | ${(c[`impossible:${i}`] ?? 0).toLocaleString('en-US')} |`));
51 space.COLLAPSE.forEach((r, i) => L.push(`| collapsed | ${r.why} (${r.axes.join(', ')} keep their first variant) | ${(c[`collapsed:${i}`] ?? 0).toLocaleString('en-US')} |`));
52 L.push('');
53 L.push(`**Cells: ${c.cells.toLocaleString('en-US')}.** Expected outcomes: ${Object.entries(outcomes).sort((a, b) => b[1] - a[1]).map(([k, n]) => `${k} ${n.toLocaleString('en-US')}`).join(', ')}.`, '');
54 const obs = observedCells();
55 L.push(`### Observed from git (${obs.size} cells; the other ${(c.cells - obs.size).toLocaleString('en-US')} are derived)`, '');
56 for (const [id, names] of obs) L.push(`- \`${id}\` — ${names.join('; ')}`);
57 L.push('', END);
58 return L.join('\n');
61export function splice(md, generated) {
62 const a = md.indexOf(START), b = md.indexOf(END);
63 if (a < 0 || b < 0) throw new Error('SPACE.md has no generated push-outcome block');
64 return md.slice(0, a) + generated + md.slice(b + END.length);
66// ---- the fsck tree-entry section ----
67export const FT_START = '<!-- fsck-tree: generated by scripts/space-md.mjs; do not edit by hand -->';
68export const FT_END = '<!-- fsck-tree: end generated -->';
69const show = b => `"${b.toString('latin1').replace(/[^\x20-\x7e]/g, ch => `\\x${ch.charCodeAt(0).toString(16).padStart(2, '0')}`).replace(/([lm])\1{4095,}/, (m, ch) => `${ch}×${m.length}`)}"`;
70export function fsckTreeBlock() {
71 const L = [FT_START, ''];
72 L.push('### Axes (tagged unions)', '');
73 for (const a of fsckTree.AXES) {
74 L.push(`**${a.name}** — ${a.doc} (${a.variants.length} variants)`, '');
75 for (const v of a.variants) {
76 const what = v.raw !== undefined ? ` \`${v.raw}\`` : v.bytes ? ` ${show(v.bytes)}` : v.entry && v.entry !== 'same' ? ` \`${v.entry.mode} ${show(v.entry.name).slice(1, -1)}\`` : '';
77 L.push(`- \`${v.tag}\`${what} — ${v.why}`);
78 }
79 L.push('');
80 }
81 const cells = fsckTree.product();
82 const raw = fsckTree.AXES.reduce((n, a) => n * a.variants.length, 1);
83 const by = {}, ids = {};
84 for (const c of cells) {
85 const w = fsckTree.expected(c);
86 by[w.ply] = (by[w.ply] ?? 0) + 1;
87 for (const m of w.errors) ids[m] = (ids[m] ?? 0) + 1;
88 for (const m of w.warnings) ids[`${m} (warning)`] = (ids[`${m} (warning)`] ?? 0) + 1;
89 }
90 L.push('### Product', '');
91 L.push(`Raw product: ${fsckTree.AXES.map(a => a.variants.length).join(' × ')} = **${raw.toLocaleString('en-US')}** (${fsckTree.AXES.map(a => a.name).join(' × ')}); ${fsckTree.COLLAPSE.map(r => r.why).join('; ')}: **${cells.length.toLocaleString('en-US')} cells**.`, '');
92 L.push(`Expected: ply accepts ${(by.accept ?? 0).toLocaleString('en-US')}, refuses ${(by.refuse ?? 0).toLocaleString('en-US')}. Cells per msgId git reports (a cell can have several):`, '');
93 L.push('| msgId | cells |', '|---|---:|');
94 for (const [m, n] of Object.entries(ids).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))) L.push(`| \`${m}\` | ${n.toLocaleString('en-US')} |`);
95 L.push('', '### Decisions for the warnings git exits 0 on', '');
96 for (const [m, d] of Object.entries(fsckTree.WARN_DECISION)) L.push(`- \`${m}\` → ${d.ply}: ${d.why}`);
97 L.push('', FT_END);
98 return L.join('\n');
100export function spliceFsckTree(md, generated) {
101 const a = md.indexOf(FT_START), b = md.indexOf(FT_END);
102 if (a < 0 || b < 0) throw new Error('SPACE.md has no generated fsck-tree block');
103 return md.slice(0, a) + generated + md.slice(b + FT_END.length);
105export const currentFsckTree = () => { const md = readFileSync(SPACE_MD, 'utf8'); return md.slice(md.indexOf(FT_START), md.indexOf(FT_END) + FT_END.length); };
107export const current = () => { const md = readFileSync(SPACE_MD, 'utf8'); return md.slice(md.indexOf(START), md.indexOf(END) + END.length); };
108// the advertisement section's block (test/space/advertisement.space.js mdBlock)
109export const currentAdvertisement = () => { const md = readFileSync(SPACE_MD, 'utf8'); return md.slice(md.indexOf(adv.MD_START), md.indexOf(adv.MD_END) + adv.MD_END.length); };
110const spliceAdvertisement = (md, generated) => {
111 const a = md.indexOf(adv.MD_START), b = md.indexOf(adv.MD_END);
112 if (a < 0 || b < 0) throw new Error('SPACE.md has no generated advertisement block');
113 return md.slice(0, a) + generated + md.slice(b + adv.MD_END.length);
114};
116if (process.argv[1] === fileURLToPath(import.meta.url)) {
117 const g = block(census()), ft = fsckTreeBlock();
118 const ga = adv.mdBlock(adv.observedCounts());
119 if (process.argv.includes('--write')) writeFileSync(SPACE_MD, spliceAdvertisement(spliceFsckTree(splice(readFileSync(SPACE_MD, 'utf8'), g), ft), ga));
120 else console.log(`${g}\n\n${ft}\n\n${ga}`);
Diagnostics4 git calls · 28 ms
CallStatusSizeTime028 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 B2 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=UPDATING
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 · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=22
git.response.bytes=38434
git.response.cache=HIT
git.response.duration_ms=3
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.6 KiB · hit22 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2658
git.response.cache=HIT
git.response.duration_ms=22
git.fetch.wants=7ecc120e99f131e9c9af287be0547208c4c9c3e8
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=2658
git.pkt.payload.max=2637
git.sideband.band1.bytes=2636
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
a5e17029ea466102
Request
a2ed3aba…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format