Files
cleveragents-core/features/acms_strategy_auto_loading.feature
HAL9000 ffa0a3b3bf fix(acms): defer settings strategy auto-load past _strategies/_logger init
The previous ACMSPipeline.__init__ invoked _load_strategies_from_settings
at line 831 before self._strategies (line 834) and self._logger (line 864)
were initialized.  When a Settings whose context dict contained a
'strategies' key was passed in, the method body raised AttributeError on
'self._strategies', and the except handler then raised a second
AttributeError on 'self._logger' that propagated out of __init__ and
crashed pipeline construction entirely.

Move the auto-load call to after both attributes are bound.  Convert the
pytest-shaped tests/strategies/test_strategy_registry.py (which the
behave-based unit_tests gate never ran) into a behave feature file +
step definitions under features/, matching the project's BDD convention
and bringing the strategy auto-loading paths under actual CI coverage.

ISSUES CLOSED: #7527
2026-06-18 03:03:26 -04:00

81 lines
4.0 KiB
Gherkin

@phase2 @acms @strategy
Feature: ACMS Pipeline Auto-Loading Strategies from Settings
As a CleverAgents developer
I want the ACMS pipeline to auto-load strategies from a Settings
object's context.strategies configuration
So that downstream code does not have to register every strategy by hand,
and so that a Settings carrying strategy config cannot crash __init__
with an AttributeError on _strategies / _logger.
# ---------------------------------------------------------------------------
# Initialization order regression (init-order AttributeError fix)
# ---------------------------------------------------------------------------
@auto_load @init_order
Scenario: Pipeline constructs cleanly when Settings carries an empty strategies sub-dict
Given a mock Settings whose context dict contains an empty strategies sub-dict
When I construct an ACMSPipeline with that Settings
Then construction should succeed without raising
And the resulting pipeline should expose its registered strategies
@auto_load @init_order
Scenario: Pipeline registers strategies declared in the Settings registry
Given a mock Settings whose context.strategies enables two built-ins
When I construct an ACMSPipeline with that Settings
Then construction should succeed without raising
And the pipeline strategies should include "simple-keyword"
@auto_load
Scenario: Pipeline tolerates a Settings without any context attribute
Given a mock Settings without any context attribute
When I construct an ACMSPipeline with that Settings
Then construction should succeed without raising
@auto_load
Scenario: Pipeline tolerates a Settings whose context is a non-dict object
Given a mock Settings whose context is a non-dict object
When I construct an ACMSPipeline with that Settings
Then construction should succeed without raising
@auto_load @error_handling
Scenario: Pipeline survives a malformed strategies config without crashing
Given a mock Settings whose context.strategies references an invalid custom strategy module
When I construct an ACMSPipeline with that Settings
Then construction should succeed without raising
# ---------------------------------------------------------------------------
# _enforce_enabled_strategies — filter pipeline strategy set to enabled subset
# ---------------------------------------------------------------------------
@auto_load @enforce
Scenario: Enabled list filters the pipeline strategy set
Given a mock Settings whose context.strategies enables only "simple-keyword"
When I construct an ACMSPipeline with that Settings
Then the pipeline strategies should contain "simple-keyword"
# ---------------------------------------------------------------------------
# load_strategies_from_config helper (context_strategies.py)
# ---------------------------------------------------------------------------
@load_helper
Scenario: load_strategies_from_config registers the three default built-ins
When I call load_strategies_from_config with an empty config dict
Then the resulting registry should contain "simple-keyword"
And the resulting registry should contain "semantic-embedding"
And the resulting registry should contain "breadth-depth-navigator"
@load_helper
Scenario: load_strategies_from_config honors an explicit enabled list
When I call load_strategies_from_config with an enabled list of only "simple-keyword"
Then the resulting registry should list only "simple-keyword" as enabled
@load_helper
Scenario: load_strategies_from_config defaults to DEFAULT_ENABLED_STRATEGIES when enabled is missing
When I call load_strategies_from_config with no enabled key
Then the resulting registry should list the default-enabled strategies
@load_helper @custom
Scenario: load_strategies_from_config registers a custom strategy from a module:ClassName string
When I call load_strategies_from_config with a custom strategy mapping "my-keyword" to SimpleKeywordStrategy
Then the resulting registry should contain "my-keyword"