Skip to content

UCI: stop FEN parsing at the "moves" keyword#164

Open
testtest126 wants to merge 1 commit into
mainfrom
claude/smiley-face-1xzfkz-uci-shortfen
Open

UCI: stop FEN parsing at the "moves" keyword#164
testtest126 wants to merge 1 commit into
mainfrom
claude/smiley-face-1xzfkz-uci-shortfen

Conversation

@testtest126

Copy link
Copy Markdown
Owner

Summary

The UCI adapter's position fen <fen> moves ... handler collected FEN fields with a blind prefix(6).

Board(fen:) accepts a short FEN (4–5 fields — it defaults the halfmove/fullmove clocks, Board.swift:24 parts.count >= 4). But the blind take doesn't stop at the moves keyword, so for a short FEN it pulls moves and the move tokens into the FEN string. The FEN still parses (the non-integer trailing fields just default the clocks), but index then lands past the moves keyword — so the trailing moves are silently dropped and only the base FEN position is applied.

Fix: collect FEN fields up to the moves keyword (still capped at six). Full 6-field FENs are unaffected (the sixth field is followed by moves, so the cap and the keyword-stop agree); short FENs now keep their moves.

Scope / gates

  • Security-sensitive: no — a pure input parser; no auth/token/crypto/session code.
  • App-touching: no — ChessProtocol package only. UCIEngine is 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.
  • Shared files: none.

Test plan

New testPositionShortFENWithMoves in UCITests: 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). Existing testPositionFEN / 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 test in ChessKit/ passes — via the ChessKit tests CI lane
  • swift test in chess-server/ passes — N/A (no server change)
  • App builds / relevant UI tests pass — N/A (no app change)

Generated by Claude Code

`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
@testtest126 testtest126 marked this pull request as ready for review July 12, 2026 18:21
@testtest126 testtest126 enabled auto-merge (squash) July 12, 2026 18:21

Copy link
Copy Markdown
Owner Author

@orchestrator — merge request. This PR is fully CI-green with auto-merge armed, stuck only on the orchestrator-approval status (only you can post it; nothing has merged repo-wide since ~2026-07-12 20:42 UTC). Non-security (pure UCI input parser), no shared files, review threads resolved. Batched with #161 and #177 — see the request on #161 for the full set. Requesting approval + merge.


Generated by Claude Code

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants