From a623924a80a4359aac6b26207530650c6cb6478f Mon Sep 17 00:00:00 2001 From: qwen-code-dev-bot Date: Sun, 30 Aug 2026 00:07:15 +0000 Subject: [PATCH 1/3] fix(acp-bridge): deflake the exhaustive UTF-16 byte-estimate test (#10529) Co-authored-by: Qwen-Coder --- packages/acp-bridge/src/json-string-bytes.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/acp-bridge/src/json-string-bytes.test.ts b/packages/acp-bridge/src/json-string-bytes.test.ts index 0936d36ce20..4ebf85322dd 100644 --- a/packages/acp-bridge/src/json-string-bytes.test.ts +++ b/packages/acp-bridge/src/json-string-bytes.test.ts @@ -8,6 +8,9 @@ import { describe, expect, it, vi } from 'vitest'; import { estimateJsonStringBytes } from './json-string-bytes.js'; describe('estimateJsonStringBytes', () => { + // The exhaustive 65,536-iteration sweep spends most of its time in + // per-iteration assertion overhead, which exceeds vitest's default 5s + // timeout on slow or contended CI runners. it('matches JSON.stringify UTF-8 bytes for every UTF-16 code unit', () => { for (let code = 0; code <= 0xffff; code++) { const value = String.fromCharCode(code); @@ -15,7 +18,7 @@ describe('estimateJsonStringBytes', () => { Buffer.byteLength(JSON.stringify(value)), ); } - }); + }, 60_000); it('matches JSON.stringify for paired surrogates and mixed escaping', () => { const samples = [ From 3f56e9a8c7e6509ce9674dee42ab109f7248ba7f Mon Sep 17 00:00:00 2001 From: qwen-code-dev-bot Date: Wed, 2 Sep 2026 04:30:10 +0000 Subject: [PATCH 2/3] test(acp-bridge): assert exhaustive byte-estimate sweep once per run The 65,536-iteration sweep spent almost all of its wall time in per-iteration expect() overhead, which made it flaky under runner contention and forced a per-test timeout raise that silently overrode the ECS-conditional testTimeout knob. Collect mismatches and assert once so the default 5s timeout stays authoritative on every lane and a failure reports which code points diverge instead of stopping at the first. --- packages/acp-bridge/src/json-string-bytes.test.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/acp-bridge/src/json-string-bytes.test.ts b/packages/acp-bridge/src/json-string-bytes.test.ts index 4ebf85322dd..d34b612f4c4 100644 --- a/packages/acp-bridge/src/json-string-bytes.test.ts +++ b/packages/acp-bridge/src/json-string-bytes.test.ts @@ -8,17 +8,16 @@ import { describe, expect, it, vi } from 'vitest'; import { estimateJsonStringBytes } from './json-string-bytes.js'; describe('estimateJsonStringBytes', () => { - // The exhaustive 65,536-iteration sweep spends most of its time in - // per-iteration assertion overhead, which exceeds vitest's default 5s - // timeout on slow or contended CI runners. it('matches JSON.stringify UTF-8 bytes for every UTF-16 code unit', () => { + const mismatches: Array<{ code: number; got: number; want: number }> = []; for (let code = 0; code <= 0xffff; code++) { const value = String.fromCharCode(code); - expect(estimateJsonStringBytes(value, Number.MAX_SAFE_INTEGER)).toBe( - Buffer.byteLength(JSON.stringify(value)), - ); + const got = estimateJsonStringBytes(value, Number.MAX_SAFE_INTEGER); + const want = Buffer.byteLength(JSON.stringify(value)); + if (got !== want) mismatches.push({ code, got, want }); } - }, 60_000); + expect(mismatches).toEqual([]); + }); it('matches JSON.stringify for paired surrogates and mixed escaping', () => { const samples = [ From 5dcf62992c615788267b505af64f517e3989c27a Mon Sep 17 00:00:00 2001 From: qwen-code-dev-bot Date: Wed, 2 Sep 2026 13:28:26 +0000 Subject: [PATCH 3/3] test(acp-bridge): bound the byte-estimate sweep's mismatch report MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Asserting on the whole mismatch array serialised every divergence into the CI log. A broken no-escape fast path — the regression class this sweep exists to catch — diverges on 63,454 of the 65,536 code units and dumped 7.4 MB across 317k lines. Report the count and the first five entries instead: the same failure still names the exact count and the offending code points, in 4 kB. --- packages/acp-bridge/src/json-string-bytes.test.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/acp-bridge/src/json-string-bytes.test.ts b/packages/acp-bridge/src/json-string-bytes.test.ts index d34b612f4c4..75ff2bef542 100644 --- a/packages/acp-bridge/src/json-string-bytes.test.ts +++ b/packages/acp-bridge/src/json-string-bytes.test.ts @@ -16,7 +16,12 @@ describe('estimateJsonStringBytes', () => { const want = Buffer.byteLength(JSON.stringify(value)); if (got !== want) mismatches.push({ code, got, want }); } - expect(mismatches).toEqual([]); + expect({ count: mismatches.length, first: mismatches.slice(0, 5) }).toEqual( + { + count: 0, + first: [], + }, + ); }); it('matches JSON.stringify for paired surrogates and mixed escaping', () => {