Files
ARTEX-chixuweihu/agent/finding_cases_test.go
T
RuoJi6 09e90b4170 feat(findings): grouped duplicate suggestions, ranked candidates, relaxed merged acceptance (Codex rewrite)
Authored entirely by Codex CLI (codex exec, reasoning effort high), one session
resumed across capacity fallbacks:
- gpt-6.1-sol (schema + initial db work, stopped at capacity)
- gpt-6-astra (db/server/agent/frontend, stopped at capacity)
- gpt-6-sol (remaining items, tests, fixes; stopped at capacity after final checks)

Schemes 1+2+3: prompt/acceptance (2..20, evidenced differences justify
independent, merged no longer blocked by unified report), group suggestions with
member table, superset reuse/subset superseded, veto-aware reject/exclusion,
anchor re-anchoring trigger, sweep after merge/reject/remove, frontend group card
with stale-response guard, candidate scoring with tier/hit_reasons/strong_total.
2026-10-24 21:55:45 +08:00

62 lines
2.7 KiB
Go

package agent
import (
"context"
"encoding/json"
"strings"
"testing"
actool "github.com/Autumn-27/norma/tool"
)
func TestFindingCaseGuidanceRespectsToolsAndTrafficSwitch(t *testing.T) {
tools := []actool.CoreTool{}
for _, name := range []string{"search_finding_duplicates", "merge_finding_records", "get_finding_case", "update_finding_case_report"} {
tools = append(tools, writeTool(name, name, obj(nil), func(context.Context, json.RawMessage) (actool.Result, error) { return actool.Text("ok"), nil }))
}
_, guide := findingCaseWorkflow("reporter", tools)
if !strings.Contains(guide, "不能直接取成员最高等级") || !strings.Contains(guide, "独立报告") {
t.Fatal("missing preservation rules")
}
if _, guide := findingCaseWorkflow("worker", tools); guide != "" {
t.Fatal("worker changed")
}
if _, guide := findingCaseWorkflow("reporter", tools[:2]); guide != "" {
t.Fatal("unbound tools reintroduced")
}
system, _ := deferredSystem("CUSTOM PROMPT", DeferredInfo{CaseGuidance: guide})
if !strings.HasPrefix(system[0], "CUSTOM PROMPT") || !strings.Contains(system[0], guide) {
t.Fatal("custom prompt lost")
}
}
func TestHistoricalFindingReviewFiltersMutationAndProbeTools(t *testing.T) {
oldAugment, oldResolve := ToolAugment, ToolResolve
ToolAugment, ToolResolve = nil, nil
t.Cleanup(func() { ToolAugment, ToolResolve = oldAugment, oldResolve })
tools := []actool.CoreTool{}
for _, name := range []string{"update_finding_report", "bind_finding_traffic", "report_finding", "Bash", "Write", "Edit", "mcp__custom__write", "get_finding_record", "merge_finding_records", "search_finding_duplicates", "get_finding_case", "update_finding_case_report", "complete_finding_case_review"} {
tools = append(tools, writeTool(name, name, obj(nil), func(context.Context, json.RawMessage) (actool.Result, error) { return actool.Text("ok"), nil }))
}
out, def, cleanup := AugmentTools(WithFindingCaseReview(t.Context()), "reporter", tools)
defer cleanup()
for _, tool := range out {
switch tool.Name() {
case "update_finding_report", "bind_finding_traffic", "report_finding", "Bash", "Write", "Edit", "mcp__custom__write":
t.Fatal("historical mutation capability", tool.Name())
}
}
if len(out) != 6 || def.FindingGuidance != "" || !strings.Contains(def.CaseGuidance, "历史整理模式") || !strings.Contains(def.CaseGuidance, "端点/路由") || !strings.Contains(def.CaseGuidance, "2..20") {
t.Fatal("missing historical isolation", def)
}
normal, _, cl := AugmentTools(t.Context(), "reporter", tools)
defer cl()
found := map[string]bool{}
for _, tool := range normal {
found[tool.Name()] = true
}
if !found["update_finding_report"] || !found["Bash"] || !found["report_finding"] {
t.Fatal("normal reporting was restricted")
}
}