返回 DeepSeek-Reasonix
contextual_visibility_test.go
根目录 / internal / tool / builtin / contextual_visibility_test.go
1 package builtin
2
3 import (
4 "context"
5 "testing"
6
7 "reasonix/internal/jobs"
8 "reasonix/internal/tool"
9 )
10
11 func TestContextualBuiltinVisibilityFollowsOwningContext(t *testing.T) {
12 goal, _ := tool.LookupBuiltin("update_goal")
13 jobNames := []string{"bash_output", "wait", "kill_shell"}
14
15 if goal.(tool.ContextualTool).ProviderVisible(context.Background()) {
16 t.Fatal("update_goal visible without a Goal lifecycle owner")
17 }
18 if !goal.(tool.ContextualTool).ProviderVisible(goalLifecycleContext(&goalLifecycleStub{view: goalView()}, tool.GoalSourceDirectHuman)) {
19 t.Fatal("update_goal hidden with a Goal lifecycle owner")
20 }
21 if _, ok := tool.LookupBuiltin("complete_step"); ok {
22 t.Fatal("retired complete_step remains discoverable")
23 }
24 for _, name := range jobNames {
25 t.Run(name, func(t *testing.T) {
26 candidate, ok := tool.LookupBuiltin(name)
27 if !ok {
28 t.Fatal("missing builtin")
29 }
30 contextual := candidate.(tool.ContextualTool)
31 if contextual.ProviderVisible(context.Background()) {
32 t.Fatal("job tool visible without a manager")
33 }
34 if !contextual.ProviderVisible(jobs.WithManager(context.Background(), &jobs.Manager{})) {
35 t.Fatal("job tool hidden with an owned manager")
36 }
37 })
38 }
39 }
40
40 lines GO