Skip to main content

Module command

Module command 

Source
Expand description

§Hierarchical Command Coordination

This module implements bidirectional command dissemination with policy-based flexibility.

§Overview

Complements upward capability aggregation with downward command propagation:

  • Policy-based routing: Commands carry routing policies (buffer, conflict, acknowledgment)
  • Hierarchical dissemination: Commands flow down through Zone → Cell → Node hierarchy
  • Acknowledgment tracking: Optional acknowledgment based on command policy
  • Conflict resolution: Deterministic resolution when multiple commands target same resource

§Architecture

┌──────────────────────────────────────────────────┐
│  Zone Commander (Higher Echelon)                │
│  Issues HierarchicalCommand with policies       │
└────────────────────┬─────────────────────────────┘
                     │
          ┌──────────┴──────────┐
          ▼                     ▼
   ┌─────────────┐       ┌─────────────┐
   │  Cell 1     │       │  Cell 2     │
   │  Receives   │       │  Receives   │
   │  & Routes   │       │  & Routes   │
   └──────┬──────┘       └──────┬──────┘
          │                     │
     ┌────┴────┐           ┌────┴────┐
     ▼         ▼           ▼         ▼
  Node-1   Node-2      Node-3   Node-4
  (Execute & Ack)     (Execute & Ack)

§Usage

use peat_protocol::command::CommandCoordinator;
use peat_schema::command::v1::HierarchicalCommand;

// Create coordinator for a squad leader
let coordinator = CommandCoordinator::new(
    Some("squad-alpha".to_string()),
    "node-1".to_string(),
    vec!["node-1".to_string(), "node-2".to_string()], // squad members
);

// Issue a command to squad members
let command = HierarchicalCommand {
    command_id: "cmd-001".to_string(),
    originator_id: "node-1".to_string(),
    // ... command details
    ..Default::default()
};

coordinator.issue_command(command).await?;
  • ADR-014: Distributed Coordination Primitives
  • ADR-013: AI Operations and Binary Transfer
  • ADR-009: Bidirectional Hierarchical Flows

Structs§

AckTimeout
Acknowledgment timeout tracking
CommandCoordinator
Coordinates hierarchical command dissemination
CommandRouter
Resolves command targets to specific node IDs
ConflictResolver
Conflict resolution engine
ObserverHandle
Handle for an active observer subscription
TimeoutManager
Timeout manager for commands and acknowledgments

Enums§

ConflictResult
Result of conflict detection
TargetResolution
Result of target resolution

Traits§

CommandStorage
Backend-agnostic storage interface for hierarchical commands