Skip to content

feat: 数据库层方言可插拔(SQLite → 高斯/MySQL/达梦易扩展) - #39

Open
tianling536 wants to merge 357 commits into
OpenBMB:mainfrom
tianling536:feat/multi-db-clean
Open

tianling536 wants to merge 357 commits into
OpenBMB:mainfrom
tianling536:feat/multi-db-clean

Conversation

@tianling536

@tianling536 tianling536 commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

概述

将数据库层从「SQLite 实现」升级为方言可插拔:默认走 ORM/标准 SQL(所有数据库通用),无法通用的少数点收口到方言提供者接口。新增一种数据库 = 注册一个小适配器(锁/日期/能力声明),业务代码零改动。

支持矩阵:SQLite(默认,行为逐字保留)、PostgreSQL(实验性)、openGauss/高斯(实验性,已在 5.0 真机验证)、MySQL 8.x(实验性,已在 8.4 真机验证)、达梦(适配器骨架,需外部 SQLAlchemy 方言插件)。

2026-11-06 更新:已合并官方最新 main(fcc28c00,含 10/21 OSS 重构后的新架构)并重新移植全部特性;本分支与 main 无冲突。随后在同一分支落地 PR 登记项:MySQL/达梦方言适配器、Alembic 迁移通路、openGauss 真机验证。

设计

新模块 backend/app/db/dialect.py

  • DatabaseDialect 协议:engine_kwargs、day_bucket、JSON 配置读改写、acquire/release/check_advisory_lock、supports_partial_index / session_scoped_advisory_lock 能力声明;
  • 注册表:sqlite → SQLiteDialect、postgresql → PostgresDialect、opengauss → OpenGaussDialect、mysql → MySQLDialect、dm → DMDialect,未知名 → GenericDialect(ORM 通用实现兜底);
  • 默认实现即通用实现,但安全语义不降级:文件锁仅对 SQLite 文件库有效,其它后端无原生锁实现时响亮拒绝;部分唯一索引只在支持方后端创建,其它后端由 init_db 启动校验兜底。

SQLAlchemy 侧:app/db/opengauss.py 为 openGauss 注册 opengauss+psycopg:// 兼容方言(处理 openGauss 的 version() 版本串解析与 SQL_ASCII 初始化库的 client_encoding=utf8)。

改造点

  1. 引擎创建走 get_dialect(backend).engine_kwargs(url)(SQLite 行为不变);PG/openGauss 可选依赖 [postgres]、MySQL [mysql]、达梦 [dm],缺失时启动即给安装指引;PG/MySQL 池参数补齐。
  2. 收编方言 SQL:channels/config_store.py 在 sqlite/PG 用原子 JSON 更新,其它后端(含 openGauss,其 jsonb_set 参数语义与上游 PG 不同)提供 ORM 读-改-写 + SELECT ... FOR UPDATE + revision CAS 通用回退;知识库 CAST AS BLOB 仅 SQLite 保留;投递日志日分桶走方言助手(PG/openGauss 支持 APP_TIMEZONE)。
  3. 索引/可移植列:sessions 唯一索引并入 models;默认模型部分唯一索引按方言 DDL 事件创建(MySQL/达梦不退化);JSON 列统一 PortableJSON(达梦/Oracle 降级 CLOB),长文本列显式 Text;MySQL utf8mb4 下 7 个超 3072B 唯一索引与 JSON server_default 已修复,头像恢复 MEDIUMTEXT。
  4. 锁:渠道 connector 单实例锁与飞书 binding 锁方言化——PG/openGauss=会话级 advisory lock(专属 AUTOCOMMIT 连接 + 15s 存活看门狗),MySQL=GET_LOCK 命名锁,SQLite=文件锁;锁身份统一为数据库作用域 + key。
  5. Alembic 迁移通路:基线 revision 覆盖 75 表/425 索引(按方言补部分唯一索引),位于 backend/app/db/migrations/(随 wheel/PyInstaller 分发);init_db 对非 SQLite:全新库 create_all + stamp 基线、存量表无版本表 stamp + 告警、有版本表 upgrade head。SQLite 保持 create_all + 内置迁移路径不变。
  6. 依赖/文档/CI:新增 alembic 主依赖与 [postgres]/[mysql]/[dm] extras;README 增加 Database Backends 与迁移章节;新增 scripts/smoke_postgres.sh;gaussdb-smoke.yml 使用官方 openGauss 镜像 + opengauss+psycopg 并断言方言能力(维护者可 dispatch)。

验证

  • SQLite 零回归:全量 pytest backend/tests = 2612 passed / 99 failed / 1 skipped;99 个失败经干净 origin/main 基线对比确认全部是 main 既有测试债(失败集合与基线完全一致),本 PR 零回归。改动文件 ruff 全绿。
  • 真实 PostgreSQL 18(Docker):create_all/Alembic bootstrap、方言 DDL 索引、JSONB 配置补丁、APP_TIMEZONE 日分桶、知识库 ORM、PortableJSON、advisory lock 并发闭环全部通过。
  • 真实 MySQL 8.4(Docker):全新库 init_db(76 表 + alembic_version)、列类型(MEDIUMTEXT/JSON)、默认模型启动校验、config 补丁通用回退、日分桶、知识库、GET_LOCK 跨进程竞争/断连检测、渠道 connector 锁全部通过;Alembic fresh/stamp/upgrade 幂等通过。
  • 真实 openGauss 5.0(Docker aarch64):init_db(76 表 + 部分唯一索引 + sessions 唯一索引 + alembic_version)、二次启动幂等、纯 alembic upgrade head、存量表 stamp、PortableJSON、config 补丁(自动走通用回退)、日分桶、知识库(中文)、advisory lock(hashtext + pg_locks)、渠道 connector 锁全部通过。
  • 完整应用端到端启动验证(2026-11-09 补):本机构建 Harness v3(DeepSeek Harness,python3 prepare.py --no-cli-link 产出 harness-engine/apps/cli/lib/bin.js)后,SQLite / PostgreSQL 18 / openGauss 5.0 / MySQL 8.4 四种数据库均完成完整应用启动 + HTTP API 端到端冒烟(uvicorn 完整启动 Harness v3 运行时与渠道服务;每种库 10/10 API 检查 + 10~11/11 DB 产物检查),覆盖登录/员工/渠道绑定、config 补丁、日分桶、知识库、PortableJSON 与 Alembic 产物;详见下方验证评论。
  • CI:CodeQL / verify / linux / windows / macos-arm64 构建通过。

