From 841897b79838f97a809356471baf2f41e186cdfa Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 14:13:39 +0000 Subject: continuum-party: which places a proposal gives another writer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rules go by first match, and `{party}` matches only the names of the version's parties: admitting a party named as a segment of a place, or changing the rules or their order, moves who writes the places below it, and what their writer wrote there counts no more once the version passes. Nothing said so: a proposal showed only its fields' changes. `client::writers` names, of the places holding a value, those whose writer a version changes, as `place: before -> after` (`nobody` where no rule gives it one). `continuum-party proposals` prints them under each proposal's changes (`who writes …`), and a fork's check does for the fork's version (`writers` in POST /events/fork). The guides and federation.md say so; row 72 is tested (`federation_attack_72`). --- docs/federation.md | 4 +- docs/guides/federation/forking-and-following.md | 7 ++- docs/guides/federation/proposing-and-voting.md | 8 +++- docs/openapi.yaml | 10 ++++- src/api/events.rs | 4 +- src/federation/client.rs | 59 +++++++++++++++++++++++++ src/federation/fork.rs | 12 ++++- src/federation/party.rs | 15 +++++++ 8 files changed, 109 insertions(+), 10 deletions(-) diff --git a/docs/federation.md b/docs/federation.md index e47da93..f0099ef 100644 --- a/docs/federation.md +++ b/docs/federation.md @@ -626,7 +626,8 @@ store of its own from the federation's ([`store.md`](store.md), [Forks](store.md 3. The others join it as a node joins any swarm, by its ID. A node holding the history up to those heads builds the root and checks it, says what it holds that those heads lack, what the fork's version changes of the one current there, its rules and their - order among it, and, party by party, whether it gives the party the keys it had there: + order among it, the places holding a value whose writer it changes, and, party by + party, whether it gives the party the keys it had there: a founder may give a party that didn't go keys of its own. A node that doesn't hold that history takes the root on its operator's word, as its operator names the fork. @@ -783,6 +784,7 @@ fold, with crafted events. *Sim*: a simulation. *Bench*: measured, not judged. | 69 | A key a version names, stolen, writes its party's node list at a history from before the version naming the party's keys anew, beside the list the party writes under that version, several, for the lowest ID | The party's counts: of a party's lists, those written under the latest version come first | unit | | 70 | A checkpoint's version proposed again, by an event beside its heads | Voters back it all the same, as a proposal lapses with the move, and vote on the events proposing it above its heads, as a node shows them; a version event on votes beside them is refused | unit | | 71 | Merge events under the base revision, signed by a node its party doesn't list, by a party's key, or spelled otherwise | Refused, or none: a merge event is taken only under a revision with merge events, signed by a node its party's node list names, its `merge` `true`; it counts for nothing | unit | +| 72 | A version, or a fork's, admitting a party named as a segment of places others write, or changing the rules or their order, so that who writes those places moves, rules unchanged in the first case | Taken, as any version two thirds pass, or any fork: a party's client names each place holding a value whose writer a proposal changes before it is voted on, and a fork's check does for the fork's version | unit | ## Roads not taken diff --git a/docs/guides/federation/forking-and-following.md b/docs/guides/federation/forking-and-following.md index dafa974..4890a61 100644 --- a/docs/guides/federation/forking-and-following.md +++ b/docs/guides/federation/forking-and-following.md @@ -57,16 +57,19 @@ continuum-party --node http://lass:secret@localhost:3000 check fork-root # its heads lack 0c7e… # its version changes: # changes: "3a90…" -> "b41f…" +# keys.euer: {"keys":["ssh-ed25519 AAAA…"],"since":0} -> - # keys.makefu: {"keys":["ssh-ed25519 AAAA…"],"since":2} -> {"keys":[…],"since":5} -# nodes.lass: {"nodes":["continuum:9c07…"],"since":0} -> {…,"since":5} +# nodes.euer: {"nodes":["continuum:3b1e…"],"since":0} -> - # number: 4 -> 5 +# who writes home/euer/hosts/x: euer -> nobody # makefu's keys: ["ssh-ed25519 AAAA…"] here, ["ssh-ed25519 AAAA…"] in the fork ``` Whether it builds that root at those heads; what it took that the heads lack (neither among them, in their history, nor above them), which the fork doesn't hold; what the fork's version changes of the one current at those heads, field by field, its rules and -their order among them, which say who writes where; and, party by party, the keys the +their order among them, which say who writes where, and the places holding a value whose +writer it changes; and, party by party, the keys the fork's version gives otherwise than the party had at those heads. A node that doesn't hold that history takes the root on its operator's word, who names the fork by its ID: compare that ID whole, as a founder trying versions can steer its first few digits. diff --git a/docs/guides/federation/proposing-and-voting.md b/docs/guides/federation/proposing-and-voting.md index 330d670..f052276 100644 --- a/docs/guides/federation/proposing-and-voting.md +++ b/docs/guides/federation/proposing-and-voting.md @@ -157,8 +157,12 @@ curl -s -u tv:secret localhost:3000/events/counts | jq .proposals # "proposals":["c41e…"],"votes":["5a77…","e019…"],"yes":["tv"]}} ``` -The client shows the same, why it backs one not, by the federation it knows, and what -each proposal's version changes of the current one, field by field and party by party: +The client shows the same, why it backs one not, by the federation it knows, what each +proposal's version changes of the current one, field by field and party by party, and +the places holding a value whose writer it changes (`who writes names/wiki/a: tv -> +wiki`): admitting a party named as a segment of a place is, or changing the rules or +their order, moves who writes there, rules unchanged in the first case, and what was +written there counts no more once it passes: ```sh continuum-party --node http://tv:secret@localhost:3000 proposals diff --git a/docs/openapi.yaml b/docs/openapi.yaml index 6cef2f2..b5e7b14 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -1696,7 +1696,9 @@ paths: events it took that are neither among them, nor in their history, nor above them); what the fork's version changes of the version current at those heads, a line each as `field: before -> after`, its rules among them, `keys` and `nodes` - party by party (`changes`); and the parties whose keys the fork's version gives + party by party (`changes`); of the places holding a value there, those whose + writer the fork's version changes, as `place: before -> after`, `nobody` where no + rule gives it one (`writers`); and the parties whose keys the fork's version gives otherwise than they had at those heads, each with its keys there and in the fork. A node that doesn't hold that history takes a fork's root on its operator's word, who names @@ -1715,7 +1717,7 @@ paths: application/json: schema: type: object - required: [fork, builds, why, lacking, changes, keys] + required: [fork, builds, why, lacking, changes, writers, keys] properties: fork: type: string @@ -1732,6 +1734,10 @@ paths: type: array items: type: string + writers: + type: array + items: + type: string keys: type: object additionalProperties: diff --git a/src/api/events.rs b/src/api/events.rs index a3781c1..5182c23 100644 --- a/src/api/events.rs +++ b/src/api/events.rs @@ -400,7 +400,8 @@ async fn make_fork(State(state): State, Json(forking): Json) /// `POST /events/fork`: what this node finds of the fork whose root is the body's first /// line, as the file its founders start from holds it: whether it builds that root at /// its heads, and why not; what it holds that those heads lack; what the fork's version -/// changes of the one current there, a line each; and the parties whose keys the fork's +/// changes of the one current there, a line each, and the places holding a value whose +/// writer it changes; and the parties whose keys the fork's /// version gives otherwise than they had there, each with its keys there and in the fork. async fn check_fork(State(state): State, body: Bytes) -> Response { let (root, _) = fork::read_root_file(&body); @@ -419,6 +420,7 @@ async fn check_fork(State(state): State, body: Bytes) -> Response { "why": check.why, "lacking": ids(check.lacking), "changes": check.changes, + "writers": check.writers, "keys": keys, })) .into_response() diff --git a/src/federation/client.rs b/src/federation/client.rs index 45f5019..f0c196f 100644 --- a/src/federation/client.rs +++ b/src/federation/client.rs @@ -481,6 +481,32 @@ pub(crate) fn changes(current: &Json, proposed: &Json) -> Vec { lines } +/// Of `places`, the places holding a value, those whose writer the version `proposed` +/// changes of `current`, a line each, `place: before -> after`, `nobody` where no rule +/// gives it one: admitting a party named as a place's segment is, or changing the rules or +/// their order, moves who writes there, and what its writer wrote there counts no more +/// once `proposed` passes. +pub(crate) fn writers<'a>( + current: &Version, + proposed: &Version, + places: impl IntoIterator, +) -> Vec { + places + .into_iter() + .filter_map(|place| { + let path = super::version::path(place)?; + let (before, after) = (current.writer(&path), proposed.writer(&path)); + (before != after).then(|| { + format!( + "{place}: {} -> {}", + before.unwrap_or("nobody"), + after.unwrap_or("nobody") + ) + }) + }) + .collect() +} + /// Of the parties' nodes, those not known to know `revision`, by what the node a client /// talks to heard each say it knows (`knows` in `counts`, from `GET /events/counts`): a /// line for each party with any, naming them and what each said. Once a version of @@ -945,6 +971,39 @@ mod tests { ); } + /// Row 72 (`docs/federation.md`): a party admitted under the name of a place's segment + /// moves who writes there, rules unchanged, and so does a change of the rules' order; + /// the places it moves are named, the others left out. + #[test] + fn federation_attack_72() { + let (tv, lass, wiki) = ( + Party::new("tv", 1), + Party::new("lass", 2), + Party::new("wiki", 3), + ); + let rules = [ + ("names/{party}/**", harness::str("{party}")), + ("names/**", harness::str("tv")), + ]; + let read = |spec: Spec| Version::read(&spec.json()).unwrap(); + let current = read(Spec::first(&[&tv, &lass], &rules)); + let places = ["names/wiki/a", "names/lass/b", "names/other", "home/tv/c"]; + let admitted = read(Spec::first(&[&tv, &lass, &wiki], &rules)); + assert_eq!( + writers(¤t, &admitted, places), + ["names/wiki/a: tv -> wiki"] + ); + let reordered = read(Spec::first( + &[&tv, &lass], + &[rules[1].clone(), rules[0].clone()], + )); + assert_eq!( + writers(¤t, &reordered, places), + ["names/lass/b: lass -> tv"] + ); + assert!(writers(¤t, ¤t, places).is_empty()); + } + /// Of the nodes `knows` names, those that didn't say they know a revision are named, /// with what each said; a party whose nodes all did, not. #[test] diff --git a/src/federation/fork.rs b/src/federation/fork.rs index c5ce727..0333a52 100644 --- a/src/federation/fork.rs +++ b/src/federation/fork.rs @@ -1,8 +1,9 @@ //! Forks (`docs/federation.md`, Forks): a node holding a federation's history makes the //! root of a fork at heads it holds, by a version (`make`), and checks one it is given //! (`check`): whether it builds that root at its heads, what it holds that those heads -//! lack, what the fork's version changes of the one current there, and, party by party, -//! the keys the fork's version gives where they aren't the keys the party had there. A +//! lack, what the fork's version changes of the one current there, and so who writes the +//! places holding a value, and, party by party, the keys the fork's version gives where +//! they aren't the keys the party had there. A //! node that doesn't hold that history takes a fork's root on its operator's word, who //! names the fork by its root's ID (`--store-id`). //! @@ -64,6 +65,9 @@ pub(crate) struct Check { /// What the fork's version changes of the version current at those heads, a line each /// (`client::changes`): its rules among them, whose order says who writes where. pub(crate) changes: Vec, + /// Of the places holding a value there, those whose writer the fork's version changes, + /// a line each (`client::writers`). + pub(crate) writers: Vec, /// Each party whose keys the fork's version gives otherwise than the party had at /// those heads, with its keys there and in the fork. pub(crate) keys: Vec<(String, Vec, Vec)>, @@ -90,6 +94,7 @@ pub(crate) fn check(store: &Store, root: &[u8]) -> Result, root: &[u8]) -> Result| { keys.sort(); keys @@ -129,6 +135,7 @@ pub(crate) fn check(store: &Store, root: &[u8]) -> Result Result<()> { for line in changes { println!(" {line}"); } + for line in check["writers"].as_array().into_iter().flatten() { + println!(" who writes {}", line.as_str().unwrap_or_default()); + } for (party, keys) in check["keys"].as_object().into_iter().flatten() { println!( "{party}'s keys: {} here, {} in the fork", @@ -891,6 +894,13 @@ async fn again(node: &Node, signer: &Signer, record: &mut Record, path: &Path) - async fn proposals(node: &Node) -> Result<()> { let counts = node.counts().await?; let current = current(&counts)?; + // The places holding a value, whose writer a proposal may move. + let places: Vec<&str> = counts["values"] + .as_object() + .into_iter() + .flatten() + .map(|(place, _)| place.as_str()) + .collect(); let parties = |names: &JsonValue| -> String { let names: Vec<&str> = names .as_array() @@ -933,6 +943,11 @@ async fn proposals(node: &Node) -> Result<()> { for line in client::changes(¤t.json, &version) { println!(" {line}"); } + if let Ok(proposed) = Version::read(&version) { + for line in client::writers(¤t, &proposed, places.iter().copied()) { + println!(" who writes {line}"); + } + } } _ => println!(" the event {id} proposes no version of that hash"), } -- cgit v1.3.1