Why: Layout rules alone do not produce conclusion-first documents, extra views, or infographics, and nothing scored a deliverable before it was returned. Evidence: go test ./internal/prompts/ ./internal/quality/ ./internal/tools/ ./internal/squadadapter/ ./eval/ -count=1 and the house-style unittest passed in the previous session. Impact: Every task inherits content rules. Meetings, reports, and comparisons can name a view family. Long documents without a visual summary warn. quality_review and the squad checker share one scorecard. Refs: deliverable-quality-system A1-A5 Co-authored-by: Cursor <cursoragent@cursor.com>
63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
// Package eval 用固定样例比较交付质量。真实会议材料放在仓外
|
|
// ~/.agent-system/eval/,或用 EVAL_DIR 指向该目录;仓内只放脱敏短样例。
|
|
package eval
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"agent-system-backend/internal/quality"
|
|
)
|
|
|
|
func TestDesensitizedSampleBeatsColumnNotes(t *testing.T) {
|
|
good := scoreFixture(t, "good.md")
|
|
bad := scoreFixture(t, "bad.md")
|
|
if !good.Passed {
|
|
t.Fatalf("good fixture should pass: %+v", good)
|
|
}
|
|
if bad.Score >= good.Score {
|
|
t.Fatalf("bad %d should be below good %d", bad.Score, good.Score)
|
|
}
|
|
missing := MissingThemes(readFixture(t, "good.md"), []string{"相关性", "标签", "未指明"})
|
|
if len(missing) > 0 {
|
|
t.Fatalf("good fixture missed themes %v", missing)
|
|
}
|
|
}
|
|
|
|
func TestExternalEvalDirOptional(t *testing.T) {
|
|
dir := os.Getenv("EVAL_DIR")
|
|
if dir == "" {
|
|
home, err := os.UserHomeDir()
|
|
if err != nil {
|
|
t.Skip(err)
|
|
}
|
|
dir = filepath.Join(home, ".agent-system", "eval")
|
|
}
|
|
entries, err := os.ReadDir(dir)
|
|
if err != nil {
|
|
t.Skip("no external eval dir")
|
|
}
|
|
for _, entry := range entries {
|
|
if entry.IsDir() || filepath.Ext(entry.Name()) != ".md" {
|
|
continue
|
|
}
|
|
report := quality.ScoreFile(filepath.Join(dir, entry.Name()))
|
|
t.Logf("%s score=%d passed=%v", entry.Name(), report.Score, report.Passed)
|
|
}
|
|
}
|
|
|
|
func scoreFixture(t *testing.T, name string) quality.Report {
|
|
t.Helper()
|
|
return quality.ScoreText(readFixture(t, name))
|
|
}
|
|
|
|
func readFixture(t *testing.T, name string) string {
|
|
t.Helper()
|
|
data, err := os.ReadFile(filepath.Join("testdata", name))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return string(data)
|
|
}
|