Files
Genarrative/server-rs/crates
suzmii ffd7510143
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(游戏共创): 公开投影新增 coCreationCount(公开可见的全部后代数)
会议口径:共创页卡片要突出「共创次数(= 该作品有多少个子项目/衍生作品)」。前端已按 `coCreationCount`
接字段(TS 侧先声明 ⇒ 上轮 **dto parity 变红**:`GameDistributionGame 多出未登记字段/变体:coCreationCount`),
本提交把服务端补齐并让 parity 回绿。

- **字段**:公开投影新增 `coCreationCount`(Rust `co_creation_count: u64`)= **该作品子树里「公开可见的全部后代」
  数,不含自己**;沿血缘边 BFS 整棵子树,只数「未软删除 + 已公开」的后代(与 `forkCount` 同一批规则
  `module_game_distribution::counts_as_public_derivative`,只是深度不同)。已删/未公开的后代不进任何一层计数;
  **中间作品不可见也不断链**(它可见的后代仍计入祖先);血缘环/自引用按 visited 去重,自己永不计数。
- **与 `forkCount` 并存、互不推导**:`forkCount` = **直接**子代(「被改编 N」),`coCreationCount` = **全部**后代
  (「共创 N」);同卡上前者 ≤ 后者。
- **发出范围**:公开投影**恒发**(公开目录、公开详情、我的收藏、主题成员 `roots` 都走同一个 `public_game_payload`);
  **无后代时发 `0` 而不是缺键**;作者侧同形响应不发(与 `currentVersion`/`ratingSummary` 同类)⇒ 前端读取建议
  `coCreationCount ?? forkCount`。
- **算法与成本**:在 spacetime **只读事务内现算** —— 先建一次 `PublicDerivativeIndex`(父→直接子代边 + 可见性集合),
  再对本页每行做一次 BFS 子树计数(visited 去重);目录/详情/收藏/主题各自事务内建一次。
  **不新增表/列/索引、不落物化计数,api-server 只发键不遍历**;边际成本 O(作品数)(当前 51)。
- **契约/门禁**:parity 的 `public_game_payload` 构建器 `mustEmit` 把 `coCreationCount` 与 `forkCount` 一起钉住
  ⇒ **parity 由红转绿(EXIT 0)**;TS 契约里两字段注释改为最终口径。
- **文档**:主规范公开投影一行写明两字段口径、BFS 算法与成本。
- **测试**:+4(根带 3 直接子代、其中一个再带 1 孙代 ⇒ **`forkCount == 3`、`coCreationCount == 4`**;无后代两键恒发且为 0;
  不可见后代不计且**中间不可见不断链**;环/自引用安全)→ `module-game-distribution` **153 passed**。

门禁:`cargo check --all-targets` 0;`cargo test -p module-game-distribution` **153 passed**;
`cargo test -p api-server game_distribution` 见下文;**`check-game-distribution-dto-parity` 0(66 组 / 19 构建器 /
15 手拼类型)**;`check:spacetime-schema` 0(98 表);`cargo fmt --all -- --check` 0;`git diff --check` 0。
2026-10-07 18:02:13 +08:00
..
2026-07-16 18:33:06 +08:00