image.domain\self_evolve\evolve_loop_full.mbt
97.5% · 39 / 40 points · 148 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/evolve_loop_full - 3
/// - 4
/// 图像处理库子模块 - 5
/// 图像处理库子模块 Image processing library submodule - 6
// 自演化闭环 — 完整的自主演化闭环 - 7
// Evolution loop: complete autonomous evolution loop - 8
// - 9
// Phase 10 v309: 将演化从"参数调优"推向"闭环" — 预测→决策→策略→调优→执行→验证。 - 10
- 11
///| - 12
/// 闭环阶段。 - 13
/// 描述 Loop phase. - 14
/// `#non_exhaustive` 表示未来可能添加新构造器 - 15
#derive(Eq, @debug.Debug) - 16
#non_exhaustive - 17
pub(all) enum LoopPhase { - 18
Predict - 19
Decide - 20
Strategize - 21
Tune - 22
Execute - 23
Verify - 24
Done - 25
} - 26
- 27
///| - 28
pub extend LoopPhase with @debug.Debug::{to_repr} - 29
- 30
///| - 31
pub extend LoopPhase with Eq::{not_equal, equal} - 32
- 33
///| - 34
/// 单个闭环步骤。 - 35
/// 描述 Single loop step. - 36
#derive(Eq, @debug.Debug) - 37
pub(all) struct LoopStep { - 38
phase : LoopPhase - 39
result_desc : String - 40
} - 41
- 42
///| - 43
pub extend LoopStep with @debug.Debug::{to_repr} - 44
- 45
///| - 46
pub extend LoopStep with Eq::{not_equal, equal} - 47
- 48
///| - 49
/// 闭环执行结果。 - 50
/// 描述 Loop execution result. - 51
#derive(Eq, @debug.Debug) - 52
pub(all) struct LoopResult { - 53
steps : Array[LoopStep] - 54
total_phases : Int32 - 55
success : Bool - 56
summary : String - 57
} - 58
- 59
///| - 60
pub extend LoopResult with @debug.Debug::{to_repr} - 61
- 62
///| - 63
pub extend LoopResult with Eq::{not_equal, equal} - 64
- 65
///| - 66
/// 为单个算子运行完整演化闭环。 - 67
/// 运行 Run complete evolution loop for a single op. - 68
pub fn run_evolve_loop(op : @imgir.IROp) -> LoopResult { - 69●
let tag = op.tag() - 70
let steps : Array[LoopStep] = [] - 71●
let pred = predict_op(op) - 72●
steps.push({ - 73
phase: Predict, - 74
result_desc: tag + " 预测: " + pred.description, - 75
}) - 76●
let decision = decide_op(op) - 77●
steps.push({ - 78
phase: Decide, - 79
result_desc: tag + " 决策: " + decision.rationale, - 80
}) - 81●
let combo = combine_strategies(op) - 82●
steps.push({ - 83
phase: Strategize, - 84
result_desc: tag + " 策略: " + combo.description, - 85
}) - 86●
let params = tune_params(op) - 87●
steps.push({ - 88
phase: Tune, - 89●
result_desc: tag + " 调优: " + params.length().to_string() + " 参数", - 90
}) - 91●
let sched = create_schedule([op]) - 92●
let result = run_schedule(sched) - 93●
steps.push({ - 94
phase: Execute, - 95
result_desc: tag + " 执行: " + result.summary, - 96
}) - 97●
let degs = detect_degradation(op) - 98●
let verify_desc = if degs.length() == 0 { - 99●
tag + " 验证: 无退化" - 100
} else { - 101●
tag + " 验证: " + degs.length().to_string() + " 退化残留" - 102
} - 103●
steps.push({ phase: Verify, result_desc: verify_desc, }) - 104●
steps.push({ phase: Done, result_desc: tag + " 闭环完成", }) - 105●
let total = steps.length() - 106
let success = decision.action is EvolveNow || decision.action is SkipEvolution - 107
let summary = "演化闭环[" + - 108
tag + - 109
"]: " + - 110●
total.to_string() + - 111
" 阶段, " + - 112●
(if success { "成功" } else { "需关注" }) - 113
{ steps, total_phases: total, success, summary, } - 114
} - 115
- 116
///| - 117
/// 为所有算子运行完整演化闭环。 - 118
/// 运行 Run complete evolution loop for all ops. - 119
pub fn run_evolve_loop_all() -> LoopResult { - 120●
let all_steps : Array[LoopStep] = [] - 121
let mut all_success = true - 122
let mut total_ops = 0 - 123●
for op in all_ops() { - 124●
let result = run_evolve_loop(op) - 125
for s in result.steps { - 126●
all_steps.push(s) - 127
} - 128
if !result.success { - 129●
all_success = false - 130
} - 131
total_ops = total_ops + 1 - 132
} - 133●
let total = all_steps.length() - 134
let summary = "全量演化闭环: " + - 135●
total_ops.to_string() + - 136
" 算子, " + - 137●
total.to_string() + - 138
" 阶段, " + - 139◐
(if all_success { "全部成功" } else { "部分需关注" }) - 140
{ steps: all_steps, total_phases: total, success: all_success, summary, } - 141
} - 142
- 143
///| - 144
/// 闭环结果是否完整完成。 - 145
/// 描述 Whether loop result is complete. - 146
pub fn LoopResult::is_complete(self : LoopResult) -> Bool { - 147●
self.total_phases > 0 - 148
}