Merge remote-tracking branch 'upstream/main' into unbuilt-pops

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
Christopher Hawker 2026-11-05 18:27:21 +11:00
commit 5259e93034
24 changed files with 859 additions and 19 deletions

View file

@ -154,8 +154,15 @@
return r + '\n' + fl + '\n' + pf;
};
const parts = () => { const o = {}; if (!R) return o; for (const k of Object.keys(R)) o[k] = JSON.stringify(R[k]); o.fl = R.fl ? JSON.stringify(R.fl) : ''; return o; };
const sDigest = () => JSON.stringify(S);
const sParts = () => { const o = {}; for (const k of Object.keys(S)) o[k] = JSON.stringify(S[k]); return o; };
// A field only this checkout's game has (a new feature's state, on S or on its customers and offers) cannot match main
// yet: the driver passes those (drop) and they are left out; every field both games have must still match.
const sKeys = () => ({ top: Object.keys(S), items: [...new Set([...(S.biz || []), ...(S.offers || [])].flatMap((x) => Object.keys(x)))] });
const sDrop = (drop) => { if (!drop || (!drop.top.length && !drop.items.length)) return S; const o = {};
for (const k of Object.keys(S)) if (!drop.top.includes(k)) o[k] = S[k];
for (const k of ['biz', 'offers']) if (Array.isArray(o[k])) o[k] = o[k].map((x) => { const y = {}; for (const f of Object.keys(x)) if (!drop.items.includes(f)) y[f] = x[f]; return y; });
return o; };
const sDigest = (drop) => JSON.stringify(sDrop(drop));
const sParts = (drop) => { const s = sDrop(drop), o = {}; for (const k of Object.keys(s)) o[k] = JSON.stringify(s[k]); return o; };
/* After a move: what the move routed (a), routing again from the same state (b: on this checkout's page the kept
tables are used), and routing from that state with the cache off (c: RC.on=false where there is an RC). b and c
route from the same previous R; c's R is kept, as a plain compute would. */
@ -170,5 +177,5 @@
if (keep) UI.rkR = R;
return { a, b, c };
};
window.__fz = { direct, lists, start, state, screen, press, close, poke, day, routing, parts, sDigest, sParts, check, errs, modalOpen };
window.__fz = { direct, lists, start, state, screen, press, close, poke, day, routing, parts, sKeys, sDigest, sParts, check, errs, modalOpen };
})();

View file

@ -78,8 +78,10 @@ function playGame(pages, seed, opts = {}) {
const [x, y] = both('check');
for (const k of ['a', 'b', 'c']) if (x[k] !== y[k]) { fail(where + ': routing (' + k + ') base vs head', { diff: firstDiff(base.call('parts'), head.call('parts')) }); return false; }
if (y.b !== y.c) { fail(where + ': head cached vs uncached', { diff: 'R from the kept tables differs from a fresh route' }); return false; }
const [s1, s2] = both('sDigest');
if (s1 !== s2) { fail(where + ': game state S', { diff: firstDiff(base.call('sParts'), head.call('sParts')) }); return false; }
// Fields only this checkout's game has are left out on both sides (see sKeys in fuzz-page.js).
const [k1, k2] = both('sKeys'), drop = { top: k2.top.filter((k) => !k1.top.includes(k)), items: k2.items.filter((k) => !k1.items.includes(k)) };
const [s1, s2] = both('sDigest', drop);
if (s1 !== s2) { fail(where + ': game state S', { diff: firstDiff(base.call('sParts', drop), head.call('sParts', drop)) }); return false; }
return true;
};