diff options
| author | tv <tv@krebsco.de> | 2026-11-29 03:04:13 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-29 03:04:13 +0000 |
| commit | 10f4e55b1c7d88eef1454ea02488de239489789b (patch) | |
| tree | 68d698c7fd0874cbf55318040c48b2024bf98e22 /src | |
| parent | 2b4e99e1ed273da0f921eaec3e52300480acdf0a (diff) | |
document: screening what is received is the document's, the rules access control's
access::screen becomes document::screen: reading received bytes as
changes, putting them in order, keeping those that wait or are refused,
vouching by signatures and applying is all Automerge's shape, and has
each change judged by the rules (access::rules) before it applies it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/access/holding.rs | 2 | ||||
| -rw-r--r-- | src/access/mod.rs | 1 | ||||
| -rw-r--r-- | src/access/policy.rs | 2 | ||||
| -rw-r--r-- | src/access/rules.rs | 4 | ||||
| -rw-r--r-- | src/api/changes.rs | 2 | ||||
| -rw-r--r-- | src/api/peers.rs | 2 | ||||
| -rw-r--r-- | src/api/stats.rs | 2 | ||||
| -rw-r--r-- | src/document/bench.rs | 10 | ||||
| -rw-r--r-- | src/document/changes.rs | 2 | ||||
| -rw-r--r-- | src/document/inspect.rs | 2 | ||||
| -rw-r--r-- | src/document/mod.rs | 1 | ||||
| -rw-r--r-- | src/document/replica.rs | 2 | ||||
| -rw-r--r-- | src/document/screen.rs (renamed from src/access/screen.rs) | 22 | ||||
| -rw-r--r-- | src/document/signatures.rs | 4 | ||||
| -rw-r--r-- | src/document/sync.rs | 6 | ||||
| -rw-r--r-- | src/node.rs | 2 | ||||
| -rw-r--r-- | src/simtest/policy.rs | 2 | ||||
| -rw-r--r-- | src/state/host.rs | 8 | ||||
| -rw-r--r-- | src/state/mod.rs | 6 | ||||
| -rw-r--r-- | src/state/peer.rs | 2 | ||||
| -rw-r--r-- | src/swarm/roots.rs | 2 | ||||
| -rw-r--r-- | src/swarm/sync.rs | 10 | ||||
| -rw-r--r-- | src/transport/mod.rs | 2 |
23 files changed, 49 insertions, 49 deletions
diff --git a/src/access/holding.rs b/src/access/holding.rs index c68ca92..7b6c823 100644 --- a/src/access/holding.rs +++ b/src/access/holding.rs @@ -637,8 +637,8 @@ mod tests { /// saves and loads; and another node, given all it took, takes it all. #[test] fn what_a_node_takes_leaves_its_events_sound() { - use crate::access::screen::{Screening, apply_bytes}; use crate::document::Change; + use crate::document::screen::{Screening, apply_bytes}; use std::cell::Cell; let id = Id::of(ROOT); let (taken, refused) = (Cell::new(0), Cell::new(0)); diff --git a/src/access/mod.rs b/src/access/mod.rs index 65c3817..d9330fc 100644 --- a/src/access/mod.rs +++ b/src/access/mod.rs @@ -22,7 +22,6 @@ pub(crate) mod holding; pub(crate) mod policy; pub(crate) mod registry; pub(crate) mod rules; -pub(crate) mod screen; pub(crate) mod sealed; pub(crate) mod sshsig; pub(crate) mod strict; diff --git a/src/access/policy.rs b/src/access/policy.rs index e75dce5..1e28731 100644 --- a/src/access/policy.rs +++ b/src/access/policy.rs @@ -1,5 +1,5 @@ //! The swarm's write protection policy (`_continuum/access/policy`): whether every node -//! judges received changes by rules by path before applying them (`access::screen`, +//! judges received changes by rules by path before applying them (`document::screen`, //! `access::rules`). Absent, nobody does: what exists keeps working as it did. Written //! by a user who may write protocol data, as any of it. //! diff --git a/src/access/rules.rs b/src/access/rules.rs index cda7111..520ff0f 100644 --- a/src/access/rules.rs +++ b/src/access/rules.rs @@ -53,7 +53,7 @@ pub(crate) struct Change<'a> { pub(crate) deps: &'a [ChangeHash], /// The heads to judge it at: its dependencies, or, for those not applied yet, the /// changes of the document they build on, where nothing between changed what rules - /// read (`access::screen`). + /// read (`document::screen`). pub(crate) seen: &'a [ChangeHash], /// The node that made it (its node ID), as its signature proves. pub(crate) committer: Option<&'a str>, @@ -131,7 +131,7 @@ pub(crate) struct Seen { /// What `judge` reads at the heads a change is judged at (`Seen`), kept while the heads /// stay the same (`judge_reading`). Each read at given heads costs as much as working out /// what they cover, and screening judges most of a batch at the same heads -/// (`access::screen`). What the heads hold doesn't change as the document takes more +/// (`document::screen`). What the heads hold doesn't change as the document takes more /// changes. #[derive(Debug, Default)] pub(crate) struct Reads { diff --git a/src/api/changes.rs b/src/api/changes.rs index 13c8dd3..fa34029 100644 --- a/src/api/changes.rs +++ b/src/api/changes.rs @@ -139,7 +139,7 @@ fn changes( } ChangesReport { changes, more } } -/// A change the policy refused (`access::screen`): its hash, when its writer made it +/// A change the policy refused (`document::screen`): its hash, when its writer made it /// (by its clock), who made it and for whom, as it says, what it touched, and why. #[derive(Serialize)] #[serde(rename_all = "camelCase")] diff --git a/src/api/peers.rs b/src/api/peers.rs index 1f7af21..30d1204 100644 --- a/src/api/peers.rs +++ b/src/api/peers.rs @@ -52,7 +52,7 @@ pub(crate) struct PeerStatus { /// between; absent while they match. pub(crate) diverged_for_secs: Option<u64>, /// Whether we refuse it as a whole, its own change having broken the swarm's rules - /// (`access::screen`): then we send it nothing. + /// (`document::screen`): then we send it nothing. pub(crate) refused: Option<RefusedPeer>, pub(crate) has_pending_delivery: bool, /// Epoch the peer last advertised; absent until it has sent a message. diff --git a/src/api/stats.rs b/src/api/stats.rs index 37a7447..a5fe0d8 100644 --- a/src/api/stats.rs +++ b/src/api/stats.rs @@ -131,7 +131,7 @@ struct SyncStats { /// Peers whose heads differ from ours while sync is idle (`peers.md`, healing). diverged_peers: usize, /// Peers refused as a whole, their own changes having broken the swarm's rules - /// (`access::screen`): sent nothing. + /// (`document::screen`): sent nothing. refused_peers: usize, /// Changes peers say the swarm's rules refuse, which this node took unjudged and its /// rules refuse too, whose drop takes much: held for a second member to say so diff --git a/src/document/bench.rs b/src/document/bench.rs index db76ccc..09095fa 100644 --- a/src/document/bench.rs +++ b/src/document/bench.rs @@ -31,7 +31,7 @@ //! document, each once. //! //! `screening`: what judging every change received costs while catching up -//! (`access::screen`), against applying them unjudged, as a node whose document has no +//! (`document::screen`), against applying them unjudged, as a node whose document has no //! policy does now: many changes into an empty document, as one delta brings them; //! judged with no policy in them (each passes, read at its dependencies, after its //! paths were found), and with the policy their first change wrote (each judged by the @@ -638,7 +638,7 @@ fn nested_on(mut doc: Document, changes: usize, actors: usize) -> Document { } /// The time to take `doc`'s changes into an empty document: unjudged, as Automerge -/// applies them; and screened (`access::screen::apply`). +/// applies them; and screened (`document::screen::apply`). fn screening_costs(workload: &str, doc: &Document) { let raw: Vec<Vec<u8>> = doc .get_changes(&[]) @@ -661,13 +661,13 @@ fn screening_costs(workload: &str, doc: &Document) { let changes = changes(); let mut empty = Document::new(); let started = Instant::now(); - let screened = crate::access::screen::apply( + let screened = crate::document::screen::apply( &mut empty, Epoch::GENESIS, false, changes, - &mut crate::access::screen::Waiting::default(), - &mut crate::access::screen::Refusals::default(), + &mut crate::document::screen::Waiting::default(), + &mut crate::document::screen::Refusals::default(), None, &mut crate::document::PatchLog::inactive(), ) diff --git a/src/document/changes.rs b/src/document/changes.rs index 800ea19..e6b81c5 100644 --- a/src/document/changes.rs +++ b/src/document/changes.rs @@ -170,7 +170,7 @@ pub(crate) fn delta_bytes( } /// Loads a delta (`delta_bytes`) into `doc`, unjudged: for tests; a node screens what it -/// downloads (`access::screen::apply_bytes`). +/// downloads (`document::screen::apply_bytes`). #[cfg(test)] pub(crate) fn load_delta(doc: &mut Document, bytes: &[u8]) -> Result<()> { use anyhow::Context as _; diff --git a/src/document/inspect.rs b/src/document/inspect.rs index 350b69c..0e51103 100644 --- a/src/document/inspect.rs +++ b/src/document/inspect.rs @@ -89,7 +89,7 @@ impl Place { } /// Whether any of `changes` does anything at a map key `key`: a cheap look, without -/// placing anything, for whether they may write the policy (`access::screen`). +/// placing anything, for whether they may write the policy (`document::screen`). pub(crate) fn touch_key(changes: &[ExpandedChange], key: &str) -> bool { changes.iter().any(|change| { change diff --git a/src/document/mod.rs b/src/document/mod.rs index 1c39de3..ac35b95 100644 --- a/src/document/mod.rs +++ b/src/document/mod.rs @@ -66,6 +66,7 @@ pub(crate) mod lock; pub(crate) mod meta; pub(crate) mod own; pub(crate) mod replica; +pub(crate) mod screen; pub(crate) mod signatures; pub(crate) mod signed; pub(crate) mod store; diff --git a/src/document/replica.rs b/src/document/replica.rs index ba94ca9..a6eaade 100644 --- a/src/document/replica.rs +++ b/src/document/replica.rs @@ -234,7 +234,7 @@ impl Replica { } /// [`logged`](Self::logged), `f` given the document's signatures too - /// (`access::screen`, judging received changes, checks theirs). + /// (`document::screen`, judging received changes, checks theirs). pub(crate) fn logged_signed<T>( &mut self, f: impl FnOnce( diff --git a/src/access/screen.rs b/src/document/screen.rs index 050b23f..542a22e 100644 --- a/src/access/screen.rs +++ b/src/document/screen.rs @@ -35,12 +35,12 @@ use std::collections::{BTreeSet, HashMap, HashSet}; use anyhow::Result; -use super::rules::{self, Refusal}; -use crate::document::inspect::{Action, Inspector, Op, Path}; -use crate::document::meta; -use crate::document::replica::{Epoch, user_of}; -use crate::document::signatures::Signatures; -use crate::document::{Change, ChangeHash, Document}; +use super::inspect::{Action, Inspector, Op, Path}; +use super::meta; +use super::replica::{Epoch, user_of}; +use super::signatures::Signatures; +use super::{Change, ChangeHash, Document}; +use crate::access::rules::{self, Refusal}; /// Changes waiting for their dependencies, kept at most: the oldest go. const MAX_WAITING: usize = 10_000; @@ -171,7 +171,7 @@ impl Screening { /// a restart: a node that starts with nothing at the policy's place judges as one /// that never had a policy. pub(crate) fn policed(&mut self, doc: &Document) -> bool { - self.policed |= crate::document::store::held_anywhere(doc, &super::policy::path()); + self.policed |= crate::document::store::held_anywhere(doc, &crate::access::policy::path()); self.policed } @@ -383,7 +383,7 @@ pub(crate) fn apply( // still come), nor one among these: none judged but an epoch's root, and nothing // placed. A change writing the policy writes at its key. let judging = policed - || super::policy::of(&*doc).enforced() + || crate::access::policy::of(&*doc).enforced() || crate::document::inspect::touch_key(&decoded, "policy"); let ops: Vec<Vec<Op>> = if judging { Inspector::new(doc).ops(&decoded) @@ -961,14 +961,14 @@ fn reaches_signed( return false; } let signed = signed.get_or_insert_with(|| { - super::policy::of(doc) + crate::access::policy::of(doc) .strict() - .then(|| super::envelope::signed_paths(doc)) + .then(|| crate::access::envelope::signed_paths(doc)) }); signed.as_ref().is_some_and(|signed| { paths .iter() - .any(|path| super::envelope::reaches_signed(signed, path)) + .any(|path| crate::access::envelope::reaches_signed(signed, path)) }) } diff --git a/src/document/signatures.rs b/src/document/signatures.rs index f9dd94b..4908041 100644 --- a/src/document/signatures.rs +++ b/src/document/signatures.rs @@ -6,7 +6,7 @@ //! dependencies, and a node's change builds on its previous one, so a signed change of //! an actor vouches for the changes of that actor it builds on: in the document, all //! up to it (`check`: the actor and seq it verifies up to); received, not in it yet, -//! those among them it builds on (`access::screen`). Only those: anyone can make a +//! those among them it builds on (`document::screen`). Only those: anyone can make a //! change under any actor, and one at a seq whose change the document holds is a fork //! (`forks`). So not every change needs one: a change is signed when it //! touches protocol data (`_continuum`) or a path the swarm lists as signed @@ -512,7 +512,7 @@ impl Signatures { /// Received signatures waiting for their changes (`offer`) checked against /// `changes`, not in the document yet, each made by its committer (`committers`, as - /// `access::screen` finds them): one valid vouches for its actor's changes up to it, + /// `document::screen` finds them): one valid vouches for its actor's changes up to it, /// these among them. Past `MAX_INVALID` found invalid, the rest are dropped /// unchecked. pub(crate) fn vouch_batch(&mut self, changes: &[super::Change], committers: &[Option<String>]) { diff --git a/src/document/sync.rs b/src/document/sync.rs index 51cf9eb..2de8e60 100644 --- a/src/document/sync.rs +++ b/src/document/sync.rs @@ -24,7 +24,7 @@ pub(crate) struct Received(sync::Message); impl Received { /// The changes it carries, as their chunks, taken out of it: applied otherwise - /// (`access::screen`), what is left of it says what the peer has and needs. + /// (`document::screen`), what is left of it says what the peer has and needs. pub(crate) fn take_changes(&mut self) -> Vec<u8> { let bytes = self.0.changes.iter().flatten().copied().collect(); self.0.changes = sync::ChunkList::empty(); @@ -211,7 +211,7 @@ pub(crate) struct SyncSession { /// The latest heads the peer said that we hold all of: what it has for certain, /// where the heads we share may only be taken for its (`assume_delivered`). held_said: Vec<crate::document::ChangeHash>, - /// What changes waiting in screening build on and we lack (`access::screen`): asked + /// What changes waiting in screening build on and we lack (`document::screen`): asked /// for in our next message (`lacks`). lacking: Vec<crate::document::ChangeHash>, @@ -1035,7 +1035,7 @@ impl SyncSession { self.id } - /// The peer offered again only changes we refused (`access::screen`): it would as + /// The peer offered again only changes we refused (`document::screen`): it would as /// often as we answer, its sync state never learning we won't take them. No message /// to it before the returned wait, which doubles while it goes on. pub(crate) fn refused_again(&mut self, now: Instant) -> Duration { diff --git a/src/node.rs b/src/node.rs index 5cf72c8..a4a5c85 100644 --- a/src/node.rs +++ b/src/node.rs @@ -203,7 +203,7 @@ impl Node { node_key: config.node_key, sign_every: config.sign_every, screening: Arc::new(std::sync::Mutex::new( - crate::access::screen::Screening::pinned(crate::swarm::roots::pin( + crate::document::screen::Screening::pinned(crate::swarm::roots::pin( config.genesis_root, &Default::default(), false, diff --git a/src/simtest/policy.rs b/src/simtest/policy.rs index d451497..e58f0c3 100644 --- a/src/simtest/policy.rs +++ b/src/simtest/policy.rs @@ -1,5 +1,5 @@ //! A swarm whose policy has every node judge every change (`access::policy`, -//! `access::screen`), with signatures required: honest writes go everywhere, a joining +//! `document::screen`), with signatures required: honest writes go everywhere, a joining //! node registers, a write a node lets through for a user the registry doesn't have //! stays where it was made, and a remake carries the swarm over without refusing //! anything. A strict one (`"values": "signed"`) takes the values its users sign, and diff --git a/src/state/host.rs b/src/state/host.rs index 2fac94b..4ef12a1 100644 --- a/src/state/host.rs +++ b/src/state/host.rs @@ -160,10 +160,10 @@ impl AppState { } }; let paths = dropped.own_paths; - let theirs: Vec<crate::access::screen::Refused> = dropped + let theirs: Vec<crate::document::screen::Refused> = dropped .theirs .into_iter() - .map(|theirs| crate::access::screen::Refused { + .map(|theirs| crate::document::screen::Refused { change: theirs.change, committer: theirs.committer, user: theirs.user, @@ -559,12 +559,12 @@ impl Host for AppState { tokio::task::spawn_blocking(move || { let result = { let mut replica = state.doc.blocking_write(); - // Judged first (`access::screen`), whether this document has a policy + // Judged first (`document::screen`), whether this document has a policy // yet or not. let result = { let (epoch, epoch_seq) = (replica.epoch, replica.epoch_seq); let replica = &mut *replica; - crate::access::screen::apply_bytes( + crate::document::screen::apply_bytes( &mut replica.doc, epoch, epoch_seq, diff --git a/src/state/mod.rs b/src/state/mod.rs index 4187654..ccd8a93 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -168,8 +168,8 @@ pub(crate) struct AppState { /// (`--sign-every`). pub(crate) sign_every: SignEvery, /// Received changes waiting for their dependencies, and those refused, while the - /// policy has them judged (`access::screen`). Locked after the document. - pub(crate) screening: Arc<std::sync::Mutex<crate::access::screen::Screening>>, + /// policy has them judged (`document::screen`). Locked after the document. + pub(crate) screening: Arc<std::sync::Mutex<crate::document::screen::Screening>>, /// The challenges logins by key used, until they expire (`access::challenge`). pub(crate) challenges: Arc<std::sync::Mutex<crate::access::challenge::Used>>, /// Sessions ended on this node in a swarm without a registry, where they can't be @@ -327,7 +327,7 @@ impl AppState { /// until it synced once with a ready neighbour (`release_writes`, `swarm::sync`), or /// `KEPT_WRITER_WAIT` passed: so that a neighbour holding later changes of that writer, /// which another copy of its files made (a backup restored, a disk rolled back), hands - /// them over first, and the node takes a fresh writer then (`access::screen`). + /// them over first, and the node takes a fresh writer then (`document::screen`). pub(crate) fn hold_writes(&self) { self.writes_held.send_replace(true); let held = Arc::clone(&self.writes_held); diff --git a/src/state/peer.rs b/src/state/peer.rs index 88cbb58..721a754 100644 --- a/src/state/peer.rs +++ b/src/state/peer.rs @@ -141,7 +141,7 @@ pub(crate) struct PeerState { pub(crate) epoch_seq: Option<u32>, /// The peer's run, from its HELLO or HELLO_REPLY: a new one starts `epoch_seq` over. pub(crate) run_id: Option<crate::transport::RunId>, - /// While we refuse the peer as a whole (`access::screen`): its run and `epoch_seq` + /// While we refuse the peer as a whole (`document::screen`): its run and `epoch_seq` /// when we began to. Another means it has another document since (it dropped what /// we refused, `swarm::refusals`, or rejoined): we sync with it again. pub(crate) refused_with: Option<(Option<crate::transport::RunId>, Option<u32>)>, diff --git a/src/swarm/roots.rs b/src/swarm/roots.rs index 1df0129..7ce2bb9 100644 --- a/src/swarm/roots.rs +++ b/src/swarm/roots.rs @@ -25,8 +25,8 @@ use std::time::Duration; use anyhow::{Result, bail}; use tracing::{error, info, warn}; -use crate::access::screen::RootPin; use crate::document::replica::Epoch; +use crate::document::screen::RootPin; use crate::document::{ChangeHash, Document}; use crate::locks::MutexExt; use crate::state::AppState; diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs index 45698fa..517f67d 100644 --- a/src/swarm/sync.rs +++ b/src/swarm/sync.rs @@ -43,7 +43,7 @@ async fn deliver_sync_to_peer(state: &AppState, peer: &str) -> Result<()> { let now_with = (ps.run_id, ps.epoch_seq); match (refusing, ps.refused_with) { (false, _) => ps.refused_with = None, - // All it commits builds on what we refused (`access::screen`). + // All it commits builds on what we refused (`document::screen`). (true, None) => { ps.refused_with = Some(now_with); trace!("Refusing the peer as a whole; not syncing with it"); @@ -686,13 +686,13 @@ pub(crate) async fn handle_sync( .logged_signed(|doc, known, log| { let result = (|| { // Judged first, each as the policy it was written under has it - // (`access::screen`), whether this document has one yet or not; + // (`document::screen`), whether this document has one yet or not; // and vouched for by the signatures it sent too, where that policy // requires them. { let bytes = message.take_changes(); known.offer(doc, std::mem::take(&mut signatures)); - let outcome = crate::access::screen::apply_bytes( + let outcome = crate::document::screen::apply_bytes( doc, epoch, epoch_seq, @@ -1025,12 +1025,12 @@ async fn download_and_apply_delta( let heads_before = replica.heads().to_vec(); { // Its signatures wait for its changes (`Signatures::offer`), each checked as - // they are judged (`access::screen`), whether this document has a policy yet + // they are judged (`document::screen`), whether this document has a policy yet // or not. let epoch_seq = replica.epoch_seq; let replica = &mut *replica; replica.signatures.offer(&replica.doc, signatures); - let outcome = crate::access::screen::apply_bytes( + let outcome = crate::document::screen::apply_bytes( &mut replica.doc, epoch, epoch_seq, diff --git a/src/transport/mod.rs b/src/transport/mod.rs index ee63988..6fe17eb 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -271,7 +271,7 @@ pub(crate) struct Speaks { pub(crate) revision: Option<[u8; 32]>, } -/// REFUSALS: changes the sender refused by the swarm's rules (`access::screen`), of +/// REFUSALS: changes the sender refused by the swarm's rules (`document::screen`), of /// those the recipient brought it: the recipient judges them itself, and rejoins if its /// own rules refuse them too, as it took them under another policy (`swarm::refusals`). #[derive(Debug, Clone, Serialize, Deserialize)] |
