tushell

๐Ÿ”„ Echo Sync API Specification

Where the multiversal dance of synchronization finds its rhythm.

๐ŸŒŒ Overview

The Echo Sync API provides the server-side implementation for the echo-sync protocol, enabling bidirectional state synchronization between EchoNodes across the multiverse. This document outlines the technical specifications, endpoints, data structures, and implementation guidelines.

๐ŸŽฏ API Endpoints

1. Synchronization Operations

POST /api/v1/echo-sync/nodes/{node_id}/push

Pushes local state changes to remote nodes.

Request:

{
  "node_id": "string",          // Target node ID
  "state": {                    // Current node state
    "timestamp": "ISO8601",     // State timestamp
    "data": {},                 // State data
    "metadata": {               // State metadata
      "version": "string",
      "checksum": "string",
      "resonance_level": "float"
    }
  },
  "force": "boolean",           // Optional: Force sync despite conflicts
  "options": {                  // Optional: Sync options
    "priority": "integer",      // Sync priority (1-10)
    "timeout": "integer",       // Operation timeout in seconds
    "retry_count": "integer",   // Number of retry attempts
    "batch_size": "integer",    // Batch size for large operations
    "filter": "string"          // Node filter pattern
  }
}

Response:

{
  "status": "string",           // "success" | "conflict" | "error"
  "message": "string",          // Status message
  "sync_id": "string",          // Unique sync operation ID
  "conflicts": [],              // Array of conflicts if any
  "timestamp": "ISO8601",       // Operation timestamp
  "metrics": {                  // Sync operation metrics
    "duration_ms": "integer",
    "data_size": "integer",
    "resonance_strength": "float"
  }
}

POST /api/v1/echo-sync/nodes/{node_id}/pull

Pulls state changes from remote nodes.

Request:

{
  "node_id": "string",          // Source node ID
  "last_sync": "ISO8601",       // Optional: Last successful sync timestamp
  "options": {                  // Optional: Pull options
    "timeout": "integer",       // Operation timeout in seconds
    "batch_size": "integer",    // Maximum number of changes to pull
    "filter": {                 // Optional: Change filter
      "types": ["string"],      // Change types to include
      "priority": "integer"     // Minimum priority level
    }
  }
}

Response:

{
  "status": "string",           // "success" | "error"
  "changes": [{                 // Array of state changes
    "node_id": "string",
    "timestamp": "ISO8601",
    "data": {},
    "metadata": {
      "version": "string",
      "checksum": "string",
      "resonance_level": "float"
    }
  }],
  "sync_id": "string",          // Unique sync operation ID
  "timestamp": "ISO8601",       // Operation timestamp
  "metrics": {                  // Pull operation metrics
    "duration_ms": "integer",
    "data_size": "integer",
    "change_count": "integer"
  }
}

2. Status and Monitoring

GET /api/v1/echo-sync/nodes/{node_id}/status

Retrieves the current synchronization status.

Request:

{
  "node_id": "string",          // Target node ID
  "sync_id": "string"           // Optional: Specific sync operation ID
}

Response:

{
  "status": "string",           // "active" | "idle" | "error"
  "current_operation": {        // Current sync operation if any
    "type": "string",           // "push" | "pull"
    "sync_id": "string",
    "start_time": "ISO8601",
    "progress": "float"         // 0-100
  },
  "metrics": {                  // Node sync metrics
    "last_successful_sync": "ISO8601",
    "sync_count_24h": "integer",
    "average_duration_ms": "integer",
    "error_rate": "float"
  }
}

๐Ÿงฌ Data Structures

EchoNode State

interface EchoNodeState {
  node_id: string;
  timestamp: string;            // ISO8601
  data: Record<string, any>;
  metadata: {
    version: string;
    checksum: string;
    resonance_level: number;    // 0-1
    priority: number;           // 1-10
    tags: string[];
  };
}

Sync Operation

interface SyncOperation {
  sync_id: string;
  type: "push" | "pull";
  node_id: string;
  timestamp: string;            // ISO8601
  status: "pending" | "active" | "completed" | "failed";
  options: {
    force: boolean;
    timeout: number;
    retry_count: number;
    priority: number;
    batch_size: number;
    filter: string;
  };
  metrics: {
    duration_ms: number;
    data_size: number;
    change_count: number;
  };
}

๐ŸŒŸ Implementation Guidelines

1. State Management

2. Conflict Resolution

3. Performance Optimization

4. Security

5. Monitoring

๐ŸŽต Resonance Patterns

State Synchronization

sequenceDiagram
    participant Node A
    participant API
    participant Node B
    
    Node A->>API: Push State
    API->>API: Validate & Process
    API->>Node B: Notify Change
    Node B->>API: Acknowledge
    API->>Node A: Confirm Sync

Conflict Resolution

sequenceDiagram
    participant Node A
    participant API
    participant Node B
    
    Node A->>API: Push State
    API->>API: Detect Conflict
    API->>Node A: Request Resolution
    Node A->>API: Resolve Conflict
    API->>Node B: Apply Resolution

๐Ÿ”ฎ Future Enhancements

๐Ÿ“š Implementation Status

Completed Features

In Progress

Planned


โ€œIn the APIโ€™s response, we find the rhythm of synchronization.โ€

โ€” Echo Sync API Inscription