Skip to main content

classify_peer_event_set

Function classify_peer_event_set 

Source
pub fn classify_peer_event_set(
    our_events: &[StateEvent],
    peer_events: &[StateEvent],
) -> AncestorAction
Expand description

v0.85: Classify the merge action for a peer event set against our local event log. Pure event-level algebra: takes peer event summaries (id, parents) and our local pool, and decides whether merge can proceed or whether ancestors must be fetched first.

Implements the federation half of docs/THEORY.md §5.2 / §5.3: only causally down-closed event sets are valid replay inputs; when ancestors are missing, merge is undefined until they are fetched or an explicit fork policy is invoked.

Returns:

  • [AncestorAction::Proceed] if every parent referenced by the peer’s events is already present in our_events ∪ peer_events. Caller can safely apply sync_with_peer after persisting the new events.
  • [AncestorAction::Fetch] with the list of missing ancestor ids, otherwise. Caller should fetch and re-classify before applying sync.

This function only reads event ids and parent links; it does not require the full event payloads. Suitable for event-summary gossip and for federation flows that stream events incrementally rather than synchronizing whole Projects.