Commit Graph

132 Commits

Author SHA1 Message Date
jxxghp
ebddeee23b feat(subscribe): accumulate music album track progress 2026-09-14 19:35:04 +08:00
Aqr-K
d44480d739 Merge pull request #6666 from Aqr-K/feat/plugin-instance-target-enablement
feat(plugin): 插件实例默认调用目标与启停,未指定实例时不再兜底取第一个
2026-09-13 16:37:27 +08:00
jxxghp
c60949ffff Merge branch 'v3' into feat/plugin-instance-config-logging 2026-09-13 14:30:42 +08:00
jxxghp
8072b7d78f Refactor application architecture and compatibility boundaries 2026-09-13 12:53:00 +08:00
Aqr-K
e47d7defe7 feat(plugin): 插件本体与分身可各自设置独立日志等级
全局日志等级是一个开关,调试单个插件时只能整体下调。一旦下调,被调试插件那几行
日志会淹没在其他几十个插件与宿主自身的 DEBUG 输出里,找不出来;不下调又什么都
看不见。插件实例数量只会继续增长,这个矛盾不会自己消失。

因此把等级下放到实例:plugininstance 行加 log_level / log_expires_at 两列,本体与
分身共用同一张表、同一套语义。等级落在实例自己那一行而不是另起一张按实例 ID 索引
的表——它和业务参数一样是用户按实例设置的东西,同一个生命周期,实例被删时应当随行
一起消失。清除覆盖后若本体行只剩一对身份列,整行按 carries_only_identity 回收,与
清空业务参数同一规则。

覆盖带失效时间,因为它是调试设置不是长期配置:开了 DEBUG 忘记关,下次谁也想不起
某个插件为什么一直在刷日志。过期判定在读取时惰性执行并就地清理,不另起后台线程去
扫一张最多几十条的表。expires_at 在写入侧先归一到 UTC 再分发给缓存与落盘两处:客户端
提交的时间可能不带时区,两处各按进程时区折算一次,就会与读取口返回的 UTC 值差出一个
时区,表现为「提交的失效时刻和读回来的对不上」。

运行期用 ContextVar 在宿主自己控制的四类调用点绑定当前实例——构造与 init_plugin、
事件处理器、定时服务回调、插件声明的 HTTP 端点——而不是沿用 logger() 已有的栈帧内省。
内省认的是栈顶的模块与类,插件通过宿主公共方法转发调用时栈顶是宿主而不是发起调用的
插件,会把日志记到错误的来源上;分身更甚:分身共享源码,类的 __qualname__ 保持源类名
不变,内省根本分不出是哪一个分身在打日志。内省结果继续只用于文件路由,不参与等级判定。

等级过滤必须排在全局等级判定之前。官方现状是先按全局等级短路、之后才做内省,先短路
就会把实例调低的等级挡在门外,后面再怎么识别来源都看不到这条日志。

回调在注册时被捕获、稍后才由调度器或 FastAPI 调用,那时已经不在任何绑定作用域内,
故这两处改用 wrap_for_plugin_instance 把绑定包进回调自身;同一实例重复包装直接返回
原对象,避免插件缓存声明时包装链随重载次数无限增长。

进程内覆盖表按实例 ID 常驻,删分身时必须一并清掉:只删库里那一行的话,同一进程内用
相同后缀重建的分身会继承上一个分身的等级,界面显示「跟随全局」而实际仍按旧等级输出。
进程重启后反向从库预热缓存。

迁移链在 F1 之后追加:c4e1a7b9d2f6(3.0.35)-> 487f7e681955(3.0.36 加两列)。

顺带补了 agent 策略里缺失的 media.classification.policy.get 的 template 字段说明:
少了它,api_mcp_schema.json 与技能文档的两个生成脚本都跑不起来。
2026-09-12 19:05:05 -04:00
Aqr-K
4dbb8b8204 feat(plugin): 插件配置与实例描述符迁入独立表
插件配置此前寄存在 systemconfig 的 plugin.<实例ID> 单键下,实例描述符则整份挤在
PluginInstances 这一个 JSON 键里,两者都不成立:

- plugin.<ID> 是裸字符串 key,而仓库规则本身禁止用裸字符串做 SystemConfig key,
  只允许先定义 SystemConfigKey 枚举项;插件 ID 由用户安装决定,永远枚举不出常量。
  条目数随安装量增长,混在系统设置表里会把主程序自己的设置项淹掉。
- 那个键存的其实是实例 ID,表里没有任何一列说得出它属于哪个插件,想列出某个插件
  的全部实例配置只能靠字符串前缀去猜。
- 实例描述符整份读出再整份写回,改一个分身要重写全部分身。

改为 plugininstance 一实例一行:instance_id 与 source_plugin_id 构成身份,本体与
分身由两者是否相等派生而不设模式列——模式列会是这个等式的冗余副本,两者一旦失步
同一行就会在不同读取口被判成不同角色。展示信息与业务参数同存一行,属于同一个
生命周期,分表只会让建分身、删分身退化成两张表之间的协调问题。

读写路由落在 SystemConfigOper.get/set/delete,而不是在各个调用方各改一处:第三方
插件可能直接用 self.systemconfig.get("plugin.xxx") 读写自己的配置,只改
PluginConfigStore 与 _PluginBase.get_config/update_config 必然漏掉它们。路由只做
前缀识别,插入、更新与空本体行回收都委托 PluginInstanceOper,不在配置层重抄一遍。

PluginInstances 旧键迁移后不删,留作回滚依据,并以
SystemConfigKey.PluginInstancesImported 标志防止重复导入;判据不能是「表当前为空」,
否则用户把分身全部删光后,下次启动会把它们整批导回来。

迁移链:b2d4f6a8c1e3 -> 281965691a20(3.0.34 建表并搬描述符)
-> c4e1a7b9d2f6(3.0.35 加 config_data 并搬 plugin.* 配置)。

依赖基线与启动模块数随两个新模块重算,架构文档与数据库技能表目录同步登记新表。
2026-09-12 17:39:36 -04:00
jxxghp
5fa5b414aa feat(agent): harden tool outcomes, recovery and discovery 2026-09-09 19:55:21 +08:00
jxxghp
ce690b1140 feat(transfer): add failure stage, recovery action, retry count, and cleanup status to transfer history 2026-09-09 13:17:36 +08:00
jxxghp
8255df4df4 fix(subscribe): remove cumulative search delays and resume pending sites 2026-09-08 08:58:35 +08:00
jxxghp
b85aa5e31b feat(subscription): add search_interval and last_search fields for subscription management 2026-09-08 07:12:21 +08:00
jxxghp
744980dbd2 fix(classification): repair legacy slash category paths 2026-09-04 18:50:24 +08:00
jxxghp
71147c1d96 feat(classification): support multi-source media rules 2026-09-03 11:51:18 +08:00
InfinityPacer
68880dbbf1 优化订阅执行治理与规模性能 (#6557)
* feat(subscription): govern concurrent search and match execution

* refactor(subscription): consume complete candidate snapshots

* refactor(subscription): remove download submission ledger

* feat(subscription): stagger fallback searches without site gaps

* refactor(subscription): remove unused retry capability

* test(subscription): verify complete scale execution

* fix(subscription): surface site search failures

* test(subscription): verify site pressure through search

* test(subscription): use static facade imports

* fix(subscription): preserve completed downloads on shutdown

* fix(subscription): classify execution expiry as failure

* fix(subscription): preserve fallback search staggering

* test(subscription): stabilize unfinished wrapper gate

* fix(subscription): settle expired search returns

* style(subscription): normalize governance imports

* fix(subscription): align governance type contracts

* docs(architecture): sync mypy debt metric

* docs(architecture): sync startup module counts
2026-09-03 11:26:24 +08:00
jxxghp
e4c8cbabfb refactor(subscribe): deduplicate duplicate media records 2026-09-01 17:09:55 +08:00
jxxghp
a712284dc4 feat(subscribe): expose governed execution status 2026-09-01 17:09:54 +08:00
jxxghp
db5c316756 refactor(subscribe): make download submission idempotent 2026-09-01 17:09:54 +08:00
jxxghp
bab1d2862e refactor(subscribe): govern fallback site pressure 2026-09-01 17:09:54 +08:00
jxxghp
389131acd6 refactor(subscribe): persist fallback search queue 2026-09-01 17:08:53 +08:00
jxxghp
8e8ebcdff9 fix(transfer): repair migration and failed recovery 2026-09-01 13:31:52 +08:00
jxxghp
9146c75941 feat(auth): add first-run administrator initialization 2026-08-30 09:05:23 +08:00
jxxghp
387fd953df fix(migrations): follow torrent capability owner 2026-08-29 21:39:36 +08:00
jxxghp
aa8751f775 refactor: close transactional boundary debt batch 2026-08-28 10:36:12 +08:00
jxxghp
e9de149dbf refactor(transfer): complete durable recovery state machine 2026-08-28 00:03:36 +08:00
jxxghp
e82ce8447c refactor: complete durable transfer execution settlement 2026-08-27 20:27:42 +08:00
jxxghp
a62c541ec0 refactor: add fenced transfer recovery leases 2026-08-27 14:39:38 +08:00
jxxghp
23bff6b2bb refactor: add durable transfer planning checkpoints 2026-08-27 13:16:33 +08:00
jxxghp
aac184a1b9 refactor(transfer): make queue admission durable 2026-08-27 10:57:22 +08:00
InfinityPacer
ac2a2b1129 feat(plugin): persist declared metadata snapshots (#6467) 2026-08-26 13:15:12 +08:00
jxxghp
362f606751 feat(governance): unify durable event retention 2026-08-26 12:45:44 +08:00
InfinityPacer
71db425c07 feat(plugin): 建立可信来源准入与安装恢复 (#6462) 2026-08-26 07:52:00 +08:00
InfinityPacer
f28e8b1538 feat(plugin): add source identity foundation (#6454) 2026-08-25 19:58:56 +08:00
jxxghp
e1509c4e0d refactor: reorganize startup persistence boundaries 2026-08-23 21:24:34 +08:00
InfinityPacer
176d9255e5 fix(database): keep migrations in alembic transactions (#6400) 2026-08-23 00:27:55 +08:00
jxxghp
dce7372b81 feat: persist subscription side-effect outbox 2026-08-21 21:50:18 +08:00
jxxghp
8472bcff43 refactor: 收口 V3 分层架构与插件兼容边界 2026-08-18 13:22:02 +08:00
jxxghp
77b7960b7d fix(subscribe): 修复历史 note 双重 JSON 编码导致的订阅列表 500
2.0 时代旧代码对 JSON 列显式 json.dumps,导致 note 字段在库里是
字符串而非数组,响应模型按 List[int] 校验失败返回 500。

- 新增 3.0.7 数据迁移,解析并回写字符串型 note 为真正的 JSON 数组
- Subscribe 响应模型增加 note 字符串兼容解析,脏数据按空值处理
2026-08-17 10:56:31 +08:00
Aqr-K
8a11214a43 refactor(db): 修复异步连接池无界增长,并完成 SQLAlchemy 2.0 迁移与分层归位 (#6320) 2026-08-15 06:58:38 +08:00
jxxghp
369d7d6448 refactor: reorganize backend module boundaries 2026-08-14 19:53:33 +08:00
jxxghp
7b3444c366 refactor backend module architecture 2026-08-14 15:45:38 +08:00
InfinityPacer
57e7f86f38 feat(agent): record task run history (#6305) 2026-08-13 22:13:36 +08:00
jxxghp
d0e06e4b85 chore(database): align v3 migration filenames 2026-08-13 13:47:37 +08:00
jxxghp
b4863a6550 feat(media): support extensible media sources 2026-08-13 13:26:17 +08:00
Aqr-K
a2e70b443d fix(monitor,transfer): 修复 FUSE 挂载无响应导致的监控冻死、整理链锁死与漏件 (#6276)
* wip(v3): 移植监控与整理韧性修复到 v3 基线

包含:监控看门狗隔离/挂载探测、整理队列持久化、文件系统子进程代理、
写入原子化。迁移重挂到 v3 链 8a4c7e1d2f90 -> 7f5c1d2e3a4b -> e3d9f4b7c806。
tmdb 相关测试尚未通过,待定位。

* fix(v3): 修正移植引入的 16 项测试失败

- poller.py:合并时我方保留的行仍用旧变量名 merged_snapshot,而 v3 已统一
  改名为 current_snapshot,导致 NameError 被外层 except 吞掉、快照从未保存
- smb.py:采纳 f-string 拆分写法,恢复 Python 3.11 可解析
- dispatcher 测试:历史查重由 _should_skip_by_history 统一承担,mock 点随之调整
- tmdb 缓存测试:补充 v3 新增的 media_source/media_id 字段
- tmdb 重试测试:为 fake 补充 match_multi/async_match_multi

尚余 3 项与 v3 识别流程的连接失败处理有关,待单独判断。

* fix(v3): 测试适配 v3 的 media_source/media_id 重构

v3 将媒体标识从 tmdbid 统一重构为 media_source + media_id,recognize_media
的 tmdbid 参数已被 **kwargs 静默吞掉——传了也不生效,流程会误降级到名称搜索。
tmdb 重试用例改用新参数后恢复正确路径。

同时修正 fake 的 match_multi 语义:真实实现(tmdbapi.match_multi)吞掉所有
异常并返回 None,连接失败与「未找到」在该路径上本就不可区分,fake 需保持一致。

至此移植引入的 19 项失败全部清零。

---------

Co-authored-by: Aqr-K <Aqr-K@users.noreply.github.com>
2026-08-13 08:19:54 +08:00
InfinityPacer
46c2a856c4 fix(database): harden fresh migration chain compatibility (#6278) 2026-08-12 21:29:08 +08:00
jxxghp
ca32922a7f refactor(media): unify media identity and chain responsibilities 2026-08-12 18:31:09 +08:00
jxxghp
8bf2f601a6 refactor(media): unify source identity and music browsing 2026-08-12 12:56:40 +08:00
jxxghp
97dba2a8ae feat: unify media recognition and music lifecycle 2026-08-12 06:51:58 +08:00
jxxghp
ddc45a10c0 feat(v3): 覆盖用户通知模板前先输出日志备份 2026-08-10 23:08:40 +08:00
jxxghp
d72ed5ed8e feat(v3): move notification templates into DB migration and support music notifications 2026-08-10 13:23:20 +08:00
jxxghp
75e56d8e9a feat(music): add audio quality workflow 2026-08-10 10:23:02 +08:00