Files
cleveractors-core/features/route_bridge_coverage.feature
CoreRasurae 9753b31c7e
CI / quality (push) Successful in 36s
CI / lint (push) Successful in 38s
CI / typecheck (push) Successful in 49s
CI / security (push) Successful in 51s
CI / integration_tests (push) Successful in 55s
CI / unit_tests (push) Successful in 3m35s
CI / build (push) Successful in 33s
CI / coverage (push) Successful in 3m36s
CI / status-check (push) Successful in 3s
test: add coverage gap tests improving coverage from 81.4% to 96.90%
Add 13 BDD scenarios covering previously uncovered code paths:
- SAFE_BUILTINS validation (sandbox.py: 0% → 100%)
- ConfigurationError re-raise path (config.py: 99.3% → 100%)
- CLI hello/main functions (cli.py: 72.7% → 90.9%)
- GraphState message truncation (state.py: 98.7% → 100%)
- ProgressBarManager update/context rendering (progress.py: 0% → 87.7%)
- MessageRouter regex/exact/contains routing (message_router.py: 0% → 59.4%)
- RoutingAdapter parse_routing_command (routing_adapter.py)
- DynamicRouterNode pattern-based routing (dynamic_router.py)
- EnhancedTemplateRegistry unknown template type (enhanced_registry.py: 99.2%)
- CompositeAgent null-graph error path (composite.py: 97.8% → 98.6%)

Cover routing_adapter.py (17% → 100%): all GOTO/ROUTE patterns,
create_routing_node, create_conditional_router, dynamic config conversion.

Cover dynamic_router.py (21% → 87%): execute with empty/dict/string
messages, extract_message with colon parsing, config creation, graph
extension with edge generation.

Cover message_router.py (59% → 78%): regex, exact, contains, prefix,
suffix match types, invalid regex handling, non-string message, set_state.

Exercise Node._prepare_conversation_history with invalid configs,
_runtime error paths, _execute_message_router with rules,
_execute_agent with current_message and metadata propagation,
_execute_function with dynamic_router, and _execute_conditional
with content_contains/content_not_contains/content_starts_with
and custom condition types. Improves nodes.py from 71.3% to 72.5%.

Exercise PureGraphConfig, PureLangGraph init with dict/config,
RxPyLangGraphBridge registration/connection/lookup,
ReactiveStreamRouter operator creation and condition functions,
ReactiveConfigParser config/route/graph parsing,
ToolAgent tool execution with JSON, space-separated, single,
file_read, progress_bar invocations, and
ReactiveCleverAgentsApp init/dispose/visualization.
2026-06-02 20:02:01 +01:00

252 lines
10 KiB
Gherkin

