From 3fccc4f6859cf0b4d93e7d166142e1ab9255723f Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 16 Nov 2026 19:38:26 +0000 Subject: access: what a change of a swarm holding a store writes Every node judges a change of a swarm holding a store by what it writes, at its history (`docs/store.md`, What a change writes), in place of rules by path: `access::holding`. It writes events, each at `_continuum/events/` the bytes whose SHA-256 that is, no larger than the fold allows (the federation's 256 KiB), at a key held nowhere at the change's history; and its node's entry, with the member list's map where there is none. Everything else is refused, as closed: values outside `_continuum`, the policy, the swarm's ID, users, bans, the topology, remakes and their acks. Nothing deletes or replaces an event. A change names its node; the genesis change's writer names none, so no change under it is taken but the genesis change. In a swarm not holding a store, a change writing a policy naming one is refused: a swarm holds a store from its genesis change, or not at all. The inspector tells a put of bytes apart (`Action::PutBytes`), with the bytes, for the events' check. All of it behind the `federation` feature. --- src/document/events.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/document/events.rs') diff --git a/src/document/events.rs b/src/document/events.rs index 7b0fe5e..2b3a7e0 100644 --- a/src/document/events.rs +++ b/src/document/events.rs @@ -117,6 +117,16 @@ pub(crate) fn is_genesis(change: &Change, fold: &str, id: &Id) -> bool { root.is_some_and(|root| genesis(fold, &root).hash() == change.hash()) } +/// Puts `bytes` at the event `id`, held there or not, as no change of a node puts an +/// event: for tests of what a change may write. +#[cfg(test)] +pub(crate) fn put_held(doc: &mut super::Transaction<'_>, id: &Id, bytes: &[u8]) { + use automerge::transaction::Transactable; + let events = events_map(doc).expect("the events' map"); + doc.put(&events, id.to_string(), ScalarValue::Bytes(bytes.to_vec())) + .expect("a put"); +} + #[cfg(test)] mod tests { use super::*; -- cgit v1.3.1