UAT: ACMSPipeline.assemble() passes only {"strategy": name} dict to strategies — full ContextRequest (query, focus, entities, depth) is never forwarded #2382

Open
opened 2026-04-03 17:27:16 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: fix/acms-pipeline-context-request-forwarding
  • Commit Message: fix(acms): forward full ContextRequest from ACMSPipeline.assemble() to StrategySelector and StrategyExecutor
  • Milestone: v3.4.0
  • Parent Epic: #396

Background

ACMSPipeline.assemble() accepts a ContextRequest parameter but never forwards it to context strategies. Strategies only receive a minimal dict {"strategy": strategy_name} via StrategySelector.select(), silently discarding all CRP fields (query, focus, entities, depth, temporal_scope, preferred_strategies).

Code Location: src/cleveragents/application/services/acms_service.py lines 771–890

Problematic code (lines ~800–820):

def assemble(
    self,
    plan_id: str,
    fragments: Sequence[ContextFragment],
    budget: ContextBudget,
    strategy: str | None = None,
    request: ContextRequest | None = None,  # ← accepted but not forwarded
    context_view: ContextView | None = None,
) -> ContextPayload:
    ...
    # Only strategy name is passed — not the full ContextRequest
    candidates = self._strategy_selector.select(
        all_strategies,
        {"strategy": strategy_name},  # ← ContextRequest fields lost here
    )
    allocations = self._budget_allocator.allocate(
        candidates,
        budget.available_tokens,
        request,  # ← passed to allocator but not to executor/strategies
    )
    ranked = self._strategy_executor.execute(allocations, fragments, budget)
    # ContextRequest never reaches strategies

Impact

  1. SimpleKeywordStrategy.can_handle() receives {"strategy": "simple-keyword"} instead of the actual query — it cannot use the query for keyword matching during selection.
  2. SemanticEmbeddingStrategy.can_handle() cannot detect if a query is present — always returns 0.6 regardless.
  3. BreadthDepthNavigatorStrategy.can_handle() cannot detect focus nodes — always returns 0.2 (no-focus confidence).
  4. All strategies' assemble() methods receive pre-fetched fragments without knowing what the actor actually requested — they cannot filter by query, focus URIs, entities, or temporal scope.
  5. The ContextRequest.preferred_strategies hint is only used by BudgetAllocator, not by StrategySelector.

Expected Behaviour (per spec §25167–25189)

The ContextRequest should be passed to StrategySelector.select() and StrategyExecutor.execute() so strategies can use the query, focus, entities, depth, temporal scope, and preferred_strategies fields to produce relevant context.

Actual Behaviour

Strategies receive only {"strategy": strategy_name} — a dict with a single key. All CRP fields from the ContextRequest are silently discarded before reaching strategies.

