{"record":{"id":"110488c3b704a1ef","repo":"stablyai/orca","slug":"name-must-be-a-positive-integer-received-val-110488","errorCode":null,"errorMessage":"${name} must be a positive integer, received ${value}","messagePattern":"(.+?) must be a positive integer, received (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/hydrate-worktree-lookup-benchmark.mjs","lineNumber":26,"sourceCode":"// This runs on the renderer's synchronous cold-start path and gates workspaceSessionReady,\n// which blocks terminal pane mounting, so the cost is paid before the first frame.\n//\n// Both arms produce the resolved rows and are compared for equality before timing, so an\n// index that resolved differently could not be reported as a win.\n//\n// Run with:  node config/scripts/hydrate-worktree-lookup-benchmark.mjs\nimport { performance } from 'node:perf_hooks'\n\nconst ITERATIONS = Number(process.env.ORCA_HYDRATE_BENCH_ITERATIONS ?? '60')\nconst WARMUP = Number(process.env.ORCA_HYDRATE_BENCH_WARMUP ?? '10')\nconst ROUNDS = 6\n\nfor (const [name, value] of [\n  ['ORCA_HYDRATE_BENCH_ITERATIONS', ITERATIONS],\n  ['ORCA_HYDRATE_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}\n\n// Pre-fix: re-flatten and linear-search per id.\nfunction resolveByFlatten(worktreesByRepo, ids) {\n  const resolved = []\n  for (const id of ids) {\n    const worktree = Object.values(worktreesByRepo)\n      .flat()\n      .find((entry) => entry.id === id)\n    resolved.push(worktree ? worktree.repoId : null)\n  }\n  return resolved\n}\n\n// Post-fix: mirrors buildWorktreeByIdIndex in store/slices/worktree-by-id-index.ts.\nfunction resolveByIndex(worktreesByRepo, ids) {\n  const index = new Map()","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/hydrate-worktree-lookup-benchmark.mjs#L8-L44","documentation":"The session-hydration worktree-lookup benchmark reads ORCA_HYDRATE_BENCH_ITERATIONS (default 60) and ORCA_HYDRATE_BENCH_WARMUP (default 10) from the environment and validates both are positive safe integers before timing. Number.isSafeInteger rejects NaN, floats, Infinity, and values beyond 2^53; the <= 0 check rejects zero and negatives. Bad values would otherwise produce silent garbage timings or divide-by-zero in the per-iteration math.","triggerScenarios":"Setting ORCA_HYDRATE_BENCH_ITERATIONS or ORCA_HYDRATE_BENCH_WARMUP to '0', a negative number, a decimal like '1.5', a non-numeric string, or a value exceeding Number.MAX_SAFE_INTEGER.","commonSituations":"Typo in the env var name (leaving it unset is fine and uses defaults); passing a decimal or a trailing-space value in CI matrix config; copy-pasting '60,' with a trailing comma that maps to NaN.","solutions":["Unset both env vars to fall back to the documented defaults (60 iterations, 10 warmup).","Set each to a plain positive integer string with no decimals, signs, or commas.","If you need larger runs, keep the value under Number.MAX_SAFE_INTEGER."],"exampleFix":"# before\nexport ORCA_HYDRATE_BENCH_ITERATIONS='1.5'\n\n# after\nunset ORCA_HYDRATE_BENCH_ITERATIONS ORCA_HYDRATE_BENCH_WARMUP","handlingStrategy":"validation","validationCode":"function parsePositiveIntEnv(name, fallback) {\n  const raw = process.env[name]\n  if (!raw) return fallback\n  const n = Number(raw)\n  if (!Number.isSafeInteger(n) || n <= 0) {\n    throw new Error(`${name} must be a positive integer, received ${raw}`)\n  }\n  return n\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Leave ORCA_HYDRATE_BENCH_* unset in CI unless you need a non-default size.","Never include decimals, signs, or trailing commas in these env vars."],"tags":["validation","benchmark","environment"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}