mirror of
https://github.com/morluto/rea.git
synced 2026-10-29 10:55:57 +00:00
* fix(hopper): report unavailable procedure body coverage * refactor!: simplify runtime tools and remove replay engines Keep direct inspection, capture, and comparison tools. Bind handlers to named contracts and let agents compose experiments with commands and local fixture servers. BREAKING CHANGE: Remove controlled replay, Node characterization, finite replay-machine, managed runtime planning, and redundant string-tracing tools. Retire process replay, shims, reactive scenarios, custom checkpoints, and active browser replay and origin-scope inputs.
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { parseConfig } from "../../../src/config.js";
|
|
import { silentLogger } from "../../../src/logger.js";
|
|
import { registerConfigReload } from "../../../src/main/reload.js";
|
|
import type { RuntimeDependencies } from "../../../src/main/types.js";
|
|
import { createRuntimeState } from "../../../src/main/state.js";
|
|
|
|
describe("runtime configuration reload", () => {
|
|
it("applies a valid configuration reload", () => {
|
|
const env: NodeJS.ProcessEnv = { REA_LOG_LEVEL: "info" };
|
|
const runtime = setupReload(env);
|
|
|
|
env.REA_LOG_LEVEL = "debug";
|
|
runtime.reload();
|
|
|
|
expect(runtime.state.currentConfig.logLevel).toBe("debug");
|
|
});
|
|
|
|
it("retains the last valid configuration after an invalid reload", () => {
|
|
const env: NodeJS.ProcessEnv = { REA_LOG_LEVEL: "info" };
|
|
const runtime = setupReload(env);
|
|
|
|
env.REA_LOG_LEVEL = "invalid";
|
|
runtime.reload();
|
|
|
|
expect(runtime.state.currentConfig.logLevel).toBe("info");
|
|
});
|
|
});
|
|
|
|
const setupReload = (env: NodeJS.ProcessEnv) => {
|
|
const parsed = parseConfig(env);
|
|
if (!parsed.ok) throw parsed.error;
|
|
const state = createRuntimeState(parsed.value);
|
|
let reload: (() => void) | undefined;
|
|
const dependencies: RuntimeDependencies = {
|
|
env,
|
|
serve: serveStdio,
|
|
writeStderr: () => undefined,
|
|
setExitCode: () => undefined,
|
|
registerShutdown: () => () => undefined,
|
|
registerReload: (handler) => {
|
|
reload = handler;
|
|
return () => undefined;
|
|
},
|
|
};
|
|
registerConfigReload({
|
|
dependencies,
|
|
runtimeState: state,
|
|
serverLogger: silentLogger,
|
|
});
|
|
if (reload === undefined)
|
|
throw new Error("Reload handler was not registered");
|
|
return { reload, state };
|
|
};
|