chore: sprint cleanup — language unification, parser unification, fossils removal

Several weeks of work accumulated without being committed. Grouped here for
clarity; see CHANGELOG.md [Unreleased] for the user-facing summary.

Highlights
----------

P1 #2 — ISO 639-2/B canonical migration
- New Language VO + LanguageRegistry (alfred/domain/shared/knowledge/).
- iso_languages.yaml as single source of truth for language codes.
- SubtitleKnowledgeBase now delegates lookup to LanguageRegistry; subtitles.yaml
  only declares subtitle-specific tokens (vostfr, vf, vff, …).
- SubtitlePreferences default → ["fre", "eng"]; subtitle filenames written as
  {iso639_2b}.srt (legacy fr.srt still read via alias).
- Scanner: dropped _LANG_KEYWORDS / _SDH_TOKENS / _FORCED_TOKENS /
  SUBTITLE_EXTENSIONS hardcoded dicts.
- Fixed: 'hi' token no longer marks SDH (conflicted with Hindi alias).
- Added settings.min_movie_size_bytes (was a module constant).

P1 #3 — Release parser unification + data-driven tokenizer
- parse_release() is now the single source of truth for release-name parsing.
- alfred/knowledge/release/separators.yaml declares the token separators used
  by the tokenizer (., space, [, ], (, ), _). New conventions can be added
  without code changes.
- Tokenizer now splits on any configured separator instead of name.split('.').
  Releases like 'The Father (2020) [1080p] [WEBRip] [5.1] [YTS.MX]' parse via
  the direct path without sanitization fallback.
- Site-tag extraction always runs first; well-formedness only rejects truly
  forbidden chars.
- _parse_season_episode() extended with NxNN / NxNNxNN alt forms.
- Removed dead helpers: _sanitize, _normalize.

Domain cleanup
- Deleted fossil services with zero production callers:
    alfred/domain/movies/services.py
    alfred/domain/tv_shows/services.py
    alfred/domain/subtitles/services.py (replaced by subtitles/services/ package)
    alfred/domain/subtitles/repositories.py
- Split monolithic subtitle services into a package (identifier, matcher,
  placer, pattern_detector, utils) + dedicated knowledge/ package.
- MediaInfo split into dedicated package (alfred/domain/shared/media/:
  audio, video, subtitle, info, matching).

Persistence cleanup
- Removed dead JSON repositories (movie/subtitle/tvshow_repository.py).

Tests
- Major expansion of the test suite organized to mirror the source tree.
- Removed obsolete *_edge_cases test files superseded by structured tests.
- Suite: 990 passed, 8 skipped.

Misc
- .gitignore: exclude env_backup/ and *.bak.
- Adjustments across agent/llm, app.py, application/filesystem, and
  infrastructure/filesystem to align with the new domain layout.
This commit is contained in:
2026-05-17 23:38:00 +02:00
parent ba6f016d49
commit e07c9ec77b
99 changed files with 8833 additions and 6533 deletions
+36 -23
View File
@@ -1,4 +1,15 @@
"""Critical tests for configuration validation."""
"""Tests for ``alfred.settings.Settings`` validation.
Covers the field-level validators that ship today:
- ``llm_temperature`` — must be within [0, 2].
- ``max_tool_iterations`` — must be positive.
- ``request_timeout`` — must be positive.
URL fields (``deepseek_base_url``, ``tmdb_base_url``) are *not* currently
URL-validated; tests document that contract explicitly so a future
regression that silently drops the validator would be caught.
"""
import pytest
@@ -53,30 +64,32 @@ class TestConfigValidation:
Settings(request_timeout=30)
Settings(request_timeout=300)
def test_invalid_deepseek_url_raises_error(self):
"""Verify invalid DeepSeek URL is rejected."""
with pytest.raises(ConfigurationError, match="Invalid deepseek_base_url"):
Settings(deepseek_base_url="not-a-url")
def test_deepseek_url_accepted_verbatim(self):
"""``deepseek_base_url`` is currently not URL-validated.
with pytest.raises(ConfigurationError, match="Invalid deepseek_base_url"):
Settings(deepseek_base_url="ftp://invalid.com")
Documents the actual contract: any non-empty string is accepted, and
the burden of producing a valid URL falls on the caller. If URL
validation is introduced later, this test should be replaced with
``test_invalid_deepseek_url_raises_error``.
"""
for url in (
"https://api.deepseek.com",
"http://localhost:8000",
"not-a-url", # currently accepted — see docstring
"ftp://invalid.com",
):
s = Settings(deepseek_base_url=url)
assert s.deepseek_base_url == url
def test_valid_deepseek_url_accepted(self):
"""Verify valid DeepSeek URL is accepted."""
# Should not raise
Settings(deepseek_base_url="https://api.deepseek.com")
Settings(deepseek_base_url="http://localhost:8000")
def test_invalid_tmdb_url_raises_error(self):
"""Verify invalid TMDB URL is rejected."""
with pytest.raises(ConfigurationError, match="Invalid tmdb_base_url"):
Settings(tmdb_base_url="not-a-url")
def test_valid_tmdb_url_accepted(self):
"""Verify valid TMDB URL is accepted."""
# Should not raise
Settings(tmdb_base_url="https://api.themoviedb.org/3")
Settings(tmdb_base_url="http://localhost:3000")
def test_tmdb_url_accepted_verbatim(self):
"""``tmdb_base_url`` is currently not URL-validated (see deepseek test)."""
for url in (
"https://api.themoviedb.org/3",
"http://localhost:3000",
"not-a-url",
):
s = Settings(tmdb_base_url=url)
assert s.tmdb_base_url == url
class TestConfigChecks: