chore(ai): reconcile development → main (brings AI-independence test)#40
Merged
Conversation
Adds a test that installs a spy on Dice.rollDie (from @nodots/backgammon-core) and verifies every shipped analyzer leaves it untouched during selectMove. Covers randomMoveAnalyzer, furthestFromOffMoveAnalyzer, nodotsAIMoveAnalyzer, examplePluginAnalyzer, and gnubgMoveAnalyzer (with @nodots/gnubg-hints mocked per the existing pluginAnalyzers.test.ts pattern). The invariant: move selection reads the legal-move set and the board but does not roll dice. An analyzer that calls Dice.rollDie during selection either (a) peeks at an upcoming opponent roll or (b) advances the RNG in a way that biases subsequent game rolls — both of which would regress the fairness story in Paper 12 (§9.1). A baseline-sanity test confirms the spy fires when Dice.rollDie is invoked directly, guarding against silent passes if the spy setup breaks. Phase 1.2 of nodots/backgammon#327. Closes nodots/backgammon#331
test(ai): assert analyzers do not consume dice entropy (Phase 1.2 of nodots/backgammon#327)
The Jest config in this package sets extensionsToTreatAsEsm: ['.ts']
and useESM: true on the ts-jest transformer, which requires Node's
--experimental-vm-modules flag for jest.unstable_mockModule and
top-level await import() to work.
Several existing tests (pluginAnalyzers.test.ts, ai-independence.test.ts,
and others that mock @nodots/gnubg-hints) rely on both patterns and
were silently failing in CI with "await is only valid in async
functions and the top level bodies of modules" because the test script
did not set the flag.
Adds NODE_OPTIONS=--experimental-vm-modules to the test, test:watch,
and test:coverage scripts. CI matrix is ubuntu-latest + macos-latest
only, so plain shell-prefix form is portable; no cross-env needed.
Verified:
npm test -- src/__tests__/pluginAnalyzers.test.ts \
src/__tests__/ai-independence.test.ts
→ 10/10 tests pass, 2/2 suites.
Nine other test suites still fail for pre-existing reasons unrelated
to this flag (CJS resolver stack overflow, import-after-teardown).
Those are separate concerns.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fast-forward `main` up to `development`. Four commits:
AI-independence test Paper 12 §3.2 references. Test-only; no runtime
behavior change, but CI enforcement is absent on main today.
No new work, just reconciling already-reviewed commits onto main.
Test plan