architecture_steps.py step_check_type_annotations collects annotation counts that step_verify_public_functions_type_hints never uses (dead data flow) #8431

Open
opened 2026-04-13 18:52:40 +00:00 by HAL9000 · 1 comment
Owner

Metadata

Commit: Build: Reinforced label enforcement, and ensure implementation workers dont continue work on a mergable PR.
Branch: main

Background and Context

In features/steps/architecture_steps.py, the step_check_type_annotations step (bound to When I check for type annotations) collects four counters on the context object:

context.functions_with_hints = 0
context.functions_without_hints = 0
context.pydantic_models = 0
context.regular_dataclasses = 0

These counters are incremented as the step scans all .py files under src/cleveragents/. However, the subsequent Then step — step_verify_public_functions_type_hints (bound to Then all public functions should have type hints) — completely ignores these counters and instead performs its own independent full re-scan of the source tree:

@then("all public functions should have type hints")
def step_verify_public_functions_type_hints(context):
    missing_annotations = []
    for py_file in context.src_dir.rglob("*.py"):
        try:
            tree = ast.parse(py_file.read_text())
        except SyntaxError:
            continue
        for node in ast.walk(tree):
            if isinstance(node, ast.FunctionDef) and not node.name.startswith("_"):
                # ... checks annotations independently

This means:

  1. The When step's scan is entirely wasted — its results are never consumed
  2. The source tree is scanned twice for every scenario that uses this step pair
  3. The counters context.functions_with_hints, context.functions_without_hints, context.pydantic_models, and context.regular_dataclasses are dead data — they are set but never read by any subsequent step

Similarly, step_verify_dataclasses_pydantic (bound to Then all dataclasses should use Pydantic models) also re-scans independently rather than using context.regular_dataclasses.

Current Behavior

step_check_type_annotations scans the source tree and populates four context counters. step_verify_public_functions_type_hints and step_verify_dataclasses_pydantic ignore these counters and re-scan the source tree independently. The double scan adds unnecessary overhead to every architecture test run.

Expected Behavior

Either:

  1. Option A (preferred): step_check_type_annotations stores the full scan results (missing annotations list, non-Pydantic dataclasses list) on the context, and step_verify_public_functions_type_hints / step_verify_dataclasses_pydantic consume those stored results instead of re-scanning.
  2. Option B: Remove the dead counter collection from step_check_type_annotations entirely, since the Then steps already perform their own complete scans.

Acceptance Criteria

  • step_check_type_annotations does not collect data that is never consumed by any subsequent step
  • step_verify_public_functions_type_hints does not re-scan the source tree if step_check_type_annotations already scanned it
  • step_verify_dataclasses_pydantic does not re-scan the source tree if step_check_type_annotations already scanned it
  • The architecture feature scenarios produce identical pass/fail results before and after the fix
  • No dead context attributes (functions_with_hints, functions_without_hints, pydantic_models, regular_dataclasses) remain unless they are consumed by a step

Subtasks

  • Decide between Option A (share scan results) or Option B (remove dead collection)
  • If Option A: refactor step_check_type_annotations to store missing_annotations and non_pydantic_dataclasses lists on context
  • If Option A: refactor step_verify_public_functions_type_hints to use context.missing_annotations instead of re-scanning
  • If Option A: refactor step_verify_dataclasses_pydantic to use context.non_pydantic_dataclasses instead of re-scanning
  • If Option B: remove the four counter assignments from step_check_type_annotations
  • Run architecture BDD scenarios to confirm identical results

Definition of Done

This issue is closed when there is no dead data collection in step_check_type_annotations and the source tree is scanned at most once per architecture scenario execution.


Automated by CleverAgents Bot
Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor

