Add characterization tests for AiService turn logic - #76
Conversation
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Self-review rubric (Phase 4). CI on this head is the external anchor: run 30739697877 — Backend Build and Test pass (23s), Web Client Build and Test pass (27s).
Local anchor caveat, stated plainly: Adversarial finding (out-of-diff observation, folded in here rather than as an inline comment). Writing these tests surfaced two guards in
Both are harmless defensive code, not bugs, so per the Stage B "characterization, not change" rule I did not touch production code to remove them — flagging for a future cleanup cycle's judgment rather than filing backlog noise. Coverage limit worth naming: every test uses a square 10×10 grid, so This comment was drafted during a Gardener session (Stephenson-Software/gardener). |
Summary
Stage B cycle (unit-test expansion).
AiServiceis the whole AI opponent — threat evaluation, target selection, and garrison management for player 2 — and it had no test file at all, while every other service inbackend/src/main/java/com/barony/backend/service/does. This adds 17 characterization tests that lock in its current behavior.Coverage added, by decision path:
No production code was changed. Per the dev-loop's Stage B rule these are characterization tests only — they assert what the code does today, so they act as regression guards for future AI tuning.
Module(s) touched
backendonly. No REST endpoint, request/response shape, or player-visible behavior changed, so no web-client, README, PLAYER_GUIDE, or CHANGELOG update applies.Test plan
backend/src/test/java/com/barony/backend/service/AiServiceTest.javafollows the sibling convention (JUnit 5,<ClassName>Test.java, mirrored package, plain instantiation likeCombatServiceTest)../mvnwis unavailable in the environment this cycle ran in, so the local build is UNVERIFIED; the "CI Build and Test" workflow on this PR head is the real anchor. Both the Backend Build and Test and Web Client Build and Test jobs must pass, and the backend surefire output must showAiServiceTestactually ran.Issues
No tracking issue — this is a Stage B (unit-test expansion) cycle, not an issue fix.
Deferred this cycle: #55 (configurable, per-account dashboard layout). It is a multi-part feature spanning a new server-side per-user preferences store, authenticated backend endpoints, the web-client caller, and panel reorder/show-hide/collapse UI in
game.html/game-logic.js— comfortably past this loop's ~400 net non-test LOC / ~10 file scope ceiling for a single PR. It needs splitting into slices (e.g. client-side collapse/reorder persistence first, then server-side sync keyed to the authenticated user) before it is an implementable unit of work. PR #42 is a Copilot draft and was left untouched.This PR description was drafted during a Gardener session (Stephenson-Software/gardener).