chore: remove treasure from runtime story compat contract

This commit is contained in:
2026-04-22 18:40:39 +08:00
parent 6e4c941601
commit 6700e99dc8
4 changed files with 124 additions and 46 deletions

View File

@@ -185,7 +185,7 @@
### 4.2.2 `actions/resolve` 首版策略
当前 Rust compat handler 已按“确定性兼容动作 + snapshot 回写”落地,目标是先覆盖前端实际点击主链,而不是一步到位复刻 Node 全部 story domain。
当前 Rust compat handler 已按“确定性兼容动作 + snapshot 回写 + 最小动作后 LLM 文本增强”落地,目标是先覆盖前端实际点击主链,而不是一步到位复刻 Node 全部 story domain。
当前已覆盖动作:
@@ -213,9 +213,14 @@
22. `battle_guard_break`
23. `battle_probe_pressure`
24. `battle_recover_breath`
25. `treasure_secure`
26. `treasure_inspect`
27. `treasure_leave`
25. `inventory_use`
26. `equipment_equip`
27. `equipment_unequip`
28. `forge_craft`
29. `forge_dismantle`
30. `forge_reforge`
31. `npc_trade`
32. `npc_gift`
统一规则:
@@ -224,6 +229,7 @@
3. `clientVersion``gameState.runtimeActionVersion` 不一致时返回 `409`
4. 动作成功后递增 `runtimeActionVersion`
5. 追加 `storyHistory`,并把新的 `currentStory` / `viewModel` / `presentation` / `patches` 回写到 snapshot
6. 若已配置 `platform-llm`,允许在动作规则结算完成后尝试生成增强版 `storyText / currentStory`;生成失败时自动回退确定性结果
当前已额外对齐的 Node 旧主链细节:
@@ -248,8 +254,36 @@
- quest 不再被直接从快照中移除,而是保留为 `status = turned_in`
- 当前最小奖励闭环已写回 `playerCurrency / playerInventory / playerProgression / npc affinity`
- `playerProgression` 当前仍走 compat 侧确定性经验累计,不等价于最终 SpacetimeDB 真相成长链
6. combat compat
- battle 状态查询已补 `inventory_use` 与多条 `battle_use_skill` 选项编译
- 技能选项会继续输出 `runtimePayload.skillId``disabled``reason`
- 战斗物品会继续输出 `runtimePayload.itemId`
- `battle_use_skill` 已补 `playerSkillCooldowns``activeBuildBuffs` 写回
- `inventory_use` 已补 `playerInventory` 扣减、`itemsUsed`、冷却缩减与 `activeBuildBuffs` 写回
- hostile 战斗胜利后已补 `runtimeStats.hostileNpcsDefeated += 1`
- hostile 战斗胜利后已补 `playerProgression.totalXp / level / xpToNextLevel / lastGrantedSource = hostile_npc`
7. Task6 inventory / NPC inventory compat
- `equipment_equip` 已补最小装备换装、`playerEquipment` 写回、`playerInventory` 扣减、`playerMaxHp / playerMaxMana` 回算与 Build toast
- `equipment_unequip` 已补槽位归一化、卸装回包、`playerEquipment` 置空、`playerInventory` 回收与 Build toast 回算
- `forge_craft / forge_dismantle / forge_reforge` 已补最小工坊主链:材料消耗、产物生成、货币扣减、重铸属性提升与结果文本
- `npc_trade` 已补买入 / 卖出结算所需的 `playerCurrency``playerInventory``npcStates.*.inventory` 写回
- `npc_gift` 已补 `playerInventory` 扣减、NPC 背包收礼、`affinity``giftsGiven``npc_affinity_changed` patch
- NPC 交互态 fallback option compiler 已按 Node 旧顺序补 `npc_trade / npc_gift / npc_quest_* / npc_recruit / npc_leave`
- 已补 compat bridge 入口级 NPC state bootstrap`npcStates` 为空且遭遇为纯商贩型 NPC 时,`state/get``actions/resolve` 会自动初始化 `relationState / stanceProfile / tradeStockSignature / inventory`
8. 动作后 LLM 文本增强
- `npc_chat / story_opening_camp_dialogue` 已在 Rust 侧补最小 `generate_action_story_payload(...)` 分支
-`platform-llm` 可用时,会尝试生成中文 NPC 对话文本,并把 `currentStory` 保存为 `displayMode = dialogue`
- 该对话态当前保持与 Node 旧结构一致:`options` 只保留“继续推进冒险”,真实下一步入口先压到 `deferredOptions`
- `battle victory / spar_complete / escaped` 已支持生成结果叙事,但当前仍沿用既有 fallback options不提前迁移完整 orchestrator 选项重排
- 所有动作后 LLM 增强都只改写展示文本不改变已完成的数值结算、patch 与 snapshot 写回顺序
### 4.2.3 `initial` / `continue` 首版策略
### 4.2.3 当前明确移除的旧概念
`treasure_*` 旧 runtime story 遭遇动作已经从当前 Rust compat bridge 中移除,不再属于本阶段 M4 runtime story 主链覆盖范围。
当前保留的仅是 quest 目标语义里历史遗留的 `inspect_treasure` 字段口径,后续会在 quest / 叙事任务链单独收口,不在这份 compat bridge 文档里继续把 treasure 视作动作主循环。
### 4.2.4 `initial` / `continue` 首版策略
当前 Rust compat handler 已提供稳定 `RuntimeStoryAiResponse`
@@ -321,6 +355,18 @@
- `runtime_story_quest_offer_abandon_clears_pending_offer_and_restores_chat_options`
- `runtime_story_quest_accept_writes_quest_runtime_stats_and_followup_story`
- `runtime_story_quest_turn_in_marks_quest_rewards_and_affinity`
12. 继续补 Task6 inventory / NPC inventory compat 回归:
- `runtime_story_state_compiler_builds_active_npc_options_with_trade_gift_and_help_lock`
- `runtime_story_equipment_equip_updates_loadout_and_build_toast`
- `runtime_story_equipment_unequip_returns_item_to_inventory_and_resets_loadout`
- `runtime_story_forge_craft_consumes_materials_and_currency`
- `runtime_story_forge_dismantle_replaces_item_with_material_outputs`
- `runtime_story_forge_reforge_upgrades_item_and_consumes_cost`
- `runtime_story_npc_trade_buy_updates_currency_inventory_and_stock`
- `runtime_story_state_compiler_bootstraps_trade_inventory_for_role_npc`
- `runtime_story_npc_trade_buy_bootstraps_missing_npc_state`
- `runtime_story_npc_gift_updates_affinity_inventory_and_patch`
- `runtime_story_route_boundary_persists_equipment_equip_snapshot_updates`
---
@@ -356,7 +402,7 @@
- `POST /api/runtime/story/continue`
5. `cargo test -p shared-contracts` 通过
6. `cargo check -p api-server` 通过
7. `cargo test -p api-server runtime_story` 通过
7. `cargo test -p api-server runtime_story` 通过,当前 Rust `runtime_story` 兼容桥回归为 30 条
8. `node scripts/check-encoding.mjs` 通过
补充边界:
@@ -364,4 +410,4 @@
1. 当前测试里为 `runtime_snapshot` 加了 `#[cfg(test)]` 下的内存兜底,只用于在未启动本地 SpacetimeDB 时稳定验证 Rust route boundary。
2. 该测试兜底不进入生产链路,不改变真实 `runtime_save -> spacetime-client -> SpacetimeDB procedure` 的运行时实现。
达到以上条件后,兼容桥这一段已不再停留在 DTO / 空壳状态;下一轮重点转向“compat bridge 替换成真相态 reducer / projection”。
达到以上条件后,兼容桥这一段已不再停留在 DTO / 空壳状态;下一轮重点转向“继续迁移 Node 剩余编排分支,并最终用真相态 reducer / projection 替换 compat bridge”。