image.domain\self_evolve\auto_decide.mbt
70.6% · 24 / 34 points · 134 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/auto_decide - 3
/// - 4
/// 图像处理库子模块 - 5
/// 图像处理库子模块 Image processing library submodule - 6
// 自主决策引擎 — 根据预测结果自主决策演化方向 - 7
// Autonomous decision engine: decide evolution direction based on predictions - 8
// - 9
// Phase 10 v306: 将演化从"预测"推向"自主决策" — 根据预测结果自动决定演化动作。 - 10
- 11
///| - 12
/// 决策动作类型。 - 13
/// 描述 Decision action type. - 14
/// `#non_exhaustive` 表示未来可能添加新构造器 - 15
#derive(Eq, @debug.Debug) - 16
#non_exhaustive - 17
pub(all) enum DecisionAction { - 18
EvolveNow - 19
DeferEvolution - 20
SkipEvolution - 21
EscalateToManual - 22
} - 23
- 24
///| - 25
pub extend DecisionAction with @debug.Debug::{to_repr} - 26
- 27
///| - 28
pub extend DecisionAction with Eq::{not_equal, equal} - 29
- 30
///| - 31
/// 单算子自主决策。 - 32
/// 描述 Autonomous decision for a single op. - 33
#derive(Eq, @debug.Debug) - 34
pub(all) struct AutoDecision { - 35
op_tag : String - 36
action : DecisionAction - 37
confidence : Int32 - 38
rationale : String - 39
} - 40
- 41
///| - 42
pub extend AutoDecision with @debug.Debug::{to_repr} - 43
- 44
///| - 45
pub extend AutoDecision with Eq::{not_equal, equal} - 46
- 47
///| - 48
/// 决策报告。 - 49
/// 描述 Decision report. - 50
#derive(Eq, @debug.Debug) - 51
pub(all) struct DecisionReport { - 52
decisions : Array[AutoDecision] - 53
total : Int32 - 54
auto_count : Int32 - 55
deferred_count : Int32 - 56
summary : String - 57
} - 58
- 59
///| - 60
pub extend DecisionReport with @debug.Debug::{to_repr} - 61
- 62
///| - 63
pub extend DecisionReport with Eq::{not_equal, equal} - 64
- 65
///| - 66
/// 为单个算子做自主决策。 - 67
/// 描述 Make autonomous decision for a single op. - 68
pub fn decide_op(op : @imgir.IROp) -> AutoDecision { - 69●
let tag = op.tag() - 70●
let pred = predict_op(op) - 71
- 72●
let action = match pred.kind { - 73○
HighRisk => if pred.confidence >= 80 { EvolveNow } else { EscalateToManual } - 74
DegradationLikely => - 75●
if pred.confidence >= 60 { - 76●
EvolveNow - 77
} else { - 78○
DeferEvolution - 79
} - 80●
TestGrowthExpected => DeferEvolution - 81○
StableOp => SkipEvolution - 82
} - 83●
let rationale = match action { - 84
EvolveNow => - 85●
tag + " 立即演化: 预测 " + pred.confidence.to_string() + "% 置信" - 86●
DeferEvolution => tag + " 推迟演化: 预期改善,非紧急" - 87○
SkipEvolution => tag + " 跳过演化: 稳定无风险" - 88
EscalateToManual => - 89○
tag + - 90
" 升级人工: 置信度不足 (" + - 91○
pred.confidence.to_string() + - 92
"%)" - 93
} - 94
{ op_tag: tag, action, confidence: pred.confidence, rationale, } - 95
} - 96
- 97
///| - 98
/// 为所有算子做自主决策。 - 99
/// 描述 Make autonomous decisions for all ops. - 100
pub fn decide_all() -> DecisionReport { - 101●
let decisions : Array[AutoDecision] = [] - 102
let mut auto_count = 0 - 103
let mut deferred_count = 0 - 104●
for op in all_ops() { - 105●
let d = decide_op(op) - 106
if d.action is EvolveNow { - 107○
auto_count = auto_count + 1 - 108●
} else if d.action is DeferEvolution { - 109●
deferred_count = deferred_count + 1 - 110
} - 111●
decisions.push(d) - 112
} - 113●
let total = decisions.length() - 114
let summary = "自主决策: " + - 115●
total.to_string() + - 116
" 算子, " + - 117●
auto_count.to_string() + - 118
" 自主演化, " + - 119●
deferred_count.to_string() + - 120
" 推迟" - 121
{ decisions, total, auto_count, deferred_count, summary, } - 122
} - 123
- 124
///| - 125
/// 决策报告是否可以全自主执行(无人工升级)。 - 126
/// 描述 Whether decision report can be fully auto-run (no manual escalation). - 127
pub fn DecisionReport::can_auto_run(self : DecisionReport) -> Bool { - 128●
for d in self.decisions { - 129●
if d.action is EscalateToManual { - 130○
return false - 131
} - 132
} - 133
true - 134
}