#542 preserve _id, _time, _version, _job on Fbe.delete recreate path#545
Merged
yegor256 merged 1 commit intoJun 8, 2026
Merged
Conversation
…recreate path Strip the four system properties from the new fact's internal map after Factbase::Pre fires so the restoration loop carries the original values forward instead of the Pre-assigned ones.
|
@edmoffo Thank you for your contribution! Based on our team policy, you've earned +24 points for this code submission. This reward reflects the base points awarded for providing a review contribution. Your running score is +1851. Please keep the contributions coming and don't forget to check your Zerocracy account as well! |
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.
Issue #542 reports that
Fbe.deletereassigns the four system properties whenever the factbase is decorated byFbe.fb. The destroy-and-recreate cycle inlib/fbe/delete.rbdeleted_idfrom the snapshot up front, then routed the recreated fact through theFactbase::Preblock that assigns_id,_time,_version, and_jobon insert, and the restoration loop'snext unless c[k].nil?guard refused to overwrite the Pre-assigned values. Any external reference to the original_id, including follower facts and later(eq _id N)lookups, was left dangling.The fix strips the four system properties from the new fact's internal map after
Prefires but before the restoration loop runs, so the loop carries the original values forward.before.delete(id)is gone, so_idsurvives into the snapshot like the rest.test_deletes_safelycontinues to pass because its single-fact factbase still produces the same_idvalue, while a newtest_preserves_system_props_on_decorated_fbpins the contract against a two-fact factbase where the Pre arithmetic would otherwise drift.Verification on this branch:
bundle exec ruby -Ilib -Itest test/fbe/test_delete.rbreports 10 tests, 21 assertions, 0 failures, 0 errors, 0 skips;rubocop lib/fbe/delete.rb test/fbe/test_delete.rbreports 0 offenses. Reverting only thelib/fbe/delete.rbchange flips the new test toExpected: 1, Actual: 3, confirming it catches the bug.Closes #542