Integrate unfinished server-rs refactor worklists

This commit is contained in:
2026-04-30 13:39:06 +08:00
parent 62934b0809
commit 7ab0933f6d
676 changed files with 24487 additions and 21531 deletions

View File

@@ -4,7 +4,30 @@
## 文档列表
- [SERVER_RS_DDD_WP_BF_RUNTIME_BACKEND_TRUTH_2026-04-29.md](./SERVER_RS_DDD_WP_BF_RUNTIME_BACKEND_TRUTH_2026-04-29.md):记录 `WP-BF Big Fish` 运行态从前端本地规则切到 Rust 领域真相源、SpacetimeDB run 表、API facade 和前端新接口接入的关闭口径。
- [SERVER_RS_DDD_WP_PF_PLATFORM_ERROR_CLASSIFICATION_2026-04-29.md](./SERVER_RS_DDD_WP_PF_PLATFORM_ERROR_CLASSIFICATION_2026-04-29.md):记录 `WP-PF platform side effects` 平台副作用收口,统一 LLM、OSS、SMS、微信平台错误分类与 API 映射,并将微信 OAuth provider 下沉到 `platform-auth`
- [SERVER_RS_DDD_WP_RT_ADAPTER_API_CLOSURE_2026-04-29.md](./SERVER_RS_DDD_WP_RT_ADAPTER_API_CLOSURE_2026-04-29.md):记录 `WP-RT Runtime/Profile/Save` Adapter/API 收口,将 checkpoint、profile/save archive meta、充值/邀请/兑换/钱包等剩余纯规则迁入 `module-runtime`,移除 `/api/runtime/profile/*` 旧兼容挂载并对齐前端 `/api/profile/*` 请求路径。
- [SERVER_RS_DDD_WP_SC_SPACETIME_CLIENT_REFACTOR_2026-04-29.md](./SERVER_RS_DDD_WP_SC_SPACETIME_CLIENT_REFACTOR_2026-04-29.md):冻结 `WP-SC Spacetime Client` 本次基础设施重构边界,明确只收口 `spacetime-client` 的 typed facade、错误映射和 row snapshot mapper不预判尚未由 `WP-ST` 稳定的表、reducer、procedure 或 row shape。
- [SERVER_RS_DDD_WP_RT_APPLICATION_RECORD_REFACTOR_2026-04-29.md](./SERVER_RS_DDD_WP_RT_APPLICATION_RECORD_REFACTOR_2026-04-29.md):记录 `WP-RT Runtime/Profile/Save` 的应用记录投影拆分切片,将 settings、browse history、profile/save 等 `build_runtime_*_record` 迁入 `module-runtime/src/application.rs`,不改回包字段语义。
- [SERVER_RS_DDD_WP_RT_COMMANDS_REFACTOR_2026-04-29.md](./SERVER_RS_DDD_WP_RT_COMMANDS_REFACTOR_2026-04-29.md):记录 `WP-RT Runtime/Profile/Save` 的命令构造拆分切片,将 settings、browse history、profile/save 等 `build_runtime_*_input` 和写入归一化函数迁入 `module-runtime/src/commands.rs`,不改校验语义。
- [SERVER_RS_DDD_WP_AI_INTERNAL_MODULE_SPLIT_2026-04-29.md](./SERVER_RS_DDD_WP_AI_INTERNAL_MODULE_SPLIT_2026-04-29.md):记录 `WP-AI AI Task``module-ai` 内部子模块拆分,将 domain、commands、application 与行为测试继续拆到职责更细的子文件,同时保持 `module_ai::*` 公开导出、SpacetimeDB schema、BFF route 和前端契约不变。
- [SERVER_RS_DDD_WP_AI_TASK_BFF_CLOSURE_2026-04-29.md](./SERVER_RS_DDD_WP_AI_TASK_BFF_CLOSURE_2026-04-29.md):记录 `WP-AI AI Task` BFF 收口与关闭口径,补齐 AI task mutation route 鉴权和 SpacetimeDB 未发布错误 envelope 的定向验证不改表结构、LLM provider、SSE 或前端消费。
- [SERVER_RS_DDD_WP_CW_DOMAIN_ENUM_REHOME_2026-04-29.md](./SERVER_RS_DDD_WP_CW_DOMAIN_ENUM_REHOME_2026-04-29.md):记录 `WP-CW Custom World` 基础领域枚举归位切片,将 Custom World / RPG Agent 基础枚举、进度常量和字符串口径迁入 `module-custom-world/src/domain.rs`,不改 SpacetimeDB、API 或前端行为。
- [SERVER_RS_DDD_WP_RPG_STORY_DOMAIN_SPLIT_2026-04-29.md](./SERVER_RS_DDD_WP_RPG_STORY_DOMAIN_SPLIT_2026-04-29.md):记录 `WP-RPG Gameplay 域``module-story` 领域拆分收口,将 story session 领域模型、命令、事件、应用映射和错误层从 `lib.rs` 拆入 DDD 骨架文件,并修正 README 不再指向旧 `/api/runtime/story/*` 兼容链路。
- [SERVER_RS_DDD_WP_PZ_DOMAIN_SPLIT_2026-04-29.md](./SERVER_RS_DDD_WP_PZ_DOMAIN_SPLIT_2026-04-29.md):记录 `WP-PZ Puzzle` 领域类型与规则拆分切片,将 Agent/作品/运行态领域类型、写入命令、应用规则、字段错误和最小领域事件归位到 `module-puzzle` 的 DDD 骨架文件,不改 SpacetimeDB、API 或前端行为。
- [SERVER_RS_DDD_WP_PZ_DOMAIN_ENUM_REHOME_2026-04-29.md](./SERVER_RS_DDD_WP_PZ_DOMAIN_ENUM_REHOME_2026-04-29.md):记录 `WP-PZ Puzzle` 基础领域常量与枚举归位切片,将 Puzzle Agent、发布状态、运行态状态、ID 前缀、标签数量和洗牌次数口径迁入 `module-puzzle/src/domain.rs`,不改 SpacetimeDB、API 或前端行为。
- [SERVER_RS_DDD_WP_RPG_COMBAT_DOMAIN_ENUM_REHOME_2026-04-29.md](./SERVER_RS_DDD_WP_RPG_COMBAT_DOMAIN_ENUM_REHOME_2026-04-29.md):记录 `WP-RPG Gameplay 域` 的 combat 基础领域常量与枚举归位切片,将战斗 ID 前缀、版本、伤害、切磋保底生命、旧攻击 function 列表和基础枚举迁入 `module-combat/src/domain.rs`,不改 SpacetimeDB、API 或前端行为。
- [SERVER_RS_DDD_WP_ST_AUTH_ADAPTER_SPLIT_2026-04-29.md](./SERVER_RS_DDD_WP_ST_AUTH_ADAPTER_SPLIT_2026-04-29.md):记录 `WP-ST` Auth SpacetimeDB adapter 目录化切片将认证表、procedure 和快照 JSON mapper 拆入 `auth/` 子模块,不改 schema、procedure 签名或绑定形状。
- [SERVER_RS_DDD_WP_RS_COMPAT_RESIDUE_AUDIT_2026-04-29.md](./SERVER_RS_DDD_WP_RS_COMPAT_RESIDUE_AUDIT_2026-04-29.md):记录 `WP-RS Runtime Story 去兼容层` 的 compat 残留审计切片,清理 `module-runtime-story` 运行代码注释口径,并冻结仍需等待新写接口的前端和 contract 残留。
- [SERVER_RS_DDD_WP_AS_ASSET_OBJECT_TYPE_REHOME_2026-04-29.md](./SERVER_RS_DDD_WP_AS_ASSET_OBJECT_TYPE_REHOME_2026-04-29.md):记录 `WP-AS Assets` 资产对象类型归位切片,将领域快照、命令 DTO、应用返回 DTO 和字段错误拆入 `module-assets` 的 DDD 骨架文件,不改 SpacetimeDB、API、OSS 或前端行为。
- [SERVER_RS_DDD_WP_RT_ERROR_LAYER_REFACTOR_2026-04-29.md](./SERVER_RS_DDD_WP_RT_ERROR_LAYER_REFACTOR_2026-04-29.md):记录 `WP-RT Runtime/Profile/Save` 的错误层拆分切片,将 settings、browse history、profile/save 三组字段错误和中文错误文案迁入 `module-runtime/src/errors.rs`,不改校验语义。
- [SERVER_RS_DDD_WP_RT_DOMAIN_SNAPSHOT_RECORD_REFACTOR_2026-04-29.md](./SERVER_RS_DDD_WP_RT_DOMAIN_SNAPSHOT_RECORD_REFACTOR_2026-04-29.md):记录 `WP-RT Runtime/Profile/Save` 的 snapshot、profile、wallet、played world 与 save archive 领域快照和记录类型拆分切片,只移动纯类型和枚举方法,不改 SpacetimeDB、API 或前端接线。
- [SERVER_RS_DDD_WP_RT_RUNTIME_SETTINGS_DOMAIN_REFACTOR_2026-04-29.md](./SERVER_RS_DDD_WP_RT_RUNTIME_SETTINGS_DOMAIN_REFACTOR_2026-04-29.md):记录 `WP-RT Runtime/Profile/Save` 的 runtime settings 领域值对象拆分切片,将默认设置、平台主题和值对象迁入 `module-runtime/src/domain.rs`,不改 SpacetimeDB、API 或前端接线。
- [SERVER_RS_DDD_WP_A_AUTH_DOMAIN_VALUE_OBJECT_REFACTOR_2026-04-29.md](./SERVER_RS_DDD_WP_A_AUTH_DOMAIN_VALUE_OBJECT_REFACTOR_2026-04-29.md):记录 `WP-A Auth` DDD 分层收口,将账号、会话、验证码、微信 state/绑定规则、命令输入、应用返回、领域错误和领域事件归位到 `module-auth` 骨架,并核查 API、platform 与 SpacetimeDB adapter 边界。
- [SERVER_RS_DDD_WP_ST_CUSTOM_WORLD_ROOT_SPLIT_2026-04-29.md](./SERVER_RS_DDD_WP_ST_CUSTOM_WORLD_ROOT_SPLIT_2026-04-29.md):记录 `WP-ST` Custom World SpacetimeDB adapter 从根入口迁入 `custom_world/mod.rs` 的边界、无 schema 变更口径和验收命令。
- [SERVER_RS_DDD_WP_FE_S_RPG_RUNTIME_STORY_CLIENT_MIGRATION_2026-04-29.md](./SERVER_RS_DDD_WP_FE_S_RPG_RUNTIME_STORY_CLIENT_MIGRATION_2026-04-29.md):记录 `WP-FE-S` RPG runtime story client 读取侧迁到 `storySessionId` scoped runtime projection并补齐 story session 新主链 `begin/continue/state/projection` API client 的边界、旧写接口暂留原因和后续依赖。
- [SERVER_RS_DDD_WP_FE_H_RPG_RUNTIME_STORY_HOOKS_PROJECTION_2026-04-29.md](./SERVER_RS_DDD_WP_FE_H_RPG_RUNTIME_STORY_HOOKS_PROJECTION_2026-04-29.md):记录 `WP-FE-H` RPG runtime story 读取侧 hooks 接线切片,将 option catalog 与继续游戏刷新显式接入 `getRpgStoryRuntimeProjection`,写接口和组件层仍等待后续收口。
- [SERVER_RS_DDD_WP_FE_C_RPG_RUNTIME_SHELL_TEST_FIXTURE_2026-04-29.md](./SERVER_RS_DDD_WP_FE_C_RPG_RUNTIME_SHELL_TEST_FIXTURE_2026-04-29.md):记录 `WP-FE-C` RPG runtime shell 组件测试夹具接线切片,将组件测试 mock 对齐当前 hooks 暴露的 UI 对象形状,不触碰未稳定写接口。
- [SERVER_RS_DDD_G1_CONTRACT_AND_ROUTE_MATRIX_PROGRESS_2026-04-29.md](./SERVER_RS_DDD_G1_CONTRACT_AND_ROUTE_MATRIX_PROGRESS_2026-04-29.md):记录 `G1 契约与路由矩阵` 已完成的本地进度、验证结果、单 owner 边界和下一批并行任务入口。
- [SERVER_RS_DDD_G1_CONTRACT_AND_ROUTE_MATRIX_2026-04-29.md](./SERVER_RS_DDD_G1_CONTRACT_AND_ROUTE_MATRIX_2026-04-29.md):冻结 `server-rs` DDD G1 契约与路由矩阵,明确新旧 HTTP 路由去留、DTO 删除/保留/重命名、页面到 query/result DTO 映射、breaking change、API 错误 envelope 和共享契约单 owner 边界。
- [SERVER_RS_DDD_WP_API_BFF_START_2026-04-29.md](./SERVER_RS_DDD_WP_API_BFF_START_2026-04-29.md):记录 `WP-API api-server BFF` 启动切片,先收口旧 runtime story 兼容路由挂载、错误 envelope 回归和后续依赖,不越过 `spacetime-client` 接线边界。

View File