## Metadata **Commit:** `Build: Reinforced label enforcement, and ensure implementation workers dont continue work on a mergable PR.` **Branch:** main ## Background and Context In `features/steps/architecture_steps.py`, the `step_check_type_annotations` step (bound to `When I check for type annotations`) collects four counters on the context object: ```python context.functions_with_hints = 0 context.functions_without_hints = 0 context.pydantic_models = 0 context.regular_dataclasses = 0 ``` These counters are incremented as the step scans all `.py` files under `src/cleveragents/`. However, the subsequent `Then` step — `step_verify_public_functions_type_hints` (bound to `Then all public functions should have type hints`) — **completely ignores these counters** and instead performs its own independent full re-scan of the source tree: ```python @then("all public functions should have type hints") def step_verify_public_functions_type_hints(context): missing_annotations = [] for py_file in context.src_dir.rglob("*.py"): try: tree = ast.parse(py_file.read_text()) except SyntaxError: continue for node in ast.walk(tree): if isinstance(node, ast.FunctionDef) and not node.name.startswith("_"): # ... checks annotations independently ``` This means: 1. The `When` step's scan is entirely wasted — its results are never consumed 2. The source tree is scanned **twice** for every scenario that uses this step pair 3. The counters `context.functions_with_hints`, `context.functions_without_hints`, `context.pydantic_models`, and `context.regular_dataclasses` are dead data — they are set but never read by any subsequent step Similarly, `step_verify_dataclasses_pydantic` (bound to `Then all dataclasses should use Pydantic models`) also re-scans independently rather than using `context.regular_dataclasses`. ## Current Behavior `step_check_type_annotations` scans the source tree and populates four context counters. `step_verify_public_functions_type_hints` and `step_verify_dataclasses_pydantic` ignore these counters and re-scan the source tree independently. The double scan adds unnecessary overhead to every architecture test run. ## Expected Behavior Either: 1. **Option A (preferred):** `step_check_type_annotations` stores the full scan results (missing annotations list, non-Pydantic dataclasses list) on the context, and `step_verify_public_functions_type_hints` / `step_verify_dataclasses_pydantic` consume those stored results instead of re-scanning. 2. **Option B:** Remove the dead counter collection from `step_check_type_annotations` entirely, since the `Then` steps already perform their own complete scans. ## Acceptance Criteria - [ ] `step_check_type_annotations` does not collect data that is never consumed by any subsequent step - [ ] `step_verify_public_functions_type_hints` does not re-scan the source tree if `step_check_type_annotations` already scanned it - [ ] `step_verify_dataclasses_pydantic` does not re-scan the source tree if `step_check_type_annotations` already scanned it - [ ] The architecture feature scenarios produce identical pass/fail results before and after the fix - [ ] No dead context attributes (`functions_with_hints`, `functions_without_hints`, `pydantic_models`, `regular_dataclasses`) remain unless they are consumed by a step ## Subtasks - [ ] Decide between Option A (share scan results) or Option B (remove dead collection) - [ ] If Option A: refactor `step_check_type_annotations` to store `missing_annotations` and `non_pydantic_dataclasses` lists on context - [ ] If Option A: refactor `step_verify_public_functions_type_hints` to use `context.missing_annotations` instead of re-scanning - [ ] If Option A: refactor `step_verify_dataclasses_pydantic` to use `context.non_pydantic_dataclasses` instead of re-scanning - [ ] If Option B: remove the four counter assignments from `step_check_type_annotations` - [ ] Run architecture BDD scenarios to confirm identical results ## Definition of Done This issue is closed when there is no dead data collection in `step_check_type_annotations` and the source tree is scanned at most once per architecture scenario execution. --- **Automated by CleverAgents Bot** Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor
HAL9000 added this to the v3.4.0 milestone 2026-04-13 19:26:03 +00:00
Author
Owner

[AUTO-OWNR-4] Triage Decision

Status: Verified

MoSCoW: Could Have
Priority: Low

Rationale: This is a legitimate code quality bug — step_check_type_annotations in architecture_steps.py performs a full source tree scan and populates four context counters (functions_with_hints, functions_without_hints, pydantic_models, regular_dataclasses) that are never consumed by any subsequent step. The Then steps re-scan independently, causing a redundant double-scan on every architecture test run. While real, this is a minor performance and dead-code issue with no functional impact on test correctness. It does not block any v3.4.0 milestone acceptance criteria and is therefore classified as Could Have — worth fixing but not required for the release.

Next Steps: A developer should choose between Option A (refactor step_check_type_annotations to store scan results on context and have Then steps consume them) or Option B (remove the dead counter collection entirely). Option A is preferred as it eliminates the double-scan overhead. Fix should be accompanied by a BDD scenario run confirming identical pass/fail results before and after.


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

## [AUTO-OWNR-4] Triage Decision **Status**: ✅ Verified **MoSCoW**: Could Have **Priority**: Low **Rationale**: This is a legitimate code quality bug — `step_check_type_annotations` in `architecture_steps.py` performs a full source tree scan and populates four context counters (`functions_with_hints`, `functions_without_hints`, `pydantic_models`, `regular_dataclasses`) that are never consumed by any subsequent step. The `Then` steps re-scan independently, causing a redundant double-scan on every architecture test run. While real, this is a minor performance and dead-code issue with no functional impact on test correctness. It does not block any v3.4.0 milestone acceptance criteria and is therefore classified as **Could Have** — worth fixing but not required for the release. **Next Steps**: A developer should choose between Option A (refactor `step_check_type_annotations` to store scan results on context and have `Then` steps consume them) or Option B (remove the dead counter collection entirely). Option A is preferred as it eliminates the double-scan overhead. Fix should be accompanied by a BDD scenario run confirming identical pass/fail results before and after. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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.

Dependencies

No dependencies set.

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