45 Commits

Author SHA1 Message Date
jxxghp
721c03734a feat(widget): 提供受限凭据和只读快照接口 (#7175)
* feat(widget): add restricted read-only snapshot foundation

* test(widget): 补齐运行时与文档迁移契约
2026-10-25 06:02:47 +08:00
jxxghp
17a866f47b fix(transfer): restore AI takeover for failed transfers 2026-10-22 09:43:03 +08:00
jxxghp
85af231b20 feat(config): support deployment secrets without persisting values 2026-10-21 07:03:39 +08:00
DDSRem
2de976f6b3 Merge pull request #7050 from DDSRem-Dev/codex-comment-migration
docs: 统一全项目中文注释和结构化契约说明
2026-10-17 19:26:29 +08:00
jxxghp
47d51c3630 feat(agent): align history recall with Hermes SQLite FTS5 2026-09-30 16:28:39 +08:00
jxxghp
4a2ef75706 fix(music): retry transient recognition before freezing file operations 2026-09-30 06:36:04 +08:00
Aqr-K
6ea1cc9433 fix(plugin): 插件降级重装时拒绝迁移树不认识的库 revision (#6681) 2026-09-14 07:01:32 +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
Aqr-K
3d594ecee3 refactor(plugin): 插件配置改走独立通道,SystemConfig 不再按键值分支
插件配置此前借用 systemconfig 的 plugin.<实例ID> 单键,为了换表又在
SystemConfigOper 的 set/delete/load_snapshot 里按该前缀开分支。这是反向依赖:
一个对所有键一视同仁的通用键值存储被迫知道「插件」这个概念,读写路径依键值而
异,「这个键落在哪张表」只有读代码才说得清;规范方法按值加特例,也让此后任何新
键都要先确认自己会不会被拦截。

本次把插件配置整条链拆出,形状与本分支日志等级那条链一致:

- SystemConfigOper 整体回退到官方实现,与 f70d7c141 逐字节相同,对所有键一视同仁。
- 配置端口改按实例 ID 寻址:PluginStorage 新增 read_config / write_config /
  async_write_config / delete_config,PluginConfigStore 去掉 key_prefix 与 _key,
  不再有任何字符串键经过;plugin_exists 存在性规则、空键过滤与 force 语义不变。
- PluginInstanceOper 补齐读取与异步写入原语 get_config_data /
  async_save_config_data,同步与异步共用同一份落库决策,避免两条路径对「值未变化
  不写」和「建行用哪个源插件」各自分叉。
- _PluginBase 的 get_config / update_config 直连 PluginInstanceOper,方法名、签名、
  返回与 docstring 不变;self.systemconfig 保留,插件读 SystemConfigKey 枚举值仍
  然合法,插件公开面没有扩大。

插件直接用 SystemConfig 存取自身配置不予支持。它本就不是封装过的插件配置通道,
为它设计兼容或加守卫拦截,等于再把「插件」塞回通用存储里——那正是本次要拆掉的东
西。拆开后 plugin.<ID> 只是一个与插件无关的普通 systemconfig 键:迁移已经把旧的
plugin.* 行搬进插件实例表,读它拿到 None,写它会新增一条谁也不读的 systemconfig
记录,插件配置通道既不读也不写它,两边不会再有任何交叉。

代价是读取从内存快照变成一次按实例 ID 的主键查询。调用点都不在热路径上:宿主侧
只有插件启动/重载、配置表单接口与分身创建三处,插件侧 get_config() 惯例在
init_plugin 里取一次。写入侧没有变化,本来就是一次事务。

回归防线:新增用例断言 SystemConfigOper 对 plugin. 前缀没有任何特殊行为——写进去
就是一行普通 systemconfig 记录,读出来就是刚写的值,不会被路由到插件实例表。

兼容层零改动,三个 alembic 迁移一行未改。
2026-09-13 01:41:57 -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
Aqr-K
862ed4d5b8 fix(plugin): 插件 schema 不再回落 public,迁移目录拒绝相对路径
PostgreSQL 下 search_path 留了 public 兜底,插件 schema 里不存在的表名会继续
解析到宿主同名表,一条未限定的 DELETE 就能改到宿主数据;解析根收敛为插件自己的
schema,找不到的表名直接报错。

get_database_migrations() 的合同要求绝对路径,此前只校验目录是否存在,相对路径
会按宿主进程的当前工作目录解析成另一条迁移链,改为直接拒绝。
2026-09-02 02:38:18 -04:00
Aqr-K
a4d38e0f12 fix(plugin): 卸载先停后删、销毁全程持锁,PostgreSQL 会话按插件 schema 解析原生 SQL
卸载编排改为先停插件再删数据:插件的停机钩子取一次自有库句柄就能把刚删除的数据重新
建出来,注册表因此不再需要销毁墓碑,release 恢复为「只释放连接、保留数据」的单一语义。
停止同时注销插件类,其后的删除一律按 force 执行。

destroy_database 的摘句柄、关连接与删载体全部收进同一把锁:原先在锁外删除载体,并发的
get_database 能在间隙注册一个指向同一载体的新句柄,随后的删除会把它一并抹掉。

PostgreSQL 句柄在派生引擎上注册 begin 监听器,按事务执行 SET LOCAL search_path,让
schema_translate_map 覆盖不到的原生 SQL 同样解析到插件自己的 schema;监听器只挂在
OptionEngine 上,宿主引擎与其它插件的连接不受影响。
2026-09-02 02:14:19 -04:00
Aqr-K
d7c5955031 fix(plugin): 插件自有数据库释放与销毁全程容错,并修正建表去重与 schema 命名
release/destroy 统一经 _close_handle 先清线程局部会话再 dispose,两步失败都
只记日志:单个插件的连接池故障不再让 close_database 跳过宿主同步与异步引擎的
释放,release_all_databases 也逐插件隔离。按模型建表对 __table__ 去重,单表
继承的父子类一并声明时不再对同一张表建两次。

卸载编排先删插件数据、后停插件,停机钩子里的 get_database() 会把刚销毁的库
重新建出来:注册表记下已销毁的插件标识,其后的 release 改为再次销毁并清除
标记,ensure 则撤销标记,宿主编排代码不动。PostgreSQL schema 名在归一改写过
标识或超长时追加插件标识哈希并截到 63 字节,My-Plugin、My_Plugin 与
my_plugin 不再折叠到同一个 schema 而在卸载时互相 DROP。

start 的失败分支释放已经建立、却进不了运行态的句柄,整体停止把只登记在
_classes 里的插件一并释放。声明的迁移目录不存在时在建句柄之前抛
FileNotFoundError,不再留下空库;SQLite 迁移 URL 改由引擎渲染;
_get_sqlite_engine 的连接参数下沉到实际使用它的异步分支。
2026-09-02 02:14:19 -04:00
Aqr-K
626d8217ba feat(plugin): 开放插件自有数据库声明与句柄接口
_PluginBase 新增 get_database_models()/get_database_migrations() 声明钩子
与 get_database() 句柄入口,按类名(含分身)解析插件标识;
app/sdk/database.py 导出 plugin_declarative_base 与 PluginDatabaseHandle。
docs/rules/10-data-and-persistent.md 补充 Plugin-Owned Databases 小节,
说明 db_query/db_update 的自动兜底仍绑定宿主会话、需显式传入插件会话。
2026-09-02 02:14:19 -04:00
jxxghp
7a10964526 refactor(subscription): close typed persistence boundary 2026-08-28 13:56:42 +08:00
jxxghp
c656da1e28 refactor(site): close typed persistence boundary 2026-08-28 12:37:30 +08:00
jxxghp
017fecabd6 refactor(history): close transfer history boundary 2026-08-28 11:57:38 +08:00
jxxghp
aa8751f775 refactor: close transactional boundary debt batch 2026-08-28 10:36:12 +08:00
jxxghp
3bf94ffeda docs(architecture): enforce host persistence boundary 2026-08-27 05:44:33 +08:00
jxxghp
362f606751 feat(governance): unify durable event retention 2026-08-26 12:45:44 +08:00
InfinityPacer
f28e8b1538 feat(plugin): add source identity foundation (#6454) 2026-08-25 19:58:56 +08:00
jxxghp
9fede7fb2d docs: sync architecture docs with current structure 2026-08-24 12:38:38 +08:00
jxxghp
6e69258e3c refactor: make model sessions explicit 2026-08-23 23:33:07 +08:00
jxxghp
e1509c4e0d refactor: reorganize startup persistence boundaries 2026-08-23 21:24:34 +08:00
jxxghp
5e9933ca8b refactor: isolate subscribe history queries 2026-08-23 14:46:39 +08:00
jxxghp
8b955c04d6 refactor: isolate passkey queries 2026-08-23 14:37:21 +08:00
jxxghp
2120b8040a refactor: isolate pending transfer and config queries 2026-08-23 14:29:59 +08:00
jxxghp
8fc9a021b0 refactor: isolate agent history queries 2026-08-23 14:21:53 +08:00
jxxghp
d8b8583d49 refactor: isolate media server and site userdata queries 2026-08-23 14:15:37 +08:00
jxxghp
be1071b6cd refactor: isolate workflow queries 2026-08-23 14:06:14 +08:00
jxxghp
4074fa4e42 refactor: isolate transfer and download history queries 2026-08-23 13:59:12 +08:00
jxxghp
f1e542bef0 refactor: govern background tasks and query ownership 2026-08-23 13:24:04 +08:00
jxxghp
4d1be26a31 docs: close debt governance status 2026-08-23 04:01:02 +08:00
jxxghp
1c457143f7 test: refresh architecture debt baselines 2026-08-23 01:02:00 +08:00
jxxghp
2031f3c420 refactor: migrate agent task query ownership 2026-08-23 00:37:03 +08:00
jxxghp
be18cace1f refactor: finish transactional runtime migration 2026-08-22 15:18:16 +08:00
jxxghp
e61b5168ad refactor: move workflow execution writes to uow 2026-08-22 13:21:52 +08:00
jxxghp
b598b516d5 refactor: migrate high-risk write transactions 2026-08-21 20:46:57 +08:00
jxxghp
7de72e0e83 refactor: own subscription create transactions 2026-08-21 20:37:31 +08:00
jxxghp
de2957b9de refactor: add transaction ownership ratchet 2026-08-21 20:16:30 +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
DDSRem
784672af5c docs: restructure AGENTS.md and add docs/rules agent documentation system (#5830) 2026-05-25 13:48:43 +08:00