fix(plan_generation): remove dead code — unused _extract_path_from_prompt and _find_matching_context methods #3451

Open
opened 2026-04-05 17:19:18 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: fix/dead-code-plan-generation-unused-methods
  • Commit Message: fix(plan_generation): remove dead _extract_path_from_prompt and _find_matching_context methods
  • Milestone: None (backlog)
  • Parent Epic: #946

Background and Context

A bug-hunt consistency audit identified two unused private methods in PlanGenerationGraph that constitute dead code. The methods _extract_path_from_prompt and _find_matching_context are defined in src/cleveragents/agents/graphs/plan_generation.py (lines 465–483) but are never called anywhere in the codebase. Dead code increases maintenance burden, misleads contributors about the intended design, and may cause confusion during future refactoring.

Current Behavior

PlanGenerationGraph contains two unreachable methods:

# src/cleveragents/agents/graphs/plan_generation.py:465-483
def _extract_path_from_prompt(self, prompt: str) -> str | None:
    """Return a file or directory path only when explicitly prefixed with @."""
    match = PATH_HINT_RE.search(prompt or "")
    return match.group("path") if match else None

def _find_matching_context(
    self, contexts: list[Context], file_path: str | None
) -> Context | None:
    """Return a context whose path matches the hinted file."""
    if not file_path:
        return None
    for ctx in contexts:
        ctx_path = ctx.path
        if ctx_path and (ctx_path == file_path or ctx_path.endswith(file_path)):
            return ctx
    return None

Neither method is invoked by any other method in the class or anywhere else in the codebase.

Expected Behavior

The source tree contains no dead code. All methods in PlanGenerationGraph are reachable and serve a documented purpose.

Acceptance Criteria

  • _extract_path_from_prompt is removed from PlanGenerationGraph
  • _find_matching_context is removed from PlanGenerationGraph
  • PATH_HINT_RE constant is removed if it is only referenced by the deleted methods (verify no other usages)
  • No other references to the removed methods exist anywhere in the codebase
  • All existing tests continue to pass after removal
  • No new linting warnings are introduced

Subtasks

  • Confirm via static analysis (e.g., rg / pyright) that neither method is called anywhere
  • Remove _extract_path_from_prompt from PlanGenerationGraph
  • Remove _find_matching_context from PlanGenerationGraph
  • Check whether PATH_HINT_RE is used elsewhere; remove if orphaned
  • Run full nox suite to confirm no regressions

Definition of Done

  • Both dead methods are deleted from plan_generation.py
  • Any orphaned constants (e.g., PATH_HINT_RE) are also removed if unused
  • All nox stages pass
  • Coverage >= 97%

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


Automated by CleverAgents Bot
Supervisor: Bug Hunting | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/dead-code-plan-generation-unused-methods` - **Commit Message**: `fix(plan_generation): remove dead _extract_path_from_prompt and _find_matching_context methods` - **Milestone**: None (backlog) - **Parent Epic**: #946 ## Background and Context A bug-hunt consistency audit identified two unused private methods in `PlanGenerationGraph` that constitute dead code. The methods `_extract_path_from_prompt` and `_find_matching_context` are defined in `src/cleveragents/agents/graphs/plan_generation.py` (lines 465–483) but are never called anywhere in the codebase. Dead code increases maintenance burden, misleads contributors about the intended design, and may cause confusion during future refactoring. ## Current Behavior `PlanGenerationGraph` contains two unreachable methods: ```python # src/cleveragents/agents/graphs/plan_generation.py:465-483 def _extract_path_from_prompt(self, prompt: str) -> str | None: """Return a file or directory path only when explicitly prefixed with @.""" match = PATH_HINT_RE.search(prompt or "") return match.group("path") if match else None def _find_matching_context( self, contexts: list[Context], file_path: str | None ) -> Context | None: """Return a context whose path matches the hinted file.""" if not file_path: return None for ctx in contexts: ctx_path = ctx.path if ctx_path and (ctx_path == file_path or ctx_path.endswith(file_path)): return ctx return None ``` Neither method is invoked by any other method in the class or anywhere else in the codebase. ## Expected Behavior The source tree contains no dead code. All methods in `PlanGenerationGraph` are reachable and serve a documented purpose. ## Acceptance Criteria - [ ] `_extract_path_from_prompt` is removed from `PlanGenerationGraph` - [ ] `_find_matching_context` is removed from `PlanGenerationGraph` - [ ] `PATH_HINT_RE` constant is removed if it is only referenced by the deleted methods (verify no other usages) - [ ] No other references to the removed methods exist anywhere in the codebase - [ ] All existing tests continue to pass after removal - [ ] No new linting warnings are introduced ## Subtasks - [ ] Confirm via static analysis (e.g., `rg` / pyright) that neither method is called anywhere - [ ] Remove `_extract_path_from_prompt` from `PlanGenerationGraph` - [ ] Remove `_find_matching_context` from `PlanGenerationGraph` - [ ] Check whether `PATH_HINT_RE` is used elsewhere; remove if orphaned - [ ] Run full nox suite to confirm no regressions ## Definition of Done - [ ] Both dead methods are deleted from `plan_generation.py` - [ ] Any orphaned constants (e.g., `PATH_HINT_RE`) are also removed if unused - [ ] All nox stages pass - [ ] Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.2.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: ca-new-issue-creator
freemo added this to the v3.7.0 milestone 2026-04-05 17:25:14 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Backlog (confirmed) — Dead code removal. Two unused private methods in PlanGenerationGraph.
  • Milestone: v3.7.0 (assigned — code cleanup)
  • Story Points: 1 (XS) — Delete two methods and optionally one constant. Trivial.
  • MoSCoW: Could Have — Dead code removal is housekeeping, not functional.
  • Parent Epic: #946 (Stub Package Cleanup)

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

Issue triaged by project owner: - **State**: Verified - **Priority**: Backlog (confirmed) — Dead code removal. Two unused private methods in PlanGenerationGraph. - **Milestone**: v3.7.0 (assigned — code cleanup) - **Story Points**: 1 (XS) — Delete two methods and optionally one constant. Trivial. - **MoSCoW**: Could Have — Dead code removal is housekeeping, not functional. - **Parent Epic**: #946 (Stub Package Cleanup) --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

Milestone Triage Decision: Moved to Backlog

This issue has been moved out of v3.3.0 during aggressive milestone triage. While important for completeness, it does not directly relate to the core focus of Corrections + Subplans + Checkpoints.

Reasoning:

  • v3.3.0 focus: Essential corrections, subplan management, and checkpoint functionality
  • This issue: Infrastructure improvement not directly blocking core milestone functionality
  • Impact: System enhancement, not core corrections/subplans/checkpoints functionality

Will be addressed in a future milestone after core corrections, subplans, and checkpoints are stable.

**Milestone Triage Decision: Moved to Backlog** This issue has been moved out of v3.3.0 during aggressive milestone triage. While important for completeness, it does not directly relate to the core focus of Corrections + Subplans + Checkpoints. **Reasoning:** - v3.3.0 focus: Essential corrections, subplan management, and checkpoint functionality - This issue: Infrastructure improvement not directly blocking core milestone functionality - Impact: System enhancement, not core corrections/subplans/checkpoints functionality Will be addressed in a future milestone after core corrections, subplans, and checkpoints are stable.
freemo removed this from the v3.7.0 milestone 2026-04-06 23:49:02 +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#3451
No description provided.