fix(config): deterministic and transactional state->config migration#205
Open
juzigu40-ui wants to merge 1 commit intopeteromallet:mainfrom
Open
fix(config): deterministic and transactional state->config migration#205juzigu40-ui wants to merge 1 commit intopeteromallet:mainfrom
juzigu40-ui wants to merge 1 commit intopeteromallet:mainfrom
Conversation
Author
|
@peteromallet Added two regression tests that capture the practical impact discussed in #204:
This keeps migration recoverable under write failure and deterministic across environments. |
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
This PR hardens legacy
state -> configbootstrap migration indesloppify/base/config.pyto remove two reliability hazards present in snapshot6eb2065:config.jsonpersistence failsWhat changed
_state_files_for_migration().state-*.jsonprocessed in stable lexical orderstate.jsonprocessed after scoped filesconfig.json; only after successful write, stripconfigfrom source state files_migrate_single_state_file()to be non-destructive (merge-only)Why this matters
Before this patch, migration could rewrite source state files before destination durability was guaranteed. On write failure (permissions, transient I/O, full disk), original embedded config could be lost while
config.jsonwas still missing. This patch prevents that failure mode.It also stabilizes scalar precedence so equivalent inputs do not produce environment-dependent outcomes from filesystem iteration order.
Tests
Added regression tests in
desloppify/tests/core/test_config.py:test_scalar_merge_order_is_deterministictest_save_failure_does_not_strip_source_state_configLocal verification
uv run python -m pytest -q desloppify/tests/core/test_config.pyuv run python -m ruff check desloppify/base/config.py desloppify/tests/core/test_config.py