AGC 壳通知计数按线程隔离,修掉跨用例后台广播串台

- runtime_driver/entrypoints.rs:测试通知计数从进程级 AtomicU64 改成线程作用域 Cell,只统计本测试线程发出的通知
- runtime_driver/entrypoints.rs:`--test-threads=1` 只串行测试线程,前一个用例放行留下的后台回合仍在宿主 async runtime 工作线程上广播「运行中的项目」通知,不再是断言的取样来源
- thread_manager/mod.rs:同步用例注释,说明计数为何按线程隔离,断言语义(放行 1 / 内容变化 1 / 重复进度 0 / 收口 1)不变
- pitfalls:记录现场、根因、现行口径与验证(修复前 5 次红 3 次,修复后 CI 那一片连跑 18 次全绿)
This commit is contained in:
2026-10-01 16:42:02 +08:00
parent b51bf03854
commit c177dde5c3
3 changed files with 21 additions and 4 deletions
@@ -6183,3 +6183,12 @@ Cocos Creator 根目录由 `package.json.creator.version` 与普通 `assets/`
- **同时**:主站顶栏(`platform-desktop-topbar`)在窄屏必须保持单行——加 `flex-wrap` 后新增一个动作入口就会让品牌折到第二行;窄屏降级靠 `< 640px` 图标化下载入口、`< 480px` 只留品牌 IP 标识。
- **验证**:真机尺寸下用 `document.elementFromPoint(按钮中心)` 断言命中的是按钮自身而不是底部菜单(`overlay.parentElement === document.body`);顶栏断点矩阵(320–768)断言单行且无横向溢出。
- **关联**:`src/components/common/SquareImageCropModal.tsx`、`src/components/platform-entry/PlatformProfileModalShell.tsx`、`src/components/platform-entry/PlatformEntryActiveFlowShell.tsx`、`src/index.css`。
## 2026-10-01 AGC 壳 Rust 单测片内 `--test-threads=1` 不等于没有并发:宿主后台回合会跨用例发通知
- **现象**:`agent::thread_manager::tests::active_turn_changes_publish_one_notification_per_real_change` 在 CI 偶发红,`进度内容变化必须通知一次` 拿到 6 而非 5(也见过入队断言就多 1);本地要跑 3–5 次才复现。这条用例靠一个进程级计数器数「运行中的项目」通知。
- **原因**:`--test-threads=1` 只串行**测试线程**。上一个用例里 `TurnReservation::drop` → `kick_queue_dispatch` 会用 `tauri::async_runtime::spawn` 起整轮,这轮在 tokio 工作线程上继续跑(项目路径不存在 → 落盘失败 → `complete_turn_if_reserved` → `emit_direct_active_turns_changed`),恰好落在下一个用例的取样窗口里。用工作线程 ID + backtrace 才抓到现场。
- **处理(现行口径)**:通知计数器改成线程作用域,只统计本测试线程发出的通知,断言语义(放行 1 / 内容变化 1 / 重复进度 0 / 收口 1)不变。「进程级全局量 + 片内串行 ⇒ 安全」这个假设在 AGC 壳单测里不成立,要么按线程隔离,要么别用全局量当断言依据。
- **同时**:分片器的失败复核原先只认 `tests::` / `process_session::tests::` 前缀,而 bin 目标用例名是 `agent::…::tests::…`,于是 3143 条里 2218 条永远进不了复核,偶发假红直接判红;现在按本片名单精确匹配,并且复核也失败时保留首次现场。
- **验证**:本机用 CI 那一片(`--shards=4 --shard-index=1` 的第 3 块)连跑:修复前 5 次红 3 次,修复后 18 次全绿;`node --test apps/ai-game-creator-shell/scripts/run-rust-shell-test-shards.test.mjs` 3 项通过。
- **关联**:`apps/ai-game-creator-shell/src-tauri/src/agent/runtime_driver/entrypoints.rs`、`apps/ai-game-creator-shell/src-tauri/src/agent/thread_manager/dispatch.rs`、`apps/ai-game-creator-shell/scripts/run-rust-shell-test-shards.mjs`。