experiment(confidence-engine): add alias-capable experiment runtime
This commit is contained in:
@@ -19,6 +19,7 @@ import { createRequire } from "module";
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const rootDir = join(__dirname, "..", "..");
|
||||
const helperPath = join(rootDir, "scripts", "start-case-experiment-helper.cjs");
|
||||
const tsxPath = join(rootDir, "node_modules", ".bin", "tsx");
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
function runHelper(args = [], envOverrides = {}) {
|
||||
@@ -50,6 +51,34 @@ function runHelper(args = [], envOverrides = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
function runHelperWithTsx(args = [], envOverrides = {}) {
|
||||
return new Promise((resolve) => {
|
||||
execFile(
|
||||
tsxPath,
|
||||
[helperPath, ...args],
|
||||
{
|
||||
cwd: rootDir,
|
||||
timeout: 15000,
|
||||
env: {
|
||||
...process.env,
|
||||
OLLAMA_BASE_URL: "https://mock.host.example.com:8080",
|
||||
OLLAMA_MODEL: "mock-model-for-testing",
|
||||
START_CASE_EXPERIMENT_HELPER_MOCK: "1",
|
||||
...envOverrides,
|
||||
},
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
resolve({
|
||||
error: !!error,
|
||||
exitCode: error ? error.code : 0,
|
||||
stdout: stdout || "",
|
||||
stderr: stderr || "",
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function parseOutput(result) {
|
||||
try {
|
||||
return JSON.parse(result.stdout.trim());
|
||||
@@ -300,6 +329,18 @@ describe("start-case-experiment-helper.cjs apparatus", () => {
|
||||
// ── H — Import-only mode (production seam verification) ────────
|
||||
|
||||
describe("H — import-only mode", () => {
|
||||
it("loads real startCase through tsx with aliases resolved and no provider call", async () => {
|
||||
const result = await runHelperWithTsx([], {
|
||||
START_CASE_EXPERIMENT_HELPER_IMPORT_ONLY: "1",
|
||||
});
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(parseOutput(result)).toEqual({
|
||||
success: true,
|
||||
mode: "import-only",
|
||||
startCaseResolved: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("uses plain node subprocess with IMPORT_ONLY=1", async () => {
|
||||
const result = await runHelper([], {
|
||||
START_CASE_EXPERIMENT_HELPER_IMPORT_ONLY: "1",
|
||||
|
||||
Reference in New Issue
Block a user