image.domain\self_evolve\ci_hook.mbt

94.6% · 35 / 37 points · 109 lines

Background color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.

  1. 1///|
  2. 2/// # CI 钩子 self_evolve/ci_hook
  3. 3///
  4. 4/// 图像处理库子模块
  5. 5/// 图像处理库子模块 Image processing library submodule
  6. 6// 自演化 CI 集成 — moon test 自动演化钩子 + 回归门禁
  7. 7// CI integration: auto-evolution hooks + regression gate
  8. 8//
  9. 9// Phase 5 v284: 将自演化集成到 CI — 门禁检查(grill + repair + optimize)+ 回归检测。
  10. 10
  11. 11///|
  12. 12/// CI 门禁结果。
  13. 13/// 描述 CI gate result.
  14. 14#derive(Eq, @debug.Debug)
  15. 15pub(all) struct CIGateResult {
  16. 16 passed : Bool
  17. 17 total_checks : Int32
  18. 18 failed_checks : Int32
  19. 19 gate_summary : String
  20. 20}
  21. 21
  22. 22///|
  23. 23pub extend CIGateResult with @debug.Debug::{to_repr}
  24. 24
  25. 25///|
  26. 26pub extend CIGateResult with Eq::{not_equal, equal}
  27. 27
  28. 28///|
  29. 29/// CI 门禁检查:对管道执行 grill + repair + optimize 全套检查。
  30. 30/// 描述 CI gate check: run grill + repair + optimize on a pipeline.
  31. 31pub fn ci_gate_check(pipeline : @imgir.IRPipeline) -> CIGateResult {
  32. 32● let grill_report = run_grill_check(pipeline)
  33. 33● let repair_rep = repair_report(pipeline)
  34. 34● let opt_verified = optimize_verified(pipeline)
  35. 35 // 三项检查
  36. 36 let checks : Array[(String, Bool)] = []
  37. 37● checks.push(("grill_all_passed", grill_report.all_passed()))
  38. 38● checks.push(("repair_fully_repaired", repair_rep.is_fully_repaired()))
  39. 39● checks.push(("optimize_verified", opt_verified))
  40. 40● let total = checks.length()
  41. 41 let mut failed = 0
  42. 42 for c in checks {
  43. 43● if !c.1 {
  44. 44● failed = failed + 1
  45. 45 }
  46. 46 }
  47. 47 let passed = failed == 0
  48. 48 let summary = "CI 门禁: " +
  49. 49● (total - failed).to_string() +
  50. 50 "/" +
  51. 51● total.to_string() +
  52. 52 " 通过, " +
  53. 53● failed.to_string() +
  54. 54 " 失败"
  55. 55 { passed, total_checks: total, failed_checks: failed, gate_summary: summary, }
  56. 56}
  57. 57
  58. 58///|
  59. 59/// 对全部 19 种算子执行 CI 门禁检查。
  60. 60/// 运行 Run CI gate check on all 19 op variants.
  61. 61pub fn ci_gate_all() -> Array[CIGateResult] {
  62. 62● let results : Array[CIGateResult] = []
  63. 63● for op in all_ops() {
  64. 64● let pipe = @imgir.IRPipeline::new().add(op)
  65. 65● results.push(ci_gate_check(pipe))
  66. 66 }
  67. 67 results
  68. 68}
  69. 69
  70. 70///|
  71. 71/// 回归门禁:优化后不劣化 + 修复后无退化。
  72. 72/// 描述 Regression gate: optimization non-degrading + repair fully fixed.
  73. 73pub fn ci_regression_gate(pipeline : @imgir.IRPipeline) -> Bool {
  74. 74● let opt_ok = optimize_verified(pipeline)
  75. 75● let repair_rep = repair_report(pipeline)
  76. 76● opt_ok && repair_rep.is_fully_repaired()
  77. 77}
  78. 78
  79. 79///|
  80. 80/// 全部 19 算子是否通过回归门禁。
  81. 81/// 描述 Whether all 19 ops pass regression gate.
  82. 82pub fn ci_regression_all_pass() -> Bool {
  83. 83● let mut all_ok = true
  84. 84● for op in all_ops() {
  85. 85● let pipe = @imgir.IRPipeline::new().add(op)
  86. 86● if !ci_regression_gate(pipe) {
  87. 87○ all_ok = false
  88. 88 }
  89. 89 }
  90. 90 all_ok
  91. 91}
  92. 92
  93. 93///|
  94. 94/// CI 门禁通过率(0-100)。
  95. 95/// 描述 CI gate pass rate (0-100).
  96. 96pub fn CIGateResult::pass_rate(self : CIGateResult) -> Int32 {
  97. 97● if self.total_checks == 0 {
  98. 98○ 100
  99. 99 } else {
  100. 100● (self.total_checks - self.failed_checks) * 100 / self.total_checks
  101. 101 }
  102. 102}
  103. 103
  104. 104///|
  105. 105/// CI 门禁是否全通过。
  106. 106/// 描述 Whether CI gate fully passed.
  107. 107pub fn CIGateResult::is_green(self : CIGateResult) -> Bool {
  108. 108● self.failed_checks == 0
  109. 109}