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.
259 lines
9.9 KiB
Gherkin
259 lines
9.9 KiB
Gherkin
Feature: Stream Operator Error Branches, Switch Routing, and Delay/Throttle Operators
|
|
As a developer
|
|
I want stream operators to fail with clear errors when missing required params, switch routing to fall back correctly, and delay/throttle/buffer operators to work
|
|
So that operator misconfiguration is caught early and switch routing degrades gracefully
|
|
|
|
Background:
|
|
Given the CleverAgents reactive system is available
|
|
|
|
# ── Map operator error branches ──
|
|
|
|
Scenario: Map operator fails when missing agent, function, and transform
|
|
Given I have a stream configuration with map but no params in srg
|
|
"""
|
|
{
|
|
"name": "map_no_params",
|
|
"type": "cold",
|
|
"operators": [{"type": "map", "params": {}}]
|
|
}
|
|
"""
|
|
When I attempt stream creation and capture the error in srg
|
|
Then the error should be a stream routing error about map operator requirements in srg
|
|
|
|
# ── Filter error branches ──
|
|
|
|
Scenario: Filter operator fails when missing condition
|
|
Given I have a stream configuration with filter but no condition in srg
|
|
"""
|
|
{
|
|
"name": "filter_no_cond",
|
|
"type": "cold",
|
|
"operators": [{"type": "filter", "params": {}}]
|
|
}
|
|
"""
|
|
When I attempt stream creation and capture the error in srg
|
|
Then the error should be a stream routing error about filter condition in srg
|
|
|
|
# ── Transform operator: fn eval success ──
|
|
|
|
Scenario: Transform operator evaluates a lambda fn successfully
|
|
Given I have a stream configuration with transform fn in srg
|
|
"""
|
|
{
|
|
"name": "transform_fn_ok",
|
|
"type": "cold",
|
|
"operators": [{"type": "transform", "params": {"fn": "lambda x: str(x).upper()"}}]
|
|
}
|
|
"""
|
|
When I create the stream with transform fn and verify operator in srg
|
|
Then the stream should be created and have the transform operator in srg
|
|
|
|
# ── Transform operator: fn eval error ──
|
|
|
|
Scenario: Transform operator fails when fn eval raises an exception
|
|
Given I have a stream configuration with invalid transform fn in srg
|
|
"""
|
|
{
|
|
"name": "transform_fn_bad",
|
|
"type": "cold",
|
|
"operators": [{"type": "transform", "params": {"fn": "lambda x: unknown_var"}}]
|
|
}
|
|
"""
|
|
When I attempt stream creation and capture the error in srg
|
|
Then the error should be a stream routing error with invalid transform in srg
|
|
|
|
# ── Transform operator: type-based (replace) ──
|
|
|
|
Scenario: Transform operator with type replace applies_apply_transform
|
|
Given I have a stream configuration with transform replace type in srg
|
|
"""
|
|
{
|
|
"name": "transform_replace",
|
|
"type": "cold",
|
|
"operators": [{"type": "transform", "params": {"type": "replace", "old": "foo", "new": "bar"}}]
|
|
}
|
|
"""
|
|
When I create the stream with transform replace and send a message in srg
|
|
Then the content_not_contains condition should be exercised in srg
|
|
|
|
# ── Transform operator: missing fn/type ──
|
|
|
|
Scenario: Transform operator fails when missing both fn and type
|
|
Given I have a stream configuration with transform but no fn or type in srg
|
|
"""
|
|
{
|
|
"name": "transform_no_params",
|
|
"type": "cold",
|
|
"operators": [{"type": "transform", "params": {}}]
|
|
}
|
|
"""
|
|
When I attempt stream creation and capture the error in srg
|
|
Then the error should be a stream routing error about transform requirements in srg
|
|
|
|
# ── Switch / conditional_route: case with inline operators ──
|
|
|
|
Scenario: Switch routes to inline case operators when condition matches
|
|
Given I have a stream for switch case operators testing in srg
|
|
When I create a switch stream with inline case operators and test routing in srg
|
|
Then the switch should apply inline operators for matching case in srg
|
|
|
|
# ── Switch / conditional_route: route to target stream ──
|
|
|
|
Scenario: Switch routes to a target stream when condition matches
|
|
Given I have a stream for switch target routing testing in srg
|
|
When I create a switch stream routing to target and test the path in srg
|
|
Then the switch should route to the target stream on match in srg
|
|
|
|
# ── Switch / conditional_route: default_operators fallback ──
|
|
|
|
Scenario: Switch falls back to default_operators when no case matches
|
|
Given I have a stream for switch default operators testing in srg
|
|
When I create a switch stream with default operators and route a non-matching message in srg
|
|
Then the switch should apply default operators on no match in srg
|
|
|
|
# ── Switch / conditional_route: default_stream fallback ──
|
|
|
|
Scenario: Switch falls back to default_stream when no case matches
|
|
Given I have a stream for switch default stream testing in srg
|
|
When I create a switch stream with default stream and route a non-matching message in srg
|
|
Then the switch should route to the default stream on no match in srg
|
|
|
|
# ── Switch / conditional_route: pass-through when nothing matches ──
|
|
|
|
Scenario: Switch passes through when no case, no default operators, and no default stream match
|
|
Given I have a stream for switch pass-through testing in srg
|
|
When I create a switch stream with no fallback and send a non-matching message in srg
|
|
Then the switch should pass the message through unchanged in srg
|
|
|
|
# ── Throttle ──
|
|
|
|
Scenario: Throttle operator is created with throttle_first
|
|
Given I have a stream configuration with throttle in srg
|
|
"""
|
|
{
|
|
"name": "throttle_stream",
|
|
"type": "cold",
|
|
"operators": [{"type": "throttle", "params": {"duration": 0.3}}]
|
|
}
|
|
"""
|
|
When I create the stream and verify the operator list in srg
|
|
Then the throttle stream should be created successfully in srg
|
|
|
|
# ── Delay ──
|
|
|
|
Scenario: Delay operator is created with given duration
|
|
Given I have a stream configuration with delay in srg
|
|
"""
|
|
{
|
|
"name": "delay_stream",
|
|
"type": "cold",
|
|
"operators": [{"type": "delay", "params": {"duration": 0.2}}]
|
|
}
|
|
"""
|
|
When I create the stream and verify the operator list in srg
|
|
Then the delay stream should be created successfully in srg
|
|
|
|
# ── Buffer missing count/time ──
|
|
|
|
Scenario: Buffer operator fails when missing both count and time
|
|
Given I have a stream configuration with buffer but no count or time in srg
|
|
"""
|
|
{
|
|
"name": "buffer_no_params",
|
|
"type": "cold",
|
|
"operators": [{"type": "buffer", "params": {}}]
|
|
}
|
|
"""
|
|
When I attempt stream creation and capture the error in srg
|
|
Then the error should be a stream routing error about buffer requirements in srg
|
|
|
|
# ── Scan operator ──
|
|
|
|
Scenario: Scan operator is created with accumulator
|
|
Given I have a stream configuration with scan accumulator in srg
|
|
"""
|
|
{
|
|
"name": "scan_stream",
|
|
"type": "cold",
|
|
"operators": [{"type": "scan", "params": {"accumulator": {"type": "sum"}}}]
|
|
}
|
|
"""
|
|
When I create the stream and verify the operator list in srg
|
|
Then the scan stream should be created successfully in srg
|
|
|
|
# ── Reduce operator ──
|
|
|
|
Scenario: Reduce operator is created with accumulator
|
|
Given I have a stream configuration with reduce accumulator in srg
|
|
"""
|
|
{
|
|
"name": "reduce_stream",
|
|
"type": "cold",
|
|
"operators": [{"type": "reduce", "params": {"accumulator": {"type": "concat"}}}]
|
|
}
|
|
"""
|
|
When I create the stream and verify the operator list in srg
|
|
Then the reduce stream should be created successfully in srg
|
|
|
|
# ── Reduce missing accumulator ──
|
|
|
|
Scenario: Reduce operator fails when missing accumulator
|
|
Given I have a stream configuration with reduce but no accumulator in srg
|
|
"""
|
|
{
|
|
"name": "reduce_no_params",
|
|
"type": "cold",
|
|
"operators": [{"type": "reduce", "params": {}}]
|
|
}
|
|
"""
|
|
When I attempt stream creation and capture the error in srg
|
|
Then the error should be a stream routing error about reduce accumulator in srg
|
|
|
|
# ── Catch operator ──
|
|
|
|
Scenario: Catch operator is created and wires error handler
|
|
Given I have a stream configuration with catch in srg
|
|
"""
|
|
{
|
|
"name": "catch_stream",
|
|
"type": "cold",
|
|
"operators": [{"type": "catch", "params": {}}]
|
|
}
|
|
"""
|
|
When I create the stream and verify the operator list in srg
|
|
Then the catch stream should be created successfully in srg
|
|
|
|
# ── Debounce operator ──
|
|
|
|
Scenario: Debounce operator is created with cap for single-shot
|
|
Given I have a stream configuration with debounce in srg
|
|
"""
|
|
{
|
|
"name": "debounce_stream",
|
|
"type": "cold",
|
|
"operators": [{"type": "debounce", "params": {"duration": 2.0}}]
|
|
}
|
|
"""
|
|
When I create the stream and verify the operator list in srg
|
|
Then the debounce stream should be created successfully in srg
|
|
|
|
# ── Merge with non-existent source ──
|
|
|
|
Scenario: Merge fails when a source stream does not exist
|
|
Given I have a stream for merge error testing in srg
|
|
When I try to merge streams with a non-existent source name in srg
|
|
Then I should get a stream routing error about the missing source stream in srg
|
|
|
|
# ── _apply_accumulator: collect / concat / sum ──
|
|
|
|
Scenario: Apply accumulator functions for collect, concat, and sum types
|
|
Given I have a stream router ready for accumulator testing in srg
|
|
When I test the apply accumulator for collect concat and sum in srg
|
|
Then the accumulator results should be correct for all three types in srg
|
|
|
|
# ── _evaluate_condition: content_not_contains ──
|
|
|
|
Scenario: Content not contains condition evaluates correctly
|
|
Given I have a stream router ready for condition testing in srg
|
|
When I test the content not contains condition with matching and non-matching inputs in srg
|
|
Then the content not contains condition should return true when text is absent in srg |