{"record":{"id":"55379804114ca0c8","repo":"stablyai/orca","slug":"orca-advertised-url-bench-rounds-must-be-even","errorCode":null,"errorMessage":"ORCA_ADVERTISED_URL_BENCH_ROUNDS must be even","messagePattern":"ORCA_ADVERTISED_URL_BENCH_ROUNDS must be even","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/scripts/advertised-url-watcher-benchmark.mjs","lineNumber":63,"sourceCode":"  new URL('../../src/main/ports/advertised-url-watcher.ts', import.meta.url).href\n)\n\nconst BUFFER_LIMIT = 4096\nconst ITERATIONS = Number(process.env.ORCA_ADVERTISED_URL_BENCH_ITERATIONS ?? '10000')\nconst ROUNDS = Number(process.env.ORCA_ADVERTISED_URL_BENCH_ROUNDS ?? '12')\nconst WARMUP = Number(process.env.ORCA_ADVERTISED_URL_BENCH_WARMUP ?? '1000')\n\nfor (const [name, value] of [\n  ['ORCA_ADVERTISED_URL_BENCH_ITERATIONS', ITERATIONS],\n  ['ORCA_ADVERTISED_URL_BENCH_ROUNDS', ROUNDS],\n  ['ORCA_ADVERTISED_URL_BENCH_WARMUP', WARMUP]\n]) {\n  if (!Number.isSafeInteger(value) || value <= 0) {\n    throw new Error(`${name} must be a positive integer, received ${value}`)\n  }\n}\nif (ROUNDS % 2 !== 0) {\n  throw new Error('ORCA_ADVERTISED_URL_BENCH_ROUNDS must be even')\n}\n\nclass BeforePtyBuffer {\n  raw = ''\n\n  ingest(chunk) {\n    const chunkHasLineBreak = chunk.includes('\\n') || chunk.includes('\\r')\n    this.raw += chunk\n    if (this.raw.length > BUFFER_LIMIT) {\n      this.raw = this.raw.slice(-BUFFER_LIMIT)\n    }\n    if (!chunkHasLineBreak) {\n      return ''\n    }\n    const lastNewline = lastLineBreak(this.raw)\n    if (lastNewline === -1) {\n      return ''\n    }","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/advertised-url-watcher-benchmark.mjs#L45-L81","documentation":"Thrown by the advertised-url-watcher benchmark when ORCA_ADVERTISED_URL_BENCH_ROUNDS is odd. The benchmark alternates which arm leads each round to neutralize within-round drift (see measure()), and the median computation requires an even count; an odd value would skew the median and undermine the comparison's fairness.","triggerScenarios":"Operator sets ORCA_ADVERTISED_URL_BENCH_ROUNDS=5 (or any odd number); the default of 12 was overridden with an odd value.","commonSituations":"Operator picks a 'nicer' round count (5, 7, 10) without reading the parity requirement; CI workflow hardcoded an odd default; reducing rounds for a quick smoke run landed on an odd number.","solutions":["Use an even value: ORCA_ADVERTISED_URL_BENCH_ROUNDS=12 (default) or 6, 10, 20.","For a quick smoke run, drop to 2 rounds (still even) rather than 1 or 3.","Update the workflow's documented default if a different even number is desired.","If you genuinely need odd rounds, also update the median() helper in the benchmark to handle odd-length samples."],"exampleFix":"// before\n// ORCA_ADVERTISED_URL_BENCH_ROUNDS=7 node config/scripts/advertised-url-watcher-benchmark.mjs\n// -> 'ORCA_ADVERTISED_URL_BENCH_ROUNDS must be even'\n\n// after\n// ORCA_ADVERTISED_URL_BENCH_ROUNDS=6 node config/scripts/advertised-url-watcher-benchmark.mjs","handlingStrategy":"validation","validationCode":"function readEvenPositiveIntEnv(name, fallback) {\n  const raw = process.env[name]\n  const n = raw == null || raw === '' ? fallback : Number(raw)\n  if (!Number.isSafeInteger(n) || n <= 0) throw new Error(`${name} must be a positive integer`)\n  if (n % 2 !== 0) throw new Error(`${name} must be even`)\n  return n\n}\n// const ROUNDS = readEvenPositiveIntEnv('ORCA_ADVERTISED_URL_BENCH_ROUNDS', 12)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document the parity requirement next to the env var in the benchmark header.","In CI, use an even default like 6 or 12; do not let operators pick '5' for a quick smoke run.","If odd rounds become necessary, also update the median() helper to handle odd-length sample arrays."],"tags":["benchmark","env-var","validation","parity","advertised-url"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}