import test from "node:test"; import assert from "node:assert/strict"; import { manifestIncompatibility, normalizeMoveScript, scriptCommandAt, loadCustomPolicy, } from "../src/game/custom-policy.js"; test("legacy community move validation takes dimensions from the active Package", () => { const dimensions = { obsSize: 63, actionSize: 18 }; assert.equal( manifestIncompatibility({ obs_len: 63, action_len: 18 }, dimensions), null, ); assert.match( manifestIncompatibility({ obs_len: 61 }, dimensions), /provides 63/, ); assert.match( manifestIncompatibility({ action_len: 14 }, dimensions), /drives 18/, ); }); test("command scripts use supplied vector length, not the old global 13", () => { const script = normalizeMoveScript( { keyframes: [ { t: 0, cmd: [0, 0, 0] }, { t: 1, cmd: [2, 4, 6] }, ], }, 3, ), out = new Float32Array(3); scriptCommandAt(script, 0.5, out); assert.deepEqual(Array.from(out), [1, 2, 3]); assert.throws( () => normalizeMoveScript({ keyframes: [{ t: 0 }] }, undefined), /size required/, ); }); test("loading without a Robot Package contract fails before network access", async () => { await assert.rejects(loadCustomPolicy("ignored"), /Package dimensions/); });