diff --git a/pkgs/id/crates/id-core/src/sync_method.rs b/pkgs/id/crates/id-core/src/sync_method.rs index 12222c2d0c..1a2cf2c24f 100644 --- a/pkgs/id/crates/id-core/src/sync_method.rs +++ b/pkgs/id/crates/id-core/src/sync_method.rs @@ -10,12 +10,14 @@ //! when the peer is not yet bootstrapped (no sync with it has completed). //! - **Range** otherwise. //! -//! The initiator chooses, and sends its choice in a [`Request`]. The responder answers with an -//! [`Answer`]: it agrees to run that method, or refuses it. It never chooses for the session. +//! In the topic-scoped handshake, the initiator chooses and sends its choice in a [`Request`]. +//! The responder answers with an [`Answer`]: it agrees to run that method, or refuses it. It never +//! chooses for the session. This selection is not used by `serve`'s own event sync. //! -//! The rule is written against [`SyncStats`], so range sync's index can supply the numbers when -//! it merges. [`SyncSupport`] is the same kind of seam for the answer: range sync adds itself when -//! it merges, and until then a responder refuses range requests. +//! The rule is written against [`SyncStats`]; a production group-sync initiator and its statistics +//! source do not exist yet. The future initiator needs a stated difference estimator, or must default +//! to Log. Local data alone cannot give the exact difference before a session. [`SyncSupport`] is +//! the seam for the answer: [`LogAndRange`] supports both methods and [`LogSyncOnly`] refuses range. use std::fmt::Debug; @@ -40,8 +42,9 @@ pub trait SyncStats { /// The chains (one per author) the initiator holds for the topic. This is `C`. fn chain_count(&self) -> u64; - /// The estimated number of events the two sides disagree on. This is `D`. It is a lower - /// bound: the peer's new events are unknown until the first exchange. A margin is advisable. + /// The estimated number of events the two sides disagree on, `D`. The peer's new events are + /// unknown before the exchange, so the estimate depends on the caller's stated method and is + /// not necessarily exact or a lower bound. fn estimated_difference(&self) -> u64; /// When the last sync with this peer completed, in Unix milliseconds. `None` means the peer is @@ -97,7 +100,7 @@ pub trait SyncSupport: Debug + Send + Sync { fn supports(&self, method: SyncMethod) -> bool; } -/// Runs `LogSync` only. Range sync (P3.1) adds itself here when it merges. +/// Runs `LogSync` only; use [`LogAndRange`] to support both methods. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub struct LogSyncOnly; diff --git a/pkgs/id/src/event_sync.rs b/pkgs/id/src/event_sync.rs index bc04680830..5651fc1d0b 100644 --- a/pkgs/id/src/event_sync.rs +++ b/pkgs/id/src/event_sync.rs @@ -3,6 +3,8 @@ //! The ALPN is [`crate::event_store::sync::ALPN`], split from `log_sync`'s `/id-sync/1` //! in #179: these sessions open with a range flight, not the handshake's `Request` //! first frame, and the two shapes no longer share an ALPN. +//! `serve` always uses range sessions on this ALPN, without `choose()` or the topic-scoped +//! handshake. Their sync set is the whole store, not a topic subset. //! //! The session itself is the range sync in [`crate::event_store::sync`]: reconciliation, //! then both sides send the events the other lacks, and the receiving store's own ingest diff --git a/pkgs/id/src/log_sync.rs b/pkgs/id/src/log_sync.rs index ecb08c8001..d2bbd2de98 100644 --- a/pkgs/id/src/log_sync.rs +++ b/pkgs/id/src/log_sync.rs @@ -6,6 +6,10 @@ //! if both agree on range sync, each side runs a range session (`event_store::sync`) on the same //! stream pair, over the same store (#179). //! +//! A group-sync initiator is not built yet. When one calls `sync_with`, it must persist successful +//! completion after that call returns successfully, keyed by topic and peer, for later selection. +//! Completion recording is deferred until that initiator exists. +//! //! Three decisions shape the session: //! //! - **Arrival order is the write path.** Each operation is handed to an ingest worker, which verifies