pub struct DistributedRunner { /* private fields */ }Expand description
Orchestrates distributed tick execution.
The DistributedRunner coordinates tick execution across multiple shards,
ensuring proper phase synchronization via barriers. Each tick consists of
four phases (Sense, Act, Decay, Advance) that are executed in order across
all shards before moving to the next phase.
§Architecture
The runner uses a coordinator for global synchronization and maintains references to all shard instances. During each tick:
- Sense Phase: All shards prepare agent decisions (read-only)
- Act Phase: All shards execute agent actions (write operations)
- Decay Phase: All shards decay signals, traces, and edges
- Advance Phase: Coordinator advances the global tick counter
After the Act phase, any cross-shard edges are collected and ghost nodes are resolved if configured.
§Example
use phago_distributed::runner::{DistributedRunner, RunnerConfig};
let runner = DistributedRunner::new(coordinator, shards, RunnerConfig::default());
// Run a single tick
let result = runner.tick().await?;
println!("Completed tick {}", result.tick);
// Run multiple ticks
let results = runner.run(10).await?;Implementations§
Source§impl DistributedRunner
impl DistributedRunner
Sourcepub fn new(
coordinator: Arc<Coordinator>,
shards: Vec<Arc<RwLock<ShardedColony>>>,
config: RunnerConfig,
) -> Self
pub fn new( coordinator: Arc<Coordinator>, shards: Vec<Arc<RwLock<ShardedColony>>>, config: RunnerConfig, ) -> Self
Create a new distributed runner.
§Arguments
coordinator- The coordinator for global synchronizationshards- Vector of shard instances wrapped in Arc<RwLock<_>>config- Runner configuration
Sourcepub async fn tick(&self) -> DistributedResult<DistributedTickResult>
pub async fn tick(&self) -> DistributedResult<DistributedTickResult>
Run a single distributed tick.
Executes all four phases (Sense, Act, Decay, Advance) with barrier synchronization between each phase.
§Returns
A DistributedTickResult containing the new tick number, phase results,
and any cross-shard edges that were created.
§Errors
Returns a DistributedError if:
- Phase synchronization times out
- Cross-shard edge resolution fails
Sourcepub async fn run(
&self,
num_ticks: u64,
) -> DistributedResult<Vec<DistributedTickResult>>
pub async fn run( &self, num_ticks: u64, ) -> DistributedResult<Vec<DistributedTickResult>>
Sourcepub fn coordinator(&self) -> &Arc<Coordinator>
pub fn coordinator(&self) -> &Arc<Coordinator>
Get the coordinator.
Sourcepub fn shard_count(&self) -> usize
pub fn shard_count(&self) -> usize
Get shard count.
Sourcepub fn shards(&self) -> &[Arc<RwLock<ShardedColony>>]
pub fn shards(&self) -> &[Arc<RwLock<ShardedColony>>]
Get a reference to all shards.
Sourcepub fn config(&self) -> &RunnerConfig
pub fn config(&self) -> &RunnerConfig
Get runner configuration.