Define a non-lossy semantic round-trip contract#595
Draft
claell wants to merge 4 commits into
Draft
Conversation
* Format failed blocks with BibtexFormat.parsing_failed_comment.\n* Preserve the documented source-line placeholder.
* Write retained raw failures unchanged by default. * Offer explicit annotate and fail-closed policies. * Document why normal mutable blocks cannot safely use stale raw source.
* Recognize an existing annotation attached to the next failed block. * Avoid adding a second terminal newline to retained raw source. * Keep repeated opt-in annotation writes idempotent.
* Preserve meaningful blocks, order, comments, fields, values, and failures. * Permit documented layout normalization without semantic drift. * Exercise edited-record serialization without bypassing the parsed model.
This was referenced Jul 16, 2026
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
Closes #594.
Dependency and commit structure
The first three commits are the exact failed-block behavior from PR #589, which is required for retained failures to survive without generated annotation blocks. The semantic contract is the final test-only commit. Once #589 merges, this branch should be rebased so reviewers see only the contract diff.
The default macro-linkage and enclosure-style proposals in PRs #591 and #593 are intentionally independent. This contract does not bundle those product decisions.
Validation
pytest -p no:cacheprovider -W error tests/test_roundtrip_contract.py: 6 passed.tests/test_entrypoint.py.Review note
This is deliberately not a byte-identity promise. The writer remains canonical and may normalize documented layout. The protected invariant is that all modeled bibliography meaning survives in order, including retained failed raw source, and that edits serialize through the actual model and writer.
AI assistance
This pull request was prepared with ChatGPT Codex using GPT-5.6 Sol with high reasoning effort. Codex assisted with contract design, dependency reduction, fixture adaptation, and validation. Automated validation is not a substitute for maintainer review.