Repository navigation
fix(chess): support long game history and export - #127
Merged
Merged
Conversation
0xferit
changed the base branch from
feature/pgn-import-preservation
to
master
September 21, 2026 13:03
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.
Long PGNs now retain their full move history through import, copying, undo, and export. Previously, the 601st ply wrote beyond the native history array, while an 800-entry move buffer also failed during SAN or HTML conversion.
Dynamic history requires value-based position copying. Reconstructing a copy from FEN while retaining its undo records lost the native history those records referred to, so undo followed by a new move could write at a negative history index. Copies now retain independent repetition history and the halfmove counter. The history length is the sole source of the current history ply; the exported legacy capacity constant remains available for source compatibility.
The import, plain/HTML export, and copy/undo regressions were observed failing under sanitizers before the fix. A separate repetition test also fails without sanitizers when copying falls back to FEN, and verifies that undoing the original leaves the copy independent. Validation covers ASan and Xcode UBSan, Release builds, and an 804-ply document read/save/reopen. Native history checks through 1,000 plies and move-generation/SAN round trips match the baseline.