Why: Downstream products must extend the base through a public package and host API instead of editing internal code. Evidence: go test ./... passed, including plugin v2 assets, sidecar startup, migration v13, pending confirms, HITL timeout, hash embedder, command pairs, and the extension surface snapshot. Impact: apiVersion 2.0-experimental rejects empty network allowlists for declarative HTTP. Hash embeddings stay opt-in via models.embedding.provider=hash. Plugin secrets resolve per owner at execution time. Refs: docs/proposals/2026-10-01-plugin-contract-v2.md Co-authored-by: Cursor <cursoragent@cursor.com>
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
// Package evalgold 是通用任务黄金集的最小回归夹具。
|
|
// 领域指标(阶段映射、相关性三态)留在下游仓;这里只锁住「规则层不得误触发」。
|
|
package evalgold
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
// Case 是一条黄金样本。Want 为空表示规则层必须保持沉默。
|
|
type Case struct {
|
|
Input string `json:"input"`
|
|
Want string `json:"want"`
|
|
}
|
|
|
|
// Classify 是可替换的规则层。当前实现只认识显式危险短语,避免闲聊误触发。
|
|
func Classify(input string) string {
|
|
if strings.Contains(input, "删除全部") {
|
|
return "danger"
|
|
}
|
|
return ""
|
|
}
|
|
|
|
// Load 读取黄金集。
|
|
func Load(path string) ([]Case, error) {
|
|
raw, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var cases []Case
|
|
if err := json.Unmarshal(raw, &cases); err != nil {
|
|
return nil, err
|
|
}
|
|
return cases, nil
|
|
}
|
|
|
|
// Check 返回第一条失配。空字符串表示通过。
|
|
func Check(cases []Case) string {
|
|
for _, c := range cases {
|
|
if got := Classify(c.Input); got != c.Want {
|
|
return c.Input + ": got " + got + " want " + c.Want
|
|
}
|
|
}
|
|
return ""
|
|
}
|