UAT: acms_service.py uses # type: ignore comments — violates project's no-type-suppression rule #3986

Open
opened 2026-04-06 08:18:07 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/backlog-acms-service-remove-type-ignore-suppressions
  • Commit Message: fix(acms): remove type: ignore suppressions and resolve underlying type mismatches in ACMSPipeline
  • Milestone: None (Backlog)
  • Parent Epic: #396

Bug Report

Feature Area: Memory and Knowledge Management — ACMS Pipeline

What was tested: Type annotation compliance in src/cleveragents/application/services/acms_service.py

Expected behavior (from spec/CONTRIBUTING.md): The project's coding standards explicitly prohibit the use of # type: ignore or any other mechanism to suppress or disable type-checking errors. All code must pass nox -e typecheck (Pyright) without type suppression.

Actual behavior: acms_service.py contains 4 # type: ignore comments:

# In ACMSPipeline.BUILTIN_STRATEGIES class variable:
BUILTIN_STRATEGIES: ClassVar[dict[str, type[ContextStrategy]]] = {
    "relevance": RelevanceStrategy,  # type: ignore[dict-item]
    "recency": RecencyStrategy,  # type: ignore[dict-item]
    "tiered": TieredStrategy,  # type: ignore[dict-item]
}

# In ACMSPipeline.__init__():
self._strategies[spec_name] = SpecStrategyAdapter(spec_cls())  # type: ignore[assignment]

These suppressions indicate a real type mismatch: RelevanceStrategy, RecencyStrategy, and TieredStrategy do not fully satisfy the ContextStrategy Protocol as declared in BUILTIN_STRATEGIES. The SpecStrategyAdapter assignment also has a type mismatch.

Code location: src/cleveragents/application/services/acms_service.py

  • Line with BUILTIN_STRATEGIES dict definition (~line 260)
  • Line with SpecStrategyAdapter assignment in __init__ (~line 310)

Root cause: The ContextStrategy Protocol defines assemble(fragments, budget) but the built-in strategies (RelevanceStrategy, etc.) implement this protocol correctly. The type error likely stems from the ClassVar[dict[str, type[ContextStrategy]]] annotation being too strict — the concrete strategy classes are instances, not types. The SpecStrategyAdapter assignment type error indicates the adapter doesn't fully satisfy the ContextStrategy Protocol.

Steps to reproduce:

  1. Remove the # type: ignore comments from acms_service.py
  2. Run nox -e typecheck on the repository
  3. Observe Pyright reporting type errors in acms_service.py

Impact:

  • Violates the project's strict no-type-suppression rule from CONTRIBUTING.md
  • Masks real type incompatibilities between the ContextStrategy Protocol and its implementations
  • The underlying type mismatch may indicate a design issue in the Protocol definition or the strategy implementations

Backlog note: This issue was discovered during autonomous operation
on milestone v3.4.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.

Subtasks

  • Audit all 4 # type: ignore occurrences in acms_service.py and document the exact Pyright error each suppresses
  • Fix the BUILTIN_STRATEGIES type annotation — either correct the ClassVar annotation (e.g. dict[str, type[ContextStrategy]]dict[str, ContextStrategy]) or fix the strategy class signatures to satisfy the Protocol
  • Fix the SpecStrategyAdapter assignment type mismatch — ensure SpecStrategyAdapter fully satisfies the ContextStrategy Protocol or correct the _strategies dict annotation
  • Remove all 4 # type: ignore comments
  • Run nox -e typecheck and confirm zero Pyright errors in acms_service.py
  • Add or update BDD unit tests (Behave) covering the corrected type relationships
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions) and confirm all stages pass

