aboutsummaryrefslogtreecommitdiffstats
path: root/src/access/policy.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-15 18:52:49 +0000
committertv <tv@krebsco.de>2026-11-15 18:52:49 +0000
commitfbe98b00c9e98ebad02fe18103ca02bdfe1ed9e5 (patch)
treeeb899837386d4fffa59a027e2bacdb69f9380bfc /src/access/policy.rs
parentc8f7165bae7344c0fb0d5265b7736de8ed26d91c (diff)
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.
Diffstat (limited to 'src/access/policy.rs')
-rw-r--r--src/access/policy.rs14
1 files changed, 9 insertions, 5 deletions
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!(