mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-17 12:22:34 +03:00
`main` has been red since b342c1a361 on the vitest and integration gates:
✖ tests/unit/autoCombo/provider-family-combos.test.ts > auto/<family>
✖ chat pipeline applies Codex OAuth fingerprint and priority tier inside combos
Both call resetStorage() from beforeEach, which does an fs.rmSync(TEST_DATA_DIR,
{recursive: true, force: true}) with no retry, and intermittently loses the race
with a not-yet-released SQLite handle (ENOTEMPTY).
release/v3.8.51 fixed this in #11968 with a mechanical codemod adding
maxRetries/retryDelay to every recursive rm/rmSync/rmdirSync under tests/, but
that PR landed only on the release branch. Because main only receives work at
the release squash, it stayed broken for the whole cycle — and repo-wide gates
then turn every open PR into main red on checks unrelated to their diff.
This is the --base main twin: re-runs the same codemod that already shipped on
the release branch (scripts/ad-hoc/codemod-rm-maxretries.mjs), so the two
branches converge on identical test-teardown semantics. Test-only; no product
logic is touched.
The remaining three failures reported on #12133 (unit full suite exceeding its
4800s ceiling, package-artifact exceeding 1200s, and the boot-smoke that is
skipped as a consequence) are runner-contention timeouts, not code defects —
validate-release-green.mjs runs those heavy gates concurrently on one shared
hosted runner. There is no fix to port for those.
57 lines
2.1 KiB
TypeScript
57 lines
2.1 KiB
TypeScript
// Characterization of resolveCompressionSettings — the compression settings read extracted from
|
|
// handleChatCore's Proactive Context Compression setup (chatCore god-file decomposition, #3501).
|
|
// Uses a real temp DB (getCompressionSettings reads/seeds the settings row). Locks: the derived
|
|
// enabled / contextEditingEnabled flags and the disabled fallback shape.
|
|
import { test, before, after } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
const testDataDir = fs.mkdtempSync(path.join(os.tmpdir(), "omni-comp-settings-test-"));
|
|
process.env.DATA_DIR = testDataDir;
|
|
|
|
const coreDb = await import("../../src/lib/db/core.ts");
|
|
const { createDisabledCompressionConfig, resolveCompressionSettings } =
|
|
await import("../../open-sse/handlers/chatCore/compressionSettings.ts");
|
|
|
|
before(async () => {
|
|
await coreDb.ensureDbInitialized();
|
|
});
|
|
|
|
after(() => {
|
|
coreDb.resetDbInstance();
|
|
try {
|
|
fs.rmSync(testDataDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
} catch {
|
|
// best-effort cleanup
|
|
}
|
|
});
|
|
|
|
test("returns the settings object from the DB", async () => {
|
|
const result = await resolveCompressionSettings();
|
|
assert.ok(result.settings, "expected a settings object from the seeded DB");
|
|
});
|
|
|
|
test("builds a complete disabled compression fallback", () => {
|
|
assert.deepEqual(createDisabledCompressionConfig(), {
|
|
enabled: false,
|
|
defaultMode: "off",
|
|
autoTriggerTokens: 0,
|
|
cacheMinutes: 5,
|
|
preserveSystemPrompt: true,
|
|
comboOverrides: {},
|
|
engines: {},
|
|
activeComboId: null,
|
|
});
|
|
});
|
|
|
|
test("derives enabled and contextEditingEnabled from the settings", async () => {
|
|
const result = await resolveCompressionSettings();
|
|
// `enabled` mirrors settings.enabled exactly
|
|
assert.equal(result.enabled, result.settings!.enabled);
|
|
// `contextEditingEnabled` is the strict === true derivation of the nested flag
|
|
assert.equal(result.contextEditingEnabled, result.settings!.contextEditing?.enabled === true);
|
|
assert.equal(typeof result.contextEditingEnabled, "boolean");
|
|
});
|