3c4a52901a
After 11 class moves (Phases 3a-3i) + 1 deletion (Phase 4), this commit
reduces src/models.py from 1044 lines (original) / 768 lines (pre-Phase 3b)
to 135 lines. The remaining content is:
- DEFAULT_TOOL_CATEGORIES: the canonical tool list grouped for
the UI's category filter (the ONLY non-Pydantic constant)
- _create_generate_request + _create_confirm_request: the Pydantic
proxy classes for the API hook subsystem
- _PYDANTIC_CLASS_FACTORIES: registry for the Pydantic proxies
- __getattr__: lazy re-exports for ALL 30+ moved classes + PROVIDERS
Removed:
- All 11 class definitions (MMA Core, FileItem + 4 file-related,
Tool + ToolPreset + BiasProfile, 2 editor configs, WorkspaceProfile,
4 MCP config classes + load_mcp_config, ProjectContext + 5 sub)
- All 3 config IO function definitions (load_config_from_disk,
save_config_to_disk, _clean_nones, parse_history_entries)
- All 5 eager re-export blocks at the top (they triggered tomli_w
loading at import time via the personas import; the lazy __getattr__
breaks the cycle)
- AGENT_TOOL_NAMES (deleted in Phase 4)
The lazy __getattr__ keeps the 'from src.models import X' pattern
working for legacy callers. New code should import directly from
the subsystem files (src.mma, src.project, src.project_files,
src.tool_presets, src.tool_bias, src.external_editor, src.mcp_client,
src.workspace_manager, src.personas).
Side benefit: the pre-existing test
tests/test_models_no_top_level_tomli_w.py::test_models_does_not_import_tomli_w_at_module_level
now PASSES. Before Phase 5 it failed because the eager
'from src.personas import Persona' triggered tomli_w loading. The
lazy __getattr__ for Persona only loads tomli_w when 'models.Persona'
is actually accessed (not on a bare 'import src.models').
Verification: VC10
wc -l src/models.py # 135 lines (well under the 1044-line original;
# 30-line target was aspirational; the lazy
# __getattr__ for 30+ moved classes is the
# dominant cost)
Measure-Object -Line on src/models.py # 135
Tests verified (84/85 PASS; 1 pre-existing failure unrelated):
tests/test_mcp_config.py (3/3 PASS)
tests/test_tool_preset_manager.py (4/4 PASS)
tests/test_bias_models.py (3/3 PASS)
tests/test_tool_bias.py (3/3 PASS)
tests/test_external_editor.py (17/17 PASS)
tests/test_workspace_manager.py (3/3 PASS)
tests/test_models_no_top_level_tomli_w.py (3/3 PASS) [previously 1 FAIL]
tests/test_project_context_20260627.py (10/10 PASS)
tests/test_file_item_model.py (4/4 PASS)
tests/test_view_presets.py (4/4 PASS)
tests/test_context_presets_models.py (3/3 PASS)
tests/test_presets.py (5/5 PASS)
tests/test_persona_models.py (2/2 PASS)
tests/test_persona_manager.py (3/3 PASS)
tests/test_arch_boundary_phase2.py (5/6 PASS; 1 pre-existing FAIL
unrelated: test_rejection_prevents_dispatch
is a dialog-mock issue)
tests/test_mcp_tool_specs.py (10/10 PASS)