质量追踪器:计算、更新 Skill 质量指标,并在明显劣化时自动停用。
核心指标:
applied_rate— 选中后实际应用的比率completion_rate— 应用后任务完成的比率effective_rate— 端到端效率(选中 → 应用 → 完成)fallback_rate— 选中但未应用的比率(不可用信号)
v0.2 新增:自动停用(deactivation)
update_from_analysis/2 每次更新 SkillRecord 后,若满足以下全部条件,
会把 is_active 置为 false(保留档案用于审计):
total_selections >= min_samples(默认 5)applied_rate < applied_min或effective_rate < effective_mintrend != :improving
参数从 Application 环境读取:
config :cmdc_skill_engine, :quality_gates,
min_samples: 5,
applied_min: 0.3,
effective_min: 0.2,
trend_window: 10想在测试里临时覆盖,传 opts 给 update_from_analysis/3。
Summary
Functions
返回当前有效的 quality_gates 设置(合并 Application + opts 覆盖后)。
@spec should_deactivate?( CMDCSkillEngine.Types.SkillRecord.t(), keyword() ) :: boolean()
只计算是否应该停用,不修改 record。便于外部审查 / debug。
@spec trend(CMDCSkillEngine.Types.SkillRecord.t(), non_neg_integer()) :: %{ effective_rate: float(), trend: :improving | :stable | :declining }
@spec update_from_analysis( CMDCSkillEngine.Types.SkillRecord.t(), CMDCSkillEngine.Types.ExecutionAnalysis.t(), keyword() ) :: CMDCSkillEngine.Types.SkillRecord.t()