main
ply4 git calls420 ms42 KiB2 cachedprotocol v2
78 lines5.0 KiBRaw
1// The workbench's source of truth: ProbeBench's SQLite (runs, the repositories it created, and the admission window).
2// A run's record (steps, end state, every exchange's metadata, the verdict, cleanup counts, its spans) is one JSON row;
3// exchange bodies are R2 objects named runs/<run id>/<exchange>.<request|response>.
4import type { RunId, RunSeed, RepoName } from './brand.ts';
5import type { RunResult } from './run.ts';
7export type SqlValue = string | number | null;
8export type Sql = { exec(query: string, ...bindings: SqlValue[]): { toArray(): Array<Record<string, unknown>> } };
10export type SpanRow = { readonly id: string; readonly parent: string | null; readonly name: string; readonly startMs: number; readonly durationMs: number; readonly ok: boolean; readonly attrs: Readonly<Record<string, string | number | boolean>> };
11export type StoredRun = {
12 readonly id: RunId;
13 readonly scenario: string;
14 readonly seed: RunSeed;
15 readonly repo: RepoName;
16 readonly startedAt: number;
17 readonly finishedAt: number;
18 readonly ply: string;
19 readonly result: RunResult;
20 readonly spans: readonly SpanRow[];
21};
22export type RunSummary = { readonly id: RunId; readonly scenario: string; readonly seed: RunSeed; readonly startedAt: number; readonly finishedAt: number; readonly verdict: string; readonly failures: number; readonly exchanges: number; readonly cleaned: boolean };
24export const SCHEMA = [
25 'CREATE TABLE IF NOT EXISTS runs (id TEXT PRIMARY KEY, scenario TEXT NOT NULL, seed TEXT NOT NULL, repo TEXT NOT NULL, started_at INTEGER NOT NULL, finished_at INTEGER NOT NULL, verdict TEXT NOT NULL, failures INTEGER NOT NULL, exchanges INTEGER NOT NULL, cleaned INTEGER NOT NULL, record TEXT NOT NULL)',
26 'CREATE INDEX IF NOT EXISTS runs_started ON runs (started_at DESC)',
27 // every repository the workbench created, until its cleanup is proven (tokens refused, repository gone)
28 'CREATE TABLE IF NOT EXISTS repos (name TEXT PRIMARY KEY, run TEXT NOT NULL, created_at INTEGER NOT NULL, cleaned_at INTEGER)',
29 // admissions: one row per run started, for the hourly cap
30 'CREATE TABLE IF NOT EXISTS admissions (run TEXT PRIMARY KEY, at INTEGER NOT NULL)',
31];
33const num = (v: unknown): number => (typeof v === 'number' ? v : Number(v));
34const str = (v: unknown): string => (typeof v === 'string' ? v : String(v));
36export function migrate(sql: Sql): void {
37 for (const q of SCHEMA) sql.exec(q);
39export function admittedSince(sql: Sql, since: number): number {
40 const [row] = sql.exec('SELECT COUNT(*) AS n FROM admissions WHERE at >= ?', since).toArray();
41 return typeof row === 'object' ? num(row['n']) : 0;
43export function admit(sql: Sql, run: RunId, at: number): void {
44 sql.exec('INSERT INTO admissions (run, at) VALUES (?, ?)', run, at);
45 sql.exec('DELETE FROM admissions WHERE at < ?', at - 7 * 24 * 3600 * 1000);
47export function repoCreated(sql: Sql, name: RepoName, run: RunId, at: number): void {
48 sql.exec('INSERT OR REPLACE INTO repos (name, run, created_at, cleaned_at) VALUES (?, ?, ?, NULL)', name, run, at);
50export function repoCleaned(sql: Sql, name: RepoName, at: number): void {
51 sql.exec('UPDATE repos SET cleaned_at = ? WHERE name = ?', at, name);
53export function uncleaned(sql: Sql, before: number): string[] {
54 return sql.exec('SELECT name FROM repos WHERE cleaned_at IS NULL AND created_at < ? ORDER BY created_at', before).toArray().map(r => str(r['name']));
56export function cleanupCounts(sql: Sql): { readonly created: number; readonly cleaned: number } {
57 const [row] = sql.exec('SELECT COUNT(*) AS created, COUNT(cleaned_at) AS cleaned FROM repos').toArray();
58 return typeof row === 'object' ? { created: num(row['created']), cleaned: num(row['cleaned']) } : { created: 0, cleaned: 0 };
61export function saveRun(sql: Sql, r: StoredRun): void {
62 const failures = r.result.verdict.tag === 'fail' ? r.result.verdict.failures.length : 0;
63 const c = r.result.cleanup;
64 sql.exec(
65 'INSERT OR REPLACE INTO runs (id, scenario, seed, repo, started_at, finished_at, verdict, failures, exchanges, cleaned, record) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
66 r.id, r.scenario, r.seed, r.repo, r.startedAt, r.finishedAt, r.result.verdict.tag, failures, r.result.exchanges.length, c.refused && c.deleted && c.gone ? 1 : 0, JSON.stringify(r),
67 );
69export function loadRun(sql: Sql, id: RunId): StoredRun | null {
70 const [row] = sql.exec('SELECT record FROM runs WHERE id = ?', id).toArray();
71 return typeof row === 'object' ? (JSON.parse(str(row['record'])) as StoredRun) : null;
73export function listRuns(sql: Sql, limit: number): RunSummary[] {
74 return sql.exec('SELECT id, scenario, seed, started_at, finished_at, verdict, failures, exchanges, cleaned FROM runs ORDER BY started_at DESC LIMIT ?', limit).toArray().map(r => ({
75 id: str(r['id']) as RunId, scenario: str(r['scenario']), seed: str(r['seed']) as RunSeed, startedAt: num(r['started_at']), finishedAt: num(r['finished_at']),
76 verdict: str(r['verdict']), failures: num(r['failures']), exchanges: num(r['exchanges']), cleaned: num(r['cleaned']) === 1,
77 }));
Diagnostics4 git calls · 420 ms
CallStatusSizeTime0420 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 1020040 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=41349
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=526b305930b8ef382f2d7a1f9c0238730a585921
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=6
git.pkt.data=4
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=41349
git.pkt.payload.max=41254
git.sideband.band1.bytes=41253
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=61
git.pack.bytes=41253
git.pack.ofs_delta=0
git.pack.ref_delta=0
git.pack.chain.max=0
git.pack.trailer=ab60efef4b7243678c75de64a4386986ee885c1c
git.pack.full=61
Open pack map
fetch2001.7 KiB415 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=415
git.response.bytes=1784
git.response.cache=MISS
git.response.duration_ms=415
git.fetch.wants=e35ba2ac91d52e9d6d2c8011d459819ddb6d3443
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=1784
git.pkt.payload.max=1763
git.sideband.band1.bytes=1762
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply-web.git
Ref
refs/heads/main
Commit
526b305930b8ef382f2d7a1f9c0238730a585921
cf-ray
a5e3094dbdb615db
Request
aa243a6f…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format