refactor(chain): 处理链功能域 mixin 化,清理未使用导入并根治兼容层循环导入

- ChainBase 拆分为 RecognitionMixin/MessageProcessingMixin/NotificationMixin
- TransferChain 拆分为 7 个功能 mixin(_mixins.py),SubscribeChain 音乐订阅域拆出 _music.py
- 斜杠命令交互四件套收敛为 InteractionChainMixin 委托,会话管理器移至 application 层,chain 层不再 re-export
- 模块基础类收敛到 app/modules/_base(notification/mediaserver 语义重命名)
- 清理 app/chain/__init__.py 24 个未使用导入,修正 49 处测试 patch 目标到实际命名空间
- 兼容层 legacy 符号不再并入 __all__,根治 schemas 初始化反向拉起 application.transfer 的循环导入
- 修复 bangumi 集数为字符串时 set_bangumi_info 抛 TypeError
- 新增重复代码等架构门禁测试;capability 清单校验排除下划线内部目录
This commit is contained in:
jxxghp
2026-08-16 16:30:16 +08:00
parent 24671f8f18
commit 7e851dbfa7
102 changed files with 6041 additions and 5888 deletions
+7 -4
View File
@@ -68,6 +68,7 @@ def test_music_retry_restores_history_entity_namespace(tmp_path, monkeypatch):
title="叶惠美",
)
monkeypatch.setattr("app.chain.transfer.MediaChain", lambda: media_chain)
monkeypatch.setattr("app.chain._mixins.MediaChain", lambda: media_chain)
result = TransferChain()._recognize_music_retry_media(
history,
@@ -188,8 +189,8 @@ def test_music_scrape_batch_event_preserves_each_track_context():
)
tasks.append(task)
target_paths.append(target_path)
chain._TransferChain__register_scrape_batch_task(task)
chain._TransferChain__record_scrape_target(
chain._register_scrape_batch_task(task)
chain._record_scrape_target(
task,
TransferInfo(
success=True,
@@ -199,9 +200,9 @@ def test_music_scrape_batch_event_preserves_each_track_context():
),
)
chain._TransferChain__close_scrape_batch(batch_id)
chain._close_scrape_batch(batch_id)
for task in tasks:
chain._TransferChain__finish_scrape_batch_task(task)
chain._finish_scrape_batch_task(task)
scrape_calls = [
call
@@ -537,6 +538,7 @@ def test_success_file_aggregation_is_isolated_between_music_jobs_in_same_directo
"app.chain.transfer.TransferHistoryOper",
lambda: SimpleNamespace(),
)
monkeypatch.setattr("app.chain._mixins.TransferHistoryOper", lambda: SimpleNamespace())
monkeypatch.setattr(
"app.chain.transfer.add_transfer_success",
lambda **kwargs: SimpleNamespace(id=1),
@@ -782,6 +784,7 @@ def test_downloader_process_forwards_music_history_type(tmp_path, monkeypatch):
),
)
monkeypatch.setattr("app.chain.transfer.MediaChain", lambda: media_chain)
monkeypatch.setattr("app.chain._mixins.MediaChain", lambda: media_chain)
monkeypatch.setattr(chain, "do_transfer", Mock(return_value=(True, "")))
monkeypatch.setattr(chain, "run_module", run_module)