From 7ac9ad6c0de313b9d167d23f2cd2d5124c865c07 Mon Sep 17 00:00:00 2001 From: Werner Stein Date: Wed, 18 Nov 2026 14:12:13 +0000 Subject: [PATCH 01/10] test(cube): run the size-loop tests over 2 to 15 Widen the loops that stopped at 2 to 7 (or 3, 5, 7 and 2, 4, 6 by parity) to every accepted size: random states, scramble validity, guided reassembly and routing, face orientation solving, notation round trips, shadow floor and display-frame conjugation. test/cubeSizes.ts holds the range once. Tests that take seconds at 9 to 15 get an explicit time limit; the display-frame test runs one case per size. Co-Authored-By: Claude Sonnet 5.5 --- test/axisColorFrame.test.ts | 13 ++--- test/captureFaceMapping.test.ts | 58 ++++++++++++----------- test/captureRecoveryPersistence.test.ts | 3 +- test/cube/cubeAssembly.test.ts | 7 +-- test/cube/cubeGeometry.test.ts | 7 ++- test/cube/guidedCapture.test.ts | 13 +++-- test/cube/notation/notationOutput.test.ts | 5 +- test/cubeShadow.test.ts | 3 +- test/cubeSizes.ts | 5 ++ test/guidedCaptureProduction.test.ts | 3 +- test/guidedLfrbud.test.ts | 5 +- test/randomState.test.ts | 7 +-- test/spatialOrientationWizard.test.ts | 3 +- 13 files changed, 78 insertions(+), 54 deletions(-) create mode 100644 test/cubeSizes.ts diff --git a/test/axisColorFrame.test.ts b/test/axisColorFrame.test.ts index a9c8bf47..74a017de 100644 --- a/test/axisColorFrame.test.ts +++ b/test/axisColorFrame.test.ts @@ -4,6 +4,7 @@ import { initialColorFrame, } from '../src/core/view/AxisGizmo.gen' import { createSolvedCube } from '../src/cube/cubeAssembly' +import { EVEN_SIZES, ODD_SIZES } from './cubeSizes' import { applyCubeLayerMove, generateScrambleMoves, @@ -19,14 +20,14 @@ const standardFrame = { } describe('axis color reference frame', () => { - it.each([2, 4, 6])('uses a logical frame for a mixed %i cube', (size) => { + it.each(EVEN_SIZES)('uses a logical frame for a mixed %i cube', (size) => { let cube = createSolvedCube(size) for (const face of ['U', 'R', 'F', 'D'] as const) cube = applyCubeLayerMove(cube, size, face, 1, 1, 1) expect(initialColorFrame(cube, size)).toEqual(standardFrame) }) - it.each([2, 4, 6])( + it.each(EVEN_SIZES)( 'keeps the %i cube frame through face, inner and wide turns', (size) => { let frame = initialColorFrame(createSolvedCube(size), size) @@ -39,7 +40,7 @@ describe('axis color reference frame', () => { }, ) - it.each([2, 4, 6])('rotates the %i cube frame with x, y and z', (size) => { + it.each(EVEN_SIZES)('rotates the %i cube frame with x, y and z', (size) => { const start = initialColorFrame(createSolvedCube(size), size) const x = advanceColorFrame(start, size, 'R', size, 1, size) const y = advanceColorFrame(start, size, 'U', size, 1, size) @@ -50,7 +51,7 @@ describe('axis color reference frame', () => { expect(advanceColorFrame(y, size, 'U', size, -1, size)).toEqual(start) }) - it.each([3, 5, 7])( + it.each(ODD_SIZES)( 'preserves the middle-slice reference change on a %i cube', (size) => { const start = initialColorFrame(createSolvedCube(size), size) @@ -74,7 +75,7 @@ describe('axis color reference frame', () => { expect(initialColorFrame(rotated, 3)).toMatchObject({ u: 'W', f: 'R' }) }) - it.each([3, 5, 7])( + it.each(ODD_SIZES)( 'tracks fixed centers through a sequence of %i cube turns', (size) => { let cube = createSolvedCube(size) @@ -110,7 +111,7 @@ describe('axis color reference frame', () => { }, ) - it.each([2, 4, 6])( + it.each(EVEN_SIZES)( 'restores the %i cube frame with inverse moves and ignores Scramble turns', (size) => { const initial = initialColorFrame(createSolvedCube(size), size) diff --git a/test/captureFaceMapping.test.ts b/test/captureFaceMapping.test.ts index 6120fc52..f2110bd7 100644 --- a/test/captureFaceMapping.test.ts +++ b/test/captureFaceMapping.test.ts @@ -10,6 +10,7 @@ import { validateMapping, } from '../src/client/capture/captureFaceMapping' import { rotateGrid, turnFace, type Faces } from '../src/cube/cubeGeometry' +import { ALL_SIZES, ODD_SIZES } from './cubeSizes' const ORDER = ['U', 'R', 'F', 'D', 'L', 'B'] as const const COLORS = ['W', 'R', 'G', 'Y', 'O', 'B'] @@ -24,7 +25,7 @@ const asymmetric = (n: number) => turnFace(turnFace(solved(n), 'R', 1), 'U', 1) // Source photos are capture slots, not the cube sides named by these keys. describe('manual captured-face mapping', () => { - for (const n of [3, 5, 7]) { + for (const n of ODD_SIZES) { it(`uses fixed centers and preserves every quarter turn on an odd ${n}x${n}`, () => { const faces = asymmetric(n) const raw = Object.fromEntries( @@ -281,35 +282,38 @@ describe('recorded 7x7 capture and persisted display transforms', () => { }) }) -it('conjugates every face direction and representative layer depth exactly through all display frames', () => { - const key = (faces: Faces) => - ORDER.map((face) => faces[face].flat().join('')).join('|') - for (const n of [2, 3, 4, 5, 6, 7, 8]) { - let original = asymmetric(n) - original = turnFace(turnFace(original, 'F', -1), 'L', 2) - const widths = [...new Set([1, Math.ceil(n / 2), n])] - for (const width of widths) { - for (const quarters of [1, -1, 2]) { - const legal = new Set( - ORDER.map((face) => key(turnFace(original, face, quarters, width))), - ) - for (let index = 0; index < 24; index++) { - const displayed = transformFaces(original, index)! - const inverse = inverseTransform(index)! - for (const face of ORDER) { - const displayedMove = turnFace(displayed, face, quarters, width) - const canonical = transformFaces(displayedMove, inverse)! - expect( - legal.has(key(canonical)), - `N=${n}, frame=${index}, ${face}/${quarters}/${width}`, - ).toBe(true) - expect(transformFaces(canonical, index)).toEqual(displayedMove) +for (const n of ALL_SIZES) + describe(`${n}x${n} display frames`, () => { + const key = (faces: Faces) => + ORDER.map((face) => faces[face].flat().join('')).join('|') + // One test per size: the work grows with the size (about 15 s at 15x15 on a + // busy machine), so each size gets its own time limit. + it('conjugates every face direction and representative layer depth exactly through all display frames', () => { + let original = asymmetric(n) + original = turnFace(turnFace(original, 'F', -1), 'L', 2) + const widths = [...new Set([1, Math.ceil(n / 2), n])] + for (const width of widths) { + for (const quarters of [1, -1, 2]) { + const legal = new Set( + ORDER.map((face) => key(turnFace(original, face, quarters, width))), + ) + for (let index = 0; index < 24; index++) { + const displayed = transformFaces(original, index)! + const inverse = inverseTransform(index)! + for (const face of ORDER) { + const displayedMove = turnFace(displayed, face, quarters, width) + const canonical = transformFaces(displayedMove, inverse)! + expect( + legal.has(key(canonical)), + `N=${n}, frame=${index}, ${face}/${quarters}/${width}`, + ).toBe(true) + expect(transformFaces(canonical, index)).toEqual(displayedMove) + } } } } - } - } -}, 30_000) + }, 60_000) + }) it('prefills the current nonidentity even candidate instead of falling back to zero rotations', () => { const candidateFaces = asymmetric(4) diff --git a/test/captureRecoveryPersistence.test.ts b/test/captureRecoveryPersistence.test.ts index 1a7f6136..c0fad11f 100644 --- a/test/captureRecoveryPersistence.test.ts +++ b/test/captureRecoveryPersistence.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from 'vitest' +import { ALL_SIZES } from './cubeSizes' import { captureFrame, validateMapping, @@ -60,7 +61,7 @@ const setup = (n: number) => { } describe('versioned exact face recovery', () => { - for (const n of [2, 3, 4, 5, 6, 7, 8]) + for (const n of ALL_SIZES) it(`retains explicit slots, all rotations and capture pose for ${n}x${n}`, () => { const { raw, faces, record } = setup(n) const before = JSON.stringify(raw) diff --git a/test/cube/cubeAssembly.test.ts b/test/cube/cubeAssembly.test.ts index 71168594..dc10ea2c 100644 --- a/test/cube/cubeAssembly.test.ts +++ b/test/cube/cubeAssembly.test.ts @@ -25,6 +25,7 @@ import { pickWizardFace, } from '../../src/cube/orientationWizard' import { runFullParity } from '../../src/cube/parity' +import { EVEN_SIZES, ODD_SIZES } from '../cubeSizes' const SOLVED_COLOR: Record = { U: 'W', @@ -94,7 +95,7 @@ function captureWithRotations( } describe('solveFaceOrientations', () => { - it.each([3, 5, 7])( + it.each(ODD_SIZES)( 'resolves a solved %ix%i cube with zero rotation and full validity', (size) => { const result = solveFaceOrientations(solvedFaces(size)) @@ -106,7 +107,7 @@ describe('solveFaceOrientations', () => { }, ) - it.each([3, 5, 7])( + it.each(ODD_SIZES)( 'recovers a real one-move scramble (%ix%i, U turn) at full validity', (size) => { const captured = captureWithRotations(uTurnedFaces(size), { @@ -273,7 +274,7 @@ describe('solveFaceOrientations', () => { }) describe('even sizes (no fixed center reference - identity searched jointly with rotation)', () => { - it.each([2, 4, 6])( + it.each(EVEN_SIZES)( 'resolves a solved %ix%i cube, shuffled and pre-rotated, to full validity', (size) => { // Even sizes have no center to key off, so - unlike the odd-size diff --git a/test/cube/cubeGeometry.test.ts b/test/cube/cubeGeometry.test.ts index 15e8aaa7..190af044 100644 --- a/test/cube/cubeGeometry.test.ts +++ b/test/cube/cubeGeometry.test.ts @@ -20,6 +20,7 @@ import { solveFaceOrientations, type FaceKey, } from '../../src/cube/cubeAssembly' +import { ALL_SIZES } from '../cubeSizes' const WCA: Record = { U: 'W', @@ -99,14 +100,16 @@ describe('rotateCube', () => { }) describe('scrambles read as valid cubes', () => { - for (const n of [2, 3, 4, 5, 6, 7]) { + for (const n of ALL_SIZES) { + // Even sizes search identity and rotation jointly: 1 to 3 s per size, so + // the default 5 s limit is too tight on a busy runner. it(`${n}x${n}`, () => { for (let seed = 1; seed <= 5; seed++) { const cube = scramble(n, 30, seed * 31 + n) const solved = solveFaceOrientations(cube)! expect(solved.fullyValid, `seed ${seed}`).toBe(true) } - }) + }, 60_000) } }) diff --git a/test/cube/guidedCapture.test.ts b/test/cube/guidedCapture.test.ts index 3d86d37f..6cbd69af 100644 --- a/test/cube/guidedCapture.test.ts +++ b/test/cube/guidedCapture.test.ts @@ -32,6 +32,7 @@ import { type GuidedCapture, } from '../../src/cube/cubeAssembly' import { preferredGuidedArrangementIndex } from '../../src/cube/orientationWizard' +import { ALL_SIZES, ODD_SIZES } from '../cubeSizes' const WCA: Record = { U: 'W', @@ -140,7 +141,7 @@ const sameCube = (a: Faces, b: Faces) => { } describe('solveGuidedCapture', () => { - for (const n of [2, 3, 4, 5, 6, 7]) { + for (const n of ALL_SIZES) { it(`reassembles scrambled ${n}x${n} cubes however they were held, turned and tipped`, () => { const rand = rng(1000 + n) for (let trial = 0; trial < 6; trial++) { @@ -159,7 +160,9 @@ describe('solveGuidedCapture', () => { `trial ${trial}`, ).toBe(true) } - }) + // 1 to 9 s per size on a busy machine (6 trials of the joint search); + // the default 5 s limit is too tight above 7x7. + }, 120_000) } it('presents odd sizes in standard orientation (white on top, green in front)', () => { @@ -252,7 +255,7 @@ describe('predictGuidedCenters', () => { const face = (n: number, color: string) => Array.from({ length: n }, () => Array(n).fill(color)) - for (const n of [3, 5, 7, 9, 11, 13, 15]) { + for (const n of ODD_SIZES) { it(`shows the opposite after one ${n}x${n} face, then all remaining centers after adjacent faces`, () => { const first = face(n, 'G'), second = face(n, 'R') @@ -284,7 +287,7 @@ describe('predictGuidedCenters', () => { }) } - for (const n of [3, 5, 7, 9, 11, 13, 15]) { + for (const n of ODD_SIZES) { it(`reserves center slots and routes faces by center on ${n}x${n}`, () => { const first = face(n, 'G'), second = face(n, 'R') @@ -360,7 +363,7 @@ describe('center-routed capture slots', () => { const face = (n: number, color: string) => Array.from({ length: n }, () => Array(n).fill(color)) - for (const n of [3, 5, 7]) { + for (const n of ODD_SIZES) { it(`keeps the first two ${n}x${n} photos and routes later faces regardless of arrival order`, () => { const photos: Array = Array(6).fill(undefined) expect(captureSlotForCenter(photos, 4, face(n, 'O'))).toBe(0) diff --git a/test/cube/notation/notationOutput.test.ts b/test/cube/notation/notationOutput.test.ts index 5a540582..b5cb4be9 100644 --- a/test/cube/notation/notationOutput.test.ts +++ b/test/cube/notation/notationOutput.test.ts @@ -22,6 +22,7 @@ import { wrgFaceletsToGrids, type cubeState as CubeState, } from '../../../src/cube/notation/NotationOutput.gen' +import { ALL_SIZES } from '../../cubeSizes' function solvedCube(size: number): CubeState { const face = (color: string) => Array(size * size).fill(color) @@ -87,7 +88,7 @@ describe('fromWRGFacelets', () => { }) it('round-trips toWRGFacelets output for every supported puzzle size', () => { - for (const size of [2, 3, 4, 5, 6, 7]) { + for (const size of ALL_SIZES) { const cube = solvedCube(size) expect(fromWRGFacelets(toWRGFacelets(cube))).toEqual(cube) } @@ -163,7 +164,7 @@ describe('fromURFFacelets', () => { }) it('round-trips toURFFacelets output for every supported puzzle size', () => { - for (const size of [2, 3, 4, 5, 6, 7]) { + for (const size of ALL_SIZES) { const cube = solvedCube(size) expect(fromURFFacelets(toURFFacelets(cube))).toEqual(cube) } diff --git a/test/cubeShadow.test.ts b/test/cubeShadow.test.ts index 36c9a430..a3650849 100644 --- a/test/cubeShadow.test.ts +++ b/test/cubeShadow.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from 'vitest' +import { ALL_SIZES } from './cubeSizes' import { SHADOW_OUTLINE_POINTS, paddedOutline, @@ -39,7 +40,7 @@ describe('cube shadow', () => { }) it('lies on a floor below the cube in every orientation', () => { - for (const n of [2, 3, 7]) { + for (const n of ALL_SIZES) { const radius = (n / 2) * Math.sqrt(3) expect(shadowFloorY(n)).toBeLessThan(-radius) } diff --git a/test/cubeSizes.ts b/test/cubeSizes.ts new file mode 100644 index 00000000..afa0d64d --- /dev/null +++ b/test/cubeSizes.ts @@ -0,0 +1,5 @@ +// The cube sizes the app accepts, 2 through 15, and their parities. Tests that +// loop over sizes import these so the range lives in one place. +export const ALL_SIZES = Array.from({ length: 14 }, (_, i) => i + 2) +export const ODD_SIZES = ALL_SIZES.filter((n) => n % 2 === 1) +export const EVEN_SIZES = ALL_SIZES.filter((n) => n % 2 === 0) diff --git a/test/guidedCaptureProduction.test.ts b/test/guidedCaptureProduction.test.ts index dded6e0a..a1fa419a 100644 --- a/test/guidedCaptureProduction.test.ts +++ b/test/guidedCaptureProduction.test.ts @@ -18,6 +18,7 @@ import { } from '../src/client/capture/guidedCaptureProtocol' import { generateForProtocol } from '../src/client/capture/spatialOrientationWizard' import type { FaceCaptureData } from '../src/client/capture/captureTypes' +import { ODD_SIZES } from './cubeSizes' // Historical v2 observations are explicit; the current camera now records v3. const recordV2Guide = (slot: string, mirrored: boolean, retake: boolean) => { const guide = recordCurrentGuide(slot, mirrored, retake) @@ -147,7 +148,7 @@ it('keeps legacy top-first imports and explicit retakes in their original slots' }) it('routes different initial physical holds without interpreting capture IDs as canonical faces', () => { - for (const size of [3, 5, 7]) { + for (const size of ODD_SIZES) { const solved = solvedCubeFaces(size, { U: 'W', R: 'R', diff --git a/test/guidedLfrbud.test.ts b/test/guidedLfrbud.test.ts index 6d43ad94..c1236f96 100644 --- a/test/guidedLfrbud.test.ts +++ b/test/guidedLfrbud.test.ts @@ -21,6 +21,7 @@ import { } from '../src/client/capture/guidedCaptureProtocol' import type { FaceCaptureData } from '../src/client/capture/captureTypes' import { generateForProtocol } from '../src/client/capture/spatialOrientationWizard' +import { ALL_SIZES, ODD_SIZES } from './cubeSizes' const protocol = 'left-front-right-back-up-down/v3' const mirroredProtocol = 'right-back-left-front-up-down/v3' const slots = ['U', 'R', 'F', 'D', 'L', 'B'] @@ -64,7 +65,7 @@ it('derives all six source photo orientations from the physical five transitions } } }) -for (const size of [2, 3, 4, 7]) +for (const size of ALL_SIZES) for (const mirror of [false, true]) it(`keeps the exact LFRBUD scanned state at size=${size}, mirror=${mirror}`, () => { let original = solvedCubeFaces(size, { @@ -99,7 +100,7 @@ for (const size of [2, 3, 4, 7]) expect(JSON.stringify(photos)).toBe(before) }) -for (const size of [3, 5, 7]) +for (const size of ODD_SIZES) for (const mirrored of [false, true]) it(`routes real LFRBUD source steps without center reassignment at size=${size}, mirror=${mirrored}`, () => { const original = turnFace( diff --git a/test/randomState.test.ts b/test/randomState.test.ts index f30264c5..7c872469 100644 --- a/test/randomState.test.ts +++ b/test/randomState.test.ts @@ -2,8 +2,9 @@ import { describe, expect, it } from 'vitest' import { parityStatus } from '../src/client/capture/captureFlow' import { createSolvedCube, type CubeState } from '../src/cube/cubeAssembly' import { randomCube } from '../src/cube/randomState' +import { ALL_SIZES, EVEN_SIZES, ODD_SIZES } from './cubeSizes' -const SIZES = [2, 3, 4, 5, 6, 7] +const SIZES = ALL_SIZES const FACES = ['u', 'r', 'f', 'd', 'l', 'b'] as const const SOLVED = { u: 'W', r: 'R', f: 'G', d: 'Y', l: 'O', b: 'B' } @@ -39,7 +40,7 @@ describe('a random cube state', () => { }) it('keeps the centers of an odd cube where they were', () => { - for (const n of [3, 5, 7]) + for (const n of ODD_SIZES) for (const seed of seeds(10)) { const cube = randomCube(n, seed) for (const face of FACES) @@ -51,7 +52,7 @@ describe('a random cube state', () => { it('keeps the down-back-left corner of an even cube where it was', () => { // The frame an even cube is turned in: nothing else pins it down. - for (const n of [2, 4, 6]) + for (const n of EVEN_SIZES) for (const seed of seeds(20)) { const cube = randomCube(n, seed) expect(cube.d[n * (n - 1)], `${n}x${n} D`).toBe('Y') diff --git a/test/spatialOrientationWizard.test.ts b/test/spatialOrientationWizard.test.ts index bd1b23f8..718ee354 100644 --- a/test/spatialOrientationWizard.test.ts +++ b/test/spatialOrientationWizard.test.ts @@ -2,6 +2,7 @@ import { readFileSync } from 'node:fs' import { unzipSync, strFromU8 } from 'fflate' import { readFixtureColors } from '../src/client/fixtures/fixtureFormat' import { describe, expect, it } from 'vitest' +import { ALL_SIZES } from './cubeSizes' import { generate, retainsMapping, @@ -87,7 +88,7 @@ it('distinguishes whole-face assignments even when their colored grids are ident const keys = ['U', 'R', 'F', 'D', 'L', 'B'] const colors = ['W', 'R', 'G', 'Y', 'O', 'B'] -for (const size of [2, 3, 4, 5, 6, 7, 8]) { +for (const size of ALL_SIZES) { it(`uses existing validation for guided ${size}×${size} candidates without changing sources`, () => { const raw = Object.fromEntries( keys.map((key, i) => [ From 2c9507e006c0601f9c9084e15ec910017aa564eb Mon Sep 17 00:00:00 2001 From: Werner Stein Date: Wed, 18 Nov 2026 14:14:33 +0000 Subject: [PATCH 02/10] test(view3d): cover sizes 8 to 15 in mesh, slice-turn and scramble tests Extend the junction, inner-slice and scramble-depth tests to 15x15 and add a size 2 to 15 block: index buffers (32-bit above 65535 vertices, 9x9 stickered and up), geometry growth, zoom and the exact column a slice turn moves. The scramble length table ends at 7x7 and falls back to 20 moves above it; an expected-failure test records that gap. Co-Authored-By: Claude Sonnet 5.5 --- test/cubeView3D.test.ts | 90 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 5 deletions(-) diff --git a/test/cubeView3D.test.ts b/test/cubeView3D.test.ts index 7a57df10..9ef6bd3d 100644 --- a/test/cubeView3D.test.ts +++ b/test/cubeView3D.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest' import { createSolvedCube } from '../src/cube/cubeAssembly' +import { ALL_SIZES } from './cubeSizes' import { applyCubeMove, applyCubeLayerMove, @@ -352,7 +353,7 @@ describe('cubeView3D math and geometry', () => { return best } - for (const n of [3, 7]) + for (const n of [3, 7, 8, 15]) for (const stickerless of [true, false]) it(`closes every junction of four cubies on a ${n}x${n} (${stickerless ? 'stickerless' : 'stickered'})`, () => { const mesh = buildCubeMesh( @@ -697,8 +698,8 @@ describe('cubeView3D math and geometry', () => { expect(applyCubeLayerMove(turned, 5, 'R', 3, -1)).toEqual(solved) }) - it('roundtrips every inner slice on 4x4 through 7x7 cubes', () => { - for (let size = 4; size <= 7; size++) { + it('roundtrips every inner slice on 4x4 through 15x15 cubes', () => { + for (const size of ALL_SIZES.filter((n) => n >= 4)) { const solved = createSolvedCube(size) for (let depth = 2; depth < size; depth++) { const turned = applyCubeLayerMove(solved, size, 'U', depth, 1) @@ -721,9 +722,9 @@ describe('cubeView3D math and geometry', () => { it('scales scramble length and layer depths to the cube size', () => { const lengths = [11, 20, 40, 60, 80, 100] - for (let size = 2; size <= 7; size++) { + for (const size of ALL_SIZES) { const moves = generateScrambleMoves(size) - expect(moves).toHaveLength(lengths[size - 2]) + if (size <= 7) expect(moves).toHaveLength(lengths[size - 2]) expect( moves.every( (move) => move.depth >= 1 && move.depth <= Math.floor(size / 2), @@ -738,6 +739,18 @@ describe('cubeView3D math and geometry', () => { } }) + // Known gap: the length table (CubeMoves.res scrambleLengths) ends at 7x7 + // and every larger size falls back to 20 moves, fewer than a 3x3 gets. The + // test turns red once the table or a formula covers 8 to 15, so this + // marker cannot go stale. The target lengths are an owner decision. + it.fails('scrambles a size above 7 at least as long as the 7x7', () => { + for (const size of ALL_SIZES.filter((n) => n > 7)) + expect( + generateScrambleMoves(size).length, + `${size}x${size}`, + ).toBeGreaterThanOrEqual(100) + }) + it('builds mesh with animated turning layer rotated properly without crashing', () => { const solved = createSolvedCube(3) const staticMesh = buildCubeMesh(solved, 3) @@ -852,3 +865,70 @@ describe('cubeView3D math and geometry', () => { }) }) }) + +describe('cubeView3D for every size from 2 to 15', () => { + const meshes = new Map>() + const meshOf = (size: number, stickerless: boolean) => { + const key = `${size}/${stickerless}` + let mesh = meshes.get(key) + if (!mesh) { + mesh = buildCubeMesh(createSolvedCube(size), size, undefined, stickerless) + meshes.set(key, mesh) + } + return mesh + } + + for (const size of ALL_SIZES) + for (const stickerless of [true, false]) + it(`builds a closed index buffer for ${size}x${size} (${stickerless ? 'stickerless' : 'stickered'})`, () => { + const mesh = meshOf(size, stickerless) + expect(mesh.vertexCount).toBeGreaterThan(0) + expect(mesh.indexCount).toBeGreaterThan(0) + expect(mesh.indexCount % 3).toBe(0) + let highest = 0 + for (const index of mesh.indices) highest = Math.max(highest, index) + expect(highest).toBeLessThan(mesh.vertexCount) + // 16-bit indices hold up to 65535 vertices; larger meshes (stickered + // 9x9 and up) need 32-bit indices, which the renderer draws as such. + expect(mesh.indices instanceof Uint32Array).toBe( + mesh.vertexCount > 65535, + ) + if (mesh.vertexCount > 65535) expect(highest).toBeGreaterThan(65535) + // One position, color and occlusion value per vertex. + expect(mesh.positions.length).toBe(mesh.vertexCount * 3) + expect(mesh.occlusion.length).toBe(mesh.vertexCount) + }) + + it('adds geometry with every size', () => { + for (const size of ALL_SIZES.slice(1)) + expect(meshOf(size, false).vertexCount).toBeGreaterThan( + meshOf(size - 1, false).vertexCount, + ) + }) + + it('zooms out as the cube grows and stays finite', () => { + let previous = 0 + for (const size of ALL_SIZES) { + const zoom = getDefaultZoom(size) + expect(Number.isFinite(zoom)).toBe(true) + expect(zoom).toBeGreaterThan(previous) + previous = zoom + } + }) + + it('turns exactly the chosen layer: one column of the top face takes the front color', () => { + for (const size of ALL_SIZES) { + const solved = createSolvedCube(size) + for (let depth = 1; depth < size; depth++) { + // A single R slice at `depth` moves the front stickers of that column + // up; the top face is white elsewhere. + const turned = applyCubeLayerMove(solved, size, 'R', depth, 1, 1) + const column = size - depth + for (let i = 0; i < size * size; i++) + expect(turned.u[i], `${size}x${size} depth ${depth} cell ${i}`).toBe( + i % size === column ? 'G' : 'W', + ) + } + } + }) +}) From 1168fff0586d5ac3bfee775655038822686997c1 Mon Sep 17 00:00:00 2001 From: Werner Stein Date: Wed, 18 Nov 2026 14:19:02 +0000 Subject: [PATCH 03/10] test(properties): run the cube property tests over sizes 2 to 15 The generators stopped at 7x7. Scrambles, move inverses, valid-state, facelet round trips, the odd-cube and wing parity checks and the zoom range now draw sizes up to 15. The zoom property also checks that an in-range zoom is kept. A new property round-trips an Orbit64 V2 token for every size; the V1 token property stays at 2 to 7, the sizes of that codec. Co-Authored-By: Claude Sonnet 5.5 --- test/properties/CubeProperties_test.res | 52 +++++++++++++++++++--- test/properties/GestureProperties_test.res | 6 ++- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/test/properties/CubeProperties_test.res b/test/properties/CubeProperties_test.res index 9d13d9ad..482440ec 100644 --- a/test/properties/CubeProperties_test.res +++ b/test/properties/CubeProperties_test.res @@ -27,12 +27,17 @@ let scramble = (n, moves) => apply(cube, n, move) ) -// A size, a scramble of it and one more move. -let scrambled = - Fc.integer({min: 2, max: 7})->Fc.chain(n => +// The sizes the app accepts. +let maxSize = 15 + +// A size up to `largest`, a scramble of it and one more move. +let scrambledTo = largest => + Fc.integer({min: 2, max: largest})->Fc.chain(n => Fc.tuple3(Fc.constant(n), Fc.array(moveOf(n), {minLength: 0, maxLength: 30}), moveOf(n)) ) +let scrambled = scrambledTo(maxSize) + let sameCube = (a: CubeState.cubeState, b: CubeState.cubeState) => a == b let valid = (cube, n) => Parity.runFullParity(CubeAssembly.toCubeIR(cube, n)).valid @@ -109,7 +114,7 @@ describe("notation round trips", () => { "an Orbit64 token decodes to the facelets it encodes", () => Fc.check( - scrambled, + scrambledTo(7), ((n, moves, _)) => { let facelets = NotationOutput.toURFFacelets(scramble(n, moves)) switch Orbit64Token.encodeState(facelets)->Null.toOption { @@ -123,6 +128,41 @@ describe("notation round trips", () => { ), 120000, ) + + // The V2 codec takes every size 2..15. A canonical read turns the cube to + // its reference, so the decoded facelets are the same cube, equal to the + // input where the scramble kept the reference (the fixed centers of an odd + // cube) and in the same token either way. + test( + "an Orbit64 V2 token decodes to the cube it encodes, for every size", + () => + Fc.check( + scrambled, + ((n, moves, _)) => { + let entry = + Orbit64V2.entries->Array.find(e => e.n == n && e.model == Color && e.pose == Canonical) + let facelets = NotationOutput.toURFFacelets(scramble(n, moves)) + switch entry { + | None => false + | Some(entry) => + switch Orbit64V2Facelets.encodeFacelets(entry.id, facelets) { + | Ok(token) => + String.length(token) == entry.length && + switch Orbit64V2Facelets.decodeFacelets(token) { + | Ok(decoded) => + decoded.entry.id == entry.id && + Orbit64V2Facelets.encodeFacelets(entry.id, decoded.facelets) == Ok(token) && + (mod(n, 2) == 0 || decoded.facelets == facelets) + | Error(_) => false + } + | Error(_) => false + } + } + }, + ~runs=60, + ), + 120000, + ) }) describe("parity invariants", () => { @@ -240,7 +280,7 @@ describe("parity invariants", () => { // several arrangements that fit. That is where both the filter and the // list of tied arrangements get tested. let oddScramble = - Fc.constantFrom([3, 5, 7])->Fc.chain(n => + Fc.constantFrom([3, 5, 7, 9, 11, 13, 15])->Fc.chain(n => Fc.tuple2(Fc.constant(n), Fc.array(moveOf(n), {minLength: 0, maxLength: 4})) ) @@ -366,7 +406,7 @@ describe("middle edges of odd cubes", () => { // A wing's two stickers swapped: a 4x4+ capture whose wing pairs still // count up, but with one wing reading as its mirror-image twin. let flippedWing = - Fc.integer({min: 4, max: 7}) + Fc.integer({min: 4, max: maxSize}) ->Fc.chain(n => Fc.tuple4( Fc.constant(n), diff --git a/test/properties/GestureProperties_test.res b/test/properties/GestureProperties_test.res index 76778056..f4745291 100644 --- a/test/properties/GestureProperties_test.res +++ b/test/properties/GestureProperties_test.res @@ -218,12 +218,14 @@ describe("zoom", () => { test( "always stays within the size's range", () => - Fc.check(Fc.tuple2(num(-100.0, 100.0), Fc.integer({min: 2, max: 7})), ((zoom, size)) => { + Fc.check(Fc.tuple2(num(-100.0, 100.0), Fc.integer({min: 2, max: 15})), ((zoom, size)) => { let s = Int.toFloat(size) let clamped = CubeGesture.clampZoom(zoom, s) clamped >= 2.0 +. s && clamped <= 8.0 +. s *. 3.0 && - CubeGesture.clampZoom(clamped, s) == clamped + CubeGesture.clampZoom(clamped, s) == clamped && + (// A zoom inside the range is kept as it is. + zoom < 2.0 +. s || zoom > 8.0 +. s *. 3.0 || clamped == zoom) }), 60000, ) From d6c9be80454342ddce34afde09ca4c6e8879be87 Mon Sep 17 00:00:00 2001 From: Werner Stein Date: Wed, 18 Nov 2026 14:21:12 +0000 Subject: [PATCH 04/10] test(vision): read synthetic faces of every size 2 to 15 back as drawn The clean-face read-back now covers 8x8 to 15x15, and the lighting presets run on 8x8, 10x10, 12x12 and 15x15. At 300 px the glare preset washes four corner stickers out to white on 12x12 and 15x15; that case is listed as a known failure, like the other misread presets. Co-Authored-By: Claude Sonnet 5.5 --- test/syntheticFace.test.ts | 3 ++- test/syntheticPresets.test.ts | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/test/syntheticFace.test.ts b/test/syntheticFace.test.ts index 55e74cb5..f04f73b3 100644 --- a/test/syntheticFace.test.ts +++ b/test/syntheticFace.test.ts @@ -4,6 +4,7 @@ import { extractColorsFromImageData } from '../src/client/vision/faceDetection' import { rgbToOKLCH } from '../src/core/color/ColorMath.gen' import { NEUTRAL_GAINS } from '../src/client/vision/colorMath' import { DEFAULT_SAMPLING } from '../src/client/vision/stickerColorGeometry' +import { ALL_SIZES } from './cubeSizes' const SIZE = 480 @@ -123,7 +124,7 @@ describe('the synthetic face', () => { expect(pixels[pixels.length - 1]).toBe(255) }) - for (const n of [2, 3, 4, 5, 6, 7]) + for (const n of ALL_SIZES) it(`reads back as the same ${n}x${n} colors by the app's own detection`, () => { const colors = grid(n) expect(read(renderFace(colors, 'clean', 7, SIZE), n)).toEqual(colors) diff --git a/test/syntheticPresets.test.ts b/test/syntheticPresets.test.ts index 1479c4ef..72a79407 100644 --- a/test/syntheticPresets.test.ts +++ b/test/syntheticPresets.test.ts @@ -10,7 +10,9 @@ import { DEFAULT_SAMPLING } from '../src/client/vision/stickerColorGeometry' // failure (it.fails) until the pipeline handles it, and the test turns red // when it starts to pass, so the list cannot go stale. const SIZE = 300 -const SIZES = [2, 3, 4, 5, 7] +const SIZES = [2, 3, 4, 5, 7, 8, 10] +// At 300 px a 12x12 sticker is 25 px and a 15x15 sticker 20 px wide. +const LARGE_SIZES = [12, 15] const SEEDS = [1, 2, 3] const LETTERS = 'WYORGB' @@ -29,9 +31,9 @@ function grid(n: number, seed: number): string[][] { } // The stickers of every size and seed the detection reads wrongly. -function misreads(preset: string) { +function misreads(preset: string, sizes = SIZES) { const wrong: string[] = [] - for (const n of SIZES) + for (const n of sizes) for (const seed of SEEDS) { const colors = grid(n, seed) const read = extractColorsFromImageData( @@ -63,4 +65,17 @@ describe('synthetic presets against the face detection', () => { }, 120_000, ) + + // The same check on the largest sizes. The glare preset washes a few + // corner stickers out to white at 20 to 25 px per sticker (four misreads at + // 12x12 and 15x15); it stays a known failure until detection handles it. + const LARGE_MISREAD = new Set([...MISREAD, 'glare']) + for (const preset of PRESETS) + (LARGE_MISREAD.has(preset) ? it.fails : it)( + `reads every sticker of the ${preset} preset back as drawn on 12x12 and 15x15`, + () => { + expect(misreads(preset, LARGE_SIZES)).toEqual([]) + }, + 120_000, + ) }) From a741db855e5ebc707b4580d1bd506cb02ca73301 Mon Sep 17 00:00:00 2001 From: Werner Stein Date: Wed, 18 Nov 2026 14:26:01 +0000 Subject: [PATCH 05/10] test(fixtures): build, validate and zip synthetic fixtures of sizes 2 to 15 Each size renders a random valid cube to six JPEG faces, checks the meta against the published fixture schema, round-trips the ZIP, reads the fingerprint of every photo and reads the photos back as the cube's colors with the app's own detection. Co-Authored-By: Claude Sonnet 5.5 --- test/syntheticFixtureSizes.test.ts | 125 +++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 test/syntheticFixtureSizes.test.ts diff --git a/test/syntheticFixtureSizes.test.ts b/test/syntheticFixtureSizes.test.ts new file mode 100644 index 00000000..eb9a56af --- /dev/null +++ b/test/syntheticFixtureSizes.test.ts @@ -0,0 +1,125 @@ +import { readFileSync } from 'node:fs' +import { join } from 'node:path' +import Ajv2020 from 'ajv/dist/2020.js' +import jpeg from 'jpeg-js' +import { describe, expect, it } from 'vitest' +import { parityStatus } from '../src/client/capture/captureFlow' +import { readFixtureColors } from '../src/client/fixtures/fixtureFormat' +import { + summarizeFixture, + unzipUploadFiles, + zipFixture, +} from '../src/client/fixtures/fixtureZip' +import { readFingerprint } from '../src/client/fixtures/photoMetadata' +import { buildSyntheticFixture } from '../src/client/fixtures/syntheticFixture' +import { NEUTRAL_GAINS } from '../src/client/vision/colorMath' +import { extractColorsFromImageData } from '../src/client/vision/faceDetection' +import { DEFAULT_SAMPLING } from '../src/client/vision/stickerColorGeometry' +import { randomCube } from '../src/cube/randomState' +import { toWRGFacelets } from '../src/cube/notation/NotationOutput.gen' +import { ALL_SIZES } from './cubeSizes' + +// Synthetic fixtures of every size 2 to 15: a random valid cube is rendered +// to six JPEG faces, saved as a fixture, zipped and unzipped again, and the +// app's own detection reads the photos back as the cube's colors. +const FACES = ['u', 'r', 'f', 'd', 'l', 'b'] as const +const NOW = new Date('2026-11-18T12:00:00.000Z') +const decoder = new TextDecoder() + +const encode = (rgba: Uint8ClampedArray, size: number) => + `data:image/jpeg;base64,${Buffer.from( + jpeg.encode({ data: Buffer.from(rgba), width: size, height: size }, 92) + .data, + ).toString('base64')}` + +const validate = new Ajv2020({ allErrors: true }).compile( + JSON.parse( + readFileSync( + join(__dirname, '../public/schemas/fixture-meta-v1.schema.json'), + 'utf8', + ), + ), +) + +function build(size: number) { + const cube = randomCube(size, 40 + size) + return { + cube, + fixture: buildSyntheticFixture( + { + cube, + parity: parityStatus(cube, size), + preset: 'clean', + seed: 5, + version: '0.1.0', + commit: 'abc1234', + }, + encode, + NOW, + ), + } +} + +describe.each(ALL_SIZES)('a synthetic fixture of size %i', (size) => { + // Twelve 600 px renders and JPEG encodings: seconds on a busy machine. + const timeout = 120_000 + + it( + 'records the size and colors and validates against the published schema', + () => { + const { cube, fixture } = build(size) + const meta = JSON.parse(decoder.decode(fixture.files['meta.json'])) + expect(fixture.name).toBe(`synt-${size}x${size}-2026-11-18T12-00-00`) + expect(meta.gridSize).toBe(size) + expect(meta.colorsURFDLB).toBe(toWRGFacelets(cube)) + expect(validate(meta), JSON.stringify(validate.errors)).toBe(true) + expect(meta.tags).not.toContain('invalid-state') + const colors = readFixtureColors(meta)!.colors + for (const face of FACES) + expect(colors[face.toUpperCase()], face).toHaveLength(size) + const rows = Object.fromEntries(summarizeFixture(fixture).rows) + expect(rows['Photos from']).toMatch(/synthetic/i) + }, + timeout, + ) + + it( + 'survives a zip round trip and reads back as the cube by the app detection', + async () => { + const { fixture } = build(size) + const meta = JSON.parse(decoder.decode(fixture.files['meta.json'])) + const files = await unzipUploadFiles(await zipFixture(fixture)) + expect(files.map((f) => f.name).sort()).toEqual( + [...FACES.map((face) => `face-${face}.jpg`), 'meta.json'].sort(), + ) + const unzipped = JSON.parse( + await files.find((f) => f.name === 'meta.json')!.text(), + ) + expect(unzipped).toEqual(meta) + const colors = readFixtureColors(unzipped)!.colors + for (const face of FACES) { + const bytes = new Uint8Array( + await files.find((f) => f.name === `face-${face}.jpg`)!.arrayBuffer(), + ) + expect(JSON.parse(readFingerprint(bytes) ?? 'null')).toMatchObject({ + renderer: 'parametric/v1', + face, + size: 600, + }) + const decoded = jpeg.decode(bytes, { useTArray: true }) + const read = extractColorsFromImageData( + Uint8ClampedArray.from(decoded.data), + decoded.width, + decoded.height, + size, + NEUTRAL_GAINS, + DEFAULT_SAMPLING, + ) + expect(read.colors, `${size}x${size} face ${face}`).toEqual( + colors[face.toUpperCase()], + ) + } + }, + timeout, + ) +}) From 49c5356cc68e91b6d627e8fd00cc7d89efcf5276 Mon Sep 17 00:00:00 2001 From: Werner Stein Date: Wed, 18 Nov 2026 14:28:04 +0000 Subject: [PATCH 06/10] test(perf): budget the 15x15 steps of a capture and its 3D view Time budgets (median of three runs) for random cube, scramble, facelets, parity, Orbit64 V2 token, both meshes, photo rendering and reading, face orientation and the guided search at 15x15. The budgets are 10 to 150 times the measured medians so a loaded runner passes and a step that grows with the size faster than expected fails. Co-Authored-By: Claude Sonnet 5.5 --- test/sizePerformance.test.ts | 132 +++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 test/sizePerformance.test.ts diff --git a/test/sizePerformance.test.ts b/test/sizePerformance.test.ts new file mode 100644 index 00000000..756de9d9 --- /dev/null +++ b/test/sizePerformance.test.ts @@ -0,0 +1,132 @@ +import { describe, expect, it } from 'vitest' +import { parityStatus } from '../src/client/capture/captureFlow' +import { buildCubeMesh } from '../src/client/view3d/cubeMesh' +import { NEUTRAL_GAINS } from '../src/client/vision/colorMath' +import { extractColorsFromImageData } from '../src/client/vision/faceDetection' +import { DEFAULT_SAMPLING } from '../src/client/vision/stickerColorGeometry' +import { renderFace } from '../src/client/vision/syntheticFace' +import { + solveFaceOrientations, + solveGuidedCapture, +} from '../src/cube/cubeAssembly' +import { solvedCubeFaces, turnFace } from '../src/cube/cubeGeometry' +import { generateScrambleMoves } from '../src/cube/cubeMoves' +import { + fromURFFacelets, + fromWRGFacelets, + toURFFacelets, + toWRGFacelets, +} from '../src/cube/notation/NotationOutput.gen' +import { + decodeOrbit64V2Facelets, + encodeOrbit64V2Facelets, +} from '../src/cube/notation/orbit64V2Facelets' +import { orbit64V2Entries } from '../src/cube/notation/orbit64V2' +import { randomCube } from '../src/cube/randomState' + +// Time budgets for the largest size, 15x15x15. Each budget is 10 to 150 times +// the median measured on a busy 10-core machine (see the pull request), so a +// loaded runner does not fail the test but a step that turns quadratic or +// cubic in the size does. The steps are the ones a 15x15 capture and its 3D +// view run: building the cube, notation, parity, the token, the mesh, the +// detection of a photo and the face search. +const SIZE = 15 + +// Median of three runs, in ms. +function time(run: () => unknown): number { + const runs: number[] = [] + for (let i = 0; i < 3; i++) { + const start = performance.now() + run() + runs.push(performance.now() - start) + } + return runs.sort((a, b) => a - b)[1] +} + +const cube = randomCube(SIZE, 3) +const entry = orbit64V2Entries.find( + (e) => e.n === SIZE && e.model === 'Color' && e.pose === 'Canonical', +)! +const facelets = toURFFacelets(cube) + +describe('15x15 budgets', () => { + const budgets: Array<[string, number, () => unknown]> = [ + ['random cube', 500, () => randomCube(SIZE, 4)], + ['scramble moves', 100, () => generateScrambleMoves(SIZE)], + [ + 'WRG and URF facelets round trip', + 200, + () => { + fromWRGFacelets(toWRGFacelets(cube)) + fromURFFacelets(toURFFacelets(cube)) + }, + ], + ['full parity report', 500, () => parityStatus(cube, SIZE)], + [ + 'Orbit64 V2 token write and read', + 500, + () => { + const written = encodeOrbit64V2Facelets(entry.id, facelets) + if (written.TAG === 'Error') throw new Error(written._0) + const read = decodeOrbit64V2Facelets(written._0) + if (read.TAG === 'Error') throw new Error(read._0) + }, + ], + ['stickered mesh', 3000, () => buildCubeMesh(cube, SIZE)], + [ + 'stickerless mesh', + 3000, + () => buildCubeMesh(cube, SIZE, undefined, true), + ], + ] + for (const [name, budget, run] of budgets) + it(`${name} in under ${budget} ms`, () => { + expect(time(run)).toBeLessThan(budget) + }) + + it('reads a 600 px photo in under 3000 ms', () => { + const grid = Array.from({ length: SIZE }, (_, r) => + Array.from({ length: SIZE }, (_, c) => 'WYORGB'[(r * 2 + c * 3) % 6]), + ) + const pixels = renderFace(grid, 'clean', 1, 600) + expect(time(() => renderFace(grid, 'clean', 1, 600))).toBeLessThan(3000) + expect( + time(() => + extractColorsFromImageData( + pixels, + 600, + 600, + SIZE, + NEUTRAL_GAINS, + DEFAULT_SAMPLING, + ), + ), + ).toBeLessThan(2000) + }) + + it('orients the six faces of a scrambled cube in under 2000 ms', () => { + const faces = solvedCubeFaces(SIZE, { + U: 'W', + R: 'R', + F: 'G', + D: 'Y', + L: 'O', + B: 'B', + }) + let scrambled = faces + for (let i = 0; i < 40; i++) + scrambled = turnFace( + scrambled, + (['U', 'R', 'F', 'D', 'L', 'B'] as const)[i % 6], + 1 + (i % 3), + 1 + (i % 7), + ) + expect(time(() => solveFaceOrientations(scrambled))).toBeLessThan(2000) + // The guided search takes four side photos and two caps. + const capture = { + sides: [scrambled.F, scrambled.R, scrambled.B, scrambled.L], + caps: [scrambled.U, scrambled.D], + } as Parameters[0] + expect(time(() => solveGuidedCapture(capture))).toBeLessThan(10_000) + }, 60_000) +}) From b4e71570940e9c1c01a7d3feb0aca2044650d2f5 Mon Sep 17 00:00:00 2001 From: Werner Stein Date: Wed, 18 Nov 2026 14:36:27 +0000 Subject: [PATCH 07/10] test(capture): run the remaining size lists over 2 to 15 Grid alignment, repeated-face detection and the guided capture routing test used lists that stopped at 7x7 (2, 3, 4, 5, 7 and 2, 3, 4, 7). Co-Authored-By: Claude Sonnet 5.5 --- test/cube/guidedCapture.test.ts | 2 +- test/gridAlignment.test.ts | 3 ++- test/guidedCaptureProduction.test.ts | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/cube/guidedCapture.test.ts b/test/cube/guidedCapture.test.ts index 6cbd69af..946de547 100644 --- a/test/cube/guidedCapture.test.ts +++ b/test/cube/guidedCapture.test.ts @@ -474,7 +474,7 @@ describe('center-routed capture slots', () => { }) describe('findRepeatedFaces', () => { - for (const n of [2, 3, 4, 7]) { + for (const n of ALL_SIZES) { it(`finds a ${n}x${n} face photographed twice, even turned and (from 3x3 up) with a misread`, () => { const capture = photograph( scramble(n, 40, rng(20 + n)), diff --git a/test/gridAlignment.test.ts b/test/gridAlignment.test.ts index b1bd4a61..caae36f2 100644 --- a/test/gridAlignment.test.ts +++ b/test/gridAlignment.test.ts @@ -8,6 +8,7 @@ import { estimateTilt, findGridAlignment, } from '../src/client/vision/gridAlignment' +import { ALL_SIZES } from './cubeSizes' import { placed, scene } from './syntheticFace' describe('findGridAlignment', () => { @@ -90,7 +91,7 @@ describe('findGridAlignment', () => { }) } - for (const gridSize of [2, 3, 4, 5, 7]) { + for (const gridSize of ALL_SIZES) { it(`finds a ${gridSize}x${gridSize} face held off-center and smaller than the guide`, () => { const guideSize = 300 const width = Math.round(guideSize * 1.4) diff --git a/test/guidedCaptureProduction.test.ts b/test/guidedCaptureProduction.test.ts index a1fa419a..17efb5b4 100644 --- a/test/guidedCaptureProduction.test.ts +++ b/test/guidedCaptureProduction.test.ts @@ -32,7 +32,7 @@ const recordV2Guide = (slot: string, mirrored: boolean, retake: boolean) => { ) } const slots = ['U', 'R', 'F', 'D', 'L', 'B'] -for (const size of [3, 5, 7]) +for (const size of ODD_SIZES) for (const mirrored of [false, true]) { it(`routes all six physical ${size}×${size} shots through captureStep with mirror=${mirrored}`, () => { let initial = solvedCubeFaces(size, { From d08667b1df7ba06b9e375e66d5e1f08b2f11aa0a Mon Sep 17 00:00:00 2001 From: Werner Stein Date: Wed, 18 Nov 2026 14:40:59 +0000 Subject: [PATCH 08/10] feat(view3d): scramble sizes above 7x7 as long as their sticker count The length table ended at 7x7 (100 moves) and every larger size fell back to 20 moves. Above 7x7 the length is round(100 * n^2 / 49): 131 moves for 8x8, 459 for 15x15. The table for 2 to 7 is unchanged. The test checks the length of every size from 2 to 15 and that it grows. Co-Authored-By: Claude Sonnet 5.5 --- src/cube/CubeMoves.res | 6 +++++- test/cubeView3D.test.ts | 25 +++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/cube/CubeMoves.res b/src/cube/CubeMoves.res index 308ab07d..21efee9f 100644 --- a/src/cube/CubeMoves.res +++ b/src/cube/CubeMoves.res @@ -177,7 +177,11 @@ let scrambleScale = length => // slice fixed), and a first inner turn on 4x4 and larger. `random` returns // numbers in [0, 1). let generateScrambleMoves = (size, options: scrambleOptions, random: unit => float) => { - let base = scrambleLengths[size - 2]->Option.getOr(20) + // Above the table (7x7 = 100 moves) the length grows with the sticker count. + let base = + scrambleLengths[size - 2]->Option.getOr( + size > 7 ? Math.round(100.0 *. Int.toFloat(size * size) /. 49.0)->Float.toInt : 20, + ) let scale = scrambleScale(options.length->Option.getOr(Normal)) let length = Math.round(Int.toFloat(base) *. scale)->Float.toInt let maxDepth = options.innerLayers->Option.getOr(true) ? size / 2 : 1 diff --git a/test/cubeView3D.test.ts b/test/cubeView3D.test.ts index 9ef6bd3d..f1c20fa8 100644 --- a/test/cubeView3D.test.ts +++ b/test/cubeView3D.test.ts @@ -739,16 +739,21 @@ describe('cubeView3D math and geometry', () => { } }) - // Known gap: the length table (CubeMoves.res scrambleLengths) ends at 7x7 - // and every larger size falls back to 20 moves, fewer than a 3x3 gets. The - // test turns red once the table or a formula covers 8 to 15, so this - // marker cannot go stale. The target lengths are an owner decision. - it.fails('scrambles a size above 7 at least as long as the 7x7', () => { - for (const size of ALL_SIZES.filter((n) => n > 7)) - expect( - generateScrambleMoves(size).length, - `${size}x${size}`, - ).toBeGreaterThanOrEqual(100) + // The table covers 2 to 7 (7x7 = 100 moves); above it the length grows + // with the sticker count: round(100 * n^2 / 49). + it('gives every size its scramble length, growing as n^2 above 7x7', () => { + const table = [11, 20, 40, 60, 80, 100] + let previous = 0 + for (const size of ALL_SIZES) { + const expected = + size <= 7 ? table[size - 2] : Math.round((100 * size * size) / 49) + const length = generateScrambleMoves(size).length + expect(length, `${size}x${size}`).toBe(expected) + expect(length).toBeGreaterThan(previous) + previous = length + } + expect(generateScrambleMoves(8).length).toBe(131) + expect(generateScrambleMoves(15).length).toBe(459) }) it('builds mesh with animated turning layer rotated properly without crashing', () => { From fda7cd85b0fa578d07c163e9a62f6a59c12cf44a Mon Sep 17 00:00:00 2001 From: Werner Stein Date: Wed, 18 Nov 2026 17:05:40 +0000 Subject: [PATCH 09/10] test(properties): run the Orbit64 token property over sizes 2 to 15 The app token is the V2 codec since wstein/cube-assembler#69, so the property no longer needs the 2 to 7 generator of the removed V1 codec. Co-Authored-By: Claude Sonnet 5.5 --- test/properties/CubeProperties_test.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/properties/CubeProperties_test.res b/test/properties/CubeProperties_test.res index 482440ec..277d3700 100644 --- a/test/properties/CubeProperties_test.res +++ b/test/properties/CubeProperties_test.res @@ -114,7 +114,7 @@ describe("notation round trips", () => { "an Orbit64 token decodes to the facelets it encodes", () => Fc.check( - scrambledTo(7), + scrambled, ((n, moves, _)) => { let facelets = NotationOutput.toURFFacelets(scramble(n, moves)) switch Orbit64Token.encodeState(facelets)->Null.toOption { From 3fc038b7b1f28821ef887f61739fb4ab8c4dbf8d Mon Sep 17 00:00:00 2001 From: Werner Stein Date: Wed, 18 Nov 2026 19:22:10 +0000 Subject: [PATCH 10/10] test(perf): budget the stickered 15x15 mesh and correct the index-size note The stickered-mesh budget called the adapter with its default (stickerless), so it measured the same mesh as the stickerless line. It now passes stickerless = false (median 74 ms at 15x15, budget unchanged at 3000 ms). The index-buffer comment named 9x9 for stickered meshes; 32-bit indices start at 7x7 stickered and 9x9 stickerless. Co-Authored-By: Claude Sonnet 5.5 --- test/cubeView3D.test.ts | 3 ++- test/sizePerformance.test.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/cubeView3D.test.ts b/test/cubeView3D.test.ts index f1c20fa8..c567385d 100644 --- a/test/cubeView3D.test.ts +++ b/test/cubeView3D.test.ts @@ -894,7 +894,8 @@ describe('cubeView3D for every size from 2 to 15', () => { for (const index of mesh.indices) highest = Math.max(highest, index) expect(highest).toBeLessThan(mesh.vertexCount) // 16-bit indices hold up to 65535 vertices; larger meshes (stickered - // 9x9 and up) need 32-bit indices, which the renderer draws as such. + // 7x7 and up, stickerless 9x9 and up) need 32-bit indices, which the + // renderer draws as such. expect(mesh.indices instanceof Uint32Array).toBe( mesh.vertexCount > 65535, ) diff --git a/test/sizePerformance.test.ts b/test/sizePerformance.test.ts index 756de9d9..fbe8d8c8 100644 --- a/test/sizePerformance.test.ts +++ b/test/sizePerformance.test.ts @@ -72,7 +72,8 @@ describe('15x15 budgets', () => { if (read.TAG === 'Error') throw new Error(read._0) }, ], - ['stickered mesh', 3000, () => buildCubeMesh(cube, SIZE)], + // The adapter defaults to stickerless; the stickered mesh needs `false`. + ['stickered mesh', 3000, () => buildCubeMesh(cube, SIZE, undefined, false)], [ 'stickerless mesh', 3000,