Langsung ke konten
Skillpedia
API & server (backend)81k Β· #1464

agent-crdt-synchronizer

Fungsinya

Skill ini mengimplementasikan tipe data bebas konflik yang memungkinkan beberapa salinan data diperbarui secara terpisah lalu digabungkan. Skill ini untuk pengembang yang membangun sistem yang datanya harus tetap konsisten di antara perangkat atau node.

Kapan dipakai

  • βœ“Saat pengguna membutuhkan data yang tersinkron di beberapa perangkat atau replika tanpa konflik.
  • βœ“Saat pengguna menginginkan penghitung, himpunan, atau register yang tergabung secara otomatis.
  • βœ“Saat pengguna membutuhkan pembaruan efisien yang hanya mengirim bagian yang berubah.

Link skill

https://github.com/ruvnet/ruflo/blob/main/.agents/skills/agent-crdt-synchronizer/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/ruvnet/ruflo/blob/main/.agents/skills/agent-crdt-synchronizer/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBuatkan daftar belanja bersama yang tetap sinkron di dua perangkat, meski keduanya diperbarui pada waktu yang berbeda.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Skill ini menyiapkan tipe data berbasis state dan berbasis operasi, hanya mengirim bagian yang berubah, dan menyelesaikan konflik dengan aturan penggabungan yang deterministik. Skill ini juga menjaga urutan pembaruan yang berkaitan tetap benar.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.


name: crdt-synchronizer type: synchronizer color: "#4CAF50" description: Implements Conflict-free Replicated Data Types for eventually consistent state synchronization capabilities:

  • state_based_crdts
  • operation_based_crdts
  • delta_synchronization
  • conflict_resolution
  • causal_consistency priority: high hooks: pre: | echo "πŸ”„ CRDT Synchronizer syncing: $TASK"

    Initialize CRDT state tracking

    if [[ "$TASK" == "synchronization" ]]; then echo "πŸ“Š Preparing delta state computation" fi post: | echo "🎯 CRDT synchronization complete"

    Verify eventual consistency

    echo "βœ… Validating conflict-free state convergence"

CRDT Synchronizer

Implements Conflict-free Replicated Data Types for eventually consistent distributed state synchronization.

Core Responsibilities

  1. CRDT Implementation: Deploy state-based and operation-based conflict-free data types
  2. Data Structure Management: Handle counters, sets, registers, and composite structures
  3. Delta Synchronization: Implement efficient incremental state updates
  4. Conflict Resolution: Ensure deterministic conflict-free merge operations
  5. Causal Consistency: Maintain proper ordering of causally related operations

Technical Implementation

Base CRDT Framework

class CRDTSynchronizer {
  constructor(nodeId, replicationGroup) {
    this.nodeId = nodeId;
    this.replicationGroup = replicationGroup;
    this.crdtInstances = new Map();
    this.vectorClock = new VectorClock(nodeId);
    this.deltaBuffer = new Map();
    this.syncScheduler = new SyncScheduler();
    this.causalTracker = new CausalTracker();
  }

  // Register CRDT instance
  registerCRDT(name, crdtType, initialState = null) {
    const crdt = this.createCRDTInstance(crdtType, initialState);
    this.crdtInstances.set(name, crdt);
    
    // Subscribe to CRDT changes for delta tracking
    crdt.onUpdate((delta) => {
      this.trackDelta(name, delta);
    });
    
    return crdt;
  }

  // Create specific CRDT instance
  createCRDTInstance(type, initialState) {
    switch (type) {
      case 'G_COUNTER':
        return new GCounter(this.nodeId, this.replicationGroup, initialState);
      case 'PN_COUNTER':
        return new PNCounter(this.nodeId, this.replicationGroup, initialState);
      case 'OR_SET':
        return new ORSet(this.nodeId, initialState);
      case 'LWW_REGISTER':
        return new LWWRegister(this.nodeId, initialState);
      case 'OR_MAP':
        return new ORMap(this.nodeId, this.replicationGroup, initialState);
      case 'RGA':
        return new RGA(this.nodeId, initialState);
      default:
        throw new Error(`Unknown CRDT type: ${type}`);
    }
  }

  // Synchronize with peer nodes
  async synchronize(peerNodes = null) {
    const targets = peerNodes || Array.from(this.replicationGroup);
    
    for (const peer of targets) {
      if (peer !== this.nodeId) {
        await this.synchronizeWithPeer(peer);
      }
    }
  }

  async synchronizeWithPeer(peerNode) {
    // Get current state and deltas
    const localState = this.getCurrentState();
    const deltas = this.getDeltasSince(peerNode);
    
    // Send sync request
    const syncRequest = {
      type: 'CRDT_SYNC_REQUEST',
      sender: this.nodeId,
      vectorClock: this.vectorClock.clone(),
      state: localState,
      deltas: deltas
    };
    
    try {
      const response = await this.sendSyncRequest(peerNode, syncRequest);
      await this.processSyncResponse(response);
    } catch (error) {
      console.error(`Sync failed with ${peerNode}:`, error);
    }
  }
}

G-Counter Implementation

class GCounter {
  constructor(nodeId, replicationGroup, initialState = null) {
    this.nodeId = nodeId;
    this.replicationGroup = replicationGroup;
    this.payload = new Map();
    
    // Initialize counters for all nodes
    for (const node of replicationGroup) {
      this.payload.set(node, 0);
    }
    
    if (initialState) {
      this.merge(initialState);
    }
    
    this.updateCallbacks = [];
  }

  // Increment operation (can only be performed by owner node)
  increment(amount = 1) {
    if (amount < 0) {
      throw new Error('G-Counter only supports positive increments');
    }
    
    const oldValue = this.payload.get(this.nodeId) || 0;
    const newValue = oldValue + amount;
    this.payload.set(this.nodeId, newValue);
    
    // Notify observers
    this.notifyUpdate({
      typ
Pertanyaan umum

Apa itu CRDT?

Itu adalah tipe data yang dirancang agar salinannya bisa digabungkan tanpa konflik.

Apakah skill ini menjaga urutan pembaruan?

Ya. Skill ini menjaga konsistensi kausal, sehingga operasi yang berkaitan tetap berurutan.

Apakah skill ini mendukung penghitung?

Ya. Skill ini mencakup penghitung, himpunan, register, dan struktur gabungan.

Detail

Deskripsi asli dari pembuat

Agent skill for crdt-synchronizer - invoke with $agent-crdt-synchronizer

repo: ruvnet/ruflo

Popularitas

Bintang GitHub
81k
Peringkat
#1464
Lisensi
MIT
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa