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:
+22
-5
@@ -1,4 +1,21 @@
|
||||
"""Tests for the Agent."""
|
||||
"""Tests for ``alfred.agent.agent.Agent`` — the LLM orchestration layer.
|
||||
|
||||
Covers the public agent surface used by the FastAPI handlers:
|
||||
|
||||
- **Construction** — ``Agent(settings, llm, max_tool_iterations)`` wires the
|
||||
prompt builder, the tool registry, and the in-memory tool catalogue.
|
||||
- **Tool execution** — ``_execute_tool_call`` parses an OpenAI-shaped
|
||||
tool-call dict, validates the tool exists and is in scope for the current
|
||||
workflow, executes it, and surfaces errors as structured dicts.
|
||||
- **Step loop** — ``step(user_input)`` records the user message, builds the
|
||||
system prompt, runs the LLM/tool loop up to ``max_tool_iterations``, and
|
||||
returns the final assistant text.
|
||||
|
||||
These tests use the current component-based LTM API
|
||||
(``memory.ltm.workspace.download``, ``memory.ltm.library_paths.set(...)``).
|
||||
The legacy flat attributes (``download_folder``, ``movie_folder``, …) no
|
||||
longer exist.
|
||||
"""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
@@ -49,7 +66,7 @@ class TestExecuteToolCall:
|
||||
def test_execute_known_tool(self, memory, mock_settings, mock_llm, real_folder):
|
||||
"""Should execute known tool."""
|
||||
agent = Agent(settings=mock_settings, llm=mock_llm)
|
||||
memory.ltm.download_folder = str(real_folder["downloads"])
|
||||
memory.ltm.workspace.download = str(real_folder["downloads"])
|
||||
|
||||
tool_call = {
|
||||
"id": "call_123",
|
||||
@@ -145,7 +162,7 @@ class TestStep:
|
||||
self, memory, mock_settings, mock_llm_with_tool_call, real_folder
|
||||
):
|
||||
"""Should execute tool and continue."""
|
||||
memory.ltm.download_folder = str(real_folder["downloads"])
|
||||
memory.ltm.workspace.download = str(real_folder["downloads"])
|
||||
|
||||
agent = Agent(settings=mock_settings, llm=mock_llm_with_tool_call)
|
||||
|
||||
@@ -229,8 +246,8 @@ class TestAgentIntegration:
|
||||
|
||||
def test_multiple_tool_calls(self, memory, mock_settings, mock_llm, real_folder):
|
||||
"""Should handle multiple tool calls in sequence."""
|
||||
memory.ltm.download_folder = str(real_folder["downloads"])
|
||||
memory.ltm.movie_folder = str(real_folder["movies"])
|
||||
memory.ltm.workspace.download = str(real_folder["downloads"])
|
||||
memory.ltm.library_paths.set("movies", str(real_folder["movies"]))
|
||||
|
||||
call_count = [0]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user