From d668ce2ff8f308e54c1c7a2c145cb3479cab899d Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Oct 2026 04:13:11 +0100 Subject: move protocol paths to dedicated module --- src/remake/delta.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/remake/delta.rs') diff --git a/src/remake/delta.rs b/src/remake/delta.rs index 59acc8c..ef6a60a 100644 --- a/src/remake/delta.rs +++ b/src/remake/delta.rs @@ -27,7 +27,7 @@ use automerge::{ActorId, AutoCommit, ChangeHash, PatchAction, Prop}; use tracing::warn; use super::kind::{Translation, Translator}; -use super::snapshot::{EPOCHS, META_ROOT, REMAKES, VOTES}; +use crate::document::meta::{self, EPOCHS, REMAKES, VOTES}; use crate::document::store::{self, StoreError}; #[derive(Debug, Default, Clone)] @@ -138,12 +138,12 @@ fn is_protocol_path(path: &[String]) -> bool { let [root, part, ..] = path else { return false; }; - root == META_ROOT && [REMAKES, VOTES, EPOCHS].contains(&part.as_str()) + root == meta::ROOT && [REMAKES, VOTES, EPOCHS].contains(&part.as_str()) } /// True for the root and for `_continuum` itself. fn contains_protocol_path(path: &[String]) -> bool { - matches!(path, [] | [_]) && path.first().is_none_or(|root| root == META_ROOT) + matches!(path, [] | [_]) && path.first().is_none_or(|root| root == meta::ROOT) } /// What a late node has that a snapshot lacks. @@ -464,7 +464,7 @@ mod tests { let mut new = AutoCommit::new(); store::write_path( &mut new, - &[META_ROOT.into(), EPOCHS.into(), "1".into()], + &meta::path(&[EPOCHS, "1"]), &json!({ "generation": 1 }), ) .unwrap(); @@ -473,21 +473,16 @@ mod tests { // The old epoch replaces `_continuum` wholesale and writes a remake record. store::write_path( &mut old, - &[META_ROOT.into()], + &meta::path(&[]), &json!({ "forgotten": { "pk": 1 } }), ) .unwrap(); - store::write_path( - &mut old, - &[META_ROOT.into(), REMAKES.into(), "c".into()], - &json!({ "x": 1 }), - ) - .unwrap(); + store::write_path(&mut old, &meta::path(&[REMAKES, "c"]), &json!({ "x": 1 })).unwrap(); old.commit(); let after = old.get_heads(); replay(&mut old, &base, &after, &mut new, &Translator::default()); - let meta = &view(&new)[META_ROOT]; + let meta = &view(&new)[meta::ROOT]; assert_eq!(meta[EPOCHS]["1"]["generation"], json!(1)); assert_eq!(meta["forgotten"]["pk"], json!(1)); assert!(meta.get(REMAKES).is_none()); -- cgit v1.3.1