From c1346248397985b200c35325322acddc880ce2c3 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Apr 2026 16:20:11 +0000 Subject: [PATCH] fix(repository): saturating_add for in-memory version bump create_task used a plain += on the in-memory version returned to the caller while FileSystemStorage uses saturating_add when serialising the frontmatter. The two would disagree at u64::MAX, and in debug builds the + operator would panic on overflow. Match the storage behaviour. --- crates/onyx-core/src/repository.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/onyx-core/src/repository.rs b/crates/onyx-core/src/repository.rs index 498a542..5c18b60 100644 --- a/crates/onyx-core/src/repository.rs +++ b/crates/onyx-core/src/repository.rs @@ -26,7 +26,10 @@ impl TaskRepository { // Task operations pub fn create_task(&mut self, list_id: Uuid, mut task: Task) -> Result { self.storage.write_task(list_id, &task)?; - task.version += 1; + // Mirror the saturating increment that FileSystemStorage applies to + // the on-disk frontmatter so the in-memory Task matches what was + // written and doesn't wrap at u64::MAX. + task.version = task.version.saturating_add(1); Ok(task) }