fix(qa): 无法判定的判错结论不再计入正确率分母
build / build (push) Successful in 1m18s

根因为“结果不清”或未归因的判错记录移出正确率分母,并以 unjudged 单独返回,覆盖率口径不变。
统计规则版本升到 calendar-month-strict-yes-over-yes-no-v2,前端严格解析同步接受该字段。
This commit is contained in:
hermes
2026-10-25 23:11:12 +08:00
parent 1d880a0f49
commit 1d33ff6976
5 changed files with 74 additions and 11 deletions
@@ -1,6 +1,7 @@
package qaopsmirror
import (
"knowledge-governance/internal/qaopsquality"
"testing"
"time"
)
@@ -31,3 +32,32 @@ func TestQualityMonthCrossingWeekIsPreviousMonthReport(t *testing.T) {
})
}
}
func TestStrictQualityLeavesUnjudgeableAnswersOutOfTheCorrectnessDenominator(t *testing.T) {
start := monthlyTestTime(t, "2026-10-01T00:00:00+08:00")
end := monthlyTestTime(t, "2026-11-01T00:00:00+08:00")
at := start.Add(time.Hour)
view := func(coverage, correctness, cause string) qaopsquality.View {
return qaopsquality.View{State: "unreviewed", Effective: qaopsquality.Fields{Coverage: coverage, Correctness: correctness, RootCause: cause}}
}
records := []dashboardTimedQuality{
{id: "correct", at: at, view: view("covered", "correct", "")},
{id: "real-error", at: at, view: view("covered", "incorrect", "答案生成错误")},
{id: "unclear", at: at, view: view("covered", "incorrect", dashboardUnclearCause)},
{id: "unlabelled", at: at, view: view("covered", "incorrect", "")},
{id: "pending", at: at, view: view("uncovered", "pending", "")},
}
got := dashboardStrictQuality(records, start, end)
if got.Correctness.Numerator != 1 || got.Correctness.Denominator != 2 {
t.Fatalf("correctness = %d/%d, want 1/2 (only genuinely judged answers)", got.Correctness.Numerator, got.Correctness.Denominator)
}
if got.Unjudged != 2 {
t.Fatalf("unjudged = %d, want 2 (结果不清 + missing root cause)", got.Unjudged)
}
if got.Coverage.Numerator != 4 || got.Coverage.Denominator != 5 {
t.Fatalf("coverage = %d/%d, want 4/5 unchanged by the correctness rule", got.Coverage.Numerator, got.Coverage.Denominator)
}
if dashboardMonthlyPolicy != "calendar-month-strict-yes-over-yes-no-v2" {
t.Fatal("policy version must change when the denominator changes")
}
}