{"record":{"id":"6c01722a58f416ff","repo":"stablyai/orca","slug":"a-different-rollout-already-occupies-the-real-home","errorCode":null,"errorMessage":"A different rollout already occupies the real-home target path.","messagePattern":"A different rollout already occupies the real-home target path\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/codex/codex-legacy-session-resume.ts","lineNumber":190,"sourceCode":"    failedHealAuditRecords: 0\n  }\n  await appendCodexSessionHealAuditRecord(\n    createCodexSessionBackfillAuditWriter(auditLogPath),\n    summary,\n    { action: 'targeted-resume', source: sourcePath, target: targetPath }\n  )\n}\n\nasync function assertMatchingExistingTarget(sourcePath: string, targetPath: string): Promise<void> {\n  const [sourceStat, targetStat] = await Promise.all([lstat(sourcePath), lstat(targetPath)])\n  if (\n    !targetStat.isFile() ||\n    targetStat.isSymbolicLink() ||\n    sourceStat.size !== targetStat.size ||\n    ((sourceStat.dev !== targetStat.dev || sourceStat.ino !== targetStat.ino) &&\n      (await fileDigest(sourcePath)) !== (await fileDigest(targetPath)))\n  ) {\n    throw new Error('A different rollout already occupies the real-home target path.')\n  }\n}\n\nasync function fileDigest(filePath: string): Promise<string> {\n  const hash = createHash('sha256')\n  for await (const chunk of createReadStream(filePath)) {\n    hash.update(chunk as Buffer)\n  }\n  return hash.digest('hex')\n}\n\nfunction isDatedRolloutRelativePath(relativePath: string): boolean {\n  if (!relativePath || relativePath.startsWith('..') || resolve(relativePath) === relativePath) {\n    return false\n  }\n  const parts = relativePath.split(sep)\n  return (\n    parts.length === 4 &&","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/codex/codex-legacy-session-resume.ts#L172-L208","documentation":"Thrown by assertMatchingExistingTarget when a link/copy hit EEXIST but the existing target file is not the same rollout as the source. The guard checks: target must be a regular file (not symlink), same size, and either same dev/ino (same hardlink) or identical sha256 digest. Any mismatch means a different rollout already occupies that path, so overwriting would corrupt resume provenance.","triggerScenarios":"A prior resume installed a different rollout at the same target path; two different rollouts hash to the same dated path after a clock/path collision; the existing file was truncated/modified; the target is a symlink or non-regular file.","commonSituations":"A rollout was overwritten by another tool; dedup collision in a shared home; partial previous write left a wrong-size file; user manually placed a different file at the target.","solutions":["Compare the existing target and source: ls -l and sha256sum both — if they genuinely differ, decide which rollout is canonical.","Remove or rename the stale target file, then retry resume.","If the target is a symlink, replace it with the correct regular file.","Audit who else writes into paths.systemSessionsRoot to prevent future collisions.","Do NOT blindly delete — confirm the existing file is not the wanted rollout first."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { lstat } from 'node:fs/promises'\nimport { createHash } from 'node:crypto'\nasync function targetMatchesSource(sourcePath: string, targetPath: string): Promise<boolean> {\n  const [s, t] = await Promise.all([lstat(sourcePath), lstat(targetPath)])\n  if (!t.isFile() || t.isSymbolicLink() || s.size !== t.size) return false\n  if (s.dev === t.dev && s.ino === t.ino) return true // same hardlink\n  // else compare sha256 digests\n  return (await digest(sourcePath)) === (await digest(targetPath))\n}","typeGuard":null,"tryCatchPattern":"try {\n  await prepareLegacySharedCodexSessionResume(args, options)\n} catch (error) {\n  if (error instanceof Error && error.message === 'A different rollout already occupies the real-home target path.') {\n    // prompt user to resolve the conflicting target; do not auto-overwrite\n  } else throw error\n}","preventionTips":["Don't let multiple writers place files at the same dated rollout path.","Before resume, check the target path is absent or matches the source digest.","Never auto-delete a conflicting target — confirm it's stale first.","Keep a single canonical sessions root to avoid collisions."],"tags":["codex","session-resume","legacy","filesystem","conflict","integrity"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}