Skip to content

EPIC: Code Duplication Consolidation (DRY) #1975

@bug-ops

Description

@bug-ops

Problem

8 significant duplication patterns across the codebase, primarily in the LLM provider layer:

  • Usage/cache tracking (Mutex pattern) duplicated in 4 providers
  • set_status_tx boilerplate in 6 providers
  • type_name schema generation in 3 providers
  • ChannelError::Other mapping in 14+ locations
  • BoxFuture type alias in 3 files

Goal

Consolidate duplicated patterns into shared utilities, reducing maintenance burden.

Audit Reference

.local/audit/003-duplication-analysis.md

Key Issues

  • DRY-01: Extract UsageTracker struct for LLM providers (60 lines, 4 providers)
  • DRY-02: Consolidate set_status_tx (18 lines, 6 providers)
  • DRY-03: Shared type_name schema helper (30 lines, 3 providers)
  • DRY-04: ChannelError::Other helper method (14+ sites)
  • DRY-05: Single BoxFuture alias in zeph-memory
  • DRY-06: Provider Clone via UsageTracker
  • DRY-07: Model context window lookup table
  • DRY-08: Error::Other extension trait

Acceptance Criteria

  • UsageTracker extracted and used by all 4 LLM providers
  • ChannelError helper method reduces .map_err boilerplate
  • Single BoxFuture definition
  • All tests pass
  • No behavioral changes

Estimated Effort

~7 hours total

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureArchitecture improvementsepicMilestone-level tracking issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions