agent-crdt-synchronizer
Agent skill for crdt-synchronizer - invoke with $agent-crdt-synchronizer
Install
mkdir -p .claude/skills/agent-crdt-synchronizer && curl -L -o skill.zip "https://mcp.directory/api/skills/download/7059" && unzip -o skill.zip -d .claude/skills/agent-crdt-synchronizer && rm skill.zipInstalls to .claude/skills/agent-crdt-synchronizer
About this skill
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
- CRDT Implementation: Deploy state-based and operation-based conflict-free data types
- Data Structure Management: Handle counters, sets, registers, and composite structures
- Delta Synchronization: Implement efficient incremental state updates
- Conflict Resolution: Ensure deterministic conflict-free merge operations
- 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({
type: 'INCREMENT',
node: this.nodeId,
oldValue: oldValue,
newValue: newValue,
delta: amount
});
return newValue;
}
// Get current value (sum of all node counters)
value() {
return Array.from(this.payload.values()).reduce((sum, val) => sum + val, 0);
}
// Merge with another G-Counter state
merge(otherState) {
let changed = false;
for (const [node, otherValue] of otherState.payload) {
const currentValue = this.payload.get(node) || 0;
if (otherValue > currentValue) {
this.payload.set(node, otherValue);
changed = true;
}
}
if (changed) {
this.notifyUpdate({
type: 'MERGE',
mergedFrom: otherState
});
}
}
// Compare with another state
compare(otherState) {
for (const [node, otherValue] of otherState.payload) {
const currentValue = this.payload.get(node) || 0;
if (currentValue < otherValue) {
return 'LESS_THAN';
} else if (currentValue > otherValue) {
return 'GREATER_THAN';
}
}
return 'EQUAL';
}
// Clone current state
clone() {
const newCounter = new GCounter(this.nodeId, this.replicationGroup);
newCounter.payload = new Map(this.payload);
return newCounter;
}
onUpdate(callback) {
this.updateCallbacks.push(callback);
}
notifyUpdate(delta) {
this.updateCallbacks.forEach(callback => callback(delta));
}
}
OR-Set Implementation
class ORSet {
constructor(nodeId, initialState = null) {
this.nodeId = nodeId;
this.elements = new Map(); // element -> Set of unique tags
this.tombstones = new Set(); // removed element tags
this.tagCounter = 0;
if (initialState) {
this.merge(initialState);
}
this.updateCallbacks = [];
}
// Add element to set
add(element) {
const tag = this.generateUniqueTag();
if (!this.elements.has(element)) {
this.elements.set(element, new Set());
}
this.elements.get(element).add(tag);
this.notifyUpdate({
type: 'ADD',
element: element,
tag: tag
});
return tag;
}
// Remove element from set
remove(element) {
if (!this.elements.has(element)) {
return false; // Element not present
}
const tags = this.elements.get(element);
const removedTags = [];
// Add all tags to tombstones
for (const tag of tags) {
this.tombstones.add(tag);
removedTags.push(tag);
}
this.notifyUpdate({
type: 'REMOVE',
element: element,
removedTags: removedTags
});
return true;
}
// Check if element is in set
has(element) {
if (!this.elements.has(element)) {
return false;
}
const tags = this.elements.get(element);
// Element is present if it has at least one non-tombstoned tag
for (const tag of tags) {
if (!this.tombstones.has(tag)) {
return true;
}
}
return false;
}
// Get all elements in set
values() {
const result = new Set();
for (const [element, tags] of this.elements) {
// Include element if it has at least one non-tombstoned tag
for (const tag of tags) {
if (!this.tombstones.has(tag)) {
result.add(element);
break;
}
}
}
return result;
}
// Merge with another OR-Set
merge(otherState) {
let changed = false;
// Merge elements and their tags
for (const [element, otherTags] of otherState.elements) {
if (!this.elements.has(element)) {
this.elements.set(element, new Set());
}
const currentTags = this.elements.get(element);
for (const tag of otherTags) {
if (!currentTags.has(tag)) {
currentTags.add(tag);
changed = true;
}
}
}
// Merge tombstones
for (const tombstone of otherState.tombstones) {
if (!this.tombstones.has(tombstone)) {
this.tombstones.add(tombstone);
changed = true;
}
}
if (changed) {
this.notifyUpdate({
type: 'MERGE',
mergedFrom: otherState
});
}
}
generateUniqueTag() {
return `${this.nodeId}-${Date.now()}-${++this.tagCounter}`;
}
onUpdate(callback) {
this.updateCallbacks.push(callback);
}
notifyUpdate(delta) {
this.updateCallbacks.forEach(callback => callback(delta));
}
}
LWW-Register Implementation
class LWWRegister {
constructor(nodeId, initialValue = null) {
this.nodeId = nodeId;
this.value = initialValue;
this.timestamp = initialValue ? Date.now() : 0;
this.vectorClock = new VectorClock(nodeId);
this.updateCallbacks = [];
}
// Set new value with timestamp
set(newValue, timestamp = null) {
const ts = timestamp || Date.now();
if (ts > this.timestamp ||
(ts === this.timestamp && this.nodeId > this.getLastWriter())) {
const oldValue = this.value;
this.value = newValue;
this.timestamp = ts;
this.vectorClock.increment();
this.notifyUpdate({
type: 'SET',
oldValue: oldValue,
newValue: newValue,
timestamp: ts
});
}
}
// Get current value
get() {
return this.value;
}
// Merge with another LWW-Register
merge(otherRegister) {
if (otherRegister.timestamp > this.timestamp ||
(otherR
---
*Content truncated.*
More by ruvnet
View all skills by ruvnet →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversStay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.