UAT: StrategySelectorProtocol.select and StrategyExecutorProtocol.execute signatures missing ContextRequest, BackendSet, and PlanContext parameters #2495

Open
opened 2026-04-03 18:39:19 +00:00 by freemo · 2 comments
Owner

Summary

The StrategySelector and StrategyExecutor pipeline component protocols in acms_service.py have signatures that diverge from the spec. The select method is missing BackendSet and uses dict[str, Any] instead of ContextRequest. The execute method is missing request, backends, and plan_context parameters entirely, receiving pre-fetched fragments instead.

What Was Tested

Code-level analysis of src/cleveragents/application/services/acms_service.py (lines 263-310) against docs/specification.md §44794-44839.

Expected Behavior (from spec §44794-44839)

class StrategySelectorProtocol(Protocol):
    def select(
        self,
        strategies: Sequence[ContextStrategy],
        request: ContextRequest,
        backends: BackendSet,
    ) -> list[tuple[ContextStrategy, float]]:
        """Returns (strategy, confidence) pairs, sorted by priority."""
        ...

class StrategyExecutorProtocol(Protocol):
    def execute(
        self,
        allocations: list[tuple[ContextStrategy, float, int]],
        request: ContextRequest,
        backends: BackendSet,
        plan_context: PlanContext,
    ) -> list[ContextFragment]:
        """Executes strategies and collects all fragments."""
        ...

Actual Behavior

In src/cleveragents/application/services/acms_service.py:

StrategySelector (lines 263-276):

class StrategySelector(Protocol):
    def select(
        self,
        strategies: Sequence[ContextStrategy],
        request: dict[str, Any],  # ← should be ContextRequest + BackendSet
    ) -> list[tuple[ContextStrategy, float]]: ...

StrategyExecutor (lines 296-310):

class StrategyExecutor(Protocol):
    def execute(
        self,
        allocations: list[tuple[ContextStrategy, float, int]],
        fragments: Sequence[ContextFragment],  # ← should be request: ContextRequest
        budget: ContextBudget,                  # ← should be backends: BackendSet + plan_context: PlanContext
    ) -> Sequence[ContextFragment]: ...

The same mismatch exists in the production implementations:

  • ConfidenceWeightedSelector.select in acms_pipeline.py (line 160): takes request: dict[str, Any]
  • ParallelStrategyExecutor.execute in acms_pipeline.py (line 343): takes fragments: Sequence[ContextFragment], budget: ContextBudget

Impact

  1. StrategySelector cannot filter by backend availability — it never receives BackendSet, so it cannot exclude strategies that require unavailable backends (e.g., semantic-embedding when no vector backend is configured)
  2. StrategySelector cannot use ContextRequest.preferred_strategies — it receives a raw dict, not a typed ContextRequest, so preferred strategy hints are accessed via request.get("preferred_strategies", []) instead of request.preferred_strategies
  3. StrategyExecutor cannot pass request/backends/plan_context to strategies — it receives pre-fetched fragments instead of the request, so strategies cannot perform their own retrieval from backends
  4. Plan-hierarchy-aware strategies are brokenplan-decision-context strategy needs PlanContext to traverse ancestor decisions, but StrategyExecutor never receives or passes it

Code Locations

  • src/cleveragents/application/services/acms_service.py lines 263-310 (Protocol definitions)
  • src/cleveragents/application/services/acms_pipeline.py lines 160-185 (ConfidenceWeightedSelector.select)
  • src/cleveragents/application/services/acms_pipeline.py lines 343-459 (ParallelStrategyExecutor.execute)
  • src/cleveragents/application/services/acms_service.py lines 420-526 (Default implementations)

Severity

High — These are core pipeline protocol violations. The pipeline cannot correctly route requests to backends, cannot filter strategies by backend availability, and cannot provide plan hierarchy context to strategies.

Metadata

  • Branch: fix/acms-pipeline-protocol-signatures
  • Commit Message: fix(acms): align StrategySelector and StrategyExecutor protocol signatures with spec
  • Parent Epic: #396

Subtasks

  • Update StrategySelector.select to accept (strategies, request: ContextRequest, backends: BackendSet)
  • Update StrategyExecutor.execute to accept (allocations, request: ContextRequest, backends: BackendSet, plan_context: PlanContext)
  • Update ConfidenceWeightedSelector.select in acms_pipeline.py to use the corrected signature
  • Update ParallelStrategyExecutor.execute in acms_pipeline.py to use the corrected signature
  • Update DefaultStrategySelector.select and DefaultStrategyExecutor.execute in acms_service.py
  • Update ACMSPipeline.assemble to pass ContextRequest, BackendSet, and PlanContext through the pipeline
  • Add unit tests for the corrected protocols

