Artifactspublic-v0

ply

main
ply4 git calls28 ms39 KiB3 cachedprotocol v2
67 lines4.0 KiBRaw
1// Compile-time checks for the byte-array rule (docs/STACK.md, #100 item 2): every input accepts any `Uint8Array`
2// (ArrayBufferLike); a function that allocates returns `Uint8Array<ArrayBuffer>`. A consumer moves bytes between ply
3// functions with no casts. `tsc --noEmit` must pass; every @ts-expect-error must still be an error.
4import { fetchPack } from '../../src/fetchpack.js';
5import { push, type PackObject } from '../../src/push.js';
6import { parseRefname } from '../../src/refname.js';
7import { spliceDelta, zlibDeflate, buildPack } from '../../src/pack.js';
8import { concat, bufferSource } from '../../src/bytes.js';
9import { signCommit, withGpgsig, type Signer } from '../../src/sign.js';
10import { encodeCommit } from '../../src/objects.js';
11import { frames, type Transport } from '../../src/transport.js';
12import type { PushTransport } from '../../src/push.js';
13import type { Span } from '../../src/otel.js';
15declare const t: Transport & PushTransport;
16declare const span: Span;
17declare const signer: Signer;
18// Bytes of unknown backing (a consumer's own buffer, a SharedArrayBuffer view, a Node Buffer slice).
19declare const anyBytes: Uint8Array;
20declare const shared: Uint8Array<SharedArrayBuffer>;
22// fetchPack → push: fetched objects go straight into a push.
23const consumerFetchThenPush = async (): Promise<void> => {
24 const fetched = await fetchPack(t, { wants: ['0'.repeat(40)] });
25 if (!fetched.ok) return;
26 const r = fetched.value;
27 const objects: PackObject[] = [...(r.objects?.values() ?? [])].map(o => ({ type: o.type, data: o.data }));
28 const ref = ((): import('../../src/refname.js').Refname => { const p = parseRefname('refs/heads/x'); if (!p.ok) throw p.error; return p.value; })();
29 await push(t, { ref, oldOid: '0'.repeat(40), newOid: '1'.repeat(40), objects });
30};
31void consumerFetchThenPush;
33// spliceDelta → zlibDeflate → buildPack: each output is the next input.
34const consumerDeltaThenDeflate = async (): Promise<void> => {
35 const { delta } = spliceDelta({ baseLen: 10, off: 2, oldLen: 3, insert: anyBytes });
36 const z: Uint8Array<ArrayBuffer> = await zlibDeflate(delta);
37 await zlibDeflate(anyBytes);
38 await zlibDeflate(shared);
39 await buildPack([{ type: 3, data: z }, { type: 3, data: anyBytes }, { type: 3, data: shared }, { type: 3, data: delta, base: { tag: 'ref', oid: '2'.repeat(40) } }, { type: 3, data: delta, base: { tag: 'ofs', index: 0 } }, { type: 3, data: z, base: { tag: 'none' } }]);
40 // @ts-expect-error a base is the tagged union, not the old flag fields
41 await buildPack([{ type: 3, data: delta, baseOid: '2'.repeat(40) }]);
42};
43void consumerDeltaThenDeflate;
45// Inputs anywhere: signing, the transport's request body, a pushed object.
46const consumerInputs = async (): Promise<void> => {
47 await signCommit(anyBytes, signer);
48 await signCommit(shared, signer);
49 void withGpgsig(anyBytes, 'sig');
50 for await (const f of frames(t, 'git-upload-pack', anyBytes, span)) void f;
51 const ref = ((): import('../../src/refname.js').Refname => { const p = parseRefname('refs/heads/x'); if (!p.ok) throw p.error; return p.value; })();
52 await push(t, { ref, oldOid: '0'.repeat(40), newOid: '1'.repeat(40), objects: [{ type: 3, data: shared }] });
53};
54void consumerInputs;
56// Allocating functions return ArrayBuffer-backed bytes, so a consumer can hand them to a BufferSource Web API as is.
57const allocated: Array<Uint8Array<ArrayBuffer>> = [
58 concat([anyBytes, shared]),
59 spliceDelta({ baseLen: 1, off: 0, oldLen: 0, insert: anyBytes }).delta,
60 ((): Uint8Array<ArrayBuffer> => { const r = encodeCommit({ tree: '0'.repeat(40), author: 'a <a@b> 0 +0000' }); if (!r.ok) throw r.error; return r.value; })(),
61 ((): Uint8Array<ArrayBuffer> => { const r = withGpgsig(anyBytes, 'sig'); if (!r.ok) throw r.error; return r.value; })(),
62 bufferSource(shared),
63];
64void new Blob(allocated);
65// The rule's other half: an input of unknown backing is not ArrayBuffer-backed until bufferSource makes it so.
66// @ts-expect-error a SharedArrayBuffer view is not a BufferSource
67void new Blob([shared]);
Diagnostics4 git calls · 28 ms
CallStatusSizeTime028 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=55
Open pack map
fetch2001.5 KiB · hit22 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=22
git.response.bytes=1485
git.response.cache=HIT
git.response.duration_ms=22
git.fetch.wants=d704519527e9c8494928eecde255fb8219ddc9c5
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=1485
git.pkt.payload.max=1464
git.sideband.band1.bytes=1463
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
a5e2d9f50b9814c2
Request
dae69a4c…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format