Files
Genarrative/server-rs
suzmii 172bc22404
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 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
fix(游戏共创): 合并后修正 game_distribution_game 列顺序(master 的 price_mud_points 回到第 26 位)
CI(Backend tests 与 Repository checks)在 `check:spacetime-schema` 红:
「SpacetimeDB 表 game_distribution_game 的第 26 个字段从 price_mud_points 变为 fork_authorization,疑似字段顺序被调整」。

根因:本次合并把两侧各自「在表尾追加」的列并成了「我们的列在 master 的列之前」——schema guard 对表的字段
相对顺序是按 index 逐位比对的(只允许在结构体末尾追加)。

- `game_distribution_game` 表:`price_mud_points`(master 先追加,第 26 位)回到原位,本分支的
  `fork_authorization` 追加在它**之后**(表尾);
- `GameDistributionGameSnapshot` 按同一纪律排(同一 game 行的 RPC 形状,避免表与快照两套顺序);
- 重新生成绑定:`module_bindings/game_distribution_game_type.rs`、`..._game_snapshot_type.rs`
  (列顺序属 wire format,客户端绑定必须与模块同步);
- 两处结构体注释写明该纪律(master 的列保持 index、我们的列追加在后),避免下一次合并再踩;
- 文档:`docs/project-memory/shared-memory/pitfalls.md` 增一条「合并 master 后 schema guard 的基线盲区」——
  本地守卫默认基线是 `git merge-base HEAD origin/master`,**merge 提交尚未建立时看不见**这类重排,
  因此合并后必须用 `SPACETIME_SCHEMA_BASE_REF=<PR base>` 复跑。

门禁:`SPACETIME_SCHEMA_BASE_REF=9f4c7d76 npm run check:spacetime-schema` 0(98 表);wasm build 0;
`cargo check --all-targets` 0;`cargo test -p module-game-distribution` 113 passed;`cargo test -p api-server
game_distribution` 101 passed;`cargo test -p module-runtime` 0;`cargo test -p spacetime-client` 43 passed;
`cargo test -p spacetime-module` 294 passed / 1 ignored;DTO parity 0(62 组 / 17 构建器 / 15 手拼类型);
`check:project-bundle-policy-parity` OK;`check:production-ops` OK;`check:doc-index` OK(261 份);`check:encoding`
0(5525 files);`cargo fmt --all --manifest-path server-rs/Cargo.toml -- --check` 0;`git diff --check` 0。
2026-10-06 16:47:38 +08:00
..
2026-07-17 16:56:46 +08:00
2026-07-17 16:56:46 +08:00

server-rs 工作区说明

更新时间:2026-05-15

server-rs/ 是当前唯一后端工作区,承载 Rust api-server、SpacetimeDB module、领域模块、平台副作用适配和共享契约。旧 server-node、Express、PostgreSQL、Go 服务端和 maincloud 口径均为历史残留,不再作为当前实现目标。

当前职责

  • crates/api-server:Axum HTTP / SSE / BFF 门面、鉴权、中间件、外部服务编排和 DTO 映射。
  • crates/spacetime-module:SpacetimeDB 表、reducer、procedure、事务 adapter、row mapper 和迁移。
  • crates/spacetime-client:后端访问 SpacetimeDB 的 typed facade。
  • crates/module-*:领域模型、命令、应用规则、领域事件和领域错误。
  • crates/platform-*:OSS、LLM、语音、认证等外部平台能力。
  • crates/shared-contracts:前后端共享 DTO 与公开契约。
  • crates/shared-kernel、crates/shared-logging、crates/tests-support:跨模块基础能力、日志和测试支撑。

开发规则

  1. server-rs/Cargo.toml 是 workspace 成员和依赖版本事实源;第三方依赖和 workspace 内 crate path 优先放在 [workspace.dependencies]。
  2. module-* 不直接依赖 Axum、SpacetimeDB table/reducer/procedure、reqwest、OSS、LLM、spacetime-client、tokio 或文件系统。
  3. api-server 不承接领域真相;发现领域规则时优先沉到对应 module-*。
  4. SpacetimeDB schema 变化必须同步 spacetime-module/src/migration.rs、生成绑定和当前后端架构文档的表目录。
  5. 人工命令、本地联调和文档示例不要使用 spacetime --root-dir。

常用命令

cargo check -p api-server --manifest-path server-rs/Cargo.toml
cargo test -p api-server --manifest-path server-rs/Cargo.toml
npm run check:server-rs-ddd
npm run check:spacetime-schema
npm run spacetime:generate
npm run dev:api-server

涉及 API smoke 时用 npm run dev:api-server 启动后端并检查 /healthz,不要使用旧 api-server:maincloud。

当前文档