refactor!: simplify runtime tools and remove replay engines (#572)
* 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.
This commit is contained in:
@@ -2,14 +2,33 @@ import { describe, expect, it } from "vitest";
|
||||
|
||||
import { processScenarioSchema } from "./processScenario.js";
|
||||
|
||||
describe("process scenario collection inputs", () => {
|
||||
it("accepts OS environment names without imposing shell identifier syntax", () => {
|
||||
describe("direct process scenarios", () => {
|
||||
it("defaults to one command with inherited environment and no filesystem scan", () => {
|
||||
expect(processScenarioSchema.parse({ executable: "node" })).toMatchObject({
|
||||
executable: "node",
|
||||
arguments: [],
|
||||
working_directory: ".",
|
||||
environment: {},
|
||||
filesystem_observation_paths: [],
|
||||
events: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("accepts caller-selected environment and explicit filesystem observations", () => {
|
||||
const environment = { "app.setting": "value", "1": "numbered" };
|
||||
expect(
|
||||
processScenarioSchema.parse({ executable: "node", environment })
|
||||
.environment,
|
||||
).toEqual(environment);
|
||||
for (const name of ["", "KEY=VALUE", "KEY\0VALUE"])
|
||||
const scenario = processScenarioSchema.parse({
|
||||
executable: "node",
|
||||
arguments: ["./task.mjs"],
|
||||
working_directory: "./project",
|
||||
environment,
|
||||
filesystem_observation_paths: ["state"],
|
||||
});
|
||||
expect(scenario.environment).toEqual(environment);
|
||||
expect(scenario.filesystem_observation_paths).toEqual(["state"]);
|
||||
});
|
||||
|
||||
it("rejects malformed environment names and adapter-reserved identity", () => {
|
||||
for (const name of ["", "KEY=VALUE", "KEY\0VALUE", "REA_PROCESS_RUN_ID"])
|
||||
expect(
|
||||
processScenarioSchema.safeParse({
|
||||
executable: "node",
|
||||
@@ -18,263 +37,39 @@ describe("process scenario collection inputs", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts more than 64 named filesystem checkpoints", () => {
|
||||
it("keeps bounded capture controls and ordered scheduled interaction", () => {
|
||||
const scenario = processScenarioSchema.parse({
|
||||
executable: "/bin/echo",
|
||||
working_directory: "/tmp",
|
||||
checkpoints: Array.from({ length: 65 }, (_, index) => ({
|
||||
name: `state-${index}`,
|
||||
trigger: { type: "root_exit" as const },
|
||||
})),
|
||||
});
|
||||
|
||||
expect(scenario.checkpoints).toHaveLength(65);
|
||||
});
|
||||
|
||||
it("allows a zero-depth filesystem observation", () => {
|
||||
expect(
|
||||
processScenarioSchema.parse({
|
||||
executable: "/bin/echo",
|
||||
working_directory: "/tmp",
|
||||
limits: { filesystem_depth: 0 },
|
||||
}).limits.filesystem_depth,
|
||||
).toBe(0);
|
||||
});
|
||||
|
||||
it("accepts caller budgets above the former tool-side ceilings", () => {
|
||||
const scenario = processScenarioSchema.parse({
|
||||
executable: "/bin/echo",
|
||||
working_directory: "/tmp",
|
||||
timeout_ms: 600_000,
|
||||
idle_timeout_ms: 900_000,
|
||||
settle_ms: 20_000,
|
||||
limits: {
|
||||
output_bytes: 10_000_001,
|
||||
files: 100_001,
|
||||
file_bytes: 100_000_001,
|
||||
processes: 10_001,
|
||||
protocol_events: 100_001,
|
||||
protocol_body_bytes: 10_000_001,
|
||||
connections: 1_001,
|
||||
filesystem_depth: 100,
|
||||
},
|
||||
checkpoints: [
|
||||
{
|
||||
name: "later",
|
||||
trigger: { type: "time", at_ms: 600_000 },
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(scenario.limits.output_bytes).toBe(10_000_001);
|
||||
expect(scenario.limits.files).toBe(100_001);
|
||||
expect(scenario.limits.file_bytes).toBe(100_000_001);
|
||||
expect(scenario.limits.processes).toBe(10_001);
|
||||
expect(scenario.limits.protocol_events).toBe(100_001);
|
||||
expect(scenario.limits.protocol_body_bytes).toBe(10_000_001);
|
||||
expect(scenario.limits.connections).toBe(1_001);
|
||||
expect(scenario.limits.filesystem_depth).toBe(100);
|
||||
expect(scenario.timeout_ms).toBe(600_000);
|
||||
expect(scenario.idle_timeout_ms).toBe(900_000);
|
||||
expect(scenario.settle_ms).toBe(20_000);
|
||||
});
|
||||
});
|
||||
|
||||
describe("process scenario complete input values", () => {
|
||||
it("accepts long checkpoint and command names", () => {
|
||||
const checkpointName = `c${"k".repeat(1_000)}`;
|
||||
const commandName = `c${"m".repeat(1_000)}`;
|
||||
const scenario = processScenarioSchema.parse({
|
||||
executable: "/bin/echo",
|
||||
working_directory: "/tmp",
|
||||
checkpoints: [{ name: checkpointName, trigger: { type: "root_exit" } }],
|
||||
command_shims: [
|
||||
{
|
||||
name: commandName,
|
||||
routes: [
|
||||
{
|
||||
arguments: [],
|
||||
termination: { type: "exit", code: 0 },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(scenario.checkpoints[0]?.name).toBe(checkpointName);
|
||||
expect(scenario.command_shims[0]?.name).toBe(commandName);
|
||||
});
|
||||
});
|
||||
|
||||
describe("process scenario long delays", () => {
|
||||
it("accepts delayed actions longer than one operating-system timer", () => {
|
||||
const beyondOneTimer = 2_147_483_648;
|
||||
const scenario = processScenarioSchema.parse({
|
||||
executable: "/bin/echo",
|
||||
working_directory: "/tmp",
|
||||
timeout_ms: beyondOneTimer + 1,
|
||||
events: [{ type: "input", at_ms: beyondOneTimer, data: "later" }],
|
||||
checkpoints: [
|
||||
{
|
||||
name: "later",
|
||||
trigger: { type: "time", at_ms: beyondOneTimer },
|
||||
},
|
||||
],
|
||||
command_shims: [
|
||||
{
|
||||
name: "later",
|
||||
routes: [
|
||||
{
|
||||
arguments: [],
|
||||
outputs: [
|
||||
{
|
||||
at_ms: beyondOneTimer,
|
||||
stream: "stdout",
|
||||
data: "later",
|
||||
},
|
||||
],
|
||||
termination: { type: "exit", code: 0 },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
replay: {
|
||||
http: [
|
||||
{
|
||||
method: "GET",
|
||||
path: "/later",
|
||||
status: 200,
|
||||
body: "later",
|
||||
delay_ms: beyondOneTimer,
|
||||
},
|
||||
],
|
||||
websocket_connections: [
|
||||
{
|
||||
messages: [{ data: "later", delay_ms: beyondOneTimer }],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(scenario.events[0]?.at_ms).toBe(beyondOneTimer);
|
||||
expect(scenario.checkpoints[0]?.trigger).toMatchObject({
|
||||
at_ms: beyondOneTimer,
|
||||
});
|
||||
expect(scenario.command_shims[0]?.routes[0]?.outputs[0]?.at_ms).toBe(
|
||||
beyondOneTimer,
|
||||
);
|
||||
expect(scenario.replay.http[0]?.delay_ms).toBe(beyondOneTimer);
|
||||
expect(
|
||||
scenario.replay.websocket_connections[0]?.messages[0]?.delay_ms,
|
||||
).toBe(beyondOneTimer);
|
||||
});
|
||||
});
|
||||
|
||||
describe("process scenario large interaction inputs", () => {
|
||||
it("accepts large interaction and replay descriptions under the run budgets", () => {
|
||||
const environment = Object.fromEntries(
|
||||
Array.from({ length: 65 }, (_, index) => [`APP_VALUE_${index}`, "x"]),
|
||||
);
|
||||
const commandShims = Array.from({ length: 33 }, (_, shimIndex) => ({
|
||||
name: `tool-${shimIndex}`,
|
||||
routes: Array.from({ length: 101 }, (_, routeIndex) => ({
|
||||
arguments: [`--route-${routeIndex}`],
|
||||
outputs: Array.from({ length: routeIndex === 0 ? 1_001 : 0 }, () => ({
|
||||
at_ms: 0,
|
||||
stream: "stdout" as const,
|
||||
data: "x",
|
||||
})),
|
||||
termination: { type: "exit" as const, code: 0 },
|
||||
max_calls: 101,
|
||||
})),
|
||||
}));
|
||||
const scenario = processScenarioSchema.parse({
|
||||
executable: "/bin/echo",
|
||||
arguments: Array.from({ length: 257 }, (_, index) => String(index)),
|
||||
working_directory: "/tmp",
|
||||
filesystem_observation_paths: Array.from(
|
||||
{ length: 17 },
|
||||
(_, index) => `/tmp/root-${index}`,
|
||||
),
|
||||
environment,
|
||||
command_shims: commandShims,
|
||||
events: Array.from({ length: 1_001 }, () => ({
|
||||
type: "input" as const,
|
||||
at_ms: 0,
|
||||
data: "x",
|
||||
})),
|
||||
checkpoints: [
|
||||
{
|
||||
name: "many_occurrences",
|
||||
trigger: {
|
||||
type: "terminal_literal",
|
||||
value: "ready",
|
||||
occurrence: 1_001,
|
||||
},
|
||||
},
|
||||
],
|
||||
replay: {
|
||||
http: Array.from({ length: 101 }, (_, index) => ({
|
||||
method: "GET",
|
||||
path: `/route-${index}`,
|
||||
status: 200,
|
||||
body: "ok",
|
||||
max_calls: 101,
|
||||
})),
|
||||
websocket_messages: Array.from({ length: 101 }, () => "message"),
|
||||
websocket_connections: Array.from({ length: 101 }, () => ({
|
||||
messages: Array.from({ length: 101 }, () => ({ data: "message" })),
|
||||
disconnect_after: false,
|
||||
})),
|
||||
},
|
||||
});
|
||||
|
||||
expect(scenario.arguments).toHaveLength(257);
|
||||
expect(scenario.command_shims).toHaveLength(33);
|
||||
expect(scenario.command_shims[0]?.routes).toHaveLength(101);
|
||||
expect(scenario.command_shims[0]?.routes[0]?.outputs).toHaveLength(1_001);
|
||||
expect(scenario.events).toHaveLength(1_001);
|
||||
expect(scenario.filesystem_observation_paths).toHaveLength(17);
|
||||
expect(scenario.checkpoints[0]?.trigger).toMatchObject({
|
||||
occurrence: 1_001,
|
||||
});
|
||||
expect(scenario.replay.http).toHaveLength(101);
|
||||
expect(scenario.replay.websocket_connections[0]?.messages).toHaveLength(
|
||||
101,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("minimal process scenario inputs", () => {
|
||||
const scenario = {
|
||||
arguments: [],
|
||||
environment: {},
|
||||
filesystem_observation_paths: [],
|
||||
};
|
||||
|
||||
it("defaults working directory at execution and accepts command names", () => {
|
||||
const parsed = processScenarioSchema.parse({
|
||||
...scenario,
|
||||
executable: "node",
|
||||
events: [
|
||||
{ type: "input", at_ms: 10, data: "answer", sensitive: true },
|
||||
{ type: "resize", at_ms: 20, columns: 100, rows: 30 },
|
||||
{ type: "signal", at_ms: 30, signal: "SIGTERM" },
|
||||
],
|
||||
limits: { output_bytes: 2_000_000, filesystem_depth: 0 },
|
||||
});
|
||||
expect(parsed.working_directory).toBe(".");
|
||||
expect(parsed.executable).toBe("node");
|
||||
expect(parsed.filesystem_observation_paths).toEqual([]);
|
||||
expect(scenario.events).toHaveLength(3);
|
||||
expect(scenario.events[0]).toMatchObject({ sensitive: true });
|
||||
expect(scenario.limits.output_bytes).toBe(2_000_000);
|
||||
expect(scenario.limits.filesystem_depth).toBe(0);
|
||||
});
|
||||
|
||||
it("rejects events after timeout and unknown orchestration fields", () => {
|
||||
expect(
|
||||
processScenarioSchema.safeParse({
|
||||
executable: "node",
|
||||
timeout_ms: 10,
|
||||
events: [{ type: "input", at_ms: 11, data: "late" }],
|
||||
}).success,
|
||||
).toBe(false);
|
||||
for (const [field, value] of [
|
||||
["command_shims", []],
|
||||
["replay", {}],
|
||||
["reactive", {}],
|
||||
["checkpoints", []],
|
||||
] as const)
|
||||
expect(
|
||||
processScenarioSchema.safeParse({ executable: "node", [field]: value })
|
||||
.success,
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("process scenario path portability", () => {
|
||||
it.each([
|
||||
["posix", "/usr/bin/node", "/tmp"],
|
||||
["windows drive with backslashes", "C:\\tools\\node.exe", "C:\\work"],
|
||||
["windows drive with forward slashes", "c:/tools/node.exe", "c:/work"],
|
||||
["unc share", "\\\\server\\share\\node.exe", "\\\\server\\share"],
|
||||
])(
|
||||
"preserves a %s scenario on any host",
|
||||
(_label, executable, working_directory) => {
|
||||
expect(
|
||||
processScenarioSchema.parse({ executable, working_directory }),
|
||||
).toMatchObject({ executable, working_directory });
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user