From d9a4c27e70c4370c6e2d1805c9ac422a9d8ebbcd Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 2 Nov 2026 21:58:34 +0100 Subject: [PATCH] huginn-sources: fix the slow-reserve stub's CRLF and the revert test's premise The failed-upsert revert test now expects chunks of two commits, since nothing is deleted before the new chunks land. Co-Authored-By: Claude Opus 5.5 --- crates/huginn-daemon/src/index/ollama.rs | 9 ++------- crates/huginn-daemon/src/sources/tests.rs | 11 ++++++----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/crates/huginn-daemon/src/index/ollama.rs b/crates/huginn-daemon/src/index/ollama.rs index 4e7eb2a..575ef70 100644 --- a/crates/huginn-daemon/src/index/ollama.rs +++ b/crates/huginn-daemon/src/index/ollama.rs @@ -170,9 +170,7 @@ mod tests { Ok(read) => buffer.extend_from_slice(&chunk[..read]), } let text = String::from_utf8_lossy(&buffer).into_owned(); - if let Some(end) = text.find(" - -") { + if let Some(end) = text.find("\r\n\r\n") { let length = text.lines().find_map(|line| line.to_ascii_lowercase().strip_prefix("content-length:").map(|v| v.trim().parse().unwrap())).unwrap_or(0); break (end + 4, length); } @@ -193,10 +191,7 @@ mod tests { std::thread::sleep(delay); r#"{"embeddings":[[1.0]]}"# }; - let _ = write!(stream, "HTTP/1.1 200 OK -content-length: {} - -{body}", body.len()); + let _ = write!(stream, "HTTP/1.1 200 OK\r\ncontent-length: {}\r\n\r\n{body}", body.len()); }); } }); diff --git a/crates/huginn-daemon/src/sources/tests.rs b/crates/huginn-daemon/src/sources/tests.rs index 523f009..7e62905 100644 --- a/crates/huginn-daemon/src/sources/tests.rs +++ b/crates/huginn-daemon/src/sources/tests.rs @@ -217,10 +217,10 @@ fn cursor_never_leads() { assert_eq!(rig.index.ids(), clean.index.ids()); } -/// A run that fails between a repo's deletes and its upserts leaves chunks of -/// no single commit. A head that then reverts the files to the old content -/// makes an empty diff from the old commit, which would keep the deleted -/// chunks deleted; the repo is ingested whole instead. +/// A run that fails part way through a repo's upserts leaves chunks of two +/// commits. A head that then reverts the files to the old content makes an +/// empty diff from the old commit, which would keep the half-written new chunks; +/// the repo is ingested whole instead and only the head's chunks remain. #[test] fn a_failed_run_then_a_revert_converges() { let remote = Remote::new(); @@ -242,7 +242,8 @@ fn a_failed_run_then_a_revert_converges() { } let (refreshed, _) = rig.run(&mut forge); assert_eq!(refreshed.unwrap().failed, ["Demo"]); - assert!(rig.index.held().len() < 40, "the failed run left a partial repo"); + let commits: BTreeSet = rig.index.held().into_iter().map(|(.., commit)| commit).collect(); + assert_eq!(commits.len(), 2, "the failed run left chunks of two commits"); rig.index.state.lock().unwrap().fail_upserts_after = None; let c = remote.commit(&original, &[]);