Add typed jevdecide HTTP client (circuit, metrics) and coordinator DecideAssist wiring behind JEV_DECIDE_MODE (default off). Offline eval and synthetic soak evidence gate realtime/profile before assist rollout.
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package jevdecide_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"chat-agent-system/internal/coordinator"
|
|
"chat-agent-system/internal/jevdecide"
|
|
)
|
|
|
|
func TestRegoldProfileIfRequested(t *testing.T) {
|
|
if os.Getenv("REGOLD_PROFILE") != "1" {
|
|
t.Skip("set REGOLD_PROFILE=1")
|
|
}
|
|
path := filepath.Join("testdata", "eval-v1.json")
|
|
raw, err := os.ReadFile(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var file struct {
|
|
SchemaVersion int `json:"schema_version"`
|
|
Description string `json:"description"`
|
|
Cases []struct {
|
|
ID string `json:"id"`
|
|
Suite string `json:"suite"`
|
|
Input string `json:"input"`
|
|
Gold map[string]any `json:"gold"`
|
|
} `json:"cases"`
|
|
}
|
|
if err := json.Unmarshal(raw, &file); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for i := range file.Cases {
|
|
c := &file.Cases[i]
|
|
if c.Suite != "profile" {
|
|
continue
|
|
}
|
|
p := coordinator.ProfileTask(c.Input, nil)
|
|
c.Gold = map[string]any{
|
|
"bucket": jevdecide.ProfileBucket(p.ComplexityScore),
|
|
"score": p.ComplexityScore,
|
|
"form": string(p.DeliverableForm),
|
|
}
|
|
}
|
|
out, _ := json.MarshalIndent(file, "", " ")
|
|
if err := os.WriteFile(path, append(out, '\n'), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|