Files

66 lines
4.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# module-custom-world 独立模块 package 说明
日期:`2026-04-21`
## 1. package 职责
`module-custom-world` 是自定义世界与 agent 模块 package后续负责
1. `custom_world_profile``custom_world_session` 等世界状态模型
2. `custom_world_agent_session`、消息、操作、草稿卡等 agent 状态模型
3. 传统问答流、library、gallery、agent 会话的模块级编排
4.`apps/api-server` 的 custom world 兼容接口与 SSE 对接
5.`apps/spacetime-module` 的 custom world 表、reducer、view 聚合对接
## 2. 当前阶段说明
当前阶段已经不再是单纯目录占位,`custom world / agent` 类型契约、字段校验、发布编译规则和 Agent action 应用结果已经固定到 DDD 骨架中,避免 `spacetime-module` 在缺少领域边界的情况下直接堆表。
当前已落地:
1. 真实 `Cargo.toml` crate scaffold
2. `src/domain.rs` 承接基础枚举、进度常量、profile/session/card/gallery/publish gate 快照与结果类型。
3. `src/commands.rs` 承接 profile、library/gallery、Agent session/message/operation/action、published profile compile 和 publish world 输入 DTO。
4. `src/application.rs` 承接字段校验、默认 JSON、profile canonicalize、published profile compile 和 publish gate 相关纯规则。
5. `src/errors.rs` 承接 `CustomWorldFieldError` 与中文错误文案。
6. `src/events.rs` 承接 Custom World 领域事件与 payload struct。
7. `src/lib.rs` 只保留模块声明、公开导出和测试,继续保持 `module_custom_world::*` 公开 API。
8. `spacetime-module``generate_characters``generate_landmarks``generate_role_assets``sync_role_assets``generate_scene_assets``sync_scene_assets``expand_long_tail` 已移除最小兼容占位,改为确定性状态编排。
当前 crate 仍然只承接:
1. 共享枚举、进度常量与类型口径,基础枚举统一从 `src/domain.rs` 导出。
2. 字段校验、字符串归一化与发布编译纯规则。
3. published profile compile 与 publish world 的输入输出 contract。
4. 后续 `spacetime-module` 聚合表时需要复用的领域边界。
当前阶段明确不提前进入:
1. 旧问答流 reducer 编排
2. 外部 LLM 创作编排、图片生成、OSS 上传和 SSE 推送。
3. 资产对象真相表、资产绑定表和完整资产历史。
4. 前端创作流程和 UI 表现状态。
当前设计依据:
1. [../../../docs/technical/SERVER_RS_DDD_WP_CW_DOMAIN_ENUM_REHOME_2026-04-29.md](../../../docs/technical/SERVER_RS_DDD_WP_CW_DOMAIN_ENUM_REHOME_2026-04-29.md)
2. [../../../docs/technical/SERVER_RS_DDD_WP_CW_ACTION_AND_DOMAIN_SPLIT_2026-04-30.md](../../../docs/technical/SERVER_RS_DDD_WP_CW_ACTION_AND_DOMAIN_SPLIT_2026-04-30.md)
3. [../../../docs/technical/SPACETIMEDB_CUSTOM_WORLD_AGENT_STAGE1_TABLE_DESIGN_2026-04-21.md](../../../docs/technical/SPACETIMEDB_CUSTOM_WORLD_AGENT_STAGE1_TABLE_DESIGN_2026-04-21.md)
4. [../../../backend-rewrite-tasklist/04_M5_CUSTOM_WORLD_AND_AGENT.md](../../../backend-rewrite-tasklist/04_M5_CUSTOM_WORLD_AND_AGENT.md)
5. [../../../docs/technical/SPACETIMEDB_CUSTOM_WORLD_PUBLISHED_PROFILE_COMPILE_STAGE3_DESIGN_2026-04-21.md](../../../docs/technical/SPACETIMEDB_CUSTOM_WORLD_PUBLISHED_PROFILE_COMPILE_STAGE3_DESIGN_2026-04-21.md)
6. [../../../docs/technical/SPACETIMEDB_CUSTOM_WORLD_PUBLISH_WORLD_STAGE4_DESIGN_2026-04-21.md](../../../docs/technical/SPACETIMEDB_CUSTOM_WORLD_PUBLISH_WORLD_STAGE4_DESIGN_2026-04-21.md)
后续与本 package 直接相关的任务包括:
1. 设计 `custom_world_profile``custom_world_session`
2. 设计 `custom_world_agent_session`、消息、操作、卡片相关表
3. 对齐 traditional custom world、library、gallery、agent 兼容链路
4. 接入世界编译、场景图、封面图与角色资产的模块级编排
## 3. 边界约束
1. `module-custom-world` 负责世界状态真相、agent 状态与模块级编排,不把整个会话重新塞回单大 JSON 体。
2. 外部 LLM、图片生成、OSS 写入等副作用通过平台适配和应用层完成,状态最终回写到 `spacetime-module` 聚合的状态模型中。
3. 前端兼容 REST 与 SSE 由 `api-server` 暴露,但自定义世界主链状态不能再次分散到本地 session store 或前端临时状态中。
4. `custom_world_asset_link` 本轮不冻结,等待 `asset_object / asset_entity_binding / M6 assets` 的槽位规则稳定后再接。