From 27b76d5748f23a879d9fc82c725a58b514020ef9 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 14:11:39 +0000 Subject: fork: a fork's check says what its version changes, rules among it A node holding the history up to a fork's heads said whether it builds the root, what it holds that those heads lack, and which parties' keys the fork's version gives otherwise. A founder could change the rules, or only their order, which says who writes where, and nobody joining was shown it. The check now says what the fork's version changes of the version current at those heads, a line each as a proposal's are shown (`client::changes`): `changes` in POST /events/fork, and `continuum-party check` prints them. federation.md and the forking guide say so, and that a fork's ID is compared whole: a founder trying versions can steer its first few digits. --- src/api/events.rs | 7 ++++--- src/federation/fork.rs | 26 +++++++++++++++++++++----- src/federation/party.rs | 12 ++++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/api/events.rs b/src/api/events.rs index 45c9a32..a3781c1 100644 --- a/src/api/events.rs +++ b/src/api/events.rs @@ -399,9 +399,9 @@ 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; and the parties whose keys -/// the fork's version gives otherwise than they had there, each with its keys there and in -/// the fork. +/// 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 +/// 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); match state.holding.with(|store| fork::check(store, &root)) { @@ -418,6 +418,7 @@ async fn check_fork(State(state): State, body: Bytes) -> Response { "builds": check.builds, "why": check.why, "lacking": ids(check.lacking), + "changes": check.changes, "keys": keys, })) .into_response() diff --git a/src/federation/fork.rs b/src/federation/fork.rs index 59b744f..c5ce727 100644 --- a/src/federation/fork.rs +++ b/src/federation/fork.rs @@ -1,9 +1,10 @@ //! 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, 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`). +//! 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 +//! 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`). //! //! A fork's founders start its swarm from a file holding its root on the first line, and //! the events the root keeps, each on a line of its own (`--store-root`): JCS writes no @@ -60,14 +61,18 @@ pub(crate) struct Check { /// What it holds that those heads lack: events it took that are neither among them, /// nor in their history, nor above them. pub(crate) lacking: Vec, + /// 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, /// 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)>, } /// What `store` finds of the fork whose root is `root`: as a node holding the history up -/// to its heads builds it, says what it holds that those heads lack, and, party by party, -/// whether the fork's version gives it the keys it had there. +/// to its heads builds it, says what it holds that those heads lack, what the fork's +/// version changes of the one current there, and, party by party, whether it gives the +/// party the keys it had there. pub(crate) fn check(store: &Store, root: &[u8]) -> Result { let checkpoint = Checkpoint::read(root).ok_or("no checkpoint, so no fork's root")?; if checkpoint.at.is_empty() { @@ -84,12 +89,14 @@ pub(crate) fn check(store: &Store, root: &[u8]) -> Result| { keys.sort(); keys @@ -121,6 +128,7 @@ pub(crate) fn check(store: &Store, root: &[u8]) -> Result \"{}\"", first.hash())); + assert!(nodes.starts_with("nodes.tv: ") && nodes.ends_with(r#""since":1}"#)); + assert_eq!(number, "number: 0 -> 1"); assert_eq!( check, Check { builds: true, why: None, lacking: Vec::new(), + changes: check.changes.clone(), keys: Vec::new(), } ); diff --git a/src/federation/party.rs b/src/federation/party.rs index d829cc9..de8d9f9 100644 --- a/src/federation/party.rs +++ b/src/federation/party.rs @@ -351,6 +351,18 @@ pub(crate) async fn main() -> Result<()> { for id in check["lacking"].as_array().into_iter().flatten() { println!("its heads lack {}", id.as_str().unwrap_or_default()); } + let changes: Vec<&str> = check["changes"] + .as_array() + .into_iter() + .flatten() + .filter_map(JsonValue::as_str) + .collect(); + if !changes.is_empty() { + println!("its version changes:"); + } + for line in changes { + println!(" {line}"); + } for (party, keys) in check["keys"].as_object().into_iter().flatten() { println!( "{party}'s keys: {} here, {} in the fork", -- cgit v1.3.1