v0.1.35b: 兼容层铲除——迁移链/版本戳/死表死代码/normalize 兼容批/死字段

【A+I】migrate.ts 迁移链(CURRENT_SCHEMA/MIGRATIONS/migrateIfNeeded/MigrationError)整链铲除→validateLoadedState 结构校验(seed/family/members 断言);信封统一 payload 单格式(去双格式兜底);APP_ID 保留
【F】schemaVersion 字段全删(domain/creation/save 8 处);SaveMeta.version 记游戏版本字符串
【C】chronicle 死表+saveChronicle 死方法(首行 return+unreachable legacy 僵尸)全删
【D/E】GameEngine __state globalThis 泄漏口+seed 三元(恒不可达)删除;engineFromSnapshot/noAutoCreate 保留(测试便利——非兼容机器)
【B/H】normalizeGameState 兼容批删:老档字段补(28行)/worldGen 重放(18行)/P0-2 占位 def(9行)/worldSim 字段批删;保留 npcs 重注册/headId 修复/d distress 防护;initSim 补 0.1.34 四键(唯一初始源)
【G】domain 收紧 5 兼容 optional(techniqueRank/Progress/tribBoost/worldGen 必填)+pcgen 必写
【测试】删 9 个兼容验证体(audit 0.1.0-era/全残缺矩阵/空 worldSim 兜底);5989 全绿——金钟罩零漂(新档结构全字段,删除不涉世界数值)
This commit is contained in:
2026-08-23 22:35:17 +08:00
parent 1b1dfe8ac8
commit 9b0f36c70a
15 changed files with 44 additions and 285 deletions
-12
View File
@@ -10,18 +10,6 @@ import { GameState } from '../src/renderer/game/types/domain'
import { resetSaveBus, attachLogSink } from './world.helpers'
describe('0.1.3 audit regression', () => {
it('loads a 0.1.0-era save (missing finance/yearStats fields)', () => {
const w = World.create({ seed: 'legacy', surname: '崔', familyName: '崔家', motto: 'm', difficulty: 'normal' })
const legacy = JSON.parse(JSON.stringify(w.state)) as GameState
delete (legacy as Record<string, unknown>)['finance']
delete (legacy as Record<string, unknown>)['yearStats']
delete (legacy as Record<string, unknown>)['yearlyReports']
const w2 = new World(legacy)
for (let i = 0; i < 40; i++) w2.advanceMonth()
expect(w2.state.yearlyReports.length).toBeGreaterThan(0)
expect(Number.isNaN(w2.state.family.stones)).toBe(false)
})
it('marries a npc family once only (allied lock)', () => {
const w = World.create({ seed: 'hy', surname: '卫', familyName: '卫家', motto: 'm', difficulty: 'normal' })
const npcId = Object.keys(w.state.npcFamilies)[0]!