image.domain\self_evolve\schedule.mbt
86.4% · 19 / 22 points · 142 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/schedule - 3
/// - 4
/// 图像处理库子模块 - 5
/// 图像处理库子模块 Image processing library submodule - 6
// 演化调度引擎 — 调度并执行自动演化周期 - 7
// Evolution schedule engine: schedule and execute automatic evolution cycles - 8
// - 9
// Phase 9 v301: 将演化从"手动"推向"自动调度" — 创建调度→执行→报告。 - 10
- 11
///| - 12
/// 调度状态。 - 13
/// 调度 Schedule status. - 14
/// `#non_exhaustive` 表示未来可能添加新构造器 - 15
#derive(Eq, @debug.Debug) - 16
#non_exhaustive - 17
pub(all) enum ScheduleStatus { - 18
Pending - 19
Running - 20
Completed - 21
Failed - 22
} - 23
- 24
///| - 25
pub extend ScheduleStatus with @debug.Debug::{to_repr} - 26
- 27
///| - 28
pub extend ScheduleStatus with Eq::{not_equal, equal} - 29
- 30
///| - 31
/// 演化调度计划。 - 32
/// 描述 Evolution schedule plan. - 33
#derive(Eq, @debug.Debug) - 34
pub(all) struct EvolutionSchedule { - 35
schedule_id : String - 36
ops_count : Int32 - 37
status : ScheduleStatus - 38
description : String - 39
} - 40
- 41
///| - 42
pub extend EvolutionSchedule with @debug.Debug::{to_repr} - 43
- 44
///| - 45
pub extend EvolutionSchedule with Eq::{not_equal, equal} - 46
- 47
///| - 48
/// 调度执行结果。 - 49
/// 调度 Schedule execution result. - 50
#derive(Eq, @debug.Debug) - 51
pub(all) struct ScheduleResult { - 52
schedule : EvolutionSchedule - 53
evolved_count : Int32 - 54
fixed_count : Int32 - 55
remaining_count : Int32 - 56
summary : String - 57
} - 58
- 59
///| - 60
pub extend ScheduleResult with @debug.Debug::{to_repr} - 61
- 62
///| - 63
pub extend ScheduleResult with Eq::{not_equal, equal} - 64
- 65
///| - 66
/// 为给定算子列表创建演化调度。 - 67
/// 创建 Create evolution schedule for given ops. - 68
pub fn create_schedule(ops : Array[@imgir.IROp]) -> EvolutionSchedule { - 69●
let count = ops.length() - 70●
let id = "sched-" + count.to_string() + "-ops" - 71
{ - 72
schedule_id: id, - 73
ops_count: count, - 74
status: Pending, - 75●
description: "调度 " + count.to_string() + " 个算子的演化周期", - 76
} - 77
} - 78
- 79
///| - 80
/// 执行演化调度。 - 81
/// 执行 Execute evolution schedule. - 82
pub fn run_schedule(schedule : EvolutionSchedule) -> ScheduleResult { - 83●
let running_schedule = { - 84
schedule_id: schedule.schedule_id, - 85
ops_count: schedule.ops_count, - 86
status: Running, - 87
description: schedule.description, - 88
} - 89●
let ops = all_ops() - 90
let mut evolved = 0 - 91
let mut fixed = 0 - 92
let mut remaining = 0 - 93
for op in ops { - 94●
let degs = detect_degradation(op) - 95●
let rec = recommend_next(op) - 96●
if degs.length() > 0 { - 97○
evolved = evolved + 1 - 98
if rec.action is FixDegradation { - 99○
fixed = fixed + 1 - 100
} else { - 101○
remaining = remaining + 1 - 102
} - 103
} else { - 104●
evolved = evolved + 1 - 105
} - 106
} - 107
let completed_schedule = { - 108
schedule_id: running_schedule.schedule_id, - 109
ops_count: running_schedule.ops_count, - 110
status: Completed, - 111
description: running_schedule.description, - 112
} - 113
let summary = "调度执行完成: " + - 114●
evolved.to_string() + - 115
" 算子已演化, " + - 116●
fixed.to_string() + - 117
" 退化已修复, " + - 118●
remaining.to_string() + - 119
" 退化待修复" - 120
{ - 121
schedule: completed_schedule, - 122
evolved_count: evolved, - 123
fixed_count: fixed, - 124
remaining_count: remaining, - 125
summary, - 126
} - 127
} - 128
- 129
///| - 130
/// 运行全量演化周期(所有算子)。 - 131
/// 运行 Run full evolution cycle (all ops). - 132
pub fn run_full_evolution() -> ScheduleResult { - 133●
let schedule = create_schedule(all_ops()) - 134●
run_schedule(schedule) - 135
} - 136
- 137
///| - 138
/// 调度结果是否成功(无剩余退化)。 - 139
/// 描述 Whether schedule result is successful (no remaining degradations). - 140
pub fn ScheduleResult::is_successful(self : ScheduleResult) -> Bool { - 141●
self.schedule.status is Completed && self.remaining_count == 0 - 142
}