35 Commits

Author SHA1 Message Date
jxxghp
cc3845621f fix(db): invalidate SQLite connections after I/O errors (#7161) 2026-10-23 19:42:31 +08:00
DDSRem
2de976f6b3 Merge pull request #7050 from DDSRem-Dev/codex-comment-migration
docs: 统一全项目中文注释和结构化契约说明
2026-10-17 19:26:29 +08:00
jxxghp
3858a82852 refactor(types): align sensitive event field lookup key types 2026-10-16 11:13:47 +08:00
jxxghp
a59c9bb94e refactor(types): govern event dispatch callback types 2026-10-16 11:12:37 +08:00
jxxghp
2e897d9fe5 refactor(types): govern event handler binding contracts 2026-10-16 11:10:46 +08:00
jxxghp
e1b6d478e6 refactor(types): govern event registry and snapshot contracts 2026-10-16 11:08:28 +08:00
jxxghp
4955b7b9ea fix: harden backend isolation and execution safety 2026-10-16 09:11:28 +08:00
freeman
f3ad81b39e style: apply safe ruff auto-fixes and exempt startup late imports
Run `ruff check app tests scripts --fix` with the configured rule set
(E4/E7/E9/F/I): import sorting (I001), f-strings without placeholders
(F541), lambda/variable/unused-import cleanups that ruff marks safe.
Nine files whose only ruff debt sits next to pre-existing pylint
import-resolution errors (lazy exports, sys.path script imports) or
whose "unused" imports are reached through attribute access by tests are
left untouched so the changed-file pylint gate and the benchmark tests
stay green; their diagnostics remain in the baseline.

app/startup/lifecycle/__init__.py and app/main.py import business
modules after cache composition, import-path and stdio setup on purpose
(the source comments document the contract), so declare E402
per-file-ignores for them instead of adding per-line noqa.

Ruff ratchet watermark drops from 498 to 100; sync the baseline fixture
and the optimization checklist figure.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-09 13:29:09 +08:00
jxxghp
1374328f84 fix(event): type module identity fallback precisely 2026-09-28 07:39:45 +08:00
jxxghp
342b570a07 fix(event): preserve handler identity after module unload 2026-09-28 07:29:48 +08:00
Aqr-K
8e4a49e958 fix(plugin): 修复分身与本体在事件定向和注册表键上的身份混淆 (#6672) 2026-09-13 21:05:26 +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
jxxghp
d32d17568a fix(runtime): apply configuration changes without restart 2026-09-11 00:12:05 +08:00
jxxghp
f9f2601144 fix(transfer): deduplicate recovery failures and system alerts 2026-09-08 14:28:40 +08:00
jxxghp
c1f50f6d3f refactor(runtime): unify paired decision flows 2026-08-29 19:58:33 +08:00
jxxghp
95606801af refactor(startup): complete provider reset contracts 2026-08-29 18:33:01 +08:00
jxxghp
aa8751f775 refactor: close transactional boundary debt batch 2026-08-28 10:36:12 +08:00
jxxghp
362f606751 feat(governance): unify durable event retention 2026-08-26 12:45:44 +08:00
jxxghp
33a367ebf9 fix(ci): stabilize event and web agent checks 2026-08-26 07:04:04 +08:00
jxxghp
3ba4027d84 feat(events): expose typed payload snapshots 2026-08-25 22:32:33 +08:00
jxxghp
46c5eec54e refactor: enforce managed event dispatch 2026-08-24 06:29:56 +08:00
jxxghp
7f09927c47 refactor: own shutdown lifecycle boundaries 2026-08-23 20:20:26 +08:00
InfinityPacer
e1d7918297 fix(runtime): 收口调度与事件异步任务生命周期 (#6415) 2026-08-23 17:17:59 +08:00
jxxghp
7bc5e01afd refactor: expand async and type safety gates 2026-08-22 13:21:52 +08:00
jxxghp
677f6a66c2 refactor: complete host module and event contracts 2026-08-22 13:21:52 +08:00
jxxghp
820f7e8850 refactor: make download and transfer events durable 2026-08-22 08:03:00 +08:00
jxxghp
c5de1c7b1b refactor: make subscription lifecycle events durable 2026-08-22 07:43:41 +08:00
jxxghp
bb0964622b fix: preserve legacy event and db dto contracts 2026-08-21 22:33:21 +08:00
jxxghp
43cccb8ff8 feat: add low-cardinality observation port 2026-08-21 22:15:47 +08:00
jxxghp
47f1ff9cb4 feat: propagate request correlation context 2026-08-21 22:08:33 +08:00
jxxghp
c0b31bddb6 refactor: register event delivery contracts 2026-08-21 21:29:52 +08:00
jxxghp
27ae1b5290 fix: 插件重载窗口期装饰器包装类方法误判直调导致 missing event TypeError
事件绑定解析在 owner_class 为 None 时仅靠限定名区分自由函数与类方法声明,
装饰器包装的方法限定名含 <locals> 被误判为自由函数 unbound 直调,把 event
吞进 self 触发 TypeError。局部作用域限定名无法区分包装方法与局部自由函数,
按调用约定兜底:签名首参为 self/cls 才视为类方法声明跳过执行。
2026-08-20 08:51:37 +08:00
jxxghp
282b922f1b fix: 修复批量插件重载窗口期残留 handler 直调导致 missing event TypeError
插件重载 stop 阶段清除 sys.modules 缓存后,若广播事件命中注册表中残留的旧类方法声明,
EventBindingResolver.owner_class 因 inspect.getmodule 返回 None 而解析失败,原实现会
直接返回原始函数并绕过实例绑定,旧签名无 event 参数时抛出 TypeError 并刷屏通知。

- binding.py:owner_class 解析失败时区分类方法声明与自由函数;类方法声明记入
  unresolved 诊断并跳过执行,等待重载完成后新 handler 按标识覆盖自愈;
  自由函数保持直调路径不变。
- 收敛 binding-miss 与新路径的未命中记账逻辑到 _record_unresolved,首次未命中才告警。
- 新增回归测试:模块卸载后残留类方法被跳过、自由函数直调不受影响。

Closes #6351
2026-08-18 21:40:13 +08:00
jxxghp
8472bcff43 refactor: 收口 V3 分层架构与插件兼容边界 2026-08-18 13:22:02 +08:00
jxxghp
5128ae9e1e refactor: 推进后端分层架构治理 2026-08-18 00:29:14 +08:00