@@ -43,13 +43,13 @@ G1 单 owner 文件范围:
| Runtime settings/save | `GET/PUT /api/runtime/settings``GET/PUT/DELETE /api/runtime/save/snapshot` | 保留 | `RuntimeSettingsResponse``PutRuntimeSettingsRequest``SavedGameSnapshotResponse``PutSavedGameSnapshotRequest` | WP-RT |
| RPG 作品库 | `GET /api/runtime/custom-world-library``GET/PUT/DELETE /api/runtime/custom-world-library/{profile_id}``POST /publish``POST /unpublish``GET /api/runtime/custom-world-gallery``GET /api/runtime/custom-world-gallery/{owner_user_id}/{profile_id}``GET /api/runtime/custom-world-gallery/by-code/{code}` | 收敛 | 命名后续改为 RPG creation/work route family删除 `custom-world` 旧泛名歧义 | WP-CW、WP-FE |
| RPG Agent | `POST /api/runtime/custom-world/agent/sessions``GET/DELETE /sessions/{session_id}``GET /result-view``GET /works``GET /cards/{card_id}``POST /messages``POST /messages/stream``POST /actions``GET /operations/{operation_id}` | 收敛 | DTO 重命名为 `RpgAgent*`Rust 当前 `CustomWorldAgent*` 后续物理重命名 | WP-CW、WP-FE、WP-DEL |
| Big Fish Agent/Works | `POST /api/runtime/big-fish/agent/sessions``GET /sessions/{session_id}``POST /messages``POST /messages/stream``POST /actions``GET /works``DELETE /works/{session_id}``GET /gallery``POST /sessions/{session_id}/play``POST /works/{session_id}/play` | 保留 | `BigFish*` DTO`sessions/{id}/play``works/{id}/play` 后续二选一保留 | WP-BF |
| Big Fish Agent/Works/Runtime | `POST /api/runtime/big-fish/agent/sessions``GET /sessions/{session_id}``POST /messages``POST /messages/stream``POST /actions``GET /works``DELETE /works/{session_id}``GET /gallery``POST /sessions/{session_id}/play``POST /works/{session_id}/play``POST /sessions/{session_id}/runs``GET /runs/{run_id}``POST /runs/{run_id}/input` | 保留 | `BigFish*` DTO运行态正式使用 `BigFishRunResponse``SubmitBigFishInputRequest``sessions/{id}/play``works/{id}/play` 后续二选一保留 | WP-BF |
| Puzzle Agent/Works/Runtime | `POST /api/runtime/puzzle/agent/sessions``GET /sessions/{session_id}``POST /messages``POST /messages/stream``POST /actions``GET /works``GET/PUT/DELETE /works/{profile_id}``GET /gallery``GET /gallery/{profile_id}``POST /runs``POST /runs/local-next-level``GET /runs/{run_id}``POST /runs/{run_id}/swap``POST /runs/{run_id}/drag``POST /runs/{run_id}/next-level``POST /runs/{run_id}/leaderboard` | 保留 | `PuzzleAgent*``PuzzleWork*``PuzzleRun*` DTO | WP-PZ |
| RPG profile/asset generation | `POST /api/runtime/custom-world/profile``POST /api/custom-world/entity``POST /api/runtime/custom-world/entity``POST /api/custom-world/scene-npc``POST /api/runtime/custom-world/scene-npc``POST /api/custom-world/scene-image``POST /api/custom-world/cover-image``POST /api/runtime/custom-world/cover-image``POST /api/custom-world/cover-upload``POST /api/runtime/custom-world/cover-upload` | 重命名 | 去掉非 runtime 前缀旧入口;统一到 RPG creation asset/profile route family | WP-CW、WP-AS、WP-DEL |
| Profile | `GET/POST/DELETE /api/runtime/profile/browse-history``GET/POST/DELETE /api/profile/browse-history``GET /dashboard``GET /wallet-ledger``GET /recharge-center``POST /recharge/orders``GET /referrals/invite-center``POST /referrals/redeem-code``POST /redeem-codes/redeem``GET /play-stats``GET /save-archives``POST /save-archives/{world_key}` | 重命名 | 保留 `/api/runtime/profile/*` 主链,删除 `/api/profile/*` 镜像入口 | WP-RT、WP-FE、WP-DEL |
| Profile | `GET/POST/DELETE /api/profile/browse-history``GET /api/profile/dashboard``GET /api/profile/wallet-ledger``GET /api/profile/recharge-center``POST /api/profile/recharge/orders``GET /api/profile/referrals/invite-center``POST /api/profile/referrals/redeem-code``POST /api/profile/redeem-codes/redeem``GET /api/profile/play-stats``GET /api/profile/save-archives``POST /api/profile/save-archives/{world_key}`;旧 `GET/POST/DELETE /api/runtime/profile/*` 已取消挂载 | 重命名 | 保留 `/api/profile/*` 主链,删除 `/api/runtime/profile/*` 旧兼容入口 | WP-RT、WP-FE、WP-DEL |
| Runtime inventory | `GET /api/runtime/sessions/{runtime_session_id}/inventory` | 保留 | `RuntimeInventoryStateResponse` | WP-RPG、WP-RT |
| Runtime story 旧层 | `POST /api/runtime/story/sessions``POST /api/runtime/story/state/resolve``GET /api/runtime/story/state/{session_id}``POST /api/runtime/story/actions/resolve``POST /api/runtime/story/initial``POST /api/runtime/story/continue` | 已删除 | 已从 `api-server` 取消挂载并删除 `api-server/src/runtime_story*` 兼容实现;后续前端迁移到 `GET/POST /api/story/*` 和 session scoped story/chat facade | WP-RS、WP-FE、WP-DEL |
| Story/Game facade | `POST /api/story/sessions``GET /api/story/sessions/{story_session_id}/state``POST /api/story/sessions/continue``POST /api/story/battles``GET /api/story/battles/{battle_state_id}``POST /api/story/npc/battle``POST /api/story/battles/resolve` | 保留 | `BeginStorySession*``ContinueStory*`battle/npc command/result DTO 后续补齐到 `shared-contracts` | WP-RPG、WP-RS |
| Story/Game facade | `POST /api/story/sessions``GET /api/story/sessions/{story_session_id}/state``GET /api/story/sessions/{story_session_id}/runtime-projection``POST /api/story/sessions/continue``POST /api/story/battles``GET /api/story/battles/{battle_state_id}``POST /api/story/npc/battle``POST /api/story/battles/resolve` | 保留 | `BeginStorySession*``ContinueStory*``StoryRuntimeProjection*``CreateStoryBattle*``StoryBattleState*``ResolveStoryBattle*` DTO 补齐到 `shared-contracts` | WP-RPG、WP-RS |
## 3. DTO 冻结清单
@@ -62,13 +62,15 @@ G1 单 owner 文件范围:
| `shared-contracts/src/auth.rs` | `AuthLoginOptionsResponse``AuthUserPayload``PublicUserSummaryPayload``PublicUserSearchResponse``PasswordEntry*``PasswordChange*``PasswordReset*``AuthMeResponse``AuthSessionsResponse``RefreshSessionResponse``Logout*``Phone*``Wechat*` |
| `shared-contracts/src/ai.rs` | `CreateAiTaskRequest``AppendAiTextChunkRequest``CompleteAiStageRequest``AttachAiResultReferenceRequest``FailAiTaskRequest``AiTask*Payload``AiTaskMutationResponse``AiTaskAcceptedResponse` |
| `shared-contracts/src/assets.rs` | Direct upload、read url、asset object、asset binding、asset history、character visual/animation、workflow cache、role asset workflow 相关 DTO |
| `shared-contracts/src/big_fish*.rs` | `CreateBigFishSessionRequest``SendBigFishMessageRequest``ExecuteBigFishActionRequest``RecordBigFishPlayRequest``BigFish*Response``BigFishWorksResponse` |
| `shared-contracts/src/creation_agent_document_input.rs` | `ParseCreationAgentDocumentInputRequest/Response``CreationAgentDocumentInputPayload` |
| `shared-contracts/src/big_fish*.rs` | `CreateBigFishSessionRequest``SendBigFishMessageRequest``ExecuteBigFishActionRequest``RecordBigFishPlayRequest``SubmitBigFishInputRequest``BigFish*Response``BigFishRunResponse``BigFishWorksResponse` |
| `shared-contracts/src/puzzle_*.rs` | `CreatePuzzleAgentSessionRequest``SendPuzzleAgentMessageRequest``ExecutePuzzleAgentActionRequest``PuzzleAgent*Response``PuzzleWork*``PuzzleRun*``PuzzleGallery*` |
| `shared-contracts/src/runtime.rs` | runtime settings/save/profile/browse history/custom world library/agent/result view/inventory 现有 DTO 在迁移窗口保留 |
| `shared-contracts/src/story.rs` | `BeginStorySessionRequest``ContinueStoryRequest``StorySessionPayload``StoryEventPayload``StorySessionMutationResponse``StorySessionStateResponse` |
| `shared-contracts/src/story.rs` | `BeginStorySessionRequest``ContinueStoryRequest``StorySessionPayload``StoryEventPayload``StorySessionMutationResponse``StorySessionStateResponse``StoryRuntimeProjectionRequest/Response``CreateStoryBattleRequest``CreateStoryNpcBattleRequest``StoryBattleStateResponse``ResolveStoryBattleRequest/Response` |
| `packages/shared/src/contracts/runtime.ts` | `RuntimeSettings``SavedGameSnapshot*`、profile、browse history、library/gallery DTO迁移窗口继续作为前端消费主入口 |
| `packages/shared/src/contracts/creationAgentDocumentInput.ts` | `ParseCreationAgentDocumentInputRequest/Response``CreationAgentDocumentInputPayload` |
| `packages/shared/src/contracts/rpgAgent*.ts` | RPG Agent、draft、anchors、result view、work summary DTO |
| `packages/shared/src/contracts/bigFish*.ts` | Big Fish Agent、runtime、本地作品列表 DTO |
| `packages/shared/src/contracts/bigFish*.ts` | Big Fish Agent、backend runtime run/input、本地作品列表 DTO |
| `packages/shared/src/contracts/puzzle*.ts` | Puzzle Agent、work、gallery、runtime DTO |
### 3.2 重命名
@@ -80,7 +82,7 @@ G1 单 owner 文件范围:
| Rust `GenerateCustomWorldProfile*` | `GenerateRpgCreationProfile*` | 去掉泛化 custom world 命名,明确 RPG 创作 profile。 |
| TS `AuthEntry*` | `PasswordEntry*` 或统一后端 `AuthPasswordEntry*` | 需要在 WP-A 中二选一收口,避免 entry 与 phone/wechat 登录语义混杂。 |
| `RuntimeStory*` view model | `RpgRuntimeStory*` 或拆到 `Story*``Battle*``Inventory*` | 旧聚合大 DTO 后续拆分为 story session、battle、inventory、npc interaction 投影。 |
| Profile 镜像 DTO | `RuntimeProfile*` | `/api/profile/*` 镜像删除,契约命名跟随 `/api/runtime/profile/*`。 |
| Profile 旧兼容入口 DTO | `RuntimeProfile*` | `/api/runtime/profile/*` 旧兼容入口已删除,契约命名可继续保留 RuntimeProfile 领域语义HTTP 主链固定为 `/api/profile/*`。 |
### 3.3 删除
@@ -93,7 +95,7 @@ G1 单 owner 文件范围:
| Rust/TS `RuntimeStoryActionRequest/Response` 旧总入口形态 | `POST /api/runtime/story/actions/resolve` 删除后 | story/battle/npc/inventory 分命令 result DTO |
| TS `StoryRequestPayload``PlainTextPromptRequest``PlainTextResponse` | runtime chat 不再由前端传 prompt 后 | 后端 session scoped chat/story command |
| TS `CreateCustomWorldSessionRequest``AnswerCustomWorldSessionQuestionRequest``CustomWorldSessionRecord` 等旧问答生成 DTO | 确认无前端运行引用后 | RPG Agent session DTO |
| `/api/profile/*` 镜像 DTO 别名 | 前端全量迁到 `/api/runtime/profile/*` 后 | Runtime profile DTO |
| `/api/runtime/profile/*` 旧兼容 DTO 别名 | 前端全量迁到 `/api/profile/*` 后 | Runtime profile DTO |
## 4. 页面/功能到 query/result DTO 映射
@@ -111,23 +113,23 @@ G1 单 owner 文件范围:
| RPG Agent 工作区 | route param `session_id` / `operation_id` | `CreateCustomWorldAgentSessionRequest``SendCustomWorldAgentMessageRequest``ExecuteCustomWorldAgentActionRequest` | `CustomWorldAgentSessionResponse``CustomWorldAgentOperationResponse``CustomWorldCreationResultViewResponse`,后续重命名 `RpgAgent*` |
| RPG 结果页 | route param `session_id` | section patch/action request | `CustomWorldCreationResultViewResponse``CustomWorldAgentCardDetailResponse` |
| RPG 资产工坊 | route param `character_id``GetReadUrlQuery` | `CharacterVisualGenerateRequest``CharacterAnimationGenerateRequest``CharacterWorkflowCacheSaveRequest``CharacterRoleAssetWorkflowResolveRequest` | `CharacterVisualGenerateResponse``CharacterAnimationGenerateResponse``CharacterWorkflowCacheGetResponse``CharacterRoleAssetWorkflowResponse` |
| Big Fish Agent | route param `session_id` | `CreateBigFishSessionRequest``SendBigFishMessageRequest``ExecuteBigFishActionRequest` | `BigFishSessionResponse``BigFishActionResponse` |
| Big Fish Agent/Runtime | route param `session_id` / `run_id` | `CreateBigFishSessionRequest``SendBigFishMessageRequest``ExecuteBigFishActionRequest``SubmitBigFishInputRequest` | `BigFishSessionResponse``BigFishActionResponse``BigFishRunResponse` |
| Big Fish 广场/作品 | bearer token 或公开 gallery query | `RecordBigFishPlayRequest` | `BigFishWorksResponse``BigFishGalleryResponse``BigFishSessionResponse` |
| Puzzle Agent | route param `session_id` | `CreatePuzzleAgentSessionRequest``SendPuzzleAgentMessageRequest``ExecutePuzzleAgentActionRequest` | `PuzzleAgentSessionResponse``PuzzleAgentActionResponse` |
| Puzzle 作品/广场 | route param `profile_id` | `PutPuzzleWorkRequest` | `PuzzleWorksResponse``PuzzleWorkDetailResponse``PuzzleGalleryResponse``PuzzleGalleryDetailResponse` |
| Puzzle 运行态 | route param `run_id` | `StartPuzzleRunRequest``AdvanceLocalPuzzleNextLevelRequest``SwapPuzzlePiecesRequest``DragPuzzlePieceRequest``SubmitPuzzleLeaderboardRequest` | `PuzzleRunResponse` |
| Runtime 设置与存档 | bearer token | `PutRuntimeSettingsRequest``PutSavedGameSnapshotRequest``PutRuntimeSaveCheckpointRequest` | `RuntimeSettingsResponse``SavedGameSnapshotResponse``BasicOkResponse` |
| 个人中心 | bearer token | `CreateProfileRechargeOrderRequest``RedeemProfileReferralInviteCodeRequest``RedeemProfileRewardCodeRequest``PlatformBrowseHistoryUpsertRequest` | `ProfileDashboardSummaryResponse``ProfileWalletLedgerResponse``ProfileRechargeCenterResponse``ProfileReferralInviteCenterResponse``ProfilePlayStatsResponse``ProfileSaveArchiveListResponse``PlatformBrowseHistoryResponse` |
| RPG Story 运行态 | route param `story_session_id``battle_state_id` | `BeginStorySessionRequest``ContinueStoryRequest`battle/npc 命令 DTO 后续补齐 | `StorySessionMutationResponse``StorySessionStateResponse``RuntimeInventoryStateResponse` |
| RPG Story 运行态 | route param `story_session_id``battle_state_id` | `BeginStorySessionRequest``ContinueStoryRequest``CreateStoryBattleRequest``CreateStoryNpcBattleRequest``ResolveStoryBattleRequest` | `StorySessionMutationResponse``StorySessionStateResponse``StoryRuntimeProjectionResponse``StoryBattleStateResponse``ResolveStoryBattleResponse``RuntimeInventoryStateResponse` |
| Runtime chat/NPC 私聊 | route param `runtime_session_id``story_session_id` | 后续新增 session scoped chat command | 后续新增 chat turn result`rpgRuntimeChat.ts` DTO 只作为迁移参考 |
## 5. Breaking change 清单
1. 删除兼容层是本轮默认策略。旧 `/api/runtime/story/*``/_internal/auth/*``/generated-*``/api/profile/*` 镜像入口在对应前端迁移完成后物理删除。
1. 删除兼容层是本轮默认策略。旧 `/api/runtime/story/*``/_internal/auth/*``/generated-*``/api/runtime/profile/*` 兼容入口在对应前端迁移完成后物理删除。
2. Runtime story/chat 不再接受前端拼装的 `worldType``character``monsters``history``context`、prompt 文本作为正式真相。正式命令必须以 `runtimeSessionId``storySessionId``battleStateId` 等后端 session id 为索引。
3. `CustomWorld*` 作为 RPG 主链命名将被重命名为 `RpgCreation*``RpgAgent*`。前端可同步修改,不保留旧命名适配层。
4. `/api/custom-world/*` 非 runtime 前缀旧入口删除,统一进入 RPG creation route family 或 asset route family。
5. `/api/profile/*` 镜像入口删除,统一使用 `/api/runtime/profile/*`
5. `/api/runtime/profile/*` 兼容入口删除,统一使用 `/api/profile/*`
6. 资产读取不再依赖 `/generated-*` 静态代理作为正式 contract统一走 asset object、read url 或后端投影里的正式 URL 字段。
7. LLM 代理不得作为玩法 prompt 透传入口。玩法 prompt 由 `api-server`/`platform-llm` 内部编排,前端只提交用户动作和展示态输入。
8. API 错误体统一为 `ApiErrorEnvelope`。旧 `{ error, meta }` 只允许在已列入删除计划的旧接口中短期存在。

View File

