Artifactspublic-v0

ply

main
ply4 git calls246 ms48 KiB2 cachedprotocol v2
716 lines45 KiBRaw
1// The differential probe scenarios, keyed by matrix behaviour (`<behaviour>#<variant>`), in priority order: the hard
2// state transitions first (stale old ids, lost answers, contention, atomicity, refs moved under a push, size caps,
3// non-fast-forward), then the plain transitions the hard ones are read against. Each is a pure plan; the runner
4// (test/probes/runner.mjs here, ply-web's workbench in a Worker) seeds a fresh repository per target, runs the steps,
5// and a judge reads the result back.
6import { ABSENT } from './probe-types.js';
7import type { CommitSpec, Damage, Expectation, Fault, Timeouts, FileSpec, FinalRef, GitForm, Move, NonEmpty, ObjRef, ObjectSpec, OidExpr, Outcome, PackDefect, Push, RawCommitSpec, RawTagSpec, RawTreeEntry, RawTreeSpec, RefAt, Scenario, Step, StepExpect, TagSpec, Update } from './probe-types.js';
9const text = (path: string, s: string): FileSpec => ({ path, content: { tag: 'text', text: s } });
10const noise = (path: string, seed: string, bytes: number): FileSpec => ({ path, content: { tag: 'noise', seed, bytes } });
11const commit = (name: string, parents: readonly string[], files: readonly FileSpec[]): CommitSpec => ({ tag: 'commit', name, parents, files, message: name });
12const tag = (name: string, target: string, tagName: string): TagSpec => ({ tag: 'annotated-tag', name, target, tagName, message: `tag ${tagName}` });
13const ZERO: OidExpr = { tag: 'zero' };
14const o = (name: string): OidExpr => ({ tag: 'obj', name });
15const at = (ref: string, name: string): RefAt => ({ ref, at: name });
16const upd = (ref: string, old: OidExpr, next: OidExpr): Update => ({ ref, old, new: next });
17const move = (ref: string, to: OidExpr): Move => ({ ref, to });
18const one = (outcome: Outcome, error: string | null): StepExpect => ({ outcome, error });
19const both = (e: StepExpect): Expectation => ({ tag: 'one', ply: e, git: e });
20const LANDED: Expectation = both(one('landed', null));
21const finalAt = (ref: string, name: string): FinalRef => ({ tag: 'at', ref, at: name });
22const absent = (ref: string): FinalRef => ({ tag: 'absent', ref });
23const pushOf = (updates: NonEmpty<Update>, atomic = false): Push => ({ updates, atomic, omit: [], pack: { tag: 'objects' } });
24const MAIN = 'refs/heads/main';
25const SIDE = 'refs/heads/side';
27// base -- ff (f.txt changed)
28// \- diverged (g.txt added)
29const CORE: readonly ObjectSpec[] = [
30 commit('base', [], [text('f.txt', 'base\n'), text('dir/n.txt', 'nested\n')]),
31 commit('ff', ['base'], [text('f.txt', 'ff\n')]),
32 commit('diverged', ['base'], [text('g.txt', 'diverged\n')]),
33];
34const EXACT = { tag: 'exact' } as const;
35const PLAIN = { referenceConfig: [], compare: EXACT } as const;
36const SAME = { tag: 'same' } as const;
37const NO_FAULT = { tag: 'none' } as const;
38const FULL = { tag: 'full' } as const;
39const step = (push: Push, fault: Fault = NO_FAULT) => ({ tag: 'push', push, fault, git: SAME, ply: SAME, from: FULL, timeouts: null }) as const;
40const mapNonEmpty = <T, U>(xs: NonEmpty<T>, f: (x: T) => U): NonEmpty<U> => [f(xs[0]), ...xs.slice(1).map(x => f(x))];
42const CONTENDER_INDEXES: NonEmpty<number> = [0, 1, 2, 3, 4, 5, 6, 7];
43const CONTENDERS = CONTENDER_INDEXES.length;
44const contenders: NonEmpty<CommitSpec> = mapNonEmpty(CONTENDER_INDEXES, i => commit(`c${i}`, ['base'], [text(`c${i}.txt`, `contender ${i}\n`)]));
45const contenderNames = mapNonEmpty(contenders, c => c.name);
47// 66 MiB of incompressible content in three 22 MiB blobs: over a 64 MiB pack cap, each blob under a 32 MiB object cap.
48const MIB = 1024 * 1024;
49const BIG = commit('big', ['base'], [noise('big/a.bin', 'a', 22 * MIB), noise('big/b.bin', 'b', 22 * MIB), noise('big/c.bin', 'c', 22 * MIB)]);
50const MANY = 50;
52// ---- days 5-6 batch B objects ----
53// x: a child of ff; a depth-2 shallow fetch of x holds x and ff, with base below the boundary
54const X = commit('x', ['ff'], [text('f.txt', 'x\n')]);
55// ghost and thin: siblings of ff; ghost is never on the target and holds the blob a thin pack names as its delta base
56const LINES = Array.from({ length: 200 }, (_, i) => `line ${i}\n`).join('');
57const GHOST = commit('ghost', ['base'], [text('t.txt', LINES)]);
58const THIN = commit('thin', ['base'], [text('t.txt', `${LINES}one more\n`)]);
59// y changes f.txt on ff; z adds copy.txt holding the same blob as dir/n.txt, which a blob:none clone never fetched
60const Y = commit('y', ['ff'], [text('f.txt', 'y\n')]);
61const Z = commit('z', ['ff'], [text('copy.txt', 'nested\n')]);
62const blob = (of: string, path: string): ObjRef => ({ tag: 'blob', of, path });
63const hand = (push: Push, deltaBase: ObjRef | null, delta: 'literal' | 'copy-past-end', damage: Damage): Push => ({ ...push, pack: { tag: 'hand', deltaBase, delta, damage } });
64const NO_GIT_PACK = { tag: 'none', why: 'stock git writes its own packs; this pack is written by the harness and sent by ply (pushPack)' } as const;
65const handStep = (push: Push) => ({ tag: 'push', push, fault: NO_FAULT, git: NO_GIT_PACK, ply: SAME, from: FULL, timeouts: null }) as const;
66// ---- days 5-6 batch C objects and steps ----
67// mid: 2 MiB of incompressible content on base, so a cut or a stall lands inside the pack
68const MID = commit('mid', ['base'], [noise('mid.bin', 'mid', 2 * MIB)]);
69const fetchStep = (want: string, fault: Fault, timeouts: Timeouts = null) => ({ tag: 'fetch', ref: MAIN, want, fault, git: SAME, timeouts }) as const;
70const STALL_MS = 20_000;
71const REFUSED_PACK = { tag: 'one', ply: one('rejected', 'push_rejected'), git: null } as const;
73type Corruption = Exclude<Damage, 'none'>;
74const DAMAGE_TEXT: Readonly<Record<Corruption, string>> = {
75 'bad-trailer': 'a wrong trailing SHA-1',
76 'bad-zlib': 'an object whose zlib stream fails its Adler-32 check (trailer recomputed)',
77 truncated: 'only its first half',
78};
79const corrupt = (damage: Corruption): Scenario => ({
80 id: `pack.push-corrupt-pack-refused#${damage}`,
81 description: `ply pushes base->ff in a pack with ${DAMAGE_TEXT[damage]}: refused, main unchanged.`,
82 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
83 steps: [handStep(hand(pushOf([upd(MAIN, o('base'), o('ff'))]), null, 'literal', damage))],
84 expect: [REFUSED_PACK],
85 final: [finalAt(MAIN, 'base')],
86 ...PLAIN,
87});
89// ---- 2026-11-15: malformed packs and objects. Each is refused with an unpack or ng status, and the state after the
90// refusal is the invariant: main unmoved, the repository still served (a fetch of main lands), and fsck --strict of a
91// mirror clone clean. A defect in the pack's structure is written by the harness and sent by ply (pushPack); a
92// malformed object is seeded byte for byte (git hash-object --literally) and pushed by both clients, whose own pack
93// writers carry it unchecked.
94const REFUSED: StepExpect = one('rejected', 'push_rejected');
95// A directory/file refusal: git 2.47 words it `failed to update ref` (ply: cas_conflict; porcelain: conflict) and git
96// >= 2.51 `refname conflict` (push_rejected), so the reference's answer depends on the git it runs. Both in one push:
97// git 2.47 lands the first and refuses the second (partial); git >= 2.51 refuses both.
98const DF_WHY = "git 2.47 reports a directory/file refusal as 'failed to update ref', git >= 2.51 as 'refname conflict'";
99const DF_REFUSED: Expectation = { tag: 'either', ply: [one('conflict', 'cas_conflict'), REFUSED], git: [one('conflict', 'cas_conflict'), REFUSED], why: DF_WHY };
100const DF_PARTIAL: Expectation = { tag: 'either', ply: [one('partial', 'push_partial'), REFUSED], git: [one('partial', 'push_partial'), REFUSED], why: DF_WHY };
101// After the refused push: a fetch of main (still base) lands for the clients that ran the push.
102const fetchAfter = (git: GitForm): Step => ({ tag: 'fetch', ref: MAIN, want: 'base', fault: NO_FAULT, git, timeouts: null });
103const defectPush = (defect: PackDefect, updates: NonEmpty<Update> = [upd(MAIN, o('base'), o('ff'))]): Push => ({ ...pushOf(updates), pack: { tag: 'defect', defect } });
104const DEFECT_TEXT: Readonly<Record<PackDefect['tag'], string>> = {
105 signature: 'whose signature is PACX',
106 version: 'whose header says version 4',
107 count: 'whose header object count is off',
108 'size-header': 'whose first blob\'s header states one byte more than its zlib stream inflates to',
109 'bad-type': 'whose first blob\'s header carries object type 5 (reserved)',
110 'ofs-delta-before-start': 'whose first blob is an OFS_DELTA reaching before the pack\'s first byte',
111 'delta-size-mismatch': 'whose first blob is a REF_DELTA against base:f.txt stating a result one byte longer than it writes',
112 duplicate: 'holding every object twice',
113 'no-objects': 'with no objects',
114};
115// A pack-structure defect: ply only (stock git writes its own packs).
116const defectScenario = (behaviour: 'pack.push-bad-header-refused' | 'pack.push-bad-entry-refused', variant: string, defect: PackDefect, extra = ''): Scenario => ({
117 id: `${behaviour}#${variant}`,
118 description: `ply pushes base->ff in a pack ${DEFECT_TEXT[defect.tag]}${extra}: refused, main unchanged, main still fetchable, fsck clean.`,
119 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
120 steps: [handStep(defectPush(defect)), fetchAfter(NO_GIT_PACK)],
121 expect: [{ tag: 'one', ply: REFUSED, git: null }, { tag: 'one', ply: one('landed', null), git: null }],
122 final: [finalAt(MAIN, 'base')],
123 ...PLAIN,
124});
125// Malformed objects, written byte for byte: trees over base's and ff's f.txt blobs, commits on base's tree.
126const BASE_F = blob('base', 'f.txt');
127const FF_F = blob('ff', 'f.txt');
128const entry = (mode: string, name: string, b: ObjRef): RawTreeEntry => ({ mode, name, blob: b });
129const rawTree = (name: string, entries: NonEmpty<RawTreeEntry>): RawTreeSpec => ({ tag: 'raw-tree', name, entries });
130const rawCommit = (name: string, tree: string, author: string): RawCommitSpec => ({ tag: 'raw-commit', name, tree, parents: ['base'], author, message: name });
131const PROBE_ID = 'ply probe <probe@ply.invalid>';
132// One malformed object pushed as main base->bad by both clients: refused (receive.fsckObjects), main unchanged.
133const fsckScenario = (behaviour: 'pack.push-fsck-tree-refused' | 'pack.push-fsck-commit-refused', variant: string, what: string, objects: readonly ObjectSpec[], fsckId: string): Scenario => ({
134 id: `${behaviour}#${variant}`,
135 description: `Both clients push main base->bad, where bad ${what} (git fsck: ${fsckId}): refused, main unchanged, main still fetchable, fsck clean.`,
136 seed: { objects: [...CORE, ...objects], refs: [at(MAIN, 'base')] },
137 steps: [step(pushOf([upd(MAIN, o('base'), o('bad'))])), fetchAfter(SAME)],
138 expect: [both(REFUSED), LANDED],
139 final: [finalAt(MAIN, 'base')],
140 ...PLAIN,
141});
142const treeCase = (variant: string, what: string, fsckId: string, entries: NonEmpty<RawTreeEntry>): Scenario =>
143 fsckScenario('pack.push-fsck-tree-refused', variant, `is a commit on base whose tree ${what}`, [rawTree('t', entries), rawCommit('bad', 't', `${PROBE_ID} 1700000000 +0000`)], fsckId);
144const commitCase = (variant: string, what: string, fsckId: string, author: string): Scenario =>
145 fsckScenario('pack.push-fsck-commit-refused', variant, `is a commit on base's tree whose author line ${what}`, [rawCommit('bad', 'base', author)], fsckId);
146// 16 MiB of one byte: deflates to about 16 KiB (about 1000:1), under a 32 MiB object cap and the 64 MiB pack cap.
147const RATIO = commit('ratio', ['base'], [{ path: 'zeros.bin', content: { tag: 'repeat', byte: 0, bytes: 16 * MIB } }]);
149const MALFORMED: readonly Scenario[] = [
150 {
151 id: 'fetch.want-unreachable-or-unknown#phantom',
152 description: 'ply fetches an id no one holds (want phantom): the server refuses it (ERR not our ref) and ply reports a typed remote error; main unchanged, fsck clean.',
153 seed: { objects: [...CORE, { tag: 'phantom', name: 'phantom', seed: 'want-unknown' }], refs: [at(MAIN, 'base')] },
154 steps: [{ tag: 'fetch', ref: MAIN, want: 'phantom', fault: NO_FAULT, git: { tag: 'none', why: 'the runner\'s git fetch names a ref; stock git\'s form, git fetch <url> <unknown id>, is loadgen-phase3 fake_sha' }, timeouts: null }],
155 expect: [{ tag: 'one', ply: one('rejected', 'remote_error'), git: null }],
156 final: [finalAt(MAIN, 'base')],
157 ...PLAIN,
158 },
159 defectScenario('pack.push-bad-header-refused', 'bad-signature', { tag: 'signature' }),
160 defectScenario('pack.push-bad-header-refused', 'bad-version', { tag: 'version', version: 4 }),
161 defectScenario('pack.push-bad-header-refused', 'count-more', { tag: 'count', by: 1 }, ' (one more than sent)'),
162 defectScenario('pack.push-bad-header-refused', 'count-fewer', { tag: 'count', by: -1 }, ' (one fewer than sent)'),
163 defectScenario('pack.push-bad-entry-refused', 'size-header-mismatch', { tag: 'size-header', by: 1 }),
164 defectScenario('pack.push-bad-entry-refused', 'bad-type', { tag: 'bad-type', type: 5 }),
165 defectScenario('pack.push-bad-entry-refused', 'ofs-delta-before-start', { tag: 'ofs-delta-before-start' }),
166 defectScenario('pack.push-bad-entry-refused', 'delta-size-mismatch', { tag: 'delta-size-mismatch', base: BASE_F }),
167 {
168 id: 'pack.push-duplicate-entries#every-object-twice',
169 // git http-backend with receive.fsckObjects (index-pack --strict) refuses a pack naming an object twice: unpacker error
170 description: 'ply pushes base->ff in a pack holding every object twice (count doubled): refused, main unchanged, main still fetchable, fsck clean.',
171 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
172 steps: [handStep(defectPush({ tag: 'duplicate' })), fetchAfter(NO_GIT_PACK)],
173 expect: [{ tag: 'one', ply: REFUSED, git: null }, { tag: 'one', ply: one('landed', null), git: null }],
174 final: [finalAt(MAIN, 'base')],
175 ...PLAIN,
176 },
177 {
178 id: 'push.ref-to-missing-object-refused#not-in-pack-or-repo',
179 description: 'ply pushes main base->phantom (an id no one holds) with a well-formed pack of no objects: refused (missing necessary objects), main unchanged, still fetchable, fsck clean.',
180 seed: { objects: [...CORE, { tag: 'phantom', name: 'phantom', seed: 'not-in-pack-or-repo' }], refs: [at(MAIN, 'base')] },
181 steps: [{ ...handStep(defectPush({ tag: 'no-objects' }, [upd(MAIN, o('base'), o('phantom'))])), git: { tag: 'none', why: 'stock git refuses client side to push an object it does not have' } }, fetchAfter({ tag: 'none', why: 'stock git has no form of the push' })],
182 expect: [{ tag: 'one', ply: REFUSED, git: null }, { tag: 'one', ply: one('landed', null), git: null }],
183 final: [finalAt(MAIN, 'base')],
184 ...PLAIN,
185 },
186 treeCase('unsorted', 'lists g.txt before f.txt', 'treeNotSorted', [entry('100644', 'g.txt', FF_F), entry('100644', 'f.txt', BASE_F)]),
187 treeCase('duplicate-name', 'names f.txt twice', 'duplicateEntries', [entry('100644', 'f.txt', BASE_F), entry('100644', 'f.txt', FF_F)]),
188 treeCase('slash-in-name', 'has an entry named dir/x.txt', 'fullPathname', [entry('100644', 'dir/x.txt', BASE_F)]),
189 treeCase('dot-git', 'has an entry named .git', 'hasDotgit', [entry('100644', '.git', BASE_F)]),
190 treeCase('zero-padded-mode', 'has a file mode written 0100644', 'zeroPaddedFilemode', [entry('0100644', 'f.txt', BASE_F)]),
191 commitCase('bad-date', 'has the date notadate', 'badDate', `${PROBE_ID} notadate +0000`),
192 commitCase('missing-email', 'has no <email>', 'missingEmail', 'ply probe 1700000000 +0000'),
193 commitCase('bad-timezone', 'has the time zone +00x0', 'badTimezone', `${PROBE_ID} 1700000000 +00x0`),
194 commitCase('date-overflow', 'has a 20-digit date', 'badDateOverflow', `${PROBE_ID} 99999999999999999999 +0000`),
195 {
196 id: 'pack.push-decompression-ratio#zeros-16mib',
197 description: 'Both clients push main base->ratio, whose blob is 16 MiB of zero bytes (about 16 KiB deflated, about 1000:1): lands, fsck clean.',
198 seed: { objects: [...CORE, RATIO], refs: [at(MAIN, 'base')] },
199 steps: [step(pushOf([upd(MAIN, o('base'), o('ratio'))])), { tag: 'fetch', ref: MAIN, want: 'ratio', fault: NO_FAULT, git: SAME, timeouts: null }],
200 expect: [LANDED, LANDED],
201 final: [finalAt(MAIN, 'ratio')],
202 ...PLAIN,
203 },
204];
206// ---- ref and object semantics (phase 4): what git refuses about ref shapes and tag objects ----
207// A tag of a tag (t2 -> t1 -> base), a tag of an object nobody holds, a tag whose type line says tree for a commit.
208const rawTag = (name: string, object: string, type: string, tagName: string): RawTagSpec => ({ tag: 'raw-tag', name, object, type, tagName, message: `tag ${tagName}` });
209const NO_GIT_TAG_WALK: GitForm = { tag: 'none', why: 'stock git walks a pushed tag to its object while packing (pack-objects), so it cannot send a tag of a missing or mistyped object' };
210const listedPush = (updates: NonEmpty<Update>, objects: NonEmpty<string>): Push => ({ ...pushOf(updates), pack: { tag: 'listed', objects } });
211const REF_SEMANTICS: readonly Scenario[] = [
212 {
213 id: 'refs.directory-file-conflict#file-then-dir',
214 description: 'refs/heads/a exists; a create of refs/heads/a/b is refused (a ref cannot be both a name and a directory) and a is untouched.',
215 seed: { objects: CORE, refs: [at(MAIN, 'base'), at('refs/heads/a', 'base')] },
216 steps: [step(pushOf([upd('refs/heads/a/b', ZERO, o('ff'))]))],
217 expect: [DF_REFUSED],
218 final: [finalAt(MAIN, 'base'), finalAt('refs/heads/a', 'base'), absent('refs/heads/a/b')],
219 ...PLAIN,
220 },
221 {
222 id: 'refs.directory-file-conflict#dir-then-file',
223 description: 'refs/heads/a/b exists; a create of refs/heads/a is refused and a/b is untouched.',
224 seed: { objects: CORE, refs: [at(MAIN, 'base'), at('refs/heads/a/b', 'base')] },
225 steps: [step(pushOf([upd('refs/heads/a', ZERO, o('ff'))]))],
226 expect: [DF_REFUSED],
227 final: [finalAt(MAIN, 'base'), finalAt('refs/heads/a/b', 'base'), absent('refs/heads/a')],
228 ...PLAIN,
229 },
230 {
231 id: 'refs.directory-file-conflict#both-in-one-push',
232 description: 'One non-atomic push creating refs/heads/a and refs/heads/a/b: never both. git 2.47 applies each command alone, so a lands and a/b is refused (partial); git >= 2.51 checks the batch together, and the CI image\'s 2.56.1 was seen to land a/b and refuse a.',
233 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
234 steps: [step(pushOf([upd('refs/heads/a', ZERO, o('ff')), upd('refs/heads/a/b', ZERO, o('diverged'))]))],
235 expect: [DF_PARTIAL],
236 // which ref survives depends on git's version (DF_WHY); a server that lands both reports `landed`, which DF_PARTIAL does not list
237 final: [finalAt(MAIN, 'base'), { tag: 'one-of', ref: 'refs/heads/a', names: ['ff', ABSENT] }, { tag: 'one-of', ref: 'refs/heads/a/b', names: ['diverged', ABSENT] }],
238 ...PLAIN,
239 },
240 {
241 id: 'refs.symref-head#delete-default-branch',
242 description: 'A delete of the default branch main (what HEAD names) while side exists: refused (receive.denyDeleteCurrent, git\'s default); main and HEAD unchanged.',
243 seed: { objects: CORE, refs: [at(MAIN, 'base'), at(SIDE, 'ff')] },
244 steps: [step(pushOf([upd(MAIN, o('base'), ZERO)]))],
245 expect: [both(REFUSED)],
246 final: [finalAt(MAIN, 'base'), finalAt(SIDE, 'ff')],
247 ...PLAIN,
248 },
249 {
250 id: 'tags.peel-chain#tag-of-tag',
251 description: 'refs/tags/v2 created at a tag (t2) of a tag (t1) of base: lands, both tag objects reachable, peels to base.',
252 seed: { objects: [...CORE, tag('t1', 'base', 'v1'), rawTag('t2', 't1', 'tag', 'v2')], refs: [at(MAIN, 'base')] },
253 steps: [step(pushOf([upd('refs/tags/v2', ZERO, o('t2'))]))],
254 expect: [LANDED],
255 final: [finalAt(MAIN, 'base'), finalAt('refs/tags/v2', 't2')],
256 ...PLAIN,
257 },
258 {
259 id: 'push.ref-to-missing-object-refused#tag-of-missing-object',
260 description: 'refs/tags/m created at a tag object (sent) whose object nobody holds: refused (missing necessary objects); no ref, fsck clean.',
261 seed: { objects: [...CORE, { tag: 'phantom', name: 'phantom', seed: 'tag-of-missing' }, rawTag('tm', 'phantom', 'commit', 'm')], refs: [at(MAIN, 'base')] },
262 steps: [{ ...step(listedPush([upd('refs/tags/m', ZERO, o('tm'))], ['tm'])), git: NO_GIT_TAG_WALK }],
263 expect: [{ tag: 'one', ply: one('rejected', 'push_rejected'), git: null }],
264 final: [finalAt(MAIN, 'base'), absent('refs/tags/m')],
265 ...PLAIN,
266 },
267 {
268 id: 'pack.push-malformed-object-refused#tag-type-mismatch',
269 description: 'refs/tags/w created at a tag object (sent) whose type line says tree while its object, base, is a commit the server holds: refused; no ref, fsck clean.',
270 seed: { objects: [...CORE, rawTag('tw', 'base', 'tree', 'w')], refs: [at(MAIN, 'base')] },
271 steps: [{ ...step(listedPush([upd('refs/tags/w', ZERO, o('tw'))], ['tw'])), git: NO_GIT_TAG_WALK }],
272 expect: [{ tag: 'one', ply: one('rejected', 'push_rejected'), git: null }],
273 final: [finalAt(MAIN, 'base'), absent('refs/tags/w')],
274 ...PLAIN,
275 },
276 {
277 id: 'tags.move-existing-tag#non-fast-forward',
278 description: 'refs/tags/v1 (lightweight, at ff) moved to diverged naming the current old id (git: a lease, which forces): accepted as any ref update.',
279 seed: { objects: CORE, refs: [at(MAIN, 'base'), at('refs/tags/v1', 'ff')] },
280 steps: [step(pushOf([upd('refs/tags/v1', o('ff'), o('diverged'))]))],
281 expect: [LANDED],
282 final: [finalAt(MAIN, 'base'), finalAt('refs/tags/v1', 'diverged')],
283 ...PLAIN,
284 },
285 {
286 id: 'tags.move-existing-tag#annotated-to-other-tag',
287 description: 'refs/tags/v1 at annotated t1 (base) moved to annotated t3 (ff) with the current old id: accepted; t1 no longer reachable.',
288 seed: { objects: [...CORE, tag('t1', 'base', 'v1'), tag('t3', 'ff', 'v1')], refs: [at(MAIN, 'base'), at('refs/tags/v1', 't1')] },
289 steps: [step(pushOf([upd('refs/tags/v1', o('t1'), o('t3'))]))],
290 expect: [LANDED],
291 final: [finalAt(MAIN, 'base'), finalAt('refs/tags/v1', 't3')],
292 ...PLAIN,
293 },
294 {
295 id: 'tags.delete#annotated',
296 description: 'A delete of refs/tags/v1, an annotated tag, naming the tag object as the old id.',
297 seed: { objects: [...CORE, tag('t1', 'base', 'v1')], refs: [at(MAIN, 'base'), at('refs/tags/v1', 't1')] },
298 steps: [step(pushOf([upd('refs/tags/v1', o('t1'), ZERO)]))],
299 expect: [LANDED],
300 final: [finalAt(MAIN, 'base'), absent('refs/tags/v1')],
301 ...PLAIN,
302 },
303];
305export const SCENARIOS: readonly Scenario[] = [
306 {
307 id: 'concurrency.stale-old-oid#race',
308 description: 'Both clients read main at base; another writer moves main to diverged while the receive-pack request is held; the push base->ff must be refused and main stay at diverged.',
309 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
310 steps: [step(pushOf([upd(MAIN, o('base'), o('ff'))]), { tag: 'race', moves: [move(MAIN, o('diverged'))] })],
311 expect: [both(one('conflict', 'cas_conflict'))],
312 final: [finalAt(MAIN, 'diverged')],
313 ...PLAIN,
314 },
315 {
316 id: 'concurrency.stale-old-oid#direct',
317 description: 'ply sends a push whose old id (base) is already stale (main is at diverged): the server refuses it, main unchanged.',
318 seed: { objects: CORE, refs: [at(MAIN, 'diverged')] },
319 steps: [{ tag: 'push', push: pushOf([upd(MAIN, o('base'), o('ff'))]), fault: NO_FAULT, from: FULL, timeouts: null, ply: SAME, git: { tag: 'none', why: 'stock git checks --force-with-lease against its own advertisement and refuses client side ("stale info"); the race variant is its server-side form' } }],
320 expect: [{ tag: 'one', ply: one('conflict', 'cas_conflict'), git: null }],
321 final: [finalAt(MAIN, 'diverged')],
322 ...PLAIN,
323 },
324 {
325 id: 'interrupted.push-response-lost#cut',
326 // stock git (libcurl) re-sends a request whose reused connection closed with no answer, so git's push is sent twice:
327 // the replay meets the server's compare-and-swap (main is already ff) and is refused, and git's own retry finds
328 // main up to date. ply sends once and says ambiguous. Both must leave main at ff with nothing applied twice.
329 description: 'The server applies base->ff but its answer is cut: ply must report ambiguous, refs show the push landed, a naive retry is refused; stock git\'s transparent re-send must be refused by compare-and-swap.',
330 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
331 steps: [step(pushOf([upd(MAIN, o('base'), o('ff'))]), { tag: 'cut-response' }), step(pushOf([upd(MAIN, o('base'), o('ff'))]))],
332 expect: [{ tag: 'one', ply: one('ambiguous', 'ambiguous'), git: one('conflict', 'cas_conflict') }, { tag: 'one', ply: one('conflict', 'cas_conflict'), git: one('landed', null) }],
333 final: [finalAt(MAIN, 'ff')],
334 ...PLAIN,
335 },
336 {
337 id: 'concurrency.empty-report-under-contention#distinct-refs',
338 description: `${CONTENDERS} pushes at once to one repository, each creating its own branch: every one lands, or is reported ambiguous (never landed when it did not).`,
339 seed: { objects: [...CORE, ...contenders], refs: [at(MAIN, 'base')] },
340 steps: [{ tag: 'concurrent', pushes: mapNonEmpty(contenders, c => pushOf([upd(`refs/heads/p-${c.name}`, ZERO, o(c.name))])), git: SAME }],
341 expect: [{ tag: 'many', ply: contenders.map(() => 'landed' as const), git: contenders.map(() => 'landed' as const) }],
342 final: contenders.map(c => finalAt(`refs/heads/p-${c.name}`, c.name)),
343 ...PLAIN,
344 },
345 {
346 id: 'concurrency.empty-report-under-contention#same-ref',
347 description: `${CONTENDERS} pushes at once moving main from base to ${CONTENDERS} different commits: exactly one lands, the rest are refused as conflicts.`,
348 seed: { objects: [...CORE, ...contenders], refs: [at(MAIN, 'base')] },
349 steps: [{ tag: 'concurrent', pushes: mapNonEmpty(contenders, c => pushOf([upd(MAIN, o('base'), o(c.name))])), git: SAME }],
350 expect: [{ tag: 'many', ply: ['landed', ...contenders.slice(1).map(() => 'conflict' as const)], git: ['landed', ...contenders.slice(1).map(() => 'conflict' as const)] }],
351 final: [{ tag: 'one-of', ref: MAIN, names: contenderNames }],
352 referenceConfig: [],
353 compare: { tag: 'winner-of', why: 'the winner of a same-ref race is not fixed; objects, trees and ancestry follow it' },
354 },
355 {
356 id: 'push.atomic#all-land',
357 description: 'An atomic push moving main and side base->ff: both land.',
358 seed: { objects: CORE, refs: [at(MAIN, 'base'), at(SIDE, 'base')] },
359 steps: [step(pushOf([upd(MAIN, o('base'), o('ff')), upd(SIDE, o('base'), o('ff'))], true))],
360 expect: [LANDED],
361 final: [finalAt(MAIN, 'ff'), finalAt(SIDE, 'ff')],
362 ...PLAIN,
363 },
364 {
365 id: 'push.atomic#one-stale',
366 description: 'An atomic push of main and side base->ff while another writer moves side to diverged: neither lands.',
367 seed: { objects: CORE, refs: [at(MAIN, 'base'), at(SIDE, 'base')] },
368 steps: [step(pushOf([upd(MAIN, o('base'), o('ff')), upd(SIDE, o('base'), o('ff'))], true), { tag: 'race', moves: [move(SIDE, o('diverged'))] })],
369 expect: [both(one('conflict', 'cas_conflict'))],
370 final: [finalAt(MAIN, 'base'), finalAt(SIDE, 'diverged')],
371 ...PLAIN,
372 },
373 {
374 id: 'push.non-atomic-partial#one-stale',
375 description: 'A non-atomic push of main and side base->ff while another writer moves side to diverged: main lands, side is refused, the client says which.',
376 seed: { objects: CORE, refs: [at(MAIN, 'base'), at(SIDE, 'base')] },
377 steps: [step(pushOf([upd(MAIN, o('base'), o('ff')), upd(SIDE, o('base'), o('ff'))]), { tag: 'race', moves: [move(SIDE, o('diverged'))] })],
378 expect: [both(one('partial', 'push_partial'))],
379 final: [finalAt(MAIN, 'ff'), finalAt(SIDE, 'diverged')],
380 ...PLAIN,
381 },
382 {
383 id: 'concurrency.ref-created-between-read-and-push#race',
384 description: 'A create of refs/heads/new (zero old id) while another writer creates it first: refused, the winner kept.',
385 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
386 steps: [step(pushOf([upd('refs/heads/new', ZERO, o('ff'))]), { tag: 'race', moves: [move('refs/heads/new', o('diverged'))] })],
387 expect: [both(one('conflict', 'cas_conflict'))],
388 final: [finalAt(MAIN, 'base'), finalAt('refs/heads/new', 'diverged')],
389 ...PLAIN,
390 },
391 {
392 id: 'concurrency.ref-deleted-between-read-and-push#race',
393 description: 'An update side base->ff while another writer deletes side: refused, side stays deleted.',
394 seed: { objects: CORE, refs: [at(MAIN, 'base'), at(SIDE, 'base')] },
395 steps: [step(pushOf([upd(SIDE, o('base'), o('ff'))]), { tag: 'race', moves: [move(SIDE, ZERO)] })],
396 expect: [both(one('conflict', 'cas_conflict'))],
397 final: [finalAt(MAIN, 'base'), absent(SIDE)],
398 ...PLAIN,
399 },
400 {
401 id: 'push.size-limits#pack-over-cap',
402 description: 'A 66 MiB pack (three 22 MiB incompressible blobs) against a 64 MiB receive cap: refused, main unchanged.',
403 seed: { objects: [...CORE, BIG], refs: [at(MAIN, 'base')] },
404 steps: [step(pushOf([upd(MAIN, o('base'), o('big'))]))],
405 // ply classifies limit_exceeded from Artifacts' wording only; git http-backend's refusal is "unpacker error" with the
406 // reason on band 2, which stock git's stderr shows ("pack exceeds maximum allowed size")
407 expect: [{ tag: 'one', ply: one('rejected', 'push_rejected'), git: one('rejected', 'limit_exceeded') }],
408 final: [finalAt(MAIN, 'base')],
409 ...PLAIN,
410 },
411 {
412 id: 'push.non-fast-forward#with-old-id',
413 description: 'A non-fast-forward update ff->diverged naming the current old id (a forced update with a lease): accepted.',
414 seed: { objects: CORE, refs: [at(MAIN, 'ff')] },
415 steps: [step(pushOf([upd(MAIN, o('ff'), o('diverged'))]))],
416 expect: [LANDED],
417 final: [finalAt(MAIN, 'diverged')],
418 ...PLAIN,
419 },
420 {
421 id: 'push.fast-forward-update#plain',
422 description: 'A fast-forward update base->ff with the current old id lands.',
423 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
424 steps: [step(pushOf([upd(MAIN, o('base'), o('ff'))]))],
425 expect: [LANDED],
426 final: [finalAt(MAIN, 'ff')],
427 ...PLAIN,
428 },
429 {
430 id: 'push.create-ref#plain',
431 description: 'A create (zero old id) of refs/heads/new at ff lands.',
432 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
433 steps: [step(pushOf([upd('refs/heads/new', ZERO, o('ff'))]))],
434 expect: [LANDED],
435 final: [finalAt(MAIN, 'base'), finalAt('refs/heads/new', 'ff')],
436 ...PLAIN,
437 },
438 {
439 id: 'push.create-ref#already-exists',
440 // pins the git form of a create: with a lease or force git would overwrite the ref (git 2.47 ignores an empty or zero
441 // lease on a create); as a plain push it refuses client side, and ply's zero old id is refused by the server
442 description: 'A create (zero old id) of refs/heads/new at ff when new already exists at diverged: refused, new unchanged.',
443 seed: { objects: CORE, refs: [at(MAIN, 'base'), at('refs/heads/new', 'diverged')] },
444 steps: [step(pushOf([upd('refs/heads/new', ZERO, o('ff'))]))],
445 expect: [both(one('conflict', 'cas_conflict'))],
446 final: [finalAt(MAIN, 'base'), finalAt('refs/heads/new', 'diverged')],
447 ...PLAIN,
448 },
449 {
450 id: 'push.delete-ref#plain',
451 description: 'A delete (zero new id) of side lands.',
452 seed: { objects: CORE, refs: [at(MAIN, 'base'), at(SIDE, 'base')] },
453 steps: [step(pushOf([upd(SIDE, o('base'), ZERO)]))],
454 expect: [LANDED],
455 final: [finalAt(MAIN, 'base'), absent(SIDE)],
456 ...PLAIN,
457 },
458 {
459 id: 'push.first-commit-empty-repo#root',
460 description: 'The first push to an empty repository creates main from a root commit; HEAD names main.',
461 seed: { objects: CORE, refs: [] },
462 steps: [step(pushOf([upd(MAIN, ZERO, o('base'))]))],
463 expect: [LANDED],
464 final: [finalAt(MAIN, 'base')],
465 ...PLAIN,
466 },
467 {
468 id: 'tags.lightweight-create#plain',
469 description: 'A lightweight tag refs/tags/v1 created at ff (sending ff\'s objects).',
470 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
471 steps: [step(pushOf([upd('refs/tags/v1', ZERO, o('ff'))]))],
472 expect: [LANDED],
473 final: [finalAt(MAIN, 'base'), finalAt('refs/tags/v1', 'ff')],
474 ...PLAIN,
475 },
476 {
477 id: 'tags.annotated-create#plain',
478 description: 'An annotated tag object for base pushed as refs/tags/v1.',
479 seed: { objects: [...CORE, tag('t1', 'base', 'v1')], refs: [at(MAIN, 'base')] },
480 steps: [step(pushOf([upd('refs/tags/v1', ZERO, o('t1'))]))],
481 expect: [LANDED],
482 final: [finalAt(MAIN, 'base'), finalAt('refs/tags/v1', 't1')],
483 ...PLAIN,
484 },
485 {
486 id: 'tags.delete#plain',
487 description: 'A delete of refs/tags/v0.',
488 seed: { objects: CORE, refs: [at(MAIN, 'base'), at('refs/tags/v0', 'base')] },
489 steps: [step(pushOf([upd('refs/tags/v0', o('base'), ZERO)]))],
490 expect: [LANDED],
491 final: [finalAt(MAIN, 'base'), absent('refs/tags/v0')],
492 ...PLAIN,
493 },
494 {
495 id: 'ancestry.merge-commit-push#two-parents',
496 description: 'A two-parent merge of ff and diverged pushed onto main (base->merge): ancestry and merge bases as git computes them.',
497 seed: { objects: [...CORE, commit('merge', ['ff', 'diverged'], [text('g.txt', 'diverged\n')])], refs: [at(MAIN, 'base'), at(SIDE, 'diverged')] },
498 steps: [step(pushOf([upd(MAIN, o('base'), o('merge'))]))],
499 expect: [LANDED],
500 final: [finalAt(MAIN, 'merge'), finalAt(SIDE, 'diverged')],
501 ...PLAIN,
502 },
503 {
504 id: 'push.many-ref-updates#fifty-creates',
505 description: `One push creating ${MANY} branches at ff.`,
506 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
507 steps: [step(pushOf(mapNonEmpty([0, ...Array.from({ length: MANY - 1 }, (_, i) => i + 1)], i => upd(`refs/heads/many/${String(i).padStart(2, '0')}`, ZERO, o('ff')))))],
508 expect: [LANDED],
509 final: [finalAt(MAIN, 'base'), ...Array.from({ length: MANY }, (_, i) => finalAt(`refs/heads/many/${String(i).padStart(2, '0')}`, 'ff'))],
510 ...PLAIN,
511 },
512 // ---- days 5-6: more race shapes, retry after a refusal under contention ----
513 {
514 id: 'concurrency.stale-old-oid#delete-vs-update',
515 description: 'Both clients read side at base and delete it; another writer moves side to diverged while the request is held: the delete must be refused and side stay at diverged.',
516 seed: { objects: CORE, refs: [at(MAIN, 'base'), at(SIDE, 'base')] },
517 steps: [step(pushOf([upd(SIDE, o('base'), ZERO)]), { tag: 'race', moves: [move(SIDE, o('diverged'))] })],
518 expect: [both(one('conflict', 'cas_conflict'))],
519 final: [finalAt(MAIN, 'base'), finalAt(SIDE, 'diverged')],
520 ...PLAIN,
521 },
522 {
523 id: 'concurrency.concurrent-writers#create-vs-create',
524 description: 'Two pushes at once create refs/heads/new, one at ff and one at diverged: exactly one lands, the other is refused as a conflict.',
525 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
526 steps: [{ tag: 'concurrent', pushes: [pushOf([upd('refs/heads/new', ZERO, o('ff'))]), pushOf([upd('refs/heads/new', ZERO, o('diverged'))])], git: SAME }],
527 expect: [{ tag: 'many', ply: ['landed', 'conflict'], git: ['landed', 'conflict'] }],
528 final: [finalAt(MAIN, 'base'), { tag: 'one-of', ref: 'refs/heads/new', names: ['ff', 'diverged'] }],
529 referenceConfig: [],
530 compare: { tag: 'winner-of', why: 'the winner of a create race is not fixed; objects, trees and ancestry follow it' },
531 },
532 {
533 id: 'concurrency.concurrent-writers#delete-vs-update',
534 description: 'Two pushes at once on side (at base): one deletes it, one moves it to ff: exactly one lands, the other is refused as a conflict.',
535 seed: { objects: CORE, refs: [at(MAIN, 'base'), at(SIDE, 'base')] },
536 steps: [{ tag: 'concurrent', pushes: [pushOf([upd(SIDE, o('base'), ZERO)]), pushOf([upd(SIDE, o('base'), o('ff'))])], git: SAME }],
537 expect: [{ tag: 'many', ply: ['landed', 'conflict'], git: ['landed', 'conflict'] }],
538 final: [finalAt(MAIN, 'base'), { tag: 'one-of', ref: SIDE, names: ['ff', ABSENT] }],
539 referenceConfig: [],
540 compare: { tag: 'winner-of', why: 'the winner of a delete/update race is not fixed; objects, trees and ancestry follow it' },
541 },
542 {
543 id: 'concurrency.empty-report-under-contention#retry-after-busy',
544 description: `${CONTENDERS} pushes at once, each creating its own branch; then every push that did not land is sent again, one at a time: each retry lands (a create of a ref the first attempt had made would be refused), so nothing reported unknown was applied.`,
545 seed: { objects: [...CORE, ...contenders], refs: [at(MAIN, 'base')] },
546 steps: [
547 { tag: 'concurrent', pushes: mapNonEmpty(contenders, c => pushOf([upd(`refs/heads/p-${c.name}`, ZERO, o(c.name))])), git: SAME },
548 { tag: 'retry-unlanded', of: 0, git: SAME },
549 ],
550 expect: [
551 { tag: 'many', ply: contenders.map(() => 'landed' as const), git: contenders.map(() => 'landed' as const) },
552 { tag: 'many', ply: contenders.map(() => 'landed' as const), git: contenders.map(() => 'landed' as const) },
553 ],
554 final: contenders.map(c => finalAt(`refs/heads/p-${c.name}`, c.name)),
555 ...PLAIN,
556 },
557 // ---- days 5-6 batch B: packs ply sends as written, shallow and partial clients ----
558 {
559 id: 'pack.push-thin-against-server-base#literal-delta',
560 description: 'ply pushes thin (t.txt of thin as a REF_DELTA against base:f.txt, which the server holds): the server completes it and the push lands.',
561 seed: { objects: [...CORE, GHOST, THIN], refs: [at(MAIN, 'base')] },
562 steps: [{ ...handStep(hand(pushOf([upd(MAIN, o('base'), o('thin'))]), blob('base', 'f.txt'), 'literal', 'none')), git: SAME }],
563 expect: [LANDED],
564 final: [finalAt(MAIN, 'thin')],
565 ...PLAIN,
566 },
567 {
568 id: 'pack.push-thin-missing-base#ghost-base',
569 description: 'ply pushes a pack whose only blob is a REF_DELTA against ghost:t.txt, which the server never had: refused, main unchanged.',
570 seed: { objects: [...CORE, GHOST, THIN], refs: [at(MAIN, 'base')] },
571 steps: [handStep(hand(pushOf([upd(MAIN, o('base'), o('thin'))]), blob('ghost', 't.txt'), 'literal', 'none'))],
572 expect: [REFUSED_PACK],
573 final: [finalAt(MAIN, 'base')],
574 ...PLAIN,
575 },
576 {
577 id: 'pack.push-malformed-object-refused#missing-blob',
578 description: 'ply pushes base->ff in a pack missing ff\'s new f.txt blob (the tree names it): refused, main unchanged.',
579 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
580 steps: [handStep({ ...hand(pushOf([upd(MAIN, o('base'), o('ff'))]), null, 'literal', 'none'), omit: [blob('ff', 'f.txt')] })],
581 expect: [REFUSED_PACK],
582 final: [finalAt(MAIN, 'base')],
583 ...PLAIN,
584 },
585 {
586 id: 'pack.push-malformed-object-refused#delta-copy-past-end',
587 description: 'ply pushes base->ff with ff\'s blob as a REF_DELTA against base:f.txt whose copy reads past the end of the base: refused, main unchanged.',
588 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
589 steps: [handStep(hand(pushOf([upd(MAIN, o('base'), o('ff'))]), blob('base', 'f.txt'), 'copy-past-end', 'none'))],
590 expect: [REFUSED_PACK],
591 final: [finalAt(MAIN, 'base')],
592 ...PLAIN,
593 },
594 corrupt('bad-trailer'),
595 corrupt('bad-zlib'),
596 corrupt('truncated'),
597 {
598 id: 'push.from-shallow-clone#boundary-held',
599 description: 'main at ff; stock git pushes x (a child of ff) from a depth-2 shallow fetch of x (boundary ff, which the server holds): lands.',
600 seed: { objects: [...CORE, X], refs: [at(MAIN, 'ff')] },
601 steps: [{ ...step(pushOf([upd(MAIN, o('ff'), o('x'))])), from: { tag: 'shallow', tip: 'x', depth: 2 } }],
602 expect: [LANDED],
603 final: [finalAt(MAIN, 'x')],
604 ...PLAIN,
605 },
606 {
607 id: 'push.from-shallow-clone#history-missing',
608 description: 'An empty repository; ply pushes x with ff but without base (the history below a depth-2 shallow boundary): refused as a missing object, no ref created.',
609 seed: { objects: [...CORE, X], refs: [] },
610 steps: [{ ...step({ ...pushOf([upd(MAIN, ZERO, o('x'))]), omit: [{ tag: 'commit', name: 'base' }] }), git: { tag: 'none', why: 'stock git sends its shallow boundary with such a push; that form is the shallow-update variant' } }],
611 expect: [{ tag: 'one', ply: one('rejected', 'push_rejected'), git: null }],
612 final: [absent(MAIN)],
613 ...PLAIN,
614 },
615 {
616 id: 'push.from-shallow-clone#shallow-update',
617 // git http-backend refuses this by default ("shallow update not allowed"); the reference runs with
618 // receive.shallowUpdate=true, the receiver this scenario compares against
619 description: 'An empty repository; stock git pushes x from a depth-2 shallow fetch (x and ff, base below the boundary), sending its shallow line; with receive.shallowUpdate=true the push lands and the repository records ff as a shallow boundary.',
620 seed: { objects: [...CORE, X], refs: [] },
621 steps: [{ ...step(pushOf([upd(MAIN, ZERO, o('x'))])), from: { tag: 'shallow', tip: 'x', depth: 2 }, ply: { tag: 'none', why: 'ply keeps no shallow state and sends no shallow line; its form is the history-missing variant' } }],
622 expect: [{ tag: 'one', ply: one('landed', null), git: one('landed', null) }],
623 final: [finalAt(MAIN, 'x')],
624 referenceConfig: [['receive.shallowUpdate', 'true']],
625 compare: EXACT,
626 },
627 {
628 id: 'push.from-partial-clone#blob-none',
629 description: 'main at ff; each client first fetches main with filter blob:none, then pushes y (f.txt changed): lands.',
630 seed: { objects: [...CORE, Y], refs: [at(MAIN, 'ff')] },
631 steps: [{ ...step(pushOf([upd(MAIN, o('ff'), o('y'))])), from: { tag: 'partial' } }],
632 expect: [LANDED],
633 final: [finalAt(MAIN, 'y')],
634 ...PLAIN,
635 },
636 {
637 id: 'push.from-partial-clone#reuse-absent-blob',
638 description: 'main at ff; from a blob:none clone, push z, whose new tree names dir/n.txt\'s blob (never fetched) at copy.txt: lands, and the blob is not sent.',
639 seed: { objects: [...CORE, Z], refs: [at(MAIN, 'ff')] },
640 steps: [{ ...step(pushOf([upd(MAIN, o('ff'), o('z'))])), from: { tag: 'partial' } }],
641 expect: [LANDED],
642 final: [finalAt(MAIN, 'z')],
643 ...PLAIN,
644 },
645 // ---- days 5-6 batch C: a request body cut, stalls on both sides, a fetch answer dropped midway ----
646 {
647 id: 'interrupted.push-body-cut#half',
648 // the 2 MiB body is over git's http.postBuffer, so git streams it (after a 4-byte probe request) and cannot re-send
649 // it: both clients say ambiguous, and each one's retry must land: the server applied nothing of the cut body
650 description: 'A push base->mid (2 MiB) whose request body stops halfway and is aborted: nothing lands; each client says ambiguous and its retry lands; fsck clean.',
651 seed: { objects: [...CORE, MID], refs: [at(MAIN, 'base')] },
652 steps: [step(pushOf([upd(MAIN, o('base'), o('mid'))]), { tag: 'cut-request', fraction: 0.5 }), step(pushOf([upd(MAIN, o('base'), o('mid'))]))],
653 expect: [both(one('ambiguous', 'ambiguous')), LANDED],
654 final: [finalAt(MAIN, 'mid')],
655 ...PLAIN,
656 },
657 {
658 id: 'interrupted.stall-timeouts#push-request-stall',
659 description: `A push base->mid whose request body stops halfway for ${STALL_MS / 1000} s, then finishes: the server waits for it and the push lands.`,
660 seed: { objects: [...CORE, MID], refs: [at(MAIN, 'base')] },
661 steps: [step(pushOf([upd(MAIN, o('base'), o('mid'))]), { tag: 'stall-request', fraction: 0.5, ms: STALL_MS })],
662 expect: [LANDED],
663 final: [finalAt(MAIN, 'mid')],
664 ...PLAIN,
665 },
666 {
667 id: 'interrupted.stall-timeouts#push-request-stall-10s',
668 description: 'A push base->mid whose request body stops halfway for 10 s, then finishes: the server waits for it and the push lands.',
669 seed: { objects: [...CORE, MID], refs: [at(MAIN, 'base')] },
670 steps: [step(pushOf([upd(MAIN, o('base'), o('mid'))]), { tag: 'stall-request', fraction: 0.5, ms: 10_000 })],
671 expect: [LANDED],
672 final: [finalAt(MAIN, 'mid')],
673 ...PLAIN,
674 },
675 {
676 id: 'interrupted.stall-timeouts#push-response-stall',
677 // stock git's timer here is http.lowSpeedTime, which a silent connection trips on some git/libcurl builds (2.47.3 with
678 // curl 8.14) and not on others (CI's 2.56.1 waits and lands), so only ply's answer is stated; both still run
679 description: 'The server applies base->ff and its answer is held 4 s against a 1 s client timer: ply says ambiguous (typed); main is at ff.',
680 seed: { objects: CORE, refs: [at(MAIN, 'base')] },
681 steps: [{ ...step(pushOf([upd(MAIN, o('base'), o('ff'))]), { tag: 'stall-response', ms: 4000 }), timeouts: { ms: 1000 } }],
682 expect: [{ tag: 'one', ply: one('ambiguous', 'ambiguous'), git: null }],
683 final: [finalAt(MAIN, 'ff')],
684 ...PLAIN,
685 },
686 {
687 id: 'interrupted.stall-timeouts#fetch-request-stall',
688 description: `A fetch of main (mid) whose request body stops halfway for ${STALL_MS / 1000} s, then finishes: the server waits and the pack arrives.`,
689 seed: { objects: [...CORE, MID], refs: [at(MAIN, 'mid')] },
690 steps: [fetchStep('mid', { tag: 'stall-request', fraction: 0.5, ms: STALL_MS })],
691 expect: [LANDED],
692 final: [finalAt(MAIN, 'mid')],
693 ...PLAIN,
694 },
695 {
696 id: 'interrupted.stall-timeouts#fetch-response-stall',
697 // as push-response-stall: stock git's lowSpeedTime on a silent connection depends on the build, so only ply's is stated
698 description: 'A fetch of main whose answer is held 4 s against a 1 s client timer: ply fails with a typed timeout, nothing is half-written.',
699 seed: { objects: [...CORE, MID], refs: [at(MAIN, 'mid')] },
700 steps: [fetchStep('mid', { tag: 'stall-response', ms: 4000 }, { ms: 1000 })],
701 expect: [{ tag: 'one', ply: one('rejected', 'timeout'), git: null }],
702 final: [finalAt(MAIN, 'mid')],
703 ...PLAIN,
704 },
705 {
706 id: 'interrupted.fetch-dropped-mid-response#half',
707 description: 'A fetch of main (mid, 2 MiB) whose answer stops halfway (connection closed): each client fails, never a partial result.',
708 seed: { objects: [...CORE, MID], refs: [at(MAIN, 'mid')] },
709 steps: [fetchStep('mid', { tag: 'drop-response', fraction: 0.5 })],
710 expect: [{ tag: 'one', ply: one('rejected', 'network'), git: one('rejected', 'fetch_failed') }],
711 final: [finalAt(MAIN, 'mid')],
712 ...PLAIN,
713 },
714 ...MALFORMED,
715 ...REF_SEMANTICS,
716];
Diagnostics4 git calls · 246 ms
CallStatusSizeTime0246 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 · 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=38434
git.response.cache=HIT
git.response.duration_ms=3
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
fetch20010 KiB240 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=240
git.response.bytes=10711
git.response.cache=MISS
git.response.duration_ms=240
git.fetch.wants=38bb259af95d2242f55984fa4c9faf940ee52ea0
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=10711
git.pkt.payload.max=10690
git.sideband.band1.bytes=10689
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
a5e360d03b2fb86e
Request
f88b4907…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format