fix(07-07): #06-09-5 warn code 178 for unloaded save keys

- core.ts loadState: 差集方向改为 loaded.difference(total),178 = 存档出现但未加载的 key
- saveablesRoundTrip.test.ts:322-334 改写为「缺 key 不触发 178、仍触发 177」负向见证并更名
- saveablesRoundTrip.test.ts:337-349 取消 it.skip,承担「多出 key 触发 178」正向见证
This commit is contained in:
unanmed 2026-09-15 21:10:33 +08:00
parent 115d835b56
commit 95ea6609c6
2 changed files with 8 additions and 6 deletions

View File

@ -530,7 +530,7 @@ export class CoreState implements ICoreState {
}
const loaded = new Set<string>(state.keys());
const total = new Set(this.saveables.keys());
const remain = total.difference(loaded);
const remain = loaded.difference(total);
if (remain.size > 0) {
const ids = [...remain].join(' | ');
logger.warn(178, ids);

View File

@ -318,8 +318,8 @@ describe('CoreState save and load guards', () => {
expect(result.info.map(info => info.code)).toContain(177);
});
// 验证存档缺失 saveable key 时同时观测到警告码 178当前实现的实际触发路径
it('warns code 178 when the save data misses a saveable key', () => {
// 验证存档缺失 saveable key 时只触发警告码 177不再误报 178177/178 语义互斥
it('warns code 177 but not 178 when the save data misses a saveable key', () => {
const state = createCoreState();
const snapshot = new Map(
state.saveState(SaveCompression.NoCompression)
@ -330,11 +330,13 @@ describe('CoreState save and load guards', () => {
state.loadState(snapshot, SaveCompression.NoCompression)
);
expect(result.info.map(info => info.code)).toContain(178);
const codes = result.info.map(info => info.code);
expect(codes).toContain(177);
expect(codes).not.toContain(178);
});
// 疑似 bug码 178 的判定与文案相反,对「存档多出的 key」不告警详见 06-TEST-FINDINGS.md #06-09-5
it.skip('warns code 178 when the save data has keys that are not loaded', () => {
// 验证存档含未注册未加载key 时经 logger.catch 观测到警告码 178#06-09-5
it('warns code 178 when the save data has keys that are not loaded', () => {
const state = createCoreState();
const snapshot = new Map(
state.saveState(SaveCompression.NoCompression)