Definition of Done

  • StrategySelector.select accepts (strategies, request: ContextRequest, backends: BackendSet)
  • StrategyExecutor.execute accepts (allocations, request: ContextRequest, backends: BackendSet, plan_context: PlanContext)
  • All implementations updated to match
  • All tests pass with ≥97% coverage

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Summary The `StrategySelector` and `StrategyExecutor` pipeline component protocols in `acms_service.py` have signatures that diverge from the spec. The `select` method is missing `BackendSet` and uses `dict[str, Any]` instead of `ContextRequest`. The `execute` method is missing `request`, `backends`, and `plan_context` parameters entirely, receiving pre-fetched `fragments` instead. ## What Was Tested Code-level analysis of `src/cleveragents/application/services/acms_service.py` (lines 263-310) against `docs/specification.md` §44794-44839. ## Expected Behavior (from spec §44794-44839) ```python class StrategySelectorProtocol(Protocol): def select( self, strategies: Sequence[ContextStrategy], request: ContextRequest, backends: BackendSet, ) -> list[tuple[ContextStrategy, float]]: """Returns (strategy, confidence) pairs, sorted by priority.""" ... class StrategyExecutorProtocol(Protocol): def execute( self, allocations: list[tuple[ContextStrategy, float, int]], request: ContextRequest, backends: BackendSet, plan_context: PlanContext, ) -> list[ContextFragment]: """Executes strategies and collects all fragments.""" ... ``` ## Actual Behavior In `src/cleveragents/application/services/acms_service.py`: **StrategySelector** (lines 263-276): ```python class StrategySelector(Protocol): def select( self, strategies: Sequence[ContextStrategy], request: dict[str, Any], # ← should be ContextRequest + BackendSet ) -> list[tuple[ContextStrategy, float]]: ... ``` **StrategyExecutor** (lines 296-310): ```python class StrategyExecutor(Protocol): def execute( self, allocations: list[tuple[ContextStrategy, float, int]], fragments: Sequence[ContextFragment], # ← should be request: ContextRequest budget: ContextBudget, # ← should be backends: BackendSet + plan_context: PlanContext ) -> Sequence[ContextFragment]: ... ``` The same mismatch exists in the production implementations: - `ConfidenceWeightedSelector.select` in `acms_pipeline.py` (line 160): takes `request: dict[str, Any]` - `ParallelStrategyExecutor.execute` in `acms_pipeline.py` (line 343): takes `fragments: Sequence[ContextFragment], budget: ContextBudget` ## Impact 1. **StrategySelector cannot filter by backend availability** — it never receives `BackendSet`, so it cannot exclude strategies that require unavailable backends (e.g., `semantic-embedding` when no vector backend is configured) 2. **StrategySelector cannot use `ContextRequest.preferred_strategies`** — it receives a raw dict, not a typed `ContextRequest`, so preferred strategy hints are accessed via `request.get("preferred_strategies", [])` instead of `request.preferred_strategies` 3. **StrategyExecutor cannot pass request/backends/plan_context to strategies** — it receives pre-fetched fragments instead of the request, so strategies cannot perform their own retrieval from backends 4. **Plan-hierarchy-aware strategies are broken** — `plan-decision-context` strategy needs `PlanContext` to traverse ancestor decisions, but `StrategyExecutor` never receives or passes it ## Code Locations - `src/cleveragents/application/services/acms_service.py` lines 263-310 (Protocol definitions) - `src/cleveragents/application/services/acms_pipeline.py` lines 160-185 (`ConfidenceWeightedSelector.select`) - `src/cleveragents/application/services/acms_pipeline.py` lines 343-459 (`ParallelStrategyExecutor.execute`) - `src/cleveragents/application/services/acms_service.py` lines 420-526 (Default implementations) ## Severity **High** — These are core pipeline protocol violations. The pipeline cannot correctly route requests to backends, cannot filter strategies by backend availability, and cannot provide plan hierarchy context to strategies. ## Metadata - **Branch**: `fix/acms-pipeline-protocol-signatures` - **Commit Message**: `fix(acms): align StrategySelector and StrategyExecutor protocol signatures with spec` - **Parent Epic**: #396 ## Subtasks - [ ] Update `StrategySelector.select` to accept `(strategies, request: ContextRequest, backends: BackendSet)` - [ ] Update `StrategyExecutor.execute` to accept `(allocations, request: ContextRequest, backends: BackendSet, plan_context: PlanContext)` - [ ] Update `ConfidenceWeightedSelector.select` in `acms_pipeline.py` to use the corrected signature - [ ] Update `ParallelStrategyExecutor.execute` in `acms_pipeline.py` to use the corrected signature - [ ] Update `DefaultStrategySelector.select` and `DefaultStrategyExecutor.execute` in `acms_service.py` - [ ] Update `ACMSPipeline.assemble` to pass `ContextRequest`, `BackendSet`, and `PlanContext` through the pipeline - [ ] Add unit tests for the corrected protocols ## Definition of Done - `StrategySelector.select` accepts `(strategies, request: ContextRequest, backends: BackendSet)` - `StrategyExecutor.execute` accepts `(allocations, request: ContextRequest, backends: BackendSet, plan_context: PlanContext)` - All implementations updated to match - All tests pass with ≥97% coverage --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: Should Have — Spec compliance or quality improvement that should be included in the milestone.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: Should Have — Spec compliance or quality improvement that should be included in the milestone. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Confirmed
  • MoSCoW: Should Have (already set)

Valid finding verified during batch triage.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: Confirmed - **MoSCoW**: Should Have (already set) Valid finding verified during batch triage. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo added this to the v3.7.0 milestone 2026-04-05 05:07:07 +00:00
freemo removed this from the v3.7.0 milestone 2026-04-07 00:49:24 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#2495
No description provided.