From 4433949cb50f80ff79a231c6f91e130eda2b54b8 Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Wed, 3 Sep 2025 16:26:35 +0100 Subject: [PATCH] Changed available_in_state to applicable-states --- .../test_tool_group_integration.py | 10 ++--- tests/unit/test_agent/test_tool_filter.py | 44 +++++++++---------- trustgraph-cli/trustgraph/cli/set_tool.py | 10 ++--- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/tests/integration/test_tool_group_integration.py b/tests/integration/test_tool_group_integration.py index cac37590..4357dfc1 100644 --- a/tests/integration/test_tool_group_integration.py +++ b/tests/integration/test_tool_group_integration.py @@ -31,7 +31,7 @@ def sample_tools(): config={ 'group': ['read-only', 'knowledge', 'basic'], 'state': 'analysis', - 'available_in_states': ['undefined', 'research'] + 'applicable-states': ['undefined', 'research'] }, arguments=[] ), @@ -41,7 +41,7 @@ def sample_tools(): implementation=Mock(), config={ 'group': ['write', 'knowledge', 'admin'], - 'available_in_states': ['analysis', 'modification'] + 'applicable-states': ['analysis', 'modification'] }, arguments=[] ), @@ -52,7 +52,7 @@ def sample_tools(): config={ 'group': ['read-only', 'text', 'basic'], 'state': 'undefined' - # No available_in_states = available in all states + # No applicable-states = available in all states }, arguments=[] ), @@ -63,7 +63,7 @@ def sample_tools(): config={ 'group': ['advanced', 'compute', 'expensive'], 'state': 'results', - 'available_in_states': ['analysis'] + 'applicable-states': ['analysis'] }, arguments=[] ) @@ -332,7 +332,7 @@ class TestToolConfigurationLoading: "type": "text-completion", "group": ["read-only", "text"], "state": "analysis", - "available_in_states": ["undefined", "research"] + "applicable-states": ["undefined", "research"] }) } } diff --git a/tests/unit/test_agent/test_tool_filter.py b/tests/unit/test_agent/test_tool_filter.py index d053be99..c7e7cf3e 100644 --- a/tests/unit/test_agent/test_tool_filter.py +++ b/tests/unit/test_agent/test_tool_filter.py @@ -80,10 +80,10 @@ class TestToolFiltering: assert all(tool in filtered for tool in tools) def test_filter_tools_by_state(self): - """Test filtering based on available_in_states.""" + """Test filtering based on applicable-states.""" tools = { - 'init_tool': Mock(config={'available_in_states': ['undefined']}), - 'analysis_tool': Mock(config={'available_in_states': ['analysis']}), + 'init_tool': Mock(config={'applicable-states': ['undefined']}), + 'analysis_tool': Mock(config={'applicable-states': ['analysis']}), 'any_state_tool': Mock(config={}) # available in all states } @@ -95,10 +95,10 @@ class TestToolFiltering: assert 'any_state_tool' in filtered def test_filter_tools_state_wildcard(self): - """Test tools with '*' in available_in_states are always available.""" + """Test tools with '*' in applicable-states are always available.""" tools = { - 'wildcard_tool': Mock(config={'available_in_states': ['*']}), - 'specific_tool': Mock(config={'available_in_states': ['research']}) + 'wildcard_tool': Mock(config={'applicable-states': ['*']}), + 'specific_tool': Mock(config={'applicable-states': ['research']}) } # Filter for 'analysis' state @@ -112,19 +112,19 @@ class TestToolFiltering: tools = { 'valid_tool': Mock(config={ 'group': ['read-only'], - 'available_in_states': ['analysis'] + 'applicable-states': ['analysis'] }), 'wrong_group': Mock(config={ 'group': ['admin'], - 'available_in_states': ['analysis'] + 'applicable-states': ['analysis'] }), 'wrong_state': Mock(config={ 'group': ['read-only'], - 'available_in_states': ['research'] + 'applicable-states': ['research'] }), 'wrong_both': Mock(config={ 'group': ['admin'], - 'available_in_states': ['research'] + 'applicable-states': ['research'] }) } @@ -186,7 +186,7 @@ class TestConfigValidation: config = { 'group': ['read-only', 'basic'], 'state': 'analysis', - 'available_in_states': ['undefined', 'research'] + 'applicable-states': ['undefined', 'research'] } # Should not raise an exception @@ -213,16 +213,16 @@ class TestConfigValidation: with pytest.raises(ValueError, match="'state' field must be a string"): validate_tool_config(config) - def test_validate_available_in_states_not_list(self): - """Test validation fails when available_in_states is not a list.""" - config = {'available_in_states': 'undefined'} # Should be list + def test_validate_applicable_states_not_list(self): + """Test validation fails when applicable-states is not a list.""" + config = {'applicable-states': 'undefined'} # Should be list - with pytest.raises(ValueError, match="'available_in_states' field must be a list"): + with pytest.raises(ValueError, match="'applicable-states' field must be a list"): validate_tool_config(config) - def test_validate_available_in_states_non_string_elements(self): - """Test validation fails when available_in_states contains non-strings.""" - config = {'available_in_states': ['undefined', 123]} + def test_validate_applicable_states_non_string_elements(self): + """Test validation fails when applicable-states contains non-strings.""" + config = {'applicable-states': ['undefined', 123]} with pytest.raises(ValueError, match="All state names must be strings"): validate_tool_config(config) @@ -257,7 +257,7 @@ class TestToolAvailability: def test_tool_available_string_state_conversion(self): """Test that single state string is converted to list.""" - tool = Mock(config={'available_in_states': 'analysis'}) # Single string + tool = Mock(config={'applicable-states': 'analysis'}) # Single string assert _is_tool_available(tool, ['default'], 'analysis') assert not _is_tool_available(tool, ['default'], 'research') @@ -281,16 +281,16 @@ class TestWorkflowScenarios: 'knowledge_query': Mock(config={ 'group': ['read-only', 'knowledge'], 'state': 'analysis', - 'available_in_states': ['undefined', 'research'] + 'applicable-states': ['undefined', 'research'] }), 'complex_analysis': Mock(config={ 'group': ['advanced', 'compute'], 'state': 'results', - 'available_in_states': ['analysis'] + 'applicable-states': ['analysis'] }), 'text_completion': Mock(config={ 'group': ['read-only', 'text', 'basic'] - # No available_in_states = available in all states + # No applicable-states = available in all states }) } diff --git a/trustgraph-cli/trustgraph/cli/set_tool.py b/trustgraph-cli/trustgraph/cli/set_tool.py index b336a990..2b7e2093 100644 --- a/trustgraph-cli/trustgraph/cli/set_tool.py +++ b/trustgraph-cli/trustgraph/cli/set_tool.py @@ -65,7 +65,7 @@ def set_tool( arguments : List[Argument], group : List[str], state : str, - available_in_states : List[str], + applicable_states : List[str], ): api = Api(url).config() @@ -100,7 +100,7 @@ def set_tool( if state: object["state"] = state - if available_in_states: object["available_in_states"] = available_in_states + if applicable_states: object["applicable-states"] = applicable_states values = api.put([ ConfigValue( @@ -200,8 +200,8 @@ def main(): ) parser.add_argument( - '--available-in-states', - nargs="*", + '--applicable-states', + nargs="*", help=f'States in which this tool is available', ) @@ -247,7 +247,7 @@ def main(): arguments=arguments, group=args.group or [], state=args.state, - available_in_states=getattr(args, 'available_in_states', None) or [], + applicable_states=getattr(args, 'applicable_states', None) or [], ) except Exception as e: