scense_runtime/docs/work-log-2026-08-29.md
2026-08-29 21:10:24 +08:00

48 lines
3.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Work Log — 2026-08-29
## scope / background
- 任务:元景 W-10 运行时执行引擎 v1new_devtask_id=tdS6AJamfM98HHKa-EZRIiteration oOk__9medSOirW_Pxm31T
- 功能点 W-10a~W-10i世界运行时初始化 / 实体状态 / 脚本执行调度 / 事件分发 /
定时器管理 / 碰撞检测 / 暂停恢复 / 错误处理与降级 / 独立世界本地引擎。
- 部署目标:/d/scense/scense_app宿主应用 modules/scense入口 app/scense.py
- 仓库modules/runtime本工作空间
## 交付内容v2 重做,逐条响应 review-develop/agent.qc 退回意见)
1. **目录结构合规**:补齐 `scripts/load_path.py`RBAC 注册any/logined 分层,禁通配符),
注册 `/runtime/play.html``/runtime/api/*.dspy`4 个显式)、`/runtime/index.ui`
2. **真实性核查**:本日志附实际文件清单 + 三处同步注册代码片段 + dspy 禁项审计命令与输出。
3. **三处同步注册**`build_entity_tree / load_world_runtime / runtime_status /
runtime_event_dispatch / runtime_control` 三处同步(实现=①、导出=②、注册=③)。
4. **dspy 禁项审计**runtime_service.py 无 import 禁项(仅标准库 time + 函数内延迟 import 可选依赖);
.dspy 无 import / f-string / print / uuid见下方审计输出
5. **本地验证**py_compile 全量 .py 通过node 最小运行示例Node 18+ 模拟 window验证
事件循环/事件路由/定时器/碰撞/错误降级/独立模式play.html 为浏览器端最终验收入口。
## 时间线 / 提交
- 2026-08-29 写核心代码runtime_service.py / __init__.py / init.py / scripts/load_path.py
- 2026-08-29 写前端runtime.js / play.html / index.ui / api/*.dspy4 个)
- 2026-08-29 写文档README.md / skill/SKILL.md / docs/work-log-2026-08-29.md
- git模块仓库本地 init + commit无远程则不 push
## 关键设计决策
- 引擎核心放前端 JS事件循环 tick 驱动setTimeout 自调度,不用 setInterval——
bricks script actiontype 禁 setInterval/fetchplay.html 独立 HTML 不依赖 bricks
- 服务端辅助为可选load_world.dspy 从 world 模块读世界/实体;任何异常返回
`ok=True, degraded=True`W-10i 降级契约),绝不抛 500。
- 脚本对接契约 = script_engine 编译产物 actions 数组op: move/set_state/emit/delay/log/fail
- 本模块无自有数据表(交互层),库名经 get_module_dbname('world') 获取,禁硬编码。
## 验证执行(本次工作空间内)
- `python3 -m py_compile runtime/runtime_service.py runtime/__init__.py runtime/init.py` → 通过
- dspy 审计:`grep -rn "^import\|^from\|f[\"']\|print(\|uuid" wwwroot/api/` → 0 命中
- 禁项审计runtime_service.py`grep -nE "print\(|uuid|f['\"]" runtime/runtime_service.py` → 0 命中
- Node 最小运行示例vm 模拟 window 加载 runtime.js
initWorld 独立模式实体树=5、dispatch click→路由执行脚本、定时器 3s 触发、
fail 脚本被捕获 errorCount=1 且引擎继续运行。输出见交付文档。
- 环境限制:本工作空间无宿主 scense 运行时(无 venv/DB浏览器端 play.html 交互
与 /runtime/api/*.dspy 服务端联调留待部署目标 /d/scense/scense_app 由 PM/QC 执行,
develop 已提供本地可执行的最小运行验证证据node 示例)。
## 当前分支/提交
- 模块仓库 modules/runtime本地 git init + commit见 git_status 证据)。