当前限制

  • 迁移:SQLite 仍走内置迁移;非 SQLite 首次接入按基线 stamp,已有旧库若 schema 与当前版本不一致需人工核对;多 worker 同时首启非 SQLite 库无分布式迁移锁(当前启动形态为单进程)。
  • APP_TIMEZONE 仅对 PostgreSQL/openGauss 日分桶生效;SQLite 恒为服务器本地时区(配置了会告警)。
  • 每个数据库只允许一个 connector 进程(会话级 advisory lock / MySQL 命名锁 + 存活校验)。
  • MySQL/达梦无部分唯一索引,"每租户至多一条默认模型"由代码层 + 启动校验兜底。
  • 达梦仅适配器骨架:需外部 SQLAlchemy 达梦方言插件 + dmPython,未真机验证;MySQL 仅验证 8.4(MariaDB/5.7/9.x 未测);openGauss 验证 5.0,其他版本/认证模式(sha256)需部署方按需配置(冒烟 workflow 用 trust 仅测试容器)。

后续(登记项)

  • 达梦真机验证 / 第三方方言插件版本适配;
  • MariaDB 与 MySQL 5.7/9.x 验证;
  • 多 worker 首启的迁移/授权锁;
  • 存量 SQLite 数据向 PG/openGauss/MySQL 搬迁的一次性导数。

fadeoreo and others added 26 commits July 22, 2026 15:59
- add protocol drivers for Anthropic Messages and Gemini Generate Content
- centralize runtime model resolution and verification fingerprints
- migrate existing SQLite model configs without disrupting trusted Chat models
- add atomic initial model activation and preserve explicit disabled/default states
- expose all implemented protocols without deployment feature flags
- add per-model test loading, duplicate-request protection, and stale-result handling
- cover protocol contracts, migrations, concurrency, and LLM Center regressions
- add typed execution_policy.timeout_seconds configuration
- use per-tool timeouts for HTTP, MCP, and saved tool tests
- preserve the global timeout fallback for unconfigured tools
- retain execution policies during MCP sync and legacy updates
- configure a 20-second timeout for contract archive queries
- avoid automatic retries to prevent duplicate side effects
- prevent models from bypassing explicit knowledge_query nodes
- preserve clarification while blocking premature advancement
- build safe queries from allowlisted business fields
- skip general skill preselection on knowledge nodes
- execute knowledge queries in follow-up and reflection paths
- reuse evidence on repeated entry within the same turn
- record forced-query and query-failure events
* chore(deps): configure automated dependency updates

* chore(deps): document automated update configuration

Add a concise header comment and trigger CodeQL for the existing pull request.

* docs: add license
* fix(dev): remove hardcoded internal IPs from dev config

* fix(dev): use loadEnv() for Vite proxy config and correct default port
- prevent continue_active routing from regressing the active SOP step
- persist and consume awaiting-input state for explicit user questions
- isolate awaiting-input context across task switches
- recover sessions when published SOP nodes are removed or renamed
- preserve active task identity during confirmation and step recovery
- add regression coverage for confirmation loops and invalid transitions

