refactor(tv_shows): freeze aggregate, builder-only construction, drop ShowTracker fields

The TVShow aggregate is now fully immutable. TVShow, Season and Episode
are @dataclass(frozen=True), children stored as ordered tuples sorted
by number. All construction goes through TVShowBuilder / SeasonBuilder
(new module), which expose from_existing() to seed from a current
frozen aggregate and apply modifications.

ShowTracker-territory fields are stripped from the domain: ShowStatus,
CollectionStatus, expected_seasons/episodes, aired_episodes,
collection_status(), is_complete_series(), missing_episodes(),
is_ongoing(), is_ended(), Season.name, the aired<=expected validation,
and the TMDB status string mapping. These will reappear in a dedicated
ShowTracker layer (to be designed) combining the .alfred sidecar with
live TMDB data.

New SeasonMode enum (PACK / EPISODIC) computed at read time from the
season's structural shape — never stored, the YAML sidecar encodes the
mode via presence/absence of the episodes: block.

Test suite for the domain entirely rewritten to cover frozen invariants,
builder ordering, last-write-wins, from_existing round-trip, and
SeasonMode derivation. Full suite still green (1078 passed).
This commit is contained in:
2026-05-22 16:09:37 +02:00
parent 1427c8a54b
commit 6c12c18a27
7 changed files with 667 additions and 486 deletions
@@ -23,7 +23,6 @@ from alfred.domain.tv_shows.entities import Episode, TVShow
from alfred.domain.tv_shows.value_objects import (
EpisodeNumber,
SeasonNumber,
ShowStatus,
)
from alfred.infrastructure.filesystem.filesystem_operations import (
create_folder,
@@ -171,8 +170,6 @@ def _show() -> TVShow:
return TVShow(
imdb_id=ImdbId("tt0773262"),
title="Dexter",
expected_seasons=8,
status=ShowStatus.ENDED,
)