@@ -40,6 +40,16 @@ npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_G1_CONTRACT_AND_ROUTE
结果通过4 个文档文件 UTF-8 编码检查正常。
## 4.1 持续巡检记录
2026-04-29 本轮持续巡检已补齐迁移后漂移:
1. `Profile` 路由矩阵从旧 `/api/runtime/profile/*` 主链修正为当前 `/api/profile/*` 主链,并明确 `/api/runtime/profile/*` 已作为旧兼容入口取消挂载。
2. `Big Fish Agent/Works` 路由矩阵补齐后端真相源运行态接口:`POST /api/runtime/big-fish/sessions/{session_id}/runs``GET /api/runtime/big-fish/runs/{run_id}``POST /api/runtime/big-fish/runs/{run_id}/input`
3. `Story/Game facade` 补齐 `GET /api/story/sessions/{story_session_id}/runtime-projection`,并将 story runtime projection、story battle command/result DTO 标记为已进入 `shared-contracts/src/story.rs`
4. DTO 保留清单补齐 `shared-contracts/src/creation_agent_document_input.rs``packages/shared/src/contracts/creationAgentDocumentInput.ts`
5. `packages/shared/src/index.ts` 已导出 `creationAgentDocumentInput` 类型,避免前端继续绕过共享契约包入口深路径引用。
## 5. 后续入口
下一步可以按全局清单进入第 1 批领域规则并行任务:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,94 @@
# server-rs DDD WP-AI 内部子模块拆分记录2026-04-29
## 1. 背景
`WP-AI AI Task` 已完成领域层、SpacetimeDB adapter、spacetime-client facade 与 BFF route 闭环。当前继续推进 DDD 收口时,`module-ai` 虽然已经从首轮 `lib.rs` 大文件拆成 `domain / commands / application / events / errors`,但 `domain.rs``commands.rs``application.rs` 仍承载多类职责,后续继续演进阶段规则、任务结果聚合或 store 实现时容易重新堆成大文件。
本次只做 `module-ai` crate 内部子模块拆分,保持 `module_ai::*` 对外公开导出不变,不改变 SpacetimeDB table / reducer / procedure / event table不改变 HTTP DTO、route 或前端调用。
## 2. 本次拆分范围
允许修改:
1. `server-rs/crates/module-ai/src/domain.rs`
2. `server-rs/crates/module-ai/src/domain/*`
3. `server-rs/crates/module-ai/src/commands.rs`
4. `server-rs/crates/module-ai/src/commands/*`
5. `server-rs/crates/module-ai/src/application.rs`
6. `server-rs/crates/module-ai/src/application/*`
7. `server-rs/crates/module-ai/src/lib.rs`
8. `server-rs/crates/module-ai/src/tests.rs`
9. `server-rs/crates/module-ai/README.md`
10. 本文档、`docs/technical/README.md` 与全局任务清单进度记录
禁止修改:
1. `server-rs/crates/spacetime-module/src/**`
2. `server-rs/crates/spacetime-client/src/**`
3. `server-rs/crates/api-server/src/**`
4. `server-rs/crates/shared-contracts/src/**`
5. `packages/shared/src/contracts/**`
6. `server-rs/crates/spacetime-module/src/migration.rs`
## 3. 拆分落点
```text
server-rs/crates/module-ai/src/
├─ application.rs
├─ application/
│ ├─ result.rs
│ ├─ service.rs
│ └─ store.rs
├─ commands.rs
├─ commands/
│ ├─ inputs.rs
│ └─ validation.rs
├─ domain.rs
├─ domain/
│ ├─ ids.rs
│ ├─ stages.rs
│ └─ types.rs
├─ errors.rs
├─ events.rs
├─ lib.rs
└─ tests.rs
```
职责说明:
1. `domain/types.rs` 只放 AI task、stage、chunk、result reference 的领域类型与快照。
2. `domain/stages.rs` 只放默认阶段蓝图、阶段 slug、阶段中文标签与终态判断。
3. `domain/ids.rs` 只放 ID 前缀、ID helper 和共享字符串归一 helper re-export。
4. `commands/inputs.rs` 只放写入输入结构。
5. `commands/validation.rs` 只放创建任务输入校验。
6. `application/result.rs` 只放面向 SpacetimeDB procedure 的轻量结果结构。
7. `application/service.rs` 只放 AI task 状态机应用服务。
8. `application/store.rs` 只放当前内存 store 与流式文本片段聚合。
9. `tests.rs` 承接原 `lib.rs` 行为测试,`lib.rs` 只保留模块声明与公开导出。
## 4. 行为不变口径
本次必须保持:
1. `module_ai::*` 公开导出兼容。
2. 默认阶段蓝图顺序不变。
3. 任务状态迁移不变。
4. 终态任务不允许继续写入阶段、文本片段、结果引用或完成状态。
5. 流式文本片段继续按 `sequence` 聚合到阶段输出和 `latest_text_output`
6. 中文错误文案不改写为英文。
7. 不新增真实 LLM provider、prompt 组装、SSE 协议或前端消费逻辑。
## 5. 验收
必须执行:
```powershell
cargo fmt -p module-ai --manifest-path server-rs/Cargo.toml --check
cargo test -p module-ai --manifest-path server-rs/Cargo.toml
cargo check -p spacetime-module --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_AI_INTERNAL_MODULE_SPLIT_2026-04-29.md docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md server-rs/crates/module-ai/README.md server-rs/crates/module-ai/src/lib.rs server-rs/crates/module-ai/src/domain.rs server-rs/crates/module-ai/src/domain/ids.rs server-rs/crates/module-ai/src/domain/stages.rs server-rs/crates/module-ai/src/domain/types.rs server-rs/crates/module-ai/src/commands.rs server-rs/crates/module-ai/src/commands/inputs.rs server-rs/crates/module-ai/src/commands/validation.rs server-rs/crates/module-ai/src/application.rs server-rs/crates/module-ai/src/application/result.rs server-rs/crates/module-ai/src/application/service.rs server-rs/crates/module-ai/src/application/store.rs server-rs/crates/module-ai/src/tests.rs
npm.cmd run api-server:maincloud
```
`api-server:maincloud` 是常驻后端启动命令,验收时以命令启动和 `GET http://127.0.0.1:3100/healthz` 探测结果记录为准。

View File

@@ -0,0 +1,73 @@
# server-rs DDD WP-AI AI Task BFF 收口记录2026-04-29
## 1. 背景
`WP-AI AI Task` 的领域层已完成 DDD 拆分,`spacetime-module/src/ai/*` 已具备 AI task 真相表、阶段表、文本片段、结果引用、事件表和最小 reducer / procedure`spacetime-client` 已提供 typed facade`api-server` 已挂载 AI task mutation route。
本次认领的目标不是新增模型供应商能力,也不是改表,而是把现有 AI task BFF 链路做闭环验证,确认前端或后续业务模块调用 AI task 写接口时不会绕过鉴权、不会在 SpacetimeDB 未发布时返回错误形态不一致的响应。
## 2. 本次完成范围
1. 补齐 `api-server/src/ai_tasks.rs` 的 AI task mutation route 定向测试。
2. 覆盖以下写接口的未登录拦截:
- `POST /api/ai/tasks/{task_id}/stages/{stage_kind}/start`
- `POST /api/ai/tasks/{task_id}/chunks`
- `POST /api/ai/tasks/{task_id}/stages/{stage_kind}/complete`
- `POST /api/ai/tasks/{task_id}/references`
- `POST /api/ai/tasks/{task_id}/complete`
- `POST /api/ai/tasks/{task_id}/fail`
- `POST /api/ai/tasks/{task_id}/cancel`
3. 覆盖上述写接口在 token 有效但 SpacetimeDB 未发布时统一返回 `502 BAD_GATEWAY`,并保持错误详情 `provider = spacetimedb`
4. 复核 `module-ai``spacetime-client``spacetime-module` 与 BFF 定向测试,确认本次不需要修改 `migration.rs`
## 3. 边界
本次未进入:
1. 真实 LLM provider 调用、prompt 组装和供应商降级策略。
2. SSE 流式输出协议。
3. AI task 订阅 projection、清理调度或前端消费 UI。
4. SpacetimeDB table、reducer、procedure、event table 的结构变更。
5. 共享契约字段调整或前端 API client 改造。
这些能力继续归入 `WP-PF platform side effects``WP-API api-server BFF``WP-FE` 和后续对应业务域工作包,不在 `module-ai` 领域核心中混入。
## 4. 验收
已执行:
```powershell
cargo fmt -p api-server --manifest-path server-rs\Cargo.toml --check
cargo test -p api-server ai_task --manifest-path server-rs\Cargo.toml
cargo test -p module-ai --manifest-path server-rs\Cargo.toml
cargo check -p spacetime-client --manifest-path server-rs\Cargo.toml
cargo check -p spacetime-module --manifest-path server-rs\Cargo.toml
cargo check -p api-server --manifest-path server-rs\Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md docs/technical/SERVER_RS_DDD_WP_AI_TASK_BFF_CLOSURE_2026-04-29.md docs/technical/README.md server-rs/crates/api-server/src/ai_tasks.rs server-rs/crates/api-server/src/wechat_auth.rs
npm.cmd run api-server:maincloud
```
结果:
1. `api-server ai_task` 定向测试通过7 个测试全部通过。
2. `module-ai` 测试通过9 个测试全部通过。
3. `spacetime-client` 编译通过。
4. `spacetime-module` 编译通过。
5. `api-server` 编译通过,仅保留既有未使用代码 warning。
6. `npm.cmd run check:server-rs-ddd` 通过。
7. 编码检查通过5 个文件均为 UTF-8。
8. `npm.cmd run api-server:maincloud` 已启动本仓库 `server-rs/target/debug/api-server.exe``GET http://127.0.0.1:3100/healthz` 返回 `200`
9. 未执行 SpacetimeDB 发布、绑定生成或 migration 更新,原因是本次未改变 SpacetimeDB schema、reducer/procedure 签名或绑定形状。
## 5. 关闭口径
`WP-AI AI Task` 当前已完成:
1. 领域层 DDD 拆分。
2. SpacetimeDB AI task 真相表、阶段表、文本片段、结果引用和事件表 adapter。
3. `spacetime-client` typed facade。
4. `api-server` AI task mutation route 与错误 envelope。
5. BFF 鉴权和 SpacetimeDB 未发布错误形态的定向回归测试。
因此本次将工作包认领状态从 `已认领` 更新为 `已关闭`。后续真实模型调用、SSE 和前端消费不再阻塞 `WP-AI` 关闭分别由平台副作用、API 编排和前端迁移工作包继续承接。

View File

@@ -0,0 +1,58 @@
# WP-AS Assets 资产对象类型归位落地说明
## 背景
`module-assets` 已具备 `domain / commands / application / errors / events` DDD 骨架,但 `asset_object_core.rs` 仍同时承载领域模型、命令 DTO、应用返回 DTO、字段错误和纯构建函数。继续推进资产对象、实体绑定、OSS adapter 与 SpacetimeDB row mapper 时,容易把纯领域事实和外层编排混在同一个文件里。
本次作为 `WP-AS Assets` 的小切片,只在 `module-assets` crate 内做类型归位,不改变现有公开 API、SpacetimeDB 表结构、reducer/procedure、OSS 行为、api-server 路由或前端行为。
## 本次范围
允许修改:
1. `server-rs/crates/module-assets/src/domain.rs`
2. `server-rs/crates/module-assets/src/commands.rs`
3. `server-rs/crates/module-assets/src/application.rs`
4. `server-rs/crates/module-assets/src/errors.rs`
5. `server-rs/crates/module-assets/src/asset_object_core.rs`
6. `server-rs/crates/module-assets/src/lib.rs`
7. `server-rs/crates/module-assets/README.md`
8. 本文档与全局 DDD 任务清单
禁止修改:
1. `server-rs/crates/spacetime-module/src/**`
2. `server-rs/crates/spacetime-client/src/**`
3. `server-rs/crates/api-server/src/**`
4. `server-rs/crates/platform-oss/src/**`
5. 前端 services/hooks/components
## 设计
本次按 DDD 骨架进行类型归位:
1. `domain.rs` 承接资产对象、资产历史、实体绑定的纯快照、记录、访问策略、ID 前缀和版本常量。
2. `commands.rs` 承接确认资产对象、资产历史查询、对象 upsert、实体绑定等输入 DTO。
3. `application.rs` 承接 procedure result 和确认资产对象结果等应用返回 DTO。
4. `errors.rs` 承接 `AssetObjectFieldError` 及其中文错误文案。
5. `asset_object_core.rs` 保留字段校验、输入构建、记录构建、ID 生成和可复用归一化函数。
`lib.rs` 继续按原名称导出,避免影响 `spacetime-module``api-server` 或既有测试。
## 边界说明
1. 本次不移动 `AssetObjectService`,因为它仍依赖 `platform-oss` 的对象探测和进程内仓储。
2. 本次不新增资产任务、manifest 或专业资产表。
3. 本次不修改 `migration.rs`,因为没有表结构变更。
4. 本次不改变 `bucket + object_key` 双列真相字段。
## 验收
```powershell
cargo fmt -p module-assets --manifest-path server-rs/Cargo.toml --check
cargo test -p module-assets --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_AS_ASSET_OBJECT_TYPE_REHOME_2026-04-29.md server-rs/crates/module-assets/src/domain.rs server-rs/crates/module-assets/src/commands.rs server-rs/crates/module-assets/src/application.rs server-rs/crates/module-assets/src/errors.rs server-rs/crates/module-assets/src/asset_object_core.rs server-rs/crates/module-assets/src/lib.rs server-rs/crates/module-assets/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md docs/technical/README.md
```
后端启动按项目约束执行 `npm.cmd run api-server:maincloud`,若命令以前台服务常驻,则以 `/healthz` 结果记录。

View File

