Artifactspublic-v0

ply

main
ply4 git calls630 ms41 KiB2 cachedprotocol v2
120 lines9.0 KiBRaw
1// Gates a and b, the registry's own consistency, and SPACES.md drift. See test/space/holes.js for the categories and the
2// ratchet; `npm run spaces --` prints the same report.
3import { test } from 'vitest';
4import assert from 'node:assert/strict';
5import { readFileSync, mkdtempSync, rmSync } from 'node:fs';
6import { join } from 'node:path';
7import { tmpdir } from 'node:os';
8import { spawnSync } from 'node:child_process';
9import { compute, judge, registryProblems, readRecords, ROOT, ratchet, frameOf } from './holes.js';
10import { SPACES, DECISIONS, SAMPLED } from './registry.js';
11import { renderMd } from '../../scripts/spaces.mjs';
13const all = compute();
14const show = (cat, v) => {
15 console.log(`${cat}: ${v.mode} ${v.count} hole(s) (ratchet ${v.stored})${v.fixed.length ? `; ${v.fixed.length} fixed since the ratchet: lower it with \`npm run spaces -- --ratchet\`` : ''}`);
16 for (const id of (v.mode === 'ENFORCE' ? v.problems : all.holes[cat]).slice(0, 400)) console.log(` ${v.problems.includes(id) ? 'NEW ' : ''}${id}`);
17};
18const gate = (cat, what) => () => {
19 const v = judge(cat, all.holes[cat]);
20 show(cat, v);
21 assert.deepEqual(v.problems, [], `${cat}: ${v.problems.length} ${what} (${v.mode}):\n ${v.problems.join('\n ')}`);
22};
24test('the ratchet: REPORT passes known holes and fails a new one; ENFORCE (stored 0) fails any; a fixed hole passes', () => {
25 const report = judge('x', ['a', 'b'], { count: 3, ids: ['a', 'b', 'c'] });
26 assert.equal(report.mode, 'REPORT');
27 assert.deepEqual(report.problems, []);
28 assert.deepEqual(report.fixed, ['c']);
29 assert.deepEqual(judge('x', ['a', 'd'], { count: 3, ids: ['a', 'b', 'c'] }).problems, ['d'], 'a hole not in the ratchet fails even when the count went down');
30 const enforce = judge('x', ['a'], { count: 0, ids: [] });
31 assert.equal(enforce.mode, 'ENFORCE');
32 assert.deepEqual(enforce.problems, ['a']);
33});
35test('the registry is well-formed: every rule names a registered space and one of its axes, or gives a reason', () => {
36 assert.deepEqual(registryProblems(), []);
37});
39test('a pending space whose runners are all in the tree is a registry problem (it is merged)', () => {
40 const base = { kind: 'curated', run: 'ci', oracle: 'hand', axes: [{ tag: 'x' }] };
41 // this very file exists, so a space that names it as its runner cannot be pending
42 assert.deepEqual(registryProblems([{ ...base, name: 'synthetic', status: 'pending', pending: '#1', runners: ['test/space/registry.test.js'] }]),
43 ["space synthetic: pending (#1) but every runner is in the tree; it is merged: status: 'main'"]);
44 // a runner that is not in the tree yet: still pending, no problem
45 assert.deepEqual(registryProblems([{ ...base, name: 'synthetic', status: 'pending', pending: '#1', runners: ['test/not-written-yet.test.js'] }]), []);
46});
48test('observed: a fail site a runner reached while no test read the error is a hole, not a covered site', () => {
49 // Expected values are stated here, not derived from compute(): one real site, reached by one runner. With no
50 // observation data the records are not judged (null); with it, the site is a hole until some runner's record says a
51 // test read that error; a site nobody reached is a failsites hole and not an observed one.
52 const sampled = new Set(SAMPLED.map(s => s.id));
53 const site = all.sites.find(p => !sampled.has(p.id) && !('excluded' in (all.dec.by.get(p.id) ?? {})));
54 const runner = 'test/no-assert.test.js';
55 const base = { frames: new Map([[frameOf(site), new Set([runner])]]), runners: new Set([runner]), platforms: new Map() };
56 assert.equal(compute({ records: base }).holes.observed, null, 'records without observation data are not judged');
57 assert.deepEqual(compute({ records: { ...base, observed: new Map() } }).holes.observed, [site.id], 'reached, the error never read');
58 assert.deepEqual(compute({ records: { ...base, observed: new Map([[frameOf(site), new Set([runner])]]) } }).holes.observed, [], 'reached and read');
59 assert.deepEqual(compute({ records: { frames: new Map(), runners: new Set([runner]), platforms: new Map(), observed: new Map() } }).holes.observed, [], 'not reached: a failsites hole only');
60});
62test('observed: the recorder marks a site only when code outside src/ read the error\'s code', () => {
63 // Four node processes under the recorder, each building one error with errors.ts `fail` from a script outside src/.
64 // By hand: the stack at plyError holds exactly one src/ frame (fail's call), so each record has one frame. It is
65 // observed only where the script itself reads .code; a script that drops the result, lets only src/errors.ts read
66 // the code (isPlyError), or reads only .message (left a data property: a structured clone keeps it) observed nothing.
67 const dir = mkdtempSync(join(tmpdir(), 'ply-observed-'));
68 const run = (name, body) => {
69 const out = join(dir, name);
70 const script = `import { fail, isPlyError } from './src/errors.ts';\nconst r = fail('bad_request', 'seeded');\n${body}`;
71 const r = spawnSync(process.execPath, ['--import', './test/ts-resolve.mjs', '--import', './test/space/failsite-hook.mjs', '--input-type=module', '-e', script], { cwd: ROOT, env: { ...process.env, PLY_FAILSITES: out, NODE_OPTIONS: '' }, encoding: 'utf8' });
72 assert.equal(r.status, 0, `${name}: ${r.stderr}`);
73 const rec = readRecords(out);
74 assert.equal(rec.frames.size, 1, `${name}: one src frame`);
75 assert.match([...rec.frames.keys()][0], /^src\/errors\.ts:\d+:\d+$/, name);
76 return { frames: [...rec.frames.keys()], observed: [...(rec.observed?.keys() ?? ['(no observation data)'])] };
77 };
78 try {
79 assert.deepEqual(run('reach-only', 'void r;').observed, [], 'reached, result dropped');
80 assert.deepEqual(run('src-read', 'if (!isPlyError(r.error)) process.exit(3);').observed, [], 'only src/ read the code');
81 const code = run('code-read', "if (r.error.code !== 'bad_request') process.exit(3);");
82 assert.deepEqual(code.observed, code.frames, 'the script read .code');
83 const message = run('message-read', "if (r.error.message !== 'seeded') process.exit(3);");
84 assert.deepEqual(message.observed, [], 'the script read only .message');
85 } finally { rmSync(dir, { recursive: true, force: true }); }
86});
88test('claims: a site claimed by a space whose runner ran without reaching it is a hole, pending or merged', () => {
89 // One real fail site, claimed by exact rule (an exact rule wins over every glob) for a synthetic space with one
90 // runner. Expected values are stated here, not derived from compute(): the runner ran and reached nothing, so the
91 // one claim is the one hole; once that runner's record holds the site's frame, there is none.
92 const sampled = new Set(SAMPLED.map(s => s.id));
93 const site = all.sites.find(p => !sampled.has(p.id));
94 const runner = 'test/synthetic-runner.test.js';
95 for (const status of ['pending', 'main']) {
96 const spaces = [...SPACES, { name: 'synthetic', status, pending: '#1', kind: 'curated', run: 'manual', oracle: 'hand', axes: [{ tag: 'x' }], runners: [runner] }];
97 // last in the list: among exact rules for one id the later wins (resolve() keeps a Map by match)
98 const decisions = [...DECISIONS, { match: site.id, space: 'synthetic', axisTag: 'x' }];
99 const ran = { frames: new Map(), runners: new Set([runner]), platforms: new Map() };
100 assert.deepEqual(compute({ records: ran, spaces, decisions }).holes.claims.filter(h => h.endsWith(' -> synthetic')), [`${site.id} -> synthetic`], `${status}: reached by nobody`);
101 const other = { frames: new Map([[frameOf(site), new Set(['test/some-other.test.js'])]]), runners: new Set([runner, 'test/some-other.test.js']), platforms: new Map() };
102 assert.deepEqual(compute({ records: other, spaces, decisions }).holes.claims.filter(h => h.endsWith(' -> synthetic')), [`${site.id} -> synthetic`], `${status}: reached only by another runner`);
103 const reached = { frames: new Map([[frameOf(site), new Set([runner])]]), runners: new Set([runner]), platforms: new Map() };
104 assert.deepEqual(compute({ records: reached, spaces, decisions }).holes.claims.filter(h => h.endsWith(' -> synthetic')), [], `${status}: reached by its runner`);
105 }
106});
108test('gate a: every decision point in src/ is in the registry', gate('decisions', 'decision point(s) not in test/space/registry.js DECISIONS'));
109test('gate b: every git-manifest entry is covered by a space or excluded with a reason', gate('git', 'git check(s) neither covered nor excluded in test/space/registry.js GIT'));
110test('no stale rules: every registry rule still names something', gate('stale', 'registry rule(s) that match nothing'));
112test('the git manifest is the pinned git version and the ratchet lists every category', () => {
113 assert.equal(all.man.git.tag, 'v2.50.0');
114 assert.ok(all.man.entries.length > 300, 'the manifest lost entries');
115 for (const c of ['decisions', 'git', 'failsites', 'claims', 'linux', 'stale']) assert.ok(ratchet().categories[c], `ratchet.json has no ${c}`);
116});
118test('SPACES.md is generated from the registry (npm run spaces -- --md)', () => {
119 assert.equal(readFileSync(join(ROOT, 'SPACES.md'), 'utf8'), renderMd(all));
120});
Diagnostics4 git calls · 630 ms
CallStatusSizeTime0630 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=55
Open pack map
fetch2003.2 KiB625 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=625
git.response.bytes=3241
git.response.cache=MISS
git.response.duration_ms=625
git.fetch.wants=1cb4843e2461849511bf49ab4c891f7f7f018c7a
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=3241
git.pkt.payload.max=3220
git.sideband.band1.bytes=3219
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
a5e2f4587ff77089
Request
13911a46…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format