From c34b967346f1e0514c2f1eed3836e91a62ac08e3 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Tue, 24 Nov 2026 00:00:19 -0800 Subject: [PATCH] Weekly benchmark records can't slip text into the release log or lose a model row (GST-3606) (#4782) Weekly benchmark records can no longer slip text into the stable release job's log through their error messages, or silently lose a model row. Why: holding on a measured drop gets switched on after two weekly records, and it has to read those records exactly. Nothing to do. Issue: GST-3606 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- .../stable-benchmark-record-text-hardening.md | 3 +++ crew/lib/release-benchmark.ts | 5 +++-- crew/test/release-benchmark.test.ts | 21 +++++++++++++++++++ docs/releases.md | 3 ++- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 changelog.d/stable-benchmark-record-text-hardening.md diff --git a/changelog.d/stable-benchmark-record-text-hardening.md b/changelog.d/stable-benchmark-record-text-hardening.md new file mode 100644 index 000000000..a8bc6692f --- /dev/null +++ b/changelog.d/stable-benchmark-record-text-hardening.md @@ -0,0 +1,3 @@ +### For contributors + +- **A weekly benchmark record can no longer slip text into the release job's log through its error messages, or lose a model row to an odd model name.** When the release tool can't read a record, the reason it prints is now stripped of control characters too, and model names that collide once cleaned make the record unreadable instead of silently dropping a row. diff --git a/crew/lib/release-benchmark.ts b/crew/lib/release-benchmark.ts index 08dca7543..22e6f9136 100644 --- a/crew/lib/release-benchmark.ts +++ b/crew/lib/release-benchmark.ts @@ -45,10 +45,11 @@ export function parseRecord(tag: string, text: string): WeeklyRecord | string { if (!Number.isFinite(start)) return tag + ': window.start is not a time'; if (!SHA.test(r.candidate?.sha ?? '') || !SHA.test(r.stable?.sha ?? '')) return tag + ': candidate or stable is not a 40-hex sha'; const models = (r.models && typeof r.models === 'object' ? r.models : {}) as Record; - const rows: Record = {}; + const rows: Record = Object.create(null); for (const [id, m] of Object.entries(models)) { if (![m?.n, m?.d, m?.lo, m?.hi].every(num)) return tag + ': model row ' + clean(id) + ' is not numeric'; const v = m.vs_none; + if (clean(id) in rows) return tag + ': model ids ' + JSON.stringify(clean(id)) + ' collide once control characters are stripped'; rows[clean(id)] = { host: m.host, n: m.n, d: m.d, lo: m.lo, hi: m.hi, ...(v && [v.d, v.lo, v.hi].every(num) ? { vs_none: { d: v.d, lo: v.lo, hi: v.hi } } : {}) }; } if (Object.values(rows).some((m) => m.hi < 0) !== (r.verdict === 'HOLD')) return tag + ': verdict ' + r.verdict + ' disagrees with its model rows (verdict mismatch)'; @@ -88,7 +89,7 @@ function summary(r: WeeklyRecord): string { /** What the records say about cutting candidate over stable. A HOLD applies when its commit is in the candidate and not yet on stable. */ export function benchmarkStatus(o: { read: Records; git: Git; candidate: string; stable: string | null; now: number; hold?: boolean }): BenchmarkStatus { const mode = ' (' + ((o.hold ?? BENCHMARK.hold) ? 'holding' : 'report only') + ')'; - if (!o.read.ok) return { state: 'unreadable', line: 'BENCHMARK: unreadable (' + o.read.why + ')' + mode, record: null }; + if (!o.read.ok) return { state: 'unreadable', line: 'BENCHMARK: unreadable (' + clean(o.read.why) + ')' + mode, record: null }; const sorted = newestFirst(o.read.records), r = sorted.find((x) => x.verdict !== 'INCOMPLETE') ?? null, newest = sorted[0]; const later = newest && newest !== r ? '; the newer ' + newest.tag + ' is INCOMPLETE (' + (newest.incomplete_reason ?? 'no reason given') + ')' : ''; if (!r) return { state: 'none', line: 'BENCHMARK: none (' + (newest ? 'every record is INCOMPLETE' + later : 'no weekly record published yet') + ')' + mode, record: null }; diff --git a/crew/test/release-benchmark.test.ts b/crew/test/release-benchmark.test.ts index 3b4b8ea59..d9628b994 100644 --- a/crew/test/release-benchmark.test.ts +++ b/crew/test/release-benchmark.test.ts @@ -71,6 +71,27 @@ describe('release-benchmark: reading the records', () => { expect(injected.line).not.toContain('\n'); }); + test('a refused schema or verdict cannot start a workflow command in the unreadable line', () => { + for (const bad of [{ ...rec('GAIN'), verdict: 'x\n::stop-commands::tok' }, { ...rec('GAIN'), schema: '1\n::add-mask::tok' }]) { + const why = parseRecord('weekly-2026-w48', JSON.stringify(bad)); + expect(typeof why).toBe('string'); + const s = status({ ok: false, why: why as string }); + expect(s.state).toBe('unreadable'); + expect(s.line).not.toContain('\n'); + } + }); + + test('a __proto__ model row still counts toward the verdict, and model ids that clean alike are refused', () => { + const held = JSON.stringify(rec('HOLD')).replace('"models":{"claude-opus-5-5"', '"models":{"__proto__":{"n":10,"d":-5,"lo":-8,"hi":-2},"claude-opus-5-5"'); + const r = parseRecord('weekly-2026-w48', held) as WeeklyRecord; + expect(typeof r).toBe('object'); + expect(Object.keys(r.models)).toEqual(['__proto__', 'claude-opus-5-5']); + const gain = JSON.stringify(rec('GAIN')).replace('"models":{"claude-opus-5-5"', '"models":{"__proto__":{"n":10,"d":-5,"lo":-8,"hi":-1},"claude-opus-5-5"'); + expect(parseRecord('weekly-2026-w48', gain)).toContain('verdict mismatch'); + const twins = { ...rec('GAIN'), models: { 'm\n': { n: 1, d: -2, lo: -4, hi: -1 }, 'm ': { n: 1, d: 1, lo: 0, hi: 2 } } }; + expect(parseRecord('weekly-2026-w48', JSON.stringify(twins))).toContain('collide'); + }); + test('readRecords lists weekly tags only, retries each call once, and any failure makes the whole read unreadable', () => { const calls: string[][] = []; let flaky = 1; diff --git a/docs/releases.md b/docs/releases.md index 32d1d6570..820bce06d 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -392,7 +392,8 @@ Every cut plan, dry runs included, prints one `BENCHMARK:` line read from those reached `stable` is printed, and the choice between fixing forward and [rolling back](#rolling-stable-back) is made by hand. - A record that can't be read prints `unreadable`, and so does a record whose verdict disagrees with its own model - rows. Every list and download is retried once. A no-gstack comparison (`vs_none`) with a missing or non-numeric + rows, or two of whose model ids read the same once control characters are stripped (so no row is silently lost). + Every list and download is retried once. A no-gstack comparison (`vs_none`) with a missing or non-numeric number is left out of the line instead. **Holding is off for the first two weekly records** (`BENCHMARK.hold` is `false`), so for now the line is only