@@ -0,0 +1,121 @@
# WP-A Auth DDD 分层收口说明
## 背景
`module-auth` 当前已经具备 `domain / commands / application / events / errors` 文件骨架,但真实认证类型、服务、内存仓、文件持久化、短信 provider、密码哈希和微信状态逻辑仍主要集中在 `src/lib.rs`。这会让后续继续迁移 Auth 领域规则时难以区分纯领域模型和外层 adapter 能力。
本次从原先的领域值对象启动切片继续推进到 `WP-A Auth` 收口:把认证上下文的纯领域事实、命令输入、应用返回、领域错误和领域事件落回 DDD 骨架文件,同时核查 `api-server / platform-auth / spacetime-module` 的职责边界。
## 本次范围
允许修改:
1. `server-rs/crates/module-auth/src/domain.rs`
2. `server-rs/crates/module-auth/src/commands.rs`
3. `server-rs/crates/module-auth/src/application.rs`
4. `server-rs/crates/module-auth/src/events.rs`
5. `server-rs/crates/module-auth/src/errors.rs`
6. `server-rs/crates/module-auth/src/lib.rs`
7. `server-rs/crates/spacetime-module/src/auth.rs`
8. `server-rs/crates/module-auth/README.md`
9. 本文档
10. 全局 DDD 任务清单进度记录
本次只核查但不改动:
1. `server-rs/crates/api-server/src/auth*.rs`
2. `server-rs/crates/api-server/src/password_entry.rs`
3. `server-rs/crates/api-server/src/phone_auth.rs`
4. `server-rs/crates/api-server/src/refresh_session.rs`
5. `server-rs/crates/api-server/src/wechat_auth.rs`
6. `server-rs/crates/platform-auth/src/**`
禁止修改:
1. 其他玩法域。
2. 前端 services / hooks / components。
3. `server-node` 或旧 PostgreSQL 实现。
4. SpacetimeDB 表结构、reducer/procedure 签名和 `migration.rs`
## 设计
本次将以下纯领域事实和规则落入 `domain.rs`
1. `AuthLoginMethod`
2. `AuthBindingStatus`
3. `AuthUser`
4. `PhoneNumberSnapshot`
5. `PhoneAuthScene`
6. `WechatIdentityProfile`
7. `WechatAuthScene`
8. `WechatAuthStateRecord`
9. `RefreshSessionClientInfo`
10. `RefreshSessionRecord`
11. `AuthStoreSnapshotRecord`
12. 密码长度、短信验证码长度、验证码 TTL、冷却、失败次数等领域常量。
13. 手机号规范化、手机号脱敏、公开叙世号规范化、验证码 key 构造等纯函数。
本次将以下写入输入落入 `commands.rs`
1. `PasswordEntryInput`
2. `ChangePasswordInput`
3. `ResetPasswordInput`
4. `SendPhoneCodeInput`
5. `PhoneLoginInput`
6. `ResolveWechatLoginInput`
7. `CreateWechatAuthStateInput`
8. `BindWechatPhoneInput`
9. `CreateRefreshSessionInput`
10. `RotateRefreshSessionInput`
11. `LogoutCurrentSessionInput`
12. `LogoutAllSessionsInput`
13. `AuthStoreSnapshotUpsertInput`
本次将以下应用返回落入 `application.rs`
1. 登录、换密、重置密码、验证码发送、手机号登录、微信登录、微信绑定、会话签发/轮换/查询/登出等 result。
2. `AuthStoreSnapshotProcedureResult`
本次将以下错误落入 `errors.rs`
1. `PasswordEntryError`
2. `PhoneAuthError`
3. `WechatAuthError`
4. `RefreshSessionError`
5. `LogoutError`
6. 错误展示文案和模块内错误映射辅助函数。
本次将领域事件落入 `events.rs`
1. `UserCreated`
2. `RefreshSessionIssued`
3. `RefreshSessionRevoked`
4. `PhoneVerified`
5. `WechatIdentityBound`
`lib.rs` 保留当前服务、进程内仓储和文件持久化实现,但不再继续拥有上述命令、结果、错误、事件和领域值对象定义;公开 API 继续通过 `pub use application::* / commands::* / domain::* / errors::* / events::*` 导出,避免影响现有 BFF 调用。
## 边界说明
1. `module-auth` 承接账号、refresh session、短信验证码状态、微信 state 和微信绑定规则,不依赖 Axum、SpacetimeDB table API、HTTP status、真实短信 SDK、微信 HTTP 或 JWT/cookie 细节。
2. `platform-auth` 继续承接短信 provider、微信 OAuth provider、密码哈希、refresh token、JWT 和 cookie 等平台副作用。
3. `api-server` 只做请求解析、鉴权、DTO 映射、session cookie/JWT 编排和平台/领域服务装配;本次核查未发现 Auth route 需要复制领域状态机。
4. `spacetime-module/src/auth.rs` 当前仍是认证快照与正式表之间的 SpacetimeDB adapter不调用短信、微信、JWT、HTTP 或文件系统;本次只修正历史乱码中文注释和错误文案,不改变表结构或 procedure 签名。
5. `InMemoryAuthStore` 和文件持久化仍保留在 `lib.rs`,作为当前 Auth 运行支撑;总纲中“仓储剥离到 adapter 或测试支撑”的更彻底物理拆分可作为后续非 WP-A 阻塞项继续推进,但本次 WP-A 已完成 DDD 骨架归位和边界核查。
## 验收
```powershell
cargo fmt -p module-auth --manifest-path server-rs/Cargo.toml --check
cargo test -p module-auth --manifest-path server-rs/Cargo.toml
cargo check -p module-auth --manifest-path server-rs/Cargo.toml --all-features
cargo check -p spacetime-module --manifest-path server-rs/Cargo.toml
cargo test -p api-server auth --manifest-path server-rs/Cargo.toml
cargo test -p api-server wechat --manifest-path server-rs/Cargo.toml
cargo check -p api-server --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_A_AUTH_DOMAIN_VALUE_OBJECT_REFACTOR_2026-04-29.md server-rs/crates/module-auth/src/domain.rs server-rs/crates/module-auth/src/commands.rs server-rs/crates/module-auth/src/application.rs server-rs/crates/module-auth/src/errors.rs server-rs/crates/module-auth/src/events.rs server-rs/crates/module-auth/src/lib.rs server-rs/crates/module-auth/README.md server-rs/crates/spacetime-module/src/auth.rs docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md docs/technical/README.md
npm.cmd run api-server:maincloud
```
本次不发布 SpacetimeDB、不生成绑定、不修改 `migration.rs`原因是没有表结构、reducer、procedure 或绑定形状变更。

View File

@@ -0,0 +1,84 @@
# server-rs DDD WP-BF Big Fish 运行态后端真相源关闭记录2026-04-29
## 1. 背景
`WP-BF Big Fish` 已完成发布门禁领域化,但运行态仍由前端本地规则推进,导致前端同时承担输入、实体移动、碰撞、合成、胜负结算和快照更新。按照本轮 DDD 重构边界,前端只负责表现和提交输入,正式运行态规则必须落到 `server-rs`
本次关闭目标是把 Big Fish 从“前端本地运行态”切到“Rust 领域规则 + SpacetimeDB 运行表 + API facade + 前端 client 接入”的单主链,同时移除 Big Fish works mapper 中的旧形状兼容解析。
## 2. 本次完成范围
1. `module-big-fish` 新增运行态领域快照:
- `BigFishRunStatus`
- `BigFishVector2`
- `BigFishRuntimeEntitySnapshot`
- `BigFishRuntimeSnapshot`
2. `module-big-fish` 新增运行态应用服务:
- `start_big_fish_run`
- `submit_big_fish_input`
- `serialize_runtime_snapshot`
- `deserialize_runtime_snapshot`
3. 运行态规则已由领域层统一负责:
- 初始己方和野生实体生成。
- 输入向量归一化。
- 领队、跟随者和野生实体移动。
- 同级收编、强弱碰撞、三合一升级。
- 离屏野生实体裁剪和补刷。
- 胜利、失败和结算事件。
4. `spacetime-module/src/big_fish/runtime.rs` 新增 Big Fish 运行态 procedure
- `start_big_fish_run`
- `get_big_fish_run`
- `submit_big_fish_input`
5. 新增 `big_fish_runtime_run` 表,保存 run 快照、最后输入方向、tick、归属用户和会话来源并已同步 `migration.rs` 与表目录。
6. `spacetime-client` 新增 Big Fish runtime typed facade 和 record mapper并重新生成 Rust 绑定。
7. `api-server` 新增鉴权路由:
- `POST /api/runtime/big-fish/sessions/{session_id}/runs`
- `GET /api/runtime/big-fish/runs/{run_id}`
- `POST /api/runtime/big-fish/runs/{run_id}/input`
8. `shared-contracts` 与前端 shared contract 新增 `BigFishRunResponse`、运行态实体/坐标 DTO 和 `SubmitBigFishInputRequest`
9. 前端 Big Fish 运行态 client 改为调用后端 run/input 接口,`PlatformEntryFlowShellImpl` 不再推进本地规则。
10. 删除 `src/services/big-fish-runtime/bigFishLocalRuntime.ts``/big-fish` 调试直达页降级回平台入口,避免继续暴露本地运行态主链。
## 3. 边界说明
1. 本次不接入 `server-node`、Express 或 PostgreSQL也不为旧 Node 兼容层保留双主链。
2. `spacetime-module` 只负责表读写、授权、事务编排和调用领域服务,不在 adapter 内复制 Big Fish 玩法规则。
3. `api-server` 只负责鉴权、请求校验、DTO 映射和 `spacetime-client` facade 调用,不直接访问 SpacetimeDB table。
4. 前端只提交方向输入并渲染后端返回快照,正式实体状态、胜负和事件日志都以后端响应为准。
5. Big Fish works mapper 已移除旧 JSON 兼容解析,后续要求 SpacetimeDB procedure 返回新的 `owner_user_id``play_count` 等稳定字段。
6. `big_fish_runtime_run` 是运行态快照表,不替代创作会话、资产槽或发布门禁真相;删除作品时同步清理来源会话下的 run。
## 4. 后续边界
1. Big Fish 运行态资源展示仍复用现有 session / work 的资产槽数据;若要让公开作品 run 响应直接携带资产包,应由后续契约任务单独扩展 DTO。
2. 真实 Maincloud 发布和订阅侧 smoke 仍归 `WP-V 全链验证与发布 smoke`
3. 若后续把运行态拆为更细表,而不是整份 `snapshot_json`,必须重新同步 `migration.rs`、绑定和 `SPACETIMEDB_TABLE_CATALOG.md`
## 5. 验收
关闭前必须执行:
```powershell
cargo test -p module-big-fish --manifest-path server-rs/Cargo.toml
cargo check -p spacetime-module --manifest-path server-rs/Cargo.toml
cargo check -p spacetime-client --manifest-path server-rs/Cargo.toml
cargo check -p api-server --manifest-path server-rs/Cargo.toml
npm.cmd run test -- src/components/big-fish-runtime/BigFishRuntimeShell.test.tsx src/components/rpg-entry/RpgEntryFlowShell.agent.interaction.test.tsx
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_BF_RUNTIME_BACKEND_TRUTH_2026-04-29.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md docs/technical/README.md docs/technical/SPACETIMEDB_TABLE_CATALOG.md server-rs/crates/module-big-fish/src/application.rs server-rs/crates/module-big-fish/src/domain.rs server-rs/crates/module-big-fish/src/commands.rs server-rs/crates/module-big-fish/src/errors.rs server-rs/crates/module-big-fish/src/events.rs server-rs/crates/module-big-fish/src/lib.rs server-rs/crates/spacetime-module/src/big_fish/runtime.rs server-rs/crates/spacetime-module/src/big_fish/tables.rs server-rs/crates/spacetime-module/src/big_fish/session.rs server-rs/crates/spacetime-module/src/migration.rs server-rs/crates/spacetime-client/src/big_fish.rs server-rs/crates/spacetime-client/src/mapper.rs server-rs/crates/spacetime-client/src/lib.rs server-rs/crates/shared-contracts/src/big_fish.rs server-rs/crates/api-server/src/big_fish.rs server-rs/crates/api-server/src/app.rs packages/shared/src/contracts/bigFish.ts src/services/big-fish-runtime/bigFishRuntimeClient.ts src/services/big-fish-runtime/index.ts src/components/platform-entry/PlatformEntryFlowShellImpl.tsx src/components/rpg-entry/RpgEntryFlowShell.agent.interaction.test.tsx src/BigFishPlaygroundApp.tsx
npm.cmd run api-server:maincloud
```
最终执行结果:
1. `cargo test -p module-big-fish --manifest-path server-rs/Cargo.toml` 通过6 个测试通过。
2. `cargo check -p spacetime-module --manifest-path server-rs/Cargo.toml` 通过。
3. `cargo check -p spacetime-client --manifest-path server-rs/Cargo.toml` 通过。
4. `cargo check -p api-server --manifest-path server-rs/Cargo.toml` 通过,仅保留既有 `api-server/src/prompt/rpg/runtime_chat.rs` 未使用 helper warning。
5. `npm.cmd run check:server-rs-ddd` 通过。
6. `npm.cmd run test -- src/components/big-fish-runtime/BigFishRuntimeShell.test.tsx` 通过4 个测试通过;测试已改为真实定时等待,不再使用全局 fake timers。
7. `npm.cmd run test -- src/components/rpg-entry/RpgEntryFlowShell.agent.interaction.test.tsx -t "public code search opens a published big fish work by BF code"` 通过,确认 BF 编号搜索进入后端 run 主链。
8. `npm.cmd run check:encoding -- ...` 对本次触达文件通过,收尾补充检查对 3 个文件通过。
9. `npm.cmd run api-server:maincloud` 已按常驻服务启动;`GET http://127.0.0.1:3100/healthz` 返回 `200`,验收后已停止本次启动进程。
补充说明:完整 `src/components/rpg-entry/RpgEntryFlowShell.agent.interaction.test.tsx` 当前单独运行仍有既有长流程用例失败,失败集中在 RPG/拼图/创作结果页路径,例如 `create tab opens compiled agent draft in result refinement page``published puzzle detail returns to the source platform tab``agent draft result test button enters current draft without publish gate`。这些失败在不并跑 Big Fish runtime 测试时也存在,未指向本次 WP-BF 运行态迁移文件,后续应由对应 RPG/Puzzle/Custom World 前端接线包继续收口。

View File

@@ -0,0 +1,41 @@
# WP-CW Custom World 基础领域枚举归位切片
## 背景
`module-custom-world/src/lib.rs` 仍直接承载 Custom World 和 RPG Agent 的基础枚举、字符串口径与进度常量。随着 `custom_world` SpacetimeDB adapter 已完成根入口瘦身,领域 crate 也需要继续把纯领域对象迁入 `domain.rs`,避免后续 profile、agent session、draft card、gallery 与 publish gate 规则继续堆回根文件。
## 本次范围
1. 认领 `WP-CW Custom World` 的基础领域枚举归位切片。
2.`MAX_PROGRESS_PERCENT` 迁入 `module-custom-world/src/domain.rs`
3. 将 Custom World / RPG Agent 基础枚举迁入 `domain.rs`
- `CustomWorldPublicationStatus`
- `CustomWorldThemeMode`
- `CustomWorldGenerationMode`
- `CustomWorldSessionStatus`
- `RpgAgentStage`
- `RpgAgentMessageRole`
- `RpgAgentMessageKind`
- `RpgAgentOperationType`
- `RpgAgentOperationStatus`
- `RpgAgentDraftCardKind`
- `RpgAgentDraftCardStatus`
- `CustomWorldRoleAssetStatus`
4. 将这些枚举的 `as_str``CustomWorldThemeMode::from_client_str` 一并迁入 `domain.rs`
5. `lib.rs` 通过 `pub use domain::*` 保持既有 `module_custom_world::*` 公开 API。
## 边界
1. 本次不改 SpacetimeDB table、reducer、procedure、row mapper 或 `migration.rs`
2. 本次不改 `api-server``spacetime-client`、platform adapter 或前端。
3. 本次不移动 profile、agent session、draft card、publish gate 的结构体和校验函数,避免把大包拆分与本切片混在一起。
4. 本次不改变任何序列化字段、枚举字符串值或中文错误文案。
## 验收
```powershell
cargo fmt -p module-custom-world --manifest-path server-rs/Cargo.toml --check
cargo test -p module-custom-world --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_CW_DOMAIN_ENUM_REHOME_2026-04-29.md server-rs/crates/module-custom-world/src/domain.rs server-rs/crates/module-custom-world/src/lib.rs docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md
```

View File

