| 1 | package planmode_test |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "reasonix/internal/planmode" |
| 7 | "reasonix/internal/tool" |
| 8 | |
| 9 | _ "reasonix/internal/tool/builtin" |
| 10 | ) |
| 11 | |
| 12 | func TestBuiltinPhaseClassifiersMatchPolicy(t *testing.T) { |
| 13 | builtins := tool.Builtins() |
| 14 | if len(builtins) == 0 { |
| 15 | t.Fatal("tool.Builtins() is empty") |
| 16 | } |
| 17 | for _, tl := range builtins { |
| 18 | safety := planmode.PlanSafetyUnknown |
| 19 | if classifier, ok := tl.(tool.PlanModeClassifier); ok { |
| 20 | if classifier.PlanModeSafe() { |
| 21 | safety = planmode.PlanSafetySafe |
| 22 | } else { |
| 23 | safety = planmode.PlanSafetyUnsafe |
| 24 | } |
| 25 | } |
| 26 | got := (planmode.Policy{}).Decide(planmode.Call{ |
| 27 | Name: tl.Name(), |
| 28 | ReadOnly: tl.ReadOnly(), |
| 29 | Safety: safety, |
| 30 | }) |
| 31 | if got.Blocked != (safety == planmode.PlanSafetyUnsafe) { |
| 32 | t.Errorf("builtin %q safety=%v decision=%+v", tl.Name(), safety, got) |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | func TestRetiredCompleteStepIsNotDiscoverable(t *testing.T) { |
| 38 | if _, ok := tool.LookupBuiltin("complete_step"); ok { |
| 39 | t.Fatal("retired complete_step builtin remains discoverable") |
| 40 | } |
| 41 | } |
| 42 |