mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-20 22:02:19 +03:00
Merged as part of the 39-PR owner batch of 2026-09-11, validated as a unit. Boarded into one consolidated worktree cut from `release/v3.8.51` with the other 38 — zero conflicts between them. - ESLint over every changed file: no errors (the only finding was one suppression entry the batch emptied, pruned on #13243) - `typecheck:core` clean; `check:dashboard-typecheck` OK (206 pre-existing, within baseline); `check:changelog-integrity` OK - complexity 2821 / baseline 3218 and cognitive-complexity 1272 / baseline 1437 — both under baseline - 256 assertions green: 246 under node:test and 10 under vitest, which is where `tests/unit/**/*.test.tsx` actually runs - `check-file-size`: `chatCore.ts` rebaselined 6144 → 6146 for #13278 and #13276, annotated and landed on #13243 ⚠️ base-red inherited: #12732 — the provider count (356 in the docs vs the 358 the modules define) and `open-sse/utils/stream.ts` at 3115 > frozen 3098 both reproduce on the pure tip with zero contribution from this batch.
72 lines
2.9 KiB
JavaScript
72 lines
2.9 KiB
JavaScript
// Regression guard for #11977: the diagnostic log fired unconditionally whenever
|
|
// promptCompressionEnabled was false, claiming "reactive context compaction still
|
|
// applies when over threshold" even on a default install where
|
|
// reactiveContextCompactionEnabled is ALSO false (DEFAULT_COMPRESSION_CONFIG.enabled
|
|
// === false, per #9200's gating). That left operators with zero diagnostic signal for
|
|
// the real failure mode: large histories reaching the upstream provider untrimmed
|
|
// (e.g. Antigravity's 400 once session history grows past its real request-size
|
|
// ceiling). The fix branches the log on reactiveContextCompactionEnabled so the
|
|
// message reflects which safety net, if any, is actually still active.
|
|
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
const source = readFileSync(
|
|
new URL("../../open-sse/handlers/chatCore.ts", import.meta.url),
|
|
"utf8"
|
|
);
|
|
|
|
test("gating expressions exist as documented (sanity check, tracks real source)", () => {
|
|
assert.match(
|
|
source,
|
|
/let promptCompressionEnabled =\s*\n\s*compressionSettingsResult\.enabled && !compressionExcluded && apiKeyCompressionEnabled;/
|
|
);
|
|
assert.match(
|
|
source,
|
|
/reactiveContextCompactionEnabled = compressionSettingsResult\.enabled && !compressionExcluded;/
|
|
);
|
|
});
|
|
|
|
test("on default install, reactiveContextCompactionEnabled is provably false whenever the log fires", () => {
|
|
const compressionSettingsResultEnabled = false; // DEFAULT_COMPRESSION_CONFIG.enabled
|
|
const compressionExcluded = false;
|
|
const apiKeyCompressionEnabled = true;
|
|
|
|
const promptCompressionEnabled =
|
|
compressionSettingsResultEnabled && !compressionExcluded && apiKeyCompressionEnabled;
|
|
const reactiveContextCompactionEnabled = compressionSettingsResultEnabled && !compressionExcluded;
|
|
|
|
const logFires = !promptCompressionEnabled;
|
|
|
|
assert.equal(logFires, true, "the log fires on every default-config request");
|
|
assert.equal(
|
|
reactiveContextCompactionEnabled,
|
|
false,
|
|
"reactive compaction is ALSO disabled here — the old unconditional message was false for this branch"
|
|
);
|
|
});
|
|
|
|
test("the log statement branches on reactiveContextCompactionEnabled so it stays accurate in both cases", () => {
|
|
const blockMatch = source.match(
|
|
/if \(!promptCompressionEnabled\) \{[\s\S]{0,400}\}/
|
|
);
|
|
assert.ok(blockMatch, "expected to find the promptCompressionEnabled debug-log block");
|
|
const block = blockMatch[0];
|
|
|
|
assert.match(
|
|
block,
|
|
/reactiveContextCompactionEnabled/,
|
|
"expected the debug-log block to branch on reactiveContextCompactionEnabled"
|
|
);
|
|
assert.match(
|
|
block,
|
|
/still applies when over threshold/,
|
|
"expected the true-branch message (reactive compaction still active) to be preserved"
|
|
);
|
|
assert.match(
|
|
block,
|
|
/reactive context compaction is ALSO disabled/,
|
|
"expected a distinct false-branch message for the fully-disabled default-install case"
|
|
);
|
|
});
|