返回 DeepSeek-Reasonix
strict_model_test.go
根目录 / internal / boot / strict_model_test.go
1 package boot
2
3 import (
4 "context"
5 "strings"
6 "testing"
7
8 "reasonix/internal/agent/testutil"
9 "reasonix/internal/event"
10 )
11
12 func TestBuildFailsWhenGuardianModelIsUnresolvable(t *testing.T) {
13 isolateConfigHome(t)
14 dir := robustTempDir(t)
15 t.Chdir(dir)
16 registerBootTokenProfileTestProvider()
17 setBootTokenProfileTestProvider(t, testutil.NewMock("guardian-missing"))
18
19 writeFile(t, dir, "reasonix.toml", `
20 default_model = "executor"
21
22 [agent]
23 guardian_model = "missing-guardian"
24
25 [[providers]]
26 name = "executor"
27 kind = "boot-token-profile-test"
28 model = "executor-model"
29 `)
30 approveWorkspace(t, dir)
31
32 ctrl, err := Build(context.Background(), Options{Sink: event.Discard})
33 if err == nil || !strings.Contains(err.Error(), "guardian_model") {
34 t.Fatalf("Build = (%v, %v), want a guardian_model configuration error", ctrl, err)
35 }
36 }
37
38 func TestBuildIgnoresRetiredRecoveryModel(t *testing.T) {
39 isolateConfigHome(t)
40 dir := robustTempDir(t)
41 t.Chdir(dir)
42 registerBootTokenProfileTestProvider()
43 setBootTokenProfileTestProvider(t, testutil.NewMock("recovery-missing"))
44
45 writeFile(t, dir, "reasonix.toml", `
46 default_model = "executor"
47
48 [agent]
49 recovery_model = "missing-recovery"
50
51 [[providers]]
52 name = "executor"
53 kind = "boot-token-profile-test"
54 model = "executor-model"
55 `)
56 approveWorkspace(t, dir)
57
58 ctrl, err := Build(context.Background(), Options{Sink: event.Discard})
59 if err != nil {
60 t.Fatalf("retired recovery_model affected Build: %v", err)
61 }
62 defer ctrl.Close()
63 }
64
65 func TestBuildLeavesOptionalRolesOffWithoutExplicitModels(t *testing.T) {
66 isolateConfigHome(t)
67 dir := robustTempDir(t)
68 t.Chdir(dir)
69 registerBootTokenProfileTestProvider()
70 setBootTokenProfileTestProvider(t, testutil.NewMock("roles-off"))
71
72 writeFile(t, dir, "reasonix.toml", `
73 default_model = "executor"
74
75 [[providers]]
76 name = "executor"
77 kind = "boot-token-profile-test"
78 model = "executor-model"
79 `)
80 approveWorkspace(t, dir)
81
82 var notices []string
83 sink := event.FuncSink(func(e event.Event) {
84 if e.Kind == event.Notice {
85 notices = append(notices, e.Text)
86 }
87 })
88 ctrl, err := Build(context.Background(), Options{Sink: sink})
89 if err != nil {
90 t.Fatalf("Build: %v", err)
91 }
92 defer ctrl.Close()
93 for _, n := range notices {
94 if strings.Contains(strings.ToLower(n), "guardian enabled") {
95 t.Fatalf("guardian started without guardian_model: %v", notices)
96 }
97 }
98 if strings.Contains(ctrl.Label(), "planner") {
99 t.Fatalf("planner started without planner_model: %q", ctrl.Label())
100 }
101 }
102
102 lines GO