Skip to content

feat(transfer): 添加分类与目录路由预览 - #6317

Draft
bgColorGray wants to merge 2 commits into
jxxghp:v3from
bgColorGray:codex/category-route-preview
Draft

feat(transfer): 添加分类与目录路由预览#6317
bgColorGray wants to merge 2 commits into
jxxghp:v3from
bgColorGray:codex/category-route-preview

Conversation

@bgColorGray

@bgColorGray bgColorGray commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

关联

变更

  • 抽取分类规则与目录候选的统一求值结果,输出命中条件、排除原因和非阻断警告。
  • 新增 DirectoryMatchMode:默认 sequential 完全保留现有顺序语义,用户可显式启用 specificity,按精确类别、媒体类型、通配目录选择候选。
  • 让下载保存目录与最终媒体库目录复用同一候选选择逻辑,并保留存储、源路径、目标路径、同盘等现有硬约束。
  • 新增 DirectoryRouteChain,集中编排目录设置、分类诊断与路由预览,避免继续扩张 TransferChain
  • 新增 GET/POST /api/v1/transfer/route/settings,在同一数据库事务中保存目录和匹配模式,并从同一缓存快照读取。
  • 新增 POST /api/v1/transfer/route/preview,仅对传入的媒体与元数据快照求值,不访问 TMDB、不创建目录、不移动文件。
  • 增加分类冲突、不可达兜底、通用目录抢先、未知类别、重复条件和无匹配目录等诊断。
  • 补充 API/MCP 文档以及路由、配置原子性和并发回归测试。

兼容性

  • 默认模式始终为 sequential,旧配置无需迁移,升级后不会静默改变整理路径。
  • 分类规则继续保持第一条命中获胜,不按条件数量自动重排。
  • media=None、显式目标路径和现有目录优先级保持原行为。
  • SystemConfig 仍使用键值存储,不涉及数据库模型或 Alembic 迁移。

验证

  • 路由、配置竞态、API 鉴权与架构相关测试:46 passed。
  • 全量测试:4036 passed,3 skipped;4 个失败已在当前 upstream/v3@7b3444c3 基线确认:BluRayTest.testtest_manifest_aliases_reuse_real_canonical_modulestest_main_script_does_not_shadow_stdlib_platformtest_workflow_manager_list_actions_exposes_contract
  • 变更模块 pylint:10.00/10。
  • 严格可维护性复审:APPROVED。
  • git diff --check 与敏感信息扫描通过。

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR-Agent Code Review

该 PR 新增分类与目录路由预览接口,并统一分类诊断及顺序、精确度两种目录候选选择逻辑。当前存在一个会阻断后端模块加载的高严重度问题,另有一个特定空值规则下的诊断遗漏,需修正后再合入。

审查提交:d611286

Comment thread app/schemas/transfer.py
class TransferRouteMediaSnapshot(BaseModel):
"""路由预览使用的已识别媒体快照。"""

type: MediaType

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

导入失败

新增请求模型在类定义时直接引用 MediaType,但该模块没有导入或定义此名称;首次导入 app.schemas.transfer 时,例如服务启动注册 API schema 或运行新增测试,会立即抛出 NameError,导致后端无法启动,违反 schema 模块必须可导入且端点能够注册的基本契约。修正范围仅需覆盖该新增注解的名称解析。

)
continue

conditions = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

兜底漏报

当规则映射非空但所有条件值均为空时,例如 genre_ids: "",条件列表为空且 all([]) 会使该规则成为无条件命中,但它没有被记录到 fallback_indices。这类规则位于中间时不会产生 unconditional_category_not_last 警告,违反预览需要诊断不可达兜底规则的契约;修正范围应限定为按有效条件是否为空识别无条件规则。

pengyujie added 2 commits August 14, 2026 17:52
默认保持顺序匹配,支持显式启用精确类别优先。\n新增本地快照预览、冲突诊断、模式对比及完整回归测试。\n\nRefs: jxxghp#6313
@bgColorGray
bgColorGray force-pushed the codex/category-route-preview branch from d611286 to 3ce4a4f Compare August 14, 2026 11:00
@bgColorGray

Copy link
Copy Markdown
Contributor Author

已完成上一轮审查后的重构与回归:

  • 将设置、分类诊断和预览编排从 TransferChain 抽到 DirectoryRouteChain
  • 目录与匹配模式改为同一事务保存、同一缓存快照读取,并补确定性并发测试。
  • 修复 SystemConfigOper.set 对内置 set 类型注解的遮蔽,已验证模块可正常导入。
  • 路由、配置竞态、API 鉴权与架构相关测试 46 passed;变更模块 pylint 10.00/10。
  • 独立严格可维护性复审结果:APPROVED

本次自动 PR-Agent 工作流的红灯发生在 LLM 推理前后,三个回退模型均返回 429 WEEKLY_LIMIT_EXCEEDED,因此没有生成新的代码审查 finding;这不是测试或代码执行失败。

@bgColorGray
bgColorGray marked this pull request as draft August 14, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant