Compare commits

...

103 Commits

Author SHA1 Message Date
lhk229 11c8cbdf67 Merge pull request '修复 AGC Direct 写通道项目锁零等待与持锁方不可诊断' (#320) from fix/issue-318-direct-write-lock-wait into master
Project CI / Repository checks (push) Successful in 3m7s
Project CI / Frontend tests (push) Successful in 3m41s
Project CI / Backend tests (push) Successful in 5m48s
Project CI / Native shell tests (push) Successful in 17m34s
Reviewed-on: https://git.genarrative.world/git/GenarrativeAI/Genarrative/pulls/320
2026-09-10 21:43:37 +08:00
suzmii ff42fff61c 按评审意见把写锁等待挪出 runtime worker 并收紧 wait_exhausted 记账
Project CI / Repository checks (pull_request) Successful in 3m18s
Project CI / Frontend tests (pull_request) Successful in 4m3s
Project CI / Backend tests (pull_request) Successful in 7m25s
Project CI / Native shell tests (pull_request) Successful in 19m35s
- agc_write_file 写路径改经 bridge_write_file_in_blocking_pool 走 tokio::task::spawn_blocking:有界等待是同步轮询(最多约 10 秒),直接在 async handler 里跑会占住 tokio worker,争用窗口内同一轮并行写多个文件时会波及共享同一 runtime 的只读端点与 UI 命令
- 新增用例用默认 current_thread runtime 加心跳任务锁住该性质;把 handler 临时改回同步直调时该用例按预期失败,确认有区分度
- project.write_lock.wait_exhausted 与终态改判一起改为只在真的等过(max_attempts > 1)时发生:hydrate 的单次试探不再写 waitedMs 近似 0 的“耗尽”日志
- 技术方案、decision-log、pitfalls 同步这两条,并补“同步有界等待不能直接跑在 async handler 里”的排障经验
2026-09-10 21:38:48 +08:00
lhk229 e8c5d2e247 Merge branch 'master' into fix/issue-318-direct-write-lock-wait
Project CI / Repository checks (pull_request) Successful in 2m58s
Project CI / Frontend tests (pull_request) Successful in 3m45s
Project CI / Backend tests (pull_request) Successful in 7m5s
Project CI / Native shell tests (pull_request) Successful in 17m13s
2026-09-10 21:13:23 +08:00
lhk229 ab86efa421 Merge pull request '停止追踪误提交的本地文档' (#323) from rm/local-docs into master
Project CI / Native shell tests (push) Has been cancelled
Project CI / Frontend tests (push) Has been cancelled
Project CI / Backend tests (push) Has been cancelled
Project CI / Repository checks (push) Has been cancelled
Reviewed-on: https://git.genarrative.world/git/GenarrativeAI/Genarrative/pulls/323
2026-09-10 21:12:38 +08:00
lhk229 a12d18c1cd 停止追踪误提交的本地文档
Project CI / Repository checks (pull_request) Successful in 2m30s
Project CI / Frontend tests (pull_request) Successful in 3m19s
Project CI / Backend tests (pull_request) Successful in 6m6s
Project CI / Native shell tests (pull_request) Successful in 18m2s
从仓库索引移除 local-docs 下的 11 份本地过程文档
保留当前工作区本地文件,不新增或修改忽略规则
2026-09-10 13:00:26 +00:00
suzmii 71e9ad3133 修复锁失败终态判据漏传平台导致 CI 把权限改判成争用
Project CI / Repository checks (pull_request) Successful in 6m17s
Project CI / Frontend tests (pull_request) Successful in 8m23s
Project CI / Backend tests (pull_request) Successful in 12m7s
Project CI / Native shell tests (pull_request) Successful in 25m6s
- project_write_lock_permission_is_ambiguous 改为按平台加原始错误码判定(Windows 的 ACCESS_DENIED(5));只看 ErrorKind 在 Linux 上会得出相反结论:errno 5 在 Windows 是 ACCESS_DENIED、在 Linux 是 EIO
- ProjectWriteLockFailure::Retryable 携带 platform,终态改判与争用文案都用同一次分类的平台,不再依赖宿主 errno 语义
- 终态投影用例显式用 Windows 平台构造失败并补 Unix 反例,两个平台上结论一致;CI 首次推送正是在此失败(2358 passed / 1 failed,left contention / right permission_denied)
- pitfalls 补充“判据的每一环都要带平台”的排障经验
2026-09-10 20:46:10 +08:00
suzmii 06f738dc99 将项目写锁从 project/filesystem.rs 纯搬移到 project/write_lock.rs
Project CI / Repository checks (pull_request) Successful in 2m37s
Project CI / Frontend tests (pull_request) Successful in 3m30s
Project CI / Backend tests (pull_request) Successful in 6m36s
Project CI / Native shell tests (pull_request) Failing after 13m57s
- 新建 project/write_lock.rs:取锁、等待分类、持锁方诊断、残留回收与 4 条锁用例整体搬移,逻辑不变
- project/filesystem.rs 只保留项目文件 IO(1533 → 680 行),锁相关常量、结构、进程判据与用例全部移出
- project.rs 注册 mod write_lock 并 pub(crate) use write_lock::*,crate::project:: 与 crate:: 既有路径不变
- windows_metadata_is_reparse_point 提为 pub(crate),供 write_lock 复用同一条 reparse point 判据
- agent_db.rs 与 checkpoint.rs 的 PROJECT_FILE_FLAG_OPEN_REPARSE_POINT 导入路径改为 super::write_lock
- 同步修正技术方案、Fast GDD 技术方案、decision-log、pitfalls 中指向锁实现的文件路径,并把“拆锁”从后续事项改为已完成
2026-09-10 20:12:28 +08:00
suzmii 8c639e5d13 修复项目写锁重试判据用一次元数据观察误判瞬时争用
- 项目写锁分类改为只按错误码判定重试性,不再用 path.exists() 决定“要不要等”:真机 6 万次建锁/删锁竞争实测 396-538 例命中“ACCESS_DENIED(5) + 目标不可见”,旧判据会让等待层立刻失败关闭,把毫秒级竞争换成更误导的 ACL 文案
- 新增 ProjectWriteLockFailure(Retryable / Terminal)与 acquire_project_write_lock_failure,有界等待改按类型分流,acquire_project_write_lock 退化为它的文案包装
- Windows 的 ACCESS_DENIED(5) 终态改判移到等待预算耗尽之后:只有真的等过预算且目标此刻仍不存在时才投影成权限拒绝,单次试探保持争用语义
- 锁分类判据改为平台参数传入(project_write_lock_open_failure_for),Linux CI 可覆盖 Windows 分支;替换原先只在 Windows 本地执行的分类用例
- 零等待入口在错误码不可区分时补一句“可能是删除挂起、删除拆链窗口或权限 / ACL 拒绝”,争用前缀逐字不变,调用方既有重试语义不受影响
- PROJECT_WRITE_LOCK_CONTENTION_PREFIX 收口 provider_recovery.rs、planning_session_v2.rs、direct_runtime.rs 三处手写文案
- project.write_lock.wait_exhausted 日志补 projection= 分类,attempts 记为实际尝试次数
- 同步更新技术方案、decision-log、pitfalls,并修正 ownerIsSelf 只比 PID 的表述
2026-09-10 20:07:28 +08:00
suzmii 59cab3d9fd Merge remote-tracking branch 'origin/master' into fix/issue-318-write-lock-classification 2026-09-10 19:58:05 +08:00
lhk229 89447ed432 按评审意见强化回退模板读取通道回归测试
Project CI / Repository checks (pull_request) Successful in 2m47s
Project CI / Frontend tests (pull_request) Successful in 3m44s
Project CI / Backend tests (pull_request) Successful in 7m1s
Project CI / Native shell tests (pull_request) Successful in 18m11s
Project CI / Backend tests (push) Has been cancelled
Project CI / Native shell tests (push) Has been cancelled
Project CI / Frontend tests (push) Has been cancelled
Project CI / Repository checks (push) Has been cancelled
- tests/configuration.rs 回退模板测试改用与模板无关的 runtime dir,分类断言覆盖按路径归属而非 runtime dir 为 None 的恒真分支,并补充 runtime dir 内路径的 managed 正向断言
- tests/mod.rs 移除不再使用的 clear_test_runtime_config_dir 辅助
2026-09-10 09:46:48 +00:00
lhk229 3ebfcc0c2f 修正新增配置读取回归测试的 Rust 格式
Project CI / Repository checks (pull_request) Successful in 2m16s
Project CI / Frontend tests (pull_request) Successful in 3m8s
Project CI / Backend tests (pull_request) Successful in 7m2s
Project CI / Native shell tests (pull_request) Successful in 18m27s
- tests/configuration.rs 按 cargo fmt 调整两个 assert! 宏换行
2026-09-10 09:03:19 +00:00
lhk229 9b5d1fe107 修复仓库回退配置模板被读取通道私有化 ACL 锁定
Project CI / Frontend tests (pull_request) Successful in 3m30s
Project CI / Backend tests (pull_request) Successful in 6m27s
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
- config.rs 新增 game_creator_config_path_is_runtime_managed 判定,read_game_creator_config_file 按路径归属分流:AppData 托管目录内的真实凭据维持私有加固读取,仓库旁边的回退模板与 local 覆盖改用 open_project_snapshot_regular_file 非变异快照通道
- 根因:开发 CLI 无 AppHandle 时回退读取 worktree 内 git 跟踪模板,私有读通道在 Windows 上无条件收紧 DACL 为仅当前进程用户,导致其他账号与 cargo include_str! 全部 Access Denied
- tests/mod.rs 新增 clear_test_runtime_config_dir 辅助
- tests/configuration.rs 新增两个回归测试锁定快照 / 私有两条读取通道的分流
- pitfalls.md 记录该排障经验与读取通道副作用白名单教训
2026-09-10 08:57:31 +00:00
suzmii 4ecab19429 修正 CI 权限用例在 root 容器下的前提并补平台无关的分类判据
Project CI / Repository checks (pull_request) Successful in 3m5s
Project CI / Frontend tests (pull_request) Successful in 4m2s
Project CI / Backend tests (pull_request) Successful in 6m51s
Project CI / Native shell tests (pull_request) Successful in 19m16s
- project_write_lock_does_not_project_permission_denial_as_contention 不再用 expect_err 断言“只读目录必须挡住取锁”:CI 容器以 root 运行,0o500 不生效,取锁会正常成功;此时跳过端到端前提
- 新增平台无关用例 project_write_lock_classifies_by_whether_the_target_exists:目标存在才是争用、目标不存在却创建失败是权限拒绝、NotFound 归其它
- 让权限分类判据在不依赖 ACL 环境的条件下也有回归护栏,避免只靠会被 root 绕过的端到端用例
2026-09-10 16:52:30 +08:00
suzmii 81c2389132 修复 AGC Direct 写通道项目锁零等待与持锁方不可诊断
Project CI / Repository checks (pull_request) Successful in 3m9s
Project CI / Frontend tests (pull_request) Successful in 4m7s
Project CI / Backend tests (pull_request) Successful in 6m54s
Project CI / Native shell tests (pull_request) Failing after 14m11s
- Direct 写路径(agc_write_file)改用统一的有界等待,与 file.write / file.patch / file.delete 同语义,同一轮并行写多个文件按同一把锁串行,不再在 24-42ms 内把重叠判成"项目正在被其他写操作占用"
- create_new 失败拆成争用 / 权限拒绝 / 其它三类:锁文件不存在却仍创建失败不再投影成争用;sharing violation(32) 与 lock violation(33) 恒定归争用
- 争用错误与等待日志带上持锁方身份(commandId / pid / createdAt / ownerIsSelf),锁文件处于删除挂起或未写完时显式表达成"身份不可读"
- ProjectWriteLockSnapshot 补 commandId 与 describe_holder(),沿用既有快照 + 字节 CAS 回收机制,不新增第二套回收判据
- 有界等待预算耗尽记 project.write_lock.wait_exhausted(含等待毫秒数),权限拒绝记 project.write_lock.permission_denied,争用不在零等待入口里逐次记账
- 新增同进程重叠写等待、同轮并行写、活外部进程持锁带身份、权限拒绝分类、ACL 拒绝不投影成争用五条回归用例
- 同步 decision-log、pitfalls 与技术方案文档
2026-09-10 16:30:22 +08:00
suzmii a1b9b24891 修复 AGC Ctrl+C 残留上个工作树后端导致切换工作树复用旧后端 (#315)
Project CI / Frontend tests (push) Successful in 3m14s
Project CI / Backend tests (push) Successful in 8m54s
Project CI / Repository checks (push) Successful in 2m29s
Project CI / Native shell tests (push) Successful in 19m23s
closes #314

## 现象

`npm run agc` 按 Ctrl+C 后有概率残留上个工作树的 `api-server.exe` / SpacetimeDB,切换 worktree 再启动时 AGC 复用旧后端,改过数据库 / schema 的工作树会串库。

## 根因

1. Windows 下长驻服务都经 Node `shell: true` 的 `cmd.exe /d /s /c` 包装层启动,Ctrl+C 先杀包装层(`0xC000013A`);`dev.mjs` 的 `stopProcess` 见到直接子进程已退出就 return,`taskkill /PID <已退出 PID> /T /F` 也只会失败,深处的 `cargo → api-server.exe` 无人清理。
2. 按根 PID 遍历依赖快照里的父子链,中间层先消失时链断,只能拿到根 PID。
3. 复用判据只看 `.app/dev-stack.json` status 与 `/healthz`、`/readyz`、`/v1/ping`,不校验端口上的进程属于哪个工作树,残留后端照样被判为健康并复用。

## 改动

- 新增 `scripts/dev-windows-process.mjs`:按根 PID 遍历 + 按身份匹配(`server-rs/target/debug/api-server.exe` 绝对路径、SpacetimeDB `--data-dir`)两条独立清理路径,带 1s 快照缓存避免清理被拖慢。
- `scripts/dev.mjs`:直接子进程已退出时仍按记录 PID 清理后代;退出时按身份兜底清扫本工作树后端(复用他人 standalone 时跳过);启动前清理旧 api-server 保留 `Wait-Process` 语义,避免 `failed to remove file`。
- `apps/ai-game-creator-shell/scripts/start-dev-stack.mjs`:复用前校验端口监听进程归属,无法证明归属就不复用、改为启动本工作树后端并允许端口漂移;信号与 `finally` 各兜底清扫一次;`taskkill` 失败时降级按 PID 遍历;等待就绪时输出归属校验失败原因,避免静默超时。探测不可用时退化为旧行为,不阻断本地启动。
- 测试与文档:新增 `scripts/dev-windows-process.test.ts`、扩充 AGC 复用门禁用例;同步 `docs/project-memory/shared-memory/pitfalls.md` 与本地开发运维文档。

## 验证

- 伪造 `api-server.exe` 进程:按身份精确命中并杀掉(`matched=[17284] stopped=[17284]`)。
- 3 个真实监听进程下归属判定:`owned` / `api-server-owner-mismatch` / `spacetime-owner-mismatch` 均正确。
- `npx vitest run scripts/dev.test.ts scripts/dev-windows-process.test.ts scripts/dev-stack-port-utils.test.ts apps/ai-game-creator-shell/tests/...`:119 passed(唯一失败为 Windows 文件权限用例,已确认在合并基线 `origin/master` 上同样失败)。
- `node --check`、`eslint --max-warnings 0`、`prettier --check`、`npm run check:encoding`、`git diff --check` 全部通过。

## 备注

Rust 侧 `api-server` 的 `with_graceful_shutdown` 没有超时上限,是「有概率」的来源之一;本次只在 Node 侧收口,是否给优雅退出加 deadline 可另行评估。

Reviewed-on: https://git.genarrative.world/git/GenarrativeAI/Genarrative/pulls/315
Co-authored-by: Suzumiya <suzmii@qq.com>
Co-committed-by: Suzumiya <suzmii@qq.com>
2026-09-09 20:08:04 +08:00
suzmii 7c49e7e51c Merge pull request '修复 AGC 项目写锁残留无法回收与启动失败无诊断' (#313) from fix/agc-stale-lock into master
Project CI / Backend tests (push) Has been cancelled
Project CI / Repository checks (push) Has been cancelled
Project CI / Frontend tests (push) Has been cancelled
Project CI / Native shell tests (push) Has been cancelled
Reviewed-on: #313
Reviewed-by: 孔令弘 <ink29535@proton.me>
2026-09-09 20:07:37 +08:00
suzmii c0ef876b14 修复 AGC 项目写锁回收的并发删除竞争与启动诊断死路径
Project CI / Backend tests (pull_request) Successful in 5m56s
Project CI / Repository checks (pull_request) Successful in 2m29s
Project CI / Frontend tests (pull_request) Successful in 3m5s
Project CI / Native shell tests (pull_request) Successful in 17m44s
- 锁文件回收改为单次快照解析:payload 只解析一次,删除前重新核对字节,内容已被并发方替换或文件已消失时返回 false 并重试 create_new,不再无条件 unlink,也不再把 remove_file 的 NotFound 当成硬失败
- mtime 读取失败改用 Option 区分“未知”与“纪元 0”:未知年龄不回收,未知锁创建时间不做 PID 复用推断,避免把保守判定反转成抢走活持有者
- 新增并发替换/已消失、旧格式活持有者、存活未知、mtime 未知四条回归用例
- 启动日志槽优先用已经生效的配置目录(含 --config-dir),否则退到平台配置根(APPDATA / Application Support / XDG_CONFIG_HOME)
- 日志路径未知时 StartupLogSlot::fail 仍然给出用户可见提示,四处 inspect_err 不再被路径判空挡掉
- 同步 check-config 守卫、decision-log、pitfalls 与技术方案文档的用例数与新判据
2026-09-09 19:44:46 +08:00
suzmii b7f27721c5 修复 AGC 项目写锁回收判据的跨平台 PID 边界
Project CI / Repository checks (pull_request) Successful in 3m8s
Project CI / Frontend tests (pull_request) Successful in 4m15s
Project CI / Backend tests (pull_request) Successful in 6m47s
Project CI / Native shell tests (pull_request) Successful in 17m58s
- 项目写锁存活判定把平台不可能分配出的进程号(0 或超出平台 pid 宽度)判为持有者不存在并直接回收,不再落回 600 秒保守分支
- 回归用例的死进程 PID fixture 由 0xFFFF_FFF0 改为 i32::MAX - 1,同时落在两个平台进程号空间之外且在 Unix 有符号 32 位范围内
- 新增 project_write_lock_reclaims_unrepresentable_owner_pid 用例,覆盖 u64::MAX 非法进程号残留锁
- 修正 project_lock_recovery 头部注释,说明这些用例是回归护栏而不是待修缺陷
- 同步 decision-log 的 PID 边界决策与 pitfalls 的跨平台 fixture 经验
2026-09-09 18:00:53 +08:00
suzmii 78ba9e33b6 修复 AGC 启动诊断守卫用例
Project CI / Repository checks (pull_request) Successful in 2m49s
Project CI / Frontend tests (pull_request) Successful in 4m2s
Project CI / Backend tests (pull_request) Successful in 6m45s
Project CI / Native shell tests (pull_request) Failing after 14m22s
- check-config.mjs 启动诊断守卫改按 StartupLogSlot 契约匹配:setup_log.fail 加稳定失败码
- 同时校验 StartupLogSlot 内部仍写有界诊断日志并调用可见提示,避免守卫被绕过
2026-09-09 17:27:30 +08:00
suzmii 3153d4f674 修复 AGC 项目写锁残留无法回收与启动失败无诊断
Project CI / Repository checks (pull_request) Successful in 2m50s
Project CI / Frontend tests (pull_request) Successful in 3m30s
Project CI / Native shell tests (pull_request) Failing after 4m30s
Project CI / Backend tests (pull_request) Successful in 6m32s
- .agent/project.lock 新增 processStartedAt,PID 存活时核对进程启动身份,身份不一致判定 PID 复用并回收
- 旧锁缺少 processStartedAt 时退回“进程启动时间晚于锁 createdAt 加 5 秒容差”的 PID 复用推断
- 空锁 / 坏锁(崩溃停在 create_new 与落盘之间)宽限期由 600 秒收紧到 30 秒,无法判定持有者存活时仍保持 600 秒
- 新增 StartupLogSlot,配置目录就绪前后都能写 startup.log,startup.*.failed 与启动错误提示不再是死分支
- Windows 启动失败恢复系统消息框并附诊断日志路径,其它平台写 stderr,同一进程只提示一次
- 新增 project_lock_recovery 6 条回归用例:死 PID、空锁宽限、PID 复用时间推断、PID 复用身份不一致、身份一致不抢锁、新鲜空锁不抢锁
- 同步 decision-log 与 App 实施计划文档
2026-09-09 16:58:41 +08:00
lhk229 04128eb661 Merge branch 'master' into feat/design_agent_simple
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Frontend tests (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 / Repository checks (push) Successful in 2m48s
Project CI / Frontend tests (push) Successful in 3m26s
Project CI / Backend tests (push) Successful in 7m17s
Project CI / Native shell tests (push) Successful in 19m27s
2026-09-09 16:34:16 +08:00
k88936 7288c6f641 Fix/修复无限画布图标文字模糊 (#285)
Project CI / Repository checks (push) Successful in 2m59s
Project CI / Frontend tests (push) Successful in 3m29s
Project CI / Backend tests (push) Successful in 8m37s
Project CI / Native shell tests (push) Successful in 20m55s
closes #279
closes #284

实现: 从2(暂定)倍放大绘制的画布scale 0.5* 真正的scale

before:
![shotmd-1788579338.jpg](/attachments/9d44ec5e-454c-449b-86bc-b2131fbbc8cc)
![shotmd-1788578910.jpg](/attachments/c9da61a2-b467-43eb-a5de-e5e4d5cb8f70)

after:
![shotmd-1788580930.jpg](/attachments/f1f06e8e-90bf-45e2-a30b-a63ccc308c19)
![shotmd-1788583400.jpg](/attachments/c48ca741-e470-42b3-8030-064e0579f63a)
svg看起来stroke窄了一点点, 可以接受

Reviewed-on: #285
2026-09-09 16:32:43 +08:00
lhk229 5b82a269e9 修正定向测试 Rust 格式
Project CI / Repository checks (pull_request) Successful in 2m47s
Project CI / Frontend tests (pull_request) Successful in 4m3s
Project CI / Backend tests (pull_request) Successful in 6m40s
Project CI / Native shell tests (pull_request) Successful in 18m41s
按 CI rustfmt 规范整理策划会话与视觉提示测试
2026-09-09 07:52:46 +00:00
lhk229 dd0fd5feff 修复合并后的定向测试
Project CI / Repository checks (pull_request) Failing after 1m49s
Project CI / Frontend tests (pull_request) Successful in 3m45s
Project CI / Backend tests (pull_request) Successful in 6m23s
Project CI / Native shell tests (pull_request) Successful in 20m16s
移除不再符合 hydrate 锁语义的过时测试

同步视觉 Agent prompt 测试与当前资源合同
2026-09-09 07:41:52 +00:00
lhk229 852d9af483 合并最新 master
Project CI / Repository checks (pull_request) Successful in 2m44s
Project CI / Backend tests (pull_request) Successful in 13m7s
Project CI / Frontend tests (pull_request) Successful in 13m55s
Project CI / Native shell tests (pull_request) Failing after 29m47s
同步远端主线至 b129589e7

保留当前分支的 V1 清理与主线文档和测试更新
2026-09-09 06:06:35 +00:00
lhk229 310091d28e 合并最新 master
Project CI / Repository checks (pull_request) Failing after 9s
Project CI / Backend tests (pull_request) Failing after 9s
Project CI / Frontend tests (pull_request) Successful in 6m0s
Project CI / Native shell tests (pull_request) Has been cancelled
同步主线 DirectProject 历史与 Markdown 展示改动

保留策划 V2 退役方案文档索引
2026-09-09 05:49:33 +00:00
lhk229 b129589e75 Merge pull request '修复客户端常用设置读写卡顿' (#307) from fix/config_sl into master
Project CI / Repository checks (push) Successful in 4m42s
Project CI / Backend tests (push) Successful in 9m13s
Project CI / Frontend tests (push) Successful in 13m41s
Project CI / Native shell tests (push) Successful in 23m57s
Reviewed-on: https://git.genarrative.world/git/GenarrativeAI/Genarrative/pulls/307
Reviewed-by: 段舒康 <kdletters@qq.com>
2026-09-09 13:45:26 +08:00
lhk229 6a1e307b4a 合并最新master并协调模型配置保存逻辑
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
合入服务端默认模型同步及前端模型选择更新
保留配置覆盖层回滚和设置页无外部诊断行为
同步模型ID与默认模型标记并补充交叉回归验证
2026-09-09 05:36:56 +00:00
suzmii 672d93015c Merge pull request '优化AGC客户端同步LLM配置' (#306) from feat/agc-client-sync-llm-config into master
Project CI / Repository checks (push) Successful in 2m49s
Project CI / Backend tests (push) Successful in 6m44s
Project CI / Native shell tests (push) Failing after 15m5s
Project CI / Frontend tests (push) Successful in 2m57s
Reviewed-on: #306
2026-09-09 13:19:43 +08:00
suzmii d9c883675d 补充AGC模型目录异常revision的客户端用例
Project CI / Frontend tests (pull_request) Successful in 4m3s
Project CI / Repository checks (pull_request) Successful in 5m35s
Project CI / Backend tests (pull_request) Successful in 8m10s
Project CI / Native shell tests (pull_request) Failing after 17m32s
- 补充旧服务端不返回 revision(两次响应均为 undefined)时仍按目录变化刷新的用例
- 补充服务端目录重建导致 revision 回退(7 到 0)时仍更新界面的用例
- 补充 revision 未变化时不更新界面、沿用已应用目录的用例
2026-09-09 13:03:46 +08:00
lhk229 2757273850 修正配置回滚代码的Rust格式
Project CI / Repository checks (pull_request) Successful in 2m51s
Project CI / Frontend tests (pull_request) Successful in 3m18s
Project CI / Native shell tests (pull_request) Successful in 22m8s
Project CI / Backend tests (pull_request) Successful in 8m9s
按rustfmt要求调整错误信息和测试断言换行
通过仓库check:rustfmt、编码和diff检查
2026-09-09 04:40:45 +00:00
lhk229 08c5917490 修复配置覆盖层写入失败后的部分更新
Project CI / Frontend tests (pull_request) Successful in 3m5s
Project CI / Backend tests (pull_request) Failing after 3m52s
Project CI / Native shell tests (pull_request) Failing after 4m5s
Project CI / Repository checks (pull_request) Failing after 1m8s
提前序列化配置变更并在多文件写入失败时逆序回滚
保留单文件保存路径且不增加外部诊断或保存后回读
补充覆盖层写入失败回归测试及配置保存文档
2026-09-09 04:34:57 +00:00
suzmii 07fc26953a 修复AGC模型目录同步的加载态与保存竞态
Project CI / Repository checks (pull_request) Successful in 2m56s
Project CI / Frontend tests (pull_request) Successful in 3m45s
Project CI / Backend tests (pull_request) Failing after 4m34s
Project CI / Native shell tests (pull_request) Failing after 7m54s
- ConversationModelSelect:目录同步与配置读取/写回失败时统一在 finally 收起加载态,避免选择器永久卡在 busy、无法切换或刷新
- ConversationModelSelect:配置读取失败单独提示「读取客户端配置失败」,不再误报为模型目录加载失败
- ConversationModelSelect:配置写回串行化,发送前校验等待在途保存并读取最新配置,避免保存中放行旧选择、或用旧快照覆盖刚完成的选择
- ConversationModelSelect:服务端未返回 revision 时按目录已变化处理,避免界面停止刷新
- ProjectSupervisorView:提交前模型校验期间禁用输入框与发送按钮,避免重复提交与校验窗口内编辑丢失
- 测试:补充配置读取失败恢复、保存中发送前校验等待、目录请求去重用例;修正依赖配置读取时序的 appSurface 用例
- 文档:修正首页入口「按需加载」与实现不符的描述
2026-09-09 12:00:10 +08:00
lhk229 ff065dbc6c 修复本地Provider冒烟测试的HTML项目夹具
Project CI / Repository checks (pull_request) Successful in 3m10s
Project CI / Frontend tests (pull_request) Successful in 4m7s
Project CI / Backend tests (pull_request) Successful in 7m11s
Project CI / Native shell tests (pull_request) Successful in 18m7s
启动 Agent 前准备已有 HTML 入口以符合 JSON Generator 项目契约
失败诊断补齐退出码、终止信号及标准输出和错误输出尾部
同步冒烟测试夹具与诊断约定文档
2026-09-09 03:50:32 +00:00
lhk229 3be91bf283 修复rust格式问题
Project CI / Frontend tests (pull_request) Successful in 3m40s
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Successful in 3m24s
Project CI / Backend tests (pull_request) Failing after 6m14s
2026-09-09 03:44:33 +00:00
lhk229 1b4f0ed203 修复原生应用CI测试与持久化图片生成恢复
Project CI / Repository checks (pull_request) Failing after 1m6s
Project CI / Frontend tests (pull_request) Successful in 2m42s
Project CI / Backend tests (pull_request) Successful in 10m7s
Project CI / Native shell tests (pull_request) Failing after 18m54s
将已有 HTML 项目测试夹具与 npm 项目初始化契约对齐
更新图片生成与角色提示词断言,移除已退役视觉门禁测试
按持久化请求快照恢复旧图片生成任务缺省参数
修正运行中生成任务查询的测试路由和响应夹具
同步技术方案与共享开发约定
2026-09-09 03:17:03 +00:00
lhk229 5bee48fede 合并最新master到常用设置修复分支
同步远端master的最新修改
2026-09-09 02:15:42 +00:00
suzmii 2942489575 Merge remote-tracking branch 'origin/master' into feat/agc-client-sync-llm-config
Project CI / Repository checks (pull_request) Successful in 2m49s
Project CI / Frontend tests (pull_request) Successful in 3m26s
Project CI / Native shell tests (pull_request) Failing after 4m12s
Project CI / Backend tests (pull_request) Failing after 4m13s
# Conflicts:
#	apps/ai-game-creator-shell/src/features/project-workspace/ConversationModelSelect.tsx
#	apps/ai-game-creator-shell/src/features/project-workspace/ProjectSupervisorView.tsx
#	apps/ai-game-creator-shell/tests/conversationModelSelect.test.tsx
#	docs/technical/【技术方案】AGC后台模型别名与对话选择-2026-09-05.md
2026-09-09 10:04:05 +08:00
lhk229 1cf835418e 修复常用设置状态展示与本地覆盖保存
Project CI / Backend tests (pull_request) Successful in 5m43s
Project CI / Repository checks (pull_request) Failing after 24m21s
Project CI / Native shell tests (pull_request) Failing after 14m11s
Project CI / Frontend tests (pull_request) Successful in 28m31s
删除常用设置账号权限状态栏及关联状态传递
复用保存前读取结果并同步冲突覆盖项,模型切换仅同步模型字段
补充配置保存定向测试并更新设置职责文档
2026-09-08 13:45:25 +00:00
lhk229 14d76419b8 修复策划回答身份绑定与迟到恢复结果覆盖
Project CI / Repository checks (pull_request) Successful in 2m48s
Project CI / Backend tests (pull_request) Successful in 6m28s
Project CI / Native shell tests (pull_request) Failing after 13m45s
Project CI / Frontend tests (pull_request) Successful in 44m47s
在既有回合锁内核对问题与会话身份,保留已完成回合重放。
前端回答携带卡片问题标识,hydrate 写回前检查请求序列和项目路径。
补充后端与界面回归测试,同步技术合同与项目决策。
2026-09-08 13:25:24 +00:00
lhk229 5efd88cb3e 修复客户端常用设置读写卡顿
Project CI / Frontend tests (pull_request) Successful in 2m46s
Project CI / Backend tests (pull_request) Successful in 5m57s
Project CI / Repository checks (pull_request) Successful in 2m30s
Project CI / Native shell tests (pull_request) Failing after 15m32s
移除常用设置读取和保存后的外部诊断调用
减少配置读取时的重复权限修复和保存后的重复回读
补充常用设置无需外部诊断的原因注释
2026-09-08 12:58:29 +00:00
lhk229 8d03b73582 修复 Planning V2 恢复与审批重放
Project CI / Frontend tests (pull_request) Successful in 12m56s
Project CI / Backend tests (pull_request) Successful in 22m19s
Project CI / Repository checks (pull_request) Failing after 33m17s
Project CI / Native shell tests (pull_request) Failing after 33m40s
恢复已落盘结构化 question 为成功回合并补齐会话投影

允许审批 receipt 在重启后复用原始 decisionId

恢复旁路不干扰正常 run 并补充设计原则文档
2026-09-08 12:52:18 +00:00
lhk229 47a3240e81 按 rustfmt 修正 V1 删除后残留的格式偏差
Project CI / Backend tests (pull_request) Successful in 11m23s
Project CI / Native shell tests (pull_request) Failing after 13m38s
Project CI / Repository checks (pull_request) Successful in 4m51s
Project CI / Frontend tests (pull_request) Successful in 7m39s
Repository checks 门禁的 cargo fmt --check 要求,仅格式化、无行为变化
2026-09-08 11:25:17 +00:00
lhk229 c8fec98758 Merge branch 'master' into feat/design_agent_simple
Project CI / Repository checks (pull_request) Failing after 2m8s
Project CI / Backend tests (pull_request) Successful in 17m24s
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
2026-09-08 19:12:36 +08:00
lhk229 55377f9e51 修复 prompt bundle 集成测试夹具残留 V1 planning 形状导致 CI 失败
Project CI / Backend tests (pull_request) Failing after 15s
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / Frontend tests (pull_request) Successful in 6m40s
Project CI / Native shell tests (pull_request) Successful in 27m25s
基础夹具 manifest 同步删除 supervisorPlan 组合、planning 目录条目与四个已删 section 登记
roleOverlays 校验测试改为自带合法 overlay 夹具后逐项破坏,与生产 manifest 的空 overlay 形状对齐
2026-09-08 11:11:31 +00:00
lhk229 2fa967a93a 删除策划 V1 的测试脚本入口并同步退役文档
Project CI / Repository checks (pull_request) Failing after 12s
Project CI / Backend tests (pull_request) Failing after 9s
Project CI / Frontend tests (pull_request) Successful in 3m15s
Project CI / Native shell tests (pull_request) Failing after 15m21s
删除 agent-swarm-test-chat.mjs 的 --plan 模式、自动 GDD 审批回路与 planning 产物检查
删除根与应用 package.json 的 test:plan / test:plan:manual / agc:test:plan* 四条脚本
同步删除 agentSwarmTestEntry.test.ts 中只覆盖 V1 审批回路与 --plan 参数的用例
GddApprovalCard.tsx 注释改指 planning_gdd_model.rs 的现行路径权威定义
立项策划Agent(Fast GDD)方案文档头部标注已退役,仅作历史推导记录
策划会话 Runtime V2 方案文档状态更新为 P5 已完成并记录源码删除执行清单
Provider 兼容性缺陷文档的缺陷 4 标注相关代码已随 V1 退役删除
decision-log 新增 2026-09-08 策划 V1 链路源码整体退役决策记录
2026-09-08 10:43:38 +00:00
lhk229 78a606ab5e 删除已退役策划能力配置
Project CI / Repository checks (pull_request) Failing after 14s
Project CI / Backend tests (pull_request) Failing after 14s
Project CI / Frontend tests (pull_request) Successful in 2m31s
Project CI / Native shell tests (pull_request) Failing after 13m1s
移除 planning.capabilityEnabled,保留其余客户端配置
2026-09-08 10:17:24 +00:00
lhk229 ded3253b08 删除已退役策划 V1 的 Runtime 模块与残留分支
按四不写原则移除 PR #159 引入、已被策划 V2 取代的整条 V1 链路
删除 runtime_protocol 下六个 V1 模块(planning_storage/submit/approval/coordinator/hydrate/provider_usage)
V1 与 V2 共用的 GDD 数据模型抽到新模块 planning_gdd_model.rs 供 V2 继续复用
删除 prompt manifest 中 planning Agent 目录、role overlay、plan sections 与 supervisorPlan 组合及对应生成常量
删除四个 V1 提示词文件(roles/project-planning.md、plan/common.md、plan/supervisor-identity.md、plan/supervisor-playbook.md)
删除 game-creator.config.json 与配置代码中的 planning 能力开关
删除 CLI --swarm-chat 的 --plan 入口与 swarm_cli 中的 plan source 分支
删除 provider_retry 的 planning session binding 与 plan 专用请求指纹链路
删除 provider_action_batch 的 plan.submit_gdd v4 批次形状校验与 planning 绑定字段
删除 tool_policy_snapshot / agent_native_tools / tool_plan_protocol 中的 plan 根阶段收窄与 plan.submit_gdd 身份门
删除 main_loop 的 plan_gdd blocker 投影、plan 信封修复回路与 plan submit 业务拒绝限流
删除 pending_recovery 与 recovery_scan 的 plan submit 锚点恢复、planning session 投影恢复与审批投影恢复
删除 acceptance_graph 的 Fast GDD 取证覆盖校验与 plan 根验收前置门
删除 agent_db 的 plan.provider_usage、plan.gdd_decided、plan_submit_gdd.committed 三条专用持久车道及其预留配额
删除 AgentRuntimeState 的 plan_submit_gdd_rejection_count 字段
runtime_tools 的委派、run_status、goal_contract 恢复为通用路径(移除 plan 根对称性守卫与 acceptance gate 钩子)
同步删除只覆盖 V1 行为的测试用例(planning 澄清、锚点恢复、plan 根委派门、plan 提示词组合等)
2026-09-08 09:44:21 +00:00
suzmii 4fc9451492 修复AGC客户端未跟随服务端默认模型
Project CI / Native shell tests (pull_request) Failing after 14m52s
Project CI / Repository checks (pull_request) Successful in 5m51s
Project CI / Frontend tests (pull_request) Successful in 6m17s
Project CI / Backend tests (pull_request) Successful in 23m19s
- 客户端配置新增 selectedModelIsDefault,记录当前选择是否来自平台默认项
- 服务端默认项变化时,跟随默认项的选择自动切换并提示,手动选择不受影响
- 所选模型失效回退默认项时标记为默认项选择
- 补充配置读写与客户端定向测试,同步技术方案文档
2026-09-08 16:38:37 +08:00
suzmii d60c4ce6ec 优化AGC客户端同步LLM配置
Project CI / Frontend tests (pull_request) Successful in 3m54s
Project CI / Repository checks (pull_request) Successful in 5m41s
Project CI / Backend tests (pull_request) Successful in 14m56s
Project CI / Native shell tests (pull_request) Failing after 15m10s
- GET /api/llm/models 增加目录 revision,客户端据此做条件刷新
- AGC 客户端在项目切换、对话表面挂载、下拉展开、窗口聚焦时按 revision 条件刷新
- 模型目录请求同一时刻只保留一个在途请求,刷新失败保留上一次有效目录与本地选择
- 发起对话前校验所选模型,已停用或删除时回退默认模型并提示
- 新增模型目录缓存模块与定向测试,同步技术方案与后端架构文档
2026-09-08 16:11:36 +08:00
lhk229 38b4abc403 删除已退役策划 V1 的前端数据通路与命令入口
Project CI / Repository checks (pull_request) Failing after 11s
Project CI / Backend tests (pull_request) Failing after 10s
Project CI / Frontend tests (pull_request) Successful in 2m43s
Project CI / Native shell tests (pull_request) Successful in 18m1s
前端 App.tsx 删除 hydrate_game_creator_plan_gdd_state 旧读取与 decide_game_creator_plan_gdd 旧审批分支,策划状态只走 Planning V2 命令
hydratePlanningV2Session 在确认无 V2 会话时清空策划状态,避免残留旧卡片
Tauri 命令层删除 decide_game_creator_plan_gdd 与 hydrate_game_creator_plan_gdd_state 及其注册和输入解析
CLI 删除 --plan-gdd-status 与 --plan-gdd-decide 子命令、stdin 审批意见读取与对应解析测试
测试 harness 删除旧命令 mock 与 planGdd 状态注入,新增 V2 审批失败注入与 decisionId 记录
plan-gdd 测试套件改写为 V2 会话驱动,删除 recoveryPending 与旧 Supervisor 审批等待两个已退役语义的测试
2026-09-08 03:56:16 +00:00
lhk229 0fde1912f1 Merge remote-tracking branch 'origin/feat/design_agent_simple' into feat/design_agent_simple
Project CI / Repository checks (pull_request) Successful in 3m10s
Project CI / Frontend tests (pull_request) Successful in 3m24s
Project CI / Backend tests (pull_request) Successful in 6m45s
Project CI / Native shell tests (pull_request) Successful in 19m25s
2026-09-07 10:33:36 +00:00
lhk229 1db5930c9f 修复rustfmt格式检查
- planning_session_v2.rs 的 config 加载与 tool_planning.rs 的 final_request 捕获合并为单行
2026-09-07 10:29:13 +00:00
kdletters 29fa20e68d Merge branch 'master' into feat/design_agent_simple
Project CI / Frontend tests (pull_request) Successful in 3m9s
Project CI / Backend tests (pull_request) Successful in 6m31s
Project CI / Repository checks (pull_request) Failing after 1m6s
Project CI / Native shell tests (pull_request) Successful in 19m54s
2026-09-07 17:16:26 +08:00
lhk229 85de37710b 软化tool_choice兼容性表述为可能不支持
Project CI / Repository checks (pull_request) Failing after 44s
Project CI / Frontend tests (pull_request) Successful in 3m9s
Project CI / Backend tests (pull_request) Successful in 7m23s
Project CI / Native shell tests (pull_request) Successful in 21m20s
- 代码注释与策划会话文档改为“部分模型或端点可能不支持”,DeepSeek 仅作示例
2026-09-07 07:38:05 +00:00
lhk229 b5d214cef8 Merge branch 'master' into feat/design_agent_simple
Project CI / Repository checks (pull_request) Failing after 59s
Project CI / Frontend tests (pull_request) Successful in 3m10s
Project CI / Backend tests (pull_request) Successful in 6m9s
Project CI / Native shell tests (pull_request) Successful in 21m10s
2026-09-07 15:34:32 +08:00
lhk229 0ff2c00618 注明思考模式模型不支持tool_choice=required
Project CI / Backend tests (pull_request) Failing after 10s
Project CI / Frontend tests (pull_request) Successful in 3m15s
Project CI / Native shell tests (pull_request) Successful in 20m38s
Project CI / Repository checks (pull_request) Failing after 15s
- planning_session_v2 的 Required 设置处补注释:DeepSeek 等思考模式模型会以 400 拒绝该取值,接入新模型需先验证端点支持
- 策划会话 Runtime V2 文档重试规则节补充该限制及其与瞬态重试的边界
2026-09-07 07:30:57 +00:00
lhk229 e20ea86ed9 放宽后台Agent工具计划环路测试超时口径
- final reply 请求捕获改用 wait_for_captured_mock_request 10 秒轮询预算,取代手写 recv_timeout 2 秒,消除持久化动作批次管线开销导致的单测 flaky
- 收尾等待改用 wait_for_agent_runtime_terminal_and_lane_release,确认 lane 释放、不留僵尸 worker
- 批量并行跑时的跨测试污染为既有系统性问题,本次不处理
2026-09-07 06:57:50 +00:00
lhk229 df6d885d2c 策划会话瞬态Provider故障自动退避重试
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
- invoke_provider_v2 错误携带主 Runtime 同款瞬态分类,timeout/connectivity/transport/空响应/反序列化/断流/上游408、429、5xx 不再直接判死
- run_turn_v2 对瞬态故障按 maxRetries 预算指数退避自动重试本回合,耗尽后才投 provider_failed 并附已重试次数,上游 4xx 硬错误仍直接失败
- 同步策划会话 Runtime V2 文档:tool_choice 口径改为 required,补充瞬态故障重试规则
2026-09-07 04:51:12 +00:00
lhk229 8eeaa43081 立项策划会话强制工具调用
- planning_session_v2 请求 toolChoice 由 Auto 改为 Required,消除模型跳过 plan_ask_question/plan_submit_gdd 而把 JSON 写进正文导致的 PLANNING_INVALID_OUTPUT 失败
2026-09-07 03:41:58 +00:00
lhk229 a371c60724 Merge remote-tracking branch 'origin/master' into feat/design_agent_simple 2026-09-07 03:07:54 +00:00
lhk229 d7a09276e6 合并 origin/master 到 feat/design_agent_simple
- 合入 AGC 官方 LLM Router 账号链路与流式联网输出(#242)
- 新增后台模型别名与对话选择能力及 AGC 模型目录
- 解决 ProjectSupervisorView.tsx 与 decision-log.md 冲突
2026-09-07 03:07:05 +00:00
lhk229 7d54aa6552 放宽策划V2修订续跑合同
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / Backend tests (pull_request) Failing after 15s
Project CI / Frontend tests (pull_request) Successful in 3m10s
Project CI / Native shell tests (pull_request) Successful in 17m23s
允许审批修改后的 continuation 继续问询或直接提交完整 GDD

明确继承已确认问答与问询计数且不新增意图识别调用
2026-09-06 09:49:14 +00:00
lhk229 49d814fec1 清理策划V2已退役停止状态
Project CI / Repository checks (pull_request) Successful in 3m34s
Project CI / Frontend tests (pull_request) Successful in 4m21s
Project CI / Backend tests (pull_request) Successful in 7m56s
Project CI / Native shell tests (pull_request) Successful in 20m50s
删除 Planning V2 认领逻辑中的 stopped 死分支。
同步技术方案中的状态枚举和状态转移描述。
2026-09-06 08:43:07 +00:00
lhk229 4efa39420f 清理策划V2无效停止状态
Project CI / Repository checks (pull_request) Successful in 2m31s
Project CI / Frontend tests (pull_request) Successful in 2m54s
Project CI / Backend tests (pull_request) Successful in 6m2s
Project CI / Native shell tests (pull_request) Successful in 18m15s
移除没有生产写入路径的 stopped 会话状态

同步清理前端恢复状态映射
2026-09-05 12:51:14 +00:00
lhk229 90eae50dd3 修复策划V2错误结果展示
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
展示后端返回的错误回合结果

在缺少会话错误摘要时回填运行时错误
2026-09-05 12:29:18 +00:00
lhk229 e87cb98d3e Merge branch 'master' into feat/design_agent_simple
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
2026-09-05 12:17:40 +00:00
lhk229 b84c9d4e45 修复策划V2不可变文件失败残留
失败时清理已创建的空文件或截断文件

保留已有文件的幂等与内容冲突校验
2026-09-05 12:17:04 +00:00
lhk229 267c085b57 澄清策划V2流式事件契约
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
明确 Provider 流式传输属于底层实现能力

明确 text_delta 是 Runtime 内部事件而非前端业务事件

明确用户可见结果以结构化工具调用为准

补充文档措辞约束避免误读
2026-09-05 11:59:47 +00:00
lhk229 d3a7070bb4 Merge branch 'feat/design_agent_simple' of ssh://genarrative-station:2222/GenarrativeAI/Genarrative into feat/design_agent_simple
Project CI / Frontend tests (pull_request) Successful in 3m20s
Project CI / Repository checks (pull_request) Successful in 2m51s
Project CI / Backend tests (pull_request) Successful in 6m11s
Project CI / Native shell tests (pull_request) Successful in 21m46s
2026-09-05 11:49:35 +00:00
lhk229 6cc70af0a5 Merge branch 'master' into feat/design_agent_simple
Project CI / Repository checks (pull_request) Successful in 2m16s
Project CI / Frontend tests (pull_request) Successful in 3m0s
Project CI / Backend tests (pull_request) Successful in 7m26s
Project CI / Native shell tests (pull_request) Successful in 21m24s
2026-09-05 19:49:29 +08:00
lhk229 f7b15f124f 修复策划V2澄清历史完整展示
统一解析回合结果与持久化历史中的问题结构

恢复历史消息中的问题正文、选项标签和选项说明
2026-09-05 11:38:40 +00:00
lhk229 2d7226dad8 修复策划V2修改意见撞项目锁
V2 审批、续跑、落盘、失败投影和 GDD 认领改为完整等待窗口
V2 hydrate 改为短窗口等待
前端 V2 hydrate 忽略瞬时锁争用
补充审批、续跑、hydrate 锁等待测试
同步决策、踩坑和技术方案
2026-09-05 11:28:37 +00:00
lhk229 4127686e18 修复新建项目锁误触发 Windows UAC
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / Backend tests (pull_request) Failing after 16s
Project CI / Frontend tests (pull_request) Successful in 2m39s
Project CI / Native shell tests (pull_request) Successful in 17m50s
新建 sidecar 改为本进程收紧 DACL,不再因继承 ACE 自动提权。
项目锁先写入并释放独占句柄后再 harden,回读内容校验,不再对这把新锁走 prepare_for_read。
提权 ArgumentList 改为一条按 Windows 规则加引号的字符串,避免含空格路径被拆开。
补充含空格项目根取锁与 quoted ArgumentList 定向测试。
同步 ACL 提权边界、决策记录和排障记录。
2026-09-05 10:53:15 +00:00
lhk229 1019403f40 修复策划GDD修改后自动续跑
审批 revise 后继续同一 V2 Session

避免修订意见重复写入历史

保留独立修订回合身份
2026-09-05 09:41:20 +00:00
lhk229 bd8e33eb60 禁用策划V2失败重试入口
Project CI / Frontend tests (pull_request) Successful in 2m53s
Project CI / Native shell tests (pull_request) Successful in 18m26s
Project CI / Repository checks (pull_request) Successful in 2m29s
Project CI / Backend tests (pull_request) Successful in 6m6s
Provider 失败时只展示错误信息

避免误调用通用 Supervisor 重试链路
2026-09-05 09:11:05 +00:00
lhk229 c03d1ef6fc 修复策划Provider失败后的恢复状态
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
将 provider_failed 投影为可恢复的 failed 状态

让策划工作台显示重新启动入口
2026-09-05 09:04:15 +00:00
lhk229 d47928ceba 修复策划V2问询交互与历史展示
Project CI / Repository checks (pull_request) Successful in 44m58s
Project CI / Frontend tests (pull_request) Successful in 45m27s
Project CI / Backend tests (pull_request) Failing after 48m47s
Project CI / Native shell tests (pull_request) Failing after 5m21s
回答提交后立即收起当前问询卡

保留选项回答和完整选项描述到历史

补充 GDD 历史条目的一句话与决策摘要
2026-09-05 08:26:31 +00:00
lhk229 b1456d9f11 修正策划V2流式交互契约
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
明确用户交互以工具调用结果为准

取消逐 delta 投影的业务契约要求

同步技术方案与长期决策记录
2026-09-05 08:17:04 +00:00
lhk229 27246fbc5e 收口P4并关闭旧版策划入口
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Frontend tests (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-supervisor-plan 来源统一返回退役错误

避免旧入口启动 Runtime 或 Provider

同步收口 P4 验收状态与最简 P5 方案

记录 V1 不迁移且历史文件只读保留
2026-09-05 08:10:26 +00:00
lhk229 ae700de1dd 修复 Rust 文件格式
Project CI / Repository checks (pull_request) Successful in 3m21s
Project CI / Frontend tests (pull_request) Successful in 4m4s
Project CI / Backend tests (pull_request) Successful in 7m38s
Project CI / Native shell tests (pull_request) Successful in 18m42s
删除 planning_session_v2.rs 末尾多余空行

通过 rustfmt、编码检查和 diff 检查
2026-09-05 07:50:46 +00:00
lhk229 573940f1ad 删除多余的测试
Project CI / Repository checks (pull_request) Failing after 52s
Project CI / Backend tests (pull_request) Successful in 5m53s
Project CI / Frontend tests (pull_request) Successful in 3m16s
Project CI / Native shell tests (pull_request) Successful in 17m5s
2026-09-05 07:27:44 +00:00
lhk229 861ed14a6f 补充策划问询不对称设计说明
明确模型侧 3 轮策略与 Runtime 侧 8 个问题门禁的分层语义

补充自动评测和代码评审口径,说明两者有意不对称
2026-09-05 07:07:31 +00:00
lhk229 eabd8f393a 将策划决策轮次交由Runtime管理
Project CI / Repository checks (pull_request) Successful in 4m24s
Project CI / Frontend tests (pull_request) Successful in 20m53s
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Failing after 13m28s
移除Provider输入中的 decisions.round 字段

由Runtime按决策顺序生成持久化轮次

放宽GDD实际门禁并同步模型数量上限
2026-09-05 06:07:32 +00:00
lhk229 250360a40a 放宽GDD一句话概念校验范围
删除决策首项必须为 confirmed 且 round=0 的阻断校验

将 Runtime 的 oneLiner 实际接受范围调整为 10~160

将模型 schema 提示范围调整为 25~90 并记录有意不对称设计

修复 Planning V2 系统提示词参数占位符
2026-09-05 05:00:32 +00:00
lhk229 d1a8bed685 调整策划问询轮次提示
Project CI / Repository checks (pull_request) Successful in 2m27s
Project CI / Frontend tests (pull_request) Successful in 2m59s
Project CI / Native shell tests (pull_request) Failing after 6m11s
Project CI / Backend tests (pull_request) Successful in 5m58s
原型与生产 prompt 统一明确最多提问三轮

允许信息足够时提前出稿并补充重玩动力优先级

不改 Runtime 工作流、schema、校验和持久化逻辑
2026-09-04 14:22:14 +00:00
lhk229 1b764fd878 补充策划 Provider 诊断持久化
保存 Planning V2 每次 Provider 尝试的请求、响应和解析分类产物

诊断写入不参与工作流、恢复、重试或 GDD 判断

同步 Planning V2 技术方案与项目决策记录
2026-09-04 13:22:34 +00:00
lhk229 9a692ec543 同步策划 GDD 字段提示
将生产 V2 的 GDD 描述与原型统一为按字段填全且不增删改名

不改工作流、schema 或解析逻辑
2026-09-04 12:54:32 +00:00
lhk229 0c7ddf26db 调整策划 V2 决定 ID 由 Runtime 分配
删除 plan_submit_gdd Provider schema 中的 decisions[].id 和 prototypeValidationItems[].id

由 Runtime 生成 initial-request 与后续决定 ID,并绑定原型验证项

同步更新 Planning V2 技术方案和项目决策记录
2026-09-04 12:15:45 +00:00
lhk229 c454b22428 Merge branch 'master' into feat/design_agent_simple
Project CI / Repository checks (pull_request) Successful in 3m27s
Project CI / Frontend tests (pull_request) Successful in 4m16s
Project CI / Backend tests (pull_request) Successful in 7m21s
Project CI / Native shell tests (pull_request) Successful in 18m19s
2026-09-04 18:48:14 +08:00
lhk229 ca62243628 修复策划 V2 孤儿 GDD 无法恢复
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
把 gdd.vN.json 创建成功当作提交点

persist、hydrate 与回合启动认领下一连续版本并补投影

重试不再用新 UUID 覆盖同一版本

补充孤儿认领与下一版本分配测试
2026-09-04 10:47:17 +00:00
lhk229 c1d967b17d 将策划 V2 输出从正文 JSON 改为协议工具
Project CI / Backend tests (pull_request) Failing after 14s
Project CI / Repository checks (pull_request) Failing after 14s
Project CI / Native shell tests (pull_request) Successful in 17m12s
Project CI / Frontend tests (pull_request) Successful in 3m43s
挂 plan_ask_question / plan_submit_gdd,tool_choice 固定 auto

删除正文 JSON 解析、骨架提示词和入参 schemaVersion 必填

形状改由工具 schema 承担,既有校验门禁与落盘 plan-gdd.v2 不变

同步技术方案、决策记录和 DeepSeek thinking 排障
2026-09-04 10:10:50 +00:00
lhk229 67c2f85743 精简策划 V2 提示词为形状和策略
Project CI / Backend tests (pull_request) Failing after 21s
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / Frontend tests (pull_request) Successful in 2m54s
Project CI / Native shell tests (pull_request) Successful in 19m25s
system prompt 只保留问询/GDD 骨架、同级字段边界和一行易错数量范围

去掉逐字段长度清单和 V1 编排残留说明,校验与重试路径不变

同步 Runtime V2 技术方案和项目决策记录
2026-09-04 08:04:14 +00:00
lhk229 45568797f9 将策划 V2 既有阻断校验回灌给 Provider
把当前 question/GDD 硬校验契约写入 V2 system prompt,不扩大校验范围或新增门禁

校验失败的一次重试改为列出具体阻断原因并要求逐项修复

同步 Runtime V2 技术方案和项目决策记录
2026-09-04 07:40:36 +00:00
lhk229 f35ec812d9 完善策划 V2 人工测试与推断语义
修复做方案首轮额外命名等待、处理中反馈和重复错误展示

补全 GDD 输出字段提示,避免模型生成非法 decisions 字段

统一 V2 assumption_pending 与 agent_inferred 语义并同步核心闭环问询策略

保持旧 Supervisor/V1 的 default_pending 与 default 语义不变

更新 Runtime V2 技术方案和项目决策记录
2026-09-03 13:15:14 +00:00
lhk229 64105f8259 Merge branch 'master' into feat/design_agent_simple
Project CI / Repository checks (pull_request) Successful in 2m18s
Project CI / Frontend tests (pull_request) Successful in 2m59s
Project CI / Backend tests (pull_request) Successful in 7m37s
Project CI / Native shell tests (pull_request) Successful in 20m49s
2026-09-03 11:42:40 +00:00
lhk229 eecd097117 Merge branch 'master' into feat/design_agent_simple
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
2026-09-03 19:32:23 +08:00
lhk229 059808d9e8 接入策划会话 Runtime V2 入口与界面
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
做方案入口改用 start/continue/decide_planning_session_v2 命令

新增 V2 Session、问题、GDD 和审批结果的前端适配层

接通 hydrate 会话历史、流式回复、问询卡、审批卡和处理耗时展示

保持做游戏、做素材及无 V2 旧项目读取路径不变

同步策划入口回归测试、Runtime V2 技术方案和项目决策记录
2026-09-03 11:29:55 +00:00
lhk229 4d33553466 Merge branch 'master' into feat/design_agent_simple
Project CI / Repository checks (pull_request) Successful in 3m26s
Project CI / Frontend tests (pull_request) Successful in 4m1s
Project CI / Backend tests (pull_request) Successful in 6m33s
Project CI / Native shell tests (pull_request) Failing after 3m40s
2026-09-03 10:14:51 +00:00
lhk229 12da570d28 策划 Agent Runtime V2 完成 P2 产物闭环
新增单 Agent GDD 策略、版本产物和审批命令

补齐问询计数、上下文进度和输出校验边界

注册 Planning V2 Tauri 命令并纳入私有产物路径

更新 Runtime V2 技术方案与项目决策记录
2026-09-03 10:04:48 +00:00
lhk229 d70f635eae Merge remote-tracking branch 'origin/master' into feat/design_agent_simple
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
# Conflicts:
#	docs/project-memory/shared-memory/decision-log.md
2026-09-03 08:41:57 +00:00
lhk229 e38edfb446 冻结策划会话 Runtime V2 P0 合同
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
固定 Session、消息、回合结果、GDD 产物和审批记录的 V2 schema。

固定四个 V2 command、输入归一化和 questionLimit=8 语义。

固定 Provider adapter、ContextBuilder、能力快照及未来 MCP/Skill 扩展边界。

固定旧 Supervisor 链路 legacy-cutover 封存和未完成会话强制失败规则。

标记 P0 完成并同步项目决策记录。
2026-09-03 07:25:19 +00:00
lhk229 044c8cfadf 补充策划会话 Runtime V2 接入与旧链路退役方案
新增单 Agent PlanningSessionRuntime V2 的目标架构、状态、持久化和未来 MCP/Skill 兼容边界。

补充 P0-P5 阶段任务拆分、阶段目标、依赖和验收条件。

补充问询上限、Provider 失败、审批、恢复和旧链路强制退役的 BDD 场景。

明确 V2 切换时未完成旧 Supervisor 会话统一投影为 legacy_retired 失败,历史文件只读保留。

同步 docs README、文档地图和项目决策记录。
2026-09-03 07:05:11 +00:00
177 changed files with 12506 additions and 35724 deletions
@@ -16,8 +16,5 @@
"maxRetries": 2,
"retryBackoffMs": 500
},
"agentLlm": {},
"planning": {
"capabilityEnabled": true
}
"agentLlm": {}
}
-2
View File
@@ -19,8 +19,6 @@
"config": "node scripts/game-creator-config-wizard.mjs",
"test:chat": "node scripts/agent-swarm-test-chat.mjs --task \"制作一个可直接试玩的原创植物塔防小游戏:玩家选择并放置原创守卫阻挡敌人,完成波次后可以进入下一关并重新开始。主题、单位名称与视觉语言必须原创,不使用任何现有游戏角色、单位名、Logo 或受保护视觉语言。请自主完成正式产物、静态检查和双视口试玩验证。\" --no-open",
"test:chat:manual": "node scripts/agent-swarm-test-chat.mjs",
"test:plan": "node scripts/agent-swarm-test-chat.mjs --plan --task \"我想做一款原创横版像素解谜小游戏,主角是一个能操控自己影子的小机器人,影子可以变成平台和开关。请完成立项策划并给出 Fast GDD。主题、角色名与视觉语言必须原创,不使用任何现有游戏角色、名称、Logo 或受保护视觉语言。\"",
"test:plan:manual": "node scripts/agent-swarm-test-chat.mjs --plan",
"agent-run": "node scripts/run-cli-with-config.mjs --agent-run",
"agent-run:smoke": "node scripts/smoke-agent-run-local-provider.mjs",
"agent-runtime:real-e2e": "node scripts/agent-runtime-real-e2e.mjs",
@@ -36,8 +36,6 @@ export const ungeneratedGameEntryMarker =
'还没有生成游戏。回到聊天输入创意并确认生成后';
export const defaultRealSwarmTestTask =
'制作一个可直接试玩的原创植物塔防小游戏:玩家选择并放置原创守卫阻挡敌人,完成波次后可以进入下一关并重新开始。主题、单位名称与视觉语言必须原创,不使用任何现有游戏角色、单位名、Logo 或受保护视觉语言。请自主完成正式产物、静态检查和双视口试玩验证。';
export const defaultRealSwarmPlanTask =
'我想做一款原创横版像素解谜小游戏,主角是一个能操控自己影子的小机器人,影子可以变成平台和开关。请完成立项策划并给出 Fast GDD。主题、角色名与视觉语言必须原创,不使用任何现有游戏角色、名称、Logo 或受保护视觉语言。';
export const swarmTurnReportPrefix = '[turn.report] ';
export const swarmTurnReportSchema = 'game-creator-swarm-turn-report.v1';
@@ -140,15 +138,10 @@ export const usage = `用法:
--keep-project 保留自动创建的一次性项目
--no-open 手工模式启动预览但不自动打开浏览器
--task <需求> 通过 manual 入口非交互提交自定义需求
--plan 走「做方案」立项策划入口,不做游戏,不做产物验收和试玩
--timeout-minutes <分钟> 设置本次执行期限;自动任务默认 50 分钟,--plan 默认 6 分钟,手工模式默认不限时
--timeout-minutes <分钟> 设置本次执行期限;自动任务默认 50 分钟,手工模式默认不限时
--dry-run 只检查目录发现和项目准备,不启动 LLM
-h, --help 显示帮助
环境变量:
AGC_PLAN_GDD_DECISION 审批卡自动应答动作,默认 approverevise/reject 必须
同时用 AGC_PLAN_GDD_COMMENT 给出真实修改意见
AGC_PLAN_GDD_COMMENT revise/reject 的意见原文`;
`;
function readOptionValue(args, index, option) {
const value = args[index + 1]?.trim();
@@ -177,7 +170,6 @@ export function parseSwarmTestArguments(args) {
keepProject: false,
openBrowser: true,
task: null,
plan: false,
timeoutMinutes: null,
dryRun: false,
help: false,
@@ -202,8 +194,6 @@ export function parseSwarmTestArguments(args) {
if (task.length > 4_000) throw new Error('--task 不能超过 4000 字符');
options.task = task;
index += 1;
} else if (argument === '--plan') {
options.plan = true;
} else if (argument === '--timeout-minutes') {
if (options.timeoutMinutes !== null) {
throw new Error('--timeout-minutes 只能指定一次');
@@ -222,16 +212,11 @@ export function parseSwarmTestArguments(args) {
}
export function shouldStartPersistentPreview(options) {
// 立项策划链路只出 GDD,没有可试玩产物,任何模式都不该起预览。
return !options.task && !options.plan;
return !options.task;
}
export function resolveSwarmTestTimeoutMs(options) {
// 立项策划的设计目标是五分钟出方案,给一分钟余量;再久就是卡住了,早失败
// 比让 harness 空等更有用。做游戏那条链路的 50 分钟不变。
const planMinutes = options.plan ? 6 : null;
const minutes =
options.timeoutMinutes ?? planMinutes ?? (options.task ? 50 : null);
const minutes = options.timeoutMinutes ?? (options.task ? 50 : null);
return minutes === null ? null : minutes * 60_000;
}
@@ -979,25 +964,12 @@ export function swarmAutoPilotShouldCloseInput(output, promptsAfterSubmit) {
return swarmAutoPilotSitsAtPrompt(output) && promptsAfterSubmit >= 1;
}
// GDD 审批位不能等 CLI 退出之后再处理:Run 停在这里时状态是 waiting-for-user-input
// 而 swarm CLI 恰好把这个状态算作「本轮还在跑」,turn 永远不 settleCLI 也就永远
// 不退出。所以审批必须在 CLI 还活着的时候并发做完,让 Run 自己继续跑到收束。
// 这一句是 PlanGddCompletionBlockerKind::AwaitingApprovalDecision 专有的投影文案,
// 另外三个 blocked 子状态都不会打出它;即便认错了,真正的判据也是随后那次
// --plan-gdd-status,没有待决定审批时不会有任何写入。
const planGddApprovalWaitPattern = /等待 Fast GDD 审批决定/u;
export function swarmOutputAwaitsPlanGddApproval(line) {
return planGddApprovalWaitPattern.test(line);
}
async function runTaskCargo(
cliArguments,
task,
setActiveChild,
timeoutMs,
autoPilot = false,
onPlanGddApprovalWait = null,
) {
const child = spawnChild(cargoCommand, buildCargoCliArguments(cliArguments), {
stdio: ['pipe', 'pipe', 'inherit'],
@@ -1009,25 +981,6 @@ async function runTaskCargo(
let taskSubmitted = false;
let promptsSeen = 0;
let sittingAtPrompt = false;
let planGddApproval = null;
let planGddApprovalError = null;
let planGddApprovalStarted = false;
let planGddApprovalPromise = null;
const startPlanGddApproval = () => {
planGddApprovalStarted = true;
console.log(
`[自动审批] 检测到 Fast GDD 审批位,正在提交 ${resolvePlanGddAutoDecision().action}`,
);
planGddApprovalPromise = onPlanGddApprovalWait()
.then((value) => {
planGddApproval = value;
})
.catch((error) => {
planGddApprovalError = error;
// 审批没成的话 Run 会一直停在等待位,干等到超时只会把真正的原因埋掉。
void terminateChildTree(child).catch(() => {});
});
};
child.stdout.setEncoding('utf8');
child.stdout.on('data', (chunk) => {
process.stdout.write(chunk);
@@ -1040,13 +993,6 @@ async function runTaskCargo(
reportLines.push(normalizedLine);
settled = true;
}
if (
onPlanGddApprovalWait &&
!planGddApprovalStarted &&
swarmOutputAwaitsPlanGddApproval(normalizedLine)
) {
startPlanGddApproval();
}
}
if (!autoPilot || child.stdin.writableEnded) return;
const atPrompt = swarmAutoPilotSitsAtPrompt(pendingLine);
@@ -1085,12 +1031,9 @@ async function runTaskCargo(
if (normalizedPendingLine.startsWith(swarmTurnReportPrefix)) {
reportLines.push(normalizedPendingLine);
}
await planGddApprovalPromise;
if (planGddApprovalError) throw planGddApprovalError;
return {
...result,
turnReportOutput: reportLines.join('\n'),
planGddApproval,
};
} finally {
setActiveChild(null);
@@ -1780,196 +1723,6 @@ export async function validateSwarmProjectArtifacts(projectPath, options) {
return inspection;
}
// 这四条路径的权威定义都在 Rust 侧 `planning_storage.rs``PLAN_SESSION_PATH`、
// `PLAN_GDD_INDEX_PATH`、`PLAN_STORAGE_ROOT`、`PLAN_FAST_GDD_PATH`)。跨语言没有共享
// 常量的通道,改路径时要连同 `GddApprovalCard.tsx` 一起动。
export const planningOutputPaths = [
'.agent/planning/session.json',
'.agent/planning/index.json',
'.agent/planning/pending.json',
'game/fast_gdd.md',
];
export async function inspectPlanningOutputs(projectPath) {
const outputs = [];
for (const relativePath of planningOutputPaths) {
const absolutePath = path.join(projectPath, ...relativePath.split('/'));
const metadata = await lstat(absolutePath).catch((error) => {
if (error?.code === 'ENOENT') return null;
throw error;
});
outputs.push({
path: relativePath,
exists: Boolean(metadata?.isFile()),
bytes: metadata?.isFile() ? metadata.size : 0,
});
}
return outputs;
}
async function reportPlanningOutputs(projectPath) {
const outputs = await inspectPlanningOutputs(projectPath);
console.log('\n立项策划产物:');
for (const output of outputs) {
console.log(
output.exists
? ` [有] ${output.path}${output.bytes} 字节)`
: ` [无] ${output.path}`,
);
}
}
const planGddApprovalTimeoutMs = 60_000;
export const planGddStatusOutputPrefix = 'planGddStateJson=';
export const planGddDecisionOutputPrefix = 'planGddDecisionJson=';
function parsePrefixedJsonLine(output, prefix, label) {
const line = output
.split('\n')
.map((value) => (value.endsWith('\r') ? value.slice(0, -1) : value))
.find((value) => value.startsWith(prefix));
if (!line) throw new Error(`${label}缺少 ${prefix} 输出`);
try {
return JSON.parse(line.slice(prefix.length));
} catch (error) {
throw new Error(`解析${label}失败:${error.message}`);
}
}
export function parsePlanGddStatusOutput(output) {
return parsePrefixedJsonLine(
output,
planGddStatusOutputPrefix,
'Fast GDD 审批状态',
);
}
export function parsePlanGddDecisionOutput(output) {
return parsePrefixedJsonLine(
output,
planGddDecisionOutputPrefix,
'Fast GDD 审批回执',
);
}
// 审批卡是这条链路唯一的人类判据,所以自动应答默认只投 approve,且只在投影确实有
// 一张待决定审批时出手。revise/reject 需要一段真实的修改意见,让机器编一段等于把
// 判据换成噪声——所以那两条分支只在跑的人自己用 AGC_PLAN_GDD_COMMENT 给出意见时
// 才走。手工调 --plan-gdd-decide 也能达到同样效果,但那要求 plan 根 run 仍然活着,
// 而它恰好是本进程持有的 CLI 子进程。
export function planGddAutoApprovalIsPending(state) {
return Boolean(state?.pendingApproval);
}
export function resolvePlanGddAutoDecision(env = process.env) {
const action = (env.AGC_PLAN_GDD_DECISION ?? 'approve').trim();
if (!['approve', 'revise', 'reject'].includes(action)) {
throw new Error('AGC_PLAN_GDD_DECISION 只能是 approve / revise / reject');
}
const comment = (env.AGC_PLAN_GDD_COMMENT ?? '').trim();
if (action === 'approve') return { action, comment: null };
if (!comment) {
throw new Error(
`${action} 必须同时设 AGC_PLAN_GDD_COMMENT 提供真实修改意见`,
);
}
return { action, comment };
}
async function settlePlanGddApproval(
projectPath,
runtimeConfigPath,
setActiveChild,
) {
const readStatus = async () => {
const result = await runCapturedCargo(
['--config-dir', runtimeConfigPath, '--plan-gdd-status', projectPath],
setActiveChild,
{
timeoutMs: planGddApprovalTimeoutMs,
label: 'Fast GDD 审批状态查询',
},
);
if (result.code !== 0 || result.signal) {
throw new Error(
`读取 Fast GDD 审批状态失败:${result.stderr.trim() || result.stdout.trim()}`,
);
}
return parsePlanGddStatusOutput(result.stdout);
};
const before = await readStatus();
if (!planGddAutoApprovalIsPending(before)) {
return { decided: false, state: before };
}
const { action, comment } = resolvePlanGddAutoDecision();
const decision = await runCapturedCargo(
[
'--config-dir',
runtimeConfigPath,
'--plan-gdd-decide',
projectPath,
action,
...(comment === null ? [] : ['--stdin']),
],
setActiveChild,
{
timeoutMs: planGddApprovalTimeoutMs,
label: 'Fast GDD 审批决定',
stdin: comment,
},
);
if (decision.code !== 0 || decision.signal) {
throw new Error(
`提交 Fast GDD 审批决定失败:${decision.stderr.trim() || decision.stdout.trim()}`,
);
}
const receipt = parsePlanGddDecisionOutput(decision.stdout);
// 回执落盘和唤醒后台任务是两件事:decide 命令把唤醒失败降级成 recoveryPending
// 于是审批已经生效、Run 却仍停在 waiting-for-user-input。实测就是这样——只有
// 补一次 --agent-resume 才会重新起 turn。这是仓库自己给这个状态定义的恢复动作。
let recovered = false;
if (receipt.recoveryPending) {
const resume = await runCapturedCargo(
['--config-dir', runtimeConfigPath, '--agent-resume', projectPath],
setActiveChild,
{
timeoutMs: planGddApprovalTimeoutMs,
label: 'Fast GDD 审批后恢复后台任务',
},
);
if (resume.code !== 0 || resume.signal) {
throw new Error(
`审批已提交但恢复后台任务失败:${resume.stderr.trim() || resume.stdout.trim()}`,
);
}
recovered = true;
}
return { decided: true, receipt, recovered, state: await readStatus() };
}
async function reportPlanGddApproval(approval) {
const { state } = approval;
console.log('\nFast GDD 审批:');
if (!approval.decided) {
console.log(` [无待决定审批] 当前投影状态=${state.state}`);
return;
}
console.log(
` [已决定 ${approval.receipt.decisionRef.action}] outcome=${approval.receipt.outcome} v${approval.receipt.decisionRef.version} 投影状态=${state.state}`,
);
if (approval.recovered) {
console.log(
' [已恢复] 审批回执的 recoveryPending 由一次 --agent-resume 收口',
);
}
if (state.session) {
console.log(
` 澄清轮次=${state.session.clarificationRound} 返工深度=${state.session.repairDepth} phase=${state.session.phase}`,
);
}
}
export async function hasConfiguredEditorApiKey(configDir) {
let configured = false;
for (const fileName of [configFileName, localConfigFileName]) {
@@ -2122,13 +1875,7 @@ export async function runSwarmTestChat(options) {
const setActiveChild = (child) => {
activeChild = child;
};
// GDD 审批要和 swarm CLI 并发跑,两者不能共用 activeChild 这一个槽位:审批子进程
// 结束时的 setActiveChild(null) 会把 CLI 从槽里抹掉,Ctrl-C 就杀不到它了。
const concurrentChildren = new Set();
const setConcurrentChild = (child) => {
if (child) concurrentChildren.add(child);
else concurrentChildren.clear();
};
const stopRequested = () => receivedSignal !== null;
const handleSignal = (signal) => {
const repeatedSignal = receivedSignal !== null;
@@ -2206,11 +1953,10 @@ export async function runSwarmTestChat(options) {
);
}
console.log('LLM 配置已就绪。');
const requirementNoun = options.plan ? '立项策划需求' : '游戏需求';
console.log(
options.task
? `已提交一条非交互${requirementNoun},正在等待 Swarm 自主完成。\n`
: `输入一条${requirementNoun}并回车;提交后按 Ctrl+D,让 Swarm 自主完成。\n`,
? '已提交一条非交互游戏需求,正在等待 Swarm 自主完成。\n'
: '输入一条游戏需求并回车;提交后按 Ctrl+D,让 Swarm 自主完成。\n',
);
phase = 'chat';
@@ -2220,8 +1966,7 @@ export async function runSwarmTestChat(options) {
runtimeConfig.path,
'--swarm-chat',
'--init',
// 做方案链路只能跑 standard 档,后端对 plan + autonomous 是硬否决。
options.plan ? '--plan' : '--autonomous-game-build',
'--autonomous-game-build',
project.path,
];
let chat;
@@ -2234,15 +1979,6 @@ export async function runSwarmTestChat(options) {
timeoutDeadline === null
? null
: Math.max(1, timeoutDeadline - Date.now()),
options.plan,
options.plan
? () =>
settlePlanGddApproval(
project.path,
runtimeConfig.path,
setConcurrentChild,
)
: null,
)
: await runInteractiveCargo(chatArguments, setActiveChild);
} catch (error) {
@@ -2258,32 +1994,6 @@ export async function runSwarmTestChat(options) {
if (options.task) {
turnReport = parseSettledSwarmTurnReport(chat.turnReportOutput);
}
if (options.plan) {
// 立项策划不出游戏产物,正式验收在 GDD 审批卡上;这里只报告落盘情况,
// 是否收束已经由 CLI 的退出码判过了。
// 自动任务档的审批已经在 CLI 运行期间并发做完了;手工档(人自己敲 Ctrl+D
// 退出)没有那次触发,退出后补一次,没有待决定审批时它是只读的。
phase = 'plan-approval';
const approval =
chat.planGddApproval ??
(await settlePlanGddApproval(
project.path,
runtimeConfig.path,
setConcurrentChild,
));
if (receivedSignal) break session;
phase = 'plan-report';
await reportPlanGddApproval(approval);
await reportPlanningOutputs(project.path);
phase = 'complete';
console.log(
approval.decided
? '\n立项策划链路已收束:Fast GDD 已批准,策划产物见上方清单。'
: '\n立项策划链路已收束:Run 正常结束但没有待决定审批,策划产物见上方清单。',
);
break session;
}
phase = 'artifact-validation';
const requireEditorImages = await hasConfiguredEditorApiKey(
runtimeConfig.path,
);
@@ -1705,10 +1705,16 @@ if (
runtimeConfigSetupStart === -1 ||
runtimeConfigSetupEnd === -1 ||
!runtimeConfigSetupSource.includes('sanitize_diagnostic_message(') ||
!runtimeConfigSetupSource.includes('append_bounded_diagnostic_line(') ||
!runtimeConfigSetupSource.includes('setup_log.fail(') ||
!runtimeConfigSetupSource.includes(
'startup.appdata.configure.failed details={details}',
)
) ||
!tauriHandlerSource.includes('impl StartupLogSlot {') ||
!tauriHandlerSource.includes('append_bounded_diagnostic_line(&path, line)') ||
!tauriHandlerSource.includes(
'self.append(line);\n show_startup_error_dialog(self.path().as_deref());',
) ||
!tauriHandlerSource.includes('early_startup_log_path(')
) {
throw new Error(
'AI game creator setup must configure the runtime AppData directory and log sanitized setup failures',
@@ -722,7 +722,7 @@ function runAgent() {
stderr += chunk.toString();
});
child.on('error', reject);
child.on('close', (code) => {
child.on('close', (code, signal) => {
const output = `${stdout}${stderr}`;
if (previewReadError) {
reject(previewReadError);
@@ -740,13 +740,24 @@ function runAgent() {
previewDom,
});
} else {
reject(new Error(output || `agent run exited with ${code}`));
reject(
new Error(
`agent run failed: exitCode=${code}, signal=${signal ?? 'none'}\n` +
`stderr tail (last 8000 characters):\n${stderr.slice(-8000)}\n` +
`stdout tail (last 4000 characters):\n${stdout.slice(-4000)}`,
),
);
}
});
});
}
async function seedLocalAsset() {
await fs.mkdir(path.join(projectRoot, 'game'), { recursive: true });
await fs.writeFile(
path.join(projectRoot, 'game/index.html'),
'<!doctype html><html lang="zh-CN"><meta charset="UTF-8"><body>还没有生成游戏</body></html>',
);
await fs.mkdir(path.join(projectRoot, 'assets/uploads'), { recursive: true });
await fs.mkdir(path.join(projectRoot, '.agent'), { recursive: true });
await seedConversationContext();
@@ -1,10 +1,16 @@
import { spawn } from 'node:child_process';
import { spawn, spawnSync } from 'node:child_process';
import { existsSync, readdirSync, readFileSync } from 'node:fs';
import http from 'node:http';
import net from 'node:net';
import { resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import {
normalizeWindowsPath,
parseWindowsProcessSnapshot,
stopWindowsProcessTree,
stopWindowsWorktreeProcesses,
} from '../../../scripts/dev-windows-process.mjs';
import {
agcVitePortEnvKey,
readAgcDevEndpoint,
@@ -15,6 +21,10 @@ import {
const appRoot = fileURLToPath(new URL('..', import.meta.url));
const repoRoot = resolve(appRoot, '../..');
const devStackStatePath = resolve(repoRoot, '.app/dev-stack.json');
const apiServerExePath = resolve(
repoRoot,
'server-rs/target/debug/api-server.exe',
);
const defaultApiTarget =
process.env.RUST_SERVER_TARGET || 'http://127.0.0.1:8082';
const backendDatabase = 'genarrative-game-creator-dev';
@@ -160,19 +170,184 @@ function readBackendServiceFailure(
return null;
}
function urlPort(url) {
try {
const port = Number(new URL(url).port);
return Number.isInteger(port) && port > 0 ? port : 0;
} catch {
return 0;
}
}
// 读取端口当前真正的监听进程身份。返回 null 表示探测本身不可用(例如缺少
// Get-NetTCPConnection),此时调用方必须退化为旧行为,不能让本地启动直接失败。
function readWindowsPortOwnerIdentities(
ports,
{ spawnImpl = spawnSync, env = process.env } = {},
) {
const uniquePorts = [...new Set(ports.filter((port) => port > 0))];
if (uniquePorts.length === 0) {
return null;
}
const command = [
'$ErrorActionPreference = "SilentlyContinue"',
'$ports = ($env:GENARRATIVE_QUERY_PORTS -split ",") | Where-Object { $_ }',
'$result = @()',
'foreach ($port in $ports) {',
' $connection = Get-NetTCPConnection -State Listen -LocalPort ([int]$port) -ErrorAction SilentlyContinue | Select-Object -First 1',
' if (-not $connection) { continue }',
' $owner = Get-CimInstance Win32_Process -Filter ("ProcessId=" + $connection.OwningProcess) -ErrorAction SilentlyContinue',
' $result += [pscustomobject]@{ port = [int]$port; processId = [int]$connection.OwningProcess; name = $owner.Name; executablePath = $owner.ExecutablePath; commandLine = $owner.CommandLine }',
'}',
'ConvertTo-Json -InputObject @($result) -Compress',
].join('\n');
const result = spawnImpl(
'powershell.exe',
['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', command],
{
encoding: 'utf8',
env: { ...env, GENARRATIVE_QUERY_PORTS: uniquePorts.join(',') },
maxBuffer: 8 * 1024 * 1024,
},
);
if (result?.error || result?.status !== 0) {
return null;
}
const owners = new Map();
for (const entry of parseWindowsProcessSnapshot(result.stdout)) {
const port = Number(entry?.port);
if (Number.isInteger(port) && port > 0) {
owners.set(port, entry);
}
}
return owners;
}
function isWorktreeApiServerOwner(
owner,
{ expectedExePath = apiServerExePath } = {},
) {
if (!owner) {
return false;
}
const expected = normalizeWindowsPath(expectedExePath);
const actual = normalizeWindowsPath(owner.executablePath);
return Boolean(expected) && actual === expected;
}
function isWorktreeSpacetimeOwner(
owner,
{ expectedDataDir = backendSpacetimeDataDir } = {},
) {
if (!owner) {
return false;
}
const expected = normalizeWindowsPath(expectedDataDir);
if (!expected) {
return false;
}
const name = String(owner.name ?? '').toLowerCase();
if (!name.startsWith('spacetime')) {
return false;
}
return normalizeWindowsPath(owner.commandLine).includes(expected);
}
// 端口健康不代表后端属于当前工作树:上个工作树 Ctrl+C 残留的 api-server 仍会
// 应答 /healthz。复用前必须证明端口上的进程就是本工作树的可执行文件与数据目录。
function verifyAgcBackendOwnership({
apiUrl,
spacetimeUrl,
bgfilterWorkerUrl,
platform = process.platform,
expectedExePath = apiServerExePath,
expectedDataDir = backendSpacetimeDataDir,
readPortOwners = readWindowsPortOwnerIdentities,
} = {}) {
if (platform !== 'win32') {
return { ok: true, reason: 'platform-unsupported', owners: new Map() };
}
const ports = [
urlPort(apiUrl),
urlPort(bgfilterWorkerUrl),
urlPort(spacetimeUrl),
];
const owners = readPortOwners(ports);
if (!owners) {
return { ok: true, reason: 'owner-probe-unavailable', owners: new Map() };
}
const apiOwner = owners.get(urlPort(apiUrl));
if (!isWorktreeApiServerOwner(apiOwner, { expectedExePath })) {
return { ok: false, reason: 'api-server-owner-mismatch', owners, apiOwner };
}
const workerOwner = owners.get(urlPort(bgfilterWorkerUrl));
if (!isWorktreeApiServerOwner(workerOwner, { expectedExePath })) {
return {
ok: false,
reason: 'bgfilter-worker-owner-mismatch',
owners,
workerOwner,
};
}
const spacetimeOwner = owners.get(urlPort(spacetimeUrl));
if (!isWorktreeSpacetimeOwner(spacetimeOwner, { expectedDataDir })) {
return {
ok: false,
reason: 'spacetime-owner-mismatch',
owners,
spacetimeOwner,
};
}
return { ok: true, reason: 'owned', owners };
}
function formatOwnerLabel(owner) {
if (!owner) {
return '未知进程';
}
const pid = Number(owner.processId);
const label = owner.executablePath || owner.commandLine || owner.name || '';
return `${Number.isInteger(pid) ? `pid=${pid} ` : ''}${String(label).trim()}`.trim();
}
async function isBackendReady({
state = readJson(devStackStatePath),
isReady = isHttpReady,
verifyOwnership = verifyAgcBackendOwnership,
onOwnershipRejected = null,
} = {}) {
const { apiUrl, spacetimeUrl, bgfilterWorkerUrl, hasMatchingBackend } =
resolveBackendTargetsFromState(state, {
requireAgcBackend: true,
});
if (!hasMatchingBackend || !apiUrl || !spacetimeUrl || !bgfilterWorkerUrl) {
return false;
}
const ownership = await verifyOwnership({
apiUrl,
spacetimeUrl,
bgfilterWorkerUrl,
});
if (!ownership?.ok) {
onOwnershipRejected?.(ownership);
return false;
}
if (ownership.reason === 'owner-probe-unavailable') {
console.warn(
'[ai-game-creator-shell] 无法读取端口监听进程归属,本次按旧行为复用配套后端。',
);
}
return (
hasMatchingBackend &&
Boolean(apiUrl) &&
Boolean(spacetimeUrl) &&
Boolean(bgfilterWorkerUrl) &&
(await isReady(`${apiUrl}/healthz`)) &&
(await isReady(`${spacetimeUrl}/v1/ping`)) &&
(await isReady(`${bgfilterWorkerUrl}/readyz`))
@@ -485,14 +660,18 @@ async function terminateChildTree(
return { stopped: true, forced: false };
}
const result = await taskkillImpl(child.pid);
return {
stopped:
!result?.timedOut &&
!result?.error &&
[0, 128].includes(result?.code ?? 0),
forced: true,
result,
};
const taskkillStopped =
!result?.timedOut &&
!result?.error &&
[0, 128].includes(result?.code ?? 0);
if (taskkillStopped) {
return { stopped: true, forced: true, result };
}
// 包装层(cmd.exe / npm.cmd)先被 Ctrl+C 杀掉时 taskkill 拿不到活着的 PID
// 这里继续按记录下来的根 PID 遍历,尽量收掉更深的后端进程。
const treeStopped = stopWindowsProcessTree(child.pid);
return { stopped: treeStopped.length > 0, forced: true, result };
}
const processGroupId = childLifecycles.get(child)?.processGroupId;
@@ -542,15 +721,29 @@ async function waitForBackendReady(
backendChild,
timeoutMs = 600_000,
{
checkBackendReady = isBackendReady,
checkBackendReady = (onOwnershipRejected) =>
isBackendReady({ onOwnershipRejected }),
readState = () => readJson(devStackStatePath),
resolveTargets = readBackendTargets,
} = {},
) {
const initialStateUpdatedAt = readState()?.updatedAt ?? '';
const startedAt = Date.now();
let lastOwnershipReason = '';
while (Date.now() - startedAt < timeoutMs) {
if (await checkBackendReady()) {
if (
await checkBackendReady((ownership) => {
if (ownership.reason === lastOwnershipReason) {
return;
}
lastOwnershipReason = ownership.reason;
// 本次自己拉起的后端如果归属校验一直不通过,必须把原因打出来,
// 否则只会表现为等待 600 秒后超时。
console.warn(
`[ai-game-creator-shell] 等待配套后端就绪时归属校验未通过(${ownership.reason}: ${formatOwnerLabel(ownership.apiOwner ?? ownership.spacetimeOwner ?? ownership.workerOwner)})。`,
);
})
) {
return resolveTargets();
}
const state = readState();
@@ -576,7 +769,14 @@ async function waitForBackendReady(
async function ensureBackend({
onBackendChild = () => {},
checkBackendReady = isBackendReady,
checkBackendReady = () =>
isBackendReady({
onOwnershipRejected(ownership) {
console.warn(
`[ai-game-creator-shell] 端口上的配套后端不属于当前工作树(${ownership.reason}: ${formatOwnerLabel(ownership.apiOwner ?? ownership.spacetimeOwner ?? ownership.workerOwner)}),改为启动本工作树自己的后端。`,
);
},
}),
resolveTargets = readBackendTargets,
spawnBackend = () =>
spawnChild(
@@ -656,15 +856,33 @@ async function startVite(apiTarget, endpoint = readAgcDevEndpoint()) {
async function main() {
let backendChild = null;
let startedBackend = false;
let viteChild = null;
let shutdownSignal = '';
const signalHandlers = new Map();
// 只有本次会话真正拉起过配套后端时才做兜底清扫:复用别人后端时不能连带
// 杀掉对方的进程。dev.mjs 的清理依赖它的 shell 包装层仍然活着,而 Ctrl+C
// 往往先杀掉包装层,所以这里必须按本工作树 api-server.exe 的身份再收一次。
const sweepStartedBackend = () => {
if (!startedBackend || process.platform !== 'win32') {
return;
}
const stopped = stopWindowsWorktreeProcesses({ apiServerExePath });
if (stopped.length > 0) {
console.log(
`[ai-game-creator-shell] 已清理残留后端进程: ${stopped.join(', ')}`,
);
}
};
for (const signal of ['SIGINT', 'SIGTERM']) {
const handler = () => {
shutdownSignal = signal;
stopChild(viteChild, signal);
stopChild(backendChild, signal);
// 立刻清扫,避免外层 taskkill /F 抢在 finally 之前把本进程杀掉。
sweepStartedBackend();
};
signalHandlers.set(signal, handler);
process.on(signal, handler);
@@ -683,6 +901,7 @@ async function main() {
},
});
backendChild = backend.backendChild;
startedBackend = Boolean(backendChild);
if (shutdownSignal) {
throw new Error(`启动期收到 ${shutdownSignal},已停止配套后端`);
}
@@ -716,6 +935,7 @@ async function main() {
terminateChildTree(viteChild),
terminateChildTree(backendChild),
]);
sweepStartedBackend();
for (const [signal, handler] of signalHandlers) {
process.off(signal, handler);
}
@@ -732,20 +952,25 @@ function isDirectModuleExecution() {
export {
ensureBackend,
formatChildFailure,
formatOwnerLabel,
isAiGameCreatorServer,
isBackendReady,
isDirectModuleExecution,
isProcessGroupAlive,
isWorktreeApiServerOwner,
isWorktreeSpacetimeOwner,
preflightExistingVite,
readBackendServiceFailure,
readChildFailure,
readExistingViteServer,
readLinuxProcessGroupAlive,
readWindowsPortOwnerIdentities,
resolveBackendTargetsFromState,
runWindowsTaskkill,
spawnChild,
stopChild,
terminateChildTree,
verifyAgcBackendOwnership,
waitForBackendReady,
waitForChildTermination,
};
@@ -43,7 +43,6 @@ struct PromptCompositions {
/// 而是一份独立的完整清单:plan 根的工具面只有 7 个原生工具,专业组、
/// isolated child、任务图与视觉产物合同在这条链路上全部不可执行,逐段
/// 减法会把「plan 根到底看到什么」摊在两个函数的四个否定分支里。
supervisor_plan: Vec<String>,
supervisor_chat: SupervisorChatComposition,
}
@@ -99,10 +98,6 @@ struct ProviderFragments {
#[serde(rename_all = "camelCase", deny_unknown_fields)]
struct AgentCatalog {
supervisor: AgentGroup,
/// 立项策划子 Agent。与 `supervisor` 平级、**不进 `groups`**`specialist_nodes`
/// 只从 `groups[].roles[]` 派生,因此它不参与 `build.rs` 与种子 DAG 的一致性
/// 校验,「做游戏」的 16 任务 DAG 一行不动。详见技术方案第 3.1 节。
planning: AgentGroup,
groups: Vec<AgentGroup>,
}
@@ -231,12 +226,6 @@ pub fn compile_manifest(manifest_path: &Path) -> Result<CompiledPromptBundle, St
&sections,
&["$base", "$visualContract"],
)?;
validate_composition(
"supervisorPlan",
&manifest.compositions.supervisor_plan,
&sections,
&["$header"],
)?;
validate_section_reference(
&manifest.compositions.supervisor_chat.identity,
&sections,
@@ -299,7 +288,6 @@ pub fn compile_manifest(manifest_path: &Path) -> Result<CompiledPromptBundle, St
.supervisor
.roles
.iter()
.chain(manifest.agent_catalog.planning.roles.iter())
.chain(
manifest
.agent_catalog
@@ -348,7 +336,6 @@ pub fn compile_manifest(manifest_path: &Path) -> Result<CompiledPromptBundle, St
.runtime
.iter()
.chain(manifest.compositions.supervisor.iter())
.chain(manifest.compositions.supervisor_plan.iter())
.filter(|item| !item.starts_with('$'))
.cloned()
.collect::<BTreeSet<_>>();
@@ -421,14 +408,6 @@ fn validate_section_ownership(manifest: &PromptBundleManifest) -> Result<(), Str
{
register("composition supervisor", section);
}
for section in manifest
.compositions
.supervisor_plan
.iter()
.filter(|section| !section.starts_with('$'))
{
register("composition supervisorPlan", section);
}
register("composition supervisorChat.identity", identity);
register(
"composition supervisorChat.finalReply",
@@ -457,19 +436,9 @@ fn validate_section_ownership(manifest: &PromptBundleManifest) -> Result<(), Str
"composition supervisor",
"composition supervisorChat.identity",
]);
// plan 根 composition 是 Supervisor system prompt 的第二条 lane,不是另一种
// 语义面。它按设计复用 runtime lane 的 `isolatedAgentContract``agent.delegate`
// 的 expectedArtifacts/writeScopes 合同)和 supervisor lane 的 `supervisorRepair`
// (返工必须逐字继承原合同)。除这两个方向外,跨所有者复用仍然是错误。
let allowed_plan_runtime_owners =
BTreeSet::from(["composition runtime", "composition supervisorPlan"]);
let allowed_plan_supervisor_owners =
BTreeSet::from(["composition supervisor", "composition supervisorPlan"]);
for (section, section_owners) in owners {
if section_owners.len() > 1
&& !(section == identity && section_owners == allowed_identity_owners)
&& section_owners != allowed_plan_runtime_owners
&& section_owners != allowed_plan_supervisor_owners
{
return Err(format!(
"Prompt section 跨语义所有者复用:{section} -> {section_owners:?}"
@@ -706,17 +675,11 @@ fn validate_agent_catalog(catalog: &AgentCatalog) -> Result<(), String> {
if catalog.supervisor.roles.len() != 1 {
return Err("agentCatalog.supervisor 必须且只能包含一个 role".to_string());
}
if catalog.planning.roles.len() != 1 {
return Err("agentCatalog.planning 必须且只能包含一个 role".to_string());
}
if catalog.groups.is_empty() {
return Err("agentCatalog.groups 不能为空".to_string());
}
let mut group_brief_names = BTreeSet::new();
for group in std::iter::once(&catalog.supervisor)
.chain(std::iter::once(&catalog.planning))
.chain(catalog.groups.iter())
{
for group in std::iter::once(&catalog.supervisor).chain(catalog.groups.iter()) {
if !group_brief_names.insert(group.brief_path_name.as_str()) {
return Err(format!(
"agent group briefPathName 重复:{}",
@@ -724,10 +687,7 @@ fn validate_agent_catalog(catalog: &AgentCatalog) -> Result<(), String> {
));
}
}
let mut generated_names = BTreeSet::from([
"PROJECT_SUPERVISOR".to_string(),
"PROJECT_PLANNING".to_string(),
]);
let mut generated_names = BTreeSet::from(["PROJECT_SUPERVISOR".to_string()]);
for group in &catalog.groups {
let generated = rust_identifier(&group.id);
if !generated
@@ -753,12 +713,6 @@ fn validate_agent_catalog(catalog: &AgentCatalog) -> Result<(), String> {
&mut task_ids,
&mut tool_ids,
)?;
validate_agent_group(
&catalog.planning,
&mut group_ids,
&mut task_ids,
&mut tool_ids,
)?;
for group in &catalog.groups {
validate_agent_group(group, &mut group_ids, &mut task_ids, &mut tool_ids)?;
}
@@ -920,10 +874,6 @@ fn render_rust(manifest: &PromptBundleManifest, sections: &BTreeMap<String, Stri
"RUNTIME_PROMPT_SUPERVISOR_COMPOSITION",
&manifest.compositions.supervisor,
));
output.push_str(&render_string_slice_const(
"RUNTIME_PROMPT_SUPERVISOR_PLAN_COMPOSITION",
&manifest.compositions.supervisor_plan,
));
output.push_str(&format!(
"pub(crate) const RUNTIME_PROMPT_SUPERVISOR_CHAT_COMPOSITION: &[&str] = &[{}, {}];\n",
rust_literal(&manifest.compositions.supervisor_chat.identity),
@@ -1012,26 +962,6 @@ fn render_agent_catalog(catalog: &AgentCatalog) -> String {
"static PROJECT_SUPERVISOR_AGENT_DEFINITION: AgentGroupDefinition = {};\n",
render_group_value(&catalog.supervisor, "&PROJECT_SUPERVISOR_AGENT_ROLES")
));
let planning_role = &catalog.planning.roles[0];
output.push_str(&format!(
"pub(crate) const GAME_CREATOR_PROJECT_PLANNING_AGENT_ID: &str = {};\n",
rust_literal(&planning_role.task_id)
));
output.push_str(&format!(
"pub(crate) const GAME_CREATOR_PROJECT_PLANNING_MEMORY_PATH: &str = {};\n",
rust_literal(&format!(
"memory/agents/{}",
catalog.planning.brief_path_name
))
));
output.push_str(&render_role_array(
"PROJECT_PLANNING_AGENT_ROLES",
&catalog.planning.roles,
));
output.push_str(&format!(
"static PROJECT_PLANNING_AGENT_DEFINITION: AgentGroupDefinition = {};\n",
render_group_value(&catalog.planning, "&PROJECT_PLANNING_AGENT_ROLES")
));
for group in &catalog.groups {
let roles_name = format!("{}_AGENT_ROLES", rust_identifier(&group.id));
output.push_str(&render_role_array(&roles_name, &group.roles));
@@ -23,11 +23,7 @@
"supervisorVisualWithEditor": "supervisor/visual-contract-with-editor.md",
"supervisorPlaybook": "supervisor/playbook.md",
"supervisorClaimGate": "supervisor/claim-gate.md",
"supervisorRepair": "supervisor/repair.md",
"projectPlanningRoleBrief": "roles/project-planning.md",
"planCommon": "plan/common.md",
"planSupervisorIdentity": "plan/supervisor-identity.md",
"planSupervisorPlaybook": "plan/supervisor-playbook.md"
"supervisorRepair": "supervisor/repair.md"
},
"compositions": {
"runtime": [
@@ -47,14 +43,6 @@
"supervisorClaimGate",
"supervisorRepair"
],
"supervisorPlan": [
"$header",
"planCommon",
"isolatedAgentContract",
"planSupervisorIdentity",
"planSupervisorPlaybook",
"supervisorRepair"
],
"supervisorChat": {
"identity": "supervisorIdentityContract",
"finalReply": "supervisorFinalReplyContract"
@@ -70,12 +58,7 @@
"editorUnavailable": "supervisorVisualWithoutEditor"
}
},
"roleOverlays": [
{
"agentId": "project-planning",
"sections": ["projectPlanningRoleBrief"]
}
],
"roleOverlays": [],
"providerFragments": {
"isolatedToolContract": "providerIsolatedToolContract",
"autonomousRunProfile": "providerAutonomousRunProfile",
@@ -102,21 +85,6 @@
}
]
},
"planning": {
"id": "planning",
"label": "立项策划",
"role": "Project Planning",
"briefPathName": "project-planning.md",
"roles": [
{
"id": "project-planning",
"role": "Project Planning",
"taskId": "project-planning",
"toolId": "agent.runtime.project-planning",
"briefPathName": "project-planning.md"
}
]
},
"groups": [
{
"id": "design",
@@ -1,7 +0,0 @@
用户只描述玩法类型、机制或相似体验时,不代表授权复刻现有游戏。所有专业 Agent 必须创建原创标题、阵营、资源、单位名称、角色造型、界面术语和视觉语言;禁止沿用、翻译或近似改写现有游戏的专有角色、单位名、Logo、贴图、标志性布局与受保护视觉语言。除非用户明确提供有权使用的项目内素材,否则不得把 Sunflower、Peashooter、向日葵、豌豆射手、僵尸等知名塔防元素写入策划、记忆、代码、图片提示或正式产物。
静态委派协议:新 agent.delegate 必须提交 1-8 条 acceptanceCriteria、0-16 个精确项目内非私有 expectedArtifacts,以及 nullable repairOfDelegationId/runId/continuationOfDelegationId/questionsSha256/answersSha256,普通委派后三项传 null。专业 Agent 收到的 task 会携带完整合同。Supervisor 认领回执后必须区分 evidence-ready、needs-user-input 与 needs-repair;前者仍需语义验收,needs-repair 不能作为成功。专业 Agent 若缺少会实质改变结果的用户事实,不能调用 user.input_request,必须以最终回复首行 `AGC_NEEDS_USER_INPUT_V1`,下一行短 JSON `{"questions":[...]}` 返回 1-3 个结构化问题;Runtime 会把它作为内部回执交给 Supervisor。Supervisor 对每个原 delivery 逐一用现有 user.input_request 提问,收齐对应答案后最多创建一次 continuation 委派,并同时提交 continuationOfDelegationId、questionsSha256、answersSha256Runtime 会自动派生稳定 continuation identity,不得把多个 delivery 的问题或答案混入同一 continuation。
每 6 轮只是一次进度 checkpoint 与停滞检测,不是上下文压缩或 run 的终止上限;只要 observation 出现新的独立进展,就在同一 run 继续下一窗口,只有窗口没有新进展时才按停滞处理。真正的上下文压缩仅由 token 阈值或显式 compact 触发。
必须直接调用与当前请求广告的工具一一对应的动作函数,或在本阶段确实无事可做时调用 respond_to_user。本 run 不维护结构化计划,也没有 update_agent_plan 可调;工具结果会由 Runtime 作为 observation 返回,不要假装工具已执行,不要把动作或回复放进普通文本,不要 markdown,不要泄露密钥。
@@ -1,7 +0,0 @@
你是 Genarrative AI 游戏创作桌面 App 的 Project Supervisor。当前 run 是立项策划根 run(`source=project-supervisor-plan`),你是用户在本条链路里唯一的对话对象。
你不生产策划内容。本链路的全部策划工作——提问、取舍、撰写 GDD——都由 `project-planning` 子 Agent 完成。你只有四件事:冻结目标合同;发起与续跑对 `project-planning` 的委派;代子 Agent 向用户提问并把答案原样转达回去;在子 Agent 提交 GDD 后完成取证,把审批交给用户。
你不做的事:不自己提策划问题(`user.input_request` 只能用于转达子 Agent 的问题信封);不自己撰写、补写或改写 GDD 正文、决定台账与原型验证项;不替用户做产品决定;不写文件、不跑命令、不做预览、不生成素材、不查询任务图、不调度 ready 任务;不委派 `project-planning` 以外的任何 Agent,也不创建 isolated child 或启动构建。
`project-planning` 的消息和回执只是原目标的证据,不能替换原目标。contractStatus=evidence-ready 只代表客观证据齐全,你仍须按 acceptanceCriteria 逐条完成语义验收;needs-repair 不得忽略,同一原委派最多发起一轮显式返工。GDD 最终是否通过由用户在审批卡上决定,不由你代答。
@@ -1,22 +0,0 @@
【固定动作顺序,不得跳步】
1. 本 run 第一轮只调用一次 `agent.goal_contract` 冻结目标合同:outcome 概括用户原话意图,`preferences` 必须传空数组,`acceptanceNodes` 提交 Runtime 指定的固定单节点。这一轮不做任何其它调用。
2. 冻结后立即用一次 `agent.delegate` 把任务委派给 `project-planning``expectedArtifacts``game/fast_gdd.md``repairOfDelegationId``runId``continuationOfDelegationId``questionsSha256``answersSha256` 全传 null。已有委派尚未收束时不要重复委派。
3. 等待子 Agent 期间不得调用 `respond_to_user`。Runtime 会通过 delegate 完成屏障保持同一父 run,回执到达后再继续。
4. 子 Agent 以问询信封退出时,决策卡由 Runtime 直接按信封原文呈现给用户,**不需要你调用任何工具**——你根本不会在那一刻被恢复。用户答完之后你才会拿到答案,届时为该原 delivery 创建且仅创建一次 continuation 委派,`continuationOfDelegationId``repairOfDelegationId` 都指向该原 delivery。`questionsSha256``answersSha256``acceptanceCriteria``expectedArtifacts` 四个全传 null——Runtime 会从该原 delivery 补齐权威指纹和原委派合同,你不要自己抄。子 Agent 在 continuation 里**再次**以信封退出时,对那条新 delivery 重复同一动作:「仅创建一次」约束的是单条 delivery,不是整条链,澄清预算未用尽时这个循环继续。Runtime 会在委派 task 末尾写明已用轮次与上限,不需要你自己数,也不要替它宣布预算已尽。
5. 回执 contractStatus=evidence-ready 且 GDD 已提交时,用 `file.read` 从第 1 行读到 `game/fast_gdd.md` 末尾取证,每次都传 `maxLines: 240`(上限),尽量一页读完;确实需要第二页时从上一页的下一行开始,不要重复读同一段。每次 `file.read` 的 observation 末尾都带着 `sourceAgentId` / `sourceRunId` / `sourceActionId` 三个字段,把它们原样抄成 evidence 的 `{agentId, runId, actionId}`,用一次 `agent.acceptance_update` 一并提交即可——evidence 是按这三个字段整体查回执的,回忆错任何一个都会被判成"缺少持久动作回执"。不要为了取这些字段再去查动作历史。取证完成前审批卡不会出现。
6. 用户在审批卡上选择修改或退回时,直接创建返工委派:`repairOfDelegationId` 指向原 delegationId`runId``acceptanceCriteria``expectedArtifacts` 都传 null——Runtime 会从原 delivery 继承权威合同,不需要先 `agent.run_status` 去取再手抄。把用户原话完整附在 task 里。「同一原委派只能返工一次」约束的是单条 delivery,不是整条链:用户看过新稿再点一次修改,就对那条新 delivery 重复同一动作,这个循环没有次数上限——`repair_depth` 防的是 runaway agent,而每一轮修订都由用户亲手触发,人本身就是循环边界。不要替 Runtime 宣布「这是最后一次修改机会」,也不要因此把多条意见攒到一轮里改完。用户通过后只做一句简短收尾。
【转达的规则】
- 把用户答案回灌给 `project-planning` 时,逐条列出全部已确认决定,每条格式为 `[已确认] 第N轮问的是:{question 原文} 候选项:{option1.label} {option2.label} {option3.label} → 用户答:{原文}`。**问题原文和三个选项标签必须带上**:`{header}` 只写到「第N轮·当前要决定:{主题}」这一层,答案落在选项上;子 Agent 每轮都是全新 run,除了这段正文什么都看不到,只给它主题和答案,「类似B」「B · 沙盒里程碑成长」这类答案就无从解读,它只能把同一件事再问一遍。用户答案原文一字不改、不归纳、不拆分、不搬轮次;任务长度接近上限时压缩你自己的说明文字和选项描述,绝不压缩用户答案、问题原文和选项标签。
- 策划链路的澄清信封**恰好一题**,不是通用静态委派协议里的 1-3 题:`project-planning` 每轮只提一个主要决定,Runtime 也只接受一题,多于一题会在出卡时被拒。委派 task 里不要写“1-3 个结构化问题”。
- 上一条格式里的三个选项标签就是决策卡上的 A、B 和“需要原型验证”,必须原样转述、一个都不能省;B 是用户确认的 `confirmed/user_option`,不能转成默认建议。用户后续自由填写推翻了更早的决定时,你只负责把两轮答案的原文都原样带到,并说明后者更晚;怎么记进决定台账由 `project-planning` 判断,不要替它裁定哪条作废。
【委派合同的边界】
委派 `project-planning` 时,acceptanceCriteria 只写产物形状、覆盖范围与红线(例如必须交付 `game/fast_gdd.md`、必须原创、必须只定义一个 MVP 闭环),**不得替用户预先裁定产品取舍**。用户没有指定的玩法规则、数值、关卡量级、美术方向和目标人群,一律留给策划子 Agent 按其 3 轮问询预算决定是提问还是按默认建议填写;不要写“未指定的标注为立项假设”“自行假设后继续”这类指令,那会把问询预算作废。平台事实(自包含 Web、desktop/mobile 双视口、keyboard/touch 双输入、本地 HTTP 预览)由 Runtime 固定注入,属于已定事实,不得要求标为待定、建议或开放项。
**本轮指令三选一。** 委派任务正文里,除了用户原始意图和已确认答案原文,你只能再写一句“本轮该做什么”,且必须是下面三个之一:**继续澄清**(默认,不附加任何前置条件)、**直接出稿**(仅当用户明确要求跳过问询)、**按意见修订**(仅审批返回修改或退回时)。不要自己描述“什么情况下才该提问”“若缺少会实质改变结果的事实则……”“否则直接提交完整 GDD”——那不在这三项里。提问预算怎么花,由 `project-planning` 按 Runtime 注入的判据决定。
不要向用户暴露内部 task/event、工具计划、动态 child ID 或调试状态。
@@ -1,33 +0,0 @@
你是“立项策划 Agent”(`agentId=project-planning`),由 Project Supervisor 通过静态 `agent.delegate` 委派。你的工作是把一句用户需求收敛成可审批的 MVP Fast GDD;你只负责玩法澄清、原型验证建议和最小 GDD,不负责完整游戏构建。
## 身份与边界
- 当前 run 固定为 `source=agent-delegate``profile=standard`,父 Agent 是 `project-supervisor`。不得伪造、改写或猜测这些 Runtime 身份。
- 你不能委派或调度其他 Agent,不能创建 isolated child,不能调用 MCP、命令、进程、预览、画布、素材生成、写入/补丁/删除工具,也不能改变项目版本或审批事实。
- 你的原生工具目录只应包含 `file.read``file.list` 以及 Runtime 协议控制函数 `update_agent_plan``respond_to_user``user.input_request` 不属于你的工具目录。若需要用户决定,必须以终态信封首行 `AGC_NEEDS_USER_INPUT_V1` 退出本轮,下一行给出严格 JSON 信封 `{"questions":[{ ... }]}`,交由 Supervisor 转发。`questions` 恰好一个元素;元素字段只能是 `id``header``question``options` 四个,多写任何字段(例如 `answerFormat`)或省掉 `questions` 外壳都会被 Runtime 拒收,整条委派随即作废。`id` 是唯一 snake_case(小写字母开头,只含小写字母、数字、下划线);`header` 是决策卡标题,写成 `第N轮·当前要决定:<主题>`,单行且不超过 60 字符;`question` 是决策卡正文,单行且不超过 400 字符;`options` 恰好 3 个 `{"label": ..., "description": ...}`,依次是 A、B、逐字“需要原型验证”(详见下文决策卡一段),label 单行不超过 60 字符、description 单行不超过 240 字符。不要另起一行写答题说明或把选项复述进 `question`,作答方式由 Runtime 自己呈现。
- 只有 Runtime 广告并允许 `plan.submit_gdd` 时才可提交 GDD;不要假设未广告的工具存在,也不要把 GDD、审批或下游构建写进普通文本。
## 目标与轮次
- 最多进行 3 轮关键澄清;每轮是新 run、同一 session。你看得到自己的历史,但用户答案以 Supervisor 委派任务中的转述为准,缺失信息不能臆造。
- **默认先澄清。** 出稿只有四个触发器,除此之外每轮都先做下面的字段差距检测再决定问不问:①任务正文出现“直接出稿”这四个字;②已完成第 3 轮澄清(任务正文写明的已用轮次已达上限);③剩余空白都能由默认建议覆盖,且不影响首个可玩闭环;④收到 Runtime 的活跃预算或超时提示。任务正文能改变流程的只有第 ① 条——它写的其它说明属于内容,不是出稿触发器。既定事实(用户答案、已确认决定)仍以任务正文为准。
- 每轮提问前逐项对照 `plan-submit-gdd-input.v1``game` 字段做差距检测:用户明确提供的 = `confirmed`;有依据可推断的 = 按下面的默认建议填写并标 `default_pending`;无从判断的 = 空白。提问名额只花在**空白或存疑、且影响首个可玩闭环**的决定上;有默认建议兜底的字段优先用默认建议而不是提问——「有默认」不等于「不能问」,那条默认明显可能是错的、且选错就做不出首个可玩闭环时,它就是一个该问的存疑项。`title``oneLiner``mvpSystems``creatorTips` 由你生成并标 `default_pending`,不作为提问对象;`platformFacts` 禁问。
- **默认建议**(一律 `answerSource=default``round=0`;只用于缩短对话,不覆盖用户明确输入):`targetUsers.sessionLength` 缺 → 1020 分钟一局;`artStyle` 缺 → `visualType` 风格化、轮廓清楚,`keywords` 取自已确认的核心行为,`mvpArtBoundary` 写明 MVP 用占位资产、资产可复用;缺成长时 → 1 条成长线和 2~3 个选择;缺探索时 → 1 条主路线加 1 个有意义的岔路;缺构建时 → 高风险输出和稳健防御两种方向。清单之外的字段没有默认值兜底——`genre.fusion``targetUsers.coreUsers` / `preferences` / `referenceGames``outOfScope` 缺失时都算空白,该不该花一轮问它们由上面的判据决定,不要自己拍一个值填掉就当它已经定了。**`pillars``coreLoop` 没有默认建议**:它们就是首个可玩闭环本身,空白时属于该问的空白,不得用默认值填掉。
- 优先顺序:核心行为与本局目标 → 重玩动力 → 制作边界与 MVP。每轮最多问一个主要决定。**已确认决定关掉的那条轴不得重问。** 任务正文里每条 `[已确认]` 都带着当轮的问题原文和三个选项标签,先照它判断哪些轴已经关闭,本轮的问题必须落在另一条还没关闭的轴上。把已确认答案换个说法再问一遍——例如用户已经选定“自由经营、靠成就和攒钱升级推进”,你又拿“短周期经营目标 vs 沙盒里程碑成长”去问——是白烧一轮预算。所有轴都已关闭时按出稿触发器③直接出稿。
- 决策卡的 header 写成“第N轮·当前要决定:<主题>”,最多 60 字符。N 是 Runtime 从委派谱系派生的当前轮号,写错会被 Runtime 拒收:首轮恒为 1;之后每次续跑的任务正文都会写明已用轮次与上限,本轮该用的 N 就是“已用轮次 + 1”。`<主题>` 是这一轮真正要定的那件事本身(例如“塔的构筑方式”“每局变化来源”),一句话说完、不带状态标记——它会原样落进决定台账的 `topic`,也是你下一轮辨认哪些轴已经关掉的唯一线索,写成“关键决定”这类空话等于把它作废。正文只问尚未由平台事实或 MVP 规则排除的真实产品取舍,并说明为什么现在问;每张卡固定提供三个选项:A 是你的推荐方案(label 以 `A ·``A:``A``A-` 开头并写明推荐、好处和代价),B 是形状不同且真实可行的平行备选(label 以 `B ·``B:``B``B-` 开头并写明后果和代价),第三项逐字为“需要原型验证”,description 必须给出 30~90 分钟微型原型、试玩对象、观察信号和通过标准。自由输入按用户原话处理。
## 低幻觉与 GDD 约束
- 用户描述玩法类型、机制或“像某款游戏”时,不代表授权复刻该游戏。游戏名称、世界观、角色与单位名、阵营、资源、界面术语和视觉语言必须原创;不得沿用、翻译或近似改写现有游戏的专有名称、Logo、标志性布局与受保护视觉语言,也不得把它们写进 GDD 正文、决定台账或原型验证项。用户提到的相似作品只能作为抽象品类参考,`targetUsers.referenceGames` 同样不得填入受保护名称。你的工具面窄,但内容红线不因此放宽——GDD 是整条产线的上游。
- 决定台账记录当前 GDD 的决定快照。澄清阶段的 A、B 或自由填写得到的用户决定标 `confirmed`,选择“需要原型验证”标 `prototype_pending`;未提问、由你按默认建议填写的字段标 `default_pending``answerSource=default``round=0`。审批阶段的用户修改意见是本轮最高优先级:由该意见新增或改写的决定使用 `answerSource=user_revision``round=0`,并按当前意见重新填写 `topic``state``answerSummary`
- 以当前 GDD 为基线,仅修改用户审批意见明确涉及的内容,以及为保持内部一致性所必需同步调整的派生内容。未被意见涉及的内容保持不变;如果意见与过去决定冲突,以最新意见为准。不要把用户未要求的其它方向自行扩展进本轮修订。提交时仍须提供完整 GDD 快照,但完整快照不代表可以任意重写未涉及内容。
- `prototypeValidationItems` 是必填字段(没有就传空数组),与 `prototype_pending` 决定**一一对应**:每条 `prototype_pending` 决定必须有一个同 id 的验证项,每个验证项也必须对应一条 `prototype_pending` 决定,最多 3 项。除了用户亲选“需要原型验证”之外,你自己也可以主动标:手感、节奏、可读性、难度曲线这类你没问过、但选错就做不出首个可玩闭环的判断,标 `prototype_pending``answerSource=default``round=0`)比标 `default_pending` 诚实——那不是一个默认值,是一个没人验证过的假设。每项写清 30~90 分钟微型原型做什么、让谁试玩、观察什么信号、什么算通过。
- 不得编造具体游戏的机制、数值、销量、人群规模、团队规模或来源。写 `targetUsers` 时按已确认的类型与核心行为描述典型玩家即可。
- 只定义一个完整可玩闭环。MVP 不含多人、商城、服务器、开放世界、赛季、复杂社交、完整剧情或全量内容,除非用户明确改变范围。
- GDD 至少覆盖:游戏名称与类型、一句话描述、2~4 条游戏支柱、核心循环、目标用户、美术方向、3~6 个最小 MVP 系统、先做/暂缓/验证/扩展条件、决定状态和审批请求。不要把 Runtime 注入的身份、时间、指纹、审批 receipt 或平台事实当作 Provider 输入字段。
- 平台事实由 Runtime 固定注入为自包含 Web、desktop/mobile 双视口、keyboard/touch 双输入、本地 HTTP 预览;不得修改、删减或向用户询问。
## 输出纪律
- 澄清模式只返回 `AGC_NEEDS_USER_INPUT_V1` 终态信封,不再调用其他函数;成稿模式只在 `plan.submit_gdd` 被广告时调用它并等待 Runtime 校验;收到 revise/reject observation 后按同一 GDD 谱系修订,收到 approve 后只做简短收尾。
- 必须直接调用当前请求广告的原生函数;不要输出 JSON、代码围栏或内部思考过程,不要假装已经写入文件、完成审批或启动构建。
@@ -3777,8 +3777,6 @@ pub(crate) async fn direct_game_creator_codex_chat_at_with_optional_observer(
request_slot: "direct-chat".to_string(),
web_search_enabled: config.llm.web_search_enabled,
allow_idle_context_compaction: false,
// direct-codex 不是立项策划链路,没有 planning session 可绑定。
planning_session_binding: None,
};
let api_kind =
parse_game_creator_llm_api_kind(&config.llm.api_kind).map_err(|error| error.to_string())?;
@@ -3845,8 +3843,6 @@ pub(crate) async fn direct_game_creator_home_codex_chat(
request_slot: "direct-home-chat".to_string(),
web_search_enabled: config.llm.web_search_enabled,
allow_idle_context_compaction: false,
// 直连 Codex 的首页对话不属于任何立项策划 session。
planning_session_binding: None,
};
let api_kind =
parse_game_creator_llm_api_kind(&config.llm.api_kind).map_err(|error| error.to_string())?;
@@ -4180,7 +4176,6 @@ mod tests {
request_slot: "slot-1".to_string(),
web_search_enabled: false,
allow_idle_context_compaction: false,
planning_session_binding: None,
}
}
@@ -1776,7 +1776,7 @@ fn direct_codex_failure_recovery_hint(stage: DirectCodexFailureStage, error: &st
if normalized.contains("permission-denied") || normalized.contains("http 403") {
return "当前陶泥儿账号可能没有访问该资源的权限,请检查账号后重试";
}
if error.contains("项目正在被其他写操作占用") {
if error.contains(crate::project::PROJECT_WRITE_LOCK_CONTENTION_PREFIX) {
return "当前项目仍有写入正在结束,请稍后再次发送该需求";
}
if error.contains("身份不唯一")
@@ -4710,10 +4710,10 @@ mod tests {
assert!(!prompt.contains("你是 Codex"));
assert!(prompt.contains("不要等待 Supervisor"));
assert!(prompt.contains("提示词与技能"));
assert!(prompt.contains("AGC 工程合同(仅说明项目边界,不是流程门槛)"));
assert!(prompt.contains("AGC 工程合同:当前 cwd 是用户选择的项目目录"));
assert!(prompt.contains("客户端扩展列表中用户已启用的第三方 MCP"));
assert!(prompt.contains("用户明确指定第三方 MCP Server 或工具时"));
assert!(prompt.contains("按需读取当前 cwd 下适用的 `AGENTS.md`"));
assert!(prompt.contains("先读取当前 cwd 下适用的 AGENTS.md、README 或项目说明"));
assert!(prompt.contains("agc_write_file"));
assert!(prompt.contains("content 必须是目标文件的完整原始 UTF-8 正文"));
assert!(prompt.contains("不得把 command.exec 的 Exit code、Wall time、Output 包装"));
@@ -1473,7 +1473,14 @@ fn bridge_write_file(root: &Path, arguments: &Value) -> Value {
return Err("工具参数 content 不能包含 NUL".to_string());
}
reject_command_output_wrapper(content)?;
let _lock = acquire_project_write_lock(root, "direct-codex.file.write")?;
// Direct 写入原本用零等待取锁:任何重叠都在 24-42ms 内直接被判成"别人正在写",
// 而 `file.write / file.patch / file.delete` 等写入口用的是约 10 秒有界等待。
// 这是用户直接触发、失败即整轮无法落盘的项目写入通道,必须和其它写入口同语义:
// 短暂重叠排队等成功,只有预算耗尽才报出带持锁方身份的错误。
let _lock = acquire_game_creator_agent_runtime_project_write_lock_with_wait(
root,
"direct-codex.file.write",
)?;
let written = write_local_project_file_at(root, &path, content)?;
let revision = advance_agent_runtime_project_revision_locked(root)?;
Ok::<_, String>(json!({
@@ -1493,6 +1500,27 @@ fn bridge_write_file(root: &Path, arguments: &Value) -> Value {
}
}
/// 项目写锁的有界等待是同步轮询(2_000 × 5ms,最多约 10 秒)。handler 是 async
/// 直接在 handler 里走完整条写路径会占住一个 tokio worker:争用窗口内同一轮并行写多个
/// 文件时会有多个 worker 被占,而这条 bridge 与只读端点、UI 命令共享同一个 runtime,
/// 正是 Issue #318 现场"只读工具全部正常"这条诊断特征会被破坏的情形。
/// 因此整条写路径挪进阻塞线程池,等待语义与错误文案都不变。
async fn bridge_write_file_in_blocking_pool(root: PathBuf, arguments: Value) -> Value {
let task_root = root.clone();
match tokio::task::spawn_blocking(move || bridge_write_file(&task_root, &arguments)).await {
Ok(result) => result,
Err(error) => bridge_tool_result(
redact_agent_runtime_error(
&root,
&format!("agc_write_file 阻塞任务未返回:{error}"),
480,
),
Vec::new(),
true,
),
}
}
fn bridge_safe_account_asset_projection(asset: &Value) -> Option<Value> {
let asset_id = asset.get("assetId").and_then(Value::as_str)?;
if asset_id.trim().is_empty() {
@@ -2307,7 +2335,9 @@ async fn handle_direct_tool_bridge(
bridge_list_registered_assets(&state.root, &request.arguments)
}
"agc_list_project_files" => bridge_list_project_files(&state.root, &request.arguments),
"agc_write_file" => bridge_write_file(&state.root, &request.arguments),
"agc_write_file" => {
bridge_write_file_in_blocking_pool(state.root.clone(), request.arguments).await
}
"agc_list_account_assets" => bridge_list_account_assets(&state, &request.arguments).await,
"agc_import_account_assets" => {
bridge_import_account_assets(&state, &request.arguments).await
@@ -2712,6 +2742,185 @@ mod tests {
);
}
/// Issue #318 第 1 条验收:同一轮里并行的多个文件写必须排队成功,
/// 而不是互相报"项目正在被其他写操作占用"。
#[test]
fn bridge_write_file_serializes_parallel_writes_in_one_round() {
let temporary = tempfile::tempdir().expect("create parallel direct write root");
init_local_game_project_at(temporary.path(), "direct-parallel", "Direct 并行写入测试")
.expect("initialize parallel direct write root");
let root = temporary.path().to_path_buf();
let paths = (0..4)
.map(|index| format!("game/parallel-{index}.js"))
.collect::<Vec<_>>();
let results = std::thread::scope(|scope| {
let handles = paths
.iter()
.map(|path| {
let root = root.clone();
let path = path.clone();
scope.spawn(move || {
let result = bridge_write_file(
&root,
&json!({ "path": path, "content": format!("// {path}\n") }),
);
(path, result)
})
})
.collect::<Vec<_>>();
handles
.into_iter()
.map(|handle| handle.join().expect("parallel direct write must not panic"))
.collect::<Vec<_>>()
});
for (path, result) in &results {
assert_eq!(
result.get("isError").and_then(Value::as_bool),
Some(false),
"parallel direct write of {path} must succeed: {result}"
);
assert_eq!(
fs::read_to_string(root.join(path)).expect("read parallel direct write"),
format!("// {path}\n")
);
}
}
/// Issue #318 第 1 条验收:App 自己另一条写通道正在写该项目时,
/// Direct 写入必须等待后成功,而不是在 24-42ms 内被判成"别人正在写"。
#[test]
fn bridge_write_file_waits_for_a_short_same_process_project_writer() {
let temporary = tempfile::tempdir().expect("create contended direct write root");
init_local_game_project_at(temporary.path(), "direct-contended", "Direct 写入等待测试")
.expect("initialize contended direct write root");
let root = temporary.path().to_path_buf();
let barrier = std::sync::Arc::new(std::sync::Barrier::new(2));
let holder_barrier = std::sync::Arc::clone(&barrier);
let holder_root = root.clone();
let holder = std::thread::spawn(move || {
let lock = acquire_project_write_lock(&holder_root, "concurrent-writer")
.expect("acquire a short-lived project writer");
holder_barrier.wait();
std::thread::sleep(std::time::Duration::from_millis(300));
drop(lock);
});
barrier.wait();
let result = bridge_write_file(
&root,
&json!({ "path": "game/waited.js", "content": "// waited\n" }),
);
holder.join().expect("join the short-lived project writer");
assert_eq!(
result.get("isError").and_then(Value::as_bool),
Some(false),
"the direct write must wait out a short same-process writer: {result}"
);
assert_eq!(
fs::read_to_string(root.join("game/waited.js")).expect("read waited direct write"),
"// waited\n"
);
}
/// 有界等待是同步轮询(最多约 10 秒),而 handler 是 async:等待必须挪到阻塞线程池,
/// 否则会占住 runtime worker。本用例用默认的 current_thread runtime——handler 一旦同步
/// 阻塞,同一 runtime 上的心跳任务就完全停摆,因此在写入等待期间检查心跳即可区分。
#[tokio::test]
async fn bridge_write_file_waits_on_the_blocking_pool_instead_of_a_runtime_worker() {
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
let temporary = tempfile::tempdir().expect("create blocking pool write root");
init_local_game_project_at(temporary.path(), "direct-pool", "Direct 阻塞池测试")
.expect("initialize blocking pool write root");
let state = direct_tool_bridge_state(temporary.path().to_path_buf());
// 另一条写通道由 OS 线程持有项目写锁,不受本 runtime 影响。
let holder_root = temporary.path().to_path_buf();
let lock = acquire_project_write_lock(&holder_root, "concurrent-writer")
.expect("acquire the concurrent project writer");
let holder = std::thread::spawn(move || {
std::thread::sleep(Duration::from_millis(250));
drop(lock);
});
// 心跳任务:只有 handler 让出 worker,它才可能在写入等待期间推进。
let heartbeat = Arc::new(AtomicBool::new(false));
let heartbeat_writer = Arc::clone(&heartbeat);
tokio::spawn(async move {
tokio::time::sleep(Duration::from_millis(50)).await;
heartbeat_writer.store(true, Ordering::SeqCst);
});
let response = handle_direct_tool_bridge(
axum::extract::State(state),
axum::Json(DirectToolBridgeRequest {
tool: "agc_write_file".to_string(),
arguments: json!({ "path": "game/blocking-pool.js", "content": "// pooled\n" }),
}),
)
.await
.0;
holder.join().expect("join the concurrent project writer");
assert!(
heartbeat.load(Ordering::SeqCst),
"写入等待期间同一 runtime 的心跳任务停摆了:等待必须走阻塞线程池,不能占住 worker"
);
assert_eq!(
response.get("isError").and_then(Value::as_bool),
Some(false),
"the pooled direct write must still wait out the holder: {response}"
);
assert_eq!(
fs::read_to_string(temporary.path().join("game/blocking-pool.js"))
.expect("read pooled direct write"),
"// pooled\n"
);
}
/// Issue #318 第 3 条验收:权限拒绝不得被投影成"被其他写操作占用"。
#[cfg(unix)]
#[test]
fn bridge_write_file_does_not_project_permission_denial_as_contention() {
use std::os::unix::fs::PermissionsExt;
let temporary = tempfile::tempdir().expect("create acl direct write root");
init_local_game_project_at(temporary.path(), "direct-acl", "Direct ACL 测试")
.expect("initialize acl direct write root");
let agent_directory = temporary.path().join(".agent");
let original = fs::metadata(&agent_directory)
.expect("read control directory metadata")
.permissions();
fs::set_permissions(&agent_directory, fs::Permissions::from_mode(0o500))
.expect("drop write permission on the control directory");
let result = bridge_write_file(
temporary.path(),
&json!({ "path": "game/acl-denied.js", "content": "// denied\n" }),
);
fs::set_permissions(&agent_directory, original)
.expect("restore control directory permission");
if result.get("isError").and_then(Value::as_bool) != Some(true) {
// 以 root 运行(或文件系统忽略权限位)时 0o500 不构成拒绝,本用例不成立。
return;
}
let text = result
.pointer("/content/0/text")
.and_then(Value::as_str)
.unwrap_or_default();
assert!(
!text.contains("项目正在被其他写操作占用"),
"a permission denial must not be projected as lock contention: {text}"
);
assert!(!temporary.path().join("game/acl-denied.js").exists());
}
#[test]
fn resource_request_uuid_is_stable_v4_and_domain_separated() {
let operation = direct_resource_request_uuid("turn-1", "operation", "abc");
@@ -27,8 +27,9 @@ pub(in crate::agent) use canvas_generation::{
commit_prepared_platform_art_asset_at, commit_prepared_platform_art_asset_strict_slices_at,
generate_platform_art_asset_with_retained_runtime_options_at,
generate_platform_art_asset_with_runtime_options_at,
platform_art_generation_error_result_unknown, register_existing_platform_art_slices_at,
request_platform_art_asset_with_runtime_options_at, restore_platform_art_asset_bytes_at,
platform_art_generation_error_result_unknown, recover_persisted_visual_generation_options,
register_existing_platform_art_slices_at, request_platform_art_asset_with_runtime_options_at,
restore_platform_art_asset_bytes_at,
retained_platform_art_generation_runtime_spritesheet_identity_at,
retained_platform_art_generation_runtime_state_matches_direct_stage_at,
validate_platform_art_png_bytes_with_limits,
@@ -429,6 +429,87 @@ impl Default for PlatformArtAssetGenerationOptions {
}
}
pub(in crate::agent) fn recover_persisted_visual_generation_options(
root: &Path,
pending: &AgentRuntimePendingToolAction,
prompt: &str,
requested: &PlatformArtAssetGenerationOptions,
) -> Result<Option<PlatformArtAssetGenerationOptions>, String> {
let context = platform_art_generation_runtime_context_from_pending(pending);
let Some(state) = read_platform_art_generation_runtime_state(root, &context)? else {
return Ok(None);
};
let (path, ratio, size, kind, label, generation_kind) = match context.agent_id.as_str() {
"art-director" => (
"assets/art-spec.png",
"1:1",
"1K",
"icon-spec",
"游戏统一视觉规范图",
"spec",
),
"design-foundation" => (
"assets/ui-prototype.png",
"16:9",
"2K",
"ui-prototype",
"游戏横屏界面原型图",
"ui-design",
),
"art-asset-plan" => (
"assets/art-spritesheet.png",
"1:1",
"1K",
"art-spritesheet",
"游戏首版核心美术素材",
"icon-spritesheet",
),
_ => return Ok(None),
};
let mut options = requested.clone();
let label = if context.agent_id == "design-foundation"
&& options
.output_path
.as_deref()
.is_some_and(design_foundation_ui_page_output_path_is_valid)
{
"游戏功能页面设计图"
} else {
label
};
if options.output_path.is_none() {
options.output_path = Some(path.to_string());
}
for (value, default) in [
(&mut options.aspect_ratio, ratio),
(&mut options.image_size, size),
(&mut options.asset_kind, kind),
(&mut options.asset_label, label),
] {
if value.is_empty() {
*value = default.to_string();
}
}
let snapshot = platform_art_generation_runtime_request_snapshot(&state)?;
// 只恢复经过身份校验的已有请求;显式改参和新请求仍走当前合同。
if snapshot.generation_kind == generation_kind
&& snapshot.generation_prompt == build_platform_art_asset_prompt(prompt, &[], &options)
&& options.asset_kind == kind
&& options.aspect_ratio == ratio
&& options.image_size == size
&& (options.output_path.as_deref() == Some(path)
|| (context.agent_id == "design-foundation"
&& options
.output_path
.as_deref()
.is_some_and(design_foundation_ui_page_output_path_is_valid)))
{
Ok(Some(options))
} else {
Ok(None)
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
struct ExistingPlatformArtAssetFingerprint {
local_path: String,
@@ -8895,13 +8976,13 @@ mod canvas_generation_tests {
}
#[test]
fn strict_spritesheet_contract_requires_the_grid_2x2_provider_receipt() {
fn strict_spritesheet_contract_accepts_variable_slices_without_fixed_layout() {
let canvas_context = ExternalCanvasGenerationContext {
project_id: "canvas-project".to_string(),
asset_folder_id: "asset-folder".to_string(),
canvas_name: "contract-test".to_string(),
};
let slices = (0..4)
let slices = (0..3)
.map(|index| {
let download = rgba_test_png(100 + index);
let validated = validate_platform_art_png_bytes_with_limits(
@@ -8927,7 +9008,7 @@ mod canvas_generation_tests {
}
})
.collect::<Vec<_>>();
let error = validate_strict_platform_art_spritesheet_contract(
validate_strict_platform_art_spritesheet_contract(
&slices,
&canvas_context,
Some("canvas-project"),
@@ -8941,9 +9022,7 @@ mod canvas_generation_tests {
true,
true,
)
.expect_err("missing fixed-layout proof must not be accepted");
assert!(error.contains("grid-2x2"));
.expect("valid slice identities and pixel evidence do not require a fixed layout");
}
#[test]
@@ -10168,7 +10247,8 @@ mod canvas_generation_tests {
}
#[tokio::test]
async fn accepted_runtime_generation_rejects_changed_intent_before_operation_get() {
async fn accepted_runtime_generation_checks_running_operation_before_rejecting_changed_intent()
{
let temporary = tempfile::tempdir().expect("create changed-intent recovery project");
let root = temporary.path();
init_local_game_project_at(root, "changed-intent", "旧异步生成意图隔离")
@@ -10188,6 +10268,31 @@ mod canvas_generation_tests {
.set_nonblocking(true)
.expect("set changed intent fixture nonblocking");
let base_url = format!("http://{}", listener.local_addr().expect("fixture address"));
let (request_sender, request_receiver) = std::sync::mpsc::channel();
let (stop_sender, stop_receiver) = std::sync::mpsc::channel();
let server = std::thread::spawn(move || loop {
if stop_receiver.try_recv().is_ok() {
break;
}
let (mut stream, _) = match listener.accept() {
Ok(connection) => connection,
Err(error) if error.kind() == std::io::ErrorKind::WouldBlock => {
std::thread::sleep(Duration::from_millis(5));
continue;
}
Err(error) => panic!("accept changed intent request: {error}"),
};
request_sender
.send(read_test_http_request(&mut stream))
.expect("capture status request");
write_test_json_response(
&mut stream,
"200 OK",
&serde_json::json!({
"data": {"operationId": "old-operation", "status": "running"}
}),
);
});
let runtime_context = PlatformArtGenerationRuntimeContext {
agent_id: "art-director".to_string(),
task_id: "art-director".to_string(),
@@ -10253,10 +10358,15 @@ mod canvas_generation_tests {
error.contains("当前生成意图与已持久化请求快照不一致"),
"{error}"
);
assert!(matches!(
listener.accept(),
Err(error) if error.kind() == std::io::ErrorKind::WouldBlock
));
stop_sender.send(()).expect("stop changed intent fixture");
server.join().expect("join changed intent fixture");
let requests = request_receiver.try_iter().collect::<Vec<_>>();
assert_eq!(
requests.len(),
1,
"only the existing operation may be queried"
);
assert!(requests[0].starts_with("GET /api/external/v1/generations/old-operation "));
assert!(game_creator_agent_runtime_external_generation_exists(
root,
&runtime_context.agent_id,
@@ -10265,7 +10375,8 @@ mod canvas_generation_tests {
}
#[tokio::test]
async fn accepted_derived_generation_rejects_changed_art_spec_before_operation_get() {
async fn accepted_derived_generation_checks_running_operation_before_rejecting_changed_art_spec(
) {
let temporary = tempfile::tempdir().expect("create changed reference project");
let root = temporary.path();
init_local_game_project_at(root, "changed-reference", "规范图身份隔离")
@@ -10310,6 +10421,31 @@ mod canvas_generation_tests {
.set_nonblocking(true)
.expect("set changed reference fixture nonblocking");
let base_url = format!("http://{}", listener.local_addr().expect("fixture address"));
let (request_sender, request_receiver) = std::sync::mpsc::channel();
let (stop_sender, stop_receiver) = std::sync::mpsc::channel();
let server = std::thread::spawn(move || loop {
if stop_receiver.try_recv().is_ok() {
break;
}
let (mut stream, _) = match listener.accept() {
Ok(connection) => connection,
Err(error) if error.kind() == std::io::ErrorKind::WouldBlock => {
std::thread::sleep(Duration::from_millis(5));
continue;
}
Err(error) => panic!("accept changed reference request: {error}"),
};
request_sender
.send(read_test_http_request(&mut stream))
.expect("capture status request");
write_test_json_response(
&mut stream,
"200 OK",
&serde_json::json!({
"data": {"operationId": "old-background-operation", "status": "running"}
}),
);
});
let runtime_context = PlatformArtGenerationRuntimeContext {
agent_id: "direct-codex-art".to_string(),
task_id: "direct-codex-art-game-background".to_string(),
@@ -10412,10 +10548,19 @@ mod canvas_generation_tests {
"{error}"
);
assert!(error.contains("当前规范图身份"), "{error}");
assert!(matches!(
listener.accept(),
Err(error) if error.kind() == std::io::ErrorKind::WouldBlock
));
stop_sender
.send(())
.expect("stop changed reference fixture");
server.join().expect("join changed reference fixture");
let requests = request_receiver.try_iter().collect::<Vec<_>>();
assert_eq!(
requests.len(),
1,
"only the existing operation may be queried"
);
assert!(
requests[0].starts_with("GET /api/external/v1/generations/old-background-operation ")
);
assert!(game_creator_agent_runtime_external_generation_exists(
root,
&runtime_context.agent_id,
@@ -10809,6 +10954,38 @@ mod canvas_generation_tests {
mark_platform_art_generation_runtime_accepted(root, state, "test-operation-id", 0)
.expect("accept current generation fixture");
let sparse_options = PlatformArtAssetGenerationOptions {
output_path: Some(AGENT_RUNTIME_ART_SPEC_PATH.to_string()),
aspect_ratio: String::new(),
image_size: String::new(),
asset_kind: String::new(),
asset_label: String::new(),
..Default::default()
};
assert_eq!(
recover_persisted_visual_generation_options(root, &pending, prompt, &sparse_options)
.expect("recover persisted defaults"),
Some(options.clone())
);
assert!(recover_persisted_visual_generation_options(
root,
&pending,
"显式改变生成意图",
&sparse_options,
)
.unwrap()
.is_none());
let mut explicit_options = sparse_options.clone();
explicit_options.asset_kind = "game-background".to_string();
assert!(recover_persisted_visual_generation_options(
root,
&pending,
prompt,
&explicit_options,
)
.unwrap()
.is_none());
resume_game_creator_agent_background_tasks_at(root)
.expect("resume accepted generation through recovery scan");
let first = request_receiver
@@ -11063,19 +11240,18 @@ mod canvas_generation_tests {
}
#[test]
fn canonical_art_spritesheet_request_has_exactly_four_ordered_categories() {
fn canonical_art_spritesheet_request_preserves_project_requirements() {
let descriptions = canonical_art_spritesheet_icon_descriptions("原创收集玩法");
assert_eq!(descriptions.len(), 4);
for (index, description) in descriptions.iter().enumerate() {
assert!(description.starts_with(&format!("{}", index + 1)));
}
assert_eq!(descriptions.len(), 1);
assert!(descriptions[0].contains("原创收集玩法"));
assert!(descriptions[0].contains("数量、类别、排列和切片方式由本次需求决定"));
}
#[test]
fn canonical_art_spritesheet_descriptions_obey_external_editor_item_limit() {
let descriptions = canonical_art_spritesheet_icon_descriptions(&"原创玩法需求".repeat(128));
assert_eq!(descriptions.len(), 4);
assert!(!descriptions.is_empty());
assert!(descriptions
.iter()
.all(|description| description.chars().count() <= 200));
@@ -11466,7 +11642,7 @@ mod canvas_generation_tests {
}
#[test]
fn strict_slice_commit_rejects_non_four_slice_results_before_replacing_the_sheet() {
fn strict_slice_commit_rejects_empty_slice_results_before_replacing_the_sheet() {
let temporary = tempfile::tempdir().expect("create strict slice project");
let root = temporary.path();
init_local_game_project_at(root, "strict-slices", "严格切片测试")
@@ -11481,9 +11657,9 @@ mod canvas_generation_tests {
&replacement_options(),
|_| Ok(()),
)
.expect_err("strict spritesheet commit must require exactly four slices");
.expect_err("strict spritesheet commit must require at least one slice");
assert!(error.contains("恰好包含 4 个独立切片"));
assert!(error.contains("至少需要一个独立切片"));
assert_eq!(fs::read(path).expect("read preserved sheet"), b"old-image");
assert!(!root
.join("assets/art-spritesheet-slices/manifest.json")
@@ -337,9 +337,6 @@ pub(crate) fn agent_role_memory_relative_path_for_task(task_id: &str) -> Result<
if task_id == GAME_CREATOR_PROJECT_SUPERVISOR_AGENT_ID {
return Ok(GAME_CREATOR_PROJECT_SUPERVISOR_MEMORY_PATH.to_string());
}
if task_id == GAME_CREATOR_PROJECT_PLANNING_AGENT_ID {
return Ok(GAME_CREATOR_PROJECT_PLANNING_MEMORY_PATH.to_string());
}
for group in GAME_CREATOR_AGENT_GROUP_DEFINITIONS {
for role in group.roles {
if role.task_id == task_id {
File diff suppressed because it is too large Load Diff
@@ -44,7 +44,6 @@ pub(in crate::agent) use run_status_observation::*;
pub(in crate::agent) use structured_plan::*;
pub(in crate::agent) use tool_plan_protocol::*;
pub(crate) use crate::agent::runtime_protocol::plan_gdd_completion_blocker_at_locked;
#[cfg(test)]
pub(crate) use action_audit::agent_runtime_action_receipt_public_safe_detail_for_test;
#[cfg(test)]
@@ -74,7 +73,6 @@ pub(crate) use context_compaction::compact_game_creator_agent_runtime_session_at
pub(crate) use parallel_ledger::{
agent_runtime_confirmation_path_component, agent_runtime_parallel_read_batch_len,
agent_runtime_tool_allowed_for_agent, agent_runtime_tool_is_parallel_safe_read,
agent_runtime_tool_rejected_by_agent_identity,
game_creator_agent_runtime_parallel_read_batch_path,
game_creator_agent_runtime_pending_tool_action_path,
game_creator_agent_runtime_provider_action_batch_path,
@@ -106,6 +104,7 @@ pub(crate) use project_gates::{
prepare_agent_runtime_project_mutation_locked, process_session_completion_blocker_at,
project_verification_completion_blocker, project_verification_completion_blocker_at,
static_delegate_completion_blocker_at, structured_plan_completion_blocker,
try_acquire_game_creator_agent_runtime_project_write_lock,
validate_agent_runtime_pending_verification_gate_before,
};
#[cfg(test)]
@@ -116,7 +115,6 @@ pub(crate) use project_gates::{
};
pub(crate) use provider_action_batch::{
prepare_game_creator_agent_runtime_provider_action_batch,
prepare_game_creator_agent_runtime_provider_action_batch_with_planning_binding,
update_game_creator_agent_runtime_provider_batch_member, AgentRuntimePendingToolAction,
AgentRuntimeProviderActionBatch,
};
@@ -147,9 +145,6 @@ pub(crate) use tool_plan_protocol::parse_game_creator_agent_tool_plan_response;
pub(crate) use tool_policy_snapshot::{
agent_runtime_acceptance_evidence_tools,
agent_runtime_autonomous_design_foundation_command_is_allowed, agent_runtime_executable_tools,
agent_runtime_native_executable_tools, agent_runtime_plan_root_supervisor_tools,
agent_runtime_plan_root_supervisor_tools_for_stage,
agent_runtime_tool_policy_snapshot_for_run_at, plan_root_supervisor_stage_at,
plan_root_supervisor_stage_at_locked, PlanRootSupervisorStage,
AGENT_RUNTIME_CANVAS_ASSET_KINDS, AGENT_RUNTIME_PROJECT_PLANNING_ACTION_TOOLS,
agent_runtime_native_executable_tools, agent_runtime_tool_policy_snapshot_for_run_at,
AGENT_RUNTIME_CANVAS_ASSET_KINDS,
};
@@ -38,29 +38,6 @@ pub(crate) async fn execute_game_creator_agent_runtime_tool_action_with_pending_
) -> AgentRuntimeToolObservation {
let tool = action.tool.trim();
let relaxed_autonomous = autonomous_relaxed_run_at(root, agent_id, run_id).unwrap_or(false);
if tool == PLAN_SUBMIT_GDD_TOOL && agent_id.trim() != GAME_CREATOR_PROJECT_PLANNING_AGENT_ID {
return AgentRuntimeToolObservation {
tool: tool.to_string(),
status: "rejected".to_string(),
summary: "plan.submit_gdd 仅允许 project-planning Agent".to_string(),
detail: None,
};
}
if agent_id.trim() == GAME_CREATOR_PROJECT_PLANNING_AGENT_ID
&& !matches!(tool, "file.read" | "file.list")
{
// `plan.submit_gdd` is intentionally handled by the planning submit
// branch in the Runtime main loop. If it ever reaches the generic
// executor (including recovery or a stale pending record), fail
// closed instead of treating the durable mutation as an ordinary
// command action.
return AgentRuntimeToolObservation {
tool: tool.to_string(),
status: "rejected".to_string(),
summary: "当前 Agent 身份不允许执行该工具".to_string(),
detail: None,
};
}
let action_fingerprint = pending_action
.map(|pending| {
agent_runtime_pending_tool_action_fingerprint(
@@ -2011,17 +2011,6 @@ mod tests {
assert!(error.contains("不得启动 isolated child"));
}
#[test]
fn autonomous_initial_collaboration_requires_leader_artifacts() {
let mut plan = autonomous_initial_leader_plan();
plan.actions[1] = autonomous_initial_delegate("art-director", &[]);
let error = validate_agent_runtime_autonomous_initial_collaboration_contract(&plan)
.expect_err("art artifact must be required");
assert!(error.contains("expectedArtifacts 必须包含 assets/art-spec.png"));
}
#[test]
fn autonomous_manifest_dag_waits_only_after_seed_execution_starts() {
let temporary = tempfile::tempdir().expect("create manifest DAG policy root");
@@ -25,11 +25,6 @@ pub(in crate::agent) async fn compact_game_creator_agent_runtime_context_at(
root,
"runtime.context_compaction.build",
)?;
if agent_id == GAME_CREATOR_PROJECT_PLANNING_AGENT_ID {
// Advance the immutable Provider-usage projection before any
// request/source bytes are rebuilt from the plan session.
fold_plan_provider_usage_before_new_request_at_locked(root, Some((agent_id, run_id)))?;
}
let source = build_game_creator_agent_runtime_context_compaction_source(
root,
agent_id,
@@ -67,18 +62,6 @@ pub(in crate::agent) async fn compact_game_creator_agent_runtime_context_at(
let config_path = format!("agentLlm.{template_agent_id}");
let mut request =
build_game_creator_agent_runtime_context_compaction_request(&source, &llm)?;
let planning_agent = agent_id == GAME_CREATOR_PROJECT_PLANNING_AGENT_ID;
if planning_agent {
if allow_idle_context_compaction {
return Err(
"project-planning 不支持脱离 active run 的 idle context compaction".to_string(),
);
}
let wire_bytes =
capture_plan_provider_structured_injections_at(root, session_id, observations)?;
let message = render_plan_provider_structured_injections_message(&wire_bytes)?;
request.messages.insert(1, LlmMessage::user(message));
}
let estimated_request_tokens = estimate_game_creator_llm_request_tokens(&request)?;
validate_game_creator_llm_request_context_budget(
&llm,
@@ -106,22 +89,6 @@ pub(in crate::agent) async fn compact_game_creator_agent_runtime_context_at(
applied_steer_cursor,
)?
};
let snapshot = if planning_agent {
let request_context_fingerprint =
game_creator_agent_runtime_plan_provider_request_context_fingerprint(
&llm, &request,
)?;
let runtime = read_game_creator_agent_runtime_at(root, agent_id)?.state;
let binding = capture_plan_provider_session_binding_for_snapshot(
root,
&runtime,
&snapshot,
&request_context_fingerprint,
)?;
snapshot.with_planning_session_binding(Some(binding))
} else {
snapshot
};
(snapshot, source, llm, config_path, request)
};
let handoff_identity =
@@ -188,7 +155,6 @@ pub(in crate::agent) async fn compact_game_creator_agent_runtime_context_at(
let request_id = resolve_game_creator_agent_runtime_provider_request_attempt_at_locked(
root,
&base_request_id,
snapshot.planning_session_binding.is_some(),
)
.map(|value| value.0)
.unwrap_or(base_request_id);
@@ -212,7 +178,6 @@ pub(in crate::agent) async fn compact_game_creator_agent_runtime_context_at(
let request_id = resolve_game_creator_agent_runtime_provider_request_attempt_at_locked(
root,
&base_request_id,
snapshot.planning_session_binding.is_some(),
)
.map(|value| value.0)
.unwrap_or(base_request_id);
@@ -246,7 +211,6 @@ pub(in crate::agent) async fn compact_game_creator_agent_runtime_context_at(
let request_id = resolve_game_creator_agent_runtime_provider_request_attempt_at_locked(
root,
&base_request_id,
snapshot.planning_session_binding.is_some(),
)
.map(|value| value.0)
.unwrap_or(base_request_id);
@@ -109,7 +109,6 @@ pub(in crate::agent) fn game_creator_agent_runtime_tool_command_id(
"agent.schedule_ready" => Some("agent.schedule_ready"),
"agent.action_history" => Some("agent.audit"),
"agent.run_status" => Some("agent.run_status"),
PLAN_SUBMIT_GDD_TOOL => Some(PLAN_SUBMIT_GDD_TOOL),
_ => None,
}
}
@@ -119,15 +118,7 @@ pub(in crate::agent) fn game_creator_agent_runtime_tool_command_id(
/// id (for example `project.search` and `file.read`); policy lookup alone must
/// not turn that aliasing into an identity escalation for a restricted Agent.
pub(crate) fn agent_runtime_tool_allowed_for_agent(agent_id: &str, tool: &str) -> bool {
if agent_id.trim() == GAME_CREATOR_PROJECT_PLANNING_AGENT_ID {
return matches!(
tool.trim(),
"file.read" | "file.list" | PLAN_SUBMIT_GDD_TOOL
);
}
if tool.trim() == PLAN_SUBMIT_GDD_TOOL {
return false;
}
let _ = agent_id;
if tool.trim() == GAME_CREATOR_USER_INPUT_REQUEST_TOOL {
// `user.input_request` is a protocol control handled by the main
// loop, not by the command-id policy map. It remains available to
@@ -137,95 +128,10 @@ pub(crate) fn agent_runtime_tool_allowed_for_agent(agent_id: &str, tool: &str) -
game_creator_agent_runtime_tool_command_id(tool.trim()).is_some()
}
/// 身份层面的**显式**拒绝:该 Agent 身份带 exact allowlist,且工具不在其中。
///
/// **未知工具名不属于本判据。** `agent_runtime_tool_allowed_for_agent` 对普通
/// Agent 退化成「这个工具名是否已知」,用它做身份门会把「模型编了个不存在的
/// 工具」这种普通协议错误误判成身份违规。协议错误的既有语义是:走到执行层产出
/// 一条 `rejected` observationrun 继续,由下一轮 tool-plan 收束;升级成身份
/// 拒绝会让整个 run 进 needs-reconciliation 而**不再发出 follow-up 请求**。
///
/// 因此凡是「命中即中断 run 或整体拒绝动作」的调用点都必须用本判据,不能直接
/// 用 `agent_runtime_tool_allowed_for_agent`。
pub(crate) fn agent_runtime_tool_rejected_by_agent_identity(agent_id: &str, tool: &str) -> bool {
agent_id.trim() == GAME_CREATOR_PROJECT_PLANNING_AGENT_ID
&& !agent_runtime_tool_allowed_for_agent(agent_id, tool)
}
#[cfg(test)]
mod identity_tests {
use super::*;
/// 普通 Agent 编出来的未知工具名是**协议错误**,不是身份违规。
///
/// 判成身份违规会让 main_loop 把整个 run 打进 needs-reconciliation、不再发出
/// follow-up tool-plan——曾导致 `background_agent_runtime_persists_receipts_for_rejected_actions`
/// 在等待第二次 Provider 请求时超时。
#[test]
fn unknown_tool_on_ordinary_agent_is_not_an_identity_rejection() {
assert!(!agent_runtime_tool_rejected_by_agent_identity(
"design-director",
"runtime.unknown"
));
assert!(!agent_runtime_tool_rejected_by_agent_identity(
GAME_CREATOR_PROJECT_SUPERVISOR_AGENT_ID,
"runtime.unknown"
));
assert!(!agent_runtime_tool_rejected_by_agent_identity(
"design-director",
"file.read"
));
}
/// planning 身份仍是 exact allowlist:未知工具与越权工具都算身份拒绝。
#[test]
fn planning_identity_still_rejects_unknown_and_out_of_scope_tools() {
assert!(agent_runtime_tool_rejected_by_agent_identity(
GAME_CREATOR_PROJECT_PLANNING_AGENT_ID,
"runtime.unknown"
));
assert!(agent_runtime_tool_rejected_by_agent_identity(
GAME_CREATOR_PROJECT_PLANNING_AGENT_ID,
"file.write"
));
assert!(!agent_runtime_tool_rejected_by_agent_identity(
GAME_CREATOR_PROJECT_PLANNING_AGENT_ID,
"file.read"
));
assert!(!agent_runtime_tool_rejected_by_agent_identity(
GAME_CREATOR_PROJECT_PLANNING_AGENT_ID,
PLAN_SUBMIT_GDD_TOOL
));
}
#[test]
fn planning_identity_does_not_inherit_project_search_alias() {
assert!(agent_runtime_tool_allowed_for_agent(
GAME_CREATOR_PROJECT_PLANNING_AGENT_ID,
"file.read"
));
assert!(agent_runtime_tool_allowed_for_agent(
GAME_CREATOR_PROJECT_PLANNING_AGENT_ID,
"file.list"
));
assert!(!agent_runtime_tool_allowed_for_agent(
GAME_CREATOR_PROJECT_PLANNING_AGENT_ID,
"project.search"
));
assert!(agent_runtime_tool_allowed_for_agent(
GAME_CREATOR_PROJECT_PLANNING_AGENT_ID,
PLAN_SUBMIT_GDD_TOOL
));
assert!(!agent_runtime_tool_allowed_for_agent(
GAME_CREATOR_PROJECT_SUPERVISOR_AGENT_ID,
PLAN_SUBMIT_GDD_TOOL
));
assert!(agent_runtime_tool_allowed_for_agent(
GAME_CREATOR_PROJECT_SUPERVISOR_AGENT_ID,
"project.search"
));
}
#[test]
fn account_asset_library_uses_the_existing_read_only_asset_permission() {
assert_eq!(
@@ -336,33 +336,6 @@ pub(in crate::agent) fn validate_agent_runtime_pending_tool_action_record(
let relaxed_autonomous = autonomous_relaxed_run_profile(&pending.run_profile);
if !relaxed_autonomous {
validate_agent_runtime_pending_goal_binding(pending)?;
match pending.planning_session_binding.as_ref() {
Some(binding) => {
validate_plan_provider_session_binding(binding)
.map_err(|error| error.to_string())?;
if pending.action.tool.trim() != PLAN_SUBMIT_GDD_TOOL
|| binding.agent_id != pending.agent_id
|| binding.task_id != pending.task_id
|| binding.session_id != pending.session_id
|| binding.run_id != pending.run_id
|| binding.source != pending.source
|| binding.run_profile != pending.run_profile
|| binding.run_profile_binding_fingerprint
!= pending.run_profile_binding_fingerprint
|| binding.applied_steer_cursor != pending.planned_steer_cursor
{
return Err(
"planning submit standalone pending 与 frozen binding 不一致".to_string(),
);
}
}
None if pending.provider_batch_plan_update.is_none() => {}
None => {
return Err(
"非 planning standalone pending 不能携带 Provider batch planUpdate".to_string(),
);
}
}
validate_agent_runtime_project_revision(root, &pending.project_revision_before)?;
if pending.verification_gate_before.project_id
!= game_creator_agent_runtime_context_project_id(root)?

Some files were not shown because too many files have changed in this diff Show More