From 1a5b5ea02909e6c176ebd85d395e47fe15fcdba0 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 7 Nov 2026 22:35:21 +0100 Subject: remake: replays keep their writers A remake's replay writes each value as the user who wrote it, splitting where several users wrote under a path, so replays are judged as the original writes. Auth plan M6 (remakes, 2.4). --- src/remake/switch.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/remake/switch.rs') diff --git a/src/remake/switch.rs b/src/remake/switch.rs index 4c72b39..dd08b38 100644 --- a/src/remake/switch.rs +++ b/src/remake/switch.rs @@ -216,6 +216,7 @@ async fn switch( let actor = ActorId::random(); host.remake().add_own_actor(actor.clone()); let new_actor = actor.clone(); + let node = host.node_id(); // 2. Build (or reuse), verify and replay without holding any lock. let (new_doc, copy_heads, mut stats) = tokio::task::spawn_blocking( @@ -233,8 +234,9 @@ async fn switch( )); } - // A fresh actor: this node's writes in the new epoch. + // A fresh actor: this node's writes in the new epoch, made by it. let mut doc = snapshot.doc.with_actor(actor); + crate::document::replica::authored(&mut doc, &node); let heads = copy.get_heads(); @@ -248,8 +250,15 @@ async fn switch( } // Each write at the time it was made, so later replays judge by it. - let stats = - delta::replay_newest(©, &base, &heads, &mut doc, &translator, superseded); + let stats = delta::replay_newest( + ©, + &base, + &heads, + &mut doc, + &node, + &translator, + superseded, + ); Ok((doc, heads, stats)) }, ) @@ -302,6 +311,7 @@ pub(super) async fn swap_in( translator: Translator, ) -> Result<(Document, ReplayStats), String> { let superseded = host.superseded(); + let node = host.node_id(); // The closure runs on the blocking pool; its replay numbers come back through this. let late_stats = std::sync::Arc::new(std::sync::Mutex::new(ReplayStats::default())); let late_out = std::sync::Arc::clone(&late_stats); @@ -318,6 +328,7 @@ pub(super) async fn swap_in( ©_heads, &live_heads, &mut new_doc, + &node, &translator, superseded, ); -- cgit v1.3.1