fix(ai): write chat history atomically - #2843
Open
HandSonic wants to merge 1 commit into
Open
Conversation
HandSonic
force-pushed
the
fix/ai-history-atomic-write
branch
2 times, most recently
from
August 31, 2026 04:32
783cbff to
cc5f04f
Compare
HandSonic
marked this pull request as ready for review
August 31, 2026 05:05
HandSonic
force-pushed
the
fix/ai-history-atomic-write
branch
from
August 31, 2026 05:10
cc5f04f to
d5ed154
Compare
HandSonic
force-pushed
the
fix/ai-history-atomic-write
branch
from
September 3, 2026 08:08
d5ed154 to
1e37182
Compare
HandSonic
force-pushed
the
fix/ai-history-atomic-write
branch
from
September 3, 2026 21:07
1e37182 to
23f7627
Compare
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.
Related issue
N/A - no matching issue was found.
Summary
AI session and message histories were written directly to their final JSON files. Jackson truncates a
Filetarget before serialization, so a mid-write failure destroyed the last valid history and made subsequent reads fail. This change writes to a same-directory temporary file, atomically replaces the target when supported, cleans failed temporary writes, and constrains message paths to canonical UUIDs inside the normalized history directory.Affected surfaces
Verification
Risk and compatibility
Reviewer map
AiChatHistoryServiceImpl.writeAtomicallyandAiChatHistoryAtomicWriteTest.23f7627f50e9b2745c4c53a2e83982e6354fd32e; no migration is required.Contributor declaration
AI assistance: OpenAI Codex assisted with diagnosis, implementation, deterministic tests, verification, and adversarial review.
Latest-main revalidation (2026-09-04)