GitHubivarvong

ply

main
ply6 git calls174 ms20 KiB3 cachedprotocol v2
58 lines3.6 KiBRaw
1// A ratchet baseline may move the unsafe way only in a commit that says so. Each baseline's own script compares the
2// tree with the baseline, so a change that edits both passes it; this compares the baseline with the base commit's.
3// node scripts/ratchet-guard.mjs [<base>] base: the argument, else $RATCHET_BASE, else origin/main
4// A loosened baseline fails unless a commit in <merge-base>..HEAD carries, on a line of its own,
5// Ratchet-Change: <file>: <reason>
6// Loosened means: throw-baseline's count rose; an absence-baseline count rose or its boundary changed; a category of
7// test/space/ratchet.json gained a hole id or was removed; test/durations.json lost the entry of a test file that
8// still exists (it would be planned as the heaviest file). A baseline the base does not have is new, not loosened.
9import { execFileSync } from 'node:child_process';
10import { existsSync, readFileSync } from 'node:fs';
11import { pathToFileURL } from 'node:url';
13const rose = (base, head) => Object.keys(base).filter(k => typeof base[k] === 'number')
14 .flatMap(k => (typeof head[k] !== 'number' ? [`${k} removed`] : head[k] > base[k] ? [`${k} rose ${base[k]} -> ${head[k]}`] : []));
16export const BASELINES = {
17 'scripts/throw-baseline.json': rose,
18 'scripts/absence-baseline.json': (base, head) => [...(head.boundary === base.boundary ? [] : [`boundary ${base.boundary} -> ${head.boundary}`]), ...rose(base, head)],
19 'test/space/ratchet.json': (base, head) => Object.entries(base.categories ?? {}).flatMap(([c, { ids }]) => {
20 const now = head.categories?.[c];
21 if (!now) return [`category ${c} removed`];
22 const had = new Set(ids);
23 return now.ids.filter(id => !had.has(id)).map(id => `${c} gained hole ${id}`);
24 }),
25 'test/durations.json': (base, head, exists) => Object.keys(base).filter(f => !(f in head) && exists(f)).map(f => `${f} lost its weight`),
26};
28// The ways `file` moved the unsafe way between two versions of its text; [] when it did not.
29export function loosened(file, baseText, headText, exists = existsSync) {
30 if (baseText === null) return [];
31 if (headText === null) return ['baseline deleted'];
32 return BASELINES[file](JSON.parse(baseText), JSON.parse(headText), exists);
35function main() {
36 const git = (...args) => execFileSync('git', args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
37 const ref = process.argv[2] ?? (process.env.RATCHET_BASE || 'origin/main');
38 let base;
39 try { base = git('merge-base', ref, 'HEAD').trim(); } catch {
40 console.error(`ratchet-guard: cannot resolve base '${ref}' (fetch it; CI needs fetch-depth: 0)`);
41 process.exit(1);
42 }
43 const marked = new Set([...git('log', '--format=%B', `${base}..HEAD`).matchAll(/^Ratchet-Change: (\S+): \S.*$/gmu)].map(m => m[1]));
44 let failed = false;
45 for (const file of Object.keys(BASELINES)) {
46 let baseText = null;
47 try { baseText = git('show', `${base}:${file}`); } catch { /* not in the base: a new baseline */ }
48 const why = loosened(file, baseText, existsSync(file) ? readFileSync(file, 'utf8') : null);
49 if (why.length === 0) continue;
50 if (marked.has(file)) { console.log(`ratchet-guard: ${file} loosened (${why.length}), declared by Ratchet-Change`); continue; }
51 failed = true;
52 console.error(`ratchet-guard: ${file} moved the unsafe way against ${base.slice(0, 7)}:\n${why.slice(0, 20).map(w => ` ${w}`).join('\n')}${why.length > 20 ? `\n ... ${why.length - 20} more` : ''}\n a commit must carry the line 'Ratchet-Change: ${file}: <reason>'`);
53 }
54 if (failed) process.exit(1);
55 console.log(`ratchet-guard: no undeclared loosening against ${base.slice(0, 7)}`);
58if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) main();
Diagnostics6 git calls · 174 ms
CallStatusSizeTime0174 ms
discover200191 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=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 KiB86 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=81
git.response.bytes=11990
git.response.cache=EXPIRED
git.response.duration_ms=86
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 · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=4
git.response.bytes=4347
git.response.cache=HIT
git.response.duration_ms=4
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=10
Open 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=5323b9266eea5ded637285d1c5320699f12be76e
Open pack map
fetchtree:0200831 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=831
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=b9290e370bd091fd3272931655a175dd1a7af82d
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=831
git.pkt.payload.max=804
git.sideband.band1.bytes=804
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=804
git.pack.trailer=81ddc1f73214935b4ee953ad84f959db955ce0d1
Open pack map
fetch2001.7 KiB80 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=80
git.response.bytes=1724
git.response.cache=MISS
git.response.duration_ms=80
git.fetch.wants=eca27b7811f4c0584616d9c7bf8711954b4d1f37
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=1724
git.pkt.payload.max=1697
git.sideband.band1.bytes=1697
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
a5e1b487fb6e5b65
Request
6d56158f…
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