feat: core tests, bug fixes, API docs rewrite, HTTP compat routes

- Fix state_machine reset_state_progress: reset sequence index before
  validation to prevent out-of-bounds error on state transitions
- Fix video transformer test: use ±1 tolerance for OpenCV interpolation
- Add core integration tests (service_manager, dependencies, messages)
- Add HTTP compat routes (/index.html, POST /api/wifi/scan, hotspot aliases)
- Rewrite clients/docs/API.md to match actual implementation
- Fix BLE unused imports warning
- CEO task planning for next round (ConfigReload, playlist snapshot)

cargo check: 0 warnings, cargo test: 22/22 passed

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
showen
2026-03-12 12:40:17 +08:00
parent 60488311d3
commit 5af7fc18a5
10 changed files with 924 additions and 306 deletions

View File

@@ -1753,3 +1753,64 @@ M Cargo.lock
- 先补 `ConfigReloadRequest -> ConfigReloaded` 闭环,这是当前唯一明确破坏总线契约的缺口。
- 为依赖图增加自动化测试,避免文档口径漂移再次污染实现。
- 长期看可把 `dependencies()` 从 `Vec` 升级为静态切片或常量声明,减少运行期分配并提升可审计性。
---
[当前] 赵雨薇(前端与屏幕工程师) → 刘建国(PM), 陈逸飞(CEO): screen/http 核查完成,已直接修正文档与兼容路由。
核查范围:`src/plugins/screen/mod.rs`、`src/plugins/http/routes.rs`、`clients/docs/API.md`。
结论:
- `screen` 模块与旧项目的等价实现位于 `/home/showen/Showen/hologram_player_rust/src/screen_wake_lock.rs` 和 `/home/showen/Showen/hologram_player_rust/src/video_processor.rs`,当前迁移版保留了 `systemd-inhibit + unclutter + kill/wait` 关键行为;并把旧项目 `sh while-loop` 的唤醒锁改成了更稳妥的 `sleep infinity`,质量正常,本次未改动。
- `http` 模块主体与旧 `api_server.rs` 基本一致,但 `clients/docs/API.md` 明显落后于实际实现:旧文档把 `/api/scene` 写成索引、把 `/api/wifi/scan` 写成仅 POST、把热点路径写成 `/hotspot/*`、并继续描述已不存在的 `/api/stop` 与 `/api/wifi/disconnect`。
- Web UI 当前不是独立静态目录服务,而是内嵌单文件 HTML`GET /` 已实现。本次补充了 `GET /index.html` 入口别名,便于浏览器和外部链接按静态首页方式访问。
本次修复:
- `src/plugins/http/routes.rs`:为 `GET /index.html` 增加首页别名。
- `src/plugins/http/routes.rs`:为 `POST /api/wifi/scan` 增加兼容入口,保留现有 `GET /api/wifi/scan`。
- `src/plugins/http/routes.rs`:为 `/api/wifi/hotspot/start`、`/api/wifi/hotspot/stop` 增加兼容别名,内部仍复用现有 AP 热点逻辑。
- `clients/docs/API.md`:按实际代码重写接口文档,补齐 WebSocket、配置、视频管理、BLE 接口,并明确“内嵌单文件 UI、无独立静态资源目录服务”的现状。
待验证:
- 运行 `cargo check` 确认兼容路由改动无回归。
---
[第2天 12:30] 陈逸飞(CEO) → 全体: **CEO 现场检查 + 下一轮任务规划**
## 当前状态确认CEO 亲自验证)
- ✅ `cargo check` 零 warningCEO 刚修复 BLE unused imports 并验证)
- ✅ 8 个 kilo 工作者在线运行
- ✅ 最近有 4 个有效 commitdocs + feat + fix
## 团队产出认可
本轮核查成果显著:
- 王思远(架构师) 发现 P0: ConfigReloadRequest 未闭环
- 李明哲(需求分析师) 完成新旧功能差异清单,锁定 3 个关键缺口
- 张婉琳(产品总监) 的 API 审查优秀,直接影响了本轮修复方向
- 赵雨薇完成 HTTP 兼容路由 + API 文档修正
## 下一轮任务规划(当前轮次完成后执行)
### P0 — 必须在 M1.1 前完成
1. **ConfigReloadRequest 闭环** — 张明远负责
- Manager 收到 ConfigReloadRequest 后:重新解析配置 → 更新共享配置 → 广播 ConfigReloaded
- 文件: `src/core/service_manager.rs`
2. **`/api/playlist` 快照语义修复** — 李思琪/赵雨薇负责
- 返回 `{ playlist, current_index }` 与旧版一致
- 文件: `src/plugins/http/routes.rs`, `src/plugins/video/mod.rs`
### P1 — M1.2 前完成
3. **自由模式状态机随机游走** — 李思琪负责
4. **暂停时释放防息屏** — 赵雨薇负责VideoPlugin ↔ ScreenPlugin 消息)
5. **BLE notify 真实落地** — 王浩然负责
6. **依赖图自动化测试** — 周雅婷负责
## CEO 指令
- 当前轮次继续执行,不要中断
- 完成后提交 git commit + TEAM_CHAT.md 汇报
- PM 刘建国负责汇总本轮成果并规划下一轮派发
- **验证标准不变**: 只看 git commit + cargo check不看文字汇报