claude-flow-novice 1.3.6 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/analysis/code-analyzer.md +3 -20
- package/.claude/agents/analysis/code-review/analyze-code-quality.md +1 -1
- package/.claude/agents/analyst.md +208 -550
- package/.claude/agents/architect.md +136 -469
- package/.claude/agents/architecture/system-architect.md +20 -1
- package/.claude/agents/architecture/system-design/arch-system-design.md +1 -1
- package/.claude/agents/base-template-generator.md +24 -1
- package/.claude/agents/coder.md +87 -303
- package/.claude/agents/consensus/byzantine-coordinator.md +4 -21
- package/.claude/agents/consensus/consensus-builder.md +3 -20
- package/.claude/agents/consensus/crdt-synchronizer.md +4 -21
- package/.claude/agents/consensus/gossip-coordinator.md +4 -21
- package/.claude/agents/consensus/performance-benchmarker.md +4 -21
- package/.claude/agents/consensus/quorum-manager.md +4 -21
- package/.claude/agents/consensus/raft-manager.md +4 -21
- package/.claude/agents/consensus/security-manager.md +4 -21
- package/.claude/agents/coordinator.md +22 -11
- package/.claude/agents/data/ml/data-ml-model.md +2 -2
- package/.claude/agents/development/backend/dev-backend-api.md +2 -2
- package/.claude/agents/devops/ci-cd/ops-cicd-github.md +2 -2
- package/.claude/agents/devops/devops-engineer.md +134 -402
- package/.claude/agents/documentation/api-docs/docs-api-openapi.md +2 -2
- package/.claude/agents/github/code-review-swarm.md +1 -1
- package/.claude/agents/github/github-specialist.md +856 -0
- package/.claude/agents/github/pr-manager.md +1 -1
- package/.claude/agents/github/release-manager.md +1 -1
- package/.claude/agents/neural/neural-pattern-agent.md +762 -0
- package/.claude/agents/optimization/benchmark-suite.md +1 -1
- package/.claude/agents/optimization/perf-analyzer.md +1 -1
- package/.claude/agents/optimization/performance-monitor.md +1 -1
- package/.claude/agents/planner.md +135 -0
- package/.claude/agents/researcher.md +22 -9
- package/.claude/agents/reviewer.md +291 -0
- package/.claude/agents/security/security-specialist.md +1 -1
- package/.claude/agents/sparc/architecture.md +1 -1
- package/.claude/agents/sparc/pseudocode.md +1 -1
- package/.claude/agents/sparc/refinement.md +1 -1
- package/.claude/agents/sparc/specification.md +1 -1
- package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +2 -2
- package/.claude/agents/tester.md +21 -11
- package/.claude/agents/testing/unit/tdd-london-swarm.md +1 -1
- package/.claude/agents/testing/validation/production-validator.md +1 -1
- package/.claude/commands/claude-soul.js +1 -1
- package/.claude/commands/fullstack.md +134 -0
- package/.claude/commands/index.js +4 -0
- package/.claude/hooks.json +12 -15
- package/{.claude → .claude-flow-novice/.claude}/agents/MIGRATION_SUMMARY.md +1 -1
- package/.claude-flow-novice/.claude/agents/analysis/code-analyzer.md +192 -0
- package/.claude-flow-novice/.claude/agents/analysis/code-review/analyze-code-quality.md +180 -0
- package/.claude-flow-novice/.claude/agents/analyst.md +300 -0
- package/.claude-flow-novice/.claude/agents/architect.md +557 -0
- package/.claude-flow-novice/.claude/agents/architecture/system-architect.md +630 -0
- package/.claude-flow-novice/.claude/agents/architecture/system-design/arch-system-design.md +156 -0
- package/.claude-flow-novice/.claude/agents/base-template-generator.md +65 -0
- package/.claude-flow-novice/.claude/agents/coder.md +180 -0
- package/.claude-flow-novice/.claude/agents/consensus/byzantine-coordinator.md +46 -0
- package/.claude-flow-novice/.claude/agents/consensus/consensus-builder.md +225 -0
- package/.claude-flow-novice/.claude/agents/consensus/crdt-synchronizer.md +980 -0
- package/.claude-flow-novice/.claude/agents/consensus/gossip-coordinator.md +46 -0
- package/.claude-flow-novice/.claude/agents/consensus/performance-benchmarker.md +834 -0
- package/.claude-flow-novice/.claude/agents/consensus/quorum-manager.md +806 -0
- package/.claude-flow-novice/.claude/agents/consensus/raft-manager.md +46 -0
- package/.claude-flow-novice/.claude/agents/consensus/security-manager.md +605 -0
- package/.claude-flow-novice/.claude/agents/coordinator.md +842 -0
- package/.claude-flow-novice/.claude/agents/data/ml/data-ml-model.md +193 -0
- package/.claude-flow-novice/.claude/agents/development/backend/dev-backend-api.md +142 -0
- package/.claude-flow-novice/.claude/agents/devops/ci-cd/ops-cicd-github.md +164 -0
- package/.claude-flow-novice/.claude/agents/devops/devops-engineer.md +638 -0
- package/.claude-flow-novice/.claude/agents/documentation/api-docs/docs-api-openapi.md +174 -0
- package/.claude-flow-novice/.claude/agents/github/code-review-swarm.md +538 -0
- package/.claude-flow-novice/.claude/agents/github/github-modes.md +173 -0
- package/.claude-flow-novice/.claude/agents/github/github-specialist.md +856 -0
- package/.claude-flow-novice/.claude/agents/github/issue-tracker.md +319 -0
- package/.claude-flow-novice/.claude/agents/github/multi-repo-swarm.md +553 -0
- package/.claude-flow-novice/.claude/agents/github/pr-manager.md +191 -0
- package/.claude-flow-novice/.claude/agents/github/project-board-sync.md +509 -0
- package/.claude-flow-novice/.claude/agents/github/release-manager.md +367 -0
- package/.claude-flow-novice/.claude/agents/github/release-swarm.md +583 -0
- package/.claude-flow-novice/.claude/agents/github/repo-architect.md +398 -0
- package/.claude-flow-novice/.claude/agents/github/swarm-issue.md +573 -0
- package/.claude-flow-novice/.claude/agents/github/swarm-pr.md +428 -0
- package/.claude-flow-novice/.claude/agents/github/sync-coordinator.md +452 -0
- package/.claude-flow-novice/.claude/agents/github/workflow-automation.md +635 -0
- package/.claude-flow-novice/.claude/agents/goal/goal-planner.md +73 -0
- package/.claude-flow-novice/.claude/agents/neural/neural-pattern-agent.md +762 -0
- package/.claude-flow-novice/.claude/agents/neural/safla-neural.md +74 -0
- package/.claude-flow-novice/.claude/agents/optimization/benchmark-suite.md +665 -0
- package/.claude-flow-novice/.claude/agents/optimization/load-balancer.md +431 -0
- package/.claude-flow-novice/.claude/agents/optimization/perf-analyzer.md +725 -0
- package/.claude-flow-novice/.claude/agents/optimization/performance-monitor.md +672 -0
- package/.claude-flow-novice/.claude/agents/optimization/resource-allocator.md +674 -0
- package/.claude-flow-novice/.claude/agents/optimization/topology-optimizer.md +808 -0
- package/.claude-flow-novice/.claude/agents/planner.md +135 -0
- package/.claude-flow-novice/.claude/agents/researcher.md +185 -0
- package/.claude-flow-novice/.claude/agents/reviewer.md +291 -0
- package/.claude-flow-novice/.claude/agents/security/security-specialist.md +978 -0
- package/.claude-flow-novice/.claude/agents/sparc/architecture.md +472 -0
- package/.claude-flow-novice/.claude/agents/sparc/pseudocode.md +318 -0
- package/.claude-flow-novice/.claude/agents/sparc/refinement.md +525 -0
- package/.claude-flow-novice/.claude/agents/sparc/specification.md +276 -0
- package/.claude-flow-novice/.claude/agents/specialized/mobile/spec-mobile-react-native.md +226 -0
- package/.claude-flow-novice/.claude/agents/sublinear/consciousness-evolution-agent.md +499 -0
- package/.claude-flow-novice/.claude/agents/sublinear/matrix-solver-agent.md +113 -0
- package/.claude-flow-novice/.claude/agents/sublinear/nanosecond-scheduler-agent.md +644 -0
- package/.claude-flow-novice/.claude/agents/sublinear/pagerank-agent.md +699 -0
- package/.claude-flow-novice/.claude/agents/sublinear/phi-calculator-agent.md +749 -0
- package/.claude-flow-novice/.claude/agents/sublinear/psycho-symbolic-agent.md +543 -0
- package/.claude-flow-novice/.claude/agents/sublinear/sublinear.md +816 -0
- package/.claude-flow-novice/.claude/agents/sublinear/temporal-advantage-agent.md +360 -0
- package/.claude-flow-novice/.claude/agents/swarm/adaptive-coordinator-enhanced.md +746 -0
- package/.claude-flow-novice/.claude/agents/swarm/adaptive-coordinator.md +396 -0
- package/.claude-flow-novice/.claude/agents/swarm/hierarchical-coordinator.md +300 -0
- package/.claude-flow-novice/.claude/agents/swarm/mesh-coordinator.md +435 -0
- package/.claude-flow-novice/.claude/agents/templates/automation-smart-agent.md +205 -0
- package/.claude-flow-novice/.claude/agents/templates/coordinator-swarm-init.md +90 -0
- package/.claude-flow-novice/.claude/agents/templates/github-pr-manager.md +177 -0
- package/.claude-flow-novice/.claude/agents/templates/implementer-sparc-coder.md +259 -0
- package/.claude-flow-novice/.claude/agents/templates/memory-coordinator.md +187 -0
- package/.claude-flow-novice/.claude/agents/templates/migration-plan.md +746 -0
- package/.claude-flow-novice/.claude/agents/templates/orchestrator-task.md +139 -0
- package/.claude-flow-novice/.claude/agents/templates/performance-analyzer.md +199 -0
- package/.claude-flow-novice/.claude/agents/templates/sparc-coordinator.md +183 -0
- package/.claude-flow-novice/.claude/agents/tester.md +663 -0
- package/.claude-flow-novice/.claude/agents/testing/e2e/playwright-agent.md +249 -0
- package/.claude-flow-novice/.claude/agents/testing/unit/tdd-london-swarm.md +244 -0
- package/.claude-flow-novice/.claude/agents/testing/validation/production-validator.md +395 -0
- package/.claude-flow-novice/dist/index.js +12 -24
- package/.claude-flow-novice/dist/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/agents/agent-manager.js +123 -69
- package/.claude-flow-novice/dist/src/agents/agent-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/agents/github/utils/hook-integration.js +7 -7
- package/.claude-flow-novice/dist/src/agents/github/utils/hook-integration.js.map +1 -1
- package/.claude-flow-novice/dist/src/agents/stage3-integration-validator.js +485 -0
- package/.claude-flow-novice/dist/src/agents/stage3-integration-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/agents/unified-ultra-fast-agent-manager.js +630 -0
- package/.claude-flow-novice/dist/src/agents/unified-ultra-fast-agent-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/cli/commands/agent.js +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/agent.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/config-integration.js +6 -6
- package/.claude-flow-novice/dist/src/cli/commands/enterprise.js +18 -18
- package/.claude-flow-novice/dist/src/cli/commands/enterprise.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/goal-init.js +4 -4
- package/.claude-flow-novice/dist/src/cli/commands/help-new.js +23 -23
- package/.claude-flow-novice/dist/src/cli/commands/help-new.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/help.js +74 -74
- package/.claude-flow-novice/dist/src/cli/commands/help.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/hive-mind/pause.js +2 -2
- package/.claude-flow-novice/dist/src/cli/commands/hive-mind/pause.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/hive.js +4 -4
- package/.claude-flow-novice/dist/src/cli/commands/index.js +103 -132
- package/.claude-flow-novice/dist/src/cli/commands/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/mcp.js +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/migrate.js +4 -4
- package/.claude-flow-novice/dist/src/cli/commands/migrate.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/monitor.js +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/neural-init.js +4 -4
- package/.claude-flow-novice/dist/src/cli/commands/ruv-swarm.js +8 -8
- package/.claude-flow-novice/dist/src/cli/commands/sparc.js +12 -12
- package/.claude-flow-novice/dist/src/cli/commands/sparc.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/start/start-command.js +3 -3
- package/.claude-flow-novice/dist/src/cli/commands/status.js +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/swarm.js +7 -7
- package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/verification.js +18 -18
- package/.claude-flow-novice/dist/src/cli/completion.js +54 -54
- package/.claude-flow-novice/dist/src/cli/completion.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/consolidated/ConsolidatedCLI.js +11 -11
- package/.claude-flow-novice/dist/src/cli/consolidated/ConsolidatedCLI.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/consolidated/core/CommandHandlers.js +31 -31
- package/.claude-flow-novice/dist/src/cli/consolidated/core/TierManager.js +39 -39
- package/.claude-flow-novice/dist/src/cli/consolidated/core/TierManager.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/consolidated/help/InteractiveHelp.js +25 -25
- package/.claude-flow-novice/dist/src/cli/consolidated/help/InteractiveHelp.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/consolidated/routing/CommandRouter.js +8 -8
- package/.claude-flow-novice/dist/src/cli/consolidated/routing/CommandRouter.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/consolidated/utils/IntelligentDefaults.js +6 -6
- package/.claude-flow-novice/dist/src/cli/consolidated/utils/IntelligentDefaults.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/consolidated/utils/PerformanceOptimizer.js +7 -7
- package/.claude-flow-novice/dist/src/cli/consolidated/utils/PerformanceOptimizer.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/index-remote.js +10 -10
- package/.claude-flow-novice/dist/src/cli/index.js +1 -1
- package/.claude-flow-novice/dist/src/cli/init/directory-structure.js +8 -8
- package/.claude-flow-novice/dist/src/cli/init/index.js +3 -3
- package/.claude-flow-novice/dist/src/cli/init/sparc-environment.js +67 -67
- package/.claude-flow-novice/dist/src/cli/init/swarm-commands.js +18 -18
- package/.claude-flow-novice/dist/src/cli/node-repl.js +2 -2
- package/.claude-flow-novice/dist/src/cli/repl.js +1 -1
- package/.claude-flow-novice/dist/src/cli/simple-cli.js +68 -68
- package/.claude-flow-novice/dist/src/cli/simple-cli.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/simple-commands/session-start-soul.js +271 -0
- package/.claude-flow-novice/dist/src/cli/simple-orchestrator.js +7 -7
- package/.claude-flow-novice/dist/src/cli/simple-orchestrator.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/ui/fallback-handler.js +7 -7
- package/.claude-flow-novice/dist/src/communication/enhanced-event-bus.js +816 -0
- package/.claude-flow-novice/dist/src/communication/enhanced-event-bus.js.map +1 -0
- package/.claude-flow-novice/dist/src/communication/failure-recovery-system.js +812 -0
- package/.claude-flow-novice/dist/src/communication/failure-recovery-system.js.map +1 -0
- package/.claude-flow-novice/dist/src/communication/optimized-serialization.js +369 -0
- package/.claude-flow-novice/dist/src/communication/optimized-serialization.js.map +1 -0
- package/.claude-flow-novice/dist/src/communication/performance-optimizations.js +526 -0
- package/.claude-flow-novice/dist/src/communication/performance-optimizations.js.map +1 -0
- package/.claude-flow-novice/dist/src/communication/performance-validator.js +532 -0
- package/.claude-flow-novice/dist/src/communication/performance-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/communication/priority-message-queue.js +525 -0
- package/.claude-flow-novice/dist/src/communication/priority-message-queue.js.map +1 -0
- package/.claude-flow-novice/dist/src/communication/shared-buffer-bus.js +218 -0
- package/.claude-flow-novice/dist/src/communication/shared-buffer-bus.js.map +1 -0
- package/.claude-flow-novice/dist/src/communication/ultra-fast-communication-bus.js +521 -0
- package/.claude-flow-novice/dist/src/communication/ultra-fast-communication-bus.js.map +1 -0
- package/.claude-flow-novice/dist/src/communication/ultra-fast-serialization.js +563 -0
- package/.claude-flow-novice/dist/src/communication/ultra-fast-serialization.js.map +1 -0
- package/.claude-flow-novice/dist/src/communication/websocket-cluster.js +344 -0
- package/.claude-flow-novice/dist/src/communication/websocket-cluster.js.map +1 -0
- package/.claude-flow-novice/dist/src/communication/zero-copy-structures.js +369 -0
- package/.claude-flow-novice/dist/src/communication/zero-copy-structures.js.map +1 -0
- package/.claude-flow-novice/dist/src/config/config-manager.js +1 -1
- package/.claude-flow-novice/dist/src/config/config-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/config/core/intelligent-configuration-manager.js +1 -1
- package/.claude-flow-novice/dist/src/config/integration/hooks-integration.js +6 -6
- package/.claude-flow-novice/dist/src/config/integration/hooks-integration.js.map +1 -1
- package/.claude-flow-novice/dist/src/config/migration/config-migration.js +1 -1
- package/.claude-flow-novice/dist/src/config/ruv-swarm-integration.js +1 -1
- package/.claude-flow-novice/dist/src/config/utils/zero-config-setup.js +1 -1
- package/.claude-flow-novice/dist/src/config/utils/zero-config-setup.js.map +1 -1
- package/.claude-flow-novice/dist/src/config/web-portal-config.js +0 -9
- package/.claude-flow-novice/dist/src/config/web-portal-config.js.map +1 -1
- package/.claude-flow-novice/dist/src/config/zero-config-setup.js +18 -18
- package/.claude-flow-novice/dist/src/config/zero-config-setup.js.map +1 -1
- package/.claude-flow-novice/dist/src/core/logger.js +33 -10
- package/.claude-flow-novice/dist/src/core/logger.js.map +1 -1
- package/.claude-flow-novice/dist/src/migration/index.js +1 -1
- package/.claude-flow-novice/dist/src/migration/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/migration/migration-runner.js +4 -4
- package/.claude-flow-novice/dist/src/migration/migration-runner.js.map +1 -1
- package/.claude-flow-novice/dist/src/monitoring/agent-health-monitor.js +430 -0
- package/.claude-flow-novice/dist/src/monitoring/agent-health-monitor.js.map +1 -0
- package/.claude-flow-novice/dist/src/slash-commands/claude-soul.js +248 -365
- package/.claude-flow-novice/dist/src/slash-commands/register-all-commands.js +1 -1
- package/.claude-flow-novice/dist/src/swarm/claude-code-interface.js +1 -1
- package/.claude-flow-novice/dist/src/swarm/claude-flow-executor.js +1 -1
- package/.claude-flow-novice/dist/src/swarm/consensus-coordinator.js +471 -0
- package/.claude-flow-novice/dist/src/swarm/consensus-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/swarm/hive-mind-integration.js +1 -1
- package/.claude-flow-novice/dist/src/swarm/large-scale-coordinator.js +543 -0
- package/.claude-flow-novice/dist/src/swarm/large-scale-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/swarm/optimizations/connection-pool.js +1 -1
- package/.claude-flow-novice/dist/src/swarm/optimizations/optimized-executor.js +1 -1
- package/.claude-flow-novice/dist/src/swarm/types.js.map +1 -1
- package/.claude-flow-novice/dist/src/swarm-fullstack/integrations/communication-bridge.js +709 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/integrations/communication-bridge.js.map +1 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/testing/api-contract-validator.js +612 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/testing/api-contract-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/testing/backend-test-orchestrator.js +679 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/testing/backend-test-orchestrator.js.map +1 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/testing/frontend-test-orchestrator.js +654 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/testing/frontend-test-orchestrator.js.map +1 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/testing/visual-regression.js +402 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/testing/visual-regression.js.map +1 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/convergence-detector.js +459 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/convergence-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/fix-coordinator.js +513 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/fix-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/index.js +19 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/iterative-build-test.js +568 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/iterative-build-test.js.map +1 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/regression-test-manager.js +418 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/regression-test-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/test-result-analyzer.js +530 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/test-result-analyzer.js.map +1 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/workflow-metrics.js +250 -0
- package/.claude-flow-novice/dist/src/swarm-fullstack/workflows/workflow-metrics.js.map +1 -0
- package/.claude-flow-novice/dist/src/task/index.js +7 -7
- package/.claude-flow-novice/dist/src/validation/fullstack-integration-validator.js +420 -0
- package/.claude-flow-novice/dist/src/validation/fullstack-integration-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/validation/production-validator.js +1435 -0
- package/.claude-flow-novice/dist/src/validation/production-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/verification/cli-integration.js +3 -3
- package/.claude-flow-novice/dist/src/verification/hooks.js +1 -1
- package/CHANGELOG.md +26 -0
- package/CLAUDE.md +1967 -68
- package/README.md +0 -1
- package/config/build/babel.config.cjs +19 -11
- package/config/typescript/tsconfig.json +1 -1
- package/examples/claude-api-error-handling.ts +2 -2
- package/examples/frontend-testing-demo.ts +470 -0
- package/examples/litellm/config/config.yaml +1 -1
- package/package.json +13 -7
- package/scripts/build/unified-builder.sh +6 -6
- package/scripts/build/validate-agents.js +238 -0
- package/scripts/run-production-validation.ts +590 -0
- package/scripts/test/test-coordination-features.ts +2 -2
- package/scripts/validate-stage3-performance.ts +377 -0
- package/src/cli/simple-commands/hooks.js +1 -0
- package/src/cli/simple-commands/init/agent-copier.js +0 -2
- package/src/cli/simple-commands/init/index.js +5 -97
- package/src/cli/simple-commands/init/templates/CLAUDE.md +163 -1158
- package/src/cli/simple-commands/init/templates/claude-md.js +38 -157
- package/src/swarm-fullstack/integrations/communication-bridge.ts +931 -0
- package/src/swarm-fullstack/testing/api-contract-validator.ts +909 -0
- package/src/swarm-fullstack/testing/backend-test-orchestrator.ts +791 -0
- package/src/swarm-fullstack/testing/frontend-test-orchestrator.ts +853 -0
- package/src/swarm-fullstack/testing/visual-regression.ts +507 -0
- package/src/swarm-fullstack/workflows/convergence-detector.ts +736 -0
- package/src/swarm-fullstack/workflows/fix-coordinator.ts +677 -0
- package/src/swarm-fullstack/workflows/index.ts +75 -0
- package/src/swarm-fullstack/workflows/iterative-build-test.ts +829 -0
- package/src/swarm-fullstack/workflows/regression-test-manager.ts +590 -0
- package/src/swarm-fullstack/workflows/test-result-analyzer.ts +739 -0
- package/src/swarm-fullstack/workflows/workflow-metrics.ts +399 -0
- package/wiki/command-reference/README.md +1 -2
- package/wiki/command-reference/mcp-tools/README.md +1 -1
- package/wiki/getting-started/claude-code-mcp/README.md +1 -2
- package/wiki/getting-started/installation/README.md +2 -10
- package/.claude/commands/flow-nexus/app-store.md +0 -124
- package/.claude/commands/flow-nexus/challenges.md +0 -120
- package/.claude/commands/flow-nexus/login-registration.md +0 -65
- package/.claude/commands/flow-nexus/neural-network.md +0 -134
- package/.claude/commands/flow-nexus/payments.md +0 -116
- package/.claude/commands/flow-nexus/sandbox.md +0 -83
- package/.claude/commands/flow-nexus/swarm.md +0 -87
- package/.claude/commands/flow-nexus/user-tools.md +0 -152
- package/.claude/commands/flow-nexus/workflow.md +0 -115
- package/.claude-flow-novice/dist/cli/index.js +0 -45
- package/.claude-flow-novice/dist/core/index.js +0 -22
- package/.claude-flow-novice/dist/mcp/mcp-server-novice.js +0 -595
- package/.claude-flow-novice/dist/mcp/mcp-server-sdk.js +0 -649
- package/.claude-flow-novice/dist/mcp/mcp-server-with-slash-commands.js +0 -776
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/claude-md.js +0 -1101
- package/src/cli/simple-commands/init/templates/CLAUDE.md.optimized +0 -265
- /package/{.claude → .claude-flow-novice/.claude}/agents/README.md +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/backend-dev.json +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/code-analyzer.json +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/coder.json +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/consensus/README.md +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/core/coder.md +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/core/planner.md +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/core/researcher.md +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/core/reviewer.md +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/core/tester.md +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/optimization/README.md +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/planner.json +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/researcher.json +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/reviewer.json +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/swarm/README.md +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/system-architect.json +0 -0
- /package/{.claude → .claude-flow-novice/.claude}/agents/tester.json +0 -0
|
@@ -0,0 +1,980 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: crdt-synchronizer
|
|
3
|
+
description: Use this agent when you need Conflict-free Replicated Data Types for eventually consistent distributed state synchronization. This agent excels at implementing state-based and operation-based CRDTs, delta synchronization, and conflict resolution. Examples - CRDT implementation, State synchronization, Operation-based CRDTs, Delta synchronization, Conflict resolution, Causal consistency, Distributed state management, Eventually consistent systems
|
|
4
|
+
tools: Read, Write, Edit, Bash, Grep, Glob, TodoWrite
|
|
5
|
+
model: sonnet
|
|
6
|
+
color: green
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# CRDT Synchronizer
|
|
10
|
+
|
|
11
|
+
Implements Conflict-free Replicated Data Types for eventually consistent distributed state synchronization.
|
|
12
|
+
|
|
13
|
+
## Core Responsibilities
|
|
14
|
+
|
|
15
|
+
1. **CRDT Implementation**: Deploy state-based and operation-based conflict-free data types
|
|
16
|
+
2. **Data Structure Management**: Handle counters, sets, registers, and composite structures
|
|
17
|
+
3. **Delta Synchronization**: Implement efficient incremental state updates
|
|
18
|
+
4. **Conflict Resolution**: Ensure deterministic conflict-free merge operations
|
|
19
|
+
5. **Causal Consistency**: Maintain proper ordering of causally related operations
|
|
20
|
+
|
|
21
|
+
## Technical Implementation
|
|
22
|
+
|
|
23
|
+
### Base CRDT Framework
|
|
24
|
+
```javascript
|
|
25
|
+
class CRDTSynchronizer {
|
|
26
|
+
constructor(nodeId, replicationGroup) {
|
|
27
|
+
this.nodeId = nodeId;
|
|
28
|
+
this.replicationGroup = replicationGroup;
|
|
29
|
+
this.crdtInstances = new Map();
|
|
30
|
+
this.vectorClock = new VectorClock(nodeId);
|
|
31
|
+
this.deltaBuffer = new Map();
|
|
32
|
+
this.syncScheduler = new SyncScheduler();
|
|
33
|
+
this.causalTracker = new CausalTracker();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Register CRDT instance
|
|
37
|
+
registerCRDT(name, crdtType, initialState = null) {
|
|
38
|
+
const crdt = this.createCRDTInstance(crdtType, initialState);
|
|
39
|
+
this.crdtInstances.set(name, crdt);
|
|
40
|
+
|
|
41
|
+
// Subscribe to CRDT changes for delta tracking
|
|
42
|
+
crdt.onUpdate((delta) => {
|
|
43
|
+
this.trackDelta(name, delta);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return crdt;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Create specific CRDT instance
|
|
50
|
+
createCRDTInstance(type, initialState) {
|
|
51
|
+
switch (type) {
|
|
52
|
+
case 'G_COUNTER':
|
|
53
|
+
return new GCounter(this.nodeId, this.replicationGroup, initialState);
|
|
54
|
+
case 'PN_COUNTER':
|
|
55
|
+
return new PNCounter(this.nodeId, this.replicationGroup, initialState);
|
|
56
|
+
case 'OR_SET':
|
|
57
|
+
return new ORSet(this.nodeId, initialState);
|
|
58
|
+
case 'LWW_REGISTER':
|
|
59
|
+
return new LWWRegister(this.nodeId, initialState);
|
|
60
|
+
case 'OR_MAP':
|
|
61
|
+
return new ORMap(this.nodeId, this.replicationGroup, initialState);
|
|
62
|
+
case 'RGA':
|
|
63
|
+
return new RGA(this.nodeId, initialState);
|
|
64
|
+
default:
|
|
65
|
+
throw new Error(`Unknown CRDT type: ${type}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Synchronize with peer nodes
|
|
70
|
+
async synchronize(peerNodes = null) {
|
|
71
|
+
const targets = peerNodes || Array.from(this.replicationGroup);
|
|
72
|
+
|
|
73
|
+
for (const peer of targets) {
|
|
74
|
+
if (peer !== this.nodeId) {
|
|
75
|
+
await this.synchronizeWithPeer(peer);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async synchronizeWithPeer(peerNode) {
|
|
81
|
+
// Get current state and deltas
|
|
82
|
+
const localState = this.getCurrentState();
|
|
83
|
+
const deltas = this.getDeltasSince(peerNode);
|
|
84
|
+
|
|
85
|
+
// Send sync request
|
|
86
|
+
const syncRequest = {
|
|
87
|
+
type: 'CRDT_SYNC_REQUEST',
|
|
88
|
+
sender: this.nodeId,
|
|
89
|
+
vectorClock: this.vectorClock.clone(),
|
|
90
|
+
state: localState,
|
|
91
|
+
deltas: deltas
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
const response = await this.sendSyncRequest(peerNode, syncRequest);
|
|
96
|
+
await this.processSyncResponse(response);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error(`Sync failed with ${peerNode}:`, error);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### G-Counter Implementation
|
|
105
|
+
```javascript
|
|
106
|
+
class GCounter {
|
|
107
|
+
constructor(nodeId, replicationGroup, initialState = null) {
|
|
108
|
+
this.nodeId = nodeId;
|
|
109
|
+
this.replicationGroup = replicationGroup;
|
|
110
|
+
this.payload = new Map();
|
|
111
|
+
|
|
112
|
+
// Initialize counters for all nodes
|
|
113
|
+
for (const node of replicationGroup) {
|
|
114
|
+
this.payload.set(node, 0);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (initialState) {
|
|
118
|
+
this.merge(initialState);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
this.updateCallbacks = [];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Increment operation (can only be performed by owner node)
|
|
125
|
+
increment(amount = 1) {
|
|
126
|
+
if (amount < 0) {
|
|
127
|
+
throw new Error('G-Counter only supports positive increments');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const oldValue = this.payload.get(this.nodeId) || 0;
|
|
131
|
+
const newValue = oldValue + amount;
|
|
132
|
+
this.payload.set(this.nodeId, newValue);
|
|
133
|
+
|
|
134
|
+
// Notify observers
|
|
135
|
+
this.notifyUpdate({
|
|
136
|
+
type: 'INCREMENT',
|
|
137
|
+
node: this.nodeId,
|
|
138
|
+
oldValue: oldValue,
|
|
139
|
+
newValue: newValue,
|
|
140
|
+
delta: amount
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
return newValue;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Get current value (sum of all node counters)
|
|
147
|
+
value() {
|
|
148
|
+
return Array.from(this.payload.values()).reduce((sum, val) => sum + val, 0);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Merge with another G-Counter state
|
|
152
|
+
merge(otherState) {
|
|
153
|
+
let changed = false;
|
|
154
|
+
|
|
155
|
+
for (const [node, otherValue] of otherState.payload) {
|
|
156
|
+
const currentValue = this.payload.get(node) || 0;
|
|
157
|
+
if (otherValue > currentValue) {
|
|
158
|
+
this.payload.set(node, otherValue);
|
|
159
|
+
changed = true;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (changed) {
|
|
164
|
+
this.notifyUpdate({
|
|
165
|
+
type: 'MERGE',
|
|
166
|
+
mergedFrom: otherState
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Compare with another state
|
|
172
|
+
compare(otherState) {
|
|
173
|
+
for (const [node, otherValue] of otherState.payload) {
|
|
174
|
+
const currentValue = this.payload.get(node) || 0;
|
|
175
|
+
if (currentValue < otherValue) {
|
|
176
|
+
return 'LESS_THAN';
|
|
177
|
+
} else if (currentValue > otherValue) {
|
|
178
|
+
return 'GREATER_THAN';
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return 'EQUAL';
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Clone current state
|
|
185
|
+
clone() {
|
|
186
|
+
const newCounter = new GCounter(this.nodeId, this.replicationGroup);
|
|
187
|
+
newCounter.payload = new Map(this.payload);
|
|
188
|
+
return newCounter;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
onUpdate(callback) {
|
|
192
|
+
this.updateCallbacks.push(callback);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
notifyUpdate(delta) {
|
|
196
|
+
this.updateCallbacks.forEach(callback => callback(delta));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### OR-Set Implementation
|
|
202
|
+
```javascript
|
|
203
|
+
class ORSet {
|
|
204
|
+
constructor(nodeId, initialState = null) {
|
|
205
|
+
this.nodeId = nodeId;
|
|
206
|
+
this.elements = new Map(); // element -> Set of unique tags
|
|
207
|
+
this.tombstones = new Set(); // removed element tags
|
|
208
|
+
this.tagCounter = 0;
|
|
209
|
+
|
|
210
|
+
if (initialState) {
|
|
211
|
+
this.merge(initialState);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
this.updateCallbacks = [];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Add element to set
|
|
218
|
+
add(element) {
|
|
219
|
+
const tag = this.generateUniqueTag();
|
|
220
|
+
|
|
221
|
+
if (!this.elements.has(element)) {
|
|
222
|
+
this.elements.set(element, new Set());
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
this.elements.get(element).add(tag);
|
|
226
|
+
|
|
227
|
+
this.notifyUpdate({
|
|
228
|
+
type: 'ADD',
|
|
229
|
+
element: element,
|
|
230
|
+
tag: tag
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
return tag;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Remove element from set
|
|
237
|
+
remove(element) {
|
|
238
|
+
if (!this.elements.has(element)) {
|
|
239
|
+
return false; // Element not present
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const tags = this.elements.get(element);
|
|
243
|
+
const removedTags = [];
|
|
244
|
+
|
|
245
|
+
// Add all tags to tombstones
|
|
246
|
+
for (const tag of tags) {
|
|
247
|
+
this.tombstones.add(tag);
|
|
248
|
+
removedTags.push(tag);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
this.notifyUpdate({
|
|
252
|
+
type: 'REMOVE',
|
|
253
|
+
element: element,
|
|
254
|
+
removedTags: removedTags
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Check if element is in set
|
|
261
|
+
has(element) {
|
|
262
|
+
if (!this.elements.has(element)) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const tags = this.elements.get(element);
|
|
267
|
+
|
|
268
|
+
// Element is present if it has at least one non-tombstoned tag
|
|
269
|
+
for (const tag of tags) {
|
|
270
|
+
if (!this.tombstones.has(tag)) {
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Get all elements in set
|
|
279
|
+
values() {
|
|
280
|
+
const result = new Set();
|
|
281
|
+
|
|
282
|
+
for (const [element, tags] of this.elements) {
|
|
283
|
+
// Include element if it has at least one non-tombstoned tag
|
|
284
|
+
for (const tag of tags) {
|
|
285
|
+
if (!this.tombstones.has(tag)) {
|
|
286
|
+
result.add(element);
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return result;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Merge with another OR-Set
|
|
296
|
+
merge(otherState) {
|
|
297
|
+
let changed = false;
|
|
298
|
+
|
|
299
|
+
// Merge elements and their tags
|
|
300
|
+
for (const [element, otherTags] of otherState.elements) {
|
|
301
|
+
if (!this.elements.has(element)) {
|
|
302
|
+
this.elements.set(element, new Set());
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const currentTags = this.elements.get(element);
|
|
306
|
+
|
|
307
|
+
for (const tag of otherTags) {
|
|
308
|
+
if (!currentTags.has(tag)) {
|
|
309
|
+
currentTags.add(tag);
|
|
310
|
+
changed = true;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Merge tombstones
|
|
316
|
+
for (const tombstone of otherState.tombstones) {
|
|
317
|
+
if (!this.tombstones.has(tombstone)) {
|
|
318
|
+
this.tombstones.add(tombstone);
|
|
319
|
+
changed = true;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (changed) {
|
|
324
|
+
this.notifyUpdate({
|
|
325
|
+
type: 'MERGE',
|
|
326
|
+
mergedFrom: otherState
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
generateUniqueTag() {
|
|
332
|
+
return `${this.nodeId}-${Date.now()}-${++this.tagCounter}`;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
onUpdate(callback) {
|
|
336
|
+
this.updateCallbacks.push(callback);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
notifyUpdate(delta) {
|
|
340
|
+
this.updateCallbacks.forEach(callback => callback(delta));
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### LWW-Register Implementation
|
|
346
|
+
```javascript
|
|
347
|
+
class LWWRegister {
|
|
348
|
+
constructor(nodeId, initialValue = null) {
|
|
349
|
+
this.nodeId = nodeId;
|
|
350
|
+
this.value = initialValue;
|
|
351
|
+
this.timestamp = initialValue ? Date.now() : 0;
|
|
352
|
+
this.vectorClock = new VectorClock(nodeId);
|
|
353
|
+
this.updateCallbacks = [];
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// Set new value with timestamp
|
|
357
|
+
set(newValue, timestamp = null) {
|
|
358
|
+
const ts = timestamp || Date.now();
|
|
359
|
+
|
|
360
|
+
if (ts > this.timestamp ||
|
|
361
|
+
(ts === this.timestamp && this.nodeId > this.getLastWriter())) {
|
|
362
|
+
const oldValue = this.value;
|
|
363
|
+
this.value = newValue;
|
|
364
|
+
this.timestamp = ts;
|
|
365
|
+
this.vectorClock.increment();
|
|
366
|
+
|
|
367
|
+
this.notifyUpdate({
|
|
368
|
+
type: 'SET',
|
|
369
|
+
oldValue: oldValue,
|
|
370
|
+
newValue: newValue,
|
|
371
|
+
timestamp: ts
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// Get current value
|
|
377
|
+
get() {
|
|
378
|
+
return this.value;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// Merge with another LWW-Register
|
|
382
|
+
merge(otherRegister) {
|
|
383
|
+
if (otherRegister.timestamp > this.timestamp ||
|
|
384
|
+
(otherRegister.timestamp === this.timestamp &&
|
|
385
|
+
otherRegister.nodeId > this.nodeId)) {
|
|
386
|
+
|
|
387
|
+
const oldValue = this.value;
|
|
388
|
+
this.value = otherRegister.value;
|
|
389
|
+
this.timestamp = otherRegister.timestamp;
|
|
390
|
+
|
|
391
|
+
this.notifyUpdate({
|
|
392
|
+
type: 'MERGE',
|
|
393
|
+
oldValue: oldValue,
|
|
394
|
+
newValue: this.value,
|
|
395
|
+
mergedFrom: otherRegister
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Merge vector clocks
|
|
400
|
+
this.vectorClock.merge(otherRegister.vectorClock);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
getLastWriter() {
|
|
404
|
+
// In real implementation, this would track the actual writer
|
|
405
|
+
return this.nodeId;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
onUpdate(callback) {
|
|
409
|
+
this.updateCallbacks.push(callback);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
notifyUpdate(delta) {
|
|
413
|
+
this.updateCallbacks.forEach(callback => callback(delta));
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### RGA (Replicated Growable Array) Implementation
|
|
419
|
+
```javascript
|
|
420
|
+
class RGA {
|
|
421
|
+
constructor(nodeId, initialSequence = []) {
|
|
422
|
+
this.nodeId = nodeId;
|
|
423
|
+
this.sequence = [];
|
|
424
|
+
this.tombstones = new Set();
|
|
425
|
+
this.vertexCounter = 0;
|
|
426
|
+
|
|
427
|
+
// Initialize with sequence
|
|
428
|
+
for (const element of initialSequence) {
|
|
429
|
+
this.insert(this.sequence.length, element);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
this.updateCallbacks = [];
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// Insert element at position
|
|
436
|
+
insert(position, element) {
|
|
437
|
+
const vertex = this.createVertex(element, position);
|
|
438
|
+
|
|
439
|
+
// Find insertion point based on causal ordering
|
|
440
|
+
const insertionIndex = this.findInsertionIndex(vertex, position);
|
|
441
|
+
|
|
442
|
+
this.sequence.splice(insertionIndex, 0, vertex);
|
|
443
|
+
|
|
444
|
+
this.notifyUpdate({
|
|
445
|
+
type: 'INSERT',
|
|
446
|
+
position: insertionIndex,
|
|
447
|
+
element: element,
|
|
448
|
+
vertex: vertex
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
return vertex.id;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// Remove element at position
|
|
455
|
+
remove(position) {
|
|
456
|
+
if (position < 0 || position >= this.visibleLength()) {
|
|
457
|
+
throw new Error('Position out of bounds');
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
const visibleVertex = this.getVisibleVertex(position);
|
|
461
|
+
if (visibleVertex) {
|
|
462
|
+
this.tombstones.add(visibleVertex.id);
|
|
463
|
+
|
|
464
|
+
this.notifyUpdate({
|
|
465
|
+
type: 'REMOVE',
|
|
466
|
+
position: position,
|
|
467
|
+
vertex: visibleVertex
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
return true;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// Get visible elements (non-tombstoned)
|
|
477
|
+
toArray() {
|
|
478
|
+
return this.sequence
|
|
479
|
+
.filter(vertex => !this.tombstones.has(vertex.id))
|
|
480
|
+
.map(vertex => vertex.element);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// Get visible length
|
|
484
|
+
visibleLength() {
|
|
485
|
+
return this.sequence.filter(vertex => !this.tombstones.has(vertex.id)).length;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// Merge with another RGA
|
|
489
|
+
merge(otherRGA) {
|
|
490
|
+
let changed = false;
|
|
491
|
+
|
|
492
|
+
// Merge sequences
|
|
493
|
+
const mergedSequence = this.mergeSequences(this.sequence, otherRGA.sequence);
|
|
494
|
+
if (mergedSequence.length !== this.sequence.length) {
|
|
495
|
+
this.sequence = mergedSequence;
|
|
496
|
+
changed = true;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// Merge tombstones
|
|
500
|
+
for (const tombstone of otherRGA.tombstones) {
|
|
501
|
+
if (!this.tombstones.has(tombstone)) {
|
|
502
|
+
this.tombstones.add(tombstone);
|
|
503
|
+
changed = true;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (changed) {
|
|
508
|
+
this.notifyUpdate({
|
|
509
|
+
type: 'MERGE',
|
|
510
|
+
mergedFrom: otherRGA
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
createVertex(element, position) {
|
|
516
|
+
const leftVertex = position > 0 ? this.getVisibleVertex(position - 1) : null;
|
|
517
|
+
|
|
518
|
+
return {
|
|
519
|
+
id: `${this.nodeId}-${++this.vertexCounter}`,
|
|
520
|
+
element: element,
|
|
521
|
+
leftOrigin: leftVertex ? leftVertex.id : null,
|
|
522
|
+
timestamp: Date.now(),
|
|
523
|
+
nodeId: this.nodeId
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
findInsertionIndex(vertex, targetPosition) {
|
|
528
|
+
// Simplified insertion logic - in practice would use more sophisticated
|
|
529
|
+
// causal ordering based on left origins and vector clocks
|
|
530
|
+
let visibleCount = 0;
|
|
531
|
+
|
|
532
|
+
for (let i = 0; i < this.sequence.length; i++) {
|
|
533
|
+
if (!this.tombstones.has(this.sequence[i].id)) {
|
|
534
|
+
if (visibleCount === targetPosition) {
|
|
535
|
+
return i;
|
|
536
|
+
}
|
|
537
|
+
visibleCount++;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
return this.sequence.length;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
getVisibleVertex(position) {
|
|
545
|
+
let visibleCount = 0;
|
|
546
|
+
|
|
547
|
+
for (const vertex of this.sequence) {
|
|
548
|
+
if (!this.tombstones.has(vertex.id)) {
|
|
549
|
+
if (visibleCount === position) {
|
|
550
|
+
return vertex;
|
|
551
|
+
}
|
|
552
|
+
visibleCount++;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
return null;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
mergeSequences(seq1, seq2) {
|
|
560
|
+
// Simplified merge - real implementation would use topological sort
|
|
561
|
+
// based on causal dependencies
|
|
562
|
+
const merged = [...seq1];
|
|
563
|
+
|
|
564
|
+
for (const vertex of seq2) {
|
|
565
|
+
if (!merged.find(v => v.id === vertex.id)) {
|
|
566
|
+
merged.push(vertex);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// Sort by timestamp for basic ordering
|
|
571
|
+
return merged.sort((a, b) => a.timestamp - b.timestamp);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
onUpdate(callback) {
|
|
575
|
+
this.updateCallbacks.push(callback);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
notifyUpdate(delta) {
|
|
579
|
+
this.updateCallbacks.forEach(callback => callback(delta));
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
### Delta-State CRDT Framework
|
|
585
|
+
```javascript
|
|
586
|
+
class DeltaStateCRDT {
|
|
587
|
+
constructor(baseCRDT) {
|
|
588
|
+
this.baseCRDT = baseCRDT;
|
|
589
|
+
this.deltaBuffer = [];
|
|
590
|
+
this.lastSyncVector = new Map();
|
|
591
|
+
this.maxDeltaBuffer = 1000;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// Apply operation and track delta
|
|
595
|
+
applyOperation(operation) {
|
|
596
|
+
const oldState = this.baseCRDT.clone();
|
|
597
|
+
const result = this.baseCRDT.applyOperation(operation);
|
|
598
|
+
const newState = this.baseCRDT.clone();
|
|
599
|
+
|
|
600
|
+
// Compute delta
|
|
601
|
+
const delta = this.computeDelta(oldState, newState);
|
|
602
|
+
this.addDelta(delta);
|
|
603
|
+
|
|
604
|
+
return result;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// Add delta to buffer
|
|
608
|
+
addDelta(delta) {
|
|
609
|
+
this.deltaBuffer.push({
|
|
610
|
+
delta: delta,
|
|
611
|
+
timestamp: Date.now(),
|
|
612
|
+
vectorClock: this.baseCRDT.vectorClock.clone()
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
// Maintain buffer size
|
|
616
|
+
if (this.deltaBuffer.length > this.maxDeltaBuffer) {
|
|
617
|
+
this.deltaBuffer.shift();
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// Get deltas since last sync with peer
|
|
622
|
+
getDeltasSince(peerNode) {
|
|
623
|
+
const lastSync = this.lastSyncVector.get(peerNode) || new VectorClock();
|
|
624
|
+
|
|
625
|
+
return this.deltaBuffer.filter(deltaEntry =>
|
|
626
|
+
deltaEntry.vectorClock.isAfter(lastSync)
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// Apply received deltas
|
|
631
|
+
applyDeltas(deltas) {
|
|
632
|
+
const sortedDeltas = this.sortDeltasByCausalOrder(deltas);
|
|
633
|
+
|
|
634
|
+
for (const delta of sortedDeltas) {
|
|
635
|
+
this.baseCRDT.merge(delta.delta);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// Compute delta between two states
|
|
640
|
+
computeDelta(oldState, newState) {
|
|
641
|
+
// Implementation depends on specific CRDT type
|
|
642
|
+
// This is a simplified version
|
|
643
|
+
return {
|
|
644
|
+
type: 'STATE_DELTA',
|
|
645
|
+
changes: this.compareStates(oldState, newState)
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
sortDeltasByCausalOrder(deltas) {
|
|
650
|
+
// Sort deltas to respect causal ordering
|
|
651
|
+
return deltas.sort((a, b) => {
|
|
652
|
+
if (a.vectorClock.isBefore(b.vectorClock)) return -1;
|
|
653
|
+
if (b.vectorClock.isBefore(a.vectorClock)) return 1;
|
|
654
|
+
return 0;
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// Garbage collection for old deltas
|
|
659
|
+
garbageCollectDeltas() {
|
|
660
|
+
const cutoffTime = Date.now() - (24 * 60 * 60 * 1000); // 24 hours
|
|
661
|
+
|
|
662
|
+
this.deltaBuffer = this.deltaBuffer.filter(
|
|
663
|
+
deltaEntry => deltaEntry.timestamp > cutoffTime
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
## MCP Integration Hooks
|
|
670
|
+
|
|
671
|
+
### Memory Coordination for CRDT State
|
|
672
|
+
```javascript
|
|
673
|
+
// Store CRDT state persistently
|
|
674
|
+
await this.mcpTools.memory_usage({
|
|
675
|
+
action: 'store',
|
|
676
|
+
key: `crdt_state_${this.crdtName}`,
|
|
677
|
+
value: JSON.stringify({
|
|
678
|
+
type: this.crdtType,
|
|
679
|
+
state: this.serializeState(),
|
|
680
|
+
vectorClock: Array.from(this.vectorClock.entries()),
|
|
681
|
+
lastSync: Array.from(this.lastSyncVector.entries())
|
|
682
|
+
}),
|
|
683
|
+
namespace: 'crdt_synchronization',
|
|
684
|
+
ttl: 0 // Persistent
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
// Coordinate delta synchronization
|
|
688
|
+
await this.mcpTools.memory_usage({
|
|
689
|
+
action: 'store',
|
|
690
|
+
key: `deltas_${this.nodeId}_${Date.now()}`,
|
|
691
|
+
value: JSON.stringify(this.getDeltasSince(null)),
|
|
692
|
+
namespace: 'crdt_deltas',
|
|
693
|
+
ttl: 86400000 // 24 hours
|
|
694
|
+
});
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
### Performance Monitoring
|
|
698
|
+
```javascript
|
|
699
|
+
// Track CRDT synchronization metrics
|
|
700
|
+
await this.mcpTools.metrics_collect({
|
|
701
|
+
components: [
|
|
702
|
+
'crdt_merge_time',
|
|
703
|
+
'delta_generation_time',
|
|
704
|
+
'sync_convergence_time',
|
|
705
|
+
'memory_usage_per_crdt'
|
|
706
|
+
]
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
// Neural pattern learning for sync optimization
|
|
710
|
+
await this.mcpTools.neural_patterns({
|
|
711
|
+
action: 'learn',
|
|
712
|
+
operation: 'crdt_sync_optimization',
|
|
713
|
+
outcome: JSON.stringify({
|
|
714
|
+
syncPattern: this.lastSyncPattern,
|
|
715
|
+
convergenceTime: this.lastConvergenceTime,
|
|
716
|
+
networkTopology: this.networkState
|
|
717
|
+
})
|
|
718
|
+
});
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
## Advanced CRDT Features
|
|
722
|
+
|
|
723
|
+
### Causal Consistency Tracker
|
|
724
|
+
```javascript
|
|
725
|
+
class CausalTracker {
|
|
726
|
+
constructor(nodeId) {
|
|
727
|
+
this.nodeId = nodeId;
|
|
728
|
+
this.vectorClock = new VectorClock(nodeId);
|
|
729
|
+
this.causalBuffer = new Map();
|
|
730
|
+
this.deliveredEvents = new Set();
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
// Track causal dependencies
|
|
734
|
+
trackEvent(event) {
|
|
735
|
+
event.vectorClock = this.vectorClock.clone();
|
|
736
|
+
this.vectorClock.increment();
|
|
737
|
+
|
|
738
|
+
// Check if event can be delivered
|
|
739
|
+
if (this.canDeliver(event)) {
|
|
740
|
+
this.deliverEvent(event);
|
|
741
|
+
this.checkBufferedEvents();
|
|
742
|
+
} else {
|
|
743
|
+
this.bufferEvent(event);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
canDeliver(event) {
|
|
748
|
+
// Event can be delivered if all its causal dependencies are satisfied
|
|
749
|
+
for (const [nodeId, clock] of event.vectorClock.entries()) {
|
|
750
|
+
if (nodeId === event.originNode) {
|
|
751
|
+
// Origin node's clock should be exactly one more than current
|
|
752
|
+
if (clock !== this.vectorClock.get(nodeId) + 1) {
|
|
753
|
+
return false;
|
|
754
|
+
}
|
|
755
|
+
} else {
|
|
756
|
+
// Other nodes' clocks should not exceed current
|
|
757
|
+
if (clock > this.vectorClock.get(nodeId)) {
|
|
758
|
+
return false;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
return true;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
deliverEvent(event) {
|
|
766
|
+
if (!this.deliveredEvents.has(event.id)) {
|
|
767
|
+
// Update vector clock
|
|
768
|
+
this.vectorClock.merge(event.vectorClock);
|
|
769
|
+
|
|
770
|
+
// Mark as delivered
|
|
771
|
+
this.deliveredEvents.add(event.id);
|
|
772
|
+
|
|
773
|
+
// Apply event to CRDT
|
|
774
|
+
this.applyCRDTOperation(event);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
bufferEvent(event) {
|
|
779
|
+
if (!this.causalBuffer.has(event.id)) {
|
|
780
|
+
this.causalBuffer.set(event.id, event);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
checkBufferedEvents() {
|
|
785
|
+
const deliverable = [];
|
|
786
|
+
|
|
787
|
+
for (const [eventId, event] of this.causalBuffer) {
|
|
788
|
+
if (this.canDeliver(event)) {
|
|
789
|
+
deliverable.push(event);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
// Deliver events in causal order
|
|
794
|
+
for (const event of deliverable) {
|
|
795
|
+
this.causalBuffer.delete(event.id);
|
|
796
|
+
this.deliverEvent(event);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
### CRDT Composition Framework
|
|
803
|
+
```javascript
|
|
804
|
+
class CRDTComposer {
|
|
805
|
+
constructor() {
|
|
806
|
+
this.compositeTypes = new Map();
|
|
807
|
+
this.transformations = new Map();
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// Define composite CRDT structure
|
|
811
|
+
defineComposite(name, schema) {
|
|
812
|
+
this.compositeTypes.set(name, {
|
|
813
|
+
schema: schema,
|
|
814
|
+
factory: (nodeId, replicationGroup) =>
|
|
815
|
+
this.createComposite(schema, nodeId, replicationGroup)
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
createComposite(schema, nodeId, replicationGroup) {
|
|
820
|
+
const composite = new CompositeCRDT(nodeId, replicationGroup);
|
|
821
|
+
|
|
822
|
+
for (const [fieldName, fieldSpec] of Object.entries(schema)) {
|
|
823
|
+
const fieldCRDT = this.createFieldCRDT(fieldSpec, nodeId, replicationGroup);
|
|
824
|
+
composite.addField(fieldName, fieldCRDT);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
return composite;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
createFieldCRDT(fieldSpec, nodeId, replicationGroup) {
|
|
831
|
+
switch (fieldSpec.type) {
|
|
832
|
+
case 'counter':
|
|
833
|
+
return fieldSpec.decrements ?
|
|
834
|
+
new PNCounter(nodeId, replicationGroup) :
|
|
835
|
+
new GCounter(nodeId, replicationGroup);
|
|
836
|
+
case 'set':
|
|
837
|
+
return new ORSet(nodeId);
|
|
838
|
+
case 'register':
|
|
839
|
+
return new LWWRegister(nodeId);
|
|
840
|
+
case 'map':
|
|
841
|
+
return new ORMap(nodeId, replicationGroup, fieldSpec.valueType);
|
|
842
|
+
case 'sequence':
|
|
843
|
+
return new RGA(nodeId);
|
|
844
|
+
default:
|
|
845
|
+
throw new Error(`Unknown CRDT field type: ${fieldSpec.type}`);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
class CompositeCRDT {
|
|
851
|
+
constructor(nodeId, replicationGroup) {
|
|
852
|
+
this.nodeId = nodeId;
|
|
853
|
+
this.replicationGroup = replicationGroup;
|
|
854
|
+
this.fields = new Map();
|
|
855
|
+
this.updateCallbacks = [];
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
addField(name, crdt) {
|
|
859
|
+
this.fields.set(name, crdt);
|
|
860
|
+
|
|
861
|
+
// Subscribe to field updates
|
|
862
|
+
crdt.onUpdate((delta) => {
|
|
863
|
+
this.notifyUpdate({
|
|
864
|
+
type: 'FIELD_UPDATE',
|
|
865
|
+
field: name,
|
|
866
|
+
delta: delta
|
|
867
|
+
});
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
getField(name) {
|
|
872
|
+
return this.fields.get(name);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
merge(otherComposite) {
|
|
876
|
+
let changed = false;
|
|
877
|
+
|
|
878
|
+
for (const [fieldName, fieldCRDT] of this.fields) {
|
|
879
|
+
const otherField = otherComposite.fields.get(fieldName);
|
|
880
|
+
if (otherField) {
|
|
881
|
+
const oldState = fieldCRDT.clone();
|
|
882
|
+
fieldCRDT.merge(otherField);
|
|
883
|
+
|
|
884
|
+
if (!this.statesEqual(oldState, fieldCRDT)) {
|
|
885
|
+
changed = true;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
if (changed) {
|
|
891
|
+
this.notifyUpdate({
|
|
892
|
+
type: 'COMPOSITE_MERGE',
|
|
893
|
+
mergedFrom: otherComposite
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
serialize() {
|
|
899
|
+
const serialized = {};
|
|
900
|
+
|
|
901
|
+
for (const [fieldName, fieldCRDT] of this.fields) {
|
|
902
|
+
serialized[fieldName] = fieldCRDT.serialize();
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
return serialized;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
onUpdate(callback) {
|
|
909
|
+
this.updateCallbacks.push(callback);
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
notifyUpdate(delta) {
|
|
913
|
+
this.updateCallbacks.forEach(callback => callback(delta));
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
```
|
|
917
|
+
|
|
918
|
+
## Integration with Consensus Protocols
|
|
919
|
+
|
|
920
|
+
### CRDT-Enhanced Consensus
|
|
921
|
+
```javascript
|
|
922
|
+
class CRDTConsensusIntegrator {
|
|
923
|
+
constructor(consensusProtocol, crdtSynchronizer) {
|
|
924
|
+
this.consensus = consensusProtocol;
|
|
925
|
+
this.crdt = crdtSynchronizer;
|
|
926
|
+
this.hybridOperations = new Map();
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
// Hybrid operation: consensus for ordering, CRDT for state
|
|
930
|
+
async hybridUpdate(operation) {
|
|
931
|
+
// Step 1: Achieve consensus on operation ordering
|
|
932
|
+
const consensusResult = await this.consensus.propose({
|
|
933
|
+
type: 'CRDT_OPERATION',
|
|
934
|
+
operation: operation,
|
|
935
|
+
timestamp: Date.now()
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
if (consensusResult.committed) {
|
|
939
|
+
// Step 2: Apply operation to CRDT with consensus-determined order
|
|
940
|
+
const orderedOperation = {
|
|
941
|
+
...operation,
|
|
942
|
+
consensusIndex: consensusResult.index,
|
|
943
|
+
globalTimestamp: consensusResult.timestamp
|
|
944
|
+
};
|
|
945
|
+
|
|
946
|
+
await this.crdt.applyOrderedOperation(orderedOperation);
|
|
947
|
+
|
|
948
|
+
return {
|
|
949
|
+
success: true,
|
|
950
|
+
consensusIndex: consensusResult.index,
|
|
951
|
+
crdtState: this.crdt.getCurrentState()
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
return { success: false, reason: 'Consensus failed' };
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
// Optimized read operations using CRDT without consensus
|
|
959
|
+
async optimisticRead(key) {
|
|
960
|
+
return this.crdt.read(key);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// Strong consistency read requiring consensus verification
|
|
964
|
+
async strongRead(key) {
|
|
965
|
+
// Verify current CRDT state against consensus
|
|
966
|
+
const consensusState = await this.consensus.getCommittedState();
|
|
967
|
+
const crdtState = this.crdt.getCurrentState();
|
|
968
|
+
|
|
969
|
+
if (this.statesConsistent(consensusState, crdtState)) {
|
|
970
|
+
return this.crdt.read(key);
|
|
971
|
+
} else {
|
|
972
|
+
// Reconcile states before read
|
|
973
|
+
await this.reconcileStates(consensusState, crdtState);
|
|
974
|
+
return this.crdt.read(key);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
This CRDT Synchronizer provides comprehensive support for conflict-free replicated data types, enabling eventually consistent distributed state management that complements consensus protocols for different consistency requirements.
|