Integrate unfinished server-rs refactor worklists
This commit is contained in:
@@ -1,4 +1,55 @@
|
||||
//! 剧情领域模型过渡落位。
|
||||
//! 剧情会话领域模型。
|
||||
//!
|
||||
//! 后续迁移 `StorySession`、`StoryEvent` 和剧情推进规则时,只保留剧情聚合内部变化;
|
||||
//! LLM 生成和 SpacetimeDB 写回由外层 adapter 处理。
|
||||
//! 这里仅保存 RPG story session 聚合内的稳定状态和值对象;LLM 生成、HTTP 回包和
|
||||
//! SpacetimeDB 写回都留给外层 adapter,不在领域模型里直接发生副作用。
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use shared_kernel::build_prefixed_seed_id;
|
||||
#[cfg(feature = "spacetime-types")]
|
||||
use spacetimedb::SpacetimeType;
|
||||
|
||||
/// 剧情会话 ID 的稳定前缀,统一放在领域层,避免 adapter 重复拼接。
|
||||
pub const STORY_SESSION_ID_PREFIX: &str = "storysess_";
|
||||
/// 新建剧情会话快照的初始版本号。
|
||||
pub const INITIAL_STORY_SESSION_VERSION: u32 = 1;
|
||||
|
||||
/// 剧情会话状态,用于判断后续 story command 是否还能继续推进。
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum StorySessionStatus {
|
||||
Active,
|
||||
Completed,
|
||||
Archived,
|
||||
}
|
||||
|
||||
impl StorySessionStatus {
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Active => "active",
|
||||
Self::Completed => "completed",
|
||||
Self::Archived => "archived",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// story session 的领域快照,SpacetimeDB row 与 HTTP DTO 都从它映射。
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct StorySessionSnapshot {
|
||||
pub story_session_id: String,
|
||||
pub runtime_session_id: String,
|
||||
pub actor_user_id: String,
|
||||
pub world_profile_id: String,
|
||||
pub initial_prompt: String,
|
||||
pub opening_summary: Option<String>,
|
||||
pub latest_narrative_text: String,
|
||||
pub latest_choice_function_id: Option<String>,
|
||||
pub status: StorySessionStatus,
|
||||
pub version: u32,
|
||||
pub created_at_micros: i64,
|
||||
pub updated_at_micros: i64,
|
||||
}
|
||||
|
||||
pub fn generate_story_session_id(seed_micros: i64) -> String {
|
||||
build_prefixed_seed_id(STORY_SESSION_ID_PREFIX, seed_micros)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user