From 7cc454d931da506722bcbfa93873be6d97a1d5fc Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza Date: Fri, 18 Sep 2026 08:13:49 -0300 Subject: [PATCH] fix(compression): repair the unit-test base-reds left by the 09-17 merge wave (#14082) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every PR against release/v3.8.51 is born red on all four Unit Tests fast-path shards. Reproduced on the pure tip (1603c86e): ~35 tests. This commit repairs the two large clusters plus the stale assertions sharing their root cause (17 tests); the rest is tracked separately. RTK (12 tests, real regression): #13521 gated dedup on skipFilters || isDocumentLikeRead but isDocumentLikeRead is true for ANY text whose type detection is unknown — not only non-shell tool results — so plain repeated tool output (the classic RTK case) stopped being deduplicated, processRtkText returned no stats, and rtkEngine.apply().stats.engine came back undefined. The intent of #13388 was the non-shell-tool skip, which resolveToolMeta already expresses as skipFilters; dedup now honours only that. The #13521 regression guard (rtk-file-content-preservation, tool named 'read' → skipFilters) still passes 4/4; rtk-engine is back to 9/9. Golden + stale assertions (5 tests, product changes never propagated): - tests/snapshots/provider/translate-path.json: xKiro (#12648) was added to the registry without regenerating the snapshot — purely additive entry. - providers-constants-split: APIKEY_PROVIDER_COUNT 241 → 242 (xKiro). - tests/snapshots/g13/combo-chatcore-public-seams.json and the three Content-Type assertions in chatcore-translation-paths / chat-route-coverage: #13419 deliberately made streaming responses declare 'text/event-stream; charset=utf-8' (Arabic/Persian mojibake) and updated the integration test but not these unit assertions. Before/after on the 26 base-red files: 266 tests, 23 → 18 failing here (the RTK suites were counted per-file in CI; per-test this is 17 fixed). The file-size ✗ on chatcore-translation-paths.test.ts is the pre-existing drift #14016 rebaselines — this commit keeps that file's line count unchanged. --- .../release-v3851-basereds-unit-rtk-golden.md | 1 + .../services/compression/engines/rtk/index.ts | 2 +- .../g13/combo-chatcore-public-seams.json | 4 ++-- tests/snapshots/provider/translate-path.json | 23 +++++++++++++++++++ tests/unit/chat-route-coverage.test.ts | 2 +- tests/unit/chatcore-translation-paths.test.ts | 4 ++-- tests/unit/providers-constants-split.test.ts | 3 ++- 7 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 changelog.d/maintenance/release-v3851-basereds-unit-rtk-golden.md diff --git a/changelog.d/maintenance/release-v3851-basereds-unit-rtk-golden.md b/changelog.d/maintenance/release-v3851-basereds-unit-rtk-golden.md new file mode 100644 index 0000000000..b22a00122f --- /dev/null +++ b/changelog.d/maintenance/release-v3851-basereds-unit-rtk-golden.md @@ -0,0 +1 @@ +- **compression/tests:** repair the unit base-reds on `release/v3.8.51` left by the 09-17 merge wave — RTK dedup was skipped for every unknown-type text (#13521 widened `skipFilters` to `isDocumentLikeRead`), so repeated tool output stopped compressing (12 tests); the translate-path golden, the `APIKEY_PROVIDERS` count and the G13 golden/SSE `Content-Type` assertions were stale after #12648 (xKiro) and #13419 (`charset=utf-8`). diff --git a/open-sse/services/compression/engines/rtk/index.ts b/open-sse/services/compression/engines/rtk/index.ts index 82f5a4b221..b4dba7e8a9 100644 --- a/open-sse/services/compression/engines/rtk/index.ts +++ b/open-sse/services/compression/engines/rtk/index.ts @@ -314,7 +314,7 @@ export function processRtkText( // #13388: skip dedup for non-shell tool results (file reads, grep, glob, etc.) // where repeated structural lines are semantically meaningful. Also skip when // the content is a document-like read to avoid false-positive dedup on code files. - const shouldSkipDedup = options.skipFilters || isDocumentLikeRead; + const shouldSkipDedup = Boolean(options.skipFilters); const deduped = shouldSkipDedup ? { text: result, collapsed: 0 } : deduplicateRepeatedLines(result, { threshold: config.deduplicateThreshold }); diff --git a/tests/snapshots/g13/combo-chatcore-public-seams.json b/tests/snapshots/g13/combo-chatcore-public-seams.json index bf58e93350..6235043654 100644 --- a/tests/snapshots/g13/combo-chatcore-public-seams.json +++ b/tests/snapshots/g13/combo-chatcore-public-seams.json @@ -392,7 +392,7 @@ "output": { "Cache-Control": "no-cache, no-transform", "Connection": "keep-alive", - "Content-Type": "text/event-stream", + "Content-Type": "text/event-stream; charset=utf-8", "X-Accel-Buffering": "no", "X-OmniRoute-Cache": "MISS", "X-OmniRoute-Cache-Hit": "false", @@ -416,7 +416,7 @@ "output": { "Cache-Control": "no-cache, no-transform", "Connection": "keep-alive", - "Content-Type": "text/event-stream", + "Content-Type": "text/event-stream; charset=utf-8", "X-Accel-Buffering": "no", "X-OmniRoute-Cache": "MISS", "X-OmniRoute-Cache-Hit": "false", diff --git a/tests/snapshots/provider/translate-path.json b/tests/snapshots/provider/translate-path.json index 4ea6a91560..7cc9a9b678 100644 --- a/tests/snapshots/provider/translate-path.json +++ b/tests/snapshots/provider/translate-path.json @@ -6398,6 +6398,29 @@ "stream": "https://token-plan-sgp.xiaomimimo.com/v1" } }, + "xkiro": { + "format": "openai", + "headers": { + "apiKey": { + "Accept": "text/event-stream", + "Authorization": "Bearer ", + "Content-Type": "application/json" + }, + "nonStream": { + "Authorization": "Bearer ", + "Content-Type": "application/json" + }, + "oauth": { + "Accept": "text/event-stream", + "Authorization": "Bearer ", + "Content-Type": "application/json" + } + }, + "url": { + "nonStream": "https://api.xkiro.com/v1/chat/completions", + "stream": "https://api.xkiro.com/v1/chat/completions" + } + }, "yi": { "format": "openai", "headers": { diff --git a/tests/unit/chat-route-coverage.test.ts b/tests/unit/chat-route-coverage.test.ts index db46de811e..543c4c3bb3 100644 --- a/tests/unit/chat-route-coverage.test.ts +++ b/tests/unit/chat-route-coverage.test.ts @@ -157,7 +157,7 @@ test("handleChat treats a pure Accept: text/event-stream as stream=true and retu const raw = await response.text(); assert.equal(response.status, 200); - assert.equal(response.headers.get("Content-Type"), "text/event-stream"); + assert.equal(response.headers.get("Content-Type"), "text/event-stream; charset=utf-8"); assert.ok(response.headers.get("X-OmniRoute-Session-Id")); assert.match(raw, /Accept header stream/); assert.match(raw, /\[DONE\]/); diff --git a/tests/unit/chatcore-translation-paths.test.ts b/tests/unit/chatcore-translation-paths.test.ts index b5ef7a62ba..1d5a4eea21 100644 --- a/tests/unit/chatcore-translation-paths.test.ts +++ b/tests/unit/chatcore-translation-paths.test.ts @@ -2993,7 +2993,7 @@ test("buildStreamingResponseHeaders drops upstream compression and framing heade ) ); - assert.equal(headers.get("Content-Type"), "text/event-stream"); + assert.equal(headers.get("Content-Type"), "text/event-stream; charset=utf-8"); assert.equal(headers.get("Content-Encoding"), null); assert.equal(headers.get("Content-Length"), null); assert.equal(headers.get("Transfer-Encoding"), null); @@ -3028,7 +3028,7 @@ test("chatCore strips upstream compression and length headers from streaming res }); assert.equal(result.success, true); - assert.equal(result.response.headers.get("Content-Type"), "text/event-stream"); + assert.equal(result.response.headers.get("Content-Type"), "text/event-stream; charset=utf-8"); assert.equal(result.response.headers.get("Content-Length"), null); assert.equal(result.response.headers.get("X-Upstream-Trace"), "trace-1"); assert.equal(result.response.headers.get("X-OmniRoute-Cache"), "MISS"); diff --git a/tests/unit/providers-constants-split.test.ts b/tests/unit/providers-constants-split.test.ts index da74f7db0e..6fb113f7c1 100644 --- a/tests/unit/providers-constants-split.test.ts +++ b/tests/unit/providers-constants-split.test.ts @@ -36,12 +36,13 @@ // SeekAi (#11786, QuantumNous New-API gateway) adds one gateways entry — 238. // GreenPT (#13024, 2b9e7fb3e) and EURouter (#13025, 22473dee5) each add one gateways entry — 240. // Agnes AI China (#13399, cdcde97c7) adds one apikey/regional entry — 241. +// xKiro (#12648, 83fa4328f) adds one apikey entry — 242. import { test } from "node:test"; import assert from "node:assert/strict"; const P = await import("../../src/shared/constants/providers.ts"); -const APIKEY_PROVIDER_COUNT = 241; +const APIKEY_PROVIDER_COUNT = 242; test("barrel still exports every catalog + key helpers", () => { for (const name of [