返回 DeepSeek-Reasonix
ablation_test.go
根目录 / internal / boot / ablation_test.go
1 package boot
2
3 import (
4 "context"
5 "path/filepath"
6 "testing"
7
8 "reasonix/internal/ablation"
9 "reasonix/internal/event"
10 )
11
12 func builtToolNames(t *testing.T, set ablation.Set) map[string]bool {
13 t.Helper()
14 ctrl, err := Build(context.Background(), Options{
15 SessionDir: filepath.Join(t.TempDir(), "sessions"),
16 TokenMode: TokenModeFull,
17 Sink: event.Discard,
18 Ablation: set,
19 })
20 if err != nil {
21 t.Fatalf("Build(%s): %v", set.Arm(), err)
22 }
23 defer ctrl.Close()
24 // Ablation is judged against the full registry (including use_capability
25 // dispatch targets), not only the lean provider-visible surface.
26 names := map[string]bool{}
27 for _, e := range ctrl.AllToolContractEntries() {
28 names[e.Name] = true
29 }
30 return names
31 }
32
33 func TestAblationRemovesOnlyTheTargetedToolSurfaces(t *testing.T) {
34 isolateConfigHome(t)
35 t.Chdir(robustTempDir(t))
36
37 full := builtToolNames(t, ablation.Set{})
38 for _, name := range []string{"task", "read_only_task", "history", "memory", "remember", "list_sessions", "set_session_title"} {
39 if !full[name] {
40 t.Fatalf("control arm is missing %s; the ablation assertions below would be vacuous", name)
41 }
42 }
43 if !full["use_capability"] {
44 t.Fatal("control arm must register use_capability")
45 }
46
47 noSubagent := builtToolNames(t, ablation.New(ablation.Subagent))
48 for _, name := range []string{"task", "read_only_task", "parallel_tasks", "fleet"} {
49 if noSubagent[name] {
50 t.Errorf("subagent ablation left %s registered", name)
51 }
52 }
53 if !noSubagent["history"] || !noSubagent["memory"] {
54 t.Error("subagent ablation must not touch the retrieval surfaces")
55 }
56
57 noRetrieval := builtToolNames(t, ablation.New(ablation.Retrieval))
58 for _, name := range []string{"history", "memory"} {
59 if noRetrieval[name] {
60 t.Errorf("retrieval ablation left the BM25-backed %s registered", name)
61 }
62 }
63 for _, name := range []string{"remember", "forget", "list_sessions", "read_session", "task"} {
64 if !noRetrieval[name] {
65 t.Errorf("retrieval ablation dropped %s, which is not a retrieval surface", name)
66 }
67 }
68 }
69
69 lines GO