consensus-voting
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConsensus Voting Skill
共识投票Skill
Purpose
用途
Execute weighted multi-agent voting for critical decisions where domain expertise matters. Unlike debate (collaborative synthesis) or n-version (parallel generation), this skill focuses on structured voting with expertise weighting for security, authentication, and data-handling changes.
针对需要考量领域专业度的关键决策,执行加权多Agent投票。与辩论(协作合成)或N版本(并行生成)不同,该Skill专注于为安全、身份认证和数据处理变更提供基于专业度加权的结构化投票机制。
Key Insight from Pattern Analysis
模式分析关键洞察
From (Pattern Applicability Analysis):
~/.amplihack/.claude/context/DISCOVERIES.mdVoting vs Expert Judgment Selection CriteriaWhen Voting Works:
- Adversarial environment (can't trust individual nodes)
- Binary or simple discrete choices
- No objective quality metric available
- Consensus more valuable than correctness
When Expert Judgment Works:
- Cooperative environment (honest actors)
- Complex quality dimensions
- Objective evaluation criteria exist
- Correctness more valuable than consensus
This skill uses BOTH strategically: Expert judgment to evaluate, weighted voting to decide.
来自(模式适用性分析):
~/.amplihack/.claude/context/DISCOVERIES.md投票 vs 专家判断选择标准投票适用场景:
- 对抗性环境(无法信任单个节点)
- 二元或简单离散选择
- 无客观质量衡量标准
- 共识比正确性更重要
专家判断适用场景:
- 协作性环境(参与者诚实可信)
- 复杂质量维度
- 存在客观评估标准
- 正确性比共识更重要
本Skill战略性地结合了两者:用专家判断进行评估,用加权投票做出决策。
When to Use This Skill
何时使用本Skill
AUTO-TRIGGERS (high-risk domains):
- Security implementations (authentication, authorization)
- Encryption and cryptographic code
- Sensitive data handling (PII, credentials)
- Permission and access control changes
- Critical algorithm implementations
EXPLICIT TRIGGERS:
- Major design decisions with competing approaches
- When stakeholder buy-in matters
- Binary or discrete choices needing validation
- Risk-mitigating decisions for production code
AVOID FOR:
- Complex trade-off analysis (use instead)
debate-workflow - Code generation (use instead)
n-version-workflow - Simple implementation choices
- Subjective quality assessments
自动触发场景(高风险领域):
- 安全实现(身份认证、授权)
- 加密与密码学代码
- 敏感数据处理(PII、凭证)
- 权限与访问控制变更
- 关键算法实现
手动触发场景:
- 存在竞争方案的重大设计决策
- 需要利益相关方认可的决策
- 需要验证的二元或离散选择
- 生产代码的风险缓解决策
避免使用场景:
- 复杂权衡分析(改用)
debate-workflow - 代码生成(改用)
n-version-workflow - 简单实现选择
- 主观质量评估
Configuration
配置
Voting Configuration
投票配置
Voting Mode:
- - 50%+ votes to pass
simple-majority - - 66%+ votes to pass (DEFAULT for security)
supermajority - - 100% agreement required
unanimous
Agent Selection:
- - Select agents based on detected domain (DEFAULT)
auto - - Specify agents explicitly
manual - - All relevant agents vote
comprehensive
Weight Calibration:
- - Fixed weights per domain (DEFAULT)
static
投票模式:
- - 超过50%投票即可通过
simple-majority - - 超过66%投票方可通过(安全场景默认值)
supermajority - - 需要100%同意
unanimous
Agent选择:
- - 根据检测到的领域自动选择Agent(默认值)
auto - - 明确指定Agent
manual - - 所有相关Agent参与投票
comprehensive
权重校准:
- - 各领域使用固定权重(默认值)
static
Domain Expertise Weights
领域专业度权重
| Agent | Security | Auth | Data | Algorithm | General |
|---|---|---|---|---|---|
| security | 3.0 | 2.5 | 2.5 | 1.5 | 1.0 |
| reviewer | 1.5 | 1.5 | 1.5 | 2.0 | 2.0 |
| architect | 1.5 | 2.0 | 2.0 | 2.5 | 2.0 |
| tester | 1.0 | 1.5 | 1.5 | 2.0 | 1.5 |
| optimizer | 0.5 | 0.5 | 0.5 | 2.5 | 1.0 |
| cleanup | 0.5 | 0.5 | 0.5 | 1.0 | 1.5 |
Weight Interpretation:
- 3.0 = Domain expert (vote counts triple)
- 2.0 = Significant expertise (vote counts double)
- 1.0 = General competence (standard vote)
- 0.5 = Peripheral relevance (half vote)
| Agent | 安全 | 身份认证 | 数据 | 算法 | 通用 |
|---|---|---|---|---|---|
| security | 3.0 | 2.5 | 2.5 | 1.5 | 1.0 |
| reviewer | 1.5 | 1.5 | 1.5 | 2.0 | 2.0 |
| architect | 1.5 | 2.0 | 2.0 | 2.5 | 2.0 |
| tester | 1.0 | 1.5 | 1.5 | 2.0 | 1.5 |
| optimizer | 0.5 | 0.5 | 0.5 | 2.5 | 1.0 |
| cleanup | 0.5 | 0.5 | 0.5 | 1.0 | 1.5 |
权重说明:
- 3.0 = 领域专家(投票权重为3倍)
- 2.0 = 具备重要专业度(投票权重为2倍)
- 1.0 = 通用能力(标准投票权重)
- 0.5 = 相关性较低(投票权重为0.5倍)
Execution Process
执行流程
Step 1: Detect Decision Domain
步骤1:检测决策领域
Analyze the change or decision to determine primary domain:
- Use analyzer agent to examine code/proposal
- Detect keywords: auth, encrypt, password, token, permission, credential
- Identify file paths: auth/, security/, crypto/
- Classify: SECURITY | AUTH | DATA | ALGORITHM | GENERAL
Domain Detection Triggers:
SECURITY: encrypt, decrypt, hash, salt, vulnerability, CVE, injection
AUTH: login, logout, session, token, jwt, oauth, password, credential
DATA: pii, gdpr, sensitive, personal, private, secret, key
ALGORITHM: sort, search, calculate, compute, process, transform分析变更或决策内容,确定主要领域:
- 使用分析Agent检查代码/提案
- 检测关键词:auth、encrypt、password、token、permission、credential
- 识别文件路径:auth/、security/、crypto/
- 分类:SECURITY | AUTH | DATA | ALGORITHM | GENERAL
领域检测触发词:
SECURITY: encrypt, decrypt, hash, salt, vulnerability, CVE, injection
AUTH: login, logout, session, token, jwt, oauth, password, credential
DATA: pii, gdpr, sensitive, personal, private, secret, key
ALGORITHM: sort, search, calculate, compute, process, transformStep 2: Select Voting Agents
步骤2:选择投票Agent
Based on detected domain, select relevant agents with weights:
For SECURITY domain:
- security agent (weight: 3.0) - Primary expert
- architect agent (weight: 1.5) - System design perspective
- reviewer agent (weight: 1.5) - Code quality check
- tester agent (weight: 1.0) - Testability assessment
For AUTH domain:
- security agent (weight: 2.5) - Security implications
- architect agent (weight: 2.0) - Integration patterns
- reviewer agent (weight: 1.5) - Implementation quality
- tester agent (weight: 1.5) - Auth flow testing
For DATA domain:
- security agent (weight: 2.5) - Data protection
- architect agent (weight: 2.0) - Data architecture
- reviewer agent (weight: 1.5) - Handling patterns
- tester agent (weight: 1.5) - Data validation
For ALGORITHM domain:
- optimizer agent (weight: 2.5) - Performance analysis
- architect agent (weight: 2.5) - Design patterns
- tester agent (weight: 2.0) - Correctness testing
- reviewer agent (weight: 2.0) - Code quality
根据检测到的领域,选择带权重的相关Agent:
SECURITY领域:
- security agent(权重:3.0) - 主要专家
- architect agent(权重:1.5) - 系统设计视角
- reviewer agent(权重:1.5) - 代码质量检查
- tester agent(权重:1.0) - 可测试性评估
AUTH领域:
- security agent(权重:2.5) - 安全影响评估
- architect agent(权重:2.0) - 集成模式
- reviewer agent(权重:1.5) - 实现质量
- tester agent(权重:1.5) - 认证流程测试
DATA领域:
- security agent(权重:2.5) - 数据保护
- architect agent(权重:2.0) - 数据架构
- reviewer agent(权重:1.5) - 处理模式
- tester agent(权重:1.5) - 数据验证
ALGORITHM领域:
- optimizer agent(权重:2.5) - 性能分析
- architect agent(权重:2.5) - 设计模式
- tester agent(权重:2.0) - 正确性测试
- reviewer agent(权重:2.0) - 代码质量
Step 3: Present Decision to Agents
步骤3:向Agent呈现决策内容
Each selected agent receives:
- Clear decision statement
- Available options (if applicable)
- Relevant context and constraints
- Evaluation criteria
Decision Prompt Template:
markdown
undefined每个选中的Agent会收到:
- 清晰的决策说明
- 可选方案(如有)
- 相关上下文与约束
- 评估标准
决策提示模板:
markdown
undefinedDecision Required: [TITLE]
待决策事项:[标题]
Domain: [SECURITY | AUTH | DATA | ALGORITHM]
Your Weight: [X.X] (based on domain expertise)
领域: [SECURITY | AUTH | DATA | ALGORITHM]
你的权重: [X.X](基于领域专业度)
Context
上下文
[Relevant background and constraints]
[相关背景与约束]
Options
可选方案
- [Reject Both]: Propose alternative
- [方案A]:[描述]
- [方案B]:[描述]
- [拒绝两者]:提出替代方案
Evaluation Criteria
评估标准
- Security implications
- Implementation complexity
- Maintainability
- Risk assessment
- 安全影响
- 实现复杂度
- 可维护性
- 风险评估
Your Vote
你的投票
Provide:
- Your vote (Option 1, 2, or Reject)
- Confidence level (HIGH, MEDIUM, LOW)
- Key reasoning (2-3 sentences max)
- Any conditions or caveats
undefined请提供:
- 投票选择(方案1、2或拒绝)
- 置信度(HIGH、MEDIUM、LOW)
- 核心理由(最多2-3句话)
- 任何条件或注意事项
undefinedStep 4: Collect Votes
步骤4:收集投票
For each agent, collect structured vote:
yaml
agent: security
weight: 3.0
vote: Option 1
confidence: HIGH
reasoning: "Option 1 follows OWASP best practices for credential storage. Option 2 uses deprecated hashing algorithm."
conditions: ["Ensure salt length >= 16 bytes", "Use constant-time comparison"]收集每个Agent的结构化投票:
yaml
agent: security
weight: 3.0
vote: Option 1
confidence: HIGH
reasoning: "Option 1 follows OWASP best practices for credential storage. Option 2 uses deprecated hashing algorithm."
conditions: ["Ensure salt length >= 16 bytes", "Use constant-time comparison"]Step 5: Calculate Weighted Result
步骤5:计算加权结果
Weighted Vote Calculation:
For each option:
weighted_score = sum(agent_weight * confidence_multiplier)
Where confidence_multiplier:
HIGH = 1.0
MEDIUM = 0.7
LOW = 0.4Example Calculation:
| Agent | Weight | Vote | Confidence | Score |
|---|---|---|---|---|
| security | 3.0 | A | HIGH | 3.0 |
| architect | 1.5 | A | MEDIUM | 1.05 |
| reviewer | 1.5 | B | HIGH | 1.5 |
| tester | 1.0 | A | LOW | 0.4 |
Option A Score: 3.0 + 1.05 + 0.4 = 4.45
Option B Score: 1.5
Total Weighted Votes: 5.95
Option A Percentage: 74.8% (SUPERMAJORITY)加权投票计算方式:
针对每个选项:
weighted_score = sum(agent_weight * confidence_multiplier)
其中置信度乘数:
HIGH = 1.0
MEDIUM = 0.7
LOW = 0.4计算示例:
| Agent | 权重 | 投票 | 置信度 | 得分 |
|---|---|---|---|---|
| security | 3.0 | A | HIGH | 3.0 |
| architect | 1.5 | A | MEDIUM | 1.05 |
| reviewer | 1.5 | B | HIGH | 1.5 |
| tester | 1.0 | A | LOW | 0.4 |
方案A得分:3.0 + 1.05 + 0.4 = 4.45
方案B得分:1.5
加权投票总分:5.95
方案A占比:74.8%(符合超级多数要求)Step 6: Apply Voting Threshold
步骤6:应用投票阈值
Based on configured voting mode:
simple-majority (50%+):
- Option with highest weighted score wins if > 50%
- If no option > 50%, proceed to debate or reject
supermajority (66%+): (DEFAULT for security)
- Winning option must have > 66% weighted votes
- Provides stronger validation for high-risk decisions
unanimous (100%):
- All agents must agree (rare, highest bar)
- Any dissent blocks decision
根据配置的投票模式:
simple-majority(超过50%):
- 加权得分最高的选项若超过50%则获胜
- 若无选项超过50%,则进入辩论或拒绝
supermajority(超过66%):(安全场景默认值)
- 获胜选项必须获得超过66%的加权投票
- 为高风险决策提供更强的验证
unanimous(100%):
- 所有Agent必须同意(罕见,要求最高)
- 任何异议都会阻止决策通过
Step 7: Report Consensus Result
步骤7:报告共识结果
If Consensus Reached:
markdown
undefined达成共识时:
markdown
undefinedConsensus Voting Result
共识投票结果
Decision: [Selected Option]
Domain: SECURITY
Threshold: Supermajority (66%+)
Result: PASSED (74.8%)
决策: [选中方案]
领域: SECURITY
阈值: 超级多数(66%+)
结果: 通过(74.8%)
Vote Summary
投票汇总
| Agent | Weight | Vote | Confidence |
|---|---|---|---|
| security | 3.0 | A | HIGH |
| architect | 1.5 | A | MEDIUM |
| reviewer | 1.5 | B | HIGH |
| tester | 1.0 | A | LOW |
| Agent | 权重 | 投票 | 置信度 |
|---|---|---|---|
| security | 3.0 | A | HIGH |
| architect | 1.5 | A | MEDIUM |
| reviewer | 1.5 | B | HIGH |
| tester | 1.0 | A | LOW |
Key Reasoning (from highest-weighted agents)
核心理由(来自最高权重Agent)
- security (3.0): "Option 1 follows OWASP best practices..."
- security (3.0): "方案1遵循OWASP凭证存储最佳实践..."
Conditions/Caveats
条件/注意事项
- Ensure salt length >= 16 bytes
- Use constant-time comparison
- 确保盐长度 >= 16字节
- 使用恒定时间比较
Dissenting View
异议观点
- reviewer (1.5): "Option B has simpler implementation..."
**If No Consensus:**
```markdown- reviewer (1.5): "方案B实现更简单..."
**未达成共识时:**
```markdownConsensus Voting Result
共识投票结果
Decision: NO CONSENSUS
Domain: AUTH
Threshold: Supermajority (66%+)
Result: FAILED (52.3%)
决策: 未达成共识
领域: AUTH
阈值: 超级多数(66%+)
结果: 未通过(52.3%)
Recommendation
建议
- Escalate to for structured trade-off analysis
/amplihack:debate - OR: Gather more information and re-vote
- OR: Accept simple majority with documented risk
undefined- 升级至进行结构化权衡分析
/amplihack:debate - 或:收集更多信息后重新投票
- 或:接受简单多数并记录风险
undefinedStep 8: Record Decision
步骤8:记录决策
- Log voting result to session decisions
- Document vote reasoning for future reference
- 将投票结果记录到会话决策中
- 记录投票理由,以备未来参考
Trade-Offs
权衡
Benefits:
- Structured decision-making for high-risk domains
- Domain expertise appropriately weighted
- Clear audit trail with reasoning
- Faster than full debate for binary/discrete choices
Costs:
- Less nuanced than debate (no synthesis)
- Requires clear options (not generative)
- Weight calibration needs real data
- May miss creative alternatives
Use When: Decision is discrete, domain expertise matters, audit trail needed
优势:
- 为高风险领域提供结构化决策机制
- 领域专业度得到合理加权
- 包含理由的清晰审计追踪
- 比完整辩论更适合二元/离散选择
成本:
- 不如辩论细致(无合成过程)
- 需要明确的可选方案(不适合生成式场景)
- 权重校准需要真实数据
- 可能错过创新性替代方案
适用场景: 决策为离散型、领域专业度重要、需要审计追踪的情况
Examples
示例
Example 1: Password Hashing Implementation
示例1:密码哈希实现选择
Context: Choosing between bcrypt, argon2id, and PBKDF2 for new auth system
Domain Detection: AUTH (password, hash)
Agents Selected:
- security (2.5), architect (2.0), reviewer (1.5), tester (1.5)
Votes:
- security: argon2id (HIGH) - "OWASP current recommendation, memory-hard"
- architect: argon2id (MEDIUM) - "Good library support, modern design"
- reviewer: bcrypt (HIGH) - "More battle-tested in production"
- tester: argon2id (MEDIUM) - "Easier to test with configurable params"
Result: argon2id wins with 68.2% (supermajority passed)
场景: 为新认证系统选择bcrypt、argon2id或PBKDF2
领域检测: AUTH(password、hash)
选中Agent:
- security (2.5)、architect (2.0)、reviewer (1.5)、tester (1.5)
投票:
- security: argon2id(HIGH)- "OWASP当前推荐的内存密集型算法"
- architect: argon2id(MEDIUM)- "库支持良好,设计现代"
- reviewer: bcrypt(HIGH)- "生产环境中经过更多实战检验"
- tester: argon2id(MEDIUM)- "参数配置更易于测试"
结果: argon2id以68.2%的支持率通过(符合超级多数要求)
Example 2: API Rate Limiting Approach
示例2:API限流方案选择
Context: Token bucket vs sliding window vs fixed window
Domain Detection: SECURITY (rate limit, protection)
Agents Selected:
- security (3.0), optimizer (1.5), architect (1.5), reviewer (1.5)
Votes:
- security: token bucket (HIGH) - "Best protection against burst attacks"
- optimizer: sliding window (MEDIUM) - "Better resource utilization"
- architect: token bucket (MEDIUM) - "Industry standard, well-understood"
- reviewer: sliding window (LOW) - "Simpler implementation"
Result: token bucket wins with 69.4% (supermajority passed)
场景: 令牌桶、滑动窗口还是固定窗口
领域检测: SECURITY(rate limit、protection)
选中Agent:
- security (3.0)、optimizer (1.5)、architect (1.5)、reviewer (1.5)
投票:
- security: 令牌桶(HIGH)- "对突发攻击的防护效果最佳"
- optimizer: 滑动窗口(MEDIUM)- "资源利用率更高"
- architect: 令牌桶(MEDIUM)- "行业标准,易于理解"
- reviewer: 滑动窗口(LOW)- "实现更简单"
结果: 令牌桶以69.4%的支持率通过(符合超级多数要求)
Example 3: No Consensus Scenario
示例3:未达成共识场景
Context: Microservices vs monolith for new feature
Domain Detection: ALGORITHM (general architecture)
Agents Selected:
- architect (2.5), optimizer (2.5), reviewer (2.0), tester (2.0)
Votes:
- architect: microservices (MEDIUM) - "Better long-term scalability"
- optimizer: monolith (HIGH) - "Simpler operations, less overhead"
- reviewer: monolith (MEDIUM) - "Easier to maintain initially"
- tester: microservices (LOW) - "Harder to test but more isolated"
Result: No consensus (52.1%) - Escalate to
/amplihack:debate场景: 新功能采用微服务还是单体架构
领域检测: ALGORITHM(通用架构)
选中Agent:
- architect (2.5)、optimizer (2.5)、reviewer (2.0)、tester (2.0)
投票:
- architect: 微服务(MEDIUM)- "长期扩展性更好"
- optimizer: 单体(HIGH)- "运维更简单,开销更小"
- reviewer: 单体(MEDIUM)- "初期维护更轻松"
- tester: 微服务(LOW)- "测试难度大但隔离性更好"
结果: 未达成共识(52.1%)- 升级至
/amplihack:debateIntegration with Other Workflows
与其他工作流集成
Handoff to Debate
移交至辩论工作流
When voting fails to reach consensus:
- Document vote results and reasoning
- Invoke with vote context
Skill(debate-workflow) - Use voting insights to frame debate perspectives
当投票无法达成共识时:
- 记录投票结果与理由
- 调用并传入投票上下文
Skill(debate-workflow) - 利用投票洞察构建辩论视角
After N-Version Implementation
N版本实现后集成
Use consensus voting to select between N-version implementations:
- N-version generates 3+ implementations
- Consensus voting selects winner
- Domain experts have weighted influence on selection
使用共识投票从N版本实现中选择最优方案:
- N版本生成3个以上实现方案
- 共识投票选出获胜方案
- 领域专家的加权意见影响选择结果
Philosophy Alignment
理念对齐
This skill enforces:
- Evidence-Based Decisions: Votes require reasoning
- Domain Expertise: Weights reflect competence
- Transparent Trade-offs: Dissent documented
- Audit Trail: Full voting record preserved
- Appropriate Rigor: Auto-triggers for high-risk domains
本Skill遵循以下原则:
- 基于证据的决策: 投票需附带理由
- 领域专业度: 权重反映能力水平
- 透明权衡: 异议会被记录
- 审计追踪: 完整投票记录被保留
- 适度严谨: 高风险领域自动触发