@@ -0,0 +1,32 @@
# WP-FE-C RPG runtime shell 组件测试夹具接线切片
## 背景
`WP-FE-S``WP-FE-H` 已经把 RPG runtime story 读取侧收口到 `storySessionId` scoped projection client 与 hooks 网关。组件层仍不能迁移完整开局、动作结算等写接口,但 `RpgRuntimeShell` 组件测试夹具还保留旧 hook UI 形状,导致 `typecheck` 在组件测试文件中失败。
## 本次范围
1. 认领 `WP-FE-C Frontend components 接线` 中可并行的 RPG runtime shell 组件测试夹具接线切片。
2. 修正 `src/components/rpg-runtime-shell/RpgRuntimeShell.test.tsx`
- `StoryMoment` mock 使用当前 `text/options` 字段。
- `Character` mock 对齐当前角色类型,不再写入旧 `motivation/combatStyle/role/imageSrc/initialItems` 等字段。
- `npcUi/characterChatUi/inventoryUi/battleRewardUi/questUi/npcChatQuestOfferUi/goalUi` mock 对齐当前 hooks 暴露的稳定 UI 对象形状。
3. 保持 `RpgRuntimeShell` 正式组件行为不变,只消除测试夹具对旧组件接线形状的依赖。
## 边界
1. 本次不改 `src/services/**``src/hooks/**` 或任何后端接口。
2. 本次不迁移 `beginRuntimeStorySession``resolveRuntimeStoryAction` 等尚未稳定的新写接口。
3. 本次不新增 UI 文案,不改组件视觉布局。
4. 本次不删除旧 runtime story contract 或旧 client alias这些仍等待 `WP-DEL` 串行收口。
## 验收
```powershell
npm.cmd run typecheck -- --pretty false
npm.cmd run test -- src/components/rpg-runtime-shell/RpgRuntimeShell.test.tsx
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_FE_C_RPG_RUNTIME_SHELL_TEST_FIXTURE_2026-04-29.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md src/components/rpg-runtime-shell/RpgRuntimeShell.test.tsx
git diff --check -- docs/technical/SERVER_RS_DDD_WP_FE_C_RPG_RUNTIME_SHELL_TEST_FIXTURE_2026-04-29.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md src/components/rpg-runtime-shell/RpgRuntimeShell.test.tsx
```
结果:`RpgRuntimeShell.test.tsx` 定向测试通过;编码检查和空白检查通过。`typecheck` 未全量通过,但不再报本切片文件,剩余阻塞来自既有非本切片文件 `src/data/sceneEncounterPreviews.ts``src/services/ai.ts`

View File

@@ -0,0 +1,32 @@
# WP-FE-H RPG runtime story 读取侧 hooks 接线切片
## 背景
`WP-FE-S` 已经补齐 story session 新主链 client并提供 `getRpgStoryRuntimeProjection` 读取 `/api/story/sessions/{storySessionId}/runtime-projection``WP-FE-H` 的完整 hooks 迁移仍依赖后端 session scoped 开局和动作结算写接口;但读取侧 option catalog 与继续游戏刷新已经具备稳定 projection contract可以先把 hooks 网关的读取语义收口到 projection client。
## 本次范围
1. 认领 `WP-FE-H Frontend hooks 迁移` 中可并行的 RPG runtime story 读取侧 hooks 接线切片。
2.`src/hooks/rpg-runtime-story/rpgRuntimeStoryGateway.ts` 的读取侧从历史别名 `getRpgRuntimeStoryState` 改为显式调用 `getRpgStoryRuntimeProjection`
3. `loadServerRuntimeOptionCatalog` 继续只读取服务端 option catalog不上传本地 `GameState` 参与动作合法性解析。
4. `resumeServerRuntimeStory` 继续保持本地已水合快照主体,只同步服务端 `runtimeSessionId / storySessionId / runtimeActionVersion` 和投影故事。
5. 更新 `runtimeStoryCoordinator.test.ts` mock 命名,确保 hooks 测试明确断言读取侧走 projection client。
6. 补齐 `src/hooks/useGameFlow.customWorld.test.tsx``beginRpgRuntimeStorySession` 测试桩,避免 hooks 全量测试在 Node 环境直接 fetch 相对路径,同时保持自定义世界开局 hooks 仍消费服务端快照。
## 边界
1. 本次不迁移 `beginRuntimeStorySession`,因为新开局接口尚未返回可直接进入游戏的完整 `GameState` 快照。
2. 本次不迁移 `resolveRuntimeStoryAction`,因为完整动作结算的新 session scoped 写接口尚未稳定。
3. 本次不改 components不新增 UI 文案,不在组件层拼 API 请求。
4. 本次不改 `api-server``spacetime-client``spacetime-module` 或共享契约。
5. 本次不删除旧 runtime story contract、旧 client alias 或兼容测试;这些仍等待 `WP-DEL` 串行收口。
## 验收
```powershell
npm.cmd run test -- src/hooks/rpg-runtime-story/runtimeStoryCoordinator.test.ts
npm.cmd run test -- src/hooks/useGameFlow.customWorld.test.tsx
npm.cmd run test -- src/hooks
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_FE_H_RPG_RUNTIME_STORY_HOOKS_PROJECTION_2026-04-29.md src/hooks/rpg-runtime-story/rpgRuntimeStoryGateway.ts src/hooks/rpg-runtime-story/inventoryActions.ts src/hooks/rpg-runtime-story/runtimeStoryCoordinator.test.ts src/hooks/useGameFlow.customWorld.test.tsx docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md
git diff --check -- docs/technical/SERVER_RS_DDD_WP_FE_H_RPG_RUNTIME_STORY_HOOKS_PROJECTION_2026-04-29.md src/hooks/rpg-runtime-story/rpgRuntimeStoryGateway.ts src/hooks/rpg-runtime-story/inventoryActions.ts src/hooks/rpg-runtime-story/runtimeStoryCoordinator.test.ts src/hooks/useGameFlow.customWorld.test.tsx docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md
```

View File

@@ -0,0 +1,57 @@
# WP-FE-S RPG runtime story client 迁移记录
## 背景
`WP-API` 已提供新主链读取接口:
```text
GET /api/story/sessions/{storySessionId}/runtime-projection
```
该接口返回 `StoryRuntimeProjectionResponse`,不再返回旧 runtime story 的 `snapshot / viewModel / presentation / patches` 组合。前端读取侧必须改用 `storySessionId`,不能继续把 `runtimeSessionId` 当成 story 会话主键。
## 本轮落地边界
已落地:
1.`packages/shared/src/contracts/story.ts` 补齐前端 story session / runtime projection 契约,字段对齐 Rust `shared-contracts/src/story.rs` 的 camelCase 回包。
2.`GameState`、快照水合类型与水合逻辑中新增 `storySessionId?: string | null`
3. `src/services/rpg-runtime/rpgRuntimeStoryClient.ts` 的读取侧改为:
- `getRuntimeStoryState({ storySessionId })` 请求 `/api/story/sessions/{storySessionId}/runtime-projection`
- `loadRuntimeInventoryView``StoryRuntimeProjectionResponse` 映射背包视图。
- 缺失 `storySessionId` 时直接抛出中文错误,不回退到 `runtimeSessionId`
4. `src/hooks/rpg-runtime-story/rpgRuntimeStoryGateway.ts` 的读取侧改为消费新投影:
- 选项目录来自 `projection.options`
- 继续游戏时保留本地已水合快照主体,只同步 `runtimeSessionId / storySessionId / runtimeActionVersion` 和展示故事。
5. `src/services/rpg-runtime/rpgRuntimeStoryClient.ts` 新增 story session 新主链 API client
- `beginStorySession` 请求 `POST /api/story/sessions`
- `continueStorySession` 请求 `POST /api/story/sessions/continue`
- `getStorySessionState` 请求 `GET /api/story/sessions/{storySessionId}/state`
- `getStoryRuntimeProjection` 请求 `GET /api/story/sessions/{storySessionId}/runtime-projection`
-`storySessionId` 做统一 trim 与空值中文错误,避免后续 hooks 继续散落路径常量和空 ID 分支。
6. `src/services/rpg-runtime/index.ts` 已导出新 client 函数与结果类型,供后续 `WP-FE-H` 迁 hook 时直接接入。
7. 为满足 `WP-FE-S``src/services` 全量验收,补回 `src/services/customWorldAgentGenerationProgress.ts` 缺失的“建立场景连接”阶段,使草稿生成进度重新对齐既有 13 步文档与测试口径。
## 未完成边界
暂未迁移:
1. `beginRuntimeStorySession` 仍调用旧 `/api/runtime/story/sessions`,因为当前新 `/api/story/sessions` 只创建 story session不返回前端开局所需的完整 `GameState` 快照。新 `beginStorySession` 已作为稳定 client 先行提供hook 是否切换等待后端开局投影组合稳定。
2. `resolveRuntimeStoryAction` 仍调用旧 `/api/runtime/story/actions/resolve`,因为当前新主链尚未提供等价的 session scoped 动作结算接口与快照回包。新 `continueStorySession` 只覆盖 story event 续写,不等价于完整 runtime action settle。
3. hooks/components 不在本轮大改;`WP-FE-H` 等后端写接口稳定后再迁。
## 后续依赖
1. `WP-API/WP-RS` 需要提供新的 story session scoped 开局接口,返回可直接进入游戏的 `GameState` 或明确的前端投影组合。
2. `WP-API/WP-RS` 需要提供新的 story session scoped 动作结算接口,返回新投影及必要的状态更新结果。
3. 上述接口稳定后,`WP-FE-S` 再删除旧 `/api/runtime/story/*` 写接口调用,`WP-FE-H` 迁 hooks最后由 `WP-DEL` 物理删除旧 runtime story contract 与 compat 测试。
## 验收命令
```powershell
npm.cmd run test -- src/services/rpg-runtime/rpgRuntimeStoryClient.test.ts
npm.cmd run test -- src/hooks/rpg-runtime-story/runtimeStoryCoordinator.test.ts
npm.cmd run test -- src/services/customWorldAgentGenerationProgress.test.ts
npm.cmd run test -- src/services
npm.cmd run check:encoding -- packages/shared/src/contracts/story.ts src/services/rpg-runtime/rpgRuntimeStoryClient.ts src/services/rpg-runtime/index.ts src/services/customWorldAgentGenerationProgress.ts src/services/customWorldAgentGenerationProgress.test.ts src/hooks/rpg-runtime-story/rpgRuntimeStoryGateway.ts src/hooks/rpg-runtime-story/inventoryActions.ts src/persistence/runtimeSnapshot.ts src/persistence/runtimeSnapshotTypes.ts src/types/game.ts docs/technical/SERVER_RS_DDD_WP_FE_S_RPG_RUNTIME_STORY_CLIENT_MIGRATION_2026-04-29.md
```

View File

@@ -0,0 +1,69 @@
# WP-PF 平台副作用错误分类收口记录2026-04-29
## 1. 背景
`WP-PF platform side effects` 负责承载 LLM、OSS、SMS、微信等外部副作用实现。当前 `platform-llm``platform-oss``platform-auth` 已经各自有错误枚举,但 `api-server` 后续接入时仍容易重复用字符串或具体枚举分支判断 HTTP 错误类别。
第一段切片已补平台错误分类基础设施。继续收口时,需要把 `api-server` 中已接入的平台副作用统一改为消费这些稳定分类,并把微信 OAuth HTTP provider 下沉到 `platform-auth`,让 `api-server` 只保留 BFF 编排、会话签发、redirect 与错误 envelope 映射。
## 2. 范围
允许修改:
1. `server-rs/crates/platform-llm/src/lib.rs`
2. `server-rs/crates/platform-oss/src/lib.rs`
3. `server-rs/crates/platform-auth/src/lib.rs`
4. `server-rs/crates/api-server/src/platform_errors.rs`
5. `server-rs/crates/api-server/src/llm.rs`
6. `server-rs/crates/api-server/src/assets.rs`
7. 已经直接映射 OSS 错误的资产相关 BFF 模块
8. `server-rs/crates/api-server/src/state.rs`
9. `server-rs/crates/api-server/src/wechat_auth.rs`
10. `server-rs/crates/api-server/src/wechat_provider.rs`
11. 本文档
12. 全局任务清单进度记录
禁止修改:
1. `spacetime-module/src/**`
2. `spacetime-client/src/**`
3. `module-*`
4. 前端 services/hooks/components
5. SpacetimeDB table / reducer / procedure / migration
6. 玩法状态机和领域规则
## 3. 设计
每个 platform crate 暴露自己的错误分类枚举:
1. `LlmErrorKind`
2. `OssErrorKind`
3. `AuthPlatformErrorKind`
并在既有错误枚举上增加 `kind()` 方法。分类只表达 adapter 可消费的稳定错误类别,不承载业务状态机,也不直接绑定 HTTP status。
`api-server` 增加内部 `platform_errors` 模块,负责把平台错误分类映射到 HTTP status、统一 provider details 与中文 envelope。映射原则
1. `InvalidRequest` / `InvalidConfig` 等本地配置或请求错误不再散落在业务 route 中重复 match。
2. `ObjectNotFound` 稳定映射为 `404`
3. LLM 上游 `429` 保留 `429`,其他上游、网络、序列化、签名类错误映射为 `502`
4. SMS/微信 provider 错误统一走 `platform-auth` 错误分类,领域态错误仍由 `module-auth` 自己的应用错误映射。
5. `platform-*` 不绑定 HTTP status不生成 Axum response不持有玩法领域状态。
微信 OAuth provider 的 HTTP 请求、授权 URL 拼接、mock provider 和回调资料解析归入 `platform-auth`。由于 `platform-auth` 不能依赖 `module-auth`,微信 provider 输出独立的 `WechatIdentityProfile``api-server` 在 BFF 边界把它转换为 `module_auth::WechatIdentityProfile` 后再调用领域服务。
图像/视频模型直连接口仍分布在角色形象、角色动画、拼图和自定义世界资产模块中,当前属于视觉资产生成专项遗留,不在本次 WP-PF LLM/OSS/SMS/微信统一 adapter 收口内;后续若新建 image/video platform crate需要另立工作包迁移。
## 4. 验收
```powershell
cargo test -p platform-llm -p platform-oss -p platform-auth --manifest-path server-rs/Cargo.toml
cargo fmt -p platform-llm -p platform-oss -p platform-auth --manifest-path server-rs/Cargo.toml --check
cargo test -p api-server platform_errors --manifest-path server-rs/Cargo.toml
cargo test -p api-server llm --manifest-path server-rs/Cargo.toml
cargo test -p api-server wechat --manifest-path server-rs/Cargo.toml
cargo check -p api-server --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_PF_PLATFORM_ERROR_CLASSIFICATION_2026-04-29.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md server-rs/crates/platform-llm/src/lib.rs server-rs/crates/platform-oss/src/lib.rs server-rs/crates/platform-auth/src/lib.rs server-rs/crates/api-server/src/platform_errors.rs server-rs/crates/api-server/src/llm.rs server-rs/crates/api-server/src/state.rs server-rs/crates/api-server/src/wechat_provider.rs server-rs/crates/api-server/src/wechat_auth.rs
npm.cmd run api-server:maincloud
```

View File