Feature: Route Upgrade and Downgrade Conversion Between Streams and Graphs
As a developer
I want routes to upgrade from streams to graphs and downgrade from graphs to streams based on configurable conditions
So that the system can dynamically adapt processing complexity based on message load and state size
Background:
Given I have a clean test environment for route bridge
Scenario: Test RouteBridge initialization
Given I have a stream router and agents
When I create a RouteBridge instance
Then the route bridge should be initialized correctly
And the logger should be set up
And active conversions should be empty
Scenario: Test RouteBridge initialization with scheduler
Given I have a stream router and agents
And I have an AsyncIO scheduler
When I create a RouteBridge instance with scheduler
Then the route bridge should be initialized with scheduler
And the scheduler should be stored correctly
Scenario: Test check_upgrade_conditions - no bridge config
Given I have a RouteBridge instance
And I have a route config without bridge configuration
And I have a stream message
When I check upgrade conditions
Then the result should be False
Scenario: Test check_upgrade_conditions - wrong route type
Given I have a RouteBridge instance
And I have a graph route config with bridge configuration
And I have a stream message
When I check upgrade conditions
Then the result should be False
Scenario: Test check_upgrade_conditions - needs_state condition
Given I have a RouteBridge instance
And I have a stream route config with needs_state upgrade condition
And I have a stream message with requires_state metadata
When I check upgrade conditions
Then the result should be True
Scenario: Test check_upgrade_conditions - message_count condition
Given I have a RouteBridge instance
And I have a stream route config with message_count upgrade condition
And I have processed enough messages to trigger upgrade
When I check upgrade conditions
Then the result should be True
Scenario: Test check_upgrade_conditions - complexity_threshold condition
Given I have a RouteBridge instance
And I have a stream route config with complexity_threshold upgrade condition
And I have a complex route configuration
When I check upgrade conditions
Then the result should be True
Scenario: Test check_upgrade_conditions - custom_predicate condition
Given I have a RouteBridge instance
And I have a stream route config with custom_predicate upgrade condition
And I have a custom predicate that returns True
When I check upgrade conditions
Then the result should be True
Scenario: Test check_upgrade_conditions - custom_predicate false
Given I have a RouteBridge instance
And I have a stream route config with custom_predicate upgrade condition
And I have a custom predicate that returns False
When I check upgrade conditions
Then the result should be False
Scenario: Test check_upgrade_conditions - non-callable predicate
Given I have a RouteBridge instance
And I have a stream route config with non-callable custom_predicate
And I have a stream message
When I check upgrade conditions
Then the result should be False
Scenario: Test check_downgrade_conditions - no bridge config
Given I have a RouteBridge instance
And I have a route config without bridge configuration
And I have a graph state
When I check downgrade conditions
Then the result should be False
Scenario: Test check_downgrade_conditions - wrong route type
Given I have a RouteBridge instance
And I have a stream route config with bridge configuration
And I have a graph state
When I check downgrade conditions
Then the result should be False
Scenario: Test check_downgrade_conditions - idle_time condition
Given I have a RouteBridge instance
And I have a graph route config with idle_time downgrade condition
And I have a graph state that has been idle too long
When I check downgrade conditions
Then the result should be True
Scenario: Test check_downgrade_conditions - state_size condition
Given I have a RouteBridge instance
And I have a graph route config with state_size downgrade condition
And I have a graph state with minimal messages
When I check downgrade conditions
Then the result should be True
Scenario: Test check_downgrade_conditions - no_conditionals_used condition
Given I have a RouteBridge instance
And I have a graph route config with no_conditionals_used downgrade condition
And I have a graph state with no conditional edges used
When I check downgrade conditions
Then the result should be True
Scenario: Test upgrade_stream_to_graph - basic functionality
Given I have a RouteBridge instance
And I have a stream route config for upgrade
And I have a stream message
When I upgrade stream to graph
Then a LangGraph should be created
And the graph should be configured correctly
And active conversions should be updated
Scenario: Test upgrade_stream_to_graph - with state extractor
Given I have a RouteBridge instance
And I have a stream route config with state extractor
And I have a stream message
When I upgrade stream to graph
Then a LangGraph should be created with initial state
And the state should be extracted correctly
Scenario: Test upgrade_stream_to_graph - with preserve subscriptions
Given I have a RouteBridge instance
And I have a stream route config with preserve subscriptions
And I have a stream message
When I upgrade stream to graph
Then a LangGraph should be created
And subscriptions should be preserved
Scenario: Test downgrade_graph_to_stream - basic functionality
Given I have a RouteBridge instance
And I have a graph route config for downgrade
And I have a LangGraph instance
When I downgrade graph to stream
Then a StreamConfig should be created
And the stream should be configured correctly
And active conversions should be updated
Scenario: Test downgrade_graph_to_stream - with state flattener
Given I have a RouteBridge instance
And I have a graph route config with state flattener
And I have a LangGraph instance with state
When I downgrade graph to stream
Then a StreamConfig should be created
And the state should be flattened correctly
Scenario: Test downgrade_graph_to_stream - with preserve checkpointing
Given I have a RouteBridge instance
And I have a graph route config with preserve checkpointing
And I have a LangGraph instance with checkpoint directory
When I downgrade graph to stream
Then a StreamConfig should be created
And checkpointing should be preserved
Scenario: Test _create_graph_from_stream - basic operators
Given I have a RouteBridge instance
And I have a stream route config with basic operators
When I create graph from stream
Then a GraphConfig should be created
And nodes should be created from operators
And edges should connect the nodes properly
Scenario: Test _create_graph_from_stream - agent operators
Given I have a RouteBridge instance
And I have a stream route config with agent operators
When I create graph from stream
Then a GraphConfig should be created with agent nodes
And agent nodes should be configured correctly
Scenario: Test _create_graph_from_stream - mixed operators
Given I have a RouteBridge instance
And I have a stream route config with mixed operators
When I create graph from stream
Then a GraphConfig should be created with mixed node types
And all operators should be converted to nodes
Scenario: Test _create_stream_from_graph - basic functionality
Given I have a RouteBridge instance
And I have a graph route config
And I have a LangGraph with nodes
When I create stream from graph
Then a StreamConfig should be created
And operators should be extracted from nodes
And the stream should be configured properly
Scenario: Test _create_stream_from_graph - with agent nodes
Given I have a RouteBridge instance
And I have a graph route config
And I have a LangGraph with agent nodes
When I create stream from graph
Then a StreamConfig should be created with agent operators
And agents should be extracted correctly
Scenario: Test _create_stream_from_graph - with function nodes
Given I have a RouteBridge instance
And I have a graph route config
And I have a LangGraph with function nodes
When I create stream from graph
Then a StreamConfig should be created with function operators
And function operators should be restored correctly
Scenario: Test _get_message_count functionality
Given I have a RouteBridge instance
When I get message count for a route
Then the message count should be returned
And the result should be a valid integer
Scenario: Test get_active_conversion - existing conversion
Given I have a RouteBridge instance
And I have an active conversion registered
When I get active conversion info
Then the conversion info should be returned
And the info should contain the correct details
Scenario: Test get_active_conversion - non-existing conversion
Given I have a RouteBridge instance
When I get active conversion info for non-existing route
Then None should be returned for route bridge
Scenario: Test error handling in upgrade_stream_to_graph
Given I have a RouteBridge instance
And I have an invalid stream route config
And I have a stream message
When I attempt to upgrade stream to graph
Then appropriate error handling should occur
And the system should remain stable
Scenario: Test error handling in downgrade_graph_to_stream
Given I have a RouteBridge instance
And I have an invalid graph route config
And I have a corrupted LangGraph instance
When I attempt to downgrade graph to stream
Then appropriate error handling should occur
And the system should remain stable
Scenario: Test complex upgrade downgrade cycle
Given I have a RouteBridge instance
And I have a route config that supports both upgrade and downgrade
When I perform an upgrade and then downgrade cycle
Then the cycle should complete successfully
And the final configuration should be consistent
And active conversions should be tracked correctly