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
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.
92 lines
4.8 KiB
Gherkin
92 lines
4.8 KiB
Gherkin
Feature: Bridge Task Handler and Cleanup Edge Cases
|
|
As a developer
|
|
I want the bridge to handle CancelledError and generic exceptions in task handlers, create new loops for closed loops, and clean up inside running loops
|
|
So that bridge error recovery and cleanup is robust under concurrent conditions
|
|
|
|
Background:
|
|
Given a fresh bridge final test context (bgr)
|
|
|
|
Scenario: Conditional router handles non-string route_name key
|
|
Given a bridge for conditional router testing (bgr)
|
|
When I evaluate a route with integer key and non-string default (bgr)
|
|
Then the router should convert non-string route_name and default to string (bgr)
|
|
|
|
Scenario: Graph executor task handler handles CancelledError
|
|
Given a bridge with a mock graph named "gc_graph" (bgr)
|
|
When I invoke the graph executor task handler with CancelledError (bgr)
|
|
Then the task should be discarded from active tasks (bgr)
|
|
|
|
Scenario: Graph executor task handler handles generic exception
|
|
Given a bridge with a mock graph named "ge_graph" (bgr)
|
|
When I invoke the graph executor task handler with generic exception (bgr)
|
|
Then the task should be removed gracefully (bgr)
|
|
|
|
Scenario: Node operator task handler handles CancelledError
|
|
Given a bridge has mock graph named "nc_graph" with node named "n_task_node" (bgr)
|
|
When I invoke the node operator task handler with CancelledError (bgr)
|
|
Then the node task should be discarded (bgr)
|
|
|
|
Scenario: Node operator task handler handles generic exception
|
|
Given a bridge has mock graph named "ng_graph" with node named "n_gen_node" (bgr)
|
|
When I invoke the node operator task handler with generic exception (bgr)
|
|
Then the node task should be removed gracefully (bgr)
|
|
|
|
Scenario: Connector task handler handles CancelledError
|
|
Given a bridge with a stream "cs_stm" and graph "cs_graph" (bgr)
|
|
When I invoke the connector task handler with CancelledError (bgr)
|
|
Then the task should be cleaned up properly (bgr)
|
|
|
|
Scenario: Connector task handler handles generic exception
|
|
Given a bridge with a stream "cg_stm" and graph "cg_graph" (bgr)
|
|
When I invoke the connector task handler with generic exception (bgr)
|
|
Then the task should be cleaned gracefully (bgr)
|
|
|
|
Scenario: Graph executor creates new loop for closed loop
|
|
Given a bridge with a mock graph named "cl_graph" (bgr)
|
|
When I create a graph executor task future with a closed event loop (bgr)
|
|
Then a new event loop should be used and closed loop replaced (bgr)
|
|
|
|
Scenario: Node operator creates new loop for closed loop
|
|
Given a bridge has mock graph named "ncl_graph" with node named "ncl_node" (bgr)
|
|
When I create a node operator task future with a closed event loop (bgr)
|
|
Then a new event loop should be allocated for node execution (bgr)
|
|
|
|
Scenario: Graph executor handles exception in no-running-loop path
|
|
Given a bridge with a failing mock graph named "ef_graph" (bgr)
|
|
When I invoke the graph executor with no running loop and execution fails (bgr)
|
|
Then the exception should be set on the future (bgr)
|
|
|
|
Scenario: Node operator handles exception in no-running-loop path
|
|
Given a bridge has mock graph named "enf_graph" with node named "enf_node" (bgr)
|
|
When I invoke the node operator with no running loop and node execution fails (bgr)
|
|
Then the exception should be set on the node future (bgr)
|
|
|
|
Scenario: Connector creates new loop for closed loop
|
|
Given a bridge with a stream "ccl_stm" and graph "ccl_graph" (bgr)
|
|
When I create a connector task future with a closed event loop (bgr)
|
|
Then a new event loop should be allocated for the connection (bgr)
|
|
|
|
Scenario: Cleanup inside running loop cancels tasks directly
|
|
Given a bridge with active tasks and a running loop (bgr)
|
|
When I call cleanup inside a running loop (bgr)
|
|
Then tasks should be cancelled without blocking (bgr)
|
|
|
|
Scenario: Cleanup with closed loop creates new loop
|
|
Given a bridge with active tasks and a closed loop (bgr)
|
|
When I call cleanup with a closed loop context (bgr)
|
|
Then a new event loop should be created and used for cleanup (bgr)
|
|
|
|
Scenario: Cleanup with RuntimeError fallback
|
|
Given a bridge with active tasks and unwired loop (bgr)
|
|
When I call cleanup with RuntimeError from get_event_loop (bgr)
|
|
Then a new event loop should be created via RuntimeError path (bgr)
|
|
|
|
Scenario: Cleanup with running loop cancels without await
|
|
Given a bridge with active tasks where event loop is running (bgr)
|
|
When I call cleanup when event loop is running (bgr)
|
|
Then tasks should be cancelled without awaiting (bgr)
|
|
|
|
Scenario: Cleanup fallback catches general exception
|
|
Given a bridge with active tasks where cleanup will fail (bgr)
|
|
When I call cleanup and all operations raise exceptions (bgr)
|
|
Then tasks should be cancelled via fallback path (bgr) |