aboutsummaryrefslogtreecommitdiffstats
path: root/src/access/screen.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-15 12:28:33 +0000
committertv <tv@krebsco.de>2026-11-15 12:28:33 +0000
commit6be5646df342b21fe82c63f59cfec5a369ab54f8 (patch)
tree48ede9923ab4fa762623a6e32b9b18a088276b98 /src/access/screen.rs
parentd1d081cf8e0e8bb5809c1c82bbdfec6bd7ad0285 (diff)
signed values: value and meta apart, numbered; the highest seq is read
A member could put a user's older signed value back beside a newer one: a change made with dependencies from before both is judged where the place was empty, so the older envelope (`prev` empty) is taken; and of values written at once, the one read was the one with the highest operation, which whoever writes the change steers. A revoked capability, a lifted ban or an earlier policy came back that way, signed by whoever signed it then. An envelope is now `cv2.<value>.<meta>.<signature>`: the value as its user wrote it, and apart from it what continuum adds (swarm, path, user, at, seq, prev), the signature over the value's line and the meta's. `seq` is one more than that of the envelope it replaces, 0 where it replaces none; every node checks it with `prev`. Of the values a place holds, written at once, signed ones are read before any other, the highest `seq` first, of equal ones the lower digest (`store::candidates`): reads, snapshots and writes all go by it. An older envelope beside a newer one changes nothing. `application/continuum-signed` is the value's line, the meta's, then the signature; `scripts/continuum-signed` writes and checks it so. The wire version goes up: nodes must agree on what a place's value is.
Diffstat (limited to 'src/access/screen.rs')
-rw-r--r--src/access/screen.rs28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/access/screen.rs b/src/access/screen.rs
index b616238..9ca8809 100644
--- a/src/access/screen.rs
+++ b/src/access/screen.rs
@@ -1064,7 +1064,8 @@ mod tests {
}
/// Under a strict policy, two signed values written one after the other at the same
- /// path, received in one batch: both taken, the second judged with the first in.
+ /// path, received in one batch: both taken, the second judged with the first in. And
+ /// the first put back beside the second changes nothing.
#[test]
fn successive_signed_values_in_one_batch() {
use crate::access::{envelope, sshsig};
@@ -1094,18 +1095,20 @@ mod tests {
write(&mut theirs, "a", None, "_continuum/members/a", json!({}));
let sealed = |prev: &str, value: serde_json::Value| {
let payload = envelope::Payload {
+ value,
swarm: "s".to_owned(),
path: path("config"),
- value,
user: "alice".to_owned(),
at: 1,
+ seq: u64::from(!prev.is_empty()),
prev: prev.to_owned(),
};
- let bytes = serde_json::to_vec(&payload).unwrap();
+ let bytes = payload.signed();
envelope::seal(&bytes, &sshsig::sign(&key, envelope::NAMESPACE, &bytes)).unwrap()
};
let first = sealed("", json!(1));
let second = sealed(&envelope::digest(Some(&first)), json!(2));
+ let before = theirs.get_heads();
write(&mut theirs, "a", Some("alice"), "config", json!(first));
write(&mut theirs, "a", Some("alice"), "config", json!(second));
@@ -1117,6 +1120,25 @@ mod tests {
store::read_path(&ours, &path("config")).unwrap(),
Some(json!(second))
);
+
+ // The first put there again, by a change that saw neither: taken, as nothing
+ // was there at its history, and held beside the second, which stays the value
+ // (its `seq` is higher), whatever the order of the operations.
+ let mut side = theirs.fork_at(&before).unwrap();
+ write(&mut side, "a", Some("alice"), "config", json!(first));
+ theirs.merge(&mut side).unwrap();
+ let mut ours = Document::new();
+ let screened = screen(&mut ours, received(&theirs, &[]), &mut Waiting::default());
+ let why: Vec<&str> = screened.refused.iter().map(|r| r.why.as_str()).collect();
+ assert!(why.is_empty(), "{why:?}");
+ assert_eq!(
+ store::read_candidates(&ours, &path("config")).unwrap(),
+ [json!(second), json!(first)]
+ );
+ assert_eq!(
+ store::read_path(&ours, &path("config")).unwrap(),
+ Some(json!(second))
+ );
}
/// A refused change offered again: refused by its hash, not judged or kept again,