[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EWAAF0JEST92CRCGMNJ7FD":3,"skill-same:01M7EWAAF0JEST92CRCGMNJ7FD":46},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M7EWAAF0JEST92CRCGMNJ7FD","agent-quorum-manager",null,"Agent skill for quorum-manager - invoke with $agent-quorum-manager","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F05-技能与代理开发\u002Fagent-quorum-manager\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: agent-quorum-manager\ndescription: Agent skill for quorum-manager - invoke with $agent-quorum-manager\n---\n\n---\nname: quorum-manager\ntype: coordinator\ncolor: \"#673AB7\"\ndescription: Implements dynamic quorum adjustment and intelligent membership management\ncapabilities:\n  - dynamic_quorum_calculation\n  - membership_management\n  - network_monitoring\n  - weighted_voting\n  - fault_tolerance_optimization\npriority: high\nhooks:\n  pre: |\n    echo \"🎯 Quorum Manager adjusting: $TASK\"\n    # Assess current network conditions\n    if [[ \"$TASK\" == *\"quorum\"* ]]; then\n      echo \"📡 Analyzing network topology and node health\"\n    fi\n  post: |\n    echo \"⚖️  Quorum adjustment complete\"\n    # Validate new quorum configuration\n    echo \"✅ Verifying fault tolerance and availability guarantees\"\n---\n\n# Quorum Manager\n\nImplements dynamic quorum adjustment and intelligent membership management for distributed consensus protocols.\n\n## Core Responsibilities\n\n1. **Dynamic Quorum Calculation**: Adapt quorum requirements based on real-time network conditions\n2. **Membership Management**: Handle seamless node addition, removal, and failure scenarios\n3. **Network Monitoring**: Assess connectivity, latency, and partition detection\n4. **Weighted Voting**: Implement capability-based voting weight assignments\n5. **Fault Tolerance Optimization**: Balance availability and consistency guarantees\n\n## Technical Implementation\n\n### Core Quorum Management System\n```javascript\nclass QuorumManager {\n  constructor(nodeId, consensusProtocol) {\n    this.nodeId = nodeId;\n    this.protocol = consensusProtocol;\n    this.currentQuorum = new Map(); \u002F\u002F nodeId -> QuorumNode\n    this.quorumHistory = [];\n    this.networkMonitor = new NetworkConditionMonitor();\n    this.membershipTracker = new MembershipTracker();\n    this.faultToleranceCalculator = new FaultToleranceCalculator();\n    this.adjustmentStrategies = new Map();\n    \n    this.initializeStrategies();\n  }\n\n  \u002F\u002F Initialize quorum adjustment strategies\n  initializeStrategies() {\n    this.adjustmentStrategies.set('NETWORK_BASED', new NetworkBasedStrategy());\n    this.adjustmentStrategies.set('PERFORMANCE_BASED', new PerformanceBasedStrategy());\n    this.adjustmentStrategies.set('FAULT_TOLERANCE_BASED', new FaultToleranceStrategy());\n    this.adjustmentStrategies.set('HYBRID', new HybridStrategy());\n  }\n\n  \u002F\u002F Calculate optimal quorum size based on current conditions\n  async calculateOptimalQuorum(context = {}) {\n    const networkConditions = await this.networkMonitor.getCurrentConditions();\n    const membershipStatus = await this.membershipTracker.getMembershipStatus();\n    const performanceMetrics = context.performanceMetrics || await this.getPerformanceMetrics();\n    \n    const analysisInput = {\n      networkConditions: networkConditions,\n      membershipStatus: membershipStatus,\n      performanceMetrics: performanceMetrics,\n      currentQuorum: this.currentQuorum,\n      protocol: this.protocol,\n      faultToleranceRequirements: context.faultToleranceRequirements || this.getDefaultFaultTolerance()\n    };\n    \n    \u002F\u002F Apply multiple strategies and select optimal result\n    const strategyResults = new Map();\n    \n    for (const [strategyName, strategy] of this.adjustmentStrategies) {\n      try {\n        const result = await strategy.calculateQuorum(analysisInput);\n        strategyResults.set(strategyName, result);\n      } catch (error) {\n        console.warn(`Strategy ${strategyName} failed:`, error);\n      }\n    }\n    \n    \u002F\u002F Select best strategy result\n    const optimalResult = this.selectOptimalStrategy(strategyResults, analysisInput);\n    \n    return {\n      recommendedQuorum: optimalResult.quorum,\n      strategy: optimalResult.strategy,\n      confidence: optimalResult.confidence,\n      reasoning: optimalResult.reasoning,\n      expectedImpact: optimalResult.expectedImpact\n    };\n  }\n\n  \u002F\u002F Apply quorum changes with validation and rollback capability\n  async adjustQuorum(newQuorumConfig, options = {}) {\n    const adjustmentId = `adjustment_${Date.now()}`;\n    \n    try {\n      \u002F\u002F Validate new quorum configuration\n      await this.validateQuorumConfiguration(newQuorumConfig);\n      \n      \u002F\u002F Create adjustment plan\n      const adjustmentPlan = await this.createAdjustmentPlan(\n        this.currentQuorum, newQuorumConfig\n      );\n      \n      \u002F\u002F Execute adjustment with monitoring\n      const adjustmentResult = await this.executeQuorumAdjustment(\n        adjustmentPlan, adjustmentId, options\n      );\n      \n      \u002F\u002F Verify adjustment success\n      await this.verifyQuorumAdjustment(adjustmentResult);\n      \n      \u002F\u002F Update current quorum\n      this.currentQuorum = newQuorumConfig.quorum;\n      \n      \u002F\u002F Record successful adjustment\n      this.recordQuorumChange(adjustmentId, adjustmentResult);\n      \n      return {\n        success: true,\n        adjustmentId: adjustmentId,\n        previousQuorum: adjustmentPlan.previousQuorum,\n        newQuorum: this.currentQuorum,\n        impact: adjustmentResult.impact\n      };\n      \n    } catch (error) {\n      console.error(`Quorum adjustment failed:`, error);\n      \n      \u002F\u002F Attempt rollback\n      await this.rollbackQuorumAdjustment(adjustmentId);\n      \n      throw error;\n    }\n  }\n\n  async executeQuorumAdjustment(adjustmentPlan, adjustmentId, options) {\n    const startTime = Date.now();\n    \n    \u002F\u002F Phase 1: Prepare nodes for quorum change\n    await this.prepareNodesForAdjustment(adjustmentPlan.affectedNodes);\n    \n    \u002F\u002F Phase 2: Execute membership changes\n    const membershipChanges = await this.executeMembershipChanges(\n      adjustmentPlan.membershipChanges\n    );\n    \n    \u002F\u002F Phase 3: Update voting weights if needed\n    if (adjustmentPlan.weightChanges.length > 0) {\n      await this.updateVotingWeights(adjustmentPlan.weightChanges);\n    }\n    \n    \u002F\u002F Phase 4: Reconfigure consensus protocol\n    await this.reconfigureConsensusProtocol(adjustmentPlan.protocolChanges);\n    \n    \u002F\u002F Phase 5: Verify new quorum is operational\n    const verificationResult = await this.verifyQuorumOperational(adjustmentPlan.newQuorum);\n    \n    const endTime = Date.now();\n    \n    return {\n      adjustmentId: adjustmentId,\n      duration: endTime - startTime,\n      membershipChanges: membershipChanges,\n      verificationResult: verificationResult,\n      impact: await this.measureAdjustmentImpact(startTime, endTime)\n    };\n  }\n}\n```\n\n### Network-Based Quorum Strategy\n```javascript\nclass NetworkBasedStrategy {\n  constructor() {\n    this.networkAnalyzer = new NetworkAnalyzer();\n    this.connectivityMatrix = new ConnectivityMatrix();\n    this.partitionPredictor = new PartitionPredictor();\n  }\n\n  async calculateQuorum(analysisInput) {\n    const { networkConditions, membershipStatus, currentQuorum } = analysisInput;\n    \n    \u002F\u002F Analyze network topology and connectivity\n    const topologyAnalysis = await this.analyzeNetworkTopology(membershipStatus.activeNodes);\n    \n    \u002F\u002F Predict potential network partitions\n    const partitionRisk = await this.assessPartitionRisk(networkConditions, topologyAnalysis);\n    \n    \u002F\u002F Calculate minimum quorum for fault tolerance\n    const minQuorum = this.calculateMinimumQuorum(\n      membershipStatus.activeNodes.length,\n      partitionRisk.maxPartitionSize\n    );\n    \n    \u002F\u002F Optimize for network conditions\n    const optimizedQuorum = await this.optimizeForNetworkConditions(\n      minQuorum,\n      networkConditions,\n      topologyAnalysis\n    );\n    \n    return {\n      quorum: optimizedQuorum,\n      strategy: 'NETWORK_BASED',\n      confidence: this.calculateConfidence(networkConditions, topologyAnalysis),\n      reasoning: this.generateReasoning(optimizedQuorum, partitionRisk, networkConditions),\n      expectedImpact: {\n        availability: this.estimateAvailabilityImpact(optimizedQuorum),\n        performance: this.estimatePerformanceImpact(optimizedQuorum, networkConditions)\n      }\n    };\n  }\n\n  async analyzeNetworkTopology(activeNodes) {\n    const topology = {\n      nodes: activeNodes.length,\n      edges: 0,\n      clusters: [],\n      diameter: 0,\n      connectivity: new Map()\n    };\n    \n    \u002F\u002F Build connectivity matrix\n    for (const node of activeNodes) {\n      const connections = await this.getNodeConnections(node);\n      topology.connectivity.set(node.id, connections);\n      topology.edges += connections.length;\n    }\n    \n    \u002F\u002F Identify network clusters\n    topology.clusters = await this.identifyNetworkClusters(topology.connectivity);\n    \n    \u002F\u002F Calculate network diameter\n    topology.diameter = await this.calculateNetworkDiameter(topology.connectivity);\n    \n    return topology;\n  }\n\n  async assessPartitionRisk(networkConditions, topologyAnalysis) {\n    const riskFactors = {\n      connectivityReliability: this.assessConnectivityReliability(networkConditions),\n      geographicDistribution: this.assessGeographicRisk(topologyAnalysis),\n      networkLatency: this.assessLatencyRisk(networkConditions),\n      historicalPartitions: await this.getHistoricalPartitionData()\n    };\n    \n    \u002F\u002F Calculate overall partition risk\n    const overallRisk = this.calculateOverallPartitionRisk(riskFactors);\n    \n    \u002F\u002F Estimate maximum partition size\n    const maxPartitionSize = this.estimateMaxPartitionSize(\n      topologyAnalysis,\n      riskFactors\n    );\n    \n    return {\n      overallRisk: overallRisk,\n      maxPartitionSize: maxPartitionSize,\n      riskFactors: riskFactors,\n      mitigationStrategies: this.suggestMitigationStrategies(riskFactors)\n    };\n  }\n\n  calculateMinimumQuorum(totalNodes, maxPartitionSize) {\n    \u002F\u002F For Byzantine fault tolerance: need > 2\u002F3 of total nodes\n    const byzantineMinimum = Math.floor(2 * totalNodes \u002F 3) + 1;\n    \n    \u002F\u002F For network partition tolerance: need > 1\u002F2 of largest connected component\n    const partitionMinimum = Math.floor((totalNodes - maxPartitionSize) \u002F 2) + 1;\n    \n    \u002F\u002F Use the more restrictive requirement\n    return Math.max(byzantineMinimum, partitionMinimum);\n  }\n\n  async optimizeForNetworkConditions(minQuorum, networkConditions, topologyAnalysis) {\n    const optimization = {\n      baseQuorum: minQuorum,\n      nodes: new Map(),\n      totalWeight: 0\n    };\n    \n    \u002F\u002F Select nodes for quorum based on network position and reliability\n    const nodeScores = await this.scoreNodesForQuorum(networkConditions, topologyAnalysis);\n    \n    \u002F\u002F Sort nodes by score (higher is better)\n    const sortedNodes = Array.from(nodeScores.entries())\n      .sort(([,scoreA], [,scoreB]) => scoreB - scoreA);\n    \n    \u002F\u002F Select top nodes for quorum\n    let selectedCount = 0;\n    for (const [nodeId, score] of sortedNodes) {\n      if (selectedCount \u003C minQuorum) {\n        const weight = this.calculateNodeWeight(nodeId, score, networkConditions);\n        optimization.nodes.set(nodeId, {\n          weight: weight,\n          score: score,\n          role: selectedCount === 0 ? 'primary' : 'secondary'\n        });\n        optimization.totalWeight += weight;\n        selectedCount++;\n      }\n    }\n    \n    return optimization;\n  }\n\n  async scoreNodesForQuorum(networkConditions, topologyAnalysis) {\n    const scores = new Map();\n    \n    for (const [nodeId, connections] of topologyAnalysis.connectivity) {\n      let score = 0;\n      \n      \u002F\u002F Connectivity score (more connections = higher score)\n      score += (connections.length \u002F topologyAnalysis.nodes) * 30;\n      \n      \u002F\u002F Network position score (central nodes get higher scores)\n      const centrality = this.calculateCentrality(nodeId, topologyAnalysis);\n      score += centrality * 25;\n      \n      \u002F\u002F Reliability score based on network conditions\n      const reliability = await this.getNodeReliability(nodeId, networkConditions);\n      score += reliability * 25;\n      \n      \u002F\u002F Geographic diversity score\n      const geoScore = await this.getGeographicDiversityScore(nodeId, topologyAnalysis);\n      score += geoScore * 20;\n      \n      scores.set(nodeId, score);\n    }\n    \n    return scores;\n  }\n\n  calculateNodeWeight(nodeId, score, networkConditions) {\n    \u002F\u002F Base weight of 1, adjusted by score and conditions\n    let weight = 1.0;\n    \n    \u002F\u002F Adjust based on normalized score (0-1)\n    const normalizedScore = score \u002F 100;\n    weight *= (0.5 + normalizedScore);\n    \n    \u002F\u002F Adjust based on network latency\n    const nodeLatency = networkConditions.nodeLatencies.get(nodeId) || 100;\n    const latencyFactor = Math.max(0.1, 1.0 - (nodeLatency \u002F 1000)); \u002F\u002F Lower latency = higher weight\n    weight *= latencyFactor;\n    \n    \u002F\u002F Ensure minimum weight\n    return Math.max(0.1, Math.min(2.0, weight));\n  }\n}\n```\n\n### Performance-Based Quorum Strategy\n```javascript\nclass PerformanceBasedStrategy {\n  constructor() {\n    this.performanceAnalyzer = new PerformanceAnalyzer();\n    this.throughputOptimizer = new ThroughputOptimizer();\n    this.latencyOptimizer = new LatencyOptimizer();\n  }\n\n  async calculateQuorum(analysisInput) {\n    const { performanceMetrics, membershipStatus, protocol } = analysisInput;\n    \n    \u002F\u002F Analyze current performance bottlenecks\n    const bottlenecks = await this.identifyPerformanceBottlenecks(performanceMetrics);\n    \n    \u002F\u002F Calculate throughput-optimal quorum size\n    const throughputOptimal = await this.calculateThroughputOptimalQuorum(\n      performanceMetrics, membershipStatus.activeNodes\n    );\n    \n    \u002F\u002F Calculate latency-optimal quorum size\n    const latencyOptimal = await this.calculateLatencyOptimalQuorum(\n      performanceMetrics, membershipStatus.activeNodes\n    );\n    \n    \u002F\u002F Balance throughput and latency requirements\n    const balancedQuorum = await this.balanceThroughputAndLatency(\n      throughputOptimal, latencyOptimal, performanceMetrics.requirements\n    );\n    \n    return {\n      quorum: balancedQuorum,\n      strategy: 'PERFORMANCE_BASED',\n      confidence: this.calculatePerformanceConfidence(performanceMetrics),\n      reasoning: this.generatePerformanceReasoning(\n        balancedQuorum, throughputOptimal, latencyOptimal, bottlenecks\n      ),\n      expectedImpact: {\n        throughputImprovement: this.estimateThroughputImpact(balancedQuorum),\n        latencyImprovement: this.estimateLatencyImpact(balancedQuorum)\n      }\n    };\n  }\n\n  async calculateThroughputOptimalQuorum(performanceMetrics, activeNodes) {\n    const currentThroughput = performanceMetrics.throughput;\n    const targetThroughput = performanceMetrics.requirements.targetThroughput;\n    \n    \u002F\u002F Analyze relationship between quorum size and throughput\n    const throughputCurve = await this.analyzeThroughputCurve(activeNodes);\n    \n    \u002F\u002F Find quorum size that maximizes throughput while meeting requirements\n    let optimalSize = Math.ceil(activeNodes.length \u002F 2) + 1; \u002F\u002F Minimum viable quorum\n    let maxThroughput = 0;\n    \n    for (let size = optimalSize; size \u003C= activeNodes.length; size++) {\n      const projectedThroughput = this.projectThroughput(size, throughputCurve);\n      \n      if (projectedThroughput > maxThroughput && projectedThroughput >= targetThroughput) {\n        maxThroughput = projectedThroughput;\n        optimalSize = size;\n      } else if (projectedThroughput \u003C maxThroughput * 0.9) {\n        \u002F\u002F Stop if throughput starts decreasing significantly\n        break;\n      }\n    }\n    \n    return await this.selectOptimalNodes(activeNodes, optimalSize, 'THROUGHPUT');\n  }\n\n  async calculateLatencyOptimalQuorum(performanceMetrics, activeNodes) {\n    const currentLatency = performanceMetrics.latency;\n    const targetLatency = performanceMetrics.requirements.maxLatency;\n    \n    \u002F\u002F Analyze relationship between quorum size and latency\n    const latencyCurve = await this.analyzeLatencyCurve(activeNodes);\n    \n    \u002F\u002F Find minimum quorum size that meets latency requirements\n    const minViableQuorum = Math.ceil(activeNodes.length \u002F 2) + 1;\n    \n    for (let size = minViableQuorum; size \u003C= activeNodes.length; size++) {\n      const projectedLatency = this.projectLatency(size, latencyCurve);\n      \n      if (projectedLatency \u003C= targetLatency) {\n        return await this.selectOptimalNodes(activeNodes, size, 'LATENCY');\n      }\n    }\n    \n    \u002F\u002F If no size meets requirements, return minimum viable with warning\n    console.warn('No quorum size meets latency requirements');\n    return await this.selectOptimalNodes(activeNodes, minViableQuorum, 'LATENCY');\n  }\n\n  async selectOptimalNodes(availableNodes, targetSize, optimizationTarget) {\n    const nodeScores = new Map();\n    \n    \u002F\u002F Score nodes based on optimization target\n    for (const node of availableNodes) {\n      let score = 0;\n      \n      if (optimizationTarget === 'THROUGHPUT') {\n        score = await this.scoreThroughputCapability(node);\n      } else if (optimizationTarget === 'LATENCY') {\n        score = await this.scoreLatencyPerformance(node);\n      }\n      \n      nodeScores.set(node.id, score);\n    }\n    \n    \u002F\u002F Select top-scoring nodes\n    const sortedNodes = availableNodes.sort((a, b) => \n      nodeScores.get(b.id) - nodeScores.get(a.id)\n    );\n    \n    const selectedNodes = new Map();\n    \n    for (let i = 0; i \u003C Math.min(targetSize, sortedNodes.length); i++) {\n      const node = sortedNodes[i];\n      selectedNodes.set(node.id, {\n        weight: this.calculatePerformanceWeight(node, nodeScores.get(node.id)),\n        score: nodeScores.get(node.id),\n        role: i === 0 ? 'primary' : 'secondary',\n        optimizationTarget: optimizationTarget\n      });\n    }\n    \n    return {\n      nodes: selectedNodes,\n      totalWeight: Array.from(selectedNodes.values())\n        .reduce((sum, node) => sum + node.weight, 0),\n      optimizationTarget: optimizationTarget\n    };\n  }\n\n  async scoreThroughputCapability(node) {\n    let score = 0;\n    \n    \u002F\u002F CPU capacity score\n    const cpuCapacity = await this.getNodeCPUCapacity(node);\n    score += (cpuCapacity \u002F 100) * 30; \u002F\u002F 30% weight for CPU\n    \n    \u002F\u002F Network bandwidth score\n    const bandwidth = await this.getNodeBandwidth(node);\n    score += (bandwidth \u002F 1000) * 25; \u002F\u002F 25% weight for bandwidth (Mbps)\n    \n    \u002F\u002F Memory capacity score\n    const memory = await this.getNodeMemory(node);\n    score += (memory \u002F 8192) * 20; \u002F\u002F 20% weight for memory (MB)\n    \n    \u002F\u002F Historical throughput performance\n    const historicalPerformance = await this.getHistoricalThroughput(node);\n    score += (historicalPerformance \u002F 1000) * 25; \u002F\u002F 25% weight for historical performance\n    \n    return Math.min(100, score); \u002F\u002F Normalize to 0-100\n  }\n\n  async scoreLatencyPerformance(node) {\n    let score = 100; \u002F\u002F Start with perfect score, subtract penalties\n    \n    \u002F\u002F Network latency penalty\n    const avgLatency = await this.getAverageNodeLatency(node);\n    score -= (avgLatency \u002F 10); \u002F\u002F Subtract 1 point per 10ms latency\n    \n    \u002F\u002F CPU load penalty\n    const cpuLoad = await this.getNodeCPULoad(node);\n    score -= (cpuLoad \u002F 2); \u002F\u002F Subtract 0.5 points per 1% CPU load\n    \n    \u002F\u002F Geographic distance penalty (for distributed networks)\n    const geoLatency = await this.getGeographicLatency(node);\n    score -= (geoLatency \u002F 20); \u002F\u002F Subtract 1 point per 20ms geo latency\n    \n    \u002F\u002F Consistency penalty (nodes with inconsistent performance)\n    const consistencyScore = await this.getPerformanceConsistency(node);\n    score *= consistencyScore; \u002F\u002F Multiply by consistency factor (0-1)\n    \n    return Math.max(0, score);\n  }\n}\n```\n\n### Fault Tolerance Strategy\n```javascript\nclass FaultToleranceStrategy {\n  constructor() {\n    this.faultAnalyzer = new FaultAnalyzer();\n    this.reliabilityCalculator = new ReliabilityCalculator();\n    this.redundancyOptimizer = new RedundancyOptimizer();\n  }\n\n  async calculateQuorum(analysisInput) {\n    const { membershipStatus, faultToleranceRequirements, networkConditions } = analysisInput;\n    \n    \u002F\u002F Analyze fault scenarios\n    const faultScenarios = await this.analyzeFaultScenarios(\n      membershipStatus.activeNodes, networkConditions\n    );\n    \n    \u002F\u002F Calculate minimum quorum for fault tolerance requirements\n    const minQuorum = this.calculateFaultTolerantQuorum(\n      faultScenarios, faultToleranceRequirements\n    );\n    \n    \u002F\u002F Optimize node selection for maximum fault tolerance\n    const faultTolerantQuorum = await this.optimizeForFaultTolerance(\n      membershipStatus.activeNodes, minQuorum, faultScenarios\n    );\n    \n    return {\n      quorum: faultTolerantQuorum,\n      strategy: 'FAULT_TOLERANCE_BASED',\n      confidence: this.calculateFaultConfidence(faultScenarios),\n      reasoning: this.generateFaultToleranceReasoning(\n        faultTolerantQuorum, faultScenarios, faultToleranceRequirements\n      ),\n      expectedImpact: {\n        availability: this.estimateAvailabilityImprovement(faultTolerantQuorum),\n        resilience: this.estimateResilienceImprovement(faultTolerantQuorum)\n      }\n    };\n  }\n\n  async analyzeFaultScenarios(activeNodes, networkConditions) {\n    const scenarios = [];\n    \n    \u002F\u002F Single node failure scenarios\n    for (const node of activeNodes) {\n      const scenario = await this.analyzeSingleNodeFailure(node, activeNodes, networkConditions);\n      scenarios.push(scenario);\n    }\n    \n    \u002F\u002F Multiple node failure scenarios\n    const multiFailureScenarios = await this.analyzeMultipleNodeFailures(\n      activeNodes, networkConditions\n    );\n    scenarios.push(...multiFailureScenarios);\n    \n    \u002F\u002F Network partition scenarios\n    const partitionScenarios = await this.analyzeNetworkPartitionScenarios(\n      activeNodes, networkConditions\n    );\n    scenarios.push(...partitionScenarios);\n    \n    \u002F\u002F Correlated failure scenarios\n    const correlatedFailureScenarios = await this.analyzeCorrelatedFailures(\n      activeNodes, networkConditions\n    );\n    scenarios.push(...correlatedFailureScenarios);\n    \n    return this.prioritizeScenariosByLikelihood(scenarios);\n  }\n\n  calculateFaultTolerantQuorum(faultScenarios, requirements) {\n    let maxRequiredQuorum = 0;\n    \n    for (const scenario of faultScenarios) {\n      if (scenario.likelihood >= requirements.minLikelihoodToConsider) {\n        const requiredQuorum = this.calculateQuorumForScenario(scenario, requirements);\n        maxRequiredQuorum = Math.max(maxRequiredQuorum, requiredQuorum);\n      }\n    }\n    \n    return maxRequiredQuorum;\n  }\n\n  calculateQuorumForScenario(scenario, requirements) {\n    const totalNodes = scenario.totalNodes;\n    const failedNodes = scenario.failedNodes;\n    const availableNodes = totalNodes - failedNodes;\n    \n    \u002F\u002F For Byzantine fault tolerance\n    if (requirements.byzantineFaultTolerance) {\n      const maxByzantineNodes = Math.floor((totalNodes - 1) \u002F 3);\n      return Math.floor(2 * totalNodes \u002F 3) + 1;\n    }\n    \n    \u002F\u002F For crash fault tolerance\n    return Math.floor(availableNodes \u002F 2) + 1;\n  }\n\n  async optimizeForFaultTolerance(activeNodes, minQuorum, faultScenarios) {\n    const optimizedQuorum = {\n      nodes: new Map(),\n      totalWeight: 0,\n      faultTolerance: {\n        singleNodeFailures: 0,\n        multipleNodeFailures: 0,\n        networkPartitions: 0\n      }\n    };\n    \n    \u002F\u002F Score nodes based on fault tolerance contribution\n    const nodeScores = await this.scoreFaultToleranceContribution(\n      activeNodes, faultScenarios\n    );\n    \n    \u002F\u002F Select nodes to maximize fault tolerance coverage\n    const selectedNodes = this.selectFaultTolerantNodes(\n      activeNodes, minQuorum, nodeScores, faultScenarios\n    );\n    \n    for (const [nodeId, nodeData] of selectedNodes) {\n      optimizedQuorum.nodes.set(nodeId, {\n        weight: nodeData.weight,\n        score: nodeData.score,\n        role: nodeData.role,\n        faultToleranceContribution: nodeData.faultToleranceContribution\n      });\n      optimizedQuorum.totalWeight += nodeData.weight;\n    }\n    \n    \u002F\u002F Calculate fault tolerance metrics for selected quorum\n    optimizedQuorum.faultTolerance = await this.calculateFaultToleranceMetrics(\n      selectedNodes, faultScenarios\n    );\n    \n    return optimizedQuorum;\n  }\n\n  async scoreFaultToleranceContribution(activeNodes, faultScenarios) {\n    const scores = new Map();\n    \n    for (const node of activeNodes) {\n      let score = 0;\n      \n      \u002F\u002F Independence score (nodes in different failure domains get higher scores)\n      const independenceScore = await this.calculateIndependenceScore(node, activeNodes);\n      score += independenceScore * 40;\n      \n      \u002F\u002F Reliability score (historical uptime and performance)\n      const reliabilityScore = await this.calculateReliabilityScore(node);\n      score += reliabilityScore * 30;\n      \n      \u002F\u002F Geographic diversity score\n      const diversityScore = await this.calculateDiversityScore(node, activeNodes);\n      score += diversityScore * 20;\n      \n      \u002F\u002F Recovery capability score\n      const recoveryScore = await this.calculateRecoveryScore(node);\n      score += recoveryScore * 10;\n      \n      scores.set(node.id, score);\n    }\n    \n    return scores;\n  }\n\n  selectFaultTolerantNodes(activeNodes, minQuorum, nodeScores, faultScenarios) {\n    const selectedNodes = new Map();\n    const remainingNodes = [...activeNodes];\n    \n    \u002F\u002F Greedy selection to maximize fault tolerance coverage\n    while (selectedNodes.size \u003C minQuorum && remainingNodes.length > 0) {\n      let bestNode = null;\n      let bestScore = -1;\n      let bestIndex = -1;\n      \n      for (let i = 0; i \u003C remainingNodes.length; i++) {\n        const node = remainingNodes[i];\n        const additionalCoverage = this.calculateAdditionalFaultCoverage(\n          node, selectedNodes, faultScenarios\n        );\n        \n        const combinedScore = nodeScores.get(node.id) + (additionalCoverage * 50);\n        \n        if (combinedScore > bestScore) {\n          bestScore = combinedScore;\n          bestNode = node;\n          bestIndex = i;\n        }\n      }\n      \n      if (bestNode) {\n        selectedNodes.set(bestNode.id, {\n          weight: this.calculateFaultToleranceWeight(bestNode, nodeScores.get(bestNode.id)),\n          score: nodeScores.get(bestNode.id),\n          role: selectedNodes.size === 0 ? 'primary' : 'secondary',\n          faultToleranceContribution: this.calculateFaultToleranceContribution(bestNode)\n        });\n        \n        remainingNodes.splice(bestIndex, 1);\n      } else {\n        break; \u002F\u002F No more beneficial nodes\n      }\n    }\n    \n    return selectedNodes;\n  }\n}\n```\n\n## MCP Integration Hooks\n\n### Quorum State Management\n```javascript\n\u002F\u002F Store quorum configuration and history\nawait this.mcpTools.memory_usage({\n  action: 'store',\n  key: `quorum_config_${this.nodeId}`,\n  value: JSON.stringify({\n    currentQuorum: Array.from(this.currentQuorum.entries()),\n    strategy: this.activeStrategy,\n    networkConditions: this.lastNetworkAnalysis,\n    adjustmentHistory: this.quorumHistory.slice(-10)\n  }),\n  namespace: 'quorum_management',\n  ttl: 3600000 \u002F\u002F 1 hour\n});\n\n\u002F\u002F Coordinate with swarm for membership changes\nconst swarmStatus = await this.mcpTools.swarm_status({\n  swarmId: this.swarmId\n});\n\nawait this.mcpTools.coordination_sync({\n  swarmId: this.swarmId\n});\n```\n\n### Performance Monitoring Integration\n```javascript\n\u002F\u002F Track quorum adjustment performance\nawait this.mcpTools.metrics_collect({\n  components: [\n    'quorum_adjustment_latency',\n    'consensus_availability',\n    'fault_tolerance_coverage',\n    'network_partition_recovery_time'\n  ]\n});\n\n\u002F\u002F Neural learning for quorum optimization\nawait this.mcpTools.neural_patterns({\n  action: 'learn',\n  operation: 'quorum_optimization',\n  outcome: JSON.stringify({\n    adjustmentType: adjustment.strategy,\n    performanceImpact: measurementResults,\n    networkConditions: currentNetworkState,\n    faultToleranceImprovement: faultToleranceMetrics\n  })\n});\n```\n\n### Task Orchestration for Quorum Changes\n```javascript\n\u002F\u002F Orchestrate complex quorum adjustments\nawait this.mcpTools.task_orchestrate({\n  task: 'quorum_adjustment',\n  strategy: 'sequential',\n  priority: 'high',\n  dependencies: [\n    'network_analysis',\n    'membership_validation',\n    'performance_assessment'\n  ]\n});\n```\n\nThis Quorum Manager provides intelligent, adaptive quorum management that optimizes for network conditions, performance requirements, and fault tolerance needs while maintaining the safety and liveness properties of distributed consensus protocols.","---\nname: quorum-manager\ntype: coordinator\ncolor: \"#673AB7\"\ndescription: Implements dynamic quorum adjustment and intelligent membership management\ncapabilities:\n  - dynamic_quorum_calculation\n  - membership_management\n  - network_monitoring\n  - weighted_voting\n  - fault_tolerance_optimization\npriority: high\nhooks:\n  pre: |\n    echo \"🎯 Quorum Manager adjusting: $TASK\"\n    # Assess current network conditions\n    if [[ \"$TASK\" == *\"quorum\"* ]]; then\n      echo \"📡 Analyzing network topology and node health\"\n    fi\n  post: |\n    echo \"⚖️  Quorum adjustment complete\"\n    # Validate new quorum configuration\n    echo \"✅ Verifying fault tolerance and availability guarantees\"\n---\n\n# Quorum Manager\n\nImplements dynamic quorum adjustment and intelligent membership management for distributed consensus protocols.\n\n## Core Responsibilities\n\n1. **Dynamic Quorum Calculation**: Adapt quorum requirements based on real-time network conditions\n2. **Membership Management**: Handle seamless node addition, removal, and failure scenarios\n3. **Network Monitoring**: Assess connectivity, latency, and partition detection\n4. **Weighted Voting**: Implement capability-based voting weight assignments\n5. **Fault Tolerance Optimization**: Balance availability and consistency guarantees\n\n## Technical Implementation\n\n### Core Quorum Management System\n```javascript\nclass QuorumManager {\n  constructor(nodeId, consensusProtocol) {\n    this.nodeId = nodeId;\n    this.protocol = consensusProtocol;\n    this.currentQuorum = new Map(); \u002F\u002F nodeId -> QuorumNode\n    this.quorumHistory = [];\n    this.networkMonitor = new NetworkConditionMonitor();\n    this.membershipTracker = new MembershipTracker();\n    this.faultToleranceCalculator = new FaultToleranceCalculator();\n    this.adjustmentStrategies = new Map();\n    \n    this.initializeStrategies();\n  }\n\n  \u002F\u002F Initialize quorum adjustment strategies\n  initializeStrategies() {\n    this.adjustmentStrategies.set('NETWORK_BASED', new NetworkBasedStrategy());\n    this.adjustmentStrategies.set('PERFORMANCE_BASED', new PerformanceBasedStrategy());\n    this.adjustmentStrategies.set('FAULT_TOLERANCE_BASED', new FaultToleranceStrategy());\n    this.adjustmentStrategies.set('HYBRID', new HybridStrategy());\n  }\n\n  \u002F\u002F Calculate optimal quorum size based on current conditions\n  async calculateOptimalQuorum(context = {}) {\n    const networkConditions = await this.networkMonitor.getCurrentConditions();\n    const membershipStatus = await this.membershipTracker.getMembershipStatus();\n    const performanceMetrics = context.performanceMetrics || await this.getPerformanceMetrics();\n    \n    const analysisInput = {\n      networkConditions: networkConditions,\n      membershipStatus: membershipStatus,\n      performanceMetrics: performanceMetrics,\n      currentQuorum: this.currentQuorum,\n      protocol: this.protocol,\n      faultToleranceRequirements: context.faultToleranceRequirements || this.getDefaultFaultTolerance()\n    };\n    \n    \u002F\u002F Apply multiple strategies and select optimal result\n    const strategyResults = new Map();\n    \n    for (const [strategyName, strategy] of this.adjustmentStrategies) {\n      try {\n        const result = await strategy.calculateQuorum(analysisInput);\n        strategyResults.set(strategyName, result);\n      } catch (error) {\n        console.warn(`Strategy ${strategyName} failed:`, error);\n      }\n    }\n    \n    \u002F\u002F Select best strategy result\n    const optimalResult = this.selectOptimalStrategy(strategyResults, analysisInput);\n    \n    return {\n      recommendedQuorum: optimalResult.quorum,\n      strategy: optimalResult.strategy,\n      confidence: optimalResult.confidence,\n      reasoning: optimalResult.reasoning,\n      expectedImpact: optimalResult.expectedImpact\n    };\n  }\n\n  \u002F\u002F Apply quorum changes with validation and rollback capability\n  async adjustQuorum(newQuorumConfig, options = {}) {\n    const adjustmentId = `adjustment_${Date.now()}`;\n    \n    try {\n      \u002F\u002F Validate new quorum configuration\n      await this.validateQuorumConfiguration(newQuorumConfig);\n      \n      \u002F\u002F Create adjustment plan\n      const adjustmentPlan = await this.createAdjustmentPlan(\n        this.currentQuorum, newQuorumConfig\n      );\n      \n      \u002F\u002F Execute adjustment with monitoring\n      const adjustmentResult = await this.executeQuorumAdjustment(\n        adjustmentPlan, adjustmentId, options\n      );\n      \n      \u002F\u002F Verify adjustment success\n      await this.verifyQuorumAdjustment(adjustmentResult);\n      \n      \u002F\u002F Update current quorum\n      this.currentQuorum = newQuorumConfig.quorum;\n      \n      \u002F\u002F Record successful adjustment\n      this.recordQuorumChange(adjustmentId, adjustmentResult);\n      \n      return {\n        success: true,\n        adjustmentId: adjustmentId,\n        previousQuorum: adjustmentPlan.previousQuorum,\n        newQuorum: this.currentQuorum,\n        impact: adjustmentResult.impact\n      };\n      \n    } catch (error) {\n      console.error(`Quorum adjustment failed:`, error);\n      \n      \u002F\u002F Attempt rollback\n      await this.rollbackQuorumAdjustment(adjustmentId);\n      \n      throw error;\n    }\n  }\n\n  async executeQuorumAdjustment(adjustmentPlan, adjustmentId, options) {\n    const startTime = Date.now();\n    \n    \u002F\u002F Phase 1: Prepare nodes for quorum change\n    await this.prepareNodesForAdjustment(adjustmentPlan.affectedNodes);\n    \n    \u002F\u002F Phase 2: Execute membership changes\n    const membershipChanges = await this.executeMembershipChanges(\n      adjustmentPlan.membershipChanges\n    );\n    \n    \u002F\u002F Phase 3: Update voting weights if needed\n    if (adjustmentPlan.weightChanges.length > 0) {\n      await this.updateVotingWeights(adjustmentPlan.weightChanges);\n    }\n    \n    \u002F\u002F Phase 4: Reconfigure consensus protocol\n    await this.reconfigureConsensusProtocol(adjustmentPlan.protocolChanges);\n    \n    \u002F\u002F Phase 5: Verify new quorum is operational\n    const verificationResult = await this.verifyQuorumOperational(adjustmentPlan.newQuorum);\n    \n    const endTime = Date.now();\n    \n    return {\n      adjustmentId: adjustmentId,\n      duration: endTime - startTime,\n      membershipChanges: membershipChanges,\n      verificationResult: verificationResult,\n      impact: await this.measureAdjustmentImpact(startTime, endTime)\n    };\n  }\n}\n```\n\n### Network-Based Quorum Strategy\n```javascript\nclass NetworkBasedStrategy {\n  constructor() {\n    this.networkAnalyzer = new NetworkAnalyzer();\n    this.connectivityMatrix = new ConnectivityMatrix();\n    this.partitionPredictor = new PartitionPredictor();\n  }\n\n  async calculateQuorum(analysisInput) {\n    const { networkConditions, membershipStatus, currentQuorum } = analysisInput;\n    \n    \u002F\u002F Analyze network topology and connectivity\n    const topologyAnalysis = await this.analyzeNetworkTopology(membershipStatus.activeNodes);\n    \n    \u002F\u002F Predict potential network partitions\n    const partitionRisk = await this.assessPartitionRisk(networkConditions, topologyAnalysis);\n    \n    \u002F\u002F Calculate minimum quorum for fault tolerance\n    const minQuorum = this.calculateMinimumQuorum(\n      membershipStatus.activeNodes.length,\n      partitionRisk.maxPartitionSize\n    );\n    \n    \u002F\u002F Optimize for network conditions\n    const optimizedQuorum = await this.optimizeForNetworkConditions(\n      minQuorum,\n      networkConditions,\n      topologyAnalysis\n    );\n    \n    return {\n      quorum: optimizedQuorum,\n      strategy: 'NETWORK_BASED',\n      confidence: this.calculateConfidence(networkConditions, topologyAnalysis),\n      reasoning: this.generateReasoning(optimizedQuorum, partitionRisk, networkConditions),\n      expectedImpact: {\n        availability: this.estimateAvailabilityImpact(optimizedQuorum),\n        performance: this.estimatePerformanceImpact(optimizedQuorum, networkConditions)\n      }\n    };\n  }\n\n  async analyzeNetworkTopology(activeNodes) {\n    const topology = {\n      nodes: activeNodes.length,\n      edges: 0,\n      clusters: [],\n      diameter: 0,\n      connectivity: new Map()\n    };\n    \n    \u002F\u002F Build connectivity matrix\n    for (const node of activeNodes) {\n      const connections = await this.getNodeConnections(node);\n      topology.connectivity.set(node.id, connections);\n      topology.edges += connections.length;\n    }\n    \n    \u002F\u002F Identify network clusters\n    topology.clusters = await this.identifyNetworkClusters(topology.connectivity);\n    \n    \u002F\u002F Calculate network diameter\n    topology.diameter = await this.calculateNetworkDiameter(topology.connectivity);\n    \n    return topology;\n  }\n\n  async assessPartitionRisk(networkConditions, topologyAnalysis) {\n    const riskFactors = {\n      connectivityReliability: this.assessConnectivityReliability(networkConditions),\n      geographicDistribution: this.assessGeographicRisk(topologyAnalysis),\n      networkLatency: this.assessLatencyRisk(networkConditions),\n      historicalPartitions: await this.getHistoricalPartitionData()\n    };\n    \n    \u002F\u002F Calculate overall partition risk\n    const overallRisk = this.calculateOverallPartitionRisk(riskFactors);\n    \n    \u002F\u002F Estimate maximum partition size\n    const maxPartitionSize = this.estimateMaxPartitionSize(\n      topologyAnalysis,\n      riskFactors\n    );\n    \n    return {\n      overallRisk: overallRisk,\n      maxPartitionSize: maxPartitionSize,\n      riskFactors: riskFactors,\n      mitigationStrategies: this.suggestMitigationStrategies(riskFactors)\n    };\n  }\n\n  calculateMinimumQuorum(totalNodes, maxPartitionSize) {\n    \u002F\u002F For Byzantine fault tolerance: need > 2\u002F3 of total nodes\n    const byzantineMinimum = Math.floor(2 * totalNodes \u002F 3) + 1;\n    \n    \u002F\u002F For network partition tolerance: need > 1\u002F2 of largest connected component\n    const partitionMinimum = Math.floor((totalNodes - maxPartitionSize) \u002F 2) + 1;\n    \n    \u002F\u002F Use the more restrictive requirement\n    return Math.max(byzantineMinimum, partitionMinimum);\n  }\n\n  async optimizeForNetworkConditions(minQuorum, networkConditions, topologyAnalysis) {\n    const optimization = {\n      baseQuorum: minQuorum,\n      nodes: new Map(),\n      totalWeight: 0\n    };\n    \n    \u002F\u002F Select nodes for quorum based on network position and reliability\n    const nodeScores = await this.scoreNodesForQuorum(networkConditions, topologyAnalysis);\n    \n    \u002F\u002F Sort nodes by score (higher is better)\n    const sortedNodes = Array.from(nodeScores.entries())\n      .sort(([,scoreA], [,scoreB]) => scoreB - scoreA);\n    \n    \u002F\u002F Select top nodes for quorum\n    let selectedCount = 0;\n    for (const [nodeId, score] of sortedNodes) {\n      if (selectedCount \u003C minQuorum) {\n        const weight = this.calculateNodeWeight(nodeId, score, networkConditions);\n        optimization.nodes.set(nodeId, {\n          weight: weight,\n          score: score,\n          role: selectedCount === 0 ? 'primary' : 'secondary'\n        });\n        optimization.totalWeight += weight;\n        selectedCount++;\n      }\n    }\n    \n    return optimization;\n  }\n\n  async scoreNodesForQuorum(networkConditions, topologyAnalysis) {\n    const scores = new Map();\n    \n    for (const [nodeId, connections] of topologyAnalysis.connectivity) {\n      let score = 0;\n      \n      \u002F\u002F Connectivity score (more connections = higher score)\n      score += (connections.length \u002F topologyAnalysis.nodes) * 30;\n      \n      \u002F\u002F Network position score (central nodes get higher scores)\n      const centrality = this.calculateCentrality(nodeId, topologyAnalysis);\n      score += centrality * 25;\n      \n      \u002F\u002F Reliability score based on network conditions\n      const reliability = await this.getNodeReliability(nodeId, networkConditions);\n      score += reliability * 25;\n      \n      \u002F\u002F Geographic diversity score\n      const geoScore = await this.getGeographicDiversityScore(nodeId, topologyAnalysis);\n      score += geoScore * 20;\n      \n      scores.set(nodeId, score);\n    }\n    \n    return scores;\n  }\n\n  calculateNodeWeight(nodeId, score, networkConditions) {\n    \u002F\u002F Base weight of 1, adjusted by score and conditions\n    let weight = 1.0;\n    \n    \u002F\u002F Adjust based on normalized score (0-1)\n    const normalizedScore = score \u002F 100;\n    weight *= (0.5 + normalizedScore);\n    \n    \u002F\u002F Adjust based on network latency\n    const nodeLatency = networkConditions.nodeLatencies.get(nodeId) || 100;\n    const latencyFactor = Math.max(0.1, 1.0 - (nodeLatency \u002F 1000)); \u002F\u002F Lower latency = higher weight\n    weight *= latencyFactor;\n    \n    \u002F\u002F Ensure minimum weight\n    return Math.max(0.1, Math.min(2.0, weight));\n  }\n}\n```\n\n### Performance-Based Quorum Strategy\n```javascript\nclass PerformanceBasedStrategy {\n  constructor() {\n    this.performanceAnalyzer = new PerformanceAnalyzer();\n    this.throughputOptimizer = new ThroughputOptimizer();\n    this.latencyOptimizer = new LatencyOptimizer();\n  }\n\n  async calculateQuorum(analysisInput) {\n    const { performanceMetrics, membershipStatus, protocol } = analysisInput;\n    \n    \u002F\u002F Analyze current performance bottlenecks\n    const bottlenecks = await this.identifyPerformanceBottlenecks(performanceMetrics);\n    \n    \u002F\u002F Calculate throughput-optimal quorum size\n    const throughputOptimal = await this.calculateThroughputOptimalQuorum(\n      performanceMetrics, membershipStatus.activeNodes\n    );\n    \n    \u002F\u002F Calculate latency-optimal quorum size\n    const latencyOptimal = await this.calculateLatencyOptimalQuorum(\n      performanceMetrics, membershipStatus.activeNodes\n    );\n    \n    \u002F\u002F Balance throughput and latency requirements\n    const balancedQuorum = await this.balanceThroughputAndLatency(\n      throughputOptimal, latencyOptimal, performanceMetrics.requirements\n    );\n    \n    return {\n      quorum: balancedQuorum,\n      strategy: 'PERFORMANCE_BASED',\n      confidence: this.calculatePerformanceConfidence(performanceMetrics),\n      reasoning: this.generatePerformanceReasoning(\n        balancedQuorum, throughputOptimal, latencyOptimal, bottlenecks\n      ),\n      expectedImpact: {\n        throughputImprovement: this.estimateThroughputImpact(balancedQuorum),\n        latencyImprovement: this.estimateLatencyImpact(balancedQuorum)\n      }\n    };\n  }\n\n  async calculateThroughputOptimalQuorum(performanceMetrics, activeNodes) {\n    const currentThroughput = performanceMetrics.throughput;\n    const targetThroughput = performanceMetrics.requirements.targetThroughput;\n    \n    \u002F\u002F Analyze relationship between quorum size and throughput\n    const throughputCurve = await this.analyzeThroughputCurve(activeNodes);\n    \n    \u002F\u002F Find quorum size that maximizes throughput while meeting requirements\n    let optimalSize = Math.ceil(activeNodes.length \u002F 2) + 1; \u002F\u002F Minimum viable quorum\n    let maxThroughput = 0;\n    \n    for (let size = optimalSize; size \u003C= activeNodes.length; size++) {\n      const projectedThroughput = this.projectThroughput(size, throughputCurve);\n      \n      if (projectedThroughput > maxThroughput && projectedThroughput >= targetThroughput) {\n        maxThroughput = projectedThroughput;\n        optimalSize = size;\n      } else if (projectedThroughput \u003C maxThroughput * 0.9) {\n        \u002F\u002F Stop if throughput starts decreasing significantly\n        break;\n      }\n    }\n    \n    return await this.selectOptimalNodes(activeNodes, optimalSize, 'THROUGHPUT');\n  }\n\n  async calculateLatencyOptimalQuorum(performanceMetrics, activeNodes) {\n    const currentLatency = performanceMetrics.latency;\n    const targetLatency = performanceMetrics.requirements.maxLatency;\n    \n    \u002F\u002F Analyze relationship between quorum size and latency\n    const latencyCurve = await this.analyzeLatencyCurve(activeNodes);\n    \n    \u002F\u002F Find minimum quorum size that meets latency requirements\n    const minViableQuorum = Math.ceil(activeNodes.length \u002F 2) + 1;\n    \n    for (let size = minViableQuorum; size \u003C= activeNodes.length; size++) {\n      const projectedLatency = this.projectLatency(size, latencyCurve);\n      \n      if (projectedLatency \u003C= targetLatency) {\n        return await this.selectOptimalNodes(activeNodes, size, 'LATENCY');\n      }\n    }\n    \n    \u002F\u002F If no size meets requirements, return minimum viable with warning\n    console.warn('No quorum size meets latency requirements');\n    return await this.selectOptimalNodes(activeNodes, minViableQuorum, 'LATENCY');\n  }\n\n  async selectOptimalNodes(availableNodes, targetSize, optimizationTarget) {\n    const nodeScores = new Map();\n    \n    \u002F\u002F Score nodes based on optimization target\n    for (const node of availableNodes) {\n      let score = 0;\n      \n      if (optimizationTarget === 'THROUGHPUT') {\n        score = await this.scoreThroughputCapability(node);\n      } else if (optimizationTarget === 'LATENCY') {\n        score = await this.scoreLatencyPerformance(node);\n      }\n      \n      nodeScores.set(node.id, score);\n    }\n    \n    \u002F\u002F Select top-scoring nodes\n    const sortedNodes = availableNodes.sort((a, b) => \n      nodeScores.get(b.id) - nodeScores.get(a.id)\n    );\n    \n    const selectedNodes = new Map();\n    \n    for (let i = 0; i \u003C Math.min(targetSize, sortedNodes.length); i++) {\n      const node = sortedNodes[i];\n      selectedNodes.set(node.id, {\n        weight: this.calculatePerformanceWeight(node, nodeScores.get(node.id)),\n        score: nodeScores.get(node.id),\n        role: i === 0 ? 'primary' : 'secondary',\n        optimizationTarget: optimizationTarget\n      });\n    }\n    \n    return {\n      nodes: selectedNodes,\n      totalWeight: Array.from(selectedNodes.values())\n        .reduce((sum, node) => sum + node.weight, 0),\n      optimizationTarget: optimizationTarget\n    };\n  }\n\n  async scoreThroughputCapability(node) {\n    let score = 0;\n    \n    \u002F\u002F CPU capacity score\n    const cpuCapacity = await this.getNodeCPUCapacity(node);\n    score += (cpuCapacity \u002F 100) * 30; \u002F\u002F 30% weight for CPU\n    \n    \u002F\u002F Network bandwidth score\n    const bandwidth = await this.getNodeBandwidth(node);\n    score += (bandwidth \u002F 1000) * 25; \u002F\u002F 25% weight for bandwidth (Mbps)\n    \n    \u002F\u002F Memory capacity score\n    const memory = await this.getNodeMemory(node);\n    score += (memory \u002F 8192) * 20; \u002F\u002F 20% weight for memory (MB)\n    \n    \u002F\u002F Historical throughput performance\n    const historicalPerformance = await this.getHistoricalThroughput(node);\n    score += (historicalPerformance \u002F 1000) * 25; \u002F\u002F 25% weight for historical performance\n    \n    return Math.min(100, score); \u002F\u002F Normalize to 0-100\n  }\n\n  async scoreLatencyPerformance(node) {\n    let score = 100; \u002F\u002F Start with perfect score, subtract penalties\n    \n    \u002F\u002F Network latency penalty\n    const avgLatency = await this.getAverageNodeLatency(node);\n    score -= (avgLatency \u002F 10); \u002F\u002F Subtract 1 point per 10ms latency\n    \n    \u002F\u002F CPU load penalty\n    const cpuLoad = await this.getNodeCPULoad(node);\n    score -= (cpuLoad \u002F 2); \u002F\u002F Subtract 0.5 points per 1% CPU load\n    \n    \u002F\u002F Geographic distance penalty (for distributed networks)\n    const geoLatency = await this.getGeographicLatency(node);\n    score -= (geoLatency \u002F 20); \u002F\u002F Subtract 1 point per 20ms geo latency\n    \n    \u002F\u002F Consistency penalty (nodes with inconsistent performance)\n    const consistencyScore = await this.getPerformanceConsistency(node);\n    score *= consistencyScore; \u002F\u002F Multiply by consistency factor (0-1)\n    \n    return Math.max(0, score);\n  }\n}\n```\n\n### Fault Tolerance Strategy\n```javascript\nclass FaultToleranceStrategy {\n  constructor() {\n    this.faultAnalyzer = new FaultAnalyzer();\n    this.reliabilityCalculator = new ReliabilityCalculator();\n    this.redundancyOptimizer = new RedundancyOptimizer();\n  }\n\n  async calculateQuorum(analysisInput) {\n    const { membershipStatus, faultToleranceRequirements, networkConditions } = analysisInput;\n    \n    \u002F\u002F Analyze fault scenarios\n    const faultScenarios = await this.analyzeFaultScenarios(\n      membershipStatus.activeNodes, networkConditions\n    );\n    \n    \u002F\u002F Calculate minimum quorum for fault tolerance requirements\n    const minQuorum = this.calculateFaultTolerantQuorum(\n      faultScenarios, faultToleranceRequirements\n    );\n    \n    \u002F\u002F Optimize node selection for maximum fault tolerance\n    const faultTolerantQuorum = await this.optimizeForFaultTolerance(\n      membershipStatus.activeNodes, minQuorum, faultScenarios\n    );\n    \n    return {\n      quorum: faultTolerantQuorum,\n      strategy: 'FAULT_TOLERANCE_BASED',\n      confidence: this.calculateFaultConfidence(faultScenarios),\n      reasoning: this.generateFaultToleranceReasoning(\n        faultTolerantQuorum, faultScenarios, faultToleranceRequirements\n      ),\n      expectedImpact: {\n        availability: this.estimateAvailabilityImprovement(faultTolerantQuorum),\n        resilience: this.estimateResilienceImprovement(faultTolerantQuorum)\n      }\n    };\n  }\n\n  async analyzeFaultScenarios(activeNodes, networkConditions) {\n    const scenarios = [];\n    \n    \u002F\u002F Single node failure scenarios\n    for (const node of activeNodes) {\n      const scenario = await this.analyzeSingleNodeFailure(node, activeNodes, networkConditions);\n      scenarios.push(scenario);\n    }\n    \n    \u002F\u002F Multiple node failure scenarios\n    const multiFailureScenarios = await this.analyzeMultipleNodeFailures(\n      activeNodes, networkConditions\n    );\n    scenarios.push(...multiFailureScenarios);\n    \n    \u002F\u002F Network partition scenarios\n    const partitionScenarios = await this.analyzeNetworkPartitionScenarios(\n      activeNodes, networkConditions\n    );\n    scenarios.push(...partitionScenarios);\n    \n    \u002F\u002F Correlated failure scenarios\n    const correlatedFailureScenarios = await this.analyzeCorrelatedFailures(\n      activeNodes, networkConditions\n    );\n    scenarios.push(...correlatedFailureScenarios);\n    \n    return this.prioritizeScenariosByLikelihood(scenarios);\n  }\n\n  calculateFaultTolerantQuorum(faultScenarios, requirements) {\n    let maxRequiredQuorum = 0;\n    \n    for (const scenario of faultScenarios) {\n      if (scenario.likelihood >= requirements.minLikelihoodToConsider) {\n        const requiredQuorum = this.calculateQuorumForScenario(scenario, requirements);\n        maxRequiredQuorum = Math.max(maxRequiredQuorum, requiredQuorum);\n      }\n    }\n    \n    return maxRequiredQuorum;\n  }\n\n  calculateQuorumForScenario(scenario, requirements) {\n    const totalNodes = scenario.totalNodes;\n    const failedNodes = scenario.failedNodes;\n    const availableNodes = totalNodes - failedNodes;\n    \n    \u002F\u002F For Byzantine fault tolerance\n    if (requirements.byzantineFaultTolerance) {\n      const maxByzantineNodes = Math.floor((totalNodes - 1) \u002F 3);\n      return Math.floor(2 * totalNodes \u002F 3) + 1;\n    }\n    \n    \u002F\u002F For crash fault tolerance\n    return Math.floor(availableNodes \u002F 2) + 1;\n  }\n\n  async optimizeForFaultTolerance(activeNodes, minQuorum, faultScenarios) {\n    const optimizedQuorum = {\n      nodes: new Map(),\n      totalWeight: 0,\n      faultTolerance: {\n        singleNodeFailures: 0,\n        multipleNodeFailures: 0,\n        networkPartitions: 0\n      }\n    };\n    \n    \u002F\u002F Score nodes based on fault tolerance contribution\n    const nodeScores = await this.scoreFaultToleranceContribution(\n      activeNodes, faultScenarios\n    );\n    \n    \u002F\u002F Select nodes to maximize fault tolerance coverage\n    const selectedNodes = this.selectFaultTolerantNodes(\n      activeNodes, minQuorum, nodeScores, faultScenarios\n    );\n    \n    for (const [nodeId, nodeData] of selectedNodes) {\n      optimizedQuorum.nodes.set(nodeId, {\n        weight: nodeData.weight,\n        score: nodeData.score,\n        role: nodeData.role,\n        faultToleranceContribution: nodeData.faultToleranceContribution\n      });\n      optimizedQuorum.totalWeight += nodeData.weight;\n    }\n    \n    \u002F\u002F Calculate fault tolerance metrics for selected quorum\n    optimizedQuorum.faultTolerance = await this.calculateFaultToleranceMetrics(\n      selectedNodes, faultScenarios\n    );\n    \n    return optimizedQuorum;\n  }\n\n  async scoreFaultToleranceContribution(activeNodes, faultScenarios) {\n    const scores = new Map();\n    \n    for (const node of activeNodes) {\n      let score = 0;\n      \n      \u002F\u002F Independence score (nodes in different failure domains get higher scores)\n      const independenceScore = await this.calculateIndependenceScore(node, activeNodes);\n      score += independenceScore * 40;\n      \n      \u002F\u002F Reliability score (historical uptime and performance)\n      const reliabilityScore = await this.calculateReliabilityScore(node);\n      score += reliabilityScore * 30;\n      \n      \u002F\u002F Geographic diversity score\n      const diversityScore = await this.calculateDiversityScore(node, activeNodes);\n      score += diversityScore * 20;\n      \n      \u002F\u002F Recovery capability score\n      const recoveryScore = await this.calculateRecoveryScore(node);\n      score += recoveryScore * 10;\n      \n      scores.set(node.id, score);\n    }\n    \n    return scores;\n  }\n\n  selectFaultTolerantNodes(activeNodes, minQuorum, nodeScores, faultScenarios) {\n    const selectedNodes = new Map();\n    const remainingNodes = [...activeNodes];\n    \n    \u002F\u002F Greedy selection to maximize fault tolerance coverage\n    while (selectedNodes.size \u003C minQuorum && remainingNodes.length > 0) {\n      let bestNode = null;\n      let bestScore = -1;\n      let bestIndex = -1;\n      \n      for (let i = 0; i \u003C remainingNodes.length; i++) {\n        const node = remainingNodes[i];\n        const additionalCoverage = this.calculateAdditionalFaultCoverage(\n          node, selectedNodes, faultScenarios\n        );\n        \n        const combinedScore = nodeScores.get(node.id) + (additionalCoverage * 50);\n        \n        if (combinedScore > bestScore) {\n          bestScore = combinedScore;\n          bestNode = node;\n          bestIndex = i;\n        }\n      }\n      \n      if (bestNode) {\n        selectedNodes.set(bestNode.id, {\n          weight: this.calculateFaultToleranceWeight(bestNode, nodeScores.get(bestNode.id)),\n          score: nodeScores.get(bestNode.id),\n          role: selectedNodes.size === 0 ? 'primary' : 'secondary',\n          faultToleranceContribution: this.calculateFaultToleranceContribution(bestNode)\n        });\n        \n        remainingNodes.splice(bestIndex, 1);\n      } else {\n        break; \u002F\u002F No more beneficial nodes\n      }\n    }\n    \n    return selectedNodes;\n  }\n}\n```\n\n## MCP Integration Hooks\n\n### Quorum State Management\n```javascript\n\u002F\u002F Store quorum configuration and history\nawait this.mcpTools.memory_usage({\n  action: 'store',\n  key: `quorum_config_${this.nodeId}`,\n  value: JSON.stringify({\n    currentQuorum: Array.from(this.currentQuorum.entries()),\n    strategy: this.activeStrategy,\n    networkConditions: this.lastNetworkAnalysis,\n    adjustmentHistory: this.quorumHistory.slice(-10)\n  }),\n  namespace: 'quorum_management',\n  ttl: 3600000 \u002F\u002F 1 hour\n});\n\n\u002F\u002F Coordinate with swarm for membership changes\nconst swarmStatus = await this.mcpTools.swarm_status({\n  swarmId: this.swarmId\n});\n\nawait this.mcpTools.coordination_sync({\n  swarmId: this.swarmId\n});\n```\n\n### Performance Monitoring Integration\n```javascript\n\u002F\u002F Track quorum adjustment performance\nawait this.mcpTools.metrics_collect({\n  components: [\n    'quorum_adjustment_latency',\n    'consensus_availability',\n    'fault_tolerance_coverage',\n    'network_partition_recovery_time'\n  ]\n});\n\n\u002F\u002F Neural learning for quorum optimization\nawait this.mcpTools.neural_patterns({\n  action: 'learn',\n  operation: 'quorum_optimization',\n  outcome: JSON.stringify({\n    adjustmentType: adjustment.strategy,\n    performanceImpact: measurementResults,\n    networkConditions: currentNetworkState,\n    faultToleranceImprovement: faultToleranceMetrics\n  })\n});\n```\n\n### Task Orchestration for Quorum Changes\n```javascript\n\u002F\u002F Orchestrate complex quorum adjustments\nawait this.mcpTools.task_orchestrate({\n  task: 'quorum_adjustment',\n  strategy: 'sequential',\n  priority: 'high',\n  dependencies: [\n    'network_analysis',\n    'membership_validation',\n    'performance_assessment'\n  ]\n});\n```\n\nThis Quorum Manager provides intelligent, adaptive quorum management that optimizes for network conditions, performance requirements, and fault tolerance needs while maintaining the safety and liveness properties of distributed consensus protocols.",{"name":5,"description":7},"main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","05-技能与代理开发\u002Fagent-quorum-manager",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill agent-quorum-manager",{"tool":38,"command":39},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill agent-quorum-manager",{"tool":41,"command":42},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill agent-quorum-manager","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F05-技能与代理开发\u002Fagent-quorum-manager\u002FSKILL.md",true,[],[47,55,60,67,74,81],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":54},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":56,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":54},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":54},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":54},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":54},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":54},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]