main
ply4 git calls286 ms44 KiB2 cachedprotocol v2
132 lines8.9 KiBRaw
1// What a run found, as one value: a pass, or each difference from the stated expectation classified as exactly one of
2// client_bug, server_bug, expected_incompatibility or unresolved, carrying the step's outcome and error class as
3// ply's own evaluator renders them (ply/probes soloDiffs, allowFor, classify) and the exchanges that decided it.
4//
5// ply's classify can only say `unresolved` for a one-corner run (stock git and the reference did not run). The
6// workbench has one more witness, the wire, read by its own parser (src/bench/wire.ts), so two cases are decided here:
7// client_bug ply's outcome for a push contradicts the report-status the server sent on that same exchange
8// (an answer that reached ply whole: no response fault applied)
9// server_bug the server's report-status said a ref was updated, and the refs read back afterwards do not show it
10// (the last update of that ref in the run, so no later write explains it)
11// Anything else stays as classify left it; an allow entry ply keeps for the scenario makes it expected_incompatibility.
12import { ALLOW, allowFor, classify, soloDiffs, type Difference, type ErrorClass, type Names, type Observation, type Outcome, type Scenario, type StepExpect } from 'ply/probes';
13import { renderRay } from '../rays.ts';
14import type { Exchange } from './recorder.ts';
15import { reportVerdict, type Report } from './wire.ts';
17const ZERO = '0'.repeat(40);
19export type Evidence = { readonly exchange: number; readonly cfRay: string; readonly says: string };
20// The step a difference is about, when it is about one: what ply concluded and what the scenario states.
21export type StepAt = { readonly index: number; readonly outcome: Outcome; readonly error: ErrorClass; readonly expected: StepExpect | null };
23type Base = { readonly difference: Difference; readonly step: StepAt | null; readonly evidence: readonly Evidence[] };
24export type Failure =
25 | (Base & { readonly tag: 'client_bug'; readonly why: string })
26 | (Base & { readonly tag: 'server_bug'; readonly why: string })
27 | (Base & { readonly tag: 'expected_incompatibility'; readonly reason: string })
28 | (Base & { readonly tag: 'unresolved'; readonly why: string });
29export type FailureTag = Failure['tag'];
30export const FAILURE_TAGS: readonly FailureTag[] = ['client_bug', 'server_bug', 'expected_incompatibility', 'unresolved'];
32export type RunVerdict =
33 | { readonly tag: 'pass'; readonly compared: number }
34 | { readonly tag: 'fail'; readonly failures: readonly [Failure, ...Failure[]] }
35 // the run could not observe the scenario (a seed push refused, a judge read failed): nothing to classify
36 | { readonly tag: 'harness'; readonly stage: 'seed' | 'step' | 'judge'; readonly message: string };
38const ev = (x: Exchange, says: string): Evidence => ({ exchange: x.i, cfRay: renderRay(x.cfRay), says });
39const responseFault = (x: Exchange): boolean => x.applied !== null && x.applied.tag !== 'race' && x.applied.tag !== 'stall-request';
40const reportText = (r: Report): string => {
41 if (r.tag === 'none') return `no report-status (${r.why})`;
42 const refs = r.refs.map(s => (s.tag === 'ok' ? `ok ${s.ref}` : `ng ${s.ref} ${s.reason}`)).join('; ');
43 return `unpack ${r.unpack.tag === 'ok' ? 'ok' : `error ${r.unpack.reason}`}; ${refs}`;
44};
46// The outcome the server's own report-status implies for ply's classes, or null when it implies none (no report).
47export function reportOutcome(r: Report): Outcome | null {
48 switch (reportVerdict(r)) {
49 case 'all-ok': return 'landed';
50 case 'some-ok': return 'partial';
51 case 'none-ok': return null; // conflict or rejected: the reason decides, ply's classifier reads it
52 case 'no-report': return null;
53 }
56// Exchanges of a step on the main channel that carried a receive-pack answer ply read whole.
57const stepPushes = (xs: readonly Exchange[], step: number): Exchange[] => xs.filter(x => x.channel === 'main' && x.phase.tag === 'step' && x.phase.index === step && x.wire.tag === 'receive-pack' && x.answer.tag === 'http' && x.answer.status === 200 && !responseFault(x));
59function clientContradiction(s: Scenario, obs: Observation, xs: readonly Exchange[], step: number): Evidence[] {
60 const st = s.steps[step];
61 const seen = obs.steps[step];
62 if (typeof st !== 'object' || typeof seen !== 'object' || st.tag !== 'push') return [];
63 const first = seen.outcomes[0];
64 const out: Evidence[] = [];
65 for (const x of stepPushes(xs, step)) {
66 if (x.wire.tag !== 'receive-pack') continue;
67 const implied = reportOutcome(x.wire.report);
68 const v = reportVerdict(x.wire.report);
69 if (implied !== null && implied !== first.outcome) out.push(ev(x, `the server reported ${reportText(x.wire.report)}; ply concluded ${first.outcome}`));
70 if (v === 'none-ok' && first.outcome === 'landed') out.push(ev(x, `the server refused every command (${reportText(x.wire.report)}); ply concluded landed`));
71 }
72 return out;
75// The server said ok for ref R at new id X in the last write of R the run made, and the end state disagrees.
76function serverContradiction(obs: Observation, xs: readonly Exchange[]): Evidence[] {
77 const last = new Map<string, { readonly x: Exchange; readonly to: string }>();
78 for (const x of xs) {
79 if (x.wire.tag !== 'receive-pack' || x.phase.tag === 'judge' || x.phase.tag === 'cleanup') continue;
80 const report = x.wire.report;
81 for (const c of x.wire.request.commands) {
82 const okd = report.tag === 'report' && report.refs.some(r => r.tag === 'ok' && r.ref === c.ref);
83 // a write the server did not confirm makes the ref's end state unknown to the wire: forget the earlier one
84 if (okd && x.answer.tag === 'http') last.set(c.ref, { x, to: String(c.new) }); else last.delete(c.ref);
85 }
86 }
87 const out: Evidence[] = [];
88 for (const [ref, { x, to }] of last) {
89 const held = Object.hasOwn(obs.end.refs, ref) ? String(obs.end.refs[ref]) : ZERO;
90 if (held !== to) out.push(ev(x, `the server reported ok ${ref} -> ${to === ZERO ? '(deleted)' : to}; the refs read back hold ${held === ZERO ? '(absent)' : held}`));
91 }
92 return out;
95// The first step whose outcome (or error) is not the stated one: a concurrent step by its sorted outcomes, an
96// `either` step by whether it is one of the listed pairs.
97const stepOf = (d: Difference, s: Scenario, obs: Observation): StepAt | null => {
98 if (d.field !== 'outcome' && d.field !== 'error') return null;
99 for (const [i, e] of s.expect.entries()) {
100 const seen = obs.steps[i];
101 if (typeof seen !== 'object') continue;
102 const o = seen.outcomes[0];
103 if (e.tag === 'one' && (e.ply.outcome !== o.outcome || e.ply.error !== o.error)) return { index: i, outcome: o.outcome, error: o.error, expected: e.ply };
104 // a git-version-dependent step: any listed outcome/error pair meets it; none is singled out as the expected one
105 if (e.tag === 'either' && !e.ply.some(p => p.outcome === o.outcome && p.error === o.error)) return { index: i, outcome: o.outcome, error: o.error, expected: null };
106 if (e.tag === 'many' && [...e.ply].sort().join(',') !== seen.outcomes.map(x => x.outcome).sort().join(',')) return { index: i, outcome: o.outcome, error: o.error, expected: null };
107 }
108 return null;
109};
111export function verdictOf(s: Scenario, obs: Observation, names: Names, xs: readonly Exchange[]): RunVerdict {
112 const diffs = soloDiffs(s, obs, names);
113 const serverSide = serverContradiction(obs, xs);
114 const failures: Failure[] = diffs.map(d => {
115 const step = stepOf(d, s, obs);
116 const allowed = allowFor(ALLOW, d);
117 if (allowed.tag === 'some') return { tag: 'expected_incompatibility', difference: d, step, evidence: [], reason: allowed.value.reason };
118 // a step difference is checked on its own step; an end-state or claim difference on every step
119 const client = step === null ? (d.field === 'expectation' || d.field === 'claims' ? s.steps.flatMap((_, i) => clientContradiction(s, obs, xs, i)) : []) : clientContradiction(s, obs, xs, step.index);
120 if (client.length > 0) return { tag: 'client_bug', difference: d, step, evidence: client, why: 'ply\'s outcome contradicts the report-status the server sent on the same exchange' };
121 if ((d.field === 'expectation' || d.field === 'claims') && serverSide.length > 0) return { tag: 'server_bug', difference: d, step, evidence: serverSide, why: 'the server confirmed an update its refs do not hold' };
122 const c = classify(s, d, diffs);
123 const pushes = step === null ? [] : stepPushes(xs, step.index).map(x => ev(x, x.wire.tag === 'receive-pack' ? reportText(x.wire.report) : ''));
124 switch (c.class) {
125 case 'client-bug': return { tag: 'client_bug', difference: d, step, evidence: pushes, why: c.why };
126 case 'server-bug': return { tag: 'server_bug', difference: d, step, evidence: pushes, why: c.why };
127 case 'unresolved': return { tag: 'unresolved', difference: d, step, evidence: pushes, why: c.why };
128 }
129 });
130 const [first, ...rest] = failures;
131 return typeof first === 'object' ? { tag: 'fail', failures: [first, ...rest] } : { tag: 'pass', compared: s.expect.length };
Diagnostics4 git calls · 286 ms
CallStatusSizeTime0286 ms
discover200152 B4 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=4
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 · hit4 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=4
git.response.bytes=145
git.response.cache=HIT
git.response.duration_ms=4
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 1020040 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=41349
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=526b305930b8ef382f2d7a1f9c0238730a585921
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=41349
git.pkt.payload.max=41254
git.sideband.band1.bytes=41253
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=61
git.pack.bytes=41253
git.pack.ofs_delta=0
git.pack.ref_delta=0
git.pack.chain.max=0
git.pack.trailer=ab60efef4b7243678c75de64a4386986ee885c1c
git.pack.full=61
Open pack map
fetch2003.1 KiB280 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=280
git.response.bytes=3147
git.response.cache=MISS
git.response.duration_ms=280
git.fetch.wants=84a3cf5877ea05da0301314f43ea04fa36766a29
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=3147
git.pkt.payload.max=3126
git.sideband.band1.bytes=3125
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-web.git
Ref
refs/heads/main
Commit
526b305930b8ef382f2d7a1f9c0238730a585921
cf-ray
a5e33e660e2fdafe
Request
cd8c56dc…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format