From 58ab6f0d99622fa0c4d32c19c613fd321d47c1e6 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Wed, 23 Sep 2026 22:10:29 +0200 Subject: [PATCH] Pin the working-registry divergence the retired-state checks never looked at --- document/peer-transport/tests/simulation.rs | 31 +++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/document/peer-transport/tests/simulation.rs b/document/peer-transport/tests/simulation.rs index 67d4bb957f..ee68fe6c00 100644 --- a/document/peer-transport/tests/simulation.rs +++ b/document/peer-transport/tests/simulation.rs @@ -494,11 +494,7 @@ fn dump_if_requested(seed: u64, peers: &[Peer]) { let retired = peer.session().retired_marks(); let mut through: Vec<_> = retired.retired_up_to.iter().map(|(peer, sequence)| (peer.0, sequence.0)).collect(); through.sort(); - let mut above: Vec<_> = retired - .retired_beyond - .iter() - .map(|(peer, runs)| (peer.0, runs.iter().map(|(a, b)| (a.0, b.0)).collect::>())) - .collect(); + let mut above: Vec<_> = retired.retired_beyond.iter().map(|(peer, runs)| (peer.0, runs.len())).collect(); above.sort(); format!("{through:?} above {above:?}") } @@ -800,3 +796,28 @@ fn a_witness_closes_an_authors_run_before_a_gap_forms() { assert!(retired.retired_beyond.is_empty(), "a contiguous run retires wholly into the prefix"); assert_converged(0, &peers); } + +/// The working registry is what the editor renders, and at quiescence it should be each peer's snapshot +/// plus an empty hot tail, so all peers should agree on it by value. They do not: at seed 14 the host's +/// own working registry is behind its own snapshot (`key1` at 18 where the snapshot has 92) with an empty +/// hot log, so an op reached retired state without reaching the live view. +/// +/// Ignored because it fails, and it predates the retirement work: it reproduces with the hot-log +/// preservation reverted. Comparison is by value, since retirement re-stamps the snapshot while the +/// working registry keeps staging-time stamps. +#[test] +#[ignore = "known failure, seed 14: the host's working registry drifts from its own snapshot"] +fn working_registries_converge() { + for seed in 0..1000 { + let (_, peers) = simulate(seed, 1 + (seed % 3) as usize, 200); + let present: Vec<&Peer> = peers.iter().filter(|peer| !peer.departed).collect(); + let Some(host) = present.first() else { continue }; + + for (index, guest) in present.iter().enumerate().skip(1) { + assert!( + guest.session().registry().value_equal(host.session().registry()), + "seed {seed}: guest {index} working registry diverged from the host's" + ); + } + } +}