From e7c6633f06b073e00f921f4dd17166b94fef5354 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 17 Oct 2026 07:22:58 -0500 Subject: [PATCH 1/2] fix(id): refuse a complete journal line this binary cannot read --- pkgs/id/src/world_store.rs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/pkgs/id/src/world_store.rs b/pkgs/id/src/world_store.rs index 5f7ad89425..939f08d508 100644 --- a/pkgs/id/src/world_store.rs +++ b/pkgs/id/src/world_store.rs @@ -84,11 +84,15 @@ impl FileJournal { good_len += read as u64; } parsed => { - // Only an unterminated or unparsable *last* line is a - // torn append; anything after it means corruption. + // An unterminated last line is a torn append: the crash + // came before the entry was acknowledged. A newline- + // terminated line that does not parse was fully written, + // so it is corruption or an entry from a newer binary, + // and it must never be dropped silently, even as the + // last line. let mut rest = Vec::new(); reader.read_to_end(&mut rest)?; - if !rest.is_empty() { + if complete || !rest.is_empty() { bail!( "world journal {} is corrupt at byte {good_len}: {}", path.display(), @@ -879,6 +883,26 @@ mod tests { assert!(err.to_string().contains("corrupt"), "{err:#}"); } + #[test] + fn a_terminated_entry_this_binary_cannot_read_is_refused_not_dropped() { + let dir = TempDir::new().unwrap(); + let path = dir.path().join("journal.jsonl"); + drop(FileJournal::open(&path, "w").unwrap()); + let good = std::fs::read(&path).unwrap(); + + // An entry from a newer binary, fully written, as the final line. + let mut newer = good.clone(); + newer.extend_from_slice(b"{\"entry\":\"future_variant\",\"x\":1}\n"); + std::fs::write(&path, &newer).unwrap(); + let err = FileJournal::open(&path, "w").unwrap_err(); + assert!(err.to_string().contains("corrupt"), "{err:#}"); + assert_eq!( + std::fs::read(&path).unwrap(), + newer, + "the unreadable entry is left in place, not truncated" + ); + } + #[tokio::test] async fn a_journal_for_another_world_is_refused() { let dir = TempDir::new().unwrap(); From 7159357723571299faef3d54ea0f6e0f882afb5d Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 17 Oct 2026 07:24:51 -0500 Subject: [PATCH 2/2] fix(id): keep running Nix checks after one fails --- .github/workflows/id-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/id-check.yml b/.github/workflows/id-check.yml index 64b74843cd..40b90da14d 100644 --- a/.github/workflows/id-check.yml +++ b/.github/workflows/id-check.yml @@ -51,4 +51,4 @@ jobs: sudo udevadm trigger --name-match=kvm - name: Run nix flake check - run: nix flake check ./pkgs/id/ -L + run: nix flake check ./pkgs/id/ -L --keep-going