From fbe98b00c9e98ebad02fe18103ca02bdfe1ed9e5 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 15 Nov 2026 18:52:49 +0000 Subject: store: values ordered by seq as the policy a read shows says Whether values are read by `seq` went by whether any value at the policy's place asks for signed values, not by what the policy reads as. Where the place holds two, they part: a signed policy that isn't strict read before a plain one that is, or two maps, the newer not strict. Such a swarm judged as not strict and read by `seq`. Now the policy's own place is read by `seq` where any value there asks for signed values, so an older policy put back beside a strict one can't undo it; every other place is read by `seq` only where the policy that read shows is strict (`policy::read`, which `policy::of` reads with). A swarm whose policy doesn't read as strict reads every place as Automerge has it. --- src/access/policy.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/access') diff --git a/src/access/policy.rs b/src/access/policy.rs index 9f18eb5..97bea27 100644 --- a/src/access/policy.rs +++ b/src/access/policy.rs @@ -88,11 +88,15 @@ pub(crate) fn first( /// The policy `doc` holds. pub(crate) fn of(doc: &impl ReadDoc) -> Policy { - let value = match store::read_plain(doc, &path()) { - Ok(Some(value)) => value, - Ok(None) => return Policy::Open, - Err(error) => return Policy::Unknown(format!("it doesn't read: {error}")), - }; + match store::read_plain(doc, &path()) { + Ok(Some(value)) => read(&value), + Ok(None) => Policy::Open, + Err(error) => Policy::Unknown(format!("it doesn't read: {error}")), + } +} + +/// The policy `value`, as the policy's place holds it, says. +pub(crate) fn read(value: &JsonValue) -> Policy { let version = value.get("version").and_then(JsonValue::as_u64); if version != Some(VERSION) { return Policy::Unknown(format!( -- cgit v1.3.1