aboutsummaryrefslogtreecommitdiffstats
path: root/src/remake
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-15 21:44:19 +0000
committertv <tv@krebsco.de>2026-11-15 21:44:19 +0000
commitcc998c1d45939d170bcf8a6512817405ed2b44a3 (patch)
treece7f294018a558091ab7178368676423751197fb /src/remake
parent56fbbcf61ae77aed17b1fc04e914ccd3939df26f (diff)
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.
Diffstat (limited to 'src/remake')
-rw-r--r--src/remake/delta.rs25
1 files changed, 21 insertions, 4 deletions
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<Vec<String>> = 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<String> {
.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<String> {
+ 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`).