@@ -0,0 +1,43 @@
# WP-PZ Puzzle 基础领域常量与枚举归位切片
## 背景
`module-puzzle/src/lib.rs` 当前仍承载 Puzzle Agent、作品发布和运行态拼图的基础枚举、ID 前缀、标签数量规则与洗牌尝试次数。随着 DDD 骨架已经具备 `domain.rs``commands.rs``application.rs``events.rs``errors.rs`,本切片先把纯领域常量和基础枚举迁入 `domain.rs`,避免后续 Agent session、work profile、runtime run 与排行榜规则继续堆回根文件。
## 本次范围
1. 认领 `WP-PZ Puzzle` 的基础领域常量与枚举归位切片。
2. 将以下常量迁入 `module-puzzle/src/domain.rs`
- `PUZZLE_AGENT_SESSION_ID_PREFIX`
- `PUZZLE_AGENT_MESSAGE_ID_PREFIX`
- `PUZZLE_PROFILE_ID_PREFIX`
- `PUZZLE_RUN_ID_PREFIX`
- `PUZZLE_MIN_TAG_COUNT`
- `PUZZLE_MAX_TAG_COUNT`
- `PUZZLE_INITIAL_SHUFFLE_ATTEMPTS`
3. 将以下基础枚举迁入 `domain.rs`
- `PuzzleAgentStage`
- `PuzzleAnchorStatus`
- `PuzzleAgentMessageRole`
- `PuzzleAgentMessageKind`
- `PuzzlePublicationStatus`
- `PuzzleRuntimeLevelStatus`
4. 将这些枚举的 `as_str` 方法一并迁入 `domain.rs`
5. `lib.rs` 通过 `pub use domain::*` 保持既有 `module_puzzle::*` 公开 API。
## 边界
1. 本次不改 SpacetimeDB table、reducer、procedure、row mapper 或 `migration.rs`
2. 本次不改 `api-server``spacetime-client`、platform adapter 或前端。
3. 本次不移动 Agent session、work profile、runtime run、leaderboard 的结构体和校验函数,避免把大包拆分与本切片混在一起。
4. 本次不改变任何序列化字段、枚举字符串值、标签数量规则、洗牌规则或中文错误文案。
## 验收
```powershell
cargo fmt -p module-puzzle --manifest-path server-rs/Cargo.toml --check
cargo test -p module-puzzle --manifest-path server-rs/Cargo.toml
cargo check -p module-puzzle --features spacetime-types --target wasm32-unknown-unknown --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_PZ_DOMAIN_ENUM_REHOME_2026-04-29.md server-rs/crates/module-puzzle/src/domain.rs server-rs/crates/module-puzzle/src/lib.rs server-rs/crates/module-puzzle/README.md docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md
```

View File

@@ -0,0 +1,33 @@
# WP-PZ Puzzle 领域类型与规则拆分切片
## 背景
上一轮 `WP-PZ Puzzle` 已经把基础常量与枚举迁入 `module-puzzle/src/domain.rs`,但 `module-puzzle/src/lib.rs` 仍然承载 Agent 会话快照、作品 profile、运行态棋盘、procedure 输入、procedure 返回、字段错误与全部纯规则函数。
按照 `SERVER_RS_DDD_FULL_REFACTOR_2026-04-28.md``module-puzzle` 应继续把纯领域内容落入 `domain.rs``commands.rs``application.rs``events.rs``errors.rs`,让根入口只保留模块声明和公开导出。
## 本次范围
1. 将 Puzzle Agent、锚点包、草稿、作品 profile、运行态棋盘、排行榜等纯领域类型迁入 `module-puzzle/src/domain.rs`
2. 将 SpacetimeDB procedure/reducer 写入输入迁入 `module-puzzle/src/commands.rs`
3. 将 procedure 返回包装和拼图纯规则函数迁入 `module-puzzle/src/application.rs`
4.`PuzzleFieldError` 和中文错误文案迁入 `module-puzzle/src/errors.rs`
5.`module-puzzle/src/events.rs` 增加最小 `PuzzleDomainEvent`,先表达草稿变化、作品发布和运行态推进事实。
6. `module-puzzle/src/lib.rs` 只保留 DDD 子模块声明和 `pub use`,保持既有 `module_puzzle::*` 外部 API。
## 边界
1. 本次不改 SpacetimeDB table、reducer、procedure、row mapper 或 `migration.rs`
2. 本次不改 `api-server``spacetime-client`、platform adapter 或前端。
3. 本次不改变序列化字段、procedure 输入结构、procedure 返回 JSON 包装、标签数量规则、洗牌规则、移动/合并/拆分语义或中文错误文案。
4. 本次新增的 `PuzzleDomainEvent` 只作为领域事件落位,不接入 `spacetime-module` event table。
## 验收
```powershell
cargo fmt -p module-puzzle --manifest-path server-rs/Cargo.toml --check
cargo test -p module-puzzle --manifest-path server-rs/Cargo.toml
cargo check -p module-puzzle --features spacetime-types --target wasm32-unknown-unknown --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_PZ_DOMAIN_SPLIT_2026-04-29.md server-rs/crates/module-puzzle/src/lib.rs server-rs/crates/module-puzzle/src/domain.rs server-rs/crates/module-puzzle/src/commands.rs server-rs/crates/module-puzzle/src/application.rs server-rs/crates/module-puzzle/src/events.rs server-rs/crates/module-puzzle/src/errors.rs server-rs/crates/module-puzzle/README.md docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md
```

View File

@@ -0,0 +1,41 @@
# WP-RPG Combat 基础领域常量与枚举归位切片
## 背景
`WP-RPG Gameplay 域` 覆盖 combat、inventory、npc、progression、quest、runtime-item、story 等多个玩法 crate。本次选择其中最小且可并行的 `module-combat` 切片:`module-combat/src/lib.rs` 仍直接承载战斗 ID 前缀、版本/伤害常量、旧攻击 function 列表以及基础枚举。随着 DDD 骨架已经具备 `domain.rs`,这些纯领域对象应先归位到 `domain.rs`,为后续拆分命令、错误、应用结果和跨域事件留出边界。
## 本次范围
1. 认领 `WP-RPG Gameplay 域` 的 combat 基础领域常量与枚举归位切片。
2. 将以下常量迁入 `module-combat/src/domain.rs`
- `BATTLE_STATE_ID_PREFIX`
- `INITIAL_BATTLE_VERSION`
- `BASIC_FIGHT_COUNTER_RATIO`
- `MIN_FIGHT_COUNTER_DAMAGE`
- `SPAR_MIN_HP`
- `LEGACY_ATTACK_FUNCTION_IDS`
3. 将以下基础枚举迁入 `domain.rs`
- `BattleMode`
- `BattleStatus`
- `CombatOutcome`
4. 将这些枚举的 `as_str` 方法一并迁入 `domain.rs`
5. `lib.rs` 通过 `pub use domain::*` 保持既有 `module_combat::*` 公开 API。
6. `module-combat``spacetime-types` feature 同步启用 `module-runtime-item/spacetime-types`,确保战斗快照里引用的 `RuntimeItemRewardItemSnapshot` 在 wasm 目标下具备 SpacetimeDB 类型派生。
## 边界
1. 本次不改 SpacetimeDB table、reducer、procedure、row mapper 或 `migration.rs`
2. 本次不改 `api-server``spacetime-client`、platform adapter 或前端。
3. 本次不移动 `BattleStateInput``BattleStateSnapshot``ResolveCombatActionInput``CombatFieldError` 和战斗结算函数,避免把常量枚举归位与大包拆分混在一起。
4. 本次不改变任何战斗数值、支持的 function id、枚举字符串值或中文错误文案。
5. Cargo feature 传播仅用于修复 `spacetime-types` 组合编译,不引入新依赖路径或运行时行为。
## 验收
```powershell
cargo fmt -p module-combat --manifest-path server-rs/Cargo.toml --check
cargo test -p module-combat --manifest-path server-rs/Cargo.toml
cargo check -p module-combat --features spacetime-types --target wasm32-unknown-unknown --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_RPG_COMBAT_DOMAIN_ENUM_REHOME_2026-04-29.md server-rs/crates/module-combat/Cargo.toml server-rs/crates/module-combat/src/domain.rs server-rs/crates/module-combat/src/lib.rs server-rs/crates/module-combat/README.md docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md
```

View File

@@ -0,0 +1,38 @@
# WP-RPG module-story 领域拆分收口2026-04-29
## 1. 收口目标
本切片关闭 `SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md``module-story` 的两类漂移:
1. README 仍写“目录占位”和旧 `/api/runtime/story/*` 兼容链路。
2. `domain / commands / application / events / errors` 文件仍停在“过渡落位”注释,真实规则集中在 `lib.rs`
本次只做物理分层和文档对齐,不新增 story action 写接口,不修改 SpacetimeDB 表结构,不触碰 `migration.rs`
## 2. 已完成内容
1. `src/domain.rs` 收口剧情会话领域快照、状态、ID 前缀和 `generate_story_session_id`
2. `src/commands.rs` 收口 `StorySessionInput``StoryContinueInput``StorySessionStateInput`、输入构造和字段校验。
3. `src/events.rs` 收口 `StoryEventKind``StoryEventSnapshot`、开局事件和事件 ID 生成。
4. `src/application.rs` 收口会话快照构造、续写应用服务、procedure result 类型和只读 record mapper。
5. `src/errors.rs` 收口 `StorySessionFieldError` 与中文错误文案。
6. `src/lib.rs` 只保留模块声明和 `pub use`,继续保持 `module_story::*` 公开 API。
7. `module-story/README.md` 改为当前真实边界,明确不恢复旧 `/api/runtime/story/*` 兼容路由。
## 3. 边界
1. 本切片不改变 `story_session``story_event` 的 SpacetimeDB row shape、reducer/procedure 签名或前端 DTO。
2. 本切片不接入 LLM、SSE、HTTP route 或前端 hooks。
3. 后续完整动作结算仍等待 `WP-RS/WP-ST/WP-SC/WP-API/WP-FE` 继续推进。
4. `module-story` 只承载纯 story session 规则;运行态投影、背包/NPC/战斗/任务联动继续由相邻领域模块和 adapter 编排。
## 4. 验收
已执行:
```powershell
cargo test -p module-story --manifest-path server-rs\Cargo.toml
cargo check -p module-story --manifest-path server-rs\Cargo.toml
```
结果通过8 个单元测试通过。

View File

@@ -0,0 +1,56 @@
# WP-RS Runtime Story Compat 残留审计切片
## 背景
`WP-RS Runtime Story 去兼容层` 已完成 crate 迁名、旧 HTTP compat 路由下线、runtime projection 契约/API/读取侧迁移等多轮推进。当前仍存在一些 `compat` 或旧 `/api/runtime/story/*` 命名残留,需要区分“可以立即清理的工程语义残留”和“必须等待后端写接口稳定后再删除的运行依赖”。
本次切片只处理前者,并冻结后者的交接清单。
## 本次范围
允许修改:
1. `server-rs/crates/module-runtime-story/src/**` 中只描述历史兼容阶段的注释。
2. `server-rs/crates/module-runtime-story/README.md`
3. 本文档
4. `docs/technical/README.md`
5. `docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md`
禁止修改:
1. `src/services/rpg-runtime/rpgRuntimeStoryClient.ts`
2. `src/hooks/rpg-runtime-story/**`
3. `packages/shared/src/contracts/rpgRuntimeStoryState.ts`
4. `server-rs/crates/shared-contracts/src/runtime_story.rs`
5. `api-server` route 挂载和 BFF 行为
6. SpacetimeDB 表、procedure、绑定和 `migration.rs`
## 本次处理
1. 清理 `module-runtime-story` 运行代码注释中的 `compat` 定位,将 crate 口径改为 runtime story 主链纯规则收口。
2. 保留“历史 payload”相关说明因为这些字段仍是实际输入兼容范围不属于旧层命名。
3. 更新 `module-runtime-story/README.md`,明确后续要迁的是旧 `/api/runtime/story/*` 写侧能力,而不是继续扩展兼容桥。
## 残留清单
以下残留本次不删除:
1. `src/services/rpg-runtime/rpgRuntimeStoryClient.ts` 仍指向 `/api/runtime/story`,原因是开局和动作写侧 session scoped 新接口尚未完成。
2. `src/services/rpg-runtime/rpgRuntimeStoryClient.test.ts` 仍断言旧写接口路径,需等待新写接口和 service contract 稳定后由 `WP-FE-S` 修改。
3. `packages/shared/src/contracts/rpgRuntimeStoryState.ts``server-rs/crates/shared-contracts/src/runtime_story.rs` 仍保留 `RuntimeStoryActionResponse`,原因是前端旧写侧仍消费该响应形状。
4. `src/hooks/rpg-runtime-story/**` 仍保留部分旧调用面兼容注释,需等 `WP-FE-H` 在 service 迁移后统一收口。
## 后续边界
1. 后端新写接口稳定前,不删除旧前端写 client。
2. `WP-FE-S` 先迁 service再由 `WP-FE-H` 迁 hooks最后 `WP-FE-C` 接组件。
3. `WP-DEL` 只能在旧接口无运行引用后删除 `RuntimeStoryActionResponse` 等旧 contract。
## 验收
```powershell
cargo fmt -p module-runtime-story --manifest-path server-rs/Cargo.toml --check
cargo test -p module-runtime-story --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_RS_COMPAT_RESIDUE_AUDIT_2026-04-29.md docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md server-rs/crates/module-runtime-story/README.md server-rs/crates/module-runtime-story/src/domain.rs server-rs/crates/module-runtime-story/src/commands.rs server-rs/crates/module-runtime-story/src/errors.rs server-rs/crates/module-runtime-story/src/events.rs server-rs/crates/module-runtime-story/src/core.rs server-rs/crates/module-runtime-story/src/game_state.rs server-rs/crates/module-runtime-story/src/battle.rs server-rs/crates/module-runtime-story/src/forge.rs server-rs/crates/module-runtime-story/src/forge_actions.rs server-rs/crates/module-runtime-story/src/npc_support.rs
```

View File

