main
ply4 git calls26 ms43 KiB3 cachedprotocol v2
90 lines5.0 KiBRaw
1// Issue #73 acceptance: no threshold in the rollout policy (scripts/cd/cd.policy.json) or in ply-web's limits
2// (src/limits.ts, src/viewer/limits.ts) without a cited distribution or an explicit `PRIOR (uncalibrated)` tag.
3// The provenance of each is an entry in scripts/calibrate/thresholds.json whose `value` must match the threshold.
4import assert from 'node:assert/strict'
5import { test } from 'node:test'
6import { currentThresholds, loadRegistry } from '../scripts/calibrate/current.ts'
7import { CALIBRATED, PRIOR, policyThresholds, provenanceProblems, readRegistry, wildcardOf } from '../scripts/calibrate/provenance.ts'
9test('every threshold in the policy and the limits cites a distribution or is tagged PRIOR (uncalibrated)', () => {
10 const current = currentThresholds()
11 const problems = provenanceProblems(loadRegistry(), current)
12 assert.deepEqual(problems, [], problems.map(p => `${p.key}: ${p.problem}`).join('\n'))
13 // The enumeration reaches every source, so a source dropped from currentThresholds cannot pass vacuously.
14 for (const prefix of ['policy:', 'api:', 'mirror:', 'verify:', 'viewer:']) {
15 assert.ok([...current.keys()].some(key => key.startsWith(prefix)), `no ${prefix} thresholds enumerated`)
16 }
17 for (const key of ['policy:probe.maxLossRate', 'policy:telemetry.maxLossRate', 'policy:steps[2].dwellMs', 'api:maxPackBytes', 'viewer:maxTreeEntries', 'mirror:maxPackObjects']) {
18 assert.ok(current.has(key), key)
19 }
20})
22test('the checked-in calibrated entries are the ones with a measured run behind them', () => {
23 const { registry } = loadRegistry()
24 const calibrated = [...registry.thresholds.entries()].filter(([, entry]) => entry.status === CALIBRATED).map(([key]) => key).sort()
25 assert.deepEqual(calibrated, [
26 'api:requestTimeoutMs',
27 'policy:cleanup.attempts',
28 'policy:ingestWaitMs',
29 'policy:probe.maxLossRate',
30 'policy:probe.timeoutMs',
31 'policy:probe.windowAttempts',
32 'policy:rate.maxDroppedFlushes',
33 'policy:rate.maxFailOpenRate',
34 'policy:steps[*].dwellMs',
35 'policy:telemetry.query.attempts',
36 'policy:warmupMs',
37 ])
38 const prior = registry.thresholds.get('policy:telemetry.maxLossRate')
39 assert.ok(prior)
40 assert.equal(prior.status, PRIOR)
41})
43const CITED = { status: CALIBRATED, source: 'run r', query: 'q', window: 'w', date: '2026-11-01', n: 10, percentile: 'p99', headroom: 'x2' }
44const MIN_N = { value: 30, status: PRIOR, why: 'floor' }
46test('a threshold with neither a citation nor a PRIOR tag fails, and so does a stale or orphaned entry', () => {
47 const current = new Map([['policy:a', 1], ['policy:b', 2], ['policy:steps[0].percent', 10], ['policy:steps[1].percent', 50], ['api:c', 3]])
48 const parsed = readRegistry({
49 minN: MIN_N,
50 thresholds: {
51 'policy:a': { ...CITED, value: 1 },
52 'policy:b': { value: 3, status: PRIOR, why: 'round' },
53 'policy:steps[*].percent': { value: [10, 25], status: PRIOR, why: 'schedule' },
54 'api:gone': { value: 1, status: PRIOR, why: 'old' },
55 },
56 })
57 assert.deepEqual(provenanceProblems(parsed, current).map(p => [p.key, p.problem.split(':')[0]]), [
58 ['policy:b', 'threshold is 2, its provenance entry says 3'],
59 ['api:c', 'threshold 3 has no provenance'],
60 ['policy:steps[*].percent', 'thresholds are [10,50], the provenance entry says [10,25]'],
61 ['api:gone', 'provenance entry for a threshold that does not exist'],
62 ])
63})
65test('a citation must name source, query, window, date, n, percentile and headroom; a prior must say why', () => {
66 const bad = readRegistry({
67 minN: MIN_N,
68 thresholds: {
69 'x:nothing': { value: 1 },
70 'x:untagged': { value: 1, status: 'calibrated-ish' },
71 'x:half': { value: 1, status: CALIBRATED, source: 'run', date: '2026-11-01' },
72 'x:date': { ...CITED, value: 1, date: 'Nov 1' },
73 'x:n': { ...CITED, value: 1, n: 0 },
74 'x:why': { value: 1, status: PRIOR, why: ' ' },
75 'x:metric': { value: 1, status: PRIOR, why: 'w', metric: { attribute: 'git.pack.bytes', route: '*', quantile: 0.95, headroom: 2, band: 2 } },
76 'x:value': { status: PRIOR, why: 'w' },
77 },
78 })
79 assert.deepEqual(bad.problems.map(p => p.key), ['x:nothing', 'x:untagged', 'x:half', 'x:date', 'x:n', 'x:why', 'x:metric', 'x:value'])
80 assert.match(bad.problems[2].problem, /must cite query, window, n, percentile, headroom/)
81 assert.match(bad.problems[1].problem, /status must be "calibrated" \(with a citation\) or "PRIOR \(uncalibrated\)"/)
82 assert.equal(readRegistry({ thresholds: {} }).problems.some(p => p.key === 'minN'), true, 'the registry floor needs provenance too')
83})
85test('policy enumeration skips citation blocks and indexes arrays', () => {
86 const found = policyThresholds({ steps: [{ percent: 10 }], probe: { rps: 5, calls: [{ path: '/' }], calibration: { n: 790 }, schedule: { n: 128 } }, gates: { smoke: 'hard' } })
87 assert.deepEqual([...found.entries()], [['policy:steps[0].percent', 10], ['policy:probe.rps', 5]])
88 assert.equal(wildcardOf('policy:steps[3].dwellMs'), 'policy:steps[*].dwellMs')
89 assert.equal(wildcardOf('api:maxPackBytes'), null)
90})
Diagnostics4 git calls · 26 ms
CallStatusSizeTime026 ms
discover200152 B4 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
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=20
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.9 KiB · hit20 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1934
git.response.cache=HIT
git.response.duration_ms=20
git.fetch.wants=dec87f27e413ef182ed0d2d8b18d41bfa15a8d11
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=1934
git.pkt.payload.max=1913
git.sideband.band1.bytes=1912
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
a5e36e666bd9e88e
Request
53aaa2d9…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format