{"record":{"id":"96d089719ace29cd","repo":"jdx/mise","slug":"write-completion-was-not-recorded-inspect-the-liv","errorCode":null,"errorMessage":"write completion was not recorded; inspect the live file before retrying recovery","messagePattern":"write completion was not recorded; inspect the live file before retrying recovery","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/recovery.rs","lineNumber":83,"sourceCode":"    state_dir: &Path,\n    path: &Path,\n    prior: &PathSnapshot,\n    after: Option<&PathState>,\n) -> Result<()> {\n    validate_destination(path)?;\n    let comparison = tempfile::tempdir()?;\n    let depth = if matches!(prior, PathSnapshot::Directory { .. }) {\n        Capture::Shallow\n    } else {\n        Capture::Full\n    };\n    // Comparing must not leave copies of concurrent user edits in the store.\n    let current = PathSnapshot::capture_with(comparison.path(), path, depth);\n    if !matches!(prior, PathSnapshot::Unrecorded { .. }) && &current == prior {\n        return Ok(());\n    }\n    let Some(after) = after else {\n        bail!(\"write completion was not recorded; inspect the live file before retrying recovery\");\n    };\n    if PathState::observe(path) != *after {\n        bail!(\"changed after the operation; left untouched\");\n    }\n    // Entry count alone cannot establish a directory's identity. Never\n    // replace a populated directory on that evidence.\n    if matches!(after, PathState::Dir { entries, .. } if *entries != 0)\n        && !(matches!(prior, PathSnapshot::Directory { .. })\n            && matches!(\n                after,\n                PathState::Dir {\n                    identity: Some(_),\n                    ..\n                }\n            ))\n    {\n        bail!(\"directory contents cannot be verified safely; left untouched\");\n    }","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/recovery.rs#L65-L101","documentation":"recover_path compares the live path against the recorded prior snapshot; if they match, recovery is a no-op. If they differ, the operation's post-write snapshot (`after`) must exist to know what the file should look like — when no completion was recorded, mise refuses to guess and bails, telling the user to inspect the live file before retrying, since replaying the write could destroy concurrent edits.","triggerScenarios":"recover_path encounters a path whose current content differs from the prior snapshot, and the journal entry has `after == None` — i.e. the original write never recorded its completion snapshot (interrupted before the write finished or before the snapshot was captured).","commonSituations":"A crash occurred between starting the write and recording the after-snapshot; the journal entry is truncated/partial; the user interrupted mise with SIGKILL during a dotfile write and the resulting file state cannot be proven.","solutions":["Manually inspect the live file at the reported path and decide whether its content is correct.","If the live content is correct, accept it with `mise dot recover <operation> --keep-current`.","If the live content is wrong, fix or restore it manually, then retry `mise dot recover`.","If the journal entry is hopelessly incomplete, remove/discard the operation record after verifying the file."],"exampleFix":"// before: blind retry fails\n$ mise dot recover   # error: write completion was not recorded\n// after\n$ cat ~/.bashrc            # inspect live file\n$ mise dot recover <op> --keep-current   # if content is acceptable","handlingStrategy":"validation","validationCode":"export function checkCompletionRecorded(entry: RecoveryEntry): boolean {\n  if (entry.after == null) {\n    throw new Error('journal entry has no post-write snapshot; inspect the live file manually');\n  }\n  return true;\n}","typeGuard":"function hasAfterSnapshot(e: { after?: PathState }): e is { after: PathState } {\n  return e.after != null;\n}","tryCatchPattern":"try {\n  await dotRecover(op);\n} catch (e) {\n  if (/write completion was not recorded/.test(String(e))) {\n    inspectLiveFile(path); // decide manually\n    await dotRecover(op, { keepCurrent: isContentAcceptable() });\n  } else throw e;\n}","preventionTips":["Do not SIGKILL mise mid-write; let operations complete","After a crash, inspect affected files before running recover","Use --keep-current once you have verified live content is correct"],"tags":["recovery","dotfiles","snapshot","crash-consistency"],"backgroundTag":"invalid-state-transition","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}