{"record":{"id":"fe285da33eda9809","repo":"JuliusBrussee/caveman","slug":"agent-servername-mcp-transaction-journal-alr","errorCode":null,"errorMessage":"${agent} ${serverName} MCP transaction journal already exists; refusing overwrite","messagePattern":"(.+?) (.+?) MCP transaction journal already exists; refusing overwrite","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":12546,"sourceCode":"    server_name: serverName,\n    action,\n    config_path: plan.path,\n    marker_path: markerPath,\n    config_before_base64: plan.before?.toString(\"base64\") ?? null,\n    config_before_mode: plan.beforeMode,\n    config_before_sha256: optionalBytesHash(plan.before),\n    config_after_sha256: optionalBytesHash(plan.after),\n    marker_before_base64: markerBefore?.toString(\"base64\") ?? null,\n    marker_before_mode: markerBeforeMode,\n    marker_before_sha256: optionalBytesHash(markerBefore),\n    marker_after_base64: markerAfter?.toString(\"base64\") ?? null,\n    marker_after_sha256: optionalBytesHash(markerAfter),\n  };\n  const locatorPath = `${markerPath}.pending`;\n  const configPendingPath = mcpConfigPendingJournalPath(plan.path);\n  const pendingBytes = Buffer.from(JSON.stringify(journal, null, 2) + \"\\n\");\n  if (fileBytes(locatorPath) !== null || fileBytes(configPendingPath) !== null) {\n    throw new Error(`${agent} ${serverName} MCP transaction journal already exists; refusing overwrite`);\n  }\n  durableCreateFile(locatorPath, pendingBytes);\n  try {\n    durableCreateFile(configPendingPath, pendingBytes);\n  } catch (error) {\n    durableUnlink(locatorPath);\n    throw error;\n  }\n\n  try {\n    if (action === \"install\") {\n      if (plan.changed) durableReplaceFileIfUnchanged(plan.path, plan.before, plan.after, plan.beforeMode);\n      if (!optionalBytesEqual(markerBefore, markerAfter)) durableReplaceFileIfUnchanged(markerPath, markerBefore, markerAfter);\n    } else {\n      if (!optionalBytesEqual(markerBefore, markerAfter)) durableReplaceFileIfUnchanged(markerPath, markerBefore, markerAfter);\n      if (plan.changed) durableReplaceFileIfUnchanged(plan.path, plan.before, plan.after, plan.beforeMode);\n    }\n    if (optionalBytesHash(fileBytes(plan.path)) !== journal.config_after_sha256","sourceCodeStart":12528,"sourceCodeEnd":12564,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/5184b3d11ac6a1acb7d44b9bfaa31698157cff97/packages/cli/src/index.ts#L12528-L12564","documentation":"Transaction-invariant guard when creating the durable journal for an MCP install/uninstall: a journal file for this agent/server/action already exists on disk. A leftover journal means a previous transaction is unfinished or crashed, and overwriting it would orphan that recovery state, so the new transaction refuses to start.","triggerScenarios":"Thrown at packages/cli/src/index.ts:12546 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-run the command so the existing interrupted transaction is recovered or rolled back first","If recovery is impossible, manually delete the stale journal under cavemanHome()/mcp after reconciling the config and marker, then retry","Ensure only one Caveman MCP transaction per agent/server runs at a time"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5184b3d11ac6a1acb7d44b9bfaa31698157cff97","analyzedAt":"2026-09-06T12:00:26.372Z","contentChangedAt":"2026-09-06T12:00:26.372Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}