JuliusBrussee/caveman · error

changed during interrupted install; refusing recovery

Error message

${operation.file} changed during interrupted ${agent} install; refusing recovery

What it means

To roll back an interrupted install, each journaled operation's target file is hashed and compared against the journal's `after_sha256` (install applied) or `before_sha256`/absence (install not yet applied). If the file matches neither state, something modified it outside the journaled install, and replaying the rollback would destroy those changes, so recovery refuses.

Solutions

  1. Revert the file to either its pre-install content or the install's written content (check backups/editor history), then rerun recovery.
  2. If the new content is wanted, delete the pending journal and manually apply or skip the corresponding change, then rerun the install.
  3. Restore the file from version control or a backup so its hash matches the journaled before/after state.
  4. Compare the file against `after_sha256`/`before_sha256` in the pending journal to see which state it should be in.

Example fix

# before
nano ~/.aider/config.yml  # edits during pending recovery
# after
git checkout -- ~/.aider/config.yml && caveman doctor aider --fix
Defensive patterns

Strategy: try-catch

Validate before calling

import { createHash } from "node:crypto";
const sha = (b: Buffer | null) => b ? createHash("sha256").update(b).digest("hex") : null;
for (const op of pendingOps) {
  const h = sha(fileBytes(op.file));
  if (h !== op.after_sha256 && h !== op.before_sha256) console.error("file drifted from journal:", op.file);
}

Type guard

const matchesJournalState = (h: string | null, op: { after_sha256: string; before_sha256?: string }) => h === op.after_sha256 || (op.before_sha256 != null && h === op.before_sha256);

Try / catch

try { install(agent); } catch (e) { if (String(e.message).includes("changed during interrupted")) { restoreFileFromBackup(op.file) ?? discardPendingJournal(agent); } }

Prevention

When it happens

Trigger: Recovery runs while a journaled operation's file was edited after the interrupted install — e.g. the user changed the agent config, another tool rewrote it, or the install itself wrote an unexpected byte sequence.

Common situations: User manually edits their agent config between the crash and the retry; a config sync tool overwrites files; the agent app rewrites its own config on startup before caveman recovery runs.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


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

Appendix: source

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

  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 {
    for (const item of restored) writeNativeRestoration(item.file, item.bytes);
    unlinkSync(nativePendingJournalPath(agent));
  } catch (error) {
    for (const item of current) {
      try { writeNativeRestoration(item.file, item.bytes); } catch { /* original error remains authority */ }
    }
    throw error;
  }
  process.stderr.write(`${mark("warn")} recovered interrupted ${agent} integration change before continuing\n`);
  return true;
}

function nativeMutationsFor(agent: NativeAgent, gw: string, mcpBinary: string | undefined): NativeMutation[] {
  return agent === "claude"

View on GitHub (pinned to 3ee70a1026)