fix(compression): repair the unit-test base-reds left by the 09-17 merge wave (#14082)

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.
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-09-18 08:13:49 -03:00
committed by GitHub
parent 24fc202d9f
commit 7cc454d931
7 changed files with 32 additions and 7 deletions

View File

@@ -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`).

View File

@@ -314,7 +314,7 @@ export function processRtkText(
// #13388: skip dedup for non-shell tool results (file reads, grep, glob, etc.) // #13388: skip dedup for non-shell tool results (file reads, grep, glob, etc.)
// where repeated structural lines are semantically meaningful. Also skip when // 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. // 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 const deduped = shouldSkipDedup
? { text: result, collapsed: 0 } ? { text: result, collapsed: 0 }
: deduplicateRepeatedLines(result, { threshold: config.deduplicateThreshold }); : deduplicateRepeatedLines(result, { threshold: config.deduplicateThreshold });

View File

@@ -392,7 +392,7 @@
"output": { "output": {
"Cache-Control": "no-cache, no-transform", "Cache-Control": "no-cache, no-transform",
"Connection": "keep-alive", "Connection": "keep-alive",
"Content-Type": "text/event-stream", "Content-Type": "text/event-stream; charset=utf-8",
"X-Accel-Buffering": "no", "X-Accel-Buffering": "no",
"X-OmniRoute-Cache": "MISS", "X-OmniRoute-Cache": "MISS",
"X-OmniRoute-Cache-Hit": "false", "X-OmniRoute-Cache-Hit": "false",
@@ -416,7 +416,7 @@
"output": { "output": {
"Cache-Control": "no-cache, no-transform", "Cache-Control": "no-cache, no-transform",
"Connection": "keep-alive", "Connection": "keep-alive",
"Content-Type": "text/event-stream", "Content-Type": "text/event-stream; charset=utf-8",
"X-Accel-Buffering": "no", "X-Accel-Buffering": "no",
"X-OmniRoute-Cache": "MISS", "X-OmniRoute-Cache": "MISS",
"X-OmniRoute-Cache-Hit": "false", "X-OmniRoute-Cache-Hit": "false",

View File

@@ -6398,6 +6398,29 @@
"stream": "https://token-plan-sgp.xiaomimimo.com/v1" "stream": "https://token-plan-sgp.xiaomimimo.com/v1"
} }
}, },
"xkiro": {
"format": "openai",
"headers": {
"apiKey": {
"Accept": "text/event-stream",
"Authorization": "Bearer <TOK>",
"Content-Type": "application/json"
},
"nonStream": {
"Authorization": "Bearer <TOK>",
"Content-Type": "application/json"
},
"oauth": {
"Accept": "text/event-stream",
"Authorization": "Bearer <TOK>",
"Content-Type": "application/json"
}
},
"url": {
"nonStream": "https://api.xkiro.com/v1/chat/completions",
"stream": "https://api.xkiro.com/v1/chat/completions"
}
},
"yi": { "yi": {
"format": "openai", "format": "openai",
"headers": { "headers": {

View File

@@ -157,7 +157,7 @@ test("handleChat treats a pure Accept: text/event-stream as stream=true and retu
const raw = await response.text(); const raw = await response.text();
assert.equal(response.status, 200); 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.ok(response.headers.get("X-OmniRoute-Session-Id"));
assert.match(raw, /Accept header stream/); assert.match(raw, /Accept header stream/);
assert.match(raw, /\[DONE\]/); assert.match(raw, /\[DONE\]/);

View File

@@ -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-Encoding"), null);
assert.equal(headers.get("Content-Length"), null); assert.equal(headers.get("Content-Length"), null);
assert.equal(headers.get("Transfer-Encoding"), 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.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("Content-Length"), null);
assert.equal(result.response.headers.get("X-Upstream-Trace"), "trace-1"); assert.equal(result.response.headers.get("X-Upstream-Trace"), "trace-1");
assert.equal(result.response.headers.get("X-OmniRoute-Cache"), "MISS"); assert.equal(result.response.headers.get("X-OmniRoute-Cache"), "MISS");

View File

@@ -36,12 +36,13 @@
// SeekAi (#11786, QuantumNous New-API gateway) adds one gateways entry — 238. // SeekAi (#11786, QuantumNous New-API gateway) adds one gateways entry — 238.
// GreenPT (#13024, 2b9e7fb3e) and EURouter (#13025, 22473dee5) each add one gateways entry — 240. // GreenPT (#13024, 2b9e7fb3e) and EURouter (#13025, 22473dee5) each add one gateways entry — 240.
// Agnes AI China (#13399, cdcde97c7) adds one apikey/regional entry — 241. // 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 { test } from "node:test";
import assert from "node:assert/strict"; import assert from "node:assert/strict";
const P = await import("../../src/shared/constants/providers.ts"); 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", () => { test("barrel still exports every catalog + key helpers", () => {
for (const name of [ for (const name of [