agent-migrate-core 0.6.1

Core models and transactional filesystem engine for agent configuration migration
Documentation
use std::path::PathBuf;

use thiserror::Error;

use crate::transaction::{ConflictPolicy, SnapshotId};

#[derive(Debug, Error)]
pub enum TransactionError {
    #[error("target conflict at {path}")]
    Conflict { path: PathBuf },
    #[error("target is locked by another transaction")]
    LockBusy,
    #[error("unsupported conflict policy for this resource: {0:?}")]
    UnsupportedConflictPolicy(ConflictPolicy),
    #[error("cannot merge structured resource at {path}: {message}")]
    StructuredMerge { path: PathBuf, message: String },
    #[error("cannot find a free renamed resource path for {path}")]
    RenameExhausted { path: PathBuf },
    #[error("resolved transaction path is invalid: {message}")]
    InvalidResolvedPath { message: String },
    #[error("target path crosses a symbolic link: {path}")]
    Symlink { path: PathBuf },
    #[error("doctor failed after write: {message}")]
    DoctorFailed { message: String },
    #[error("doctor failed and automatic rollback also failed: {message}")]
    RollbackFailed { message: String },
    #[error("snapshot not found: {0}")]
    SnapshotNotFound(SnapshotId),
    #[error("snapshot manifest is invalid")]
    InvalidSnapshot(#[source] serde_json::Error),
    #[error("snapshot content hash mismatch at {path}")]
    SnapshotHashMismatch { path: PathBuf },
    #[error("filesystem error at {path}")]
    Io {
        path: PathBuf,
        #[source]
        source: std::io::Error,
    },
}