Skip to content

test: pin OnnxEvaluator fallback contract (null, blank, missing and non-ONNX model paths) #19

Description

@rabestro

Context

OnnxEvaluator (src/main/java/com/fortemate/dicechess/bot/OnnxEvaluator.java) loads an ONNX value model and falls back to the engine heuristic JvmApi.evaluate when the model path is null, blank, missing, or not a loadable model. OnnxStrategyTest exercises the strategy through a missing model only; the fallback contract of the evaluator itself is not pinned.

The Definition-of-Done block at the top of AGENTS.md applies: run mise run format (Spotless), then mise run check, before publishing. Tests use JUnit 5 (org.junit.jupiter.api), see OnnxStrategyTest.java for style; temporary files via @TempDir.

Objective

Add src/test/java/com/fortemate/dicechess/bot/OnnxEvaluatorFallbackTest.java with:

  1. new OnnxEvaluator(null), new OnnxEvaluator(""), new OnnxEvaluator(" ") and new OnnxEvaluator("no/such/model.onnx")isLoaded() is false, no exception, and close() is safe to call.
  2. A temporary file with arbitrary non-ONNX bytes → the constructor does not throw, isLoaded() is false.
  3. For a non-loaded evaluator and the initial position parsed via the engine (JvmApi/FenParser as used elsewhere in this repository) with dice pool p, evaluate(state, 0) equals JvmApi.evaluate(state, 0) and evaluate(state, 1) equals JvmApi.evaluate(state, 1).

Definition of Done (DoD)

  • OnnxEvaluatorFallbackTest.java exists and covers the three points; existing tests unchanged; no production source modified.
  • mise run format applied; mvn -B test -Dtest=OnnxEvaluatorFallbackTest passes; mise run check passes.
  • Pull request body states which gates were run and closes this issue.

Guards

  • Do not modify OnnxEvaluator.java, OnnxStrategy.java, Main.java or models; if a test reveals a defect, describe it in the pull request instead. No new dependencies; do not load a real ONNX model.

Verification gates

mise run format
mvn -B test -Dtest=OnnxEvaluatorFallbackTest
mise run check

Non-goals

Inference with a real model, the HTTP server, the webhook handshake.

Blast radius

One new test file. Execution tier: Routine.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

julesStart this Ready issue in Google Jules; applying this label triggers execution.spec:readySpec is self-contained: gates and blast radius listedtestingAdding or enhancing automated tests

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions