image.domain\self_evolve\recommend.mbt
91.2% · 31 / 34 points · 159 linesBackground color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.
- 1
///| - 2
/// # 推荐 self_evolve/recommend - 3
/// - 4
/// 图像处理库子模块 - 5
/// 图像处理库子模块 Image processing library submodule - 6
// 演化推荐引擎 — 根据当前状态推荐下一步演化 - 7
// Evolution recommendation engine: recommend next evolution step based on current state - 8
// - 9
// Phase 8 v298: 将演化从"被动"推向"主动推荐" — 根据覆盖/退化/传播推荐下一步。 - 10
- 11
///| - 12
/// 推荐动作类型。 - 13
/// 描述 Recommendation action type. - 14
/// `#non_exhaustive` 表示未来可能添加新构造器 - 15
#derive(Eq, @debug.Debug) - 16
#non_exhaustive - 17
pub(all) enum RecommendAction { - 18
AddTests - 19
FixDegradation - 20
AddPropagationTest - 21
OptimizePipeline - 22
NoActionNeeded - 23
} - 24
- 25
///| - 26
pub extend RecommendAction with @debug.Debug::{to_repr} - 27
- 28
///| - 29
pub extend RecommendAction with Eq::{not_equal, equal} - 30
- 31
///| - 32
/// 单条演化推荐。 - 33
/// 描述 Single evolution recommendation. - 34
#derive(Eq, @debug.Debug) - 35
pub(all) struct Recommendation { - 36
action : RecommendAction - 37
target_op : String - 38
priority : TestPriority - 39
reason : String - 40
} - 41
- 42
///| - 43
pub extend Recommendation with @debug.Debug::{to_repr} - 44
- 45
///| - 46
pub extend Recommendation with Eq::{not_equal, equal} - 47
- 48
///| - 49
/// 推荐报告。 - 50
/// 描述 Recommendation report. - 51
#derive(Eq, @debug.Debug) - 52
pub(all) struct RecommendationReport { - 53
recommendations : Array[Recommendation] - 54
total : Int32 - 55
high_priority_count : Int32 - 56
summary : String - 57
} - 58
- 59
///| - 60
pub extend RecommendationReport with @debug.Debug::{to_repr} - 61
- 62
///| - 63
pub extend RecommendationReport with Eq::{not_equal, equal} - 64
- 65
///| - 66
/// 推荐单算子下一步演化。 - 67
/// 描述 Recommend next evolution step for a single op. - 68
pub fn recommend_next(op : @imgir.IROp) -> Recommendation { - 69●
let tag = op.tag() - 70●
let degs = detect_degradation(op) - 71●
let cov = coverage_percentage(op) - 72●
if degs.length() > 0 { - 73●
{ - 74
action: FixDegradation, - 75
target_op: tag, - 76
priority: HighPriority, - 77●
reason: tag + " 有 " + degs.length().to_string() + " 个退化需修复", - 78
} - 79●
} else if cov < 50 { - 80○
{ - 81
action: AddTests, - 82
target_op: tag, - 83
priority: MediumPriority, - 84○
reason: tag + " 覆盖率仅 " + cov.to_string() + "%,需增加测试", - 85
} - 86
} else { - 87●
{ - 88
action: NoActionNeeded, - 89
target_op: tag, - 90
priority: LowPriority, - 91
reason: tag + " 状态良好,无需操作", - 92
} - 93
} - 94
} - 95
- 96
///| - 97
/// 推荐全算子演化。 - 98
/// 描述 Recommend evolution for all ops. - 99
pub fn recommend_all() -> RecommendationReport { - 100●
let recs : Array[Recommendation] = [] - 101
let mut high_count = 0 - 102●
for op in all_ops() { - 103●
let rec = recommend_next(op) - 104
if rec.priority is HighPriority { - 105○
high_count = high_count + 1 - 106
} - 107●
recs.push(rec) - 108
} - 109●
let total = recs.length() - 110
let summary = "演化推荐: " + - 111●
total.to_string() + - 112
" 条推荐, " + - 113●
high_count.to_string() + - 114
" 条高优先级" - 115
{ recommendations: recs, total, high_priority_count: high_count, summary, } - 116
} - 117
- 118
///| - 119
/// 推荐管道演化。 - 120
/// 描述 Recommend evolution for a pipeline. - 121
pub fn recommend_for_pipeline( - 122
pipeline : @imgir.IRPipeline, - 123
) -> RecommendationReport { - 124●
let recs : Array[Recommendation] = [] - 125
let mut high_count = 0 - 126●
let has_prop = has_propagation_risk(pipeline) - 127
if has_prop { - 128●
recs.push({ - 129
action: AddPropagationTest, - 130
target_op: "pipeline", - 131
priority: HighPriority, - 132
reason: "管道有传播风险,需添加传播测试", - 133
}) - 134
high_count = high_count + 1 - 135
} - 136
for op in pipeline.ops { - 137●
let rec = recommend_next(op) - 138
if rec.priority is HighPriority { - 139●
high_count = high_count + 1 - 140
} - 141●
recs.push(rec) - 142
} - 143●
let total = recs.length() - 144
let summary = "管道推荐: " + - 145●
total.to_string() + - 146
" 条推荐, " + - 147●
high_count.to_string() + - 148
" 条高优先级(管道 " + - 149●
@imgir.ir_describe(pipeline) + - 150
")" - 151
{ recommendations: recs, total, high_priority_count: high_count, summary, } - 152
} - 153
- 154
///| - 155
/// 推荐报告是否有紧急推荐。 - 156
/// 描述 Whether recommendation report has urgent items. - 157
pub fn RecommendationReport::has_urgent(self : RecommendationReport) -> Bool { - 158●
self.high_priority_count > 0 - 159
}