Comprehensive Codebase Audit Report - General Health and Refactoring Focus (2026-05-23)

Scope

Evidence Reviewed

Findings

ID Domain Severity Confidence Summary Evidence
F-001 Service complexity High 94% ChatServices.cs concentrates chat contracts, provider implementations, orchestration, tool loops, and write-approval logic in a single 2807-line unit, raising regression risk and review cost. MemorySmith.App/Services/ChatServices.cs
F-002 Service complexity High 92% MaintenanceAgentServices.cs combines many unrelated types (proposal store, workflow, topic map, scheduler, service) in one 2082-line file, reducing cohesion and test isolation. MemorySmith.App/Services/MaintenanceAgentServices.cs
F-003 Test maintainability High 89% PagesAndChatTests.cs is a 1554-line mixed-domain fixture (pages, chat, controllers), making failures harder to triage and increasing edit blast radius. MemorySmith.Tests/PagesAndChatTests.cs
F-004 Domain/service boundary Medium 86% TaskDomainService.cs mixes task contracts, validation, filesystem persistence, and activity history handling in one large service (814 lines). MemorySmith.App/Services/TaskDomainService.cs
F-005 Dependency hygiene Medium 78% Nerdbank.MessagePack is referenced in MemorySmith.App.csproj but no direct usage was found in tracked C# source, indicating likely removable dependency or stale reference. MemorySmith.App/MemorySmith.App.csproj, workspace code search
F-006 Architecture drift Medium 88% Active final refactor design favors cohesive service boundaries and simplification, but current hotspots indicate accumulated complexity drift in chat/maintenance/task surfaces. MemorySmith.Core/Docs/Plans/MemorySmith_FinalRefactorDesign_20260507.md, hotspot files above

Prioritized Backlog (Refactor-First)

  1. Split ChatServices into bounded modules (contracts, providers, tool-loop/orchestrator, agent-write pipeline).
  2. Split MaintenanceAgentServices into separate files/services by bounded context.
  3. Decompose PagesAndChatTests into focused fixtures with shared builders/utilities.
  4. Split TaskDomainService into contract/model, storage adapter, and orchestration layer.
  5. Run dependency hygiene pass; remove/justify stale package references.
  6. Add refactor guardrails (file-size/cohesion checks and architecture conformance tests).

Risk Register

Open Questions

Assumptions

Confidence