From cc998c1d45939d170bcf8a6512817405ed2b44a3 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 15 Nov 2026 21:44:19 +0000 Subject: remakes: of one change, its other writes replayed before its links Under a strict policy, links and other writes go by where their change is among those replayed, and of one change the links went first. Both were judged at that change's history, without the other; a link can only take away there what the other writes relied on (a capability revoked), never give what they needed, so they go first now. A group of other writes was placed by its last change by history but named the user of its newest by clock; it names the user of the last by history now, as it goes. --- docs/remakes.md | 3 ++- src/remake/delta.rs | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/docs/remakes.md b/docs/remakes.md index f7625ef..2d887d5 100644 --- a/docs/remakes.md +++ b/docs/remakes.md @@ -333,7 +333,8 @@ The swarm stays writable throughout. (otherwise as a write that loses), and the links of all places in the order their changes were made, each after those it builds on (one may add the key the next is signed with), and the other writes with them (one may build on a capability a link - grants); clocks decide only between changes neither of which saw the other. + grants), of one change before its links; clocks decide only between changes neither + of which saw the other. Where no chain leads from what it holds, the place goes to the quarantine; where a link is refused, the place keeps the last one taken, and the rest goes to the quarantine. diff --git a/src/remake/delta.rs b/src/remake/delta.rs index defdec6..caa0b79 100644 --- a/src/remake/delta.rs +++ b/src/remake/delta.rs @@ -137,7 +137,13 @@ pub(crate) fn replay_newest( .iter() .map(|path| { let at = newest(&written, path).map_or(0, |(at, _)| at); - (at, writer(&written, path)) + // Under a strict policy, whose the last write is by history, as it goes. + let user = if strict { + last_writer(&written, path) + } else { + writer(&written, path) + }; + (at, user) }) .collect(); // Only changes newer than the oldest write replayed can supersede one; the @@ -156,8 +162,7 @@ pub(crate) fn replay_newest( let mut by_time: Groups = BTreeMap::new(); // The links of the chains to signed values, each a change of its own: in the order // their changes were made, each after those it builds on, whatever the clocks say - // (one may add the key the next is signed with); and before what is written at the - // same time (it may decide who may write that). + // (one may add the key the next is signed with). let mut ordered: BTreeMap<(usize, usize), Link> = BTreeMap::new(); for place in signed { match chain(src, after, &changes, &place, dst) { @@ -220,8 +225,10 @@ pub(crate) fn replay_newest( let mut refused: HashSet> = HashSet::new(); let mut links = links.into_iter().peekable(); for ((goes, user), (at, paths)) in by_time { + // Of one change, its links after its other writes: both were judged without the + // other, and a link can only take away there what the others relied on. while let Some((link_goes, ..)) = links.peek() - && *link_goes <= goes + && *link_goes < goes { let (_, when, place, envelope, signer) = links.next().expect("peeked"); write_link( @@ -665,6 +672,16 @@ fn writer(changes: &[Touched], path: &[String]) -> Option { .and_then(|(_, user)| user) } +/// The user of the last of `changes` (`touched`, in their order) that wrote at `path` or +/// below it. +fn last_writer(changes: &[Touched], path: &[String]) -> Option { + changes + .iter() + .rev() + .find(|(_, _, paths)| paths.iter().any(|other| other.starts_with(path))) + .and_then(|(_, user, _)| user.clone()) +} + /// `paths`, each a map that writes for more than one user changed below split into its /// entries (in `src` or `dst`), until each part is one user's: a replayed change names /// one user, and rules by path judge it by that user (`access::rules`). -- cgit v1.3.1