Prove the conversion safety invariant per failure mode - #43
Merged
Conversation
The engine already enforces it: verification is unconditional, there is no flag to skip it, and AtomicReplace runs only after it succeeds. What was missing is evidence that it holds for every way a conversion can fail. That gap matters here more than usual. An audit across four corpora found EC reporting success on files whose text had silently changed, and the lesson was not "fix that decoder" but "a safety property nothing tests is a safety property nobody knows they still have". Eight cases, each driving a different failure mode and asserting the same pair: the conversion is refused, and the source file is byte-for-byte what it was. invalid byte sequence refused, unchanged truncated multi-byte sequence refused, unchanged target cannot represent content refused, unchanged post-write verification failure refused, unchanged impossible BOM request refused, unchanged backup creation failure aborted before converting -WhatIf nothing modified at all a provably preserving conversion succeeds The pairing is the point. A refusal that still damaged the file would be worse than no refusal, and counting safe refusals means nothing unless each is verified to have left the source alone. The last case exists so the invariant cannot be satisfied by refusing everything. This is the measurable half of the reviewer's proposed fifth metric: safe refusal is a property with tests rather than a number without them. 320 tests passing. Co-Authored-By: Claude Opus 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.
The engine already enforces the invariant — verification is unconditional, there is no flag to skip it, and
AtomicReplaceruns only after it succeeds. What was missing is evidence that it holds for every way a conversion can fail.That gap matters here more than usual: the corpus audit found EC reporting success on files whose text had silently changed. The lesson wasn't "fix that decoder" — it was that a safety property nothing tests is a safety property nobody knows they still have.
Eight cases, each driving a different failure mode and asserting the same pair — refused, and the source byte-for-byte unchanged:
-WhatIfThe pairing is deliberate. A refusal that still damaged the file would be worse than no refusal, and counting "safe refusals" means nothing unless each is verified to have left the source alone. The last row exists so the invariant cannot be satisfied by refusing everything.
This is the measurable half of the reviewer's proposed fifth metric: safe refusal becomes a property with tests rather than a number without them.
320 tests passing (was 312).
🤖 Generated with Claude Code