fix: sort rollback version files in descending timestamp order (LIFO)#1509
fix: sort rollback version files in descending timestamp order (LIFO)#1509swattamw2024 wants to merge 1 commit into
Conversation
|
Thanks for your contribution! However, this PR is linked to issue #1487, which is not assigned to you. Please refer to our contribution guidelines. PRs should only be opened by contributors who are assigned to the linked issue. |
|
👀 Human Input Needed → Pair Review Briefing |
| logger.warning( | ||
| f"File {file} does not match expected pattern of <{scenario_type or '*'}>_<timestamp>_<hash_suffix>.py" | ||
| ) | ||
| version_files.sort( |
There was a problem hiding this comment.
The intra-context LIFO this sort promises won't hold in real usage because Version.timestamp and hash_suffix at config.py:266-267 are @dataclass defaults evaluated once at class-definition time — so every Version.new_version(...) call in the same process produces an identical <scenario>_<timestamp>_<hash>.py, making the sort key constant within a context and collapsing this into a stable no-op over os.listdir order. The new test_search_returns_files_in_descending_timestamp_order only passes because it hand-crafts filenames with distinct timestamps rather than routing through Version.
Severity: medium
🤖 Was this useful? React with 👍 or 👎
|
Hi @swattamw2024! 👋 This PR has merge conflicts with To rebase your branch: git fetch upstream
git rebase upstream/main
# resolve any conflicts, then:
git add .
git rebase --continue
git push --force-with-lease
For more details, see the Rebase with upstream guide. The |
Fixes #1487
Type of change
Description
Rollback version files and context directories were being processed in arbitrary (filesystem) order. This caused rollbacks to execute in non-deterministic order instead of LIFO (newest-first), which is required for correct rollback semantics.
This fix sorts:
Related Tickets & Documents
Documentation
Checklist before requesting a review
REQUIRED:
Description of combination of tests performed and output of run
python -m unittest tests.test_rollback -v Two new test cases added: - test_search_returns_files_in_descending_timestamp_order — verifies LIFO ordering within a single context directory - test_search_returns_files_across_contexts_in_descending_order — verifies correct ordering across multiple context directories