新增 external v1 游戏场景生成路由并迁移 AGC 美术包背景阶段
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
- api-server 新增 POST /api/external/v1/editor/scenes/generations,复用 editor:image-generate scope、幂等键和站内场景生图队列 - editor_project.rs 抽取站内与外部共用的场景生图 payload 构造函数,站内 handler 改为调用共享函数 - 同步更新 external v1 OpenAPI 契约与 MCP 派生排除标记,登记 docs/README.md 索引 - AGC 客户端美术包背景阶段改走新场景路由,stylePreset 固定 custom + customStyle 保留现有风格文案 - external_generation_state 快照与 recovery_scan 账本白名单支持新场景路由 - direct_runtime 背景资源识别同时兼容新场景路由与旧通用路由,新增旧路由回放测试 - 更新 genarrative-external-editor-api skill 参考文档 - 新增主规范、里程碑规范与实施计划三份 SDD 文档
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
# 【技术方案】External v1 游戏场景生成路由
|
||||
|
||||
更新时间:`2026-09-24`
|
||||
|
||||
## 目标
|
||||
|
||||
为 `/api/external/v1` 补齐游戏场景生成的结构化专用路由,使 AGC 客户端(陶泥儿美术包背景阶段)在平台收紧 `kind = scene` / `assetKind = scene` 边界校验后仍有合规的场景生成入口:
|
||||
|
||||
```text
|
||||
AGC 美术包背景阶段(结构化场景意图)
|
||||
-> POST /api/external/v1/editor/scenes/generations
|
||||
-> 后端确定性组装场景 Prompt(与站内场景路由同一实现)
|
||||
-> 现有 editor_image_generation 队列与 Worker
|
||||
-> 现有计费、幂等、失败、资源持久化与 canvasCompletion
|
||||
```
|
||||
|
||||
同时修复 AGC 客户端背景阶段保留账本匹配口径与实际请求不一致的既有隐患。
|
||||
|
||||
## 非目标
|
||||
|
||||
- 不改动站内 `/api/editor/scenes/generations` 的请求字段、Prompt 组装结果与计费语义。
|
||||
- 不放松通用 `/api/editor/images/generations` 与 `/api/external/v1/editor/images/generations` 对 `kind = scene` / `assetKind = scene` 的拒绝。
|
||||
- 不新增场景 Worker、任务表、计费档位或 SpacetimeDB schema。
|
||||
- 不改变美术包背景图的出图风格与尺寸(16:9 / 1K)。
|
||||
- 不处理 issue #495 的抠图重放 409 与动画 compact 字段问题(独立排期)。
|
||||
|
||||
## 入口与边界
|
||||
|
||||
- 系统入口:AGC 客户端 Direct 美术包流程的背景阶段(`reuse-or-create` 与 `regenerate` 均经过)。
|
||||
- 涉及模块:`api-server`(external v1 路由与场景 Prompt 组装)、`shared-contracts`(DTO 复用)、AGC `src-tauri`(请求构造、保留账本、身份对账与恢复扫描常量)。
|
||||
- 正式状态来源:`external_generation_job` 队列记录与项目 manifest 登记,与现役外部生成入口一致。
|
||||
|
||||
## 必须成立的行为
|
||||
|
||||
### 正常路径
|
||||
|
||||
1. 新路由 `POST /api/external/v1/editor/scenes/generations` 接受与站内场景路由相同的 `EditorSceneGenerateRequest` 字段(`sceneContent`、`stylePreset`、`customStyle?`、`model?`、`aspectRatio?`、`imageSize?`、`referenceImageSrcs?`、`projectId?`、`generationInputs?`、`assetFolderId?`、`assetLabel?`、`canvasCompletion?`),不接受调用方组装后的完整 `prompt`。
|
||||
2. 场景 Prompt 由后端经与站内路由完全相同的组装实现生成;两路由只共享这一份组装逻辑。
|
||||
3. 鉴权复用现有 `editor:image-generate` scope;与现役外部生成入口一样强制 `Idempotency-Key` 请求头。
|
||||
4. 受理响应与现役外部生成入口同形(operationId 异步受理信封),轮询继续走 `/api/external/v1/generations/{operation_id}`。
|
||||
5. 入队后 `kind = scene`、`assetKind = scene`,队列类型、Worker、计费与持久化与站内场景路由一致;队列标题与任务摘要口径不变。
|
||||
6. AGC 美术包背景阶段以 `stylePreset = custom` + `customStyle` 承载现有风格描述,`sceneContent` 承载 brief 衍生的画面内容,出图风格与比例不因迁移改变。
|
||||
|
||||
### 失败、重试与幂等
|
||||
|
||||
1. 缺少 `sceneContent`、非法 `stylePreset`、自定义风格缺少 `customStyle` 等参数错误返回 400,与站内路由同语义。
|
||||
2. 缺少或非法幂等键、越权 scope 的拒绝语义与现役外部生成入口一致。
|
||||
3. 同一幂等键 + 同一请求重放返回原任务,不新建任务、不重复扣费;同键不同请求返回 409。
|
||||
4. Provider 失败、取消与 lease 耗尽沿用现有扣退费语义。
|
||||
|
||||
### 权限、归属与数据边界
|
||||
|
||||
1. 资源归属、项目绑定与素材文件夹解析沿用现役外部生成入口的 owner 口径。
|
||||
2. 任务摘要只展示 `generationInputs.fields` 的「画面内容」,不把后端完整 Prompt 暴露到任务侧栏。
|
||||
3. 场景产物以 `assetKind = scene` 持久化并保存 `scene.generate` V2 配方,与站内产物口径一致。
|
||||
|
||||
## 契约与迁移
|
||||
|
||||
- API / DTO / OpenAPI:新增 external v1 场景路由,DTO 复用 `shared-contracts` 的 `EditorSceneGenerateRequest`;同一次变更同步 `docs/openapi/genarrative-external-v1.openapi.json` 与契约测试(路由矩阵、鉴权、参数 400、幂等重放)。
|
||||
- SpacetimeDB schema / migration / bindings:不变。
|
||||
- 兼容与迁移策略:AGC 客户端背景阶段的路由、manifest 身份登记、保留账本匹配与恢复扫描常量整圈迁移到新路由;历史已登记的背景身份(旧通用路由 + `kind = spec`)保持可读,不做数据迁移。
|
||||
|
||||
## 验收标准与证据
|
||||
|
||||
| 条款 | 验收方式 | 证据 |
|
||||
| ---- | -------- | ---- |
|
||||
| 新路由受理/参数校验/鉴权/幂等重放 | api-server 契约测试与单测 | 待补 |
|
||||
| 与站内路由同一 Prompt 组装结果 | 共享实现的单测对照 | 待补 |
|
||||
| OpenAPI 与实现一致 | 契约测试 + `check:openapi` 类门禁 | 待补 |
|
||||
| 美术包背景端到端(reuse-or-create / regenerate) | 客户端定向测试 + 本地真实栈 smoke | 待补 |
|
||||
| 中断恢复:保留账本匹配与身份对账 | 客户端定向测试 | 待补 |
|
||||
|
||||
## 未决问题与决策
|
||||
|
||||
- `stylePreset` 取舍:已决策——AGC 美术包背景固定 `custom` + `customStyle` 承载现有风格文案,不绑定预设风格(2026-09-24,与用户确认)。
|
||||
Reference in New Issue
Block a user