Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(wiki): retry a commit whose walk read a file that vanished mid-scan
AkitaOnRailsaf8ed952e77b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a8c29885..55d3e162 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Fixed+- Fixed a wiki checkpoint failing instead of retrying when a full walk listed a+ file that was gone by the time it was read (libgit2's `Os`-class "failed to+ read file into stream", e.g. an atomic writer's temp file renamed away+ mid-walk). It now takes the same bounded racy-read retry as a file changed+ mid-write; unrelated I/O errors still fail fast. This was also the source of+ an intermittent `concurrent_commits_queue_instead_of_failing` CI failure.+## [2.5.1] - 2026-10-01### Fixeddiff --git a/crates/ai-memory-wiki/src/git.rs b/crates/ai-memory-wiki/src/git.rsindex fb1fbcaa..c7f30a4c 100644--- a/crates/ai-memory-wiki/src/git.rs+++ b/crates/ai-memory-wiki/src/git.rs@@ -79,9 +79,18 @@ const UNREPORTED_SAMPLE: usize = 5;const RACY_READ_ATTEMPTS: u32 = 4;const RACY_READ_BACKOFF: Duration = Duration::from_millis(25);-/// libgit2's "file changed before we could read it": a writer was mid-write.+/// A staging read that raced a writer outside the commit lock: libgit2's+/// "file changed before we could read it" (mid-write), or a file that was+/// listed by the walk but gone by the time libgit2 streamed it in (an `Os`+/// "failed to read file into stream" — e.g. an atomic writer's temp file+/// renamed away between the scan and the read). Both settle within+/// milliseconds; a rescan no longer sees a vanished file.fn is_racy_read(e: &git2::Error) -> bool {- e.class() == git2::ErrorClass::Filesystem && e.message().contains("changed before")+ match e.class() {+ git2::ErrorClass::Filesystem => e.message().contains("changed before"),+ git2::ErrorClass::Os => e.message().contains("failed to read file into stream"),+ _ => false,+ }}/// Writes that reached the tree without a report: a writer bypassed the wiki.@@ -1436,6 +1445,33 @@ mod tests {/// Two session ends at once used to collide on libgit2's index lock and/// one of them lost its snapshot; now they queue.+ /// The CI flake behind `concurrent_commits_queue_instead_of_failing`: a+ /// walk listed a file that was gone when libgit2 read it, and libgit2+ /// reports that as an `Os`-class "failed to read file into stream" — not+ /// the "changed before" the retry recognized — so the commit failed+ /// instead of retrying. Unrelated errors must still fail fast.+ #[test]+ fn a_file_vanishing_mid_walk_is_a_racy_read_but_other_errors_are_not() {+ let err =+ |class, message: &str| git2::Error::new(git2::ErrorCode::GenericError, class, message);+ assert!(is_racy_read(&err(+ git2::ErrorClass::Os,+ "failed to read file into stream: "+ )));+ assert!(is_racy_read(&err(+ git2::ErrorClass::Filesystem,+ "file changed before we could read it"+ )));+ assert!(!is_racy_read(&err(+ git2::ErrorClass::Os,+ "failed to open file"+ )));+ assert!(!is_racy_read(&err(+ git2::ErrorClass::Index,+ "failed to read file into stream: "+ )));+ }+#[test]fn concurrent_commits_queue_instead_of_failing() {let tmp = tempdir();