8000 fix(query): include asserted flag in selective_fact_fetch dedup key (#285) by adityamukho · Pull Request #286 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content
8000

fix(query): include asserted flag in selective_fact_fetch dedup key (#285) - #286

Merged
adityamukho merged 2 commits into
mainfrom
fix/285-selective-fact-fetch-dedup
Jun 2, 2026
Merged

adityamukho merged 2 commits into
mainfrom
fix/285-selective-fact-fetch-dedup

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Summary

  • Fixes selective_fact_fetch drops new assertion when retract+transact share tx_count in WriteTransaction #285: atomic retract + transact in a WriteTransaction returned empty results via the selective_fact_fetch path
  • Root cause: dedup key (entity, attribute, tx_count) collapsed retraction and new assertion into one entry when they shared a tx_count (all facts in a committed WriteTransaction receive the same counter value)
  • Fix: expand key to (entity, attribute, tx_count, asserted) — retraction (asserted=false) and assertion (asserted=true) are now treated as distinct facts

Changed files

  • src/query/datalog/executor.rs — two dedup HashSet key tuples updated from 3-tuple to 4-tuple; doc comment updated
  • tests/retraction_test.rs — regression test: atomic retract+transact in WriteTransaction with plain query (exercises selective_fact_fetch)

Test plan

  • New test test_write_transaction_retract_and_transact_same_attr_query_sees_new_value added and confirmed red before fix, green after
  • Full suite (cargo test) passes — 963 tests, 0 failures

🤖 Generated with Claude Code

adityamukho and others added 2 commits June 2, 2026 20:23
…285)

When a WriteTransaction commits both a retraction and a new assertion for the
same (entity, attribute) they share a tx_count, causing the previous dedup key
(entity, attribute, tx_count) to silently drop the assertion.  Adding `asserted`
to the key ensures both facts survive the dedup and net_asserted_facts can
correctly compute the final state.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
codecov Bot commented Jun 2, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit 0ee4a14 into main Jun 2, 2026
15 checks passed
@adityamukho
adityamukho deleted the fix/285-selective-fact-fetch-dedup branch June 2, 2026 15:01
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.

selective_fact_fetch drops new assertion when retract+transact share tx_count in WriteTransaction

1 participant

0