main
1// The push-outcome space, as code. Each axis is a tagged union (a list of variants, each with the minimal payload needed
2// to render it and a `why` citing git's source). The space is the plain list of axes; `product` takes it generically, so
3// a new variant or axis adds every cell it creates. `render` is one function per axis, composed; `expected` is a total
4// function from a cell to a tagged-union outcome, written as one exhaustive table per axis (MEANING) plus a combiner.
5// SPACE.md's "Push outcome" section is generated from this file (scripts/space-md.mjs) and checked by the test.
6//
7// git sources cited are git v2.50.0: builtin/receive-pack.c (report, report_v2, execute_commands, execute_commands_atomic,
8// unpack, copy_to_sideband, cmd_receive_pack), send-pack.c (receive_unpack_status, receive_status, send_pack),
9// sideband.c (demultiplex_sideband), pkt-line.c (recv_sideband, packet_writer_error, packet_read_with_status).
10import { pkt, FLUSH } from '../../src/pktline.js';
11import { concat, te } from '../../src/bytes.js';
12import { unwrap } from '../unwrap.js';
14export const ZERO = '0'.repeat(40);
15export const OLD = '1'.repeat(40);
16export const NEW = '2'.repeat(40);
17export const REFS = ['refs/heads/r0', 'refs/heads/r1', 'refs/heads/r2'];
18export const FOREIGN_REF = 'refs/heads/zz';
19// The enumerator runs with a small report-line cap so the `flood` delivery can exceed it cheaply.
20export const MAX_REPORT_LINES = 16;
21// git's unpack() return values (builtin/receive-pack.c unpack, parse_pack_header): the only non-"ok" unpack statuses
22// receive-pack can write. Exported for the doc; src/push.js keeps its own copy (the test checks they agree).
23export const GIT_UNPACK_ERRORS = [
24 'eof before pack header was fully read',
25 'protocol error (pack signature mismatch detected)',
26 'protocol error (pack version unsupported)',
27 'unknown error in parse_pack_header',
28 'unable to create temporary object directory',
29 'unpack-objects abnormal exit',
30 'index-pack fork failed',
31 'index-pack abnormal exit',
32];
33// A host's own unpack failure (not git's grammar), echoed as every ref's reason: Cloudflare Artifacts, observed
34// 2026-11-10 (#246): "unpack invalid pack entry type 0" then "ng <ref> invalid pack entry type 0" per ref.
35export const HOST_UNPACK_ERROR = 'invalid pack entry type 0';
37// ---- per-ref status: one union, used by two axes (every ref's status, and the odd ref of a mixed report) ----
38const STATUS = [
39 { tag: 'ok', why: 'report(): "ok <ref>" when cmd->error_string is NULL' },
40 { tag: 'ngCas', reason: 'failed to update ref', why: 'execute_commands_non_atomic(): ref_transaction_commit failed (stale old oid; observed from git 2.50)' },
41 { tag: 'ngHook', reason: 'hook declined', why: 'update(): the update hook refused (observed)' },
42 { tag: 'ngAtomic', reason: 'atomic push failure', why: 'execute_commands_atomic(): the innocent members of a failed atomic push (observed)' },
43 { tag: 'ngUnpacker', reason: 'unpacker error', why: 'execute_commands(): every command, and only when unpack failed' },
44 { tag: 'ngEcho', reason: HOST_UNPACK_ERROR, why: 'a host (Cloudflare Artifacts) refuses every ref with its unpack status as the reason (observed, #246); after "unpack ok" it is an ordinary refusal' },
45 { tag: 'missing', why: 'no status line for a commanded ref: report() writes one per command, so never git' },
46 { tag: 'duplicate', why: 'the ref\'s "ok" line twice: report() writes one per command; report_v2 repeats "ok" only with option lines (proc-receive)' },
47 { tag: 'unexpected', why: `the ref's line names ${FOREIGN_REF}, a ref not commanded (send-pack.c receive_status: "unknown ref")` },
48 { tag: 'unreadable', why: 'the status word is not text (0xff 0xfe): send-pack.c receive_status "invalid ref status"' },
49 { tag: 'nearMiss', why: '"ng <ref>" with no reason: report() always writes a reason; send-pack.c would read it as "failed"' },
50];
52const variants = (list, extra = {}) => list.map(v => ({ ...v, ...extra }));
54// ---- the axes ----
55const EVENT = { name: 'event', doc: 'what else happens around the exchange', variants: [
56 { tag: 'clean', why: 'nothing else' },
57 { tag: 'progress', why: 'band 2 before the report (unpack/hook stderr via copy_to_sideband) and after it (post-receive)' },
58 { tag: 'keepalive', why: 'an empty band-1 packet "0005\\1" before and after the report: copy_to_sideband sends it while hooks run (use_keepalive is KEEPALIVE_ALWAYS from execute_commands on, so post-receive too)' },
59 { tag: 'band3Before', why: 'band 3 before the report: demultiplex_sideband reports "remote error"; receive-pack itself never writes band 3' },
60 { tag: 'band3After', why: 'band 3 after the report, before the outer flush' },
61 { tag: 'errPkt', why: 'an "ERR " pkt before the report: packet_read dies (PACKET_READ_DIE_ON_ERR_PACKET in send_pack)' },
62 { tag: 'dropBeforePack', why: 'the connection fails after the commands, before the pack: the server unpacks nothing ("eof before pack header")' },
63 { tag: 'dropMidPack', why: 'the connection fails inside the pack: index-pack/unpack-objects fails, nothing is updated' },
64 { tag: 'dropAfterPack', why: 'the connection fails after the pack, before any response byte: the server may have updated the refs' },
65 ...[
66 ['ref', 'validateRef refuses the ref name'],
67 ['oid', 'an old/new oid that is not 40-hex'],
68 ['maxRefs', 'more commands than limits.maxRefs'],
69 ['packBytes', 'the built pack exceeds limits.maxPackBytes'],
70 ['pushOption', 'a push option containing LF'],
71 ].map(([what, why]) => ({ tag: 'refused', what, why: `ply refuses before sending: ${why}` })),
72 ] };
73const FRAMING = { name: 'framing', doc: 'how the report is carried', variants: [
74 { tag: 'plain', why: 'no side-band: report() write_or_die(1, …); hook output goes to stderr, not the wire' },
75 { tag: 'sideband', why: 'side-band-64k: report pkts + flush inside one band-1 packet (send_sideband), then an outer flush (cmd_receive_pack)' },
76 ] };
77const DELIVERY = { name: 'delivery', doc: 'what reaches the client of the framed response', variants: [
78 { tag: 'complete', why: 'every byte, then end of stream' },
79 { tag: 'band1Split', why: 'one band-1 packet per inner pkt: send_sideband() chunks at LARGE_PACKET_MAX; the client reassembles band 1 as a stream' },
80 { tag: 'noFinalFlush', why: 'the stream ends before the final flush: git dies (packet_read: "the remote end hung up") / demultiplex_sideband "unexpected disconnect"' },
81 { tag: 'noReportFlush', why: 'the report\'s own flush is missing inside band 1, the outer flush present' },
82 { tag: 'cutAfterUnpack', why: 'the stream ends cleanly after the unpack line (a cut at a pkt boundary)' },
83 { tag: 'cutMidPkt', why: 'the stream ends inside the last data pkt' },
84 { tag: 'trailingPkt', why: 'a second copy of the report after the final flush' },
85 { tag: 'throwAfter', why: 'every byte, then the transport fails (connection reset after the flush)' },
86 { tag: 'flood', why: `${MAX_REPORT_LINES} extra report lines: exceeds the client's report-line cap` },
87 { tag: 'trailingFlush', why: 'a second flush after the final flush' },
88 { tag: 'band1Trailing', extra: 'partial', why: 'band 1 carries two more bytes after the report\'s flush (a pkt cut inside band 1)' },
89 { tag: 'band1Trailing', extra: 'flush', why: 'band 1 carries a second report flush' },
90 { tag: 'wrongBand', band: 5, why: 'the report on band 5: one bit from band 1 (demultiplex_sideband: "bad band")' },
91 ] };
92export const AXES = [
93 EVENT, FRAMING, DELIVERY,
94 { name: 'refs', doc: 'number of commanded refs', variants: [
95 { tag: 'one', n: 1, why: 'single-ref push (the edit pipeline)' },
96 { tag: 'two', n: 2, why: 'smallest multi-ref push: first and last ref differ' },
97 { tag: 'three', n: 3, why: 'a ref with neighbours on both sides (an interior position)' },
98 ] },
99 { name: 'commands', doc: 'what the commands ask for; decides whether a pack is sent', variants: [
100 { tag: 'withPack', why: 'some new oid is non-zero: cmd_receive_pack runs unpack_with_sideband()' },
101 { tag: 'deleteOnly', why: 'every new oid is zero: delete_only() skips unpack, so the status is always "unpack ok"' },
102 ] },
103 { name: 'atomic', doc: 'the atomic capability', variants: [
104 { tag: 'off', why: 'execute_commands_non_atomic(): one transaction per ref' },
105 { tag: 'on', why: 'execute_commands_atomic(): one transaction; a failure inside it marks every other command "atomic push failure"' },
106 ] },
107 { name: 'format', doc: 'report-status v1 or v2, and option lines', variants: [
108 { tag: 'v1', why: 'report(): unpack line, one ok/ng line per command, flush' },
109 { tag: 'v2', why: 'report_v2() without proc-receive: byte-identical to report()' },
110 { tag: 'v2Options', why: 'report_v2(): "option forced-update" after each ok, written only for proc-receive reports' },
111 { tag: 'v1Options', why: 'option lines when report-status-v2 was not negotiated: report() never writes them' },
112 ] },
113 { name: 'unpack', doc: 'the unpack line', variants: [
114 { tag: 'ok', why: 'report(): "unpack ok" when unpack_status is NULL' },
115 { tag: 'gitError', status: 'unpack-objects abnormal exit', why: 'unpack(): one of git\'s fixed failure strings (observed with a corrupted pack)' },
116 { tag: 'hostError', status: HOST_UNPACK_ERROR, why: 'a host\'s own unpack failure text (Cloudflare Artifacts, observed with a pack entry of type 0, #246): definite only when every ref echoes it' },
117 { tag: 'absent', why: 'no unpack line: send-pack.c receive_unpack_status fails' },
118 { tag: 'unreadable', why: 'status bytes 0xff 0xfe: not text' },
119 { tag: 'nearMiss', status: 'ok*', why: 'one flip from "ok" (issue #33): neither "ok" nor a git failure string' },
120 { tag: 'duplicated', why: 'two "unpack ok" lines: receive_unpack_status reads one; the second is an invalid ref status' },
121 ] },
122 { name: 'status', doc: 'every commanded ref\'s status (a mixed report overrides one ref, see spread)', variants: variants(STATUS) },
123 { name: 'spread', doc: 'statuses across refs: uniform, or one ref (at index `at`) differs', variants: [
124 { tag: 'uniform', why: 'every ref has `status`' },
125 ...[0, 1, 2].flatMap(at => STATUS.map(odd => ({ tag: 'mixed', at, odd, why: `ref ${at} has status ${odd.tag}` }))),
126 ] },
127];
129export const axis = name => AXES.find(a => a.name === name);
130export const TAGS = Object.fromEntries(AXES.map(a => [a.name, [...new Set(a.variants.map(v => v.tag))]]));
131export const STATUS_TAGS = STATUS.map(s => s.tag);
133// ---- constraints: impossible cells, and axes made irrelevant by another axis ----
134const SIDEBAND_ONLY_EVENTS = new Set(['progress', 'keepalive', 'band3Before', 'band3After']);
135const NO_RESPONSE = new Set(['dropBeforePack', 'dropMidPack', 'dropAfterPack', 'refused']);
136// Each rule reads `axes` and says why the cell cannot exist. A cell matching any rule is not a cell of the space.
137export const IMPOSSIBLE = [
138 { why: 'plain framing has no band 1, 2 or 3 (use_sideband=0: hook output goes to stderr)', axes: ['event', 'framing', 'delivery'], test: c => c.framing.tag === 'plain' && (SIDEBAND_ONLY_EVENTS.has(c.event.tag) || ['band1Split', 'noReportFlush', 'band1Trailing', 'wrongBand'].includes(c.delivery.tag)) },
139 { why: 'a delete-only push sends no pack, so it cannot be cut inside or after one, nor refused for its size', axes: ['event', 'commands'], test: c => c.commands.tag === 'deleteOnly' && (['dropMidPack', 'dropAfterPack'].includes(c.event.tag) || (c.event.tag === 'refused' && c.event.what === 'packBytes')) },
140 { why: 'one ref cannot be mixed', axes: ['refs', 'spread'], test: c => c.spread.tag === 'mixed' && c.refs.n === 1 },
141 { why: 'the odd ref index is beyond the commanded refs', axes: ['refs', 'spread'], test: c => c.spread.tag === 'mixed' && c.spread.at >= c.refs.n },
142 { why: 'a mixed report whose odd status equals the common status is the uniform cell', axes: ['status', 'spread'], test: c => c.spread.tag === 'mixed' && c.spread.odd.tag === c.status.tag },
143];
144// When `when(cell)` holds (it reads only `on`), `axes` cannot affect anything (nothing is read): only their first
145// variant is kept. `on` must precede `axes` in AXES.
146export const COLLAPSE = [
147 { why: 'no response is read (refused before sending, or the connection failed first): the response axes are irrelevant', on: ['event'], when: c => NO_RESPONSE.has(c.event.tag), axes: ['framing', 'delivery', 'format', 'unpack', 'status', 'spread'] },
148];
150// ---- the product (generic, pruned) ----
151// Walks AXES in order; a rule is checked as soon as every axis it reads is assigned, so an impossible subtree is
152// skipped whole and its size counted arithmetically. `visit(cell)` sees every cell; the return is the census.
153export const rawSize = (axes = AXES) => axes.reduce((n, a) => n * a.variants.length, 1);
154export function walk(visit = () => {}, axes = AXES) {
155 const pos = Object.fromEntries(axes.map((a, i) => [a.name, i]));
156 const ready = rules => rules.map(r => Math.max(...(r.axes ?? r.on).map(n => pos[n])));
157 const impReady = ready(IMPOSSIBLE), colReady = ready(COLLAPSE.map(r => ({ axes: r.on })));
158 const by = { cells: 0 };
159 const rest = i => axes.slice(i).reduce((n, a) => n * a.variants.length, 1);
160 const cell = {}, collapsed = new Set();
161 const go = i => {
162 if (i === axes.length) { by.cells++; visit({ ...cell }); return; }
163 const a = axes[i];
164 const vs = collapsed.has(a.name) ? a.variants.slice(0, 1) : a.variants;
165 if (vs.length < a.variants.length) { const k = 'collapsed:0'; by[k] = (by[k] ?? 0) + (a.variants.length - vs.length) * rest(i + 1); }
166 for (const v of vs) {
167 cell[a.name] = v;
168 const bad = IMPOSSIBLE.findIndex((r, j) => impReady[j] === i && r.test(cell));
169 if (bad >= 0) { const k = `impossible:${bad}`; by[k] = (by[k] ?? 0) + rest(i + 1); continue; }
170 const added = [];
171 COLLAPSE.forEach((r, j) => { if (colReady[j] === i && r.when(cell)) for (const n of r.axes) if (!collapsed.has(n)) { collapsed.add(n); added.push(n); } });
172 go(i + 1);
173 for (const n of added) collapsed.delete(n);
174 }
175 delete cell[a.name];
176 };
177 go(0);
178 return { raw: rawSize(axes), ...by };
179}
180// Deviations from git's canonical single-ref success on the axes that shape the response. PUSH_SPACE=quick (the mutation
181// gate) explores the sub-product of cells with at most QUICK_DEVIATIONS of them; the full run explores every cell.
182const CANONICAL_AXES = ['event', 'delivery', 'format', 'unpack', 'status', 'spread'];
183export const QUICK_DEVIATIONS = 2;
184export const deviations = c => CANONICAL_AXES.filter(n => c[n] !== axis(n).variants[0]).length;
185export function* cells() { const all = []; walk(c => all.push(c)); yield* all; }
186export const census = () => walk();
187export const cellId = c => AXES.map(a => {
188 const v = c[a.name];
189 const p = Object.entries(v).filter(([k]) => k !== 'tag' && k !== 'why' && k !== 'n').map(([k, x]) => `${k}=${typeof x === 'object' ? x.tag : x}`);
190 return p.length ? `${v.tag}(${p.join(',')})` : v.tag;
191}).join('/');
193// ---- per-ref statuses of a cell ----
194export const statuses = c => Array.from({ length: c.refs.n }, (_, i) => (c.spread.tag === 'mixed' && c.spread.at === i ? c.spread.odd : c.status));
196// ---- rendering: one function per axis, composed ----
197const line = (...parts) => concat(parts.map(p => (typeof p === 'string' ? te.encode(p) : p)));
198const band = (b, body) => unwrap(pkt(concat([Uint8Array.of(b), body])));
199const OPTION_LINE = line('option forced-update\n');
201export const RENDER = {
202 refs: v => ({ refs: REFS.slice(0, v.n) }),
203 commands: v => ({ newOid: v.tag === 'deleteOnly' ? ZERO : NEW }),
204 atomic: v => ({ atomic: v.tag === 'on' }),
205 format: v => ({ reportV2: v.tag === 'v2' || v.tag === 'v2Options', options: v.tag === 'v2Options' || v.tag === 'v1Options' }),
206 unpack: v => ({
207 ok: () => [line('unpack ok\n')],
208 gitError: () => [line(`unpack ${v.status}\n`)],
209 hostError: () => [line(`unpack ${v.status}\n`)],
210 absent: () => [],
211 unreadable: () => [line('unpack ', Uint8Array.of(0xff, 0xfe), '\n')],
212 nearMiss: () => [line(`unpack ${v.status}\n`)],
213 duplicated: () => [line('unpack ok\n'), line('unpack ok\n')],
214 })[v.tag](),
215 // one ref's status lines
216 status: (v, ref, options) => ({
217 ok: () => [line(`ok ${ref}\n`), ...(options ? [OPTION_LINE] : [])],
218 ngCas: () => [line(`ng ${ref} ${v.reason}\n`)],
219 ngHook: () => [line(`ng ${ref} ${v.reason}\n`)],
220 ngAtomic: () => [line(`ng ${ref} ${v.reason}\n`)],
221 ngUnpacker: () => [line(`ng ${ref} ${v.reason}\n`)],
222 ngEcho: () => [line(`ng ${ref} ${v.reason}\n`)],
223 missing: () => [],
224 duplicate: () => [line(`ok ${ref}\n`), line(`ok ${ref}\n`)],
225 unexpected: () => [line(`ok ${FOREIGN_REF}\n`)],
226 unreadable: () => [line(Uint8Array.of(0xff, 0xfe), ` ${ref}\n`)],
227 nearMiss: () => [line(`ng ${ref}\n`)],
228 })[v.tag](),
229 spread: (c, refs, options) => statuses(c).flatMap((s, i) => RENDER.status(s, refs[i], options)),
230 // framing: report lines (+ the event's frames) → outer frames. A frame is { data } or { flush: true }.
231 framing: (v, { lines, pre, post, reportFlush, split, reportBand = 1, after = new Uint8Array(0) }) => v.tag === 'plain'
232 ? [...pre, ...lines.map(data => ({ data: unwrap(pkt(data)) })), { flush: true, final: true }]
233 : [...pre, ...(split
234 ? [...lines.map(data => ({ data: band(reportBand, unwrap(pkt(data))) })), ...(reportFlush ? [{ data: band(reportBand, FLUSH) }] : [])]
235 : [{ data: band(reportBand, concat([...lines.map(d => unwrap(pkt(d))), ...(reportFlush ? [FLUSH] : []), after])) }]), ...post, { flush: true, final: true }],
236 event: v => ({
237 clean: () => ({ pre: [], post: [] }),
238 progress: () => ({ pre: [{ data: band(2, line('Resolving deltas: 100% (1/1), done.\n')) }], post: [{ data: band(2, line('post-receive: deployed\n')) }] }),
239 keepalive: () => ({ pre: [{ data: band(1, new Uint8Array(0)) }], post: [{ data: band(1, new Uint8Array(0)) }] }),
240 band3Before: () => ({ pre: [{ data: band(3, line('internal server error\n')) }], post: [] }),
241 band3After: () => ({ pre: [], post: [{ data: band(3, line('internal server error\n')) }] }),
242 errPkt: () => ({ pre: [{ data: unwrap(pkt('ERR access denied\n')) }], post: [] }),
243 dropBeforePack: () => ({ drop: 'before the pack' }),
244 dropMidPack: () => ({ drop: 'inside the pack' }),
245 dropAfterPack: () => ({ drop: 'after the pack' }),
246 refused: () => ({ refused: v.what }),
247 })[v.tag](),
248 // delivery: (frames, report lines) → { bytes, end: 'eof' | 'throw' }
249 delivery: v => v.tag,
250};
252const serialize = frames => concat(frames.map(f => (f.flush ? FLUSH : f.data)));
254// The request ply makes for a cell, and the server's behaviour (null for a pre-send refusal).
255export function render(c) {
256 const { refs } = RENDER.refs(c.refs);
257 const { newOid } = RENDER.commands(c.commands);
258 const { atomic } = RENDER.atomic(c.atomic);
259 const { reportV2, options } = RENDER.format(c.format);
260 const ev = RENDER.event(c.event);
261 let commands = refs.map(ref => ({ ref, oldOid: OLD, newOid }));
262 const opts = { sideband: c.framing.tag === 'sideband', reportV2, atomic, pushOptions: [] };
263 const limits = { maxRefs: 8, maxReportLines: MAX_REPORT_LINES, maxPackBytes: 1 << 20 };
264 if (ev.refused) {
265 if (ev.refused === 'ref') commands = [{ ...commands[0], ref: 'refs/heads/bad name' }, ...commands.slice(1)];
266 if (ev.refused === 'oid') commands = [{ ...commands[0], oldOid: 'xyz' }, ...commands.slice(1)];
267 if (ev.refused === 'maxRefs') limits.maxRefs = refs.length - 1;
268 if (ev.refused === 'packBytes') limits.maxPackBytes = 16;
269 if (ev.refused === 'pushOption') opts.pushOptions = ['a\nb'];
270 return { commands, opts, limits, response: null };
271 }
272 if (ev.drop) return { commands, opts, limits, response: { drop: ev.drop } };
273 let lines = [...RENDER.unpack(c.unpack), ...RENDER.spread(c, refs, options)];
274 const d = RENDER.delivery(c.delivery);
275 if (d === 'cutAfterUnpack') lines = lines.slice(0, 1);
276 if (d === 'flood') lines = [...lines.slice(0, 1), ...Array.from({ length: MAX_REPORT_LINES }, () => line('unpack flood\n')), ...lines.slice(1)];
277 const after = d === 'band1Trailing' ? (c.delivery.extra === 'flush' ? FLUSH : te.encode('00')) : undefined;
278 const framed = RENDER.framing(c.framing, { lines, pre: ev.pre, post: d === 'cutAfterUnpack' ? [] : ev.post, reportFlush: !['noReportFlush', 'cutAfterUnpack'].includes(d), split: d === 'band1Split', reportBand: d === 'wrongBand' ? c.delivery.band : 1, after });
279 let frames = framed;
280 if (d === 'noFinalFlush' || d === 'cutAfterUnpack' || d === 'cutMidPkt') frames = frames.filter(f => !f.final);
281 if (d === 'trailingPkt') frames = [...frames, ...RENDER.framing(c.framing, { lines, pre: [], post: [], reportFlush: true, split: false })];
282 if (d === 'trailingFlush') frames = [...frames, { flush: true }];
283 let bytes = serialize(frames);
284 if (d === 'cutMidPkt') {
285 // inside the last data pkt; a report with no data pkt at all ends inside its flush ("00")
286 const last = frames.filter(f => f.data).at(-1);
287 bytes = last ? bytes.subarray(0, bytes.length - Math.ceil(last.data.length / 2)) : concat([bytes, te.encode('00')]);
288 }
289 return { commands, opts, limits, response: { bytes, end: d === 'throwAfter' ? 'throw' : 'eof' } };
290}
292// ---- the expected outcome: exhaustive per-axis meaning, then one combiner ----
293// Outcomes: { tag: 'landed', refs } | { tag: 'rejected', code } | { tag: 'partial', landed, rejected }
294// | { tag: 'ambiguous' } | { tag: 'preSend', code, what }
295const CAS = new Set(['ngCas', 'ngAtomic']);
296export const MEANING = {
297 refs: { one: () => ({}), two: () => ({}), three: () => ({}) },
298 commands: { withPack: () => ({ pack: true }), deleteOnly: () => ({ pack: false }) },
299 atomic: { off: () => ({ atomic: false }), on: () => ({ atomic: true }) },
300 // option lines follow each ok: neither shape is a plain update. v2 + options is proc-receive (the server updated some
301 // other ref or oid on our behalf): ply does not model it, so a report carrying them is never a definite answer.
302 format: { v1: () => ({ options: false }), v2: () => ({ options: false }), v2Options: () => ({ options: true }), v1Options: () => ({ options: true }) },
303 unpack: {
304 ok: () => 'ok', gitError: () => 'failed', hostError: () => 'hostFailed',
305 absent: () => 'bad', unreadable: () => 'bad', nearMiss: () => 'bad', duplicated: () => 'bad',
306 },
307 status: {
308 ok: () => 'ok', ngCas: () => 'ng', ngHook: () => 'ng', ngAtomic: () => 'ng', ngUnpacker: () => 'unpacker', ngEcho: () => 'echo',
309 missing: () => 'bad', duplicate: () => 'bad', unexpected: () => 'bad', unreadable: () => 'bad', nearMiss: () => 'bad',
310 },
311 spread: { uniform: () => null, mixed: v => v.at },
312 framing: { plain: () => 'exact', sideband: () => 'exact' },
313 delivery: {
314 complete: () => 'exact', band1Split: () => 'exact',
315 noFinalFlush: () => 'broken', noReportFlush: () => 'broken', cutAfterUnpack: () => 'broken', cutMidPkt: () => 'broken',
316 trailingPkt: () => 'broken', throwAfter: () => 'broken', flood: () => 'broken',
317 trailingFlush: () => 'broken', band1Trailing: () => 'broken', wrongBand: () => 'broken',
318 },
319 event: {
320 clean: () => 'exact', progress: () => 'exact', keepalive: () => 'exact',
321 band3Before: () => 'broken', band3After: () => 'broken', errPkt: () => 'broken',
322 dropBeforePack: () => 'none', dropMidPack: () => 'none', dropAfterPack: () => 'none',
323 refused: v => ({ ref: ['bad_request', 'ref'], oid: ['bad_request', undefined], maxRefs: ['limit_exceeded', 'push commands'], packBytes: ['limit_exceeded', 'push pack bytes'], pushOption: ['bad_request', 'push option'] })[v.what],
324 },
325};
326const mean = (name, v) => {
327 const f = MEANING[name][v.tag];
328 if (!f) throw new Error(`MEANING.${name} has no case for tag ${v.tag}`);
329 return f(v);
330};
332const AMBIGUOUS = Object.freeze({ tag: 'ambiguous' });
333export function expected(c) {
334 const ev = mean('event', c.event);
335 if (Array.isArray(ev)) return { tag: 'preSend', code: ev[0], what: ev[1] };
336 if (ev === 'none' || ev === 'broken') return AMBIGUOUS;
337 if (mean('framing', c.framing) !== 'exact' || mean('delivery', c.delivery) !== 'exact') return AMBIGUOUS;
338 mean('refs', c.refs); mean('spread', c.spread);
339 const { pack } = mean('commands', c.commands);
340 const { atomic } = mean('atomic', c.atomic);
341 const { options } = mean('format', c.format);
342 const unpack = mean('unpack', c.unpack);
343 const per = statuses(c).map(s => ({ kind: mean('status', s), s }));
344 if (unpack === 'bad' || per.some(p => p.kind === 'bad')) return AMBIGUOUS;
345 if (options && per.some(p => p.kind === 'ok')) return AMBIGUOUS;
346 const refs = REFS.slice(0, c.refs.n);
347 if (unpack === 'failed') return pack && per.every(p => p.kind === 'unpacker') ? { tag: 'rejected', code: 'push_rejected' } : AMBIGUOUS;
348 // a host's failure text is definite only echoed by every ref (#246); git's grammar never writes it
349 if (unpack === 'hostFailed') return pack && per.every(p => p.kind === 'echo') ? { tag: 'rejected', code: 'push_rejected' } : AMBIGUOUS;
350 if (per.some(p => p.kind === 'unpacker')) return AMBIGUOUS;
351 // after "unpack ok" the echoed reason is an ordinary refusal (ngClass: rejected)
352 const ok = refs.filter((_, i) => per[i].kind === 'ok'), ng = refs.filter((_, i) => per[i].kind === 'ng' || per[i].kind === 'echo');
353 if (!ng.length) return { tag: 'landed', refs: ok };
354 if (!ok.length) {
355 const tags = per.map(p => p.s.tag);
356 return { tag: 'rejected', code: tags.every(t => CAS.has(t)) && tags.some(t => t === 'ngCas') ? 'cas_conflict' : 'push_rejected' };
357 }
358 return atomic ? AMBIGUOUS : { tag: 'partial', landed: ok, rejected: ng };
359}
360export const isDefinite = o => o.tag === 'landed' || o.tag === 'rejected' || o.tag === 'partial';
Diagnostics4 git calls · 31 ms
CallStatusSizeTime031 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 · 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 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=55Open pack map
fetch2008.5 KiB · hit25 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=25 git.response.bytes=8704 git.response.cache=HIT git.response.duration_ms=25 git.fetch.wants=a877e81122634d6865e0f03532e78bdd57099a91 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=8704 git.pkt.payload.max=8683 git.sideband.band1.bytes=8682 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
- a5e314e32ce83e6e
- Request
- fac36ed2…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format