Skip to content

#469: Preserve hash additions in place#491

Open
akmhatey-ai wants to merge 1 commit into
zerocracy:masterfrom
akmhatey-ai:codex/overwrite-absent-hash-469
Open

#469: Preserve hash additions in place#491
akmhatey-ai wants to merge 1 commit into
zerocracy:masterfrom
akmhatey-ai:codex/overwrite-absent-hash-469

Conversation

@akmhatey-ai

@akmhatey-ai akmhatey-ai commented May 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #469.

Fbe.overwrite already updates scalar-form absent properties on the existing fact. The hash form did not have the same absent-property path, so adding { bar: 44 } destroyed and reinserted the fact even when all requested properties were missing.

This change keeps the destroy/reinsert path for existing-property hash updates, but assigns the all-absent hash properties directly on the current fact. The regression test pins that identity-preserving behavior with Factbase::Pre.

Validation:

  • ruby -c lib/fbe/overwrite.rb -> Syntax OK
  • ruby -c test/fbe/test_overwrite.rb -> Syntax OK
  • origin/master manual repro -> PASS origin/master reproduces issue: before pos=0, after pos=1
  • candidate manual repro -> PASS hash absent property preserved pos=0, foo=42, bar=44
  • existing-property hash path repro -> PASS existing-property hash path recreated pos=1, foo=55, bar=44, keep=yes
  • git diff --check origin/master...HEAD -> no output
  • git diff origin/master...HEAD -- lib/fbe/overwrite.rb test/fbe/test_overwrite.rb | gitleaks stdin --no-banner --redact -> no leaks found
  • GitHub Actions on this PR are green: actionlint, copyrights, markdown-lint, pdd, rake on Ubuntu/macOS Ruby 3.3, reuse, typos, xcop, and yamllint.

Limitations:

  • bundle exec ruby -Itest test/fbe/test_overwrite.rb and bundle exec rubocop lib/fbe/overwrite.rb test/fbe/test_overwrite.rb were blocked in this Windows environment because Bundler was missing locked gems (rdoc 7.2.0, psych 5.3.1, parallel 2.0.1), and installing psych 5.3.1 failed due missing yaml.h / MSYS2 keyring errors.
  • non-bundled rubocop lib/fbe/overwrite.rb test/fbe/test_overwrite.rb reported one unchanged pre-existing warning at test/fbe/test_overwrite.rb:16 for Lint/RedundantCopDisableDirective.

@akmhatey-ai akmhatey-ai marked this pull request as ready for review May 26, 2026 12:44

@GHX5T-SOL GHX5T-SOL left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved current head 1f43d72.

The patch matches #469: hash-form updates where every requested key is absent now assign onto the existing fact, mirroring the scalar absent-property path, while existing-property hash updates still take the delete/reinsert path. The new Factbase::Pre regression proves the absent-property hash case keeps the original pre-inserted position, so it catches the identity-changing behavior from the report.

Validation I ran locally on Ruby 3.3.11:

  • bundle install with BUNDLE_PATH=/private/tmp/bundle-fbe-491
  • bundle exec ruby -Itest test/fbe/test_overwrite.rb -- --no-cov -> 28 tests, 57 assertions, 0 failures
  • bundle exec rubocop lib/fbe/overwrite.rb test/fbe/test_overwrite.rb -> 2 files inspected, no offenses
  • ruby -c lib/fbe/overwrite.rb and ruby -c test/fbe/test_overwrite.rb -> Syntax OK
  • bundle exec rake test -> 284 tests, 803 assertions, 0 failures, 9 skips
  • git diff --check origin/master...HEAD -> clean
  • diff-only gitleaks on lib/fbe/overwrite.rb and test/fbe/test_overwrite.rb -> clean

Hosted checks are also green, including Ubuntu/macOS rake.

@0crat

0crat commented May 27, 2026

Copy link
Copy Markdown

@GHX5T-SOL Thanks for the review! You've earned +10 points for this contribution: +18 as a basis, -8 for absolutely no comments posted during the review. Your running score is +416; don't forget to check your Zerocracy account too.

@yegor256

Copy link
Copy Markdown
Member

@akmhatey-ai merge conflict here

@yegor256

Copy link
Copy Markdown
Member

Please fix the merge conflicts so this pull request can be merged.

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.

Fbe.overwrite hash form recreates the fact when adding absent properties; scalar form sets them in place

4 participants