@@ -1145,6 +1145,69 @@ func TestFeatureFlagBoth(t *testing.T) {
11451145 }
11461146}
11471147
1148+ func TestFeatureFlagMultipleEnableFlags (t * testing.T ) {
1149+ // Tool requires BOTH flag_a AND flag_b (AND semantics).
1150+ tool := mockTool ("dual_enable_tool" , "toolset1" , true )
1151+ tool .FeatureFlagEnable = []string {"flag_a" , "flag_b" }
1152+ tools := []ServerTool {tool }
1153+
1154+ // Neither flag enabled → excluded
1155+ checkerNone := func (_ context.Context , _ string ) (bool , error ) { return false , nil }
1156+ regNone := mustBuild (t , NewBuilder ().SetTools (tools ).WithToolsets ([]string {"all" }).WithFeatureChecker (checkerNone ))
1157+ if len (regNone .AvailableTools (context .Background ())) != 0 {
1158+ t .Error ("Tool should be excluded when no enable flags are on" )
1159+ }
1160+
1161+ // Only flag_a enabled → excluded (flag_b still missing)
1162+ checkerOnlyA := func (_ context.Context , flag string ) (bool , error ) { return flag == "flag_a" , nil }
1163+ regOnlyA := mustBuild (t , NewBuilder ().SetTools (tools ).WithToolsets ([]string {"all" }).WithFeatureChecker (checkerOnlyA ))
1164+ if len (regOnlyA .AvailableTools (context .Background ())) != 0 {
1165+ t .Error ("Tool should be excluded when only one of two enable flags is on" )
1166+ }
1167+
1168+ // Both flags enabled → included
1169+ checkerBoth := func (_ context.Context , _ string ) (bool , error ) { return true , nil }
1170+ regBoth := mustBuild (t , NewBuilder ().SetTools (tools ).WithToolsets ([]string {"all" }).WithFeatureChecker (checkerBoth ))
1171+ if len (regBoth .AvailableTools (context .Background ())) != 1 {
1172+ t .Error ("Tool should be included when all enable flags are on" )
1173+ }
1174+ }
1175+
1176+ func TestFeatureFlagMultipleDisableFlags (t * testing.T ) {
1177+ // Tool is blocked when EITHER kill_a OR kill_b is enabled (OR semantics).
1178+ tool := mockTool ("dual_disable_tool" , "toolset1" , true )
1179+ tool .FeatureFlagDisable = []string {"kill_a" , "kill_b" }
1180+ tools := []ServerTool {tool }
1181+
1182+ // Neither kill flag on → included
1183+ checkerNone := func (_ context.Context , _ string ) (bool , error ) { return false , nil }
1184+ regNone := mustBuild (t , NewBuilder ().SetTools (tools ).WithToolsets ([]string {"all" }).WithFeatureChecker (checkerNone ))
1185+ if len (regNone .AvailableTools (context .Background ())) != 1 {
1186+ t .Error ("Tool should be included when no disable flags are on" )
1187+ }
1188+
1189+ // Only kill_a on → excluded
1190+ checkerOnlyA := func (_ context.Context , flag string ) (bool , error ) { return flag == "kill_a" , nil }
1191+ regOnlyA := mustBuild (t , NewBuilder ().SetTools (tools ).WithToolsets ([]string {"all" }).WithFeatureChecker (checkerOnlyA ))
1192+ if len (regOnlyA .AvailableTools (context .Background ())) != 0 {
1193+ t .Error ("Tool should be excluded when the first disable flag is on" )
1194+ }
1195+
1196+ // Only kill_b on → excluded
1197+ checkerOnlyB := func (_ context.Context , flag string ) (bool , error ) { return flag == "kill_b" , nil }
1198+ regOnlyB := mustBuild (t , NewBuilder ().SetTools (tools ).WithToolsets ([]string {"all" }).WithFeatureChecker (checkerOnlyB ))
1199+ if len (regOnlyB .AvailableTools (context .Background ())) != 0 {
1200+ t .Error ("Tool should be excluded when the second disable flag is on" )
1201+ }
1202+
1203+ // Both kill flags on → excluded
1204+ checkerBoth := func (_ context.Context , _ string ) (bool , error ) { return true , nil }
1205+ regBoth := mustBuild (t , NewBuilder ().SetTools (tools ).WithToolsets ([]string {"all" }).WithFeatureChecker (checkerBoth ))
1206+ if len (regBoth .AvailableTools (context .Background ())) != 0 {
1207+ t .Error ("Tool should be excluded when all disable flags are on" )
1208+ }
1209+ }
1210+
11481211func TestFeatureFlagError (t * testing.T ) {
11491212 tools := []ServerTool {
11501213 mockToolWithFlags ("needs_flag" , "toolset1" , true , "my_feature" , "" ),
0 commit comments