{"record":{"id":"60c88dd2c4fe3a30","repo":"stablyai/orca","slug":"no-benchmark-file-exists-at-both-head-and-head-1-i","errorCode":null,"errorMessage":"no benchmark file exists at both HEAD and HEAD~1 in this checkout","messagePattern":"no benchmark file exists at both HEAD and HEAD~1 in this checkout","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"config/scripts/git-diff-blob-concurrency-benchmark.mjs","lineNumber":104,"sourceCode":"// cost and the size-dependent read cost are both represented.\nconst CANDIDATES = [\n  'src/main/git/status.ts',\n  'src/shared/agent-hook-listener.ts',\n  'src/renderer/src/components/TaskPage.tsx'\n]\n\nconst files = []\nfor (const filePath of CANDIDATES) {\n  try {\n    await git(['cat-file', '-e', `${parent}:${filePath}`])\n    await git(['cat-file', '-e', `${head}:${filePath}`])\n    files.push(filePath)\n  } catch {\n    // Skip a path that does not exist on both sides in this checkout.\n  }\n}\nif (files.length === 0) {\n  throw new Error('no benchmark file exists at both HEAD and HEAD~1 in this checkout')\n}\n\nconst pad = (value, width) => String(value).padStart(width)\nconsole.log('One file diff = two git blob reads. Lower is better.')\nconsole.log(\n  `iterations=${ITERATIONS} warmup=${WARMUP} (interleaved, medians) head=${head.slice(0, 9)}`\n)\nconsole.log(\n  `${pad('file', 26)} ${pad('sequential', 12)} ${pad('concurrent', 12)} ${pad('speedup', 9)} ${pad('saved', 10)}`\n)\nfor (const filePath of files) {\n  const sequentialBytes = await readSequential(parent, head, filePath)\n  const concurrentBytes = await readConcurrent(parent, head, filePath)\n  if (sequentialBytes !== concurrentBytes) {\n    throw new Error(`byte mismatch for ${filePath}`)\n  }\n  const { sequential, concurrent } = await measureInterleaved(parent, head, filePath)\n  console.log(","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/git-diff-blob-concurrency-benchmark.mjs#L86-L122","documentation":"Thrown by the git-diff-blob-concurrency benchmark when none of its hard-coded CANDIDATE file paths exist as blobs at both HEAD and HEAD~1. The benchmark measures per-diff latency by reading two git blobs (parent and child sides), so it needs at least one file present on both commits to have anything to time. Each candidate is probed with `git cat-file -e <ref>:<path>` on both sides; a missing side is silently skipped.","triggerScenarios":"Running the benchmark in a shallow clone (no HEAD~1), a fresh repo with under two commits, an empty tree, or on a branch where all three candidates (`src/main/git/status.ts`, `src/shared/agent-hook-listener.ts`, `src/renderer/src/components/TaskPage.tsx`) were added/renamed/deleted between HEAD and HEAD~1. Also fires on a detached HEAD pointing at the initial commit.","commonSituations":"CI runs against a shallow-cloned checkout (--depth 1), local testing on a brand-new worktree before history is fetched, running after a large refactor that moved or deleted the candidate source files, or running in a sparse/partial checkout.","solutions":["Ensure the checkout is non-shallow: run `git fetch --unshallow` (or `git fetch --deepen=2`) so HEAD~1 resolves.","Verify history exists: run `git rev-parse HEAD~1` — if it errors, the checkout lacks the parent commit.","Confirm at least one candidate exists on both sides: `git cat-file -e HEAD~1:src/main/git/status.ts && git cat-file -e HEAD:src/main/git/status.ts`.","Checkout a commit where the candidate files are stable across the parent boundary, or add a touched candidate file so the benchmark has a measurable pair."],"exampleFix":"// before: running in a shallow clone\ngit clone --depth 1 <repo> && node config/scripts/git-diff-blob-concurrency-benchmark.mjs\n// after: deepen so HEAD~1 exists\ngit fetch --unshallow && node config/scripts/git-diff-blob-concurrency-benchmark.mjs","handlingStrategy":"validation","validationCode":"// Verify HEAD~1 resolves and at least one candidate exists on both sides before running\nimport { execFileSync } from 'node:child_process'\nconst CANDIDATES = ['src/main/git/status.ts', 'src/shared/agent-hook-listener.ts', 'src/renderer/src/components/TaskPage.tsx']\ntry { execFileSync('git', ['rev-parse', '--verify', 'HEAD~1'], { stdio: 'ignore' }) }\ncatch { throw new Error('checkout is shallow or has no HEAD~1; run git fetch --unshallow') }\nconst head = execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' }).trim()\nconst ok = CANDIDATES.some((p) => {\n  try { execFileSync('git', ['cat-file', '-e', `HEAD~1:${p}`], { stdio: 'ignore' }); execFileSync('git', ['cat-file', '-e', `HEAD:${p}`], { stdio: 'ignore' }); return true }\n  catch { return false }\n})\nif (!ok) throw new Error('no candidate file on both HEAD and HEAD~1')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run benchmarks only on non-shallow checkouts with at least two commits of history.","In CI, run `git fetch --unshallow` or `--deepen=2` before benchmark jobs.","If the candidate files are refactored, update the CANDIDATES list in the same change."],"tags":["benchmark","git","checkout-state","validation"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}