QE缺陷智能Skill "QEDefectIntelligence"

这是一个AI驱动的缺陷预测技能,用于软件质量管理。它通过机器学习模型预测易缺陷代码、分析失败模式并执行根因分析,帮助团队提前识别风险、优化测试优先级并提高软件质量。关键词:缺陷预测、机器学习、根因分析、软件测试、质量管理、AI应用。

测试 0 次安装 0 次浏览 更新于 3/9/2026

name: “QE缺陷智能” description: “AI驱动的缺陷预测、模式学习和根因分析,用于主动质量管理。” trust_tier: 3 validation: schema_path: schemas/output.json validator_path: scripts/validate-config.json eval_path: evals/qe-defect-intelligence.yaml


QE缺陷智能

目的

指导使用v3的缺陷智能功能,包括基于机器学习的缺陷预测、历史数据中的模式识别和自动化的根因分析。

激活

  • 当预测易缺陷代码时
  • 当分析失败模式时
  • 当执行根因分析时
  • 当从过去的缺陷中学习时
  • 当基于风险优先级测试时

快速开始

# 预测更改代码中的缺陷
aqe defect predict --changes HEAD~5..HEAD

# 分析失败模式
aqe defect patterns --period 90d --min-occurrences 3

# 根因分析
aqe defect rca --failure "test/auth.test.ts:45"

# 从已解决的缺陷中学习
aqe defect learn --source jira --status resolved

代理工作流

// 缺陷预测
Task("预测易缺陷代码", `
  分析PR #456更改并预测缺陷可能性:
  - 历史缺陷相关性
  - 代码复杂度因素
  - 作者对模块的经验
  - 测试覆盖度差距
  标记高风险更改需要额外审查。
`, "qe-defect-predictor")

// 根因分析
Task("分析测试失败", `
  调查AuthService测试中的重复失败:
  - 收集失败历史(最近30天)
  - 识别常见模式
  - 追踪到潜在根本原因
  - 使用5-为什么分析建议修复
`, "qe-root-cause-analyzer")

预测模型

1. 基于更改的预测

await defectPredictor.predictFromChanges({
  changes: prChanges,
  factors: {
    codeChurn: { weight: 0.2 },
    complexity: { weight: 0.25 },
    authorExperience: { weight: 0.15 },
    fileHistory: { weight: 0.2 },
    testCoverage: { weight: 0.2 }
  },
  threshold: {
    high: 0.7,
    medium: 0.4,
    low: 0.2
  }
});

2. 模式学习

await patternLearner.learnPatterns({
  source: {
    defects: 'jira:project=MYAPP&type=bug',
    commits: 'git:last-6-months',
    tests: 'test-results:last-1000-runs'
  },
  patterns: [
    '代码异味到缺陷',
    '更改耦合',
    '测试差距相关性',
    '复杂度缺陷密度'
  ],
  output: {
    rules: true,
    visualizations: true,
    recommendations: true
  }
});

3. 根因分析

await rootCauseAnalyzer.analyze({
  failure: testFailure,
  methods: [
    'five-whys',
    'fishbone-diagram',
    'fault-tree',
    'change-impact'
  ],
  context: {
    recentChanges: true,
    environmentDiff: true,
    dependencyChanges: true,
    similarFailures: true
  }
});

缺陷预测报告

interface DefectPrediction {
  file: string;
  riskScore: number;  // 0-1
  riskLevel: 'critical' | 'high' | 'medium' | 'low';
  factors: {
    name: string;
    contribution: number;
    details: string;
  }[];
  historicalDefects: {
    count: number;
    recent: Defect[];
    patterns: string[];
  };
  recommendations: {
    action: string;
    priority: string;
    expectedRiskReduction: number;
  }[];
}

模式类别

模式 检测 预防
空指针 静态分析 空值检查、可选类型
竞争条件 并发分析 锁、原子操作
内存泄漏 堆分析 资源清理
差一错误 边界分析 循环不变量
注入 污点分析 输入验证

根因模板

root_cause_analysis:
  five_whys:
    max_depth: 5
    prompt_template: "为什么发生了{effect}?"

  fishbone:
    categories:
      - 人员
      - 流程
      - 工具
      - 环境
      - 材料
      - 测量

  fault_tree:
    top_event: "测试失败"
    gate_types: [AND, OR, NOT]
    basic_events: true

与问题跟踪集成

await defectIntelligence.syncWithTracker({
  source: 'jira',
  project: 'MYAPP',
  sync: {
    defectData: '双向同步',
    predictions: '创建任务',
    patterns: '更新标签'
  },
  automation: {
    flagHighRisk: true,
    suggestAssignee: true,
    linkRelated: true
  }
});

协调

主要代理: qe-defect-predictor, qe-pattern-learner, qe-root-cause-analyzer 协调者: qe-defect-intelligence-coordinator 相关技能: qe-coverage-analysis, qe-quality-assessment