6e5cf195f8
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
真实库实证:51 条 published 时**最老的 3 条**(含最关键的 A0/A1/A11 母版与主干)在公开目录里不可见
(AGC 共创页显示「已检查最新 48 个作品(1 页)」;数据本身没丢)。根因:handler 写死
`limit: MAX_LIST_LIMIT(48)`(并忽略客户端 `limit`),事务过滤排序后 `truncate(limit)`,**既无 has_more
也无游标**。
- **页大小**:默认 **48**(保持既有 AGC 共创页首屏语义——48 只该是默认值而非硬上限)、上限 **100**
(单响应体量);`0` 取默认、超界**截断**(不报错);api-server 与事务共用同一归一函数。
- **游标**:`"{created_at_micros}:{game_id}"`(复用仓库既有 `"{micros}:{id}"` 惯例,与主题列表同构);
排序键 `created_at` **倒序** + `game_id` **升序**兜底(与改前比较器逐字同序 ⇒ 首页顺序不变;全序 ⇒
翻页不重不漏);**先过滤再切页**;「多取一条」判 has_more;`nextCursor` 为真值、**末页为 `null`**。
- **非法游标**:模块产出 `CATALOG_INVALID_CURSOR: 目录游标格式无效` → api-server 新增 `CATALOG_` 前缀分支
(**排在 owner 不匹配 / 不存在 / 状态 等子串分支之前**)→ **400 + 稳定码 `CATALOG_INVALID_CURSOR`**,
并纳入「码由模块真实文案可达」的枚举测试(防上次那种不可达码);未登记的 `CATALOG_` 码兜底
`CATALOG_ERROR`(400)。
- **响应形状不变**:仍是 `{ games, nextCursor }`(`nextCursor` 从恒 `null` 变成真值);抽命名构建器
`public_games_payload` 并登记 parity(构建器 18→**19**,`mustEmit: ['games','nextCursor']`)。
- **生成绑定**:`game_distribution_public_game_list_input_type.rs`(+`cursor`)、
`game_distribution_game_list_procedure_result_type.rs`(+`next_cursor`);client facade 改返回
`(games, next_cursor)`,mapper 同步。
- **文档**(同批):主规范 HTTP 表 `GET /games` 行改为真游标分页;创作者主页工程设计两处「最多 48 / 不分页」
改写(并注明前端尚未消费游标);`docs/README.md` 索引行同步。
- **测试 +15**:纯函数 9(**51 条能翻到最老那条**、恰好整页不产生空游标、同 `created_at` 用 `game_id` 兜底、
**先过滤再切页**、游标指向页内最后一条、limit 0/超界、非法游标 7 种);事务结构断言 1;api-server 5
(形状、`limit` 默认与截断、非法游标 400 + 稳定码、码可达性枚举、**51 条走真实 handler 链路翻页且
未公开/已软删/无公开版本三种不可见行不出现**)。
门禁:wasm build 0;`cargo check --all-targets` 0;`cargo test -p module-game-distribution` **143 passed**;
`-p spacetime-module` **307 passed / 1 ignored**;`-p spacetime-client` 44 passed;`-p api-server game_distribution`
**112 passed**;DTO parity 0(66 组 / **19** 构建器 / 15 手拼类型);`check:spacetime-schema` 0(98 表);
`check:encoding` 0(5548 files);`cargo fmt --all --manifest-path server-rs/Cargo.toml -- --check` 0;
`git diff --check` 0。
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:跨模块基础能力、日志和测试支撑。
开发规则
server-rs/Cargo.toml是 workspace 成员和依赖版本事实源;第三方依赖和 workspace 内 crate path 优先放在[workspace.dependencies]。module-*不直接依赖 Axum、SpacetimeDB table/reducer/procedure、reqwest、OSS、LLM、spacetime-client、tokio或文件系统。api-server不承接领域真相;发现领域规则时优先沉到对应module-*。- SpacetimeDB schema 变化必须同步
spacetime-module/src/migration.rs、生成绑定和当前后端架构文档的表目录。 - 人工命令、本地联调和文档示例不要使用
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。
当前文档
- ../docs/【后端架构】server-rs与SpacetimeDB数据契约-2026-05-15.md:DDD 边界、API 分组、schema 变更规则和表目录。
- ../docs/【开发运维】本地开发验证与生产运维-2026-05-15.md:本地启动、检查、SpacetimeDB 操作和生产运维。