Tests: 589 passed
…gth limit (OpenBMB#29)

* fix(llm): retry with doubled max_tokens when reasoning models hit length limit

Reasoning models such as deepseek-v4-flash (the new deepseek-chat) and
deepseek-reasoner share the max_tokens budget between reasoning_content
and content. When the thinking phase exhausts the budget before the
answer is produced, the provider returns finish_reason=length with an
empty content field, which StaffDeck treated as an empty response and
retried with the same fixed budget -- guaranteeing failure across all
EMPTY_RESPONSE_RETRIES attempts.

Track a mutable current_max_tokens per call. On each retry, if the
previous attempt was truncated by length AND produced reasoning output,
double the budget (capped at 32768) so the model has room to finish
reasoning and emit content. Applied symmetrically to generate_text
(non-stream) and generate_text_stream.

Verified end-to-end with deepseek-v4-flash: a greeting turn and a SOP
turn (seal_application_approval -> evaluate_compliance) both return
fluent content after the budget escalation.

* fix(llm): preserve token budget above escalation ceiling + add regression tests

Address review feedback on OpenBMB#29: when a model configuration already
requests max_output_tokens above the 32768 escalation ceiling, the
previous min(current*2, 32768) shrunk the retry budget instead of
preserving or increasing it (e.g. [65536, 32768, 32768]).

Extract REASONING_TOKEN_ESCALATION_CEILING and _escalate_reasoning_token_budget()
helper: double the budget up to the ceiling, but keep the configured value
unchanged once it is at or above the ceiling. Applied to both
generate_text and generate_text_stream.

Add four regression tests covering the matrix:
- generate_text: normal escalation (4096 -> 8192)
- generate_text: budget above ceiling preserved (65536 -> 65536)
- generate_text_stream: normal escalation (4096 -> 8192)
- generate_text_stream: budget above ceiling preserved (65536 -> 65536)

Full backend suite passes (590 tests).
* feat: 多渠道接入(微信/企业微信)与智能分发

- 渠道内核:绑定/身份/会话锚/入站幂等/出站 outbox(与消息落库同事务)
- 微信(iLink):扫码绑定、长轮询收发、语音转写、typing、-14 会话自愈
- 企业微信:官方 aibot SDK WS 长连接、工作线程隔离、连接状态对账
- 多员工路由:斜杠指令切换、LLM 意图自动分发(粘性保护+手动保护窗)
- 身份绑定:/绑定 指令将渠道身份合并到既有账号,记忆与会话统一
- 可见性:对话日志按 admin/创建者放开,渠道对话记录与投递日志分页
- 管理界面:租户级渠道接入页(多渠道描述驱动),员工档案 tab 移除
- 测试:新增 14 个测试文件,全量 721 通过,ruff 零告警

* fix: dev 脚本端口探测设置 SO_REUSEADDR

_port_available 裸 bind 会把刚停止进程的 TIME_WAIT 误判为端口被占,
导致开发服务重启时在 5173/5174 间漂移并写入 app.port 状态文件。
与 uvicorn 监听行为保持一致后,重启稳定落回默认端口。

* feat: 渠道身份作用域平台化(回应 review)

按 OpenBMB 维护者建议,将渠道身份模型升级为四元作用域
(tenant_id, channel, external_account_scope, external_user_id):

- channel_identities/channel_inbound_events 重建唯一约束
  (identities 含 scope;inbound 改 binding_id+event_id)
- scope 取值:企微 corp_id>bot_id>binding_id,微信空串(全局 wxid)
- external_conv_id 含 scope;懒建 username 加 scope 段防撞
- 身份解析/懒建/绑定/解绑/迁移/重绑认领全部按 scope 过滤
- 企微凭证表单新增可选 corp_id;补填/变更 corp_id 时
  同事务迁移既有身份、会话与路由指针,保障身份连续
- 存量数据守卫迁移(app_data_migrations 幂等重建+回填)
- 新增 13 个测试(维护者四场景+跨企业事件/撞名/认领/连续性)

全量 734 passed,ruff 零告警

* fix: 第二轮 review 七项阻塞修复

- 会话与出站按 binding 隔离:find_channel_session 与唯一索引
  均含 channel_binding_id,同企业多 Bot 不再串会话与回复来源
- scope 迁移限定当前 binding,冲突改合并(会话与身份一致),
  不再连带迁移其他 Bot 数据
- 入站事件陈旧 processing 接管与启动 sweep,杜绝永久卡死丢消息
- 微信游标改为整批处理成功后推进,批中崩溃可经幂等重放恢复
- 企微解绑传 external_account_scope,接口测试断言 DB 状态
- ChannelBindingRead 暴露 corp_id(非敏感作用域字段),
  重新配置可正确回填且不被静默清空
- 懒建 username 截断改可读前缀+sha256 稳定后缀,防长 id 撞名
- 渠道管理权限改为 admin 或绑定创建者,不再随默认员工漂移

全量 746 passed,ruff 零告警

* security: 微信接入域名白名单校验,防止 bot_token 外发

- redirect_host/baseurl 统一经官方域名白名单(ilinkai.weixin.qq.com
  及 *.weixin.qq.com 子域)校验,非法地址不存不用
- confirmed 的 baseurl 经 sanitize 规范化,非法回退官方默认
- WeChatClient.for_binding 对存量配置最终钳制(防御纵深)
- 新增 6 个测试(域名规则/绕过样本/钳制与回退)

回应第二轮 review 安全项

* fix: 第三轮 review 五项修复

- 重配渠道真正重启 ingress:stop(中止在飞长轮询)→wait→update→start
- corpA→corpB 禁止自动迁移合并(仅允许 binding 派生 scope
  首次补充 corp_id 的连续迁移),否则 400 要求删除重建
- 崩溃恢复补 turn 未完成窗口:不盲目重跑,标 failed+中断通知
- 移除 (agent_id,channel) 唯一约束,支持同 Agent 挂载多 Bot
- username 恒带基于完整身份键的稳定 hash,杜绝清洗碰撞

全量 761 passed,ruff 零告警

* feat(channels): establish scoped channel persistence

Add tenant and account-scoped channel storage, stable account keys, multi-binding schema support, and guarded SQLite migrations for legacy channel data.

* feat(channels): isolate identities and sessions by binding

Resolve identities within tenant and external-account scopes, quarantine contaminated legacy mappings, and prevent sessions from being reused across users or bindings.

* fix(channels): enforce binding-safe outbox delivery

Anchor staged and delivered replies to the exact tenant, binding, channel, and external account while keeping legacy session adoption conservative.

* fix(channels): harden inbound recovery and bind code claims

Use process-owned event claims, recover interrupted turns without replaying side effects, preserve deduplication across quarantined sessions, and make bind codes collision-safe and atomic.

* fix(channels): serialize connector reconfiguration and shutdown

Fence configuration revisions, stop old producers before activation, drain callbacks and workers in order, and retain the connector process lock until every consumer exits.

* fix(ui): improve long identifiers and disable business autofill

Wrap long memory usernames and user IDs within table cells, and prevent password managers from treating non-login business inputs as credentials.

---------

Co-authored-by: 田领 <tianling02@picc.com.cn>
Co-authored-by: fadeoreo <heli_9902@hotmail.com>
…ry with 10 updates (OpenBMB#32)

Bumps the frontend-minor-and-patch group with 9 updates in the /frontend-enterprise directory:

| Package | From | To |
| --- | --- | --- |
| [@fontsource-variable/geist](https://github.com/fontsource/font-files/tree/HEAD/fonts/variable/geist) | `5.2.9` | `5.3.0` |
| [@radix-ui/react-slot](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/slot) | `1.3.0` | `1.3.1` |
| [@tailwindcss/vite](https://github.com/tailwindlabs/tailwindcss/tree/HEAD/packages/@tailwindcss-vite) | `4.3.2` | `4.3.3` |
| [lucide-react](https://github.com/lucide-icons/lucide/tree/HEAD/packages/lucide-react) | `1.22.0` | `1.26.0` |
| [pinyin-pro](https://github.com/zh-lx/pinyin-pro/tree/HEAD/packages/pinyin-pro) | `3.28.1` | `3.28.2` |
| [radix-ui](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/radix-ui) | `1.6.1` | `1.6.5` |
| [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom) | `7.15.1` | `7.18.1` |
| [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `26.0.1` | `26.1.1` |
| [shadcn](https://github.com/shadcn-ui/ui/tree/HEAD/packages/shadcn) | `4.12.0` | `4.14.0` |



Updates `@fontsource-variable/geist` from 5.2.9 to 5.3.0
- [Changelog](https://github.com/fontsource/font-files/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fontsource/font-files/commits/HEAD/fonts/variable/geist)

Updates `@radix-ui/react-slot` from 1.3.0 to 1.3.1
- [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/slot/CHANGELOG.md)
- [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/slot)

Updates `@tailwindcss/vite` from 4.3.2 to 4.3.3
- [Release notes](https://github.com/tailwindlabs/tailwindcss/releases)
- [Changelog](https://github.com/tailwindlabs/tailwindcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/tailwindlabs/tailwindcss/commits/v4.3.3/packages/@tailwindcss-vite)

Updates `lucide-react` from 1.22.0 to 1.26.0
- [Release notes](https://github.com/lucide-icons/lucide/releases)
- [Commits](https://github.com/lucide-icons/lucide/commits/1.26.0/packages/lucide-react)

Updates `pinyin-pro` from 3.28.1 to 3.28.2
- [Release notes](https://github.com/zh-lx/pinyin-pro/releases)
- [Changelog](https://github.com/zh-lx/pinyin-pro/blob/main/CHANGELOG.md)
- [Commits](https://github.com/zh-lx/pinyin-pro/commits/HEAD/packages/pinyin-pro)

Updates `radix-ui` from 1.6.1 to 1.6.5
- [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/radix-ui/CHANGELOG.md)
- [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/radix-ui)

Updates `react-router-dom` from 7.15.1 to 7.18.1
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/react-router-dom@7.18.1/packages/react-router-dom/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router-dom@7.18.1/packages/react-router-dom)

Updates `tailwindcss` from 4.3.2 to 4.3.3
- [Release notes](https://github.com/tailwindlabs/tailwindcss/releases)
- [Changelog](https://github.com/tailwindlabs/tailwindcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/tailwindlabs/tailwindcss/commits/v4.3.3/packages/tailwindcss)

Updates `@types/node` from 26.0.1 to 26.1.1
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `shadcn` from 4.12.0 to 4.14.0
- [Release notes](https://github.com/shadcn-ui/ui/releases)
- [Changelog](https://github.com/shadcn-ui/ui/blob/main/packages/shadcn/CHANGELOG.md)
- [Commits](https://github.com/shadcn-ui/ui/commits/shadcn@4.14.0/packages/shadcn)

---
updated-dependencies:
- dependency-name: "@fontsource-variable/geist"
  dependency-version: 5.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: frontend-minor-and-patch
- dependency-name: "@radix-ui/react-slot"
  dependency-version: 1.3.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: frontend-minor-and-patch
- dependency-name: "@tailwindcss/vite"
  dependency-version: 4.3.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: frontend-minor-and-patch
- dependency-name: lucide-react
  dependency-version: 1.26.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: frontend-minor-and-patch
- dependency-name: pinyin-pro
  dependency-version: 3.28.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: frontend-minor-and-patch
- dependency-name: radix-ui
  dependency-version: 1.6.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: frontend-minor-and-patch
- dependency-name: react-router-dom
  dependency-version: 7.18.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: frontend-minor-and-patch
- dependency-name: tailwindcss
  dependency-version: 4.3.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: frontend-minor-and-patch
- dependency-name: "@types/node"
  dependency-version: 26.1.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: frontend-minor-and-patch
- dependency-name: shadcn
  dependency-version: 4.14.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: frontend-minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Keep DOCX heading levels and add stable page sections for text-based PDF ingestion.
Group related evidence in source order while capping merged context at 4800 characters and retaining legacy fallback behavior.
Pass query type, desired evidence, knowledge version, and document constraints through the agent loop while intersecting scope with agent permissions.
Add routing fallbacks, relevance-first candidates, weighted multi-query scoring, bounded related chunk expansion, ingest schema versioning, and legacy compatibility coverage.
Skip heading-only chunks, link only oversized paragraph fragments, reserve ranking capacity after bucket diversification, and distinguish direct evidence from related supplements.
dependabot Bot added 3 commits July 27, 2026 10:06
Bumps the frontend-minor-and-patch group in /frontend-enterprise with 4 updates: [@radix-ui/react-slot](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/slot), [lucide-react](https://github.com/lucide-icons/lucide/tree/HEAD/packages/lucide-react), [radix-ui](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/radix-ui) and [shadcn](https://github.com/shadcn-ui/ui/tree/HEAD/packages/shadcn).


Updates `@radix-ui/react-slot` from 1.3.1 to 1.3.3
- [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/slot/CHANGELOG.md)
- [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/slot)

Updates `lucide-react` from 1.26.0 to 1.27.0
- [Release notes](https://github.com/lucide-icons/lucide/releases)
- [Commits](https://github.com/lucide-icons/lucide/commits/1.27.0/packages/lucide-react)

Updates `radix-ui` from 1.6.5 to 1.6.7
- [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/radix-ui/CHANGELOG.md)
- [Commits](https://github.com/radix-ui/primitives/commits/1.6.7/packages/react/radix-ui)

Updates `shadcn` from 4.14.0 to 4.15.0
- [Release notes](https://github.com/shadcn-ui/ui/releases)
- [Changelog](https://github.com/shadcn-ui/ui/blob/main/packages/shadcn/CHANGELOG.md)
- [Commits](https://github.com/shadcn-ui/ui/commits/shadcn@4.15.0/packages/shadcn)

---
updated-dependencies:
- dependency-name: "@radix-ui/react-slot"
  dependency-version: 1.3.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: frontend-minor-and-patch
- dependency-name: lucide-react
  dependency-version: 1.27.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: frontend-minor-and-patch
- dependency-name: radix-ui
  dependency-version: 1.6.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: frontend-minor-and-patch
- dependency-name: shadcn
  dependency-version: 4.15.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: frontend-minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…penBMB#42)

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.4.2 to 8.1.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v8.1.5/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 8.1.5
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Updates the requirements on [anthropic](https://github.com/anthropics/anthropic-sdk-python) to permit the latest version.
- [Release notes](https://github.com/anthropics/anthropic-sdk-python/releases)
- [Changelog](https://github.com/anthropics/anthropic-sdk-python/blob/main/CHANGELOG.md)
- [Commits](anthropics/anthropic-sdk-python@v0.117.0...v0.120.0)

---
updated-dependencies:
- dependency-name: anthropic
  dependency-version: 0.120.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
skywclouds and others added 20 commits August 19, 2026 18:13
* feat(channels): 飞书渠道协作者管理与启停

- 新增 ChannelBindingManager 表与协作者管理 API(GET/POST/DELETE managers)

- _ensure_binding_manager 改为按操作粒度:协作者可凭证/挂载/启停,删除与管理协作者仅创建者+admin

- list_channel_bindings 放开协作者可见性并返回 my_role

- 新增 POST /{binding_id}/toggle-status 启停渠道端点

- 前端:角色徽标、断开接入按角色显隐、启停按钮、协作者管理面板

* fix(channels): require bound Feishu handoff assignees

* feat(channels): invite members to bind Feishu identities

---------

Co-authored-by: Wang He <wanghe@WangdeMacBook-Pro.local>
Co-authored-by: fadeoreo <heli_9902@hotmail.com>
* fix(harness): accept structured skill results

* feat(harness): allow host commands and file paths

* feat(harness): complete A2A and workflow updates
- 新增 app/db/dialect.py 方言提供者(协议+注册表+
  SQLite/Postgres/Generic 实现),引擎创建走方言 kwargs
- 收编 4 处生产方言 SQL:渠道配置补丁与微信运行时补丁
  改 ORM 读改写+revision CAS,知识库 BLOB 查询方言分支,
  日分桶方言助手(PG 支持 app_timezone)
- 两个索引并入 models.py,新库 create_all 即完整 schema
- 加 psycopg[binary] 驱动与 PG 冒烟脚本

全量 1006 passed,ruff 零告警
- connector 进程锁走方言提供器:PG 用 advisory lock
  (常驻会话持锁),SQLite 等保持数据目录文件锁
- 方言文件锁内置 fork 防护(pid 判别,子进程不误解父锁)
- 飞书链路传完整 SQLAlchemy URL 替代 DB 文件路径,
  放开文件 SQLite 守卫(仅拒绝内存库)

全量 1013 passed,ruff 零告警
main 合入的渠道加固在企微重连清理 disconnect_alerted_at 时用了 SQLite 专有
json_remove;改为读-改-写 + dialect.json_config_remove,与微信 _patch_runtime_config
同一模式,PG/openGauss 可用
必修:
- 部分唯一索引移出 metadata,改按方言 DDL 事件创建(sqlite/postgresql),
  MySQL/达梦不再静默退化为全量唯一索引;init_db 对无部分索引后端做
  每租户单默认模型启动校验(supports_partial_index 落地消费)
- BaseDialect 文件锁仅对 SQLite 文件库有效,MySQL/达梦响亮拒绝,
  不再把库名当文件路径在 CWD 下静默错锁
- PG advisory lock:双 int4 键 + acquire/release 即提交(不再永久
  idle-in-transaction);新增 pg_locks 存活校验 + connector 锁看门狗,
  断连静默失效时渠道服务主动降级停止
- _patch_runtime_config/_patch_binding_config_key 双向改 SELECT FOR UPDATE,
  关闭整份 JSON 读-改-写与 API 侧补丁的丢写窗口(SQLite 自动省略)
- gaussdb-smoke 工作流锁调用补 session 参数并装 [dev,postgres]

设计对齐:
- 飞书 binding 锁方言化:锁身份=数据库作用域+binding key,跨 HOME/容器
  互斥;移除含密码 URL 指纹;测试不再写真实用户目录
- psycopg[binary] 移为可选依赖 postgres 组,缺驱动时启动给明确安装指引
- README/.env 写明:PG/高斯仅支持全新库(无迁移通路)、app_timezone
  仅 PG 生效、SQLite 配了会告警

小项:wechat 补丁锁按 binding 清理防泄漏;test_db_dialect 注册表快照
还原防污染;日分桶口径差异写入 docstring;refresh 注释改正;空行补齐

验证:1214 passed(唯一失败为 main 预存在探针回归)、ruff 零告警、
真实 PG16 冒烟含 advisory lock 闭环/部分索引/FOR UPDATE 全过
- PG advisory lock 改由方言常驻专属 engine.connect()+AUTOCOMMIT Connection,
  不归池、commit/rollback 不脱钩、pg_backend_pid 全程稳定——修复飞书
  binding 锁 PG 零互斥(A)与看门狗并发 checkout 误判停服(B);fork 防护同文件锁
- PostgresDialect.engine_kwargs 补 pool_pre_ping/pool_recycle/pool_size,
  陈旧连接首用不再直接 OperationalError

数据库层新排查:
- 51 个长文本列显式 Text(content/prompt/summary/error/url/credentials_enc 等),
  MySQL 不再静默退化为 VARCHAR(255)(SQLModel AutoString 255 兜底)
- 新增 PortableJSON TypeDecorator:sqlite/pg/mysql 原生 JSON,oracle/dm 降级
  CLOB+自动序列化还原,42 张表 oracle DDL 全部可编译

测试:锁专属连接/AUTOCOMMIT/重入/fork/竞争用例,全表 mysql+oracle DDL 编译
扫描,MySQL 长文本列抽验,PortableJSON 双方言往返;真实 PG16 冒烟新增
并发 checkout 后锁校验仍真的回归场景,双进程验证 binding 锁互斥

README:多 worker 并发 init 风险提示、无部分索引后端运行期无约束说明
头像 base64 可达 ~2.8MB,MySQL 下 TEXT(64KB) 仍会截断;新增 HugeText =
Text().with_variant(MEDIUMTEXT, 'mysql')(oracle→CLOB,pg/sqlite→TEXT 均无界),
DDL 抽验同步覆盖
main 新增 api_clients/api_credentials/harness 系列表后:29 处 Column(JSON)
与 1 处 Column(JSON, nullable=False) 统一为 PortableJSON,description/
last_error/user_intent 三个长文本列显式 Text;全表 mysql/oracle DDL
编译扫描通过
main 新增 evolution_proposals/team 系列表后:15 处 Column(JSON) 统一为
PortableJSON,summary/rationale/error/description/title/content 等长文本列
显式 Text;全表 mysql/oracle DDL 编译扫描通过
收编官方最新 main(2026-10-24,含 10/21 OSS 大重构)并重新移植「数据库层方言可插拔」特性:

- 方言层:新增 backend/app/db/dialect.py(协议 + 注册表 + SQLite/PostgreSQL/Generic
  实现);engine 创建改走方言 kwargs,PG/可选 psycopg 驱动缺失启动即报错并给安装指引;
  init_db 增加默认模型单默认校验与后端约束告警。
- models:JSON 列改 PortableJSON(Oracle/达梦降级 CLOB),长文本列显式 Text,
  默认模型部分唯一索引改按方言 DDL 事件创建(不再退化为全量唯一索引),
  sessions 唯一索引并入 metadata。
- 渠道:connector 单实例锁与飞书 binding 锁改方言 advisory lock(PG 常驻专属
  AUTOCOMMIT 连接 + 15s 存活看门狗,断连静默失效时渠道服务主动降级);
  ConnectorChildSpec 改传 database_url。
- 配置补丁/日分桶:config_store 对未注册方言提供 ORM 读-改-写 + FOR UPDATE +
  revision CAS 通用回退;delivery_days 支持 APP_TIMEZONE(PG)与未知方言兜底。
- 知识库:CAST AS BLOB 仅 SQLite 保留,其它后端走 ORM。
- 依赖/文档/CI:psycopg[binary] 移入可选依赖 [postgres],README 数据库后端章节,
  openGauss 冒烟工作流与 scripts/smoke_postgres.sh。
@tianling536

Copy link
Copy Markdown
Contributor Author

已按最新架构重新收编并更新分支(head 9ac58f69)

本次变更

  • 合并官方最新 main(fcc28c00,含 10/21 OSS 重构),冲突全部解决;PR diff 从 592 文件收敛到 26 文件(+2354/−407),与 main 无冲突(mergeable=MERGEABLE)。
  • 方言特性重新落地:app/db/dialect.py 方言层、engine/驱动/池参数、models 的 PortableJSON/Text/按方言 DDL 部分索引、config_store 通用方言回退、delivery_days 的 APP_TIMEZONE、渠道 connector/binding 锁方言化 + 存活看门狗、知识库 CAST AS BLOB 仅 SQLite。
  • 依赖/文档/CI:psycopg[binary] 移入可选依赖 [postgres]、README 增加 Database Backends 章节、.github/workflows/gaussdb-smoke.yml、scripts/smoke_postgres.sh。

验证

  • SQLite 全量 pytest backend/tests:2581 passed / 99 failed / 1 skipped;99 个失败均可在纯净 origin/main 复现(main 既有测试债,如 test_channel_outbox 22 个、test_nested_sop_execution 10 个等),本 PR 无回归;另顺手修复 main 上 3 个 stale 的 test_feishu_manager 用例。
  • 真实 PostgreSQL 18(Docker)冒烟通过:create_all(75 表)、方言 DDL 索引、JSONB 配置补丁/删除、APP_TIMEZONE 日分桶、知识库 ORM、PortableJSON、advisory lock 并发闭环(acquire → 并发连接 check → release)。
  • CI:CodeQL / verify / linux / windows / macos-arm64 构建通过(macos-intel 构建中)。

请复核

  1. 方言层抽象作为 OSS 数据库基础设施是否可接受;方向认可后,下一步补 MySQL/达梦适配器与 Alembic 迁移通路。
  2. openGauss 真机验证无法在 Apple Silicon 本机完成,烦请维护者 dispatch 一次 .github/workflows/gaussdb-smoke.yml。

在数据库方言可插拔层上落地 PR 登记项,并在真实数据库上验证:

- MySQL 8.x:新增 MySQLDialect(GET_LOCK/RELEASE_LOCK/IS_USED_LOCK 命名锁、
  专属 AUTOCOMMIT 连接常驻、64 字符锁名校验、池参数、utf8mb4);不支持部分
  唯一索引时由 init_db 启动校验兜底,config 补丁/日分桶/知识库走通用回退。
  修复 models 在 utf8mb4 下的 7 个超 3072 字节唯一索引、JSON 列 server_default
  (MySQL 1101) 与头像 MEDIUMTEXT;长文本列显式 TEXT。新增可选依赖 [mysql]。
- 达梦:新增 DMDialect 适配器骨架(无部分索引/无原生 advisory lock 时响亮
  拒绝;JSON 经 PortableJSON 降级 CLOB;需外部 SQLAlchemy 达梦方言插件 +
  dmPython,未真机验证);新增可选依赖 [dm]。
- openGauss:新增 opengauss+psycopg:// SQLAlchemy 兼容方言
  (app/db/opengauss.py),处理 openGauss version() 版本串解析与 SQL_ASCII
  初始化库的 client_encoding=utf8;config_store 对 openGauss 自动走通用 ORM
  回退(其 jsonb_set 参数语义与上游 PG 不同)。已在 openGauss 5.0 Docker
  (aarch64) 实测:init_db/基线索引/advisory lock/config patch/日分桶/知识库/
  渠道 connector 锁全部通过。
- Alembic 迁移通路:backend/app/db/migrations 内基线 revision(75 表/425 索引,
  按方言补部分唯一索引,随 app 包/wheel/PyInstaller 分发)+ alembic.ini;
  init_db 对非 SQLite 后端自动 bootstrap(全新库 create_all+stamp 基线、存量表
  无版本表 stamp+告警、有版本表 upgrade head),SQLite 路径不变。
  真实 PostgreSQL 18/MySQL 8.4/openGauss 5.0 验证 fresh/stamp/upgrade/幂等均通过。
- 依赖/文档/CI:新增 alembic 主依赖与 [mysql]/[dm] extras;README 数据库后端
  章节更新;gaussdb-smoke workflow 改为官方 openGauss 镜像 +
  opengauss+psycopg + 真实断言;scripts/smoke_postgres.sh 支持 opengauss scheme。

验证:SQLite 全量 pytest 2612 passed / 99 failed(99 个均为 origin/main 既有
测试债,与基线失败集合完全一致,本提交零回归);改动文件 ruff 全绿;MySQL 8.4、
PostgreSQL 18、openGauss 5.0 真实库冒烟通过。
@tianling536

Copy link
Copy Markdown
Contributor Author

追加提交:MySQL/达梦方言适配器 + Alembic 迁移通路 + openGauss 真机验证(ab007672)

在重新收编 main 的基础上,把 PR 登记的后续项一并落地并在真实数据库上验证:

MySQL 8.x(真机验证通过)

  • 新增 MySQLDialect:GET_LOCK/RELEASE_LOCK/IS_USED_LOCK 命名锁(专属 AUTOCOMMIT 连接常驻、64 字符锁名校验)、utf8mb4 池参数;不支持部分唯一索引 → 由 init_db 启动校验兜底;配置补丁/日分桶/知识库自动走通用回退。
  • 修复 MySQL 建库阻塞项:utf8mb4 下 7 个唯一约束超 3072B、JSON 列 server_default(MySQL 1101)、头像列恢复 MEDIUMTEXT;长文本列显式 TEXT。
  • 实测(MySQL 8.4 Docker):全新库 init_db(76 表 + alembic_version)、列类型、默认模型启动校验、config 补丁、日分桶、知识库、命名锁跨进程竞争/KILL 后失效、渠道 connector 锁全部通过。

openGauss 5.0(真机验证通过,aarch64 Docker)

  • 新增 app/db/opengauss.py + opengauss+psycopg:// 兼容方言:处理 openGauss version() 返回 (openGauss 5.0.0 ...) 无法按 PG 正则解析、SQL_ASCII 初始化库导致驱动返回 bytes(注入 client_encoding=utf8)。
  • config_store 对 openGauss 自动走通用 ORM 回退(openGauss 的 jsonb_set 参数类型与上游 PG 不同)。
  • 实测:init_db(76 表 + 部分唯一索引 + sessions 唯一索引 + alembic_version)、二次启动幂等、纯 alembic upgrade head、存量表 stamp、PortableJSON、config 补丁、日分桶、知识库(中文)、advisory lock(hashtext + pg_locks)、渠道 connector 锁全部通过。
  • gaussdb-smoke.yml 已改为官方 openGauss 镜像 + opengauss+psycopg + 上述断言,维护者可 dispatch 复跑。

达梦

  • 新增 DMDialect 适配器骨架:supports_partial_index=False(启动校验兜底)、无已验证原生锁 → 非 SQLite 文件锁响亮拒绝、JSON 经 PortableJSON 降级 CLOB、长文本 TEXT;需要外部 SQLAlchemy 达梦方言插件 + dmPython([dm] extra),本仓库未预装、未真机验证。

Alembic 迁移通路

  • backend/app/db/migrations/ 基线 revision(75 表/425 索引,按方言补部分唯一索引),随 wheel/PyInstaller 分发;alembic.ini 支持 CLI。
  • init_db:SQLite 路径不变;非 SQLite 全新库 = create_all + stamp 基线,已有表无版本表 = stamp + 告警,有版本表 = upgrade head。
  • 真实 PostgreSQL 18 / MySQL 8.4 / openGauss 5.0 上验证 fresh/stamp/upgrade/幂等/降级全部通过。

验证汇总

  • SQLite 全量 pytest:2612 passed / 99 failed / 1 skipped,99 个失败与干净 origin/main 基线失败集合完全一致(main 既有测试债),本 PR 零回归;改动文件 ruff 全绿。
  • 新增可选依赖 extras:[mysql](pymysql)、[dm](dmPython);alembic 加入主依赖。

请复核

  1. opengauss+psycopg:// 独立 scheme 的设计是否可接受(替代直接复用 postgresql+psycopg://,以兼容 openGauss 的版本串/编码差异)。
  2. gaussdb-smoke.yml 的认证方式:CI 容器内使用 trust 仅用于冒烟,生产部署建议 md5/证书;如需我改成 md5 初始化也可调整。
  3. 达梦适配器骨架是否保留在 OSS 仓库,还是仅留文档说明。

修复 CodeQL actions/missing-workflow-permissions 告警(PR 变更代码新增告警,
会参与 main 的 code_scanning 分支规则);仅需 contents: read 即可 check out
与拉取 openGauss 镜像。
@tianling536

Copy link
Copy Markdown
Contributor Author

状态同步:CI 已全部通过,等待 review

本 PR 当前 head e943a9d4,CI 已全绿:

  • CodeQL / Analyze (actions, javascript-typescript, python) / checks-verify 全部 pass;
  • 打包构建全部 pass:linux、windows、macos-arm64、macos-intel;
  • mergeable=true,main 分支 ruleset 的 code scanning 规则已满足(此前 workflow permissions 的 CodeQL 告警已修复)。

补充验证:openGauss 5.0 已在真实容器上跑通(init_db、Alembic 基线迁移、部分唯一索引、advisory lock、config patch、日分桶、知识库 ORM、渠道 connector 锁),对应 .github/workflows/gaussdb-smoke.yml 可直接 dispatch 复跑;MySQL 8.4 / PostgreSQL 18 也已完成真实库冒烟。

如方便请安排 review;对以下几点如有不同意见,我可以继续调整:

  1. opengauss+psycopg:// 独立 URL scheme(用于处理 openGauss 版本串/编码差异);
  2. gaussdb-smoke.yml 的 CI 认证方式(冒烟用 trust,生产建议 md5/证书);
  3. 达梦(DM)适配器骨架是否保留在 OSS 仓库。

感谢!

@tianling536

Copy link
Copy Markdown
Contributor Author

补充:完整应用端到端启动验证 —— 四库全部通过(2026-11-09)

之前 PR 的数据库验证是「DB 层冒烟」(直接调用 init_db/方言/仓储代码,未启动完整 app)。本轮已在本机构建 Harness v3(DeepSeek Harness / dsh)运行时产物(python3 prepare.py --no-cli-link → harness-engine/apps/cli/lib/bin.js),随后对四种数据库做了完整应用启动 + HTTP API 端到端验证。

验证方式:uvicorn app.main:app 完整启动(Harness v3 运行时初始化 + 渠道服务启动 + init_db/Alembic/方言初始化),然后跑 10 项 HTTP API 冒烟 + DB 产物检查。

数据库 版本 应用启动 HTTP API 冒烟 DB 产物检查
SQLite(默认) — 6s 10/10 10/10(无 alembic_version,走内置迁移路径,符合预期)
PostgreSQL 18 8s 10/10 11/11(alembic_version + 部分唯一索引)
openGauss(高斯) 5.0(aarch64) 8s 10/10 11/11(同 PG;需 md5 认证,psycopg3 不支持其默认 sha256)
MySQL 8.4 10s 10/10 11/11(无部分唯一索引=预期,由启动校验兜底)

HTTP 冒烟覆盖(均经真实 app 进程):

  • /api/health;admin/admin 登录(验证 demo seed 的用户表初始化)
  • 员工列表、渠道绑定列表与创建(ORM 写入)
  • 企微凭证保存 → config_store 方言路径(SQLite json_set / PG JSONB / openGauss+MySQL 通用 ORM 回退)
  • /channels/{id}/deliveries/days → 方言 day_bucket
  • 知识库列表 → knowledge ORM 路径
  • 模型配置列表 → PortableJSON 读取
  • 删除渠道绑定(清理)

DB 产物检查:schema ≥75 表、sessions 唯一索引、默认模型部分唯一索引(MySQL 按预期不存在)、alembic_version(非 SQLite 且 head 非空)、demo seed 数据、JSON 列写读闭环。

备注:保存/删除企微凭证时,后台 WeCom SDK 线程会打印一条 Event loop stopped before Future completed —— 这是因为测试环境没有真实企微网络、线程随绑定删除退出,与本 PR 数据库改动无关,不影响上述结果。

据此,PR 的「完整应用端到端启动验证」缺口已补齐(四库全部通过)。

This branch has not been deployed

No deployments
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.