Validate columns × (rows + scrollback) against a 1,000,000-cell xterm working-buffer budget, including every resize with the selected scrollback. Document the budget in the advertised MCP input and process-capture guide; never clamp caller dimensions. Validation: default/exact-boundary schema cases, prelaunch MCP rejection, compiled CLI capture, terminal rendering, normalization, cancellation, and lifecycle checks pass on macOS. This is resource admission, not a measured serializer throughput improvement; Linux-only and real deep-analysis providers were not exercised. BREAKING CHANGE: process scenarios whose initial or resized terminal exceeds 1,000,000 combined visible-plus-scrollback cells are now rejected before launch.
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import { expect, it } from "vitest";
|
|
|
|
import {
|
|
parseProcessScenario,
|
|
PROCESS_TERMINAL_CELL_BUDGET,
|
|
processScenarioSchema,
|
|
} from "./processScenario.js";
|
|
|
|
it("admits the default and the exact combined terminal-cell budget", () => {
|
|
expect(parseProcessScenario({ executable: "/bin/true" }).terminal).toEqual({
|
|
columns: 80,
|
|
rows: 24,
|
|
scrollback: 1_000,
|
|
});
|
|
|
|
expect(
|
|
processScenarioSchema.safeParse({
|
|
executable: "/bin/true",
|
|
terminal: {
|
|
columns: 1,
|
|
rows: 1,
|
|
scrollback: PROCESS_TERMINAL_CELL_BUDGET - 1,
|
|
},
|
|
}).success,
|
|
).toBe(true);
|
|
});
|
|
|
|
it("rejects an oversized initial buffer without clamping caller dimensions", () => {
|
|
const input = {
|
|
executable: "/bin/true",
|
|
terminal: { columns: 1_000, rows: 1, scrollback: 1_000 },
|
|
};
|
|
const parsed = processScenarioSchema.safeParse(input);
|
|
|
|
expect(parsed.success).toBe(false);
|
|
if (parsed.success) throw new Error("expected terminal capacity rejection");
|
|
expect(parsed.error.issues).toContainEqual(
|
|
expect.objectContaining({
|
|
code: "custom",
|
|
path: ["terminal"],
|
|
message: expect.stringContaining(
|
|
`${String(PROCESS_TERMINAL_CELL_BUDGET)} renderer cells`,
|
|
),
|
|
}),
|
|
);
|
|
});
|
|
|
|
it("applies the selected scrollback budget to every scheduled resize", () => {
|
|
const parsed = processScenarioSchema.safeParse({
|
|
executable: "/bin/true",
|
|
events: [{ type: "resize", at_ms: 10, columns: 1_000, rows: 1 }],
|
|
});
|
|
|
|
expect(parsed.success).toBe(false);
|
|
if (parsed.success) throw new Error("expected resize capacity rejection");
|
|
expect(parsed.error.issues).toContainEqual(
|
|
expect.objectContaining({
|
|
code: "custom",
|
|
path: ["events", 0],
|
|
message: expect.stringContaining("resize event at 10 ms"),
|
|
}),
|
|
);
|
|
|
|
expect(
|
|
processScenarioSchema.safeParse({
|
|
executable: "/bin/true",
|
|
terminal: { columns: 1, rows: 1, scrollback: 0 },
|
|
events: [{ type: "resize", at_ms: 10, columns: 1_000, rows: 1 }],
|
|
}).success,
|
|
).toBe(true);
|
|
});
|