image.domain\self_evolve\cross_module.mbt
94.4% · 34 / 36 points · 240 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/cross_module - 3
/// - 4
/// 图像处理库子模块 - 5
/// 图像处理库子模块 Image processing library submodule - 6
// 跨模块演化协同 — 跨模块协同演化 - 7
// Cross-module evolution coordination: coordinate evolution across modules - 8
// - 9
// Phase 11 v312: 将演化从"知识图谱"推向"跨模块协同" — 多模块协同演化。 - 10
- 11
///| - 12
/// 模块依赖类型。 - 13
/// 描述 Module dependency kind. - 14
/// `#non_exhaustive` 表示未来可能添加新构造器 - 15
#derive(Eq, @debug.Debug) - 16
#non_exhaustive - 17
pub(all) enum ModuleDepKind { - 18
Uses // 使用 - 19
Extends // 扩展 - 20
Composes // 组合 - 21
} - 22
- 23
///| - 24
pub extend ModuleDepKind with @debug.Debug::{to_repr} - 25
- 26
///| - 27
pub extend ModuleDepKind with Eq::{not_equal, equal} - 28
- 29
///| - 30
/// 模块依赖关系。 - 31
/// 描述 Module dependency. - 32
#derive(Eq, @debug.Debug) - 33
pub(all) struct ModuleDep { - 34
source : String - 35
target : String - 36
kind : ModuleDepKind - 37
} - 38
- 39
///| - 40
pub extend ModuleDep with @debug.Debug::{to_repr} - 41
- 42
///| - 43
pub extend ModuleDep with Eq::{not_equal, equal} - 44
- 45
///| - 46
/// 协同演化动作类型。 - 47
/// 描述 Co-evolution action kind. - 48
/// `#non_exhaustive` 表示未来可能添加新构造器 - 49
#derive(Eq, @debug.Debug) - 50
#non_exhaustive - 51
pub(all) enum CoEvolveActionKind { - 52
SyncEvolve // 同步演化 - 53
CascadeEvolve // 级联演化 - 54
IndependentEvolve // 独立演化 - 55
} - 56
- 57
///| - 58
pub extend CoEvolveActionKind with @debug.Debug::{to_repr} - 59
- 60
///| - 61
pub extend CoEvolveActionKind with Eq::{not_equal, equal} - 62
- 63
///| - 64
/// 协同演化动作。 - 65
/// 描述 Co-evolution action. - 66
#derive(Eq, @debug.Debug) - 67
pub(all) struct CoEvolveAction { - 68
action_kind : CoEvolveActionKind - 69
source_module : String - 70
target_module : String - 71
description : String - 72
} - 73
- 74
///| - 75
pub extend CoEvolveAction with @debug.Debug::{to_repr} - 76
- 77
///| - 78
pub extend CoEvolveAction with Eq::{not_equal, equal} - 79
- 80
///| - 81
/// 协同演化报告。 - 82
/// 描述 Co-evolution report. - 83
#derive(Eq, @debug.Debug) - 84
pub(all) struct CoEvolveReport { - 85
actions : Array[CoEvolveAction] - 86
total_modules : Int32 - 87
sync_count : Int32 - 88
cascade_count : Int32 - 89
summary : String - 90
} - 91
- 92
///| - 93
pub extend CoEvolveReport with @debug.Debug::{to_repr} - 94
- 95
///| - 96
pub extend CoEvolveReport with Eq::{not_equal, equal} - 97
- 98
///| - 99
/// 构建 self_evolve 内部模块依赖图。 - 100
/// 构建 Build module dependency graph for self_evolve internal modules. - 101
pub fn build_module_deps() -> Array[ModuleDep] { - 102●
[ - 103
{ source: "degrade_detect", target: "evolve_types", kind: Uses, }, - 104
{ source: "test_gen", target: "evolve_types", kind: Uses, }, - 105
{ source: "optimize", target: "equiv_check", kind: Uses, }, - 106
{ source: "optimize", target: "evolve_types", kind: Uses, }, - 107
{ source: "equiv_check", target: "evolve_types", kind: Uses, }, - 108
{ source: "evolve", target: "degrade_detect", kind: Composes, }, - 109
{ source: "evolve", target: "test_gen", kind: Composes, }, - 110
{ source: "evolve", target: "optimize", kind: Composes, }, - 111
{ source: "schedule", target: "evolve", kind: Extends, }, - 112
{ source: "auto_decide", target: "predict", kind: Uses, }, - 113
{ source: "strategy_combo", target: "degrade_detect", kind: Uses, }, - 114
{ source: "param_tune", target: "evolve_types", kind: Uses, }, - 115
{ source: "evolve_loop_full", target: "auto_decide", kind: Composes, }, - 116
{ source: "evolve_loop_full", target: "strategy_combo", kind: Composes, }, - 117
{ source: "evolve_loop_full", target: "param_tune", kind: Composes, }, - 118
{ source: "knowledge_graph", target: "degrade_detect", kind: Uses, }, - 119
{ source: "knowledge_graph", target: "smart_priority", kind: Uses, }, - 120
] - 121
} - 122
- 123
///| - 124
/// 为单个算子分析跨模块协同演化。 - 125
/// 描述 Analyze cross-module co-evolution for a single op. - 126
pub fn co_evolve_op(op : @imgir.IROp) -> CoEvolveReport { - 127●
let tag = op.tag() - 128
let actions : Array[CoEvolveAction] = [] - 129
let mut sync_count = 0 - 130
let mut cascade_count = 0 - 131●
let degs = detect_degradation(op) - 132●
if degs.length() > 0 { - 133●
actions.push({ - 134
action_kind: SyncEvolve, - 135
source_module: "degrade_detect", - 136
target_module: "test_gen", - 137
description: tag + ": 退化检测→测试生成 同步演化", - 138
}) - 139
sync_count = sync_count + 1 - 140●
actions.push({ - 141
action_kind: CascadeEvolve, - 142
source_module: "equiv_check", - 143
target_module: "optimize", - 144
description: tag + ": 等价性→优化 级联演化", - 145
}) - 146
cascade_count = cascade_count + 1 - 147●
actions.push({ - 148
action_kind: SyncEvolve, - 149
source_module: "degrade_detect", - 150
target_module: "knowledge_graph", - 151
description: tag + ": 退化→知识图谱 同步更新", - 152
}) - 153
sync_count = sync_count + 1 - 154
} - 155●
let cov = coverage_percentage(op) - 156
if cov < 80 { - 157●
actions.push({ - 158
action_kind: IndependentEvolve, - 159
source_module: "test_gen", - 160
target_module: "test_gen", - 161●
description: tag + ": 覆盖率 " + cov.to_string() + "% → 补充测试", - 162
}) - 163
} - 164●
let score = score_op(op) - 165
if score.score > 50 { - 166○
actions.push({ - 167
action_kind: CascadeEvolve, - 168
source_module: "optimize", - 169
target_module: "equiv_check", - 170
description: tag + ": 优化→等价性验证 级联演化", - 171
}) - 172
cascade_count = cascade_count + 1 - 173
} - 174●
if actions.length() == 0 { - 175●
actions.push({ - 176
action_kind: IndependentEvolve, - 177
source_module: "optimize", - 178
target_module: "optimize", - 179
description: tag + ": 无需协同,独立优化", - 180
}) - 181
} - 182
let total_modules = 5 - 183
let summary = "跨模块协同[" + - 184
tag + - 185
"]: " + - 186●
actions.length().to_string() + - 187
" 动作, " + - 188●
sync_count.to_string() + - 189
" 同步, " + - 190●
cascade_count.to_string() + - 191
" 级联" - 192
{ actions, total_modules, sync_count, cascade_count, summary, } - 193
} - 194
- 195
///| - 196
/// 为所有算子分析跨模块协同演化。 - 197
/// 描述 Analyze cross-module co-evolution for all ops. - 198
pub fn co_evolve_all() -> CoEvolveReport { - 199●
let all_actions : Array[CoEvolveAction] = [] - 200
let mut total_sync = 0 - 201
let mut total_cascade = 0 - 202
let mut total_modules = 0 - 203●
for op in all_ops() { - 204●
let report = co_evolve_op(op) - 205
for a in report.actions { - 206●
all_actions.push(a) - 207
} - 208
total_sync = total_sync + report.sync_count - 209
total_cascade = total_cascade + report.cascade_count - 210
total_modules = total_modules + report.total_modules - 211
} - 212
let summary = "全量跨模块协同: " + - 213●
all_actions.length().to_string() + - 214
" 动作, " + - 215●
total_sync.to_string() + - 216
" 同步, " + - 217●
total_cascade.to_string() + - 218
" 级联" - 219
{ - 220
actions: all_actions, - 221
total_modules, - 222
sync_count: total_sync, - 223
cascade_count: total_cascade, - 224
summary, - 225
} - 226
} - 227
- 228
///| - 229
/// 协同演化报告是否有级联演化。 - 230
/// 描述 Whether co-evolution report has cascade actions. - 231
pub fn CoEvolveReport::has_cascade(self : CoEvolveReport) -> Bool { - 232●
self.cascade_count > 0 - 233
} - 234
- 235
///| - 236
/// 协同演化报告总动作数。 - 237
/// 描述 Total action count. - 238
pub fn CoEvolveReport::total_actions(self : CoEvolveReport) -> Int32 { - 239●
self.actions.length() - 240
}