@@ -0,0 +1,130 @@
# WP-RT Adapter/API 收口落地说明
## 背景
`WP-RT Runtime/Profile/Save` 已完成 runtime settings、snapshot/profile/save archive 类型、错误层、命令构造和应用记录投影拆分。剩余风险集中在 Adapter/API 层仍保留部分纯规则,以及 profile 旧兼容路径继续挂载,容易让后续前端或 BFF 再走 `/api/runtime/profile/*` 旧入口。
本次收口目标是继续遵循 DDD 边界:`module-runtime` 承载 runtime/profile/save 的纯规则和字段错误,`spacetime-module` 只保留 SpacetimeDB table、事务读写和 row mapper`api-server` 只负责 HTTP/BFF 映射,前端请求层改用新的 profile API。
## 本次范围
允许修改:
1. `server-rs/crates/module-runtime/src/domain.rs`
2. `server-rs/crates/module-runtime/src/errors.rs`
3. `server-rs/crates/module-runtime/src/commands.rs`
4. `server-rs/crates/module-runtime/src/application.rs`
5. `server-rs/crates/module-runtime/src/lib.rs`
6. `server-rs/crates/spacetime-module/src/runtime/profile.rs`
7. `server-rs/crates/api-server/src/app.rs`
8. `server-rs/crates/api-server/src/runtime_save.rs`
9. `server-rs/crates/api-server/src/runtime_profile.rs`
10. `server-rs/crates/api-server/src/runtime_browse_history.rs`
11. `src/services/rpg-runtime/rpgRuntimeRequest.ts`
12. `src/services/rpg-entry/rpgProfileClient.test.ts`
13. `src/services/rpg-entry/rpgEntryClients.routing.test.ts`
14. 相关 README、技术文档和全局任务清单
禁止修改:
1. SpacetimeDB 表结构和 `migration.rs`
2. RPG story / runtime story 玩法规则
3.`server-node` / PostgreSQL 兼容逻辑
4. 非 WP-RT 并行包文件
## 设计
### 1. checkpoint 规则下沉
`api-server/src/runtime_save.rs` 不再本地维护 checkpoint 的 sessionId 校验、预览/测试态拒绝和 runtimeStats 时间水位刷新规则。
新增或迁入 `module-runtime`
1. `RuntimeSaveCheckpointInput`
2. `RuntimeSaveCheckpointSnapshotUpdate`
3. `build_runtime_save_checkpoint_input`
4. `build_runtime_save_checkpoint_update`
5. `refresh_runtime_snapshot_play_time`
6. `is_non_persistent_runtime_snapshot`
7. checkpoint 相关 `RuntimeProfileFieldError`
`api-server` 只把 HTTP payload 转为领域输入,并把领域错误映射为 runtime-save 的 API envelope。
### 2. profile/save archive 投影 meta 规则下沉
`spacetime-module/src/runtime/profile.rs` 不再本地维护 save archive/world meta 的 JSON 解析规则。
新增或迁入 `module-runtime`
1. `RuntimeProfileWorldSnapshotMeta`
2. `RuntimeProfileSaveArchiveMeta`
3. `resolve_runtime_profile_world_snapshot_meta`
4. `resolve_runtime_profile_save_archive_meta`
5. `read_runtime_json_non_negative_u64`
6. `read_runtime_json_string_field`
7. `build_runtime_builtin_world_title`
`spacetime-module` 继续负责读取 snapshot、写入 dashboard / played world / save archive 表,但 meta 判断和默认标题、摘要兜底由领域模块统一维护。
### 3. profile 剩余纯规则下沉
本次继续把留在 SpacetimeDB adapter 中的纯规则收回 `module-runtime`
1. played world、snapshot wallet ledger、save archive、recharge order、recharge wallet ledger、redeem usage、redeem ledger 等 ID 生成规则。
2. 首充叙世币奖励计算。
3. 会员购买续期时间计算。
4. 邀请码 deterministic 生成、邀请链接、每日奖励窗口和邀请人奖励上限判断。
5. 兑换码 public / unique / private 模式使用资格校验。
6. 钱包正负 delta 转换、余额溢出和余额不足校验。
`spacetime-module` 中仍保留必须依赖表状态的逻辑:查找已有邀请码、统计当天奖励次数、读取/更新 wallet dashboard、写入 wallet ledger、membership、recharge order、redeem usage 和 referral relation。
### 4. profile 旧兼容路径移除
`api-server/src/app.rs` 移除 `/api/runtime/profile/*` 旧兼容挂载,只保留 `/api/profile/*` 新主路径。
保留的新路径:
1. `/api/profile/browse-history`
2. `/api/profile/dashboard`
3. `/api/profile/wallet-ledger`
4. `/api/profile/recharge-center`
5. `/api/profile/recharge/orders`
6. `/api/profile/referrals/invite-center`
7. `/api/profile/referrals/redeem-code`
8. `/api/profile/redeem-codes/redeem`
9. `/api/profile/save-archives`
10. `/api/profile/save-archives/{world_key}`
新增 `runtime_profile_legacy_routes_are_not_mounted` 测试,确认 `/api/runtime/profile/*` 旧路径返回 `404`
### 5. 前端 profile 请求路径对齐
`src/services/rpg-runtime/rpgRuntimeRequest.ts` 对以 `/profile/` 开头的 runtime request 直接发送到 `/api/profile/*`,其他 runtime 路径继续发送到 `/api/runtime/*`
`rpgProfileClient` 与 entry routing 测试同步改为断言 `/api/profile/*`
## 边界说明
1. 本次没有新增、删除或调整 SpacetimeDB 表字段,因此不修改 `migration.rs`
2. 本次没有改 reducer/procedure 对外签名,也没有改 generated binding。
3. 本次删除的是 HTTP 兼容挂载,不保留 `/api/runtime/profile/*` fallback。
4. 本次不把 SpacetimeDB 表查询搬进 `module-runtime`;领域模块只接收纯输入并返回纯结果。
5. 本次不处理 runtime story / RPG story 规则;相关内容仍归 `WP-RS``WP-RPG`
## 验收
```powershell
cargo fmt -p module-runtime -p spacetime-module -p api-server --manifest-path server-rs/Cargo.toml --check
cargo test -p module-runtime --manifest-path server-rs/Cargo.toml
cargo check -p spacetime-module --manifest-path server-rs/Cargo.toml
cargo test -p api-server runtime_profile --manifest-path server-rs/Cargo.toml
cargo test -p api-server runtime_browse_history --manifest-path server-rs/Cargo.toml
cargo test -p api-server runtime_snapshot --manifest-path server-rs/Cargo.toml
cargo test -p api-server profile_save_archives --manifest-path server-rs/Cargo.toml
npm.cmd run test -- src/services/rpg-entry/rpgProfileClient.test.ts src/services/rpg-entry/rpgEntryClients.routing.test.ts
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_RT_ADAPTER_API_CLOSURE_2026-04-29.md server-rs/crates/module-runtime/src/domain.rs server-rs/crates/module-runtime/src/errors.rs server-rs/crates/module-runtime/src/commands.rs server-rs/crates/module-runtime/src/application.rs server-rs/crates/module-runtime/src/lib.rs server-rs/crates/module-runtime/README.md server-rs/crates/spacetime-module/src/runtime/profile.rs server-rs/crates/api-server/src/app.rs server-rs/crates/api-server/src/runtime_save.rs server-rs/crates/api-server/src/runtime_profile.rs server-rs/crates/api-server/src/runtime_browse_history.rs src/services/rpg-runtime/rpgRuntimeRequest.ts src/services/rpg-entry/rpgProfileClient.test.ts src/services/rpg-entry/rpgEntryClients.routing.test.ts docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md
git diff --check -- docs/technical/SERVER_RS_DDD_WP_RT_ADAPTER_API_CLOSURE_2026-04-29.md server-rs/crates/module-runtime/src/domain.rs server-rs/crates/module-runtime/src/errors.rs server-rs/crates/module-runtime/src/commands.rs server-rs/crates/module-runtime/src/application.rs server-rs/crates/module-runtime/src/lib.rs server-rs/crates/module-runtime/README.md server-rs/crates/spacetime-module/src/runtime/profile.rs server-rs/crates/api-server/src/app.rs server-rs/crates/api-server/src/runtime_save.rs server-rs/crates/api-server/src/runtime_profile.rs server-rs/crates/api-server/src/runtime_browse_history.rs src/services/rpg-runtime/rpgRuntimeRequest.ts src/services/rpg-entry/rpgProfileClient.test.ts src/services/rpg-entry/rpgEntryClients.routing.test.ts docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md
npm.cmd run api-server:maincloud
```

View File

@@ -0,0 +1,47 @@
# WP-RT 应用记录投影拆分落地说明
## 背景
`module-runtime` 已完成领域类型、错误类型和命令构造拆分。根入口 `lib.rs` 仍承载大量 `build_runtime_*_record`,负责把 SpacetimeDB/procedure 快照转换为 BFF 或上层 facade 使用的记录投影。该职责更接近应用层读模型映射,应迁入 `application.rs`
## 本次范围
允许修改:
1. `server-rs/crates/module-runtime/src/application.rs`
2. `server-rs/crates/module-runtime/src/lib.rs`
3. `server-rs/crates/module-runtime/README.md`
4. `docs/technical/README.md`
5. 全局 DDD 任务清单进度记录
禁止修改:
1. `server-rs/crates/spacetime-module/src/**`
2. `server-rs/crates/spacetime-client/src/**`
3. `server-rs/crates/api-server/src/**`
4. 前端 services/hooks/components
5. `server-rs/crates/spacetime-module/src/migration.rs`
## 设计
本次将以下记录投影函数迁入 `application.rs`
1. settings、browse history、profile dashboard、wallet ledger、recharge center、membership、referral、reward code、redeem code、played world、play stats、runtime snapshot、save archive 的 `build_runtime_*_record`
2. 记录投影专用 JSON helper`parse_optional_json_value`
`format_utc_micros` 暂留 `lib.rs`,作为跨 commands/application 复用的时间格式化工具。充值商品目录函数也暂留 `lib.rs`,因为命令构造仍需要用它校验充值商品 ID。
## 边界说明
1. 本次不改变任何记录投影字段、时间格式、JSON 解析或错误语义。
2. 本次不迁移充值商品目录和商品查找函数。
3. 本次不改 SpacetimeDB 表结构、reducer、procedure 或 API route。
## 验收
```powershell
cargo fmt -p module-runtime --manifest-path server-rs/Cargo.toml --check
cargo test -p module-runtime --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_RT_APPLICATION_RECORD_REFACTOR_2026-04-29.md server-rs/crates/module-runtime/src/application.rs server-rs/crates/module-runtime/src/lib.rs server-rs/crates/module-runtime/README.md docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md
```

View File

@@ -0,0 +1,50 @@
# WP-RT 命令构造拆分落地说明
## 背景
`module-runtime` 已将领域类型迁入 `domain.rs`,错误类型迁入 `errors.rs`。根入口 `lib.rs` 仍承载大量 `build_runtime_*_input`、浏览历史写入准备、snapshot upsert JSON 归一化、邀请码/兑换码归一化等命令构造函数。为了继续推进 DDD 分层,本次将写入命令构造与字段归一化迁入 `commands.rs`
## 本次范围
允许修改:
1. `server-rs/crates/module-runtime/src/commands.rs`
2. `server-rs/crates/module-runtime/src/lib.rs`
3. `server-rs/crates/module-runtime/README.md`
4. `docs/technical/README.md`
5. 全局 DDD 任务清单进度记录
禁止修改:
1. `server-rs/crates/spacetime-module/src/**`
2. `server-rs/crates/spacetime-client/src/**`
3. `server-rs/crates/api-server/src/**`
4. 前端 services/hooks/components
5. `server-rs/crates/spacetime-module/src/migration.rs`
## 设计
本次将以下函数迁入 `commands.rs`
1. settings、browse history、profile dashboard、wallet、recharge、referral、reward code、redeem code、play stats、runtime snapshot、save archive 的 `build_runtime_*_input`
2. `build_runtime_browse_history_sync_input``prepare_runtime_browse_history_entries``build_runtime_browse_history_id`
3. `normalize_invite_code``normalize_redeem_code`
4. 仅服务命令构造的私有 helper`normalize_runtime_*_user_id``parse_utc_rfc3339_to_micros``normalize_bottom_tab``normalize_current_story_json`
`lib.rs` 继续通过 `pub use commands::*` 暴露原公开函数名。记录投影 builder、充值商品目录、通用时间格式化和 JSON 读取 helper 暂留 `lib.rs`,后续再拆 `application.rs`
## 边界说明
1. 本次不改变任何输入构造的校验语义。
2. 本次不移动记录投影 builder避免命令层和应用读模型混写。
3. 本次不改 SpacetimeDB 表结构、reducer、procedure 或 API route。
4. 本次不触发 `migration.rs` 更新。
## 验收
```powershell
cargo fmt -p module-runtime --manifest-path server-rs/Cargo.toml --check
cargo test -p module-runtime --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_RT_COMMANDS_REFACTOR_2026-04-29.md server-rs/crates/module-runtime/src/commands.rs server-rs/crates/module-runtime/src/lib.rs server-rs/crates/module-runtime/README.md docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md
```

View File

@@ -0,0 +1,52 @@
# WP-RT Snapshot/Profile/Save Archive 领域快照与记录类型拆分落地说明
## 背景
`module-runtime/src/lib.rs` 仍集中承载 runtime snapshot、browse history、profile dashboard、wallet ledger、recharge、referral、played world、play stats 和 save archive 的大量快照、输入、过程结果与 BFF 记录类型。上一切片已将 runtime settings 值对象迁入 `domain.rs`,本次继续把这些纯数据事实迁入领域模型文件,降低根入口体积,并为后续 `commands.rs``application.rs` 和 SpacetimeDB adapter 接线拆分留出边界。
本次只移动纯类型和类型自带的字符串格式化方法不修改构造函数、归一化函数、测试、SpacetimeDB 表结构、API route 或前端。
## 本次范围
允许修改:
1. `server-rs/crates/module-runtime/src/domain.rs`
2. `server-rs/crates/module-runtime/src/lib.rs`
3. `server-rs/crates/module-runtime/README.md`
4. `docs/technical/README.md`
5. 全局 DDD 任务清单进度记录
禁止修改:
1. `server-rs/crates/spacetime-module/src/**`
2. `server-rs/crates/spacetime-client/src/**`
3. `server-rs/crates/api-server/src/**`
4. 前端 services/hooks/components
5. `server-rs/crates/spacetime-module/src/migration.rs`
## 设计
本次将以下类型迁入 `domain.rs`
1. runtime snapshot、runtime setting、browse history、profile dashboard、wallet ledger、recharge、reward code、redeem code、referral、played world、play stats、save archive 的 snapshot/input/procedure result。
2. `RuntimeProfileWalletLedgerSourceType``RuntimeProfileRedeemCodeMode``RuntimeProfileRechargeProductKind``RuntimeProfileMembershipStatus``RuntimeProfileMembershipTier``RuntimeProfileRechargeOrderStatus``RuntimeBrowseHistoryThemeMode` 等领域枚举及其 `as_str` / `from_client_str` 方法。
3. `RuntimeSettingsRecord``RuntimeProfileDashboardRecord``RuntimeProfileWalletLedgerEntryRecord``RuntimeProfilePlayedWorldRecord``RuntimeProfilePlayStatsRecord``RuntimeSnapshotRecord``RuntimeProfileSaveArchiveRecord` 等回包投影记录类型。
4. 与这些类型强绑定、但不携带构造逻辑的默认常量:`DEFAULT_BROWSE_HISTORY_AUTHOR_DISPLAY_NAME``MAX_BROWSE_HISTORY_BATCH_SIZE``PROFILE_WALLET_LEDGER_LIST_LIMIT``PROFILE_REFERRAL_REWARD_POINTS``PROFILE_REFERRAL_DAILY_INVITER_REWARD_LIMIT``SAVE_SNAPSHOT_VERSION``DEFAULT_SAVE_ARCHIVE_SUMMARY_TEXT``PROFILE_RECHARGE_PAYMENT_CHANNEL_MOCK`
`lib.rs` 继续通过 `pub use domain::*` 保持原公开 API。构造函数、归一化函数、充值商品目录函数、错误枚举和测试暂留 `lib.rs`,避免在同一切片里混入命令层与错误层重排。
## 边界说明
1. 这些类型包含条件 `SpacetimeType` 派生,但不是 SpacetimeDB table本次只移动自定义类型位置不修改 table/reducer/procedure。
2. 本次不移动 `RuntimeSettingsFieldError``RuntimeBrowseHistoryFieldError``RuntimeProfileFieldError`,后续可单独迁入 `errors.rs`
3. 本次不移动 `build_runtime_*` 构造函数,后续可按 settings、browse history、profile/save 三组拆入 `commands.rs` / `application.rs`
4. 本次不触发 `migration.rs` 更新。
## 验收
```powershell
cargo fmt -p module-runtime --manifest-path server-rs/Cargo.toml --check
cargo test -p module-runtime --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_RT_DOMAIN_SNAPSHOT_RECORD_REFACTOR_2026-04-29.md server-rs/crates/module-runtime/src/domain.rs server-rs/crates/module-runtime/src/lib.rs server-rs/crates/module-runtime/README.md docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md
```

View File

