Skip to content

Refuse a contradicting source choice even when it is the target - #135

Merged
amrali-eg merged 1 commit into
masterfrom
fix/conflict-before-same-codec
Sep 28, 2026
Merged

amrali-eg merged 1 commit into
masterfrom
fix/conflict-before-same-codec

Conversation

@amrali-eg

Copy link
Copy Markdown
Owner

Problem

ConversionPolicy.Decide checked "already in the target" before the explicit-source conflict. When the chosen source was also the target, the file skipped the conflict check. Reproduced with the master build (3981e3c):

Command File Before
-From windows-1252 -Target windows-1252 UTF-8 with non-ASCII text (reliable detection) Unchanged, reported as already windows-1252, exit 0
-From utf-8 -Target utf-8 UTF-16 with a BOM Error / StrictValidationFailed, exit 3

Nothing was written in either case, but the first report is false and -FailOnChanges passes on it.

Change

  • The conflict check moves before both "already in the target" rules (same code page, and ASCII→UTF-8). Both files above are now Refused / ExplicitSourceConflictsWithDetection, exit 5.
  • A choice that agrees with detection is still Unchanged.
  • Backlog entry BL-37.

Semantics version

Stays at 8. The change only turns some Unchanged decisions into refusals. Applying a plan re-decides each file, and revalidation may tighten an approved decision but never broaden it, so a plan written by an earlier semantics-8 build is at worst refused for these files. Semantics 8 has not been released; v3.14.5 plans (semantics 7) are refused outright.

Tests

In ExplicitSourceEncodingTests:

  • Both reproductions via the CLI with -Backup and an existing .bak of known bytes: exit 5, Refused / ExplicitSourceConflictsWithDetection, source bytes unchanged, earlier .bak unchanged.
  • Control: -From utf-8 -Target utf-8 on UTF-8 stays Unchanged, exit 0, no backup.
  • Policy unit test: a conflicting choice equal to the target is refused.

Mutation check: restoring the old rule order fails the 3 conflict tests; restored byte-for-byte afterwards.

Verification

  • Release build, 0 warnings; 962/962 tests pass.
  • docs/Test-DefectBacklog.ps1 passes.
  • GUI smoke not run locally for this PR; CI runs gui-smoke. The full smoke run and the four-corpus audit will be on the final committed release candidate.

🤖 Generated with Claude Code

The policy checked "already in the target" before the explicit-source
conflict, so a chosen source that was also the target skipped the conflict
check. With the master build, -From windows-1252 -Target windows-1252 on a
UTF-8 file with non-ASCII text reported it Unchanged, already windows-1252,
exit 0; -From utf-8 -Target utf-8 on UTF-16 with a BOM ended as a
validation error, exit 3. Nothing was written in either case.

The conflict check now runs before both "already in the target" rules, so
both files are Refused / ExplicitSourceConflictsWithDetection, exit 5, and
an existing backup is left as it was. A choice that agrees with detection
is still Unchanged.

Semantics stay at 8: the change only turns some Unchanged decisions into
refusals, which revalidation of an applied plan already permits, and
semantics 8 has not been released.

Backlog: BL-37.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@amrali-eg
amrali-eg merged commit 3fdddf5 into master Sep 28, 2026
3 checks passed
@amrali-eg
amrali-eg deleted the fix/conflict-before-same-codec branch September 28, 2026 20:59
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.

1 participant