GitHubivarvong

ply

main
ply7 git calls147 ms25 KiB4 cachedprotocol v2
50 lines4.0 KiBRaw
1// Stock git's answers, classified the way ply's are (src/probe-evaluate.ts plyOutcome): `git push --porcelain` ref lines
2// and a `git fetch` exit, mapped onto ply's error-class names so wording differences between servers are normalized
3// before comparison. Only the in-repository runner (runner.mjs) runs stock git, so this stays out of `ply/probes`.
4import type { Classified } from '../../src/probe-evaluate.ts';
5import type { Outcome } from '../../src/probe-types.ts';
7// A refusal reason stock git printed for one ref, as the error class ply would give it. Wording differs between servers
8// ("failed to update ref", "stale ref", "incorrect old value provided"); the class is what is compared.
9// A refusal git makes itself because its advertisement already shows another writer's value ("stale info" for a lease,
10// "fetch first" for a create or update without force) is the same conflict the server's compare-and-swap reports when
11// git read the advertisement a moment earlier: which one a racing client sees is timing, so both are cas_conflict.
12export function gitReasonClass(reason: string, stderr: string): string {
13 if (/stale info|fetch first/.test(reason)) return 'cas_conflict';
14 if (/atomic push failure|atomic transaction failed/.test(reason)) return 'atomic_sibling';
15 if (/non-fast-forward/.test(reason)) return 'not_fast_forward';
16 if (/failed to update ref|failed to lock|cannot lock|incorrect old value|stale ref|already exists|does not exist|bad ref|reference/.test(reason)) return 'cas_conflict';
17 if (/exceeds maximum|too large|limit is|maximum allowed/i.test(`${reason}\n${stderr}`)) return 'limit_exceeded';
18 return 'push_rejected';
21const OK_FLAGS = new Set([' ', '+', '-', '*', '=']);
22// `git push --porcelain`: a `<flag>\t<src>:<dst>\t<summary>` line per ref (git-push(1) OUTPUT). No ref line and a
23// non-zero exit is a push whose answer git never read: ambiguous.
24// `creates`: the refs the plan creates (zero old id). git refuses a create of a ref its advertisement already shows as
25// "non-fast-forward" (or "fetch first"): for a create that is the conflict, not a history rule.
26// `git fetch`: landed when it exits 0; a low-speed abort is the timeout class, anything else a failed fetch.
27export function gitFetchOutcome(status: number | null, stderr: string): Classified {
28 const tail = stderr.trim().split('\n').slice(-3).join(' | ').slice(0, 300);
29 if (status === 0) return { outcome: 'landed', error: null, detail: 'fetched' };
30 if (/too slow|timed out|Timeout was reached/i.test(stderr)) return { outcome: 'rejected', error: 'timeout', detail: tail };
31 return { outcome: 'rejected', error: 'fetch_failed', detail: tail };
34export function gitOutcome(status: number | null, stdout: string, stderr: string, creates: ReadonlySet<string> = new Set()): Classified {
35 const refs = stdout.split('\n').filter(l => /^[ +\-*=!]\t[^\t]*:[^\t]*\t/.test(l)).map(l => {
36 const [flag = '!', spec = '', summary = ''] = l.split('\t');
37 const reason = /\(([^)]*)\)\s*$/.exec(summary)?.[1] ?? summary;
38 return { ok: OK_FLAGS.has(flag), reason: creates.has(spec.slice(spec.indexOf(':') + 1)) && reason === 'non-fast-forward' ? 'fetch first' : reason };
39 });
40 const tail = stderr.trim().split('\n').slice(-3).join(' | ').slice(0, 300);
41 if (refs.length === 0) return status === 0 ? { outcome: 'landed', error: null, detail: 'no ref lines' } : { outcome: 'ambiguous', error: 'ambiguous', detail: tail };
42 const bad = refs.filter(r => !r.ok);
43 if (bad.length === 0 && status === 0) return { outcome: 'landed', error: null, detail: 'ok' };
44 if (bad.length === 0) return { outcome: 'ambiguous', error: 'ambiguous', detail: tail };
45 if (bad.length < refs.length) return { outcome: 'partial', error: 'push_partial', detail: bad.map(b => b.reason).join('; ') };
46 const classes = bad.map(b => gitReasonClass(b.reason, stderr));
47 const error = classes.find(c => c !== 'atomic_sibling') ?? 'cas_conflict';
48 const outcome: Outcome = error === 'cas_conflict' ? 'conflict' : 'rejected';
49 return { outcome, error, detail: bad.map(b => b.reason).join('; ') };
Diagnostics7 git calls · 147 ms
CallStatusSizeTime0147 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 KiB3 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=11990
git.response.cache=UPDATING
git.response.duration_ms=3
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 · hit6 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=6
git.response.bytes=4347
git.response.cache=HIT
git.response.duration_ms=6
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 · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=919
git.response.cache=HIT
git.response.duration_ms=3
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:02005.6 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=5724
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=58fabb6768b3f737ee9cd8bac647bdc27405fb4d
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=5724
git.pkt.payload.max=5697
git.sideband.band1.bytes=5697
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=5697
git.pack.trailer=be7e0453974a5fe832f9065a33bb7e3434c10e9b
Open pack map
fetchtree:0200305 B · hit5 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=5
git.response.bytes=305
git.response.cache=HIT
git.response.duration_ms=5
git.fetch.filter=tree:0
git.fetch.wants=facf357dda5424ce8c1bda8ebca6cacc9b5bfc3a
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=305
git.pkt.payload.max=278
git.sideband.band1.bytes=278
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=278
git.pack.trailer=36c263093b3db739addfdbaa3928c1028217ea9e
Open pack map
fetch2001.7 KiB128 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=127
git.response.bytes=1726
git.response.cache=MISS
git.response.duration_ms=128
git.fetch.wants=f3a05be7b4655e7c648b0b2a14d99b044ac3e55f
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=1726
git.pkt.payload.max=1699
git.sideband.band1.bytes=1699
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
a5e2f6855bdb3a24
Request
e508cd25…
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