{"record":{"id":"5b9d943df5e1ece9","repo":"JuliusBrussee/caveman","slug":"conflicting-committed-and-pending-integration-jour","errorCode":null,"errorMessage":"conflicting committed and pending integration journals for ${agent}; refusing recovery","messagePattern":"conflicting committed and pending integration journals for (.+?); refusing recovery","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"packages/cli/src/index.ts","lineNumber":8070,"sourceCode":"    const route = routeIn(operation.owned);\n    if (!route) continue;\n    const current = fileBytes(operation.file);\n    // No file, or contents that are not what this operation would have written,\n    // means the interrupted install never got as far as pinning this route.\n    if (current && bytesHash(current) === operation.after_sha256) {\n      return { file: operation.file, route, pending: true };\n    }\n  }\n  return null;\n}\n\nfunction recoverPendingNativeInstallUnlocked(agent: NativeAgent): boolean {\n  const pending = readPendingNativeJournal(agent);\n  if (!pending) return false;\n  const committed = readNativeJournal(agent);\n  if (committed) {\n    if (JSON.stringify(committed) !== JSON.stringify(pending)) {\n      throw new Error(`conflicting committed and pending integration journals for ${agent}; refusing recovery`);\n    }\n    unlinkSync(nativePendingJournalPath(agent));\n    return false;\n  }\n  const current = pending.operations.map((operation) => ({ file: operation.file, bytes: fileBytes(operation.file) }));\n  const restored = pending.operations.map((operation) => {\n    const before = nativeBackupBytes(operation);\n    const now = fileBytes(operation.file);\n    const isInstalled = Boolean(now && bytesHash(now) === operation.after_sha256);\n    const isBefore = operation.before_exists\n      ? Boolean(now && operation.before_sha256 && bytesHash(now) === operation.before_sha256)\n      : now === null;\n    if (!isInstalled && !isBefore) {\n      throw new Error(`${operation.file} changed during interrupted ${agent} install; refusing recovery`);\n    }\n    return { file: operation.file, bytes: before };\n  });\n  try {","sourceCodeStart":8052,"sourceCodeEnd":8088,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L8052-L8088","documentation":"During recovery of an interrupted native install, the tool reads the pending journal and the committed journal. If both exist but their contents differ, the on-disk state is ambiguous — replaying either journal could corrupt files — so recovery is refused outright. Identical journals are safe: the pending copy is just deleted.","triggerScenarios":"Running a native integration command when `nativePendingJournalPath(agent)` and the committed journal both exist with different JSON payloads, typically after a crash between journal commit and pending-journal cleanup.","commonSituations":"A crash or SIGKILL mid-install; manual copying/tampering with journal files; running an old CLI version's journals through a newer version that changed the journal schema; disk issues leaving a partially written pending journal.","solutions":["Back up both journal files, then hand-review them and delete the pending journal only if the committed one reflects actual on-disk state.","Restore the state directory from a backup taken before the interrupted install.","Manually undo the install (revert config edits the agent made) and delete both journal files, then rerun the install.","Reinstall the CLI so the journal schema matches, if the conflict came from a version change."],"exampleFix":"// before\nmv ~/.caveman/hermes.pending.json ~/.caveman/hermes.json  # blind overwrite\n// after\ndiff <(cat hermes.pending.json) <(cat hermes.json)  # reconcile, then remove pending only","handlingStrategy":"try-catch","validationCode":"const pending = existsSync(pendingPath) && readFileSync(pendingPath, \"utf8\");\nconst committed = existsSync(committedPath) && readFileSync(committedPath, \"utf8\");\nif (pending && committed && pending !== committed) console.error(\"conflicting journals; reconcile manually before running caveman\");","typeGuard":"const journalsConflict = (a: string | false, b: string | false) => Boolean(a && b && a !== b);","tryCatchPattern":"try { install(agent); } catch (e) { if (String(e.message).includes(\"conflicting committed and pending\")) { backupJournals(agent); reconcileOrRestoreState(agent); } }","preventionTips":["Never SIGKILL caveman mid-install; let journaling complete.","Do not copy, edit, or migrate journal files between CLI versions or machines.","Back up the state directory before interrupted-looking installs.","If both journals exist, diff them before any manual intervention."],"tags":["journal","recovery","integrity"],"backgroundTag":"internal-invariant-violation","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}