Skip to main content

Module multi_hop

Module multi_hop 

Source
Expand description

Multi-hop rule resolution with loop detection for the IPFRS distributed logic engine.

This module extends distributed backward chaining with multi-hop traversal across peer nodes, tracking which (peer_id, goal_hash) pairs have been visited to prevent infinite loops in circular rule configurations.

§Overview

The central entry point is MultiHopResolver::resolve, which:

  1. Attempts local KB resolution (facts + one rule level) first.
  2. On failure, discovers remote peers via the find_providers callback.
  3. Delegates the goal to each peer via remote_query, recording each hop in a HopTrace.
  4. Returns a MultiHopResult indicating whether the goal was resolved, the full hop trace, and any top-level variable bindings.

Loop detection is handled by VisitedSet: before each local or remote attempt the (peer_id, goal_hash) pair is inserted; if it already exists the attempt is skipped and false is returned immediately.

Structs§

HopRecord
Records one hop in a multi-hop derivation chain.
HopTrace
Complete trace of all hops taken during a multi-hop resolution attempt.
MultiHopConfig
Configuration governing multi-hop resolution behaviour.
MultiHopResolver
Multi-hop backward-chaining resolver with loop detection.
MultiHopResult
Result of a multi-hop resolution attempt.
VisitedSet
Tracks which (peer_id, goal_hash) pairs have been visited to prevent loops.