fix(qa): reject duplicate plugin gauntlet controls

This commit is contained in:
Vincent Koc 2026-06-23 17:37:42 +02:00
parent 58552f6d7c
commit dc9c11be91
No known key found for this signature in database
2 changed files with 34 additions and 0 deletions

View file

@ -35,6 +35,24 @@ const DEFAULT_CPU_CORE_WARN = 0.9;
const DEFAULT_HOT_WALL_WARN_MS = 30_000;
const DEFAULT_MAX_RSS_WARN_MB = 1536;
const DEFAULT_QA_PLUGIN_CHUNK_SIZE = 12;
const SINGLE_VALUE_FLAGS = new Set([
"--build-timeout-ms",
"--command-timeout-ms",
"--cpu-core-warn",
"--hot-wall-warn-ms",
"--limit",
"--max-rss-warn-mb",
"--output-dir",
"--qa-cpu-regression-multiplier",
"--qa-plugin-chunk-size",
"--qa-timeout-ms",
"--qa-wall-regression-multiplier",
"--repo-root",
"--rss-anomaly-multiplier",
"--shard-index",
"--shard-total",
"--wall-anomaly-multiplier",
]);
const COMMAND_OUTPUT_MAX_BUFFER_BYTES = 16 * 1024 * 1024;
const MAX_TIMER_TIMEOUT_MS = 2_147_000_000;
const ANSI_PATTERN = new RegExp(String.raw`\u001B\[[0-9;]*m`, "gu");
@ -79,8 +97,15 @@ export function parseArgs(argv) {
};
const envIds = normalizeCsv(process.env.OPENCLAW_PLUGIN_GATEWAY_GAUNTLET_IDS);
options.pluginIds.push(...envIds);
const seenSingleValueFlags = new Set();
parseArgv: for (let index = 0; index < args.length; index += 1) {
const arg = args[index];
if (SINGLE_VALUE_FLAGS.has(arg)) {
if (seenSingleValueFlags.has(arg)) {
throw new Error(`${arg} was provided more than once`);
}
seenSingleValueFlags.add(arg);
}
const readValue = () => {
const value = args[index + 1];
if (!value || value.startsWith("-")) {

View file

@ -150,6 +150,15 @@ describe("plugin gateway gauntlet helpers", () => {
);
});
it("rejects duplicate single-value controls", () => {
expect(() =>
parseArgs(["--output-dir", ".artifacts/one", "--output-dir", ".artifacts/two"]),
).toThrow("--output-dir was provided more than once");
expect(() => parseArgs(["--shard-total", "2", "--shard-total", "3"])).toThrow(
"--shard-total was provided more than once",
);
});
it("rejects valued flags followed by another option", () => {
for (const flag of [
"--repo-root",