UAT: Two Pyright type errors in production code — missing EventType member and undefined variable #3844

Open
opened 2026-04-06 06:55:17 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/pyright-type-errors
  • Commit Message: fix(types): resolve Pyright errors for missing EventType member and undefined container variable
  • Milestone: Backlog
  • Parent Epic: #2810

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

Background

Running nox -e typecheck (Pyright) against src/cleveragents/ reveals 2 type errors that must be fixed. The project specification requires all code to be fully, statically typed and pass Pyright checks.

Error 1: Missing EventType.PLAN_ROLLED_BACK member

File: src/cleveragents/application/services/plan_lifecycle_service.py
Line: 1290
Error: reportAttributeAccessIssue — Cannot access attribute "PLAN_ROLLED_BACK" for class "type[EventType]". Attribute "PLAN_ROLLED_BACK" is unknown.

Root Cause: plan_lifecycle_service.py uses EventType.PLAN_ROLLED_BACK at line 1290, but this member is not defined in src/cleveragents/infrastructure/events/types.py. The EventType enum contains members like PLAN_CREATED, PLAN_APPLIED, PLAN_CANCELLED, etc., but PLAN_ROLLED_BACK is missing.

Fix Required: Add PLAN_ROLLED_BACK = "plan.rolled_back" to the EventType enum in src/cleveragents/infrastructure/events/types.py.

Error 2: Undefined variable container in plan.py

File: src/cleveragents/cli/commands/plan.py
Line: 3624
Error: reportUndefinedVariable — "container" is not defined.

Root Cause: At line 3624, container.decision_service() is called inside a nested try block, but container is not defined in the enclosing scope at that point. The function uses _get_lifecycle_service() at line 3596 but does not call get_container() before the nested try block at line 3619.

Fix Required: Either call container = get_container() before the nested try block, or restructure the code to use the already-available lifecycle_service variable.

Steps to Reproduce

nox -e typecheck
# Or directly:
pyright src/cleveragents/

Output:

/app/src/cleveragents/application/services/plan_lifecycle_service.py:1290:46 - error: Cannot access attribute "PLAN_ROLLED_BACK" for class "type[EventType]"  (reportAttributeAccessIssue)
/app/src/cleveragents/cli/commands/plan.py:3624:32 - error: "container" is not defined  (reportUndefinedVariable)

Expected Behavior

nox -e typecheck passes with zero errors.

Actual Behavior

Two Pyright errors are reported, indicating real type safety issues in production code.

Subtasks

  • Add PLAN_ROLLED_BACK = "plan.rolled_back" to EventType enum in src/cleveragents/infrastructure/events/types.py
  • Fix undefined container variable in src/cleveragents/cli/commands/plan.py line 3624
  • Tests (Behave): Add scenario covering EventType.PLAN_ROLLED_BACK usage in plan lifecycle service
  • Run nox -e typecheck and confirm zero errors
  • Run nox (all default sessions), fix any errors
  • Verify coverage >= 97% via nox -e coverage_report

Definition of Done

  • EventType.PLAN_ROLLED_BACK added to src/cleveragents/infrastructure/events/types.py
  • Undefined container variable fixed in src/cleveragents/cli/commands/plan.py line 3624
  • nox -e typecheck passes with zero errors
  • Corresponding Behave scenarios added to cover the new EventType member
  • 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 lines providing relevant details about the implementation
  • 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/pyright-type-errors` - **Commit Message**: `fix(types): resolve Pyright errors for missing EventType member and undefined container variable` - **Milestone**: Backlog - **Parent Epic**: #2810 > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.7.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## Background Running `nox -e typecheck` (Pyright) against `src/cleveragents/` reveals **2 type errors** that must be fixed. The project specification requires all code to be fully, statically typed and pass Pyright checks. ## Error 1: Missing `EventType.PLAN_ROLLED_BACK` member **File**: `src/cleveragents/application/services/plan_lifecycle_service.py` **Line**: 1290 **Error**: `reportAttributeAccessIssue` — Cannot access attribute "PLAN_ROLLED_BACK" for class "type[EventType]". Attribute "PLAN_ROLLED_BACK" is unknown. **Root Cause**: `plan_lifecycle_service.py` uses `EventType.PLAN_ROLLED_BACK` at line 1290, but this member is not defined in `src/cleveragents/infrastructure/events/types.py`. The `EventType` enum contains members like `PLAN_CREATED`, `PLAN_APPLIED`, `PLAN_CANCELLED`, etc., but `PLAN_ROLLED_BACK` is missing. **Fix Required**: Add `PLAN_ROLLED_BACK = "plan.rolled_back"` to the `EventType` enum in `src/cleveragents/infrastructure/events/types.py`. ## Error 2: Undefined variable `container` in `plan.py` **File**: `src/cleveragents/cli/commands/plan.py` **Line**: 3624 **Error**: `reportUndefinedVariable` — "container" is not defined. **Root Cause**: At line 3624, `container.decision_service()` is called inside a nested `try` block, but `container` is not defined in the enclosing scope at that point. The function uses `_get_lifecycle_service()` at line 3596 but does not call `get_container()` before the nested try block at line 3619. **Fix Required**: Either call `container = get_container()` before the nested try block, or restructure the code to use the already-available `lifecycle_service` variable. ## Steps to Reproduce ```bash nox -e typecheck # Or directly: pyright src/cleveragents/ ``` **Output**: ``` /app/src/cleveragents/application/services/plan_lifecycle_service.py:1290:46 - error: Cannot access attribute "PLAN_ROLLED_BACK" for class "type[EventType]" (reportAttributeAccessIssue) /app/src/cleveragents/cli/commands/plan.py:3624:32 - error: "container" is not defined (reportUndefinedVariable) ``` ## Expected Behavior `nox -e typecheck` passes with zero errors. ## Actual Behavior Two Pyright errors are reported, indicating real type safety issues in production code. ## Subtasks - [ ] Add `PLAN_ROLLED_BACK = "plan.rolled_back"` to `EventType` enum in `src/cleveragents/infrastructure/events/types.py` - [ ] Fix undefined `container` variable in `src/cleveragents/cli/commands/plan.py` line 3624 - [ ] Tests (Behave): Add scenario covering `EventType.PLAN_ROLLED_BACK` usage in plan lifecycle service - [ ] Run `nox -e typecheck` and confirm zero errors - [ ] Run `nox` (all default sessions), fix any errors - [ ] Verify coverage >= 97% via `nox -e coverage_report` ## Definition of Done - [ ] `EventType.PLAN_ROLLED_BACK` added to `src/cleveragents/infrastructure/events/types.py` - [ ] Undefined `container` variable fixed in `src/cleveragents/cli/commands/plan.py` line 3624 - [ ] `nox -e typecheck` passes with zero errors - [ ] Corresponding Behave scenarios added to cover the new `EventType` member - [ ] 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 lines providing relevant details about the implementation - [ ] 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.

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