image.domain\self_evolve\meta_evolve.mbt
84.6% · 33 / 39 points · 191 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/meta_evolve - 3
/// - 4
/// 图像处理库子模块 - 5
/// 图像处理库子模块 Image processing library submodule - 6
// 自演化 Meta — 元演化(演化演化本身) - 7
// Meta evolution: evolve the evolution process itself - 8
// - 9
// Phase 11 v314: 将演化从"质量评估"推向"元演化" — 演化演化本身。 - 10
- 11
///| - 12
/// 元演化策略。 - 13
/// 描述 Meta evolution strategy. - 14
/// `#non_exhaustive` 表示未来可能添加新构造器 - 15
#derive(Eq, @debug.Debug) - 16
#non_exhaustive - 17
pub(all) enum MetaStrategy { - 18
TightenThresholds // 收紧阈值 - 19
LoosenThresholds // 放宽阈值 - 20
AddTestCategory // 增加测试类别 - 21
RemoveRedundancy // 消除冗余 - 22
IncreaseCoverage // 提升覆盖 - 23
} - 24
- 25
///| - 26
pub extend MetaStrategy with @debug.Debug::{to_repr} - 27
- 28
///| - 29
pub extend MetaStrategy with Eq::{not_equal, equal} - 30
- 31
///| - 32
/// 元演化动作。 - 33
/// 描述 Meta evolution action. - 34
#derive(Eq, @debug.Debug) - 35
pub(all) struct MetaAction { - 36
strategy : MetaStrategy - 37
target_param : String - 38
current_value : Int32 - 39
new_value : Int32 - 40
rationale : String - 41
} - 42
- 43
///| - 44
pub extend MetaAction with @debug.Debug::{to_repr} - 45
- 46
///| - 47
pub extend MetaAction with Eq::{not_equal, equal} - 48
- 49
///| - 50
/// 元演化报告。 - 51
/// 描述 Meta evolution report. - 52
#derive(Eq, @debug.Debug) - 53
pub(all) struct MetaReport { - 54
actions : Array[MetaAction] - 55
total_strategies : Int32 - 56
applied_count : Int32 - 57
summary : String - 58
} - 59
- 60
///| - 61
pub extend MetaReport with @debug.Debug::{to_repr} - 62
- 63
///| - 64
pub extend MetaReport with Eq::{not_equal, equal} - 65
- 66
///| - 67
/// 对单个算子进行元演化。 - 68
/// 性能 Perform meta evolution for a single op. - 69
pub fn meta_evolve_op(op : @imgir.IROp) -> MetaReport { - 70●
let tag = op.tag() - 71●
let quality = eval_quality_op(op) - 72
let actions : Array[MetaAction] = [] - 73
for qs in quality.scores { - 74●
match qs.dimension { - 75
TestCoverage => - 76●
if qs.score < 80 { - 77●
actions.push({ - 78
strategy: IncreaseCoverage, - 79
target_param: "coverage_threshold", - 80
current_value: 80, - 81
new_value: 70, - 82
rationale: tag + - 83
" 覆盖 " + - 84●
qs.score.to_string() + - 85
"% → 降低阈值加速演化", - 86
}) - 87
} - 88
DegradationRate => - 89●
if qs.score < 100 { - 90●
actions.push({ - 91
strategy: TightenThresholds, - 92
target_param: "degradation_tolerance", - 93
current_value: 3, - 94
new_value: 2, - 95
rationale: tag + - 96
" 退化评分 " + - 97●
qs.score.to_string() + - 98
" → 收紧容忍", - 99
}) - 100
} - 101
PerformanceGain => - 102●
if qs.score > 80 { - 103○
actions.push({ - 104
strategy: RemoveRedundancy, - 105
target_param: "redundant_tests", - 106
current_value: 5, - 107
new_value: 3, - 108
rationale: tag + - 109
" 评分 " + - 110○
qs.score.to_string() + - 111
" → 消除冗余测试", - 112
}) - 113
} - 114
CodeStability => - 115●
if qs.score < 70 { - 116●
actions.push({ - 117
strategy: AddTestCategory, - 118
target_param: "test_categories", - 119
current_value: 3, - 120
new_value: 4, - 121
rationale: tag + - 122
" 稳定性 " + - 123●
qs.score.to_string() + - 124
" → 增加边界测试", - 125
}) - 126
} - 127
ApiCompatibility => - 128●
if quality.overall_score > 90 { - 129○
actions.push({ - 130
strategy: LoosenThresholds, - 131
target_param: "evolve_threshold", - 132
current_value: 60, - 133
new_value: 50, - 134
rationale: tag + - 135
" 总分 " + - 136○
quality.overall_score.to_string() + - 137
" → 放宽阈值加速", - 138
}) - 139
} - 140
} - 141
} - 142●
let applied = actions.length() - 143
let total_strategies = 5 - 144
let summary = "元演化[" + - 145
tag + - 146
"]: " + - 147●
applied.to_string() + - 148
" 动作, 总分 " + - 149●
quality.overall_score.to_string() - 150
{ actions, total_strategies, applied_count: applied, summary, } - 151
} - 152
- 153
///| - 154
/// 对所有算子进行元演化。 - 155
/// 性能 Perform meta evolution for all ops. - 156
pub fn meta_evolve_all() -> MetaReport { - 157●
let all_actions : Array[MetaAction] = [] - 158
let mut total_applied = 0 - 159●
for op in all_ops() { - 160●
let report = meta_evolve_op(op) - 161
for a in report.actions { - 162●
all_actions.push(a) - 163
} - 164
total_applied = total_applied + report.applied_count - 165
} - 166
let summary = "全量元演化: " + - 167●
all_actions.length().to_string() + - 168
" 动作, " + - 169●
total_applied.to_string() + - 170
" 已应用" - 171
{ - 172
actions: all_actions, - 173
total_strategies: 5, - 174
applied_count: total_applied, - 175
summary, - 176
} - 177
} - 178
- 179
///| - 180
/// 元演化报告是否有变更。 - 181
/// 描述 Whether meta report has changes. - 182
pub fn MetaReport::has_changes(self : MetaReport) -> Bool { - 183●
self.applied_count > 0 - 184
} - 185
- 186
///| - 187
/// 元演化报告策略数。 - 188
/// 描述 Strategy count. - 189
pub fn MetaReport::strategy_count(self : MetaReport) -> Int32 { - 190●
self.total_strategies - 191
}