The web client now plays borealis (data/models.json), trained on the three-round match and taking the 501-dim match view rather than a bare round. Only the actor trunk is exported -- the critic exists to grade moves in training and never plays, so the graph physically cannot leak the opponent's hand or the deck, which beats promising not to call it. The TypeScript match layer and observation mirror match.py and match_obs.py. They have to agree to the bit: a mismatch throws nowhere, the ONNX policy just consumes a wrong vector and plays worse for reasons nobody can see. So the port is not trusted -- generate_match_parity_fixture.py emits 282 positions from real JAX play (mid-round, both seats, past a roll-over, with a live carry) and the TS output is checked against them to float32 round-off. Match mode is a menu toggle. A seed fixes all three deals and the coin flips, so a match stays a pure function of it. One-deal mode is unchanged from the player's side; borealis simply sees it as round one at a carry of zero, a position it has seen a great many times. Two bugs found by driving the built app in a browser, both silent: - The result card totalled the round, not the match. It read "-11 : 3" while the match stood at -96 : 66 -- it would have named the wrong winner. It now headlines the match total and breaks the round out beneath it. - Game records were being rejected. The client's schema went to v2 (it now records which model played; the old records stored the on-screen label, which stops identifying anything once there are two models) while serve_web_with_logs.py still only accepted v1, so every record would have 400'd into a console warning. v1 stays accepted -- the 111 existing games are altair. npm test and tsc were green through both. Hence web/.claude/skills/verify, which records the recipe and the selectors so the next session drives the app instead of re-deriving how. .gitignore excluded the new model, which would have shipped a 404: the deploy builds straight from the repo. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XBQKgvBbxbheiTF1AVy1Sh
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { matchFromOrders } from "./match";
|
|
import { matchFromSeed } from "./random";
|
|
import { parseSavedGame } from "./persistence";
|
|
|
|
const { deckOrders, coinFlips } = matchFromSeed("abc");
|
|
const match = matchFromOrders(deckOrders, coinFlips, 3);
|
|
|
|
function savedGame(overrides: Record<string, unknown> = {}) {
|
|
return {
|
|
version: 2,
|
|
seed: "abc",
|
|
mode: 3,
|
|
frames: [{ state: match, selection: { handSlot: null, placeType: null } }],
|
|
cursor: 0,
|
|
resultOpen: true,
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
describe("saved game parsing", () => {
|
|
it("accepts a complete saved timeline", () => {
|
|
const saved = savedGame();
|
|
expect(parseSavedGame(JSON.stringify(saved))).toEqual(saved);
|
|
});
|
|
|
|
it("accepts a one-deal game", () => {
|
|
const saved = savedGame({
|
|
mode: 1,
|
|
frames: [
|
|
{ state: matchFromOrders(deckOrders, coinFlips, 1), selection: { handSlot: null, placeType: null } },
|
|
],
|
|
});
|
|
expect(parseSavedGame(JSON.stringify(saved))).toEqual(saved);
|
|
});
|
|
|
|
it("rejects corrupt and incompatible data", () => {
|
|
expect(parseSavedGame("not json")).toBeNull();
|
|
expect(parseSavedGame(JSON.stringify({ version: 2 }))).toBeNull();
|
|
expect(parseSavedGame(JSON.stringify(savedGame({ frames: [] })))).toBeNull();
|
|
expect(parseSavedGame(JSON.stringify(savedGame({ mode: 2 })))).toBeNull();
|
|
});
|
|
|
|
it("refuses a v1 save rather than guessing what it meant", () => {
|
|
// A v1 save is one round: no carry, no deals for rounds two and three, no
|
|
// coin flips. There is nothing honest to migrate it into, so it is dropped
|
|
// and a fresh game is dealt.
|
|
const v1 = { version: 1, seed: "abc", frames: [{ state: match.round, selection: {} }], cursor: 0, resultOpen: true };
|
|
expect(parseSavedGame(JSON.stringify(v1))).toBeNull();
|
|
});
|
|
});
|