Skip to content

Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA

TypeScript

Strip hidden line-break characters from the weekly benchmark line in release plans (GST-3606) (#4866)

Garry Tanb022764a3669
diff --git a/changelog.d/stable-benchmark-strip-unicode-line-breaks.md b/changelog.d/stable-benchmark-strip-unicode-line-breaks.md
new file mode 100644
index 000000000..d149618d8
--- /dev/null
+++ b/changelog.d/stable-benchmark-strip-unicode-line-breaks.md
@@ -0,0 +1 @@
+**The weekly benchmark line in the stable release plan now also strips C1 control characters and the Unicode line and paragraph separators (U+2028, U+2029) from record text,** so no published record can break that line. Two model ids that read the same once cleaned still make the whole benchmark read unreadable on purpose, because the release step should fail closed rather than guess which result counts. Holding stays off.
diff --git a/crew/lib/release-benchmark.ts b/crew/lib/release-benchmark.ts
index 22e6f9136..8da59c508 100644
--- a/crew/lib/release-benchmark.ts
+++ b/crew/lib/release-benchmark.ts
@@ -29,13 +29,13 @@ export type Records = { ok: true; records: WeeklyRecord[] } | { ok: false; why:
export interface BenchmarkStatus { state: 'none' | 'clear' | 'hold' | 'unreadable'; line: string; record: WeeklyRecord | null }
export interface Gate { action: 'pass' | 'wait' | 'refuse'; code?: 'REFUSED_BENCHMARK' | 'STABLE_STALE' | 'BENCHMARK_UNKNOWN'; line?: string; level?: 'notice' | 'warning' | 'error' }
-const clean = (s: unknown) => String(s).replace(/[\u0000-\u001f\u007f]+/g, ' ');
+const clean = (s: unknown) => String(s).replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]+/g, ' ');
const short = (s: string) => clean(s.trim()).slice(0, 200);
const retried = (gh: Gh, args: string[]) => { const r = gh(args); return r.status === 0 ? r : gh(args); };
const num = (x: unknown) => typeof x === 'number' && Number.isFinite(x);
const f1 = (x: number) => (x >= 0 ? '+' : '') + x.toFixed(1);
-/** One record, checked: schema 1, a known verdict, a run start, 40-hex shas, numeric model rows, and a verdict its model rows agree with (HOLD exactly when some row's interval lies wholly below 0). A vs_none with a non-numeric field is dropped, since it never decides; text is stripped of control characters so it cannot start a workflow command in the job log. */
+/** One record, checked: schema 1, a known verdict, a run start, 40-hex shas, numeric model rows, and a verdict its model rows agree with (HOLD exactly when some row's interval lies wholly below 0). A vs_none with a non-numeric field is dropped, since it never decides; text is stripped of C0 and C1 control characters and U+2028/U+2029 so it cannot start a workflow command in the job log. Model ids that clean alike refuse the record, which makes the whole read unreadable: a gate fails closed rather than guess which row counts (GST-3606). */
export function parseRecord(tag: string, text: string): WeeklyRecord | string {
let r: any;
try { r = JSON.parse(text); } catch { return tag + "'s " + BENCHMARK.asset + ' is not JSON'; }
@@ -49,7 +49,7 @@ export function parseRecord(tag: string, text: string): WeeklyRecord | string {
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';
+ if (clean(id) in rows) return tag + ': model ids ' + JSON.stringify(clean(id)) + ' collide once control characters and line separators 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)';
diff --git a/crew/test/release-benchmark.test.ts b/crew/test/release-benchmark.test.ts
index d9628b994..0565b38d4 100644
--- a/crew/test/release-benchmark.test.ts
+++ b/crew/test/release-benchmark.test.ts
@@ -92,6 +92,26 @@ describe('release-benchmark: reading the records', () => {
expect(parseRecord('weekly-2026-w48', JSON.stringify(twins))).toContain('collide');
});
+ test('C1 controls and Unicode line or paragraph separators are stripped too, so no record text breaks the line', () => {
+ const reason = 'a\u0085b\u009bc\u2028d\u2029e';
+ const s = status(records(['weekly-2026-w48', rec('NO_CHANGE')], ['weekly-2026-w49', { ...rec('INCOMPLETE', { week: '2026-W49', start: '2026-12-05T06:00:00Z' }), incomplete_reason: reason }]));
+ expect(s.line).toContain('INCOMPLETE (a b c d e)');
+ expect(s.line).not.toMatch(/[\u0080-\u009f\u2028\u2029]/);
+ const u = status({ ok: false, why: 'x\u2028::stop-commands::tok\u0085y' });
+ expect(u.line).toContain('(x ::stop-commands::tok y)');
+ });
+
+ test('model ids that collide once separators are stripped refuse the record, and the whole read fails closed', () => {
+ const twins = { ...rec('GAIN'), models: { 'm\u2028': { n: 1, d: -2, lo: -4, hi: -1 }, 'm\u0085': { n: 1, d: 1, lo: 0, hi: 2 } } };
+ const why = parseRecord('weekly-2026-w48', JSON.stringify(twins));
+ expect(why).toContain('collide');
+ const older = rec('NO_CHANGE', { week: '2026-W47', start: '2026-11-21T06:00:00Z' });
+ const gh: Gh = (args) => ({ status: 0, stderr: '', stdout: JSON.stringify(args[1] === 'list' ? [{ tagName: 'weekly-2026-w48' }, { tagName: 'weekly-2026-w47' }] : args[2] === 'weekly-2026-w48' ? twins : older) });
+ const read = readRecords(gh);
+ expect(read.ok).toBe(false);
+ expect(status(read).state).toBe('unreadable');
+ });
+
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 820bce06d..42842b7a3 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, or two of whose model ids read the same once control characters are stripped (so no row is silently lost).
+ rows, or two of whose model ids read the same once control characters and the Unicode line and paragraph
+ separators (U+2028, U+2029) 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.