Skip to content

Cleanup: Remove unused Pydantic models (User, Session, ClientMeta, Tag) #313

Description

@brianlan

Summary

Remove unused Pydantic models User, Session, ClientMeta, and Tag from backend/app/domain/models.py and their re-exports from backend/app/domain/__init__.py.

Background / Context

These four Pydantic models were likely defined as aspirational domain models early in development but never adopted. The codebase works with raw MongoDB documents throughout — the auth system, session management, and tags API all use dicts, not these models.

A full-codebase search confirms zero usage outside their own definitions and __init__.py re-exports:

  • User (L181-189) — re-exported from domain/__init__.py, never imported elsewhere
  • Session (L192-199) — re-exported from domain/__init__.py, never imported elsewhere
  • ClientMeta (L115-117) — only referenced as a field type on the unused Session model
  • Tag (L202-207) — not even re-exported, never imported anywhere

Problem

Dead code increases cognitive load for developers reading models.py. These models suggest a domain modeling approach that the codebase does not actually follow, which is misleading.

Goal / Expected Behavior

The four unused model classes and their re-exports are removed. No runtime behavior changes.

Scope

This issue should cover:

  • Removing User, Session, ClientMeta, Tag class definitions from domain/models.py
  • Removing their re-exports from domain/__init__.py
  • Removing any imports that only existed to support these models (e.g., if ClientMeta was only imported for Session's type annotation)

Out of Scope

This issue should not cover:

  • Removing other models from models.py that ARE in use
  • Refactoring the auth/session/tags system to use Pydantic models
  • Changing any production behavior

Chosen Implementation Approach

Straight deletion. Remove the class definitions and their exports. Run tests to confirm nothing breaks.

Implementation Plan

The implementor should:

  1. Verify zero usage by running: grep -rn "from app.domain.models import.*User\|from app.domain import.*User\|from app.domain.models import.*Session\|from app.domain import.*Session\|from app.domain.models import.*ClientMeta\|from app.domain import.*ClientMeta\|from app.domain.models import.*Tag\b" backend/app/ backend/tests/
  2. Remove ClientMeta class (L115-117) from models.py
  3. Remove User class (L181-189) from models.py
  4. Remove Session class (L192-199) from models.py
  5. Remove Tag class (L202-207) from models.py
  6. Remove corresponding entries from domain/__init__.py (both import lines and __all__ entries if present)
  7. Clean up any orphaned imports in models.py that were only used by the deleted classes
  8. Run the full test suite

Relevant Files / Areas

  • backend/app/domain/models.py — model definitions (delete from here)
  • backend/app/domain/__init__.py — re-exports (clean up)

Tests Required

The implementor must add or update automated tests covering:

  • No new tests are needed — this is pure dead code removal
  • All existing tests must pass unchanged

At minimum, tests should verify:

  • The full test suite passes: cd backend && python -m pytest tests/ -v
  • The application starts without import errors

Manual Verification / Self-Check

Before claiming this issue is done, the implementor must:

  1. Run: cd backend && python -m pytest tests/ -v
  2. Run: grep -rn "ClientMeta\|class User\|class Session\|class Tag" backend/app/domain/ to verify no remnants
  3. Verify models.py still contains all OTHER models that are in use
  4. Record the exact commands run and results in the PR description

Reviewer Acceptance Checklist

The reviewer should verify that:

  • Only the 4 specified classes were removed — no other models were touched
  • Re-exports in __init__.py were cleaned up
  • No orphaned imports remain
  • All existing tests pass
  • No production behavior changed

Dependencies

None.

Follow-Up Work

None.

Definition of Done

This issue is done when:

  • User, Session, ClientMeta, Tag are removed from domain/models.py
  • Their re-exports are removed from domain/__init__.py
  • All tests pass

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions