UAT: ContextStrategy.assemble() signature does not match spec — missing request, backends, and plan_context parameters #2894

Open
opened 2026-04-05 02:44:27 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/acms-context-strategy-assemble-signature
  • Commit Message: fix(acms): align ContextStrategy.assemble() signature with spec
  • Milestone: v3.4.0
  • Parent Epic: #933

Description

The ContextStrategy protocol's assemble() method in src/cleveragents/application/services/acms_service.py (line ~115) has a signature that does not match the specification.

Spec-required signature (docs/specification.md ~line 25521):

def assemble(self, request: ContextRequest,
             backends: BackendSet,
             budget: int,
             plan_context: PlanContext) -> list[ContextFragment]:

Actual implementation (acms_service.py ~line 115):

def assemble(
    self,
    fragments: Sequence[ContextFragment],
    budget: ContextBudget,
) -> Sequence[ContextFragment]:

The implementation:

  1. Takes pre-assembled fragments as input instead of request: ContextRequest — strategies should receive a ContextRequest and query backends themselves, not receive pre-filtered fragments
  2. Takes ContextBudget object instead of int for budget
  3. Is missing the backends: BackendSet parameter — strategies cannot query text/vector/graph backends
  4. Is missing the plan_context: PlanContext parameter — strategies cannot traverse plan hierarchy

This means the built-in strategies (RelevanceStrategy, RecencyStrategy, TieredStrategy) are acting as fragment rankers/filters rather than context retrievers, which is architecturally incorrect per the spec. The spec explicitly states strategies should "search for and assemble ContextFragments using a specific approach (keyword search, semantic embedding, graph navigation)" — they need access to backends to do this.

The ContextStrategy protocol in src/cleveragents/domain/models/acms/strategy.py (the domain model version) correctly matches the spec with assemble(self, request, backends, budget, plan_context), but the service-layer protocol in acms_service.py diverges.

Steps to reproduce:

  1. Read src/cleveragents/application/services/acms_service.py lines 95–125
  2. Compare with spec at docs/specification.md ~line 25521
  3. Note the ContextStrategy protocol in acms_service.py uses fragments: Sequence[ContextFragment] instead of request: ContextRequest, backends: BackendSet, budget: int, plan_context: PlanContext

Expected: assemble() receives a ContextRequest, BackendSet, integer budget, and PlanContext so strategies can query backends independently.

Actual: assemble() receives pre-assembled fragments and a ContextBudget object, making strategies unable to query any backend.

Subtasks

  • Audit src/cleveragents/application/services/acms_service.py — locate the ContextStrategy protocol definition (~line 115) and all call sites of assemble()
  • Update the ContextStrategy protocol in acms_service.py to match the spec: assemble(self, request: ContextRequest, backends: BackendSet, budget: int, plan_context: PlanContext) -> list[ContextFragment]
  • Refactor RelevanceStrategy, RecencyStrategy, and TieredStrategy implementations to accept and use the corrected signature — each strategy must query backends directly rather than filtering pre-assembled fragments
  • Remove the ContextBudget parameter from assemble() call sites and replace with the integer budget field
  • Update all callers of assemble() in the service layer to pass request, backends, budget (int), and plan_context
  • Ensure the service-layer ContextStrategy protocol is consistent with the domain-model protocol in src/cleveragents/domain/models/acms/strategy.py
  • Update or add Behave unit tests in features/ covering the corrected assemble() signature for all three built-in strategies
  • Run nox -e typecheck and confirm zero Pyright errors
  • Run nox -e unit_tests and confirm all scenarios pass
  • Run nox -e coverage_report and confirm coverage ≥ 97%

Definition of Done

  • ContextStrategy.assemble() in acms_service.py matches the spec signature exactly: (self, request: ContextRequest, backends: BackendSet, budget: int, plan_context: PlanContext) -> list[ContextFragment]
  • All three built-in strategies (RelevanceStrategy, RecencyStrategy, TieredStrategy) query backends directly and no longer accept pre-assembled fragments
  • No divergence between the service-layer and domain-model ContextStrategy protocols
  • Behave unit tests added/updated for all affected strategies
  • All nox stages pass (nox -e lint, nox -e typecheck, nox -e unit_tests, nox -e integration_tests, nox -e coverage_report)
  • Coverage >= 97%
  • Commit created with message fix(acms): align ContextStrategy.assemble() signature with spec and footer ISSUES CLOSED: #<this issue>
  • PR submitted, reviewed, and merged into the correct branch

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

## Metadata - **Branch**: `fix/acms-context-strategy-assemble-signature` - **Commit Message**: `fix(acms): align ContextStrategy.assemble() signature with spec` - **Milestone**: v3.4.0 - **Parent Epic**: #933 ## Description The `ContextStrategy` protocol's `assemble()` method in `src/cleveragents/application/services/acms_service.py` (line ~115) has a signature that does not match the specification. **Spec-required signature** (`docs/specification.md` ~line 25521): ```python def assemble(self, request: ContextRequest, backends: BackendSet, budget: int, plan_context: PlanContext) -> list[ContextFragment]: ``` **Actual implementation** (`acms_service.py` ~line 115): ```python def assemble( self, fragments: Sequence[ContextFragment], budget: ContextBudget, ) -> Sequence[ContextFragment]: ``` The implementation: 1. Takes pre-assembled `fragments` as input instead of `request: ContextRequest` — strategies should receive a `ContextRequest` and query backends themselves, not receive pre-filtered fragments 2. Takes `ContextBudget` object instead of `int` for budget 3. Is missing the `backends: BackendSet` parameter — strategies cannot query text/vector/graph backends 4. Is missing the `plan_context: PlanContext` parameter — strategies cannot traverse plan hierarchy This means the built-in strategies (`RelevanceStrategy`, `RecencyStrategy`, `TieredStrategy`) are acting as fragment rankers/filters rather than context retrievers, which is architecturally incorrect per the spec. The spec explicitly states strategies should "search for and assemble ContextFragments using a specific approach (keyword search, semantic embedding, graph navigation)" — they need access to backends to do this. The `ContextStrategy` protocol in `src/cleveragents/domain/models/acms/strategy.py` (the domain model version) correctly matches the spec with `assemble(self, request, backends, budget, plan_context)`, but the service-layer protocol in `acms_service.py` diverges. **Steps to reproduce:** 1. Read `src/cleveragents/application/services/acms_service.py` lines 95–125 2. Compare with spec at `docs/specification.md` ~line 25521 3. Note the `ContextStrategy` protocol in `acms_service.py` uses `fragments: Sequence[ContextFragment]` instead of `request: ContextRequest, backends: BackendSet, budget: int, plan_context: PlanContext` **Expected:** `assemble()` receives a `ContextRequest`, `BackendSet`, integer budget, and `PlanContext` so strategies can query backends independently. **Actual:** `assemble()` receives pre-assembled fragments and a `ContextBudget` object, making strategies unable to query any backend. ## Subtasks - [ ] Audit `src/cleveragents/application/services/acms_service.py` — locate the `ContextStrategy` protocol definition (~line 115) and all call sites of `assemble()` - [ ] Update the `ContextStrategy` protocol in `acms_service.py` to match the spec: `assemble(self, request: ContextRequest, backends: BackendSet, budget: int, plan_context: PlanContext) -> list[ContextFragment]` - [ ] Refactor `RelevanceStrategy`, `RecencyStrategy`, and `TieredStrategy` implementations to accept and use the corrected signature — each strategy must query backends directly rather than filtering pre-assembled fragments - [ ] Remove the `ContextBudget` parameter from `assemble()` call sites and replace with the integer `budget` field - [ ] Update all callers of `assemble()` in the service layer to pass `request`, `backends`, `budget` (int), and `plan_context` - [ ] Ensure the service-layer `ContextStrategy` protocol is consistent with the domain-model protocol in `src/cleveragents/domain/models/acms/strategy.py` - [ ] Update or add Behave unit tests in `features/` covering the corrected `assemble()` signature for all three built-in strategies - [ ] Run `nox -e typecheck` and confirm zero Pyright errors - [ ] Run `nox -e unit_tests` and confirm all scenarios pass - [ ] Run `nox -e coverage_report` and confirm coverage ≥ 97% ## Definition of Done - [ ] `ContextStrategy.assemble()` in `acms_service.py` matches the spec signature exactly: `(self, request: ContextRequest, backends: BackendSet, budget: int, plan_context: PlanContext) -> list[ContextFragment]` - [ ] All three built-in strategies (`RelevanceStrategy`, `RecencyStrategy`, `TieredStrategy`) query backends directly and no longer accept pre-assembled fragments - [ ] No divergence between the service-layer and domain-model `ContextStrategy` protocols - [ ] Behave unit tests added/updated for all affected strategies - [ ] All nox stages pass (`nox -e lint`, `nox -e typecheck`, `nox -e unit_tests`, `nox -e integration_tests`, `nox -e coverage_report`) - [ ] Coverage >= 97% - [ ] Commit created with message `fix(acms): align ContextStrategy.assemble() signature with spec` and footer `ISSUES CLOSED: #<this issue>` - [ ] PR submitted, reviewed, and merged into the correct branch --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
freemo added this to the v3.4.0 milestone 2026-04-05 02:44:43 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: High (confirmed)
  • MoSCoW: Should Have — ContextStrategy.assemble() signature mismatch with spec

Valid UAT finding verified during batch triage.


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

Issue triaged by project owner: - **State**: Verified - **Priority**: High (confirmed) - **MoSCoW**: Should Have — ContextStrategy.assemble() signature mismatch with spec Valid UAT finding verified during batch triage. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo removed this from the v3.4.0 milestone 2026-04-06 21:01:42 +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.

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