Write -Report atomically instead of truncating in place - #28
Merged
Merged
Conversation
Ported from EncodingChecker's BL-24 fix (AtomicArtifactFile). The report writer truncated its destination immediately (StreamWriter append: false), so an interrupted write left the report empty or half-written, and destroyed whatever prior report was already there. Extracts Program.WriteArtifactAtomically(path, Action<Stream>): writes a complete temporary file beside the destination (using LEN's existing LosslessFileWriter.AtomicReplace, now internal) and replaces the old one only after that write succeeds. TryWriteReportFile is now a thin wrapper supplying the CSV content. Verified: 4 new tests in AtomicReportWriteTests.cs, mirroring EC's AtomicArtifactFileTests.cs. Mutation-tested by reverting to a truncate-in-place implementation - confirmed a prior report was wiped to empty on a forced write failure, then reverted. Full suite 316/316 (312 existing + 4 new). Smoke-tested via the built exe: a prior report survives, the new one replaces it, no leftover temp file. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
AtomicArtifactFile) — found by scanning EC's closed defect ledger for gaps LEN's smaller codebase could share.StreamWriterwithappend: false), so an interrupted write left the report empty or half-written, destroying whatever prior report was already there.Program.WriteArtifactAtomically(path, Action<Stream>): writes a complete temporary file beside the destination (reusing LEN's existingLosslessFileWriter.AtomicReplace, nowinternal) and replaces the old one only after that write succeeds.TryWriteReportFileis now a thin wrapper supplying the CSV content.Test plan
AtomicReportWriteTests.cs, mirroring EC's ownAtomicArtifactFileTests.cs🤖 Generated with Claude Code