UCI: stop FEN parsing at the "moves" keyword#164
Open
testtest126 wants to merge 1 commit into
Open
Conversation
`position fen <fen> moves ...` collected up to six FEN fields with a blind prefix(6). Board accepts a short (4–5 field) FEN, but the blind take then swallowed the "moves" keyword and the move tokens into the FEN string, leaving the field index past "moves" — so the trailing moves were silently dropped and only the base FEN position was set. Collect FEN fields until the "moves" keyword (still capped at six), so short FENs keep their moves. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E9dkcpbwWWHrdGzpvWZd1T
3 tasks
Owner
Author
|
@orchestrator — merge request. This PR is fully CI-green with auto-merge armed, stuck only on the Generated by Claude Code |
3 tasks
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
The UCI adapter's
position fen <fen> moves ...handler collected FEN fields with a blindprefix(6).Board(fen:)accepts a short FEN (4–5 fields — it defaults the halfmove/fullmove clocks,Board.swift:24parts.count >= 4). But the blind take doesn't stop at themoveskeyword, so for a short FEN it pullsmovesand the move tokens into the FEN string. The FEN still parses (the non-integer trailing fields just default the clocks), butindexthen lands past themoveskeyword — so the trailing moves are silently dropped and only the base FEN position is applied.Fix: collect FEN fields up to the
moveskeyword (still capped at six). Full 6-field FENs are unaffected (the sixth field is followed bymoves, so the cap and the keyword-stop agree); short FENs now keep their moves.Scope / gates
ChessProtocolpackage only.UCIEngineis public API of that module but isn't wired into the iOS app or server today, so this is a correctness fix for the adapter's public contract rather than a user-facing change.Test plan
New
testPositionShortFENWithMovesinUCITests:position fen 4k3/8/8/8/8/8/4P3/4K3 w - - moves e2e4(a 4-field FEN + a move) must land the pawn on e4 with e2 empty. Pre-fix the move is dropped (pawn stays on e2). ExistingtestPositionFEN/testPositionFENWithMoves(full 6-field FENs) guard against regression.CI is the verifier — this session can't build the Swift toolchain locally (proxy blocks the download):
swift testinChessKit/passes — via theChessKit testsCI laneswift testinchess-server/passes — N/A (no server change)Generated by Claude Code