feat(product-suite): add direct job state machine

This commit is contained in:
chengma
2026-07-20 18:12:44 +08:00
parent 2a2cbad7bd
commit aa000ff5e6
11 changed files with 820 additions and 101 deletions
+6 -2
View File
@@ -3,7 +3,7 @@ id: T-679a
title: 商品套图自定义网关多来源任务状态机
phase: 7
deps: [T-678]
status: TODO
status: DONE
created: 2026-07-20
---
@@ -88,4 +88,8 @@ git diff --check
## 执行记录
(做完在这里写:变更文件、状态机决策、验证命令及结果。)
- 已实现双来源任务状态机:默认网关固定持久化为 `cmhub/cmhub` 并保留异步 submit/poll/download;自定义网关固定为 `direct/openai_images_edits`,复用 T-678 同步多图编辑,`task_id` 始终为空、固定 `n=1`、不轮询且不自动重试。执行按 job 已保存来源分派,不读取运行中设置。
- `image_studio_jobs` 新增 `run_session_id`,`image_studio_assets` 新增请求尺寸与真实像素字段;迁移附加式且幂等。启动期在单进程恢复租约下仅清理陈旧 direct `running` job,切换项目/刷新不触发恢复;已收到 direct 图片字节时停止信号不丢弃成果。
- 新增比例映射和近似比例结构化结果;直连输出保存用户原比例、请求尺寸及真实图片尺寸。直连 URL、密钥、原始响应均不写入 SQLite、日志或用户错误文案。
- 已更新 `docs/04-architecture.md`、`docs/api.md`,明确两来源生命周期和 T-679 发布门禁。
- 验证:`py -3.10 -m unittest tests.test_image_studio_generation tests.test_image_studio tests.test_ai`(99 项)、`py -3.10 -m ruff check app tests main.py`、`py -3.10 -m compileall app main.py`、`git diff --check` 均通过;完整 `py -3.10 -m unittest discover -s tests` 通过(646 项)。