main
ply4 git calls30 ms42 KiB3 cachedprotocol v2
125 lines4.1 KiBRaw
1import { homedir } from 'node:os'
2import { join, resolve } from 'node:path'
3import {
4 BASE_URL_DEFAULT,
5 BUMP_BRANCH_DEFAULT,
6 NAMESPACE_DEFAULT,
7 WORKER_DEFAULT,
8} from './baseline.ts'
9import type { Json } from './log.ts'
10import { defaultLockPath } from './lock.ts'
11import { DEFAULT_POLICY_PATH, loadPolicy, type RolloutPolicy } from './policy.ts'
12import { SLOS } from './slo.ts'
14export type CdConfig = {
15 readonly worker: string
16 readonly baseUrl: string
17 readonly namespace: string
18 readonly bumpBranch: string
19 readonly runRoot: string
20 readonly tokenFile: string
21 /** The load-test credential (PLY_LOAD_TOKEN), mode 0600: the rate gate's probes carry it. Never the /v1 bearer. */
22 readonly loadTokenFile: string
23 readonly sha: string | null
24 readonly policy: RolloutPolicy
25 readonly policyPath: string
26 readonly policySha256: string
27 readonly policyBody: Json
28 readonly ledgerPath: string
29 /** The deployment lock every writing command holds (scripts/cd/lock.ts). Shared by every worktree. */
30 readonly lockPath: string
33const RETIRED = [
34 'PLY_RAMP_MAX_HOLDS',
35 'PLY_RAMP_MIN_REQUESTS',
36 'PLY_RAMP_HOLD_MS',
37 'PLY_RAMP_PERCENTS',
38 'PLY_RAMP_DWELL_MS',
39 'PLY_RAMP_PROBE_RPS',
40] as const
42/** ISO-8601, epoch milliseconds, or epoch seconds (a value under 1e12). */
43export function parseSince(raw: string): number {
44 if (/^\d+$/.test(raw)) {
45 const n = Number(raw)
46 return n < 1e12 ? n * 1000 : n
47 }
48 const parsed = Date.parse(raw)
49 if (!Number.isFinite(parsed)) throw new Error('since is not a timestamp')
50 return parsed
53export function defaultLedgerPath(): string {
54 return join(homedir(), '.local', 'state', 'ply-cd', 'ledger.jsonl')
57/** Scratch run directories. Override with `PLY_CD_RUN_DIR`. */
58export function defaultRunRoot(): string {
59 return join(homedir(), '.local', 'state', 'ply-cd', 'runs')
62/**
63 * Worker bearer, mode 0600. Override with `PLY_TOKEN_FILE`. The file is read and never printed. The default is where the
64 * rotated bearer lives (2026-10-30); `~/.ply-token` was the default until 2026-11-08 and every run passed the override.
65 */
66export function defaultTokenFile(): string {
67 return join(homedir(), '.config', 'ply', 'worker-token')
70/** The load-test credential, mode 0600. Override with `PLY_LOAD_TOKEN_FILE`. Read by the rate gate, never printed. */
71export function defaultLoadTokenFile(): string {
72 return join(homedir(), '.config', 'ply', 'load-token')
75/** What run_started records. Paths only; never a token. */
76export function publicConfig(config: CdConfig) {
77 return {
78 worker: config.worker,
79 baseUrl: config.baseUrl,
80 namespace: config.namespace,
81 bumpBranch: config.bumpBranch,
82 runRoot: config.runRoot,
83 tokenFile: config.tokenFile,
84 loadTokenFile: config.loadTokenFile,
85 sha: config.sha,
86 ledgerPath: config.ledgerPath,
87 lockPath: config.lockPath,
88 policyPath: config.policyPath,
89 policySha256: config.policySha256,
90 slos: SLOS.map(slo => ({
91 id: slo.id,
92 statement: slo.statement,
93 target: slo.target,
94 windowDays: slo.windowDays,
95 initial: slo.initial,
96 ceilingMs: slo.ceilingMs,
97 })),
98 }
101export function loadConfig(env: NodeJS.ProcessEnv, policyPath?: string): CdConfig {
102 for (const key of RETIRED) {
103 if (env[key] !== undefined && env[key] !== '') {
104 throw new Error(`${key} is no longer used; put it in the rollout policy (--policy)`)
105 }
106 }
107 const path = policyPath ? resolve(policyPath) : DEFAULT_POLICY_PATH
108 const loaded = loadPolicy(path)
109 return {
110 worker: env.PLY_WORKER || WORKER_DEFAULT,
111 baseUrl: (env.PLY_BASE_URL || BASE_URL_DEFAULT).replace(/\/+$/, ''),
112 namespace: env.PLY_ARTIFACTS_NAMESPACE || NAMESPACE_DEFAULT,
113 bumpBranch: env.PLY_BUMP_BRANCH || BUMP_BRANCH_DEFAULT,
114 runRoot: env.PLY_CD_RUN_DIR || defaultRunRoot(),
115 tokenFile: env.PLY_TOKEN_FILE || defaultTokenFile(),
116 loadTokenFile: env.PLY_LOAD_TOKEN_FILE || defaultLoadTokenFile(),
117 sha: env.PLY_SHA || null,
118 ledgerPath: env.PLY_CD_LEDGER || defaultLedgerPath(),
119 lockPath: env.PLY_CD_LOCK || defaultLockPath(),
120 policy: loaded.policy,
121 policyPath: path,
122 policySha256: loaded.sha256,
123 policyBody: loaded.body,
124 }
Diagnostics4 git calls · 30 ms
CallStatusSizeTime030 ms
discover200152 B4 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=4
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 · hit5 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=5
git.response.bytes=145
git.response.cache=HIT
git.response.duration_ms=5
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 · hit7 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=7
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.6 KiB · hit18 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=18
git.response.bytes=1671
git.response.cache=HIT
git.response.duration_ms=18
git.fetch.wants=b39e78830cfa9c2ec3bd80a5b15d256a16f1103b
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=1671
git.pkt.payload.max=1650
git.sideband.band1.bytes=1649
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
a5e2d7952c9c14c2
Request
ec3a3747…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format