@@ -0,0 +1,48 @@
# WP-RT 错误层拆分落地说明
## 背景
`module-runtime` 已将 runtime settings 值对象,以及 snapshot/profile/save archive 的快照、输入、过程结果和记录投影类型迁入 `domain.rs`。根入口 `lib.rs` 仍承载 `RuntimeSettingsFieldError``RuntimeBrowseHistoryFieldError``RuntimeProfileFieldError` 及其中文错误文案,后续继续拆 `commands.rs``application.rs` 前,需要先把错误语义归位到 `errors.rs`
## 本次范围
允许修改:
1. `server-rs/crates/module-runtime/src/errors.rs`
2. `server-rs/crates/module-runtime/src/lib.rs`
3. `server-rs/crates/module-runtime/README.md`
4. `docs/technical/README.md`
5. 全局 DDD 任务清单进度记录
禁止修改:
1. `server-rs/crates/spacetime-module/src/**`
2. `server-rs/crates/spacetime-client/src/**`
3. `server-rs/crates/api-server/src/**`
4. 前端 services/hooks/components
5. `server-rs/crates/spacetime-module/src/migration.rs`
## 设计
本次将以下错误类型迁入 `errors.rs`
1. `RuntimeSettingsFieldError`
2. `RuntimeBrowseHistoryFieldError`
3. `RuntimeProfileFieldError`
同步迁移三组 `Display` 实现,保持中文错误文案和 `MAX_BROWSE_HISTORY_BATCH_SIZE` 上限提示不变。`lib.rs` 继续通过 `pub use errors::*` 暴露原公开 API调用点无需修改。
## 边界说明
1. 本次不调整错误枚举变体,不改任何业务校验语义。
2. 本次不移动 `build_runtime_*` 构造函数;这些函数仍在 `lib.rs` 使用错误类型。
3. 本次不改 SpacetimeDB 表结构、reducer、procedure 或 API route。
## 验收
```powershell
cargo fmt -p module-runtime --manifest-path server-rs/Cargo.toml --check
cargo test -p module-runtime --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_RT_ERROR_LAYER_REFACTOR_2026-04-29.md server-rs/crates/module-runtime/src/errors.rs server-rs/crates/module-runtime/src/lib.rs server-rs/crates/module-runtime/README.md docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md
```

View File

@@ -0,0 +1,52 @@
# WP-RT Runtime Settings 领域值对象拆分落地说明
## 背景
`module-runtime` 已承接运行时设置、快照、浏览历史、资料页、钱包、充值、邀请、兑换码、游玩记录和存档等纯规则,但当前大量类型仍集中在 `src/lib.rs``WP-RT Runtime/Profile/Save` 需要逐步把纯领域事实和写入命令拆入 DDD 分层文件,避免后续 `spacetime-module``api-server` 接线时继续依赖巨型根文件。
本次只启动 `runtime settings` 这一条最小切片,不改 SpacetimeDB 表结构、不改 HTTP route、不改前端。
## 本次范围
允许修改:
1. `server-rs/crates/module-runtime/src/domain.rs`
2. `server-rs/crates/module-runtime/src/lib.rs`
3. `server-rs/crates/module-runtime/README.md`
4. 本文档
5. 全局 DDD 任务清单进度记录
禁止修改:
1. `server-rs/crates/spacetime-module/src/**`
2. `server-rs/crates/spacetime-client/src/**`
3. `server-rs/crates/api-server/src/**`
4. 前端 services/hooks/components
## 设计
本次将以下运行时设置领域对象迁入 `domain.rs`
1. `DEFAULT_MUSIC_VOLUME`
2. `DEFAULT_PLATFORM_THEME`
3. `RuntimePlatformTheme`
4. `RuntimeSettings`
`RuntimePlatformTheme::as_str``RuntimePlatformTheme::from_client_str``RuntimeSettings::defaults``RuntimeSettings::normalized` 同步迁入 `domain.rs``lib.rs` 继续通过 `pub use domain::*` 暴露原有 API保证 `spacetime-module``spacetime-client` 和既有测试无需改调用点。
## 边界说明
1. 本次不移动 `RuntimeSettingSnapshot``RuntimeSettingGetInput``RuntimeSettingUpsertInput` 和 procedure result因为它们仍与 SpacetimeDB procedure DTO 强绑定,后续可作为 `commands.rs` / Adapter mapper 切片单独拆分。
2. 本次不移动 `RuntimeSettingsFieldError`,避免把错误 Display 与多个 profile 错误枚举混在同一切片里改动。
3. 本次不移动浏览历史、钱包、充值、邀请、兑换码、游玩记录和存档类型。
## 验收
```powershell
cargo test -p module-runtime --manifest-path server-rs/Cargo.toml
cargo fmt -p module-runtime --manifest-path server-rs/Cargo.toml --check
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_RT_RUNTIME_SETTINGS_DOMAIN_REFACTOR_2026-04-29.md server-rs/crates/module-runtime/src/domain.rs server-rs/crates/module-runtime/src/lib.rs server-rs/crates/module-runtime/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md
```
本次不改后端运行接线、不改 SpacetimeDB table/reducer/procedure因此不触发 `migration.rs` 更新。

View File

@@ -77,3 +77,45 @@ npm.cmd run api-server:maincloud
```
说明:本次不改 SpacetimeDB 表、reducer、procedure不刷新生成绑定不同步 `migration.rs`
## 8. story runtime inventory source 接线切片
### 8.1 目标
本轮继续在 `WP-SC` 内认领一个可并行切片:在 `SpacetimeClient::get_story_runtime_projection_source` 中复用已稳定的 `get_runtime_inventory_state` typed facade将 SpacetimeDB 背包/装备快照折回投影所需的 `game_state.playerInventory``game_state.playerEquipment`
目标是让 `/api/story/sessions/{story_session_id}/runtime-projection` 的读取投影优先消费新的 inventory adapter 结果,而不是只依赖 runtime snapshot 中的历史 JSON 背包副本。
### 8.2 边界
本轮允许修改:
1. `server-rs/crates/spacetime-client/src/story_runtime.rs`
2. 本文档
3. `docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md`
本轮禁止修改:
1. `server-rs/crates/spacetime-module/src/**`
2. `server-rs/crates/spacetime-client/src/module_bindings/**`
3. `server-rs/crates/api-server/src/app.rs`
4. HTTP DTO、前端 services/hooks/components
5. `migration.rs`
### 8.3 实现约束
1. 只在 `spacetime-client` 中组合已存在 facade不新增 table、reducer、procedure。
2. `StoryRuntimeProjectionSource` 的输出结构保持不变,投影规则继续由 `module-runtime-story::build_story_runtime_projection` 承接。
3. inventory slot 到 runtime story JSON 的转换只做字段映射,不新增玩法规则。
4. `get_runtime_inventory_state` 若返回作用域不匹配,必须中止投影,避免把其他会话的背包装进当前 story session。
### 8.4 验收
```powershell
cargo test -p spacetime-client story_runtime --manifest-path server-rs/Cargo.toml
cargo check -p spacetime-client --manifest-path server-rs/Cargo.toml
cargo fmt -p spacetime-client --manifest-path server-rs/Cargo.toml --check
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_SC_SPACETIME_CLIENT_REFACTOR_2026-04-29.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md server-rs/crates/spacetime-client/src/story_runtime.rs
npm.cmd run api-server:maincloud
```

View File

@@ -0,0 +1,56 @@
# WP-ST Auth Adapter 目录化切片说明
## 背景
`spacetime-module/src/auth.rs` 同时承接认证表定义、procedure 入口、事务内导入导出逻辑和 module-auth 快照 JSON mapper。随着 `WP-A Auth` 已完成 DDD 骨架归位SpacetimeDB 侧也需要把 Auth adapter 从单文件拆到上下文目录,避免后续继续堆回根文件。
本次属于 `WP-ST SpacetimeDB Adapter` 的可并行切片,只做 Auth adapter 目录化,不改变 SpacetimeDB schema、procedure 名称、procedure 入参/出参或绑定形状。
## 本次范围
允许修改:
1. `server-rs/crates/spacetime-module/src/auth.rs`
2. `server-rs/crates/spacetime-module/src/auth/mod.rs`
3. `server-rs/crates/spacetime-module/src/auth/tables.rs`
4. `server-rs/crates/spacetime-module/src/auth/procedures.rs`
5. `server-rs/crates/spacetime-module/src/auth/mapper.rs`
6. 本文档
7. `docs/technical/README.md`
8. `docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md`
禁止修改:
1. `spacetime-module/src/lib.rs`
2. `spacetime-module/src/migration.rs`
3. `docs/technical/SPACETIMEDB_TABLE_CATALOG.md`
4. `spacetime-client/src/module_bindings/**`
5. `api-server/src/**`
6. 前端 services / hooks / components
## 设计
本次将原 `auth.rs` 拆成:
1. `auth/mod.rs`Auth adapter 子模块入口,继续 `pub use procedures::*``pub use tables::*`,保持根模块 `pub use auth::*` 的对外导出不变。
2. `auth/tables.rs`:保留 `AuthStoreSnapshot``UserAccount``AuthIdentity``RefreshSession` 四张表定义和索引不改字段、可见性、accessor 或索引名。
3. `auth/procedures.rs`:保留 `get_auth_store_snapshot``upsert_auth_store_snapshot``import_auth_store_snapshot``export_auth_store_snapshot_from_tables` 四个 procedure 入口,以及对应事务内读写逻辑。
4. `auth/mapper.rs`:收口 module-auth 持久化快照 JSON 结构、refresh session client info JSON 结构和 identity id 组件清理函数,仅供 Auth procedure 内部使用。
## 边界说明
1. 本次未新增 reducer现有 Auth 同步仍通过 procedure 完成。
2. 本次未改变表结构,不需要修改 `migration.rs`
3. 本次未生成 SpacetimeDB 绑定,原因是导出的表、类型和 procedure 名称未改变。
4. Auth adapter 仍只负责认证快照与正式表的导入导出,不承接短信、微信 OAuth、JWT、cookie、HTTP 或文件持久化。
## 验收
```powershell
cargo fmt -p spacetime-module --manifest-path server-rs/Cargo.toml --check
cargo check -p spacetime-module --manifest-path server-rs/Cargo.toml
npm.cmd run check:server-rs-ddd
npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_WP_ST_AUTH_ADAPTER_SPLIT_2026-04-29.md docs/technical/README.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md server-rs/crates/spacetime-module/src/auth/mod.rs server-rs/crates/spacetime-module/src/auth/tables.rs server-rs/crates/spacetime-module/src/auth/procedures.rs server-rs/crates/spacetime-module/src/auth/mapper.rs
```
`cargo check -p spacetime-module` 被非 WP-ST 依赖 crate 当前并行改动阻断,应记录具体阻断 crate 和错误位置;本切片不越界修改其他已认领工作包。

View File

@@ -0,0 +1,30 @@
# WP-ST Custom World 根入口瘦身落地说明
## 背景
`spacetime-module/src/lib.rs` 已完成 gameplay 根入口瘦身,但仍直接承载 Custom World 的 SpacetimeDB 表、reducer、procedure 与私有事务 helper。根入口继续膨胀会让后续 `module-custom-world` 领域化、绑定生成检查和并行任务边界都难以维护。
本次迁移按 WP-ST Adapter 边界执行:根入口只负责声明模块与 re-exportCustom World 的 SpacetimeDB adapter 真正落到 `spacetime-module/src/custom_world/mod.rs`
## 落地范围
1. `lib.rs` 新增 `mod custom_world;``pub use custom_world::*;`,保留根模块对绑定生成需要的公开导出。
2. 将当前 `lib.rs` 已公开的 Custom World 表、procedure、reducer、事务 helper 与单测整体迁移到 `custom_world/mod.rs`
3. `custom_world/mod.rs``use crate::*;` 复用根模块已经公开的领域类型、SpacetimeDB 类型和 JSON helper避免复制跨模块前置导入。
4. 移除 `lib.rs` 中 Custom World 的重复实现,让根入口只承担组合职责。
## 边界
1. 不新增、删除或重命名 Custom World 表。
2. 不新增、删除或重命名当前已公开的 reducer / procedure。
3. 不修改 `CustomWorldProfile``CustomWorldGalleryEntry` 等表字段,本次不触发 `migration.rs` 更新。
4. 不启用 `custom_world` 子目录中尚未成为根入口正式导出的新过程,避免把后续行为变更混入本次根入口迁移。
5. 不修改前端、BFF、`server-node` 或 PostgreSQL 兼容逻辑。
## 验收
1. `cargo check -p spacetime-module --manifest-path server-rs/Cargo.toml`
2. `cargo test -p module-custom-world --manifest-path server-rs/Cargo.toml`
3. `npm.cmd run check:server-rs-ddd`
4. `npm.cmd run check:encoding -- docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md docs/technical/SERVER_RS_DDD_WP_ST_CUSTOM_WORLD_ROOT_SPLIT_2026-04-29.md server-rs/crates/spacetime-module/src/lib.rs server-rs/crates/spacetime-module/src/custom_world/mod.rs`
5. 修改后端 Rust 代码后,按项目约束运行 `npm.cmd run api-server:maincloud` 并探测 `/healthz`

View File

@@ -0,0 +1,31 @@
# WP-ST Gameplay 根入口瘦身落地说明
## 背景
`spacetime-module/src/gameplay/mod.rs` 已经承接 RPG gameplay 的 SpacetimeDB table、reducer、procedure、row mapper 和事务 helper但根入口 `spacetime-module/src/lib.rs` 仍保留同一批 gameplay 代码,导致根文件继续承担 Custom World 与 RPG gameplay 两条大链路。
本次切片属于 `WP-ST SpacetimeDB Adapter`目标是让根入口只做模块声明、re-export 和仍未拆出的 Custom World adapter不改变 SpacetimeDB schema、reducer/procedure 对外名称或业务规则。
## 落地范围
1.`spacetime-module/src/lib.rs` 接入 `mod gameplay; pub use gameplay::*;`
2. 将根入口中已迁入 `gameplay/mod.rs` 的 RPG gameplay table、reducer、procedure、row mapper 和事务 helper 删除。
3.`gameplay/mod.rs` 补齐模块内依赖导入。
4. 补齐 story session 继续推进与读取所需的内部 helper
- `continue_story_tx`
- `get_story_session_state_tx`
5. 保留根入口中的 Custom World table、procedure、reducer 和测试,本次不拆 Custom World。
## 边界
1. 本次不修改 `migration.rs`因为表名、字段、reducer/procedure 名称没有变化。
2. 本次不修改 `SPACETIMEDB_TABLE_CATALOG.md`,因为表目录没有变化。
3. 本次不修改 `api-server``spacetime-client`、前端 services/hooks/components。
4. 本次只移动 adapter 归属,不把业务规则从 `module-*` 拉回 SpacetimeDB adapter。
## 验收
1. `cargo check -p spacetime-module --manifest-path server-rs/Cargo.toml`
2. `npm.cmd run check:server-rs-ddd`
3. `npm.cmd run check:encoding -- server-rs/crates/spacetime-module/src/lib.rs server-rs/crates/spacetime-module/src/gameplay/mod.rs docs/technical/SERVER_RS_DDD_WP_ST_GAMEPLAY_ROOT_SPLIT_2026-04-29.md docs/technical/SERVER_RS_DDD_PARALLEL_TASKLIST_2026-04-29.md`
4. 如需联调发布,再执行当前 CLI 支持的 `spacetime build -p server-rs/crates/spacetime-module`

View File

@@ -458,7 +458,7 @@ SELECT * FROM puzzle_leaderboard_entry WHERE user_id = '<user_id>' AND profile_i
### `big_fish_creation_session`
- 作用:大鱼吃小鱼创作会话表,保存种子、阶段、锚点包、草稿、资产覆盖和发布就绪状态。
- 结构:`session_id PK: String`, `owner_user_id: String`, `seed_text: String`, `current_turn: u32`, `progress_percent: u32`, `stage: BigFishCreationStage`, `anchor_pack_json: String`, `draft_json: Option<String>`, `asset_coverage_json: String`, `last_assistant_reply: Option<String>`, `publish_ready: bool`, `created_at: Timestamp`, `updated_at: Timestamp`
- 结构:`session_id PK: String`, `owner_user_id: String`, `seed_text: String`, `current_turn: u32`, `progress_percent: u32`, `stage: BigFishCreationStage`, `anchor_pack_json: String`, `draft_json: Option<String>`, `asset_coverage_json: String`, `last_assistant_reply: Option<String>`, `publish_ready: bool`, `play_count: u32`, `created_at: Timestamp`, `updated_at: Timestamp`
- 索引:`owner_user_id`
```sql