From 749c6b9bbea2c52528e8fa5fa82be8cff4ad9f1c Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 30 Sep 2026 16:48:12 +0200 Subject: [PATCH] Odin test: with nothing to write, the next change is written on the next pass Pins the rule that only an attempted write starts the flush interval: a due write with nothing to write leaves the next change to land on the first pass after it. Kills the mutant that starts the interval on every due pass. Soul finding 5. Co-Authored-By: Claude Opus 5.5 --- crates/odin-daemon/src/main.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/odin-daemon/src/main.rs b/crates/odin-daemon/src/main.rs index dd9f019..5b54c42 100644 --- a/crates/odin-daemon/src/main.rs +++ b/crates/odin-daemon/src/main.rs @@ -3210,6 +3210,26 @@ mod tests { Ok(()) } + /// A due write with nothing to write does not start the interval: the next + /// change is written on the first pass after it. + #[test] + fn with_nothing_to_write_the_next_change_is_written_on_the_next_pass() -> Result<()> { + let mut odin = activated_odin()?; + odin.pass()?; + let written = file_identity(&odin.store)?; + odin.timers.last_projection_refresh = Some(Instant::now()); + odin.timers.last_heartbeat = Some(Instant::now()); + odin.timers.last_flush = ago(1_100); + odin.pass()?; + assert_eq!(file_identity(&odin.store)?, written, "nothing to write"); + + odin.heartbeat()?; + odin.pass()?; + assert_ne!(file_identity(&odin.store)?, written, "the change is written at once"); + assert_eq!(odin.file_records()?, odin.working_set()); + Ok(()) + } + /// The lease is checked at the write itself: lost between a change and /// its write, the write is not made and Odin ends. #[test]