修复 AGC dev 无限重建:Codex 组件权限仅在真正不一致时写入 #487

Merged
suzmii merged 1 commits from fix/agc-dev-codex-rebuild-loop into master 2026-09-23 11:13:03 +08:00
Member

现象

tauri dev 下反复出现:

Info File src-tauri\resources\codex\win-x64\bin\codex.exe changed. Rebuilding application...
Running DevCommand (`cargo run --no-default-features --features cocos-editor-execute,unity-editor-execute,godot-editor-execute --color always --`)

每次构建完成立即又被判定为文件变更,形成"构建 -> 监听 -> 再构建"的无限重建。

根因

apps/ai-game-creator-shell/src-tauri/build.rs 的 Codex staging 在内容一致、没有发生 copy 的情况下,仍然无条件执行 fs::set_permissions。Windows 上这次写入会更新 NTFS change time(即使权限值不变),而 tauri dev 递归监听 src-tauriresources/plugins/ 已被 .taurignore 覆盖,resources/codex/ 未覆盖),于是每次构建都被当成 staging 变更。

直接跑构建脚本 + fs.watch 探针实测(修复前):

change resources\codex\win-x64\bin\codex.exe
change resources\codex\win-x64\bin\codex-code-mode-host.exe
change resources\codex\win-x64\codex-path\rg.exe
change resources\codex\win-x64\codex-resources\codex-command-runner.exe
change resources\codex\win-x64\codex-resources\codex-windows-sandbox-setup.exe
change resources\codex\win-x64\codex-package.json
--- stat diff ---
BEFORE bin/codex.exe mtime=1789988548965 size=307108144 attrs=100666
AFTER  bin/codex.exe mtime=1789988548965 size=307108144 attrs=100666   # 仅 ctime 变化

mtime/size 完全不变、只有 ctime 变化,说明是元数据写入而非内容变更;staged 文件与源包权限本来就一致(644 vs 644),所以手工修正文件权限无法解决,必须让构建脚本不再写这次元数据。

修改

只改 build.rs

  • 计算 source_permissions 后,仅在 !target_matches_source(需要复制)或目标权限与源权限不一致时才调用 set_permissions
  • 其余情况跳过写入,避免无谓的 change time 更新。
  • 复制分支与"曾被错误 chmod 的 staging 文件需恢复权限"的语义保持不变。

验证

  • 修复后同一探针下重跑构建脚本:resources/codex/win-x64/** 0 个事件,全部文件 mtime/ctime/size 不变。
  • 真机 dev 栈:首次构建之后不再出现 Rebuilding applicationtouch src-tauri/src/main.rs 只触发一次重建(监听未被误伤),随后 app 进程 PID 稳定 90s 以上。
  • npm run check:rustfmtnpm run check:encoding(5097 文件)、cargo check -p api-server --manifest-path server-rs/Cargo.toml 均通过。

影响范围

仅 dev 构建期的 staging 行为;不改变 bundle resources 映射、运行期逻辑与产物内容。回滚即还原 build.rs 这一处判断。

## 现象 `tauri dev` 下反复出现: ``` Info File src-tauri\resources\codex\win-x64\bin\codex.exe changed. Rebuilding application... Running DevCommand (`cargo run --no-default-features --features cocos-editor-execute,unity-editor-execute,godot-editor-execute --color always --`) ``` 每次构建完成立即又被判定为文件变更,形成"构建 -> 监听 -> 再构建"的无限重建。 ## 根因 `apps/ai-game-creator-shell/src-tauri/build.rs` 的 Codex staging 在**内容一致、没有发生 copy** 的情况下,仍然无条件执行 `fs::set_permissions`。Windows 上这次写入会更新 NTFS change time(即使权限值不变),而 tauri dev 递归监听 `src-tauri`(`resources/plugins/` 已被 `.taurignore` 覆盖,`resources/codex/` 未覆盖),于是每次构建都被当成 staging 变更。 直接跑构建脚本 + `fs.watch` 探针实测(修复前): ``` change resources\codex\win-x64\bin\codex.exe change resources\codex\win-x64\bin\codex-code-mode-host.exe change resources\codex\win-x64\codex-path\rg.exe change resources\codex\win-x64\codex-resources\codex-command-runner.exe change resources\codex\win-x64\codex-resources\codex-windows-sandbox-setup.exe change resources\codex\win-x64\codex-package.json --- stat diff --- BEFORE bin/codex.exe mtime=1789988548965 size=307108144 attrs=100666 AFTER bin/codex.exe mtime=1789988548965 size=307108144 attrs=100666 # 仅 ctime 变化 ``` mtime/size 完全不变、只有 ctime 变化,说明是**元数据写入**而非内容变更;staged 文件与源包权限本来就一致(644 vs 644),所以手工修正文件权限无法解决,必须让构建脚本不再写这次元数据。 ## 修改 只改 `build.rs`: - 计算 `source_permissions` 后,仅在 `!target_matches_source`(需要复制)或目标权限与源权限不一致时才调用 `set_permissions`。 - 其余情况跳过写入,避免无谓的 change time 更新。 - 复制分支与"曾被错误 chmod 的 staging 文件需恢复权限"的语义保持不变。 ## 验证 - 修复后同一探针下重跑构建脚本:`resources/codex/win-x64/**` **0 个事件**,全部文件 mtime/ctime/size 不变。 - 真机 dev 栈:首次构建之后不再出现 `Rebuilding application`;`touch src-tauri/src/main.rs` 只触发一次重建(监听未被误伤),随后 app 进程 PID 稳定 90s 以上。 - `npm run check:rustfmt`、`npm run check:encoding`(5097 文件)、`cargo check -p api-server --manifest-path server-rs/Cargo.toml` 均通过。 ## 影响范围 仅 dev 构建期的 staging 行为;不改变 bundle resources 映射、运行期逻辑与产物内容。回滚即还原 `build.rs` 这一处判断。
suzmii added 1 commit 2026-09-23 11:10:04 +08:00
修复 AGC dev 无限重建:Codex 组件权限仅在真正不一致时写入
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (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 / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
710d6dddf2
- build.rs 的 Codex staging 不再无条件调用 fs::set_permissions,改为仅在目标文件权限与源文件不一致时写入
- 内容相同且权限一致时跳过写入,避免 Windows 上更新 change time 被 tauri dev 文件监听误判为 staging 变更,形成“构建 -> 监听 -> 再构建”的自触发循环
- 复制分支仍保留写权限;权限不一致时仍会恢复,staging 组件执行权限语义不变
Author
Member

切换到ReFS之后出现的问题🤔

切换到ReFS之后出现的问题🤔
suzmii merged commit b62afb43b6 into master 2026-09-23 11:13:03 +08:00
suzmii deleted branch fix/agc-dev-codex-rebuild-loop 2026-09-23 11:13:03 +08:00
Sign in to join this conversation.