UAT: ACMSPipeline.BUILTIN_STRATEGIES and SpecStrategyAdapter assignment use prohibited # type: ignore comments in acms_service.py #3746

Open
opened 2026-04-05 22:25:56 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/acms-service-remove-type-ignore-comments
  • Commit Message: fix(acms-service): resolve Pyright protocol conflicts to remove prohibited type: ignore comments
  • Milestone: (none — backlog)
  • Parent Epic: #396

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.

Background and Context

src/cleveragents/application/services/acms_service.py contains four # type: ignore comments that directly violate the project's strict code standards. CONTRIBUTING.md explicitly prohibits # type: ignore directives — all code must pass nox -e typecheck without any type suppression.

The four violations are:

  1. Line 731: "relevance": RelevanceStrategy, # type: ignore[dict-item]
  2. Line 732: "recency": RecencyStrategy, # type: ignore[dict-item]
  3. Line 733: "tiered": TieredStrategy, # type: ignore[dict-item]
  4. Line 775: self._strategies[spec_name] = SpecStrategyAdapter(spec_cls()) # type: ignore[assignment]

Root Cause

BUILTIN_STRATEGIES is typed as ClassVar[dict[str, type[ContextStrategy]]], but RelevanceStrategy, RecencyStrategy, and TieredStrategy are concrete classes that Pyright does not recognise as satisfying type[ContextStrategy] (a Protocol). Pyright cannot verify that a concrete class type satisfies a Protocol's structural requirements at the class-object level, hence the dict-item errors.

Similarly, SpecStrategyAdapter is not recognised as satisfying the ContextStrategy Protocol for the _strategies dict assignment (line 775), producing an assignment error. This is related to the dual incompatible ContextStrategy protocols tracked in #3491, but the # type: ignore suppressions are an independent code-standards violation that must be fixed regardless of how #3491 is resolved.

Steps to Reproduce

  1. Remove the four # type: ignore comments from acms_service.py lines 731–733 and 775
  2. Run nox -e typecheck
  3. Observe Pyright errors on those lines

Expected Behaviour

