Files
Genarrative/server-rs/crates/module-runtime
kdletters 458371a73d
Project CI / Repository checks (push) Successful in 4m11s
Project CI / Frontend tests (push) Successful in 8m38s
Project CI / Backend tests (push) Successful in 10m42s
Project CI / Native shell tests (push) Successful in 32m11s
将退款 outbox 主路径迁入 SpacetimeDB (#204)
## 变更内容

- 新增 `profile_wallet_refund_outbox` 表与 enqueue/process procedure,退款主路径进入 SpacetimeDB。
- 外部生成失败事务、inline 资产失败和跨节点 worker 统一使用库内 outbox,按 ledger 幂等并在事务内完成退款与删除。
- SpacetimeDB 完全不可达时才写本机 emergency spool,恢复时重新入库;兼容旧 spool 文件并保留 attempt 追踪。
- 更新 SpacetimeDB migration、生成 bindings、架构文档、运维恢复说明和项目决策记录。

## 验证

- `cargo check -p spacetime-module -p spacetime-client -p api-server --manifest-path server-rs/Cargo.toml`
- api-server / spacetime-client / spacetime-module / module-runtime 定向测试
- `npm run check:spacetime-schema`
- `npm run check:spacetime-runtime-access`
- `npm run check:server-rs-ddd`
- `npm run check:encoding`
- `git diff --check`

Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/204
Co-authored-by: kdletters <kdletters@qq.com>
Co-committed-by: kdletters <kdletters@qq.com>
2026-08-27 22:04:50 +08:00
..

module-runtime 独立模块 package 占位说明

日期:2026-04-20

1. package 职责

module-runtime 是运行时状态基座模块 package,后续负责:

  1. runtime_snapshotruntime_setting 等主状态模型
  2. profile dashboard、browse history、save archive 相关读写模型
  3. 运行时状态归一化与兼容聚合快照策略
  4. apps/api-server 的 runtime facade 对接
  5. apps/spacetime-module 的运行时表与 view 聚合对接

2. 当前阶段说明

当前已进入 DDD 分层拆分阶段,但仍以小切片推进,不提前改动未冻结的表结构、projection 与接口实现。

后续与本 package 直接相关的任务包括:

  1. 设计 runtime_snapshotruntime_setting
  2. 设计 profile_dashboard_stateprofile_wallet_ledger
  3. 设计 profile_played_worldprofile_save_archiveuser_browse_history
  4. 落地存档、设置、资料页兼容接口

已落地的拆分切片:

  1. runtime settings 的默认值、平台主题值对象与设置聚合已迁入 src/domain.rs,根入口通过 pub use domain::* 保持原有 crate API。
  2. runtime snapshot、profile dashboard、wallet、recharge、referral、played world、play stats、save archive 的快照、输入、过程结果与记录投影类型已迁入 src/domain.rs
  3. settings、browse history、profile/save 三组字段错误和中文错误文案已迁入 src/errors.rs
  4. settings、browse history、profile/save 等输入构造和写入归一化函数已迁入 src/commands.rs
  5. settings、browse history、profile/save 等记录投影 builder 已迁入 src/application.rs
  6. checkpoint、profile/save archive meta、充值/邀请/兑换/钱包等剩余纯规则已迁入 src/application.rsspacetime-module 只保留表事务读写,api-server 只保留 HTTP/BFF 映射。
  7. 详细边界与验收记录见:
    • docs/【玩法创作】平台入口与玩法链路-2026-05-15.md
    • docs/【后端架构】server-rs与SpacetimeDB数据契约-2026-05-15.md
    • docs/【后端架构】server-rs与SpacetimeDB数据契约-2026-05-15.md
    • docs/【后端架构】server-rs与SpacetimeDB数据契约-2026-05-15.md
    • docs/【后端架构】server-rs与SpacetimeDB数据契约-2026-05-15.md
    • docs/【后端架构】server-rs与SpacetimeDB数据契约-2026-05-15.md

3. 边界约束

  1. module-runtime 负责运行时状态真相与模块级 facade 编排,不把主状态继续留在旧式大 JSON repository 中。
  2. 兼容快照可以作为聚合产物保留,但不能再次成为唯一真相。
  3. 前端兼容接口由 apps/api-server 暴露,状态表与 view 最终由 apps/spacetime-module 聚合。