Files
OmniRoute/tests/unit/codex-tools-split.test.ts
Diego Rodrigues de Sa e Souza 25783d1ca7 refactor(executors): extract reasoning-effort (base) + tool-normalization (codex) leaves (#6030)
Two pure-leaf follow-ups closing the Block H tail:

- base/reasoningEffort.ts: provider-aware reasoning_effort sanitation
  (MISTRAL/GITHUB reject patterns, supportsMaxEffortForProvider,
  sanitizeReasoningEffortForProvider). Deps are config/services only
  (PROVIDER_CLAUDE, isClaudeCodeCompatible, supportsClaudeMaxEffort/supportsXHighEffort)
  so the leaf never imports the host — no cycle. base.ts re-exports
  sanitizeReasoningEffortForProvider for its external importers (mimoThinking + tests).
  base.ts 1466 -> 1312 LOC.

- codex/tools.ts: Responses-API tool normalization (CODEX_HOSTED_TOOL_TYPES hosted-tool
  passthrough, isCodexFreePlan gating, normalizeCodexTools). Self-contained
  (console.debug only). codex.ts re-exports isCodexFreePlan + normalizeCodexTools for
  external importers (tests + provider services). codex.ts 1430 -> 1268 LOC.

Byte-identical bodies (verbatim: base 100/100, codex 126/126); both leaves have zero host
imports. Adds two split-guards asserting the leaf owns the symbol and both import paths
resolve to the same function. Consumer tests stay green (base-executor-sanitize-effort 34,
executor-codex 40, mimoThinking 9, codex-free-plan-image-generation 3, issue-fixes 6).
2026-07-02 23:51:52 -03:00

30 lines
1.4 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
// Split-guard for the codex executor tool-normalization extraction.
// The hosted-tool passthrough + free-plan gating live in codex/tools.ts (self-contained,
// console.debug only). codex.ts re-exports them so external importers keep the path.
const HERE = dirname(fileURLToPath(import.meta.url));
const EXE = join(HERE, "../../open-sse/executors");
test("leaf hosts the tool normalizers and does not import the host", () => {
const src = readFileSync(join(EXE, "codex/tools.ts"), "utf8");
assert.match(src, /export function normalizeCodexTools\b/);
assert.match(src, /export function isCodexFreePlan\b/);
assert.doesNotMatch(src, /from "\.\.\/codex\.ts"/);
});
test("codex.ts re-exports them for external importers", () => {
const host = readFileSync(join(EXE, "codex.ts"), "utf8");
assert.match(host, /export \{[^}]*normalizeCodexTools[^}]*\} from "\.\/codex\/tools\.ts"/s);
});
test("both import paths resolve to the same function", async () => {
const viaHost = (await import("../../open-sse/executors/codex.ts")).normalizeCodexTools;
const viaLeaf = (await import("../../open-sse/executors/codex/tools.ts")).normalizeCodexTools;
assert.equal(viaHost, viaLeaf);
});