image.domain\self_evolve\regression.mbt
60% · 15 / 25 points · 168 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/regression - 3
/// - 4
/// 图像处理库子模块 - 5
/// 图像处理库子模块 Image processing library submodule - 6
// 跨版本回归检测 — 检测版本间退化回归 - 7
// Cross-version regression detection: detect degradation regressions across versions - 8
// - 9
// Phase 9 v302: 将演化从"调度"推向"回归检测" — 比较历史快照,发现退化回归。 - 10
- 11
///| - 12
/// 回归类型。 - 13
/// 描述 Regression kind. - 14
/// `#non_exhaustive` 表示未来可能添加新构造器 - 15
#derive(Eq, @debug.Debug) - 16
#non_exhaustive - 17
pub(all) enum RegressionKind { - 18
DegradationIncrease - 19
TestDecrease - 20
OpCountChange - 21
NoRegression - 22
} - 23
- 24
///| - 25
pub extend RegressionKind with @debug.Debug::{to_repr} - 26
- 27
///| - 28
pub extend RegressionKind with Eq::{not_equal, equal} - 29
- 30
///| - 31
/// 单个回归案例。 - 32
/// 描述 Single regression case. - 33
#derive(Eq, @debug.Debug) - 34
pub(all) struct RegressionCase { - 35
from_version : String - 36
to_version : String - 37
kind : RegressionKind - 38
delta : Int32 - 39
description : String - 40
} - 41
- 42
///| - 43
pub extend RegressionCase with @debug.Debug::{to_repr} - 44
- 45
///| - 46
pub extend RegressionCase with Eq::{not_equal, equal} - 47
- 48
///| - 49
/// 回归检测报告。 - 50
/// 描述 Regression detection report. - 51
#derive(Eq, @debug.Debug) - 52
pub(all) struct RegressionReport { - 53
cases : Array[RegressionCase] - 54
total_regressions : Int32 - 55
total_improvements : Int32 - 56
summary : String - 57
} - 58
- 59
///| - 60
pub extend RegressionReport with @debug.Debug::{to_repr} - 61
- 62
///| - 63
pub extend RegressionReport with Eq::{not_equal, equal} - 64
- 65
///| - 66
/// 检测历史快照间的回归。 - 67
/// 检测 Detect regressions across history snapshots. - 68
pub fn detect_regressions() -> RegressionReport { - 69●
let log = history_log() - 70
let entries = log.entries - 71●
let n = entries.length() - 72
let cases : Array[RegressionCase] = [] - 73
let mut reg_count = 0 - 74
let mut imp_count = 0 - 75
for i in 1..<n { - 76●
let prev = entries[i - 1] - 77
let curr = entries[i] - 78
let deg_delta = curr.degradation_count - prev.degradation_count - 79
let test_delta = curr.test_count - prev.test_count - 80
if deg_delta > 0 { - 81○
cases.push({ - 82
from_version: prev.version, - 83
to_version: curr.version, - 84
kind: DegradationIncrease, - 85
delta: deg_delta, - 86
description: prev.version + - 87
" → " + - 88
curr.version + - 89
": 退化增加 " + - 90○
deg_delta.to_string(), - 91
}) - 92
reg_count = reg_count + 1 - 93
} - 94
if test_delta < 0 { - 95○
cases.push({ - 96
from_version: prev.version, - 97
to_version: curr.version, - 98
kind: TestDecrease, - 99
delta: test_delta, - 100
description: prev.version + - 101
" → " + - 102
curr.version + - 103
": 测试减少 " + - 104○
(-test_delta).to_string(), - 105
}) - 106
reg_count = reg_count + 1 - 107
} - 108
if prev.op_count != curr.op_count { - 109○
cases.push({ - 110
from_version: prev.version, - 111
to_version: curr.version, - 112
kind: OpCountChange, - 113
delta: curr.op_count - prev.op_count, - 114
description: prev.version + - 115
" → " + - 116
curr.version + - 117
": 算子数 " + - 118○
prev.op_count.to_string() + - 119
" → " + - 120○
curr.op_count.to_string(), - 121
}) - 122
} - 123
if deg_delta <= 0 && test_delta >= 0 { - 124●
cases.push({ - 125
from_version: prev.version, - 126
to_version: curr.version, - 127
kind: NoRegression, - 128
delta: 0, - 129
description: prev.version + " → " + curr.version + ": 无回归", - 130
}) - 131
imp_count = imp_count + 1 - 132
} - 133
} - 134●
let total = cases.length() - 135
let summary = "回归检测: " + - 136●
total.to_string() + - 137
" 个比较, " + - 138●
reg_count.to_string() + - 139
" 回归, " + - 140●
imp_count.to_string() + - 141
" 改进" - 142
{ - 143
cases, - 144
total_regressions: reg_count, - 145
total_improvements: imp_count, - 146
summary, - 147
} - 148
} - 149
- 150
///| - 151
/// 检查指定版本是否有回归(退化数 > 0)。 - 152
/// 描述 Whether a specific version has regressions (degradation count > 0). - 153
pub fn has_regression(version : String) -> Bool { - 154●
let log = history_log() - 155
for e in log.entries { - 156●
if e.version == version { - 157●
return e.degradation_count > 0 - 158
} - 159
} - 160
false - 161
} - 162
- 163
///| - 164
/// 回归报告是否无回归。 - 165
/// 描述 Whether regression report is clean (no regressions). - 166
pub fn RegressionReport::is_clean(self : RegressionReport) -> Bool { - 167●
self.total_regressions == 0 - 168
}