Skip to content

refactor: Continue database.py mixin split (1270 lines) #123

Closed as not planned

Description

@vybe

Problem

src/backend/database.py (1270 lines) is a delegation facade for all database operations. The agent operations were successfully split into mixins (#102), reducing db/agents.py from ~1000 to ~160 lines. The same pattern should be applied to the remaining delegation methods in database.py itself.

Currently database.py contains delegation methods for:

  • Agent operations (done — delegates to mixins)
  • Schedule operations
  • Public link operations
  • Monitoring operations
  • System view operations
  • Dashboard history operations
  • And more

Proposed Solution

Group remaining delegations by concern and slim the facade:

  1. Remove pass-through methods where callers can use the operation class directly
  2. Or continue the mixin/facade pattern to keep DatabaseManager as the single entry point but slim each section

The goal is database.py < 500 lines with clear section organization.

Also: Clean up dead imports

Vulture detected 8 unused imports in database.py:29 (90% confidence):
AgentOwnership, AgentPermissionInfo, EmailWhitelistEntry, HealthCheckRecord, HealthCheckType, McpAgentKeyCreate, SharedFolderConfigUpdate, SharedFolderInfo

Verify these aren't re-exported before removing.

Acceptance Criteria

  • database.py < 600 lines
  • Dead imports verified and removed
  • All existing DB access patterns work
  • All tests pass

Source

Refactor audit 2026-03-13, continuation of #102

Activity

  1. added
    priority-p1
    type-refactor
    on Mar 14, 2026
  2. oleksandr-korin commented on May 29, 2026

    @oleksandr-korin
    Contributor

    Closing as superseded — file-split refactor tickets created en masse on 2026-03-14 from a one-shot complexity scan. The /code-health weekly automation now scores hotspots dynamically and creates better-targeted issues from current churn × complexity, so static "split N-line file" tickets are no longer the right unit of work. The underlying complexity signal will resurface organically if/when it matters. Reference: backlog lean review on 2026-05-28.

  3. added
    complexity-low
    theme-devex
    on Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-lowpriority-p1theme-devextype-refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions