{"record":{"id":"84b00ed2356d9f79","repo":"stablyai/orca","slug":"fixture-mib-and-trials-must-be-positive-integers","errorCode":null,"errorMessage":"fixture-mib and trials must be positive integers","messagePattern":"fixture-mib and trials must be positive integers","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/legacy-worker-recovery-persistence-benchmark.mjs","lineNumber":20,"sourceCode":"// Run: node config/scripts/legacy-worker-recovery-persistence-benchmark.mjs\nimport { closeSync, fsyncSync, openSync, renameSync, rmSync, writeFileSync } from 'node:fs'\nimport { mkdtemp, open, readFile, rename } from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { performance } from 'node:perf_hooks'\nimport { fileURLToPath } from 'node:url'\n\nconst repoRoot = fileURLToPath(new URL('../..', import.meta.url))\nconst runtimePath = join(repoRoot, 'src/main/runtime/orca-runtime.ts')\nconst args = new Map(\n  process.argv.slice(2).map((value, index, values) => [value, values[index + 1]])\n)\nconst fixtureMiB = Number(args.get('--fixture-mib') ?? 24)\nconst trials = Number(args.get('--trials') ?? 3)\nconst jsonOutput = process.argv.includes('--json')\n\nif (!Number.isInteger(fixtureMiB) || fixtureMiB < 1 || !Number.isInteger(trials) || trials < 1) {\n  throw new Error('fixture-mib and trials must be positive integers')\n}\n\nconst runtimeSource = await readFile(runtimePath, 'utf8')\nconst recoveryStart = runtimeSource.indexOf(\n  'private async persistLegacyWorkerTerminalRecoveryBatch'\n)\nconst recoveryEnd = runtimeSource.indexOf(\n  'private reconcileMissingLegacyWorkerTerminal',\n  recoveryStart\n)\nconst recoverySource = runtimeSource.slice(recoveryStart, recoveryEnd)\nif (\n  recoveryStart === -1 ||\n  recoveryEnd === -1 ||\n  !recoverySource.includes('await this.flushWorkspaceSessionOrThrowAsync()') ||\n  recoverySource.includes('flushOrThrow()')\n) {\n  throw new Error('recovery persistence implementation changed; update this benchmark')","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/legacy-worker-recovery-persistence-benchmark.mjs#L2-L38","documentation":"The legacy-worker-recovery-persistence benchmark reads --fixture-mib (default 24) and --trials (default 3) from argv and validates both are positive integers before allocating fixtures and running trials. Non-positive or non-integer values would produce a zero-byte filler, fractional trial counts, or NaN sizes that break the comparison.","triggerScenarios":"Passing --fixture-mib or --trials as 0, a negative, a decimal, or a non-numeric string; passing the flag without a following value so the map resolves it to undefined → NaN.","commonSituations":"A trailing flag with no value; a decimal MiB; a typo like '--trials 3.'.","solutions":["Pass positive integers for both flags, or omit them to use defaults (24 MiB, 3 trials).","Ensure each flag is immediately followed by its numeric value.","Avoid decimals and units (the value is already in MiB)."],"exampleFix":"# before\nnode config/scripts/legacy-worker-recovery-persistence-benchmark.mjs --fixture-mib\n\n# after\nnode config/scripts/legacy-worker-recovery-persistence-benchmark.mjs --fixture-mib 24 --trials 3","handlingStrategy":"validation","validationCode":"function parsePositiveIntArg(map, flag, fallback) {\n  const raw = map.get(flag)\n  if (raw === undefined) return fallback\n  const n = Number(raw)\n  if (!Number.isInteger(n) || n < 1) throw new Error(`${flag} must be a positive integer`)\n  return n\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always follow --fixture-mib and --trials with their numeric value.","Omit the flags to use the documented defaults (24 MiB, 3 trials)."],"tags":["validation","benchmark"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}