Subtasks

  • Update StrategySelector.select() signature to accept ContextRequest | None instead of a plain dict
  • Update StrategyExecutor.execute() signature to accept and forward ContextRequest | None to each strategy's assemble() call
  • Update ACMSPipeline.assemble() to pass request to both _strategy_selector.select() and _strategy_executor.execute()
  • Update SimpleKeywordStrategy.can_handle() to use request.query for keyword-presence detection
  • Update SemanticEmbeddingStrategy.can_handle() to use request.query to determine embedding availability
  • Update BreadthDepthNavigatorStrategy.can_handle() to use request.focus to detect focus nodes
  • Ensure ContextRequest.preferred_strategies hint is forwarded to and honoured by StrategySelector
  • Update all affected Behave unit test scenarios in features/ to reflect the corrected signatures and behaviour
  • Update all affected Robot Framework integration tests in robot/ if applicable
  • Verify nox -e typecheck passes (Pyright — no # type: ignore suppressions)
  • Verify nox -e lint passes
  • Verify nox -e unit_tests passes
  • Verify nox -e coverage_report reports coverage ≥ 97%

Definition of Done

  • StrategySelector.select() receives the full ContextRequest object
  • StrategyExecutor.execute() receives and forwards the full ContextRequest object to each strategy
  • SimpleKeywordStrategy, SemanticEmbeddingStrategy, and BreadthDepthNavigatorStrategy correctly use CRP fields in can_handle()
  • ContextRequest.preferred_strategies is honoured by StrategySelector
  • No regression in existing ACMS pipeline behaviour
  • All nox stages pass (nox -e lint, nox -e typecheck, nox -e unit_tests, nox -e integration_tests, nox -e coverage_report)
  • Coverage ≥ 97%
  • PR merged into main with commit message matching the Metadata section above, referencing this issue with ISSUES CLOSED: #<this issue>

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

## Metadata - **Branch**: `fix/acms-pipeline-context-request-forwarding` - **Commit Message**: `fix(acms): forward full ContextRequest from ACMSPipeline.assemble() to StrategySelector and StrategyExecutor` - **Milestone**: v3.4.0 - **Parent Epic**: #396 ## Background `ACMSPipeline.assemble()` accepts a `ContextRequest` parameter but never forwards it to context strategies. Strategies only receive a minimal dict `{"strategy": strategy_name}` via `StrategySelector.select()`, silently discarding all CRP fields (`query`, `focus`, `entities`, `depth`, `temporal_scope`, `preferred_strategies`). **Code Location**: `src/cleveragents/application/services/acms_service.py` lines 771–890 **Problematic code** (lines ~800–820): ```python def assemble( self, plan_id: str, fragments: Sequence[ContextFragment], budget: ContextBudget, strategy: str | None = None, request: ContextRequest | None = None, # ← accepted but not forwarded context_view: ContextView | None = None, ) -> ContextPayload: ... # Only strategy name is passed — not the full ContextRequest candidates = self._strategy_selector.select( all_strategies, {"strategy": strategy_name}, # ← ContextRequest fields lost here ) allocations = self._budget_allocator.allocate( candidates, budget.available_tokens, request, # ← passed to allocator but not to executor/strategies ) ranked = self._strategy_executor.execute(allocations, fragments, budget) # ContextRequest never reaches strategies ``` ## Impact 1. `SimpleKeywordStrategy.can_handle()` receives `{"strategy": "simple-keyword"}` instead of the actual query — it cannot use the query for keyword matching during selection. 2. `SemanticEmbeddingStrategy.can_handle()` cannot detect if a query is present — always returns `0.6` regardless. 3. `BreadthDepthNavigatorStrategy.can_handle()` cannot detect focus nodes — always returns `0.2` (no-focus confidence). 4. All strategies' `assemble()` methods receive pre-fetched fragments without knowing what the actor actually requested — they cannot filter by query, focus URIs, entities, or temporal scope. 5. The `ContextRequest.preferred_strategies` hint is only used by `BudgetAllocator`, not by `StrategySelector`. ## Expected Behaviour (per spec §25167–25189) The `ContextRequest` should be passed to `StrategySelector.select()` and `StrategyExecutor.execute()` so strategies can use the query, focus, entities, depth, temporal scope, and `preferred_strategies` fields to produce relevant context. ## Actual Behaviour Strategies receive only `{"strategy": strategy_name}` — a dict with a single key. All CRP fields from the `ContextRequest` are silently discarded before reaching strategies. ## Subtasks - [ ] Update `StrategySelector.select()` signature to accept `ContextRequest | None` instead of a plain `dict` - [ ] Update `StrategyExecutor.execute()` signature to accept and forward `ContextRequest | None` to each strategy's `assemble()` call - [ ] Update `ACMSPipeline.assemble()` to pass `request` to both `_strategy_selector.select()` and `_strategy_executor.execute()` - [ ] Update `SimpleKeywordStrategy.can_handle()` to use `request.query` for keyword-presence detection - [ ] Update `SemanticEmbeddingStrategy.can_handle()` to use `request.query` to determine embedding availability - [ ] Update `BreadthDepthNavigatorStrategy.can_handle()` to use `request.focus` to detect focus nodes - [ ] Ensure `ContextRequest.preferred_strategies` hint is forwarded to and honoured by `StrategySelector` - [ ] Update all affected Behave unit test scenarios in `features/` to reflect the corrected signatures and behaviour - [ ] Update all affected Robot Framework integration tests in `robot/` if applicable - [ ] Verify `nox -e typecheck` passes (Pyright — no `# type: ignore` suppressions) - [ ] Verify `nox -e lint` passes - [ ] Verify `nox -e unit_tests` passes - [ ] Verify `nox -e coverage_report` reports coverage ≥ 97% ## Definition of Done - [ ] `StrategySelector.select()` receives the full `ContextRequest` object - [ ] `StrategyExecutor.execute()` receives and forwards the full `ContextRequest` object to each strategy - [ ] `SimpleKeywordStrategy`, `SemanticEmbeddingStrategy`, and `BreadthDepthNavigatorStrategy` correctly use CRP fields in `can_handle()` - [ ] `ContextRequest.preferred_strategies` is honoured by `StrategySelector` - [ ] No regression in existing ACMS pipeline behaviour - [ ] All nox stages pass (`nox -e lint`, `nox -e typecheck`, `nox -e unit_tests`, `nox -e integration_tests`, `nox -e coverage_report`) - [ ] Coverage ≥ 97% - [ ] PR merged into `main` with commit message matching the Metadata section above, referencing this issue with `ISSUES CLOSED: #<this issue>` --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
freemo added this to the v3.4.0 milestone 2026-04-03 17:27:22 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: High (correct — ACMS pipeline is core functionality for v3.4.0)
  • Milestone: v3.4.0 (correct — ACMS v1 milestone)
  • MoSCoW: Should Have — The ACMS pipeline is a core component of v3.4.0. Without proper ContextRequest forwarding, strategies cannot produce relevant context, which undermines the entire ACMS v1 goal. Per spec §25167–25189, this is required behavior.
  • Parent Epic: #396

This is a well-documented bug with clear code analysis and specific fix locations. The impact is significant — all context strategies are effectively operating blind without the query/focus/entities fields.


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

Issue triaged by project owner: - **State**: Verified ✅ - **Priority**: High (correct — ACMS pipeline is core functionality for v3.4.0) - **Milestone**: v3.4.0 (correct — ACMS v1 milestone) - **MoSCoW**: Should Have — The ACMS pipeline is a core component of v3.4.0. Without proper ContextRequest forwarding, strategies cannot produce relevant context, which undermines the entire ACMS v1 goal. Per spec §25167–25189, this is required behavior. - **Parent Epic**: #396 This is a well-documented bug with clear code analysis and specific fix locations. The impact is significant — all context strategies are effectively operating blind without the query/focus/entities fields. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

Starting implementation on branch fix/acms-pipeline-context-request-forwarding.

Plan: 13 subtasks identified. Analyzing dependencies for parallel wave dispatch.

Wave plan:

  • Wave 1 (parallel): Subtasks 1–7 — update signatures and logic in StrategySelector, StrategyExecutor, ACMSPipeline, and the three strategy can_handle() methods, plus preferred_strategies forwarding
  • Wave 2 (parallel): Subtasks 8–9 — update Behave unit tests and Robot Framework integration tests
  • Wave 3 (sequential): Subtasks 10–13 — quality gates (typecheck, lint, unit_tests, coverage_report)

Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker

Starting implementation on branch `fix/acms-pipeline-context-request-forwarding`. **Plan:** 13 subtasks identified. Analyzing dependencies for parallel wave dispatch. **Wave plan:** - Wave 1 (parallel): Subtasks 1–7 — update signatures and logic in `StrategySelector`, `StrategyExecutor`, `ACMSPipeline`, and the three strategy `can_handle()` methods, plus `preferred_strategies` forwarding - Wave 2 (parallel): Subtasks 8–9 — update Behave unit tests and Robot Framework integration tests - Wave 3 (sequential): Subtasks 10–13 — quality gates (typecheck, lint, unit_tests, coverage_report) --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-worker
freemo removed this from the v3.4.0 milestone 2026-04-06 21:01:26 +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.

Blocks
#396 Epic: ACMS Context Pipeline
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2382
No description provided.