Repository navigation
fix(rules): a pseudo-attribute in a rule body reads the stored fact (#661) - #665
Merged
Merged
Conversation
…661) RecursiveEvaluator copied the base facts into its working storage with transact, one fact per call, so each copy got a new tx-id and tx-count, valid-from = the evaluation time and valid-to = forever, and a positive rule body's :db/valid-from, :db/valid-to, :db/tx-count and :db/tx-id read those. The base facts are now loaded as stored (load_facts), as the mixed-rule pass already did. Test counts brought up to date (1678 total, 1668 passing). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT
This was referenced Oct 20, 2026
…nts combined: 1681 total, 1671 passing) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Fixes the v3 side of #661 (data-integrity, known-issue, listed in #421). No closing keyword: #661 stays open until the v2.0.x patch with the
mainbackport ships.Cause
RecursiveEvaluator::evaluate_recursive_rulescopied the base facts into its workingFactStoragewithtransact, one fact per call: every copy got a new tx-id and tx-count, valid-from = the evaluation time and valid-to = forever. A positive rule body's:db/valid-from,:db/valid-to,:db/tx-countand:db/tx-idread those. The mixed-rule pass (StratifiedEvaluator) already matched againstload_factcopies, which keep the metadata.Fix
Load the base facts as stored (
load_facts, thenrestore_tx_counterso derived facts get later counts).Tests
tests/recursive_rules_test.rs: for each of the four pseudo-attributes, a positive rule and a recursive rule (later iterations read the base facts again) return the same rows as the pattern in a query body, on a fact with an explicit 2020–2021 valid window and two later transactions. Fails before the fix.Counts: 1,678 tests (1,668 passing, 10 ignored); the documented counts were stale (see #663, which edits the same lines; whichever merges second combines them).
CHANGELOG: Fixed entry. No docs-site change (the docs never described the wrong values).
Main backport: separate PR next.
🤖 Generated with Claude Code
https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT