Files
Genarrative/server-rs
suzmii 576c28354b
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
feat(游戏共创): 公开目录支持 forkable 过滤(只列支持共创的作品)
- `forkable=1/true`(大小写不敏感、先 trim)→ 只返回 `fork_authorization != forbidden` 的公开作品;
  省略 / 空 / `0` / `false` / 非法取值一律按「未过滤」(宽容降级 = 现状:公开只读列表里的可选展示过滤
  不该让整个游戏广场 400,降级只会少列不会多列)。
- 过滤落在**事务内、切页之前**(api-server 只解析参数、不对返回结果做过滤)⇒ forbidden 不占页位、
  翻页不重不漏、末页仍为 `null`;分页与游标语义、响应形状均不变(**无新字段**,`forkAuthorization` 本来就在
  公开投影里)。
- 判据只有一份实现:`ForkAuthorization::stored_allows_fork`(未知档位按「禁止」解释,与 `/fork-source`
  403 同源)。
- 测试 +9:module 6(含「9 条里夹 4 条 forbidden、页大小 2 → 3 页且游标序列 / 末页 None / forbidden 不占位」、
  真值集合精确、未知档位失败关闭、不可见行不被 resurrect、未设置时逐条相等)+ api-server 2 + 结构断言 1。
- 文档 §3.4 目录行补 `&forkable=`、语义与宽容降级理由(该文档改动已由 peer 提交进 `67f691784`)。

门禁:`cargo check --all-targets` 0;`cargo test -p module-game-distribution` **149 passed**;
`-p spacetime-module` **308 passed / 1 ignored**;`-p api-server game_distribution` **114 passed**;
DTO parity 66 组 / 19 构建器 / 15 手拼类型;`check:spacetime-schema` 0(98 表);`check:encoding` 0(5641 files);
`cargo fmt --all -- --check` 0;`git diff --check` 0。
2026-10-07 14:47:26 +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。

当前文档