0.0.3-alpha.3

This commit is contained in:
2026-09-29 11:39:02 +02:00
parent 88a63b06cc
commit c3a825657d
14 changed files with 1209 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/knowledge-git-lib/src/error.rs
// version: 3
// version: 4
//! Recoverable errors for controlled Git process execution.
@@ -18,6 +18,18 @@ pub enum GitOperation {
CreateSnapshot,
/// Validate an existing detached snapshot before reuse.
InspectSnapshot,
/// Create one isolated detached worktree for candidate construction.
CreateWriteWorktree,
/// Stage the requested candidate mutations.
StageCandidate,
/// Inspect the candidate index, commit or parent relationship.
InspectCandidate,
/// Create the candidate commit with explicit identity.
CommitCandidate,
/// Retain the detached candidate commit under an internal backend reference.
PreserveCandidate,
/// Remove one backend-owned candidate worktree.
RemoveWriteWorktree,
}
impl std::fmt::Display for crate::GitOperation {
@@ -29,6 +41,12 @@ impl std::fmt::Display for crate::GitOperation {
crate::GitOperation::ResolveRevision => return formatter.write_str("resolve revision"),
crate::GitOperation::CreateSnapshot => return formatter.write_str("create snapshot"),
crate::GitOperation::InspectSnapshot => return formatter.write_str("inspect snapshot"),
crate::GitOperation::CreateWriteWorktree => return formatter.write_str("create write worktree"),
crate::GitOperation::StageCandidate => return formatter.write_str("stage candidate"),
crate::GitOperation::InspectCandidate => return formatter.write_str("inspect candidate"),
crate::GitOperation::CommitCandidate => return formatter.write_str("commit candidate"),
crate::GitOperation::PreserveCandidate => return formatter.write_str("preserve candidate"),
crate::GitOperation::RemoveWriteWorktree => return formatter.write_str("remove write worktree"),
}
}
}
@@ -71,6 +89,20 @@ pub enum GitBackendError {
InvalidRevision,
/// An existing snapshot does not match the requested revision or is not clean.
InvalidSnapshot,
/// The deterministic backend-owned write worktree path already exists unexpectedly.
WriteWorktreeExists,
/// A mutation would traverse or replace a symbolic link.
UnsafeMutationTarget,
/// A requested deletion target does not exist.
MutationTargetMissing,
/// A filesystem mutation or parent-directory preparation failed.
MutationFilesystemFailed,
/// The staged candidate paths do not exactly match the requested mutation set.
CandidateMutationMismatch,
/// The resulting candidate commit does not have the requested base as its sole first parent.
InvalidCandidate,
/// A backend-owned write worktree could not be removed deterministically.
WriteCleanupFailed,
/// Git returned output that does not satisfy the backend contract.
UnexpectedGitOutput {
/// Operation whose output could not be validated.
@@ -95,6 +127,13 @@ impl std::fmt::Display for crate::GitBackendError {
crate::GitBackendError::MirrorMissing => return formatter.write_str("controlled git mirror does not exist"),
crate::GitBackendError::InvalidRevision => return formatter.write_str("git revision is not a safe object identity"),
crate::GitBackendError::InvalidSnapshot => return formatter.write_str("controlled git snapshot is invalid or dirty"),
crate::GitBackendError::WriteWorktreeExists => return formatter.write_str("controlled git write worktree already exists"),
crate::GitBackendError::UnsafeMutationTarget => return formatter.write_str("git mutation target traverses a symbolic link"),
crate::GitBackendError::MutationTargetMissing => return formatter.write_str("git deletion target does not exist"),
crate::GitBackendError::MutationFilesystemFailed => return formatter.write_str("git candidate filesystem mutation failed"),
crate::GitBackendError::CandidateMutationMismatch => return formatter.write_str("git candidate staged paths do not match requested mutations"),
crate::GitBackendError::InvalidCandidate => return formatter.write_str("git candidate commit does not match the requested base"),
crate::GitBackendError::WriteCleanupFailed => return formatter.write_str("controlled git write worktree cleanup failed"),
crate::GitBackendError::UnexpectedGitOutput { operation } => {
return write!(formatter, "git returned unexpected output while attempting to {operation}");
},