chore(quality): give the reformatted grok-web suite a cap with headroom

Prettier expands tests/unit/grok-web.test.ts from 2436 to 2713 lines, past its 2437 cap.
Cap set to 2985 (~10% headroom) per the operator's instruction, so routine additions to
this suite do not re-trip the gate on formatting alone. Recorded as a deliberate,
annotated exception to the down-only ratchet; no other entry moves.
This commit is contained in:
Markus Hartung
2026-09-02 10:14:33 -03:00
16 changed files with 375 additions and 157 deletions

View File

@@ -7,6 +7,7 @@ import {
parseTscOutput,
diffAgainstBaseline,
} from "../../../scripts/check/check-api-typecheck.mjs";
import { diffAgainstBaseline as diffOpenSseAgainstBaseline } from "../../../scripts/check/check-open-sse-typecheck.mjs";
test("parseTscOutput: parses an API-route TS2554 regression", () => {
const raw =
@@ -85,3 +86,130 @@ test("diffAgainstBaseline: reports a disappeared diagnostic as an improvement",
assert.equal(improvements[0].liveCount, 0);
assert.equal(improvements[0].baselineCount, 2);
});
test("diffAgainstBaseline: ignores underscore-prefixed baseline metadata", () => {
const baseline = {
_relax_velocity_2026_08_30:
"per-file TS diagnostic counts raised by 20% (289 -> 455); velocity phase",
"src/app/api/foo/route.ts": { TS2339: 1 },
};
const live = { "src/app/api/foo/route.ts": { TS2339: 1 } };
for (const compare of [diffAgainstBaseline, diffOpenSseAgainstBaseline]) {
assert.deepEqual(compare(live, baseline), {
regressions: [],
improvements: [],
});
}
});
test("diffAgainstBaseline: rejects a string in place of a real file diagnostic map", () => {
const malformedBaseline = {
"src/app/api/foo/route.ts": "TS2339: 1",
};
assert.throws(
() => diffAgainstBaseline({}, malformedBaseline),
/src\/app\/api\/foo\/route\.ts.*plain object/
);
assert.throws(
() => diffOpenSseAgainstBaseline({}, malformedBaseline),
/src\/app\/api\/foo\/route\.ts.*plain object/
);
});
test("diffAgainstBaseline: rejects non-plain roots and file maps", () => {
const inheritedRoot = Object.create({
"src/app/api/inherited/route.ts": { TS2339: 1 },
});
const inheritedFileMap = Object.create({ TS2339: 1 });
for (const malformedBaseline of [[], "not an object", null, inheritedRoot]) {
assert.throws(
() => diffAgainstBaseline({}, malformedBaseline),
/typecheck baseline must be a plain object/
);
}
for (const malformedFileMap of [[], null, inheritedFileMap]) {
assert.throws(
() =>
diffAgainstBaseline(
{},
{
"src/app/api/foo/route.ts": malformedFileMap,
}
),
/src\/app\/api\/foo\/route\.ts.*plain object/
);
}
});
test("diffAgainstBaseline: rejects prototype property keys", () => {
const malformedBaseline = JSON.parse('{"__proto__":{"TS2339":1}}');
assert.throws(
() => diffAgainstBaseline({}, malformedBaseline),
/unsupported property key "__proto__"/
);
});
test("diffAgainstBaseline: rejects non-TypeScript diagnostic keys", () => {
for (const code of ["2339", "TSX2339", "TS23x", "constructor"]) {
assert.throws(
() =>
diffAgainstBaseline(
{},
{
"src/app/api/foo/route.ts": { [code]: 1 },
}
),
/invalid TypeScript code/
);
}
});
test("diffAgainstBaseline: rejects invalid diagnostic counts", () => {
for (const count of [Number.NaN, Number.POSITIVE_INFINITY, -1, 1.5, "1"]) {
assert.throws(
() =>
diffAgainstBaseline(
{},
{
"src/app/api/foo/route.ts": { TS2339: count },
}
),
/finite nonnegative integer/
);
}
});
test("diffAgainstBaseline: validates live diagnostics with the same schema", () => {
assert.throws(
() =>
diffAgainstBaseline(
{ "src/app/api/foo/route.ts": { TS2339: -1 } },
{ "src/app/api/foo/route.ts": { TS2339: 1 } }
),
/live diagnostics.*finite nonnegative integer/
);
});
test("diffAgainstBaseline: accepts zero counts without fabricating a second improvement", () => {
assert.deepEqual(
diffAgainstBaseline(
{ "src/app/api/foo/route.ts": { TS2339: 0 } },
{ "src/app/api/foo/route.ts": { TS2339: 1 } }
),
{
regressions: [],
improvements: [
{
file: "src/app/api/foo/route.ts",
code: "TS2339",
liveCount: 0,
baselineCount: 1,
},
],
}
);
});

View File

@@ -541,7 +541,7 @@ test("provider asset provenance gate binds auditedCommit to the physical provide
}
});
test("repository provider asset manifest covers the audited 142-file snapshot", (t) => {
test("repository provider asset manifest covers the audited 141-file snapshot", (t) => {
const manifestPath = join(REPO_ROOT, "config/quality/provider-assets-provenance.jsonl");
const { auditedCommit } = JSON.parse(readFileSync(manifestPath, "utf8").split("\n")[0]);
if (!gitHasCommit(auditedCommit) && isShallowRepository()) {
@@ -556,7 +556,7 @@ test("repository provider asset manifest covers the audited 142-file snapshot",
assert.equal(result.status, 0, `${result.stdout}\n${result.stderr}`);
assert.match(
result.stdout,
/142\/142 registered; proven=71 probable=69 unresolved=2; duplicate-groups=1/
/141\/141 registered; proven=72 probable=69 unresolved=0; duplicate-groups=1/
);
});

View File

@@ -35,6 +35,7 @@ const LOCAL_SVG_IDS_WITHOUT_PROVENANCE = [
"leonardo",
"modal",
"modelscope",
"nimble-search",
"nlpcloud",
"oauth",
"oci",
@@ -177,9 +178,9 @@ const AUDITED_REFERENCE_FILES = [
...referenceRoots.flatMap((directory) => collectTextFiles(join(root, directory))),
];
test("provider bundle retires exactly the 78 unresolved assets and keeps the generic icon", () => {
assert.equal(retiredAssetNames.length, 78);
assert.equal(new Set(retiredAssetNames).size, 78);
test("provider bundle retires exactly the 79 unresolved assets and keeps the generic icon", () => {
assert.equal(retiredAssetNames.length, 79);
assert.equal(new Set(retiredAssetNames).size, 79);
for (const assetName of retiredAssetNames) {
assert.equal(
@@ -196,8 +197,9 @@ test("provider bundle retires exactly the 78 unresolved assets and keeps the gen
// provenance PRs (#11735, #11736, #11711) landed first and independently retired
// 6 further unproven files this PR never targeted (freebuff-dark.svg,
// freebuff-light.svg, freebuff.png, openvecta.svg, picoclaw.jpg, zoocode.png),
// so the real remaining count is 142, not 148.
assert.equal(distributedAssets.length, 142, "all 142 non-target assets must remain");
// so the real pre-fix count was 142, not 148. This fix retires the unresolved
// Nimble asset as well, leaving 141 distributed assets.
assert.equal(distributedAssets.length, 141, "all 141 non-target assets must remain");
assert.ok(distributedAssets.includes("cli-generic.svg"));
});

View File

@@ -0,0 +1,42 @@
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import test from "node:test";
import { NextRequest } from "next/server";
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-rerank-providers-route-"));
process.env.DATA_DIR = TEST_DATA_DIR;
const core = await import("../../src/lib/db/core.ts");
const { createProviderNode } = await import("../../src/lib/db/providers/nodes.ts");
const rerankProvidersRoute = await import("../../src/app/api/memory/rerank-providers/route.ts");
test.after(() => {
core.resetDbInstance();
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
});
test("GET /api/memory/rerank-providers includes rerank-capable local provider nodes", async () => {
await createProviderNode({
id: "rerank-route-test-node",
type: "openai-compatible",
name: "Local reranker",
prefix: "local-reranker",
apiType: "rerank",
baseUrl: "http://127.0.0.1:8099/v1",
});
const response = await rerankProvidersRoute.GET(
new NextRequest("http://localhost/api/memory/rerank-providers")
);
const body = await response.json();
assert.equal(response.status, 200);
assert.deepEqual(
body.providers.find(
(provider: { provider?: string }) => provider.provider === "local-reranker"
),
{ provider: "local-reranker", hasKey: true, models: [] }
);
});

View File

@@ -120,6 +120,52 @@ test("injectSystemPrompt: null body returns as-is", () => {
assert.equal(injectSystemPrompt(null), null);
});
test("injectSystemPrompt: non-object bodies return as-is", () => {
setSystemPromptConfig({ enabled: true, suffixPrompt: "test" });
for (const body of [undefined, "prompt", 42, true]) {
assert.equal(injectSystemPrompt(body), body);
}
});
test("injectSystemPrompt: skips malformed message entries safely", () => {
setSystemPromptConfig({ enabled: true, prefixPrompt: "PRE", suffixPrompt: "SUF" });
const body = {
messages: [
{ role: "user", content: "hi" },
null,
{ role: "system", content: "Original prompt" },
],
};
const result = injectSystemPrompt(body);
assert.equal(result.messages[2].content, "PRE\n\nOriginal prompt\n\nSUF");
assert.equal(result.messages[1], null);
});
test("injectSystemPrompt: does not mutate the request or nested message content", () => {
setSystemPromptConfig({ enabled: true, prefixPrompt: "PRE", suffixPrompt: "SUF" });
const systemContent = [{ type: "text", text: "Original prompt" }];
const systemMessage = { role: "system", content: systemContent };
const body = {
messages: [systemMessage, { role: "user", content: "hi" }],
};
const result = injectSystemPrompt(body);
assert.notEqual(result, body);
assert.notEqual(result.messages, body.messages);
assert.notEqual(result.messages[0], systemMessage);
assert.notEqual(result.messages[0].content, systemContent);
assert.deepEqual(body, {
messages: [
{ role: "system", content: [{ type: "text", text: "Original prompt" }] },
{ role: "user", content: "hi" },
],
});
});
test("injectSystemPrompt: developer role treated as system", () => {
setSystemPromptConfig({ enabled: true, prefixPrompt: "PRE", suffixPrompt: "SUF" });
const body = {

View File

@@ -54,6 +54,7 @@ const PROVIDER_IDS_WITHOUT_LOCAL_ASSET_PROVENANCE = [
"leonardo",
"modal",
"modelscope",
"nimble-search",
"nlpcloud",
"oauth",
"oci",
@@ -229,6 +230,7 @@ describe("ProviderIcon — local SVG dimensions", () => {
it.each([
["cline", "/providers/cline.svg"],
["kimi-coding", "/providers/kimi-logomark-light.svg"],
["opper", "/providers/opper.svg"],
])("gives %s a definite square layout size", (providerId, expectedSrc) => {
const container = renderIcon({ providerId, size: 24 });
const img = container.querySelector(`img[src="${expectedSrc}"]`);
@@ -244,8 +246,8 @@ describe("ProviderIcon — local SVG dimensions", () => {
describe("ProviderIcon — unresolved local asset provenance", () => {
it("covers the complete provider and alias inventory", () => {
expect(PROVIDER_IDS_WITHOUT_LOCAL_ASSET_PROVENANCE).toHaveLength(78);
expect(new Set(PROVIDER_IDS_WITHOUT_LOCAL_ASSET_PROVENANCE)).toHaveLength(78);
expect(PROVIDER_IDS_WITHOUT_LOCAL_ASSET_PROVENANCE).toHaveLength(79);
expect(new Set(PROVIDER_IDS_WITHOUT_LOCAL_ASSET_PROVENANCE)).toHaveLength(79);
});
it.each(PROVIDER_IDS_WITHOUT_LOCAL_ASSET_PROVENANCE)(