JuliusBrussee/caveman · critical

conflicting committed and pending integration journals for

Error message

conflicting committed and pending integration journals for ${agent}; refusing recovery

What it means

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.

Solutions

  1. Back up both journal files, then hand-review them and delete the pending journal only if the committed one reflects actual on-disk state.
  2. Restore the state directory from a backup taken before the interrupted install.
  3. Manually undo the install (revert config edits the agent made) and delete both journal files, then rerun the install.
  4. Reinstall the CLI so the journal schema matches, if the conflict came from a version change.

Example fix

// before
mv ~/.caveman/hermes.pending.json ~/.caveman/hermes.json  # blind overwrite
// after
diff <(cat hermes.pending.json) <(cat hermes.json)  # reconcile, then remove pending only
Defensive patterns

Strategy: try-catch

Validate before calling

const pending = existsSync(pendingPath) && readFileSync(pendingPath, "utf8");
const committed = existsSync(committedPath) && readFileSync(committedPath, "utf8");
if (pending && committed && pending !== committed) console.error("conflicting journals; reconcile manually before running caveman");

Type guard

const journalsConflict = (a: string | false, b: string | false) => Boolean(a && b && a !== b);

Try / catch

try { install(agent); } catch (e) { if (String(e.message).includes("conflicting committed and pending")) { backupJournals(agent); reconcileOrRestoreState(agent); } }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/5b9d943df5e1ece9. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/index.ts:8070

    const route = routeIn(operation.owned);
    if (!route) continue;
    const current = fileBytes(operation.file);
    // No file, or contents that are not what this operation would have written,
    // means the interrupted install never got as far as pinning this route.
    if (current && bytesHash(current) === operation.after_sha256) {
      return { file: operation.file, route, pending: true };
    }
  }
  return null;
}

function recoverPendingNativeInstallUnlocked(agent: NativeAgent): boolean {
  const pending = readPendingNativeJournal(agent);
  if (!pending) return false;
  const committed = readNativeJournal(agent);
  if (committed) {
    if (JSON.stringify(committed) !== JSON.stringify(pending)) {
      throw new Error(`conflicting committed and pending integration journals for ${agent}; refusing recovery`);
    }
    unlinkSync(nativePendingJournalPath(agent));
    return false;
  }
  const current = pending.operations.map((operation) => ({ file: operation.file, bytes: fileBytes(operation.file) }));
  const restored = pending.operations.map((operation) => {
    const before = nativeBackupBytes(operation);
    const now = fileBytes(operation.file);
    const isInstalled = Boolean(now && bytesHash(now) === operation.after_sha256);
    const isBefore = operation.before_exists
      ? Boolean(now && operation.before_sha256 && bytesHash(now) === operation.before_sha256)
      : now === null;
    if (!isInstalled && !isBefore) {
      throw new Error(`${operation.file} changed during interrupted ${agent} install; refusing recovery`);
    }
    return { file: operation.file, bytes: before };
  });
  try {

View on GitHub (pinned to 3ee70a1026)