From f3bfea8ebda0fa7efe1fd9ed6fe670ddb544d38e Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 15 Nov 2026 18:43:13 +0000 Subject: rules: the time before strict is the change that turned it, written again or not A change written under a policy that isn't strict was refused, in a strict document, unless it was in the history of the change that wrote the policy value the document read now. So the policy written again by a node that held a change from before, taken beside the strict policy, put that change in the new writer's history: that node kept it, every other node refused it, and the new policy with it, and the node was cut off. Now the reference is the change that turned the swarm strict: one that wrote a strict policy where the policy at its history wasn't, found by following back the writes of what the policy holds (`store::writers`). A change written under a policy that isn't strict is refused where such a change is beside it, neither in its history nor built on it. A policy written again, strict over strict, names the same change. One turning the swarm strict beside it is refused like any other. Of two at once neither is preferred: any rule choosing one, the lower hash say, would let a change made later to look as old take the place of the one every node took, and every node would drop it with all that was built on it. So two members turning a swarm strict at once split the nodes that took one from those that took the other; access.md says to turn it from one. --- src/document/changes.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/document/changes.rs') diff --git a/src/document/changes.rs b/src/document/changes.rs index 800ea19..e1cbe21 100644 --- a/src/document/changes.rs +++ b/src/document/changes.rs @@ -28,6 +28,18 @@ pub(crate) fn holds_all(doc: &impl ReadDoc, heads: &[ChangeHash]) -> bool { heads.iter().all(|head| holds(doc, head)) } +/// Whether `hash` is in the history of `heads`, which `doc` holds: one of them, or one +/// they build on. +pub(crate) fn in_history(doc: &Document, hash: &ChangeHash, heads: &[ChangeHash]) -> bool { + heads.contains(hash) + || (holds(doc, hash) + && holds_all(doc, heads) + && !doc + .get_changes(heads) + .iter() + .any(|later| later.hash() == *hash)) +} + /// Whether the history of `theirs` (of them, those `doc` has) holds all of `ours` /// (heads of `doc`): a peer at `theirs` has every change we have. pub(crate) fn covers(doc: &Document, theirs: &[ChangeHash], ours: &[ChangeHash]) -> bool { -- cgit v1.3.1