Repository navigation
feat: 数据库层方言可插拔(SQLite → 高斯/MySQL/达梦易扩展) - #39
tianling536 wants to merge 357 commits into
Conversation
- 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.
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>
* 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 编译扫描通过
888c3f9 to
4cc415b
Compare
4cc415b to
aa3cf63
Compare
收编官方最新 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。
已按最新架构重新收编并更新分支(head
|
在数据库方言可插拔层上落地 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 真实库冒烟通过。
追加提交:MySQL/达梦方言适配器 + Alembic 迁移通路 + openGauss 真机验证(
|
修复 CodeQL actions/missing-workflow-permissions 告警(PR 变更代码新增告警, 会参与 main 的 code_scanning 分支规则);仅需 contents: read 即可 check out 与拉取 openGauss 镜像。
状态同步:CI 已全部通过,等待 review本 PR 当前 head
补充验证:openGauss 5.0 已在真实容器上跑通(init_db、Alembic 基线迁移、部分唯一索引、advisory lock、config patch、日分桶、知识库 ORM、渠道 connector 锁),对应 如方便请安排 review;对以下几点如有不同意见,我可以继续调整:
感谢! |
补充:完整应用端到端启动验证 —— 四库全部通过(2026-11-09)之前 PR 的数据库验证是「DB 层冒烟」(直接调用 验证方式:
HTTP 冒烟覆盖(均经真实 app 进程):
DB 产物检查:schema ≥75 表、sessions 唯一索引、默认模型部分唯一索引(MySQL 按预期不存在)、 备注:保存/删除企微凭证时,后台 WeCom SDK 线程会打印一条 据此,PR 的「完整应用端到端启动验证」缺口已补齐(四库全部通过)。 |
概述
将数据库层从「SQLite 实现」升级为方言可插拔:默认走 ORM/标准 SQL(所有数据库通用),无法通用的少数点收口到方言提供者接口。新增一种数据库 = 注册一个小适配器(锁/日期/能力声明),业务代码零改动。
支持矩阵:SQLite(默认,行为逐字保留)、PostgreSQL(实验性)、openGauss/高斯(实验性,已在 5.0 真机验证)、MySQL 8.x(实验性,已在 8.4 真机验证)、达梦(适配器骨架,需外部 SQLAlchemy 方言插件)。
设计
新模块
backend/app/db/dialect.pyDatabaseDialect协议: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 通用实现兜底);init_db启动校验兜底。SQLAlchemy 侧:
app/db/opengauss.py为 openGauss 注册opengauss+psycopg://兼容方言(处理 openGauss 的version()版本串解析与 SQL_ASCII 初始化库的client_encoding=utf8)。改造点
get_dialect(backend).engine_kwargs(url)(SQLite 行为不变);PG/openGauss 可选依赖[postgres]、MySQL[mysql]、达梦[dm],缺失时启动即给安装指引;PG/MySQL 池参数补齐。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)。PortableJSON(达梦/Oracle 降级 CLOB),长文本列显式Text;MySQL utf8mb4 下 7 个超 3072B 唯一索引与 JSONserver_default已修复,头像恢复MEDIUMTEXT。GET_LOCK命名锁,SQLite=文件锁;锁身份统一为数据库作用域 + key。backend/app/db/migrations/(随 wheel/PyInstaller 分发);init_db对非 SQLite:全新库 create_all + stamp 基线、存量表无版本表 stamp + 告警、有版本表upgrade head。SQLite 保持 create_all + 内置迁移路径不变。alembic主依赖与[postgres]/[mysql]/[dm]extras;README 增加 Database Backends 与迁移章节;新增scripts/smoke_postgres.sh;gaussdb-smoke.yml使用官方 openGauss 镜像 +opengauss+psycopg并断言方言能力(维护者可 dispatch)。验证
pytest backend/tests= 2612 passed / 99 failed / 1 skipped;99 个失败经干净origin/main基线对比确认全部是 main 既有测试债(失败集合与基线完全一致),本 PR 零回归。改动文件 ruff 全绿。GET_LOCK跨进程竞争/断连检测、渠道 connector 锁全部通过;Alembic fresh/stamp/upgrade 幂等通过。alembic upgrade head、存量表 stamp、PortableJSON、config 补丁(自动走通用回退)、日分桶、知识库(中文)、advisory lock(hashtext + pg_locks)、渠道 connector 锁全部通过。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 产物;详见下方验证评论。当前限制
APP_TIMEZONE仅对 PostgreSQL/openGauss 日分桶生效;SQLite 恒为服务器本地时区(配置了会告警)。后续(登记项)