[DO NOT MERGE] Synthetic castling bug — CI mutation test#96
Closed
ber4444 wants to merge 1 commit into
Closed
Conversation
SYNTHETIC BUG — intentional mutation to test CI's regression coverage. Drops the attack check on the king's queenside transit square (d1/d8) in getCastlingMoves. This violates FIDE castling rule (king may not pass through an attacked square), allowing two extra illegal castles in Kiwipete depth-2 (2041 vs canonical 2039). The bespoke CastlingTest does NOT cover the d-file case (gap), so it still passes. The perft oracle (PerftTest/PerftCanonicalGateTest/ PerftVsStockfishTest) catches it on castling-rich positions. Expect: CI red on :chess-core:desktopTest and :chess-core:check. Do NOT merge — revert immediately after CI verdict is captured.
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.
This PR intentionally breaks a chess rule to test whether CI catches the regression. It will be reverted immediately after the CI verdict is captured.
The bug injected
In
chess-core/.../Move.kt,getCastlingMovespreviously simulated the king's queenside transit through bothc1andd1(resp.c8/d8) to verify neither square is attacked. This PR drops thed-square check:That violates the FIDE castling rule: the king may not pass through a square that is attacked. Queenside castling is now legal even when
d1/d8is attacked.Why this particular mutation
I deliberately picked a gap in the bespoke test suite:
CastlingTest.ktdoes NOT cover this case. It tests the kingside king-path rule (f-file attacker) and theb1exception, but never places an attacker on thed-file. → These unit tests still pass with the bug.Local verification (before pushing)
CastlingTest(bespoke unit tests)PerftTest > kiwipete_depth_2expected:<2039> but was:<2041>(+2 illegal castles)PerftCanonicalGateTest > kiwipete_depth_3PerftVsStockfishTest > canonical_positions_match_stockfishWhat CI should do
check-kotlin(Linux) —:chess-core:check→:chess-core:desktopTestruns the perft rig → REDapple(macOS) —:chess-core:desktopTest --parallel→ REDIf both jobs go red on
PerftTest/PerftCanonicalGateTest, CI's regression coverage is confirmed. If any goes green, that's a real gap in the gate.Outcome
Once CI finishes, this branch will be deleted and
Move.ktrestored tomain. Do not merge.