Definition of Done

  • All 4 # type: ignore comments removed from acms_service.py
  • nox -e typecheck passes with zero errors in acms_service.py without any suppression comments
  • The ContextStrategy Protocol and its implementations (RelevanceStrategy, RecencyStrategy, TieredStrategy, SpecStrategyAdapter) are type-compatible without suppression
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/backlog-acms-service-remove-type-ignore-suppressions` - **Commit Message**: `fix(acms): remove type: ignore suppressions and resolve underlying type mismatches in ACMSPipeline` - **Milestone**: None (Backlog) - **Parent Epic**: #396 ## Bug Report **Feature Area**: Memory and Knowledge Management — ACMS Pipeline **What was tested**: Type annotation compliance in `src/cleveragents/application/services/acms_service.py` **Expected behavior (from spec/CONTRIBUTING.md)**: The project's coding standards explicitly prohibit the use of `# type: ignore` or any other mechanism to suppress or disable type-checking errors. All code must pass `nox -e typecheck` (Pyright) without type suppression. **Actual behavior**: `acms_service.py` contains 4 `# type: ignore` comments: ```python # In ACMSPipeline.BUILTIN_STRATEGIES class variable: BUILTIN_STRATEGIES: ClassVar[dict[str, type[ContextStrategy]]] = { "relevance": RelevanceStrategy, # type: ignore[dict-item] "recency": RecencyStrategy, # type: ignore[dict-item] "tiered": TieredStrategy, # type: ignore[dict-item] } # In ACMSPipeline.__init__(): self._strategies[spec_name] = SpecStrategyAdapter(spec_cls()) # type: ignore[assignment] ``` These suppressions indicate a real type mismatch: `RelevanceStrategy`, `RecencyStrategy`, and `TieredStrategy` do not fully satisfy the `ContextStrategy` Protocol as declared in `BUILTIN_STRATEGIES`. The `SpecStrategyAdapter` assignment also has a type mismatch. **Code location**: `src/cleveragents/application/services/acms_service.py` - Line with `BUILTIN_STRATEGIES` dict definition (~line 260) - Line with `SpecStrategyAdapter` assignment in `__init__` (~line 310) **Root cause**: The `ContextStrategy` Protocol defines `assemble(fragments, budget)` but the built-in strategies (`RelevanceStrategy`, etc.) implement this protocol correctly. The type error likely stems from the `ClassVar[dict[str, type[ContextStrategy]]]` annotation being too strict — the concrete strategy classes are instances, not types. The `SpecStrategyAdapter` assignment type error indicates the adapter doesn't fully satisfy the `ContextStrategy` Protocol. **Steps to reproduce**: 1. Remove the `# type: ignore` comments from `acms_service.py` 2. Run `nox -e typecheck` on the repository 3. Observe Pyright reporting type errors in `acms_service.py` **Impact**: - Violates the project's strict no-type-suppression rule from CONTRIBUTING.md - Masks real type incompatibilities between the `ContextStrategy` Protocol and its implementations - The underlying type mismatch may indicate a design issue in the Protocol definition or the strategy implementations > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.4.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## Subtasks - [ ] Audit all 4 `# type: ignore` occurrences in `acms_service.py` and document the exact Pyright error each suppresses - [ ] Fix the `BUILTIN_STRATEGIES` type annotation — either correct the `ClassVar` annotation (e.g. `dict[str, type[ContextStrategy]]` → `dict[str, ContextStrategy]`) or fix the strategy class signatures to satisfy the Protocol - [ ] Fix the `SpecStrategyAdapter` assignment type mismatch — ensure `SpecStrategyAdapter` fully satisfies the `ContextStrategy` Protocol or correct the `_strategies` dict annotation - [ ] Remove all 4 `# type: ignore` comments - [ ] Run `nox -e typecheck` and confirm zero Pyright errors in `acms_service.py` - [ ] Add or update BDD unit tests (Behave) covering the corrected type relationships - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions) and confirm all stages pass ## Definition of Done - [ ] All 4 `# type: ignore` comments removed from `acms_service.py` - [ ] `nox -e typecheck` passes with zero errors in `acms_service.py` without any suppression comments - [ ] The `ContextStrategy` Protocol and its implementations (`RelevanceStrategy`, `RecencyStrategy`, `TieredStrategy`, `SpecStrategyAdapter`) are type-compatible without suppression - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
HAL9000 added this to the v3.5.0 milestone 2026-04-09 03:12:16 +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#3986
No description provided.