跳到主要内容

v0.2.67 — 架构改造大版本

12 个架构改造 commit,涵盖分层修复、连接池化、SQLAlchemy Core 迁移、348 个测试防护网。

分层修复

  • 消除 core→api 反向依赖,新增 core/dispatcher.py Dispatcher protocol
  • task_manager.py 三拆:db_adapter.py + db_schema.py + 业务方法
  • api/sse.py 瘦身 1466→94 行,阶段编排状态机下沉为 core/phase_runner.py

数据库层

  • 修生产连接饱和("FATAL: too many clients already"):改为进程级共享 SQLAlchemy Engine(QueuePool),16 线程并发只占 3 个连接(旧代码 16 个)
  • 删除全部手写方言转换规则
  • 新增 schema_migrations 表,补 Postgres 此前不执行 migrations 的缺陷

可观测性

每次 job 启动生成 job_run_id(12 hex),server.log 每行携带 [run:xxx]

测试抓出的 3 个生产 bug

  1. sweep_wedged_running 产物检查被 except 吞掉 → 误杀保护从未生效
  2. run_migrations 在 Postgres dict 行上 row[0] KeyError → PG 库二次启动崩
  3. SQLite Core 路径默认值列落 NULL → api_tokens.revoked 为 NULL 导致认证失败