Priority: high Complexity: medium Status: done
domain.py is a monolith that contains all of the following at once:
GoalRecord, AttemptEntryRecord, EffectiveGoalRecord)goal_from_dict, goal_to_dict, entry_from_dict, …)validate_goal_record, validate_entry_record, validate_metrics_data, …)aggregate_chain_costs, compute_summary_block, build_effective_goals, …)now_utc_iso, parse_iso_datetime, …)next_goal_id, next_entry_id)LEGACY_GOAL_SUPERSEDES_MAP, normalize_legacy_metrics_data)Any change to any of these layers touches the same file.
Split into submodules:
src/ai_agents_metrics/domain/
__init__.py # re-exports the public API (backward compatibility)
models.py # dataclasses only
serde.py # from_dict / to_dict
validation.py # validate_* functions
aggregation.py # aggregate_*, compute_summary_block, build_effective_goals
ids.py # next_goal_id, next_entry_id
time_utils.py # now_utc_iso, parse_iso_datetime, ...
domain/__init__.py re-exports everything — the external API does not break.
from ai_agents_metrics.domain import GoalRecord continues to workmake verify passesmodels.py — it has no dependencies on other parts of domainaggregation.py for last — it has the most complex dependency graph