All four lines must be accepted by Pyright without any # type: ignore suppression. Acceptable remediation approaches include:

  • Changing BUILTIN_STRATEGIES type annotation to ClassVar[dict[str, Any]] or a more precise callable/factory type that Pyright can verify
  • Making SpecStrategyAdapter explicitly declare conformance to the ContextStrategy Protocol (e.g., via class SpecStrategyAdapter(ContextStrategy): ...)
  • Resolving the underlying Protocol conflict (see #3491) so that all concrete strategy classes satisfy a single, unified ContextStrategy Protocol

Code Location

src/cleveragents/application/services/acms_service.py — lines 731–733 (BUILTIN_STRATEGIES dict literal) and line 775 (_strategies assignment in _load_spec_strategy())

Subtasks

  • Investigate the exact Pyright error messages on lines 731–733 and 775 after removing # type: ignore
  • Choose the least-invasive remediation that satisfies Pyright without weakening the type model (prefer explicit Protocol conformance over Any)
  • Refactor BUILTIN_STRATEGIES type annotation and/or concrete strategy class declarations so Pyright accepts the dict literal without suppression
  • Refactor SpecStrategyAdapter to explicitly satisfy the ContextStrategy Protocol so the line 775 assignment is accepted
  • Verify no # type: ignore comments remain in acms_service.py
  • Add or update Behave scenarios covering BUILTIN_STRATEGIES strategy resolution and SpecStrategyAdapter assignment
  • Run nox -e typecheck — must pass with zero errors
  • Run nox -e unit_tests — must pass
  • Run nox (all default sessions) — must pass
  • Verify coverage >= 97% via nox -e coverage_report

Definition of Done

  • All four # type: ignore comments removed from acms_service.py
  • nox -e typecheck passes with zero Pyright errors on the affected lines
  • SpecStrategyAdapter explicitly satisfies the ContextStrategy Protocol (no implicit suppression)
  • BUILTIN_STRATEGIES type annotation is correct and Pyright-verified
  • Behave unit tests cover the affected code paths
  • All nox stages pass
  • Coverage >= 97%
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional details
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done

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

## Metadata - **Branch**: `fix/acms-service-remove-type-ignore-comments` - **Commit Message**: `fix(acms-service): resolve Pyright protocol conflicts to remove prohibited type: ignore comments` - **Milestone**: *(none — backlog)* - **Parent Epic**: #396 > **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. ## Background and Context `src/cleveragents/application/services/acms_service.py` contains four `# type: ignore` comments that directly violate the project's strict code standards. CONTRIBUTING.md explicitly prohibits `# type: ignore` directives — all code must pass `nox -e typecheck` without any type suppression. The four violations are: 1. **Line 731**: `"relevance": RelevanceStrategy, # type: ignore[dict-item]` 2. **Line 732**: `"recency": RecencyStrategy, # type: ignore[dict-item]` 3. **Line 733**: `"tiered": TieredStrategy, # type: ignore[dict-item]` 4. **Line 775**: `self._strategies[spec_name] = SpecStrategyAdapter(spec_cls()) # type: ignore[assignment]` ## Root Cause `BUILTIN_STRATEGIES` is typed as `ClassVar[dict[str, type[ContextStrategy]]]`, but `RelevanceStrategy`, `RecencyStrategy`, and `TieredStrategy` are concrete classes that Pyright does not recognise as satisfying `type[ContextStrategy]` (a Protocol). Pyright cannot verify that a concrete class *type* satisfies a Protocol's structural requirements at the class-object level, hence the `dict-item` errors. Similarly, `SpecStrategyAdapter` is not recognised as satisfying the `ContextStrategy` Protocol for the `_strategies` dict assignment (line 775), producing an `assignment` error. This is related to the dual incompatible `ContextStrategy` protocols tracked in #3491, but the `# type: ignore` suppressions are an independent code-standards violation that must be fixed regardless of how #3491 is resolved. ## Steps to Reproduce 1. Remove the four `# type: ignore` comments from `acms_service.py` lines 731–733 and 775 2. Run `nox -e typecheck` 3. Observe Pyright errors on those lines ## Expected Behaviour All four lines must be accepted by Pyright without any `# type: ignore` suppression. Acceptable remediation approaches include: - Changing `BUILTIN_STRATEGIES` type annotation to `ClassVar[dict[str, Any]]` or a more precise callable/factory type that Pyright can verify - Making `SpecStrategyAdapter` explicitly declare conformance to the `ContextStrategy` Protocol (e.g., via `class SpecStrategyAdapter(ContextStrategy): ...`) - Resolving the underlying Protocol conflict (see #3491) so that all concrete strategy classes satisfy a single, unified `ContextStrategy` Protocol ## Code Location `src/cleveragents/application/services/acms_service.py` — lines 731–733 (`BUILTIN_STRATEGIES` dict literal) and line 775 (`_strategies` assignment in `_load_spec_strategy()`) ## Subtasks - [ ] Investigate the exact Pyright error messages on lines 731–733 and 775 after removing `# type: ignore` - [ ] Choose the least-invasive remediation that satisfies Pyright without weakening the type model (prefer explicit Protocol conformance over `Any`) - [ ] Refactor `BUILTIN_STRATEGIES` type annotation and/or concrete strategy class declarations so Pyright accepts the dict literal without suppression - [ ] Refactor `SpecStrategyAdapter` to explicitly satisfy the `ContextStrategy` Protocol so the line 775 assignment is accepted - [ ] Verify no `# type: ignore` comments remain in `acms_service.py` - [ ] Add or update Behave scenarios covering `BUILTIN_STRATEGIES` strategy resolution and `SpecStrategyAdapter` assignment - [ ] Run `nox -e typecheck` — must pass with zero errors - [ ] Run `nox -e unit_tests` — must pass - [ ] Run `nox` (all default sessions) — must pass - [ ] Verify coverage >= 97% via `nox -e coverage_report` ## Definition of Done - [ ] All four `# type: ignore` comments removed from `acms_service.py` - [ ] `nox -e typecheck` passes with zero Pyright errors on the affected lines - [ ] `SpecStrategyAdapter` explicitly satisfies the `ContextStrategy` Protocol (no implicit suppression) - [ ] `BUILTIN_STRATEGIES` type annotation is correct and Pyright-verified - [ ] Behave unit tests cover the affected code paths - [ ] All nox stages pass - [ ] Coverage >= 97% - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional details - [ ] The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly - [ ] The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
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#3746
No description provided.