Repository navigation
fix(rules): bind the query's valid time for :db/valid-at in rule definitions (#617) - #619
Merged
Merged
Conversation
…nitions (#617) The rule evaluators were built without the query's valid time, so a :db/valid-at pattern in a rule body bound nil (INT-022 on the head), in a rule's not / not-join body bound nil, and in a rule's or branch bound the current time. StratifiedEvaluator and RecursiveEvaluator now take it via with_valid_at and use it for rule bodies, negation bodies and or branches, on the semi-naive, stratified and magic-sets paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PtCdzbJMSS1V8qEPaJ4jXz
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
adityamukho
added a commit
that referenced
this pull request
Oct 18, 2026
…nitions (#617, backport) (#621) Backport of #619 from v3. The rule evaluators were built without the query's valid time, so a :db/valid-at pattern in a rule body bound nil (INT-022 on the head), in a rule's not / not-join body bound nil, and in a rule's or branch bound the current time. StratifiedEvaluator and RecursiveEvaluator now take it via with_valid_at and use it for rule bodies, negation bodies and or branches. Claude-Session: https://claude.ai/code/session_01PtCdzbJMSS1V8qEPaJ4jXz Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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 #617.
Problem
StratifiedEvaluatorandRecursiveEvaluatorwere built without the query's valid time, so inside a rule definition a:db/valid-atpattern:nil→INT-022when instantiating the head;not/not-joinbody boundnil→ the negation never matched on it;orbranch bound the current time (apply_or_clauses(.., None, ..)) instead of the query's:valid-at.Fix
RecursiveEvaluator::with_valid_at/StratifiedEvaluator::with_valid_at(builders; defaultnilkeeps existing call sites unchanged). The rules query path passes the value it already computes for the top-level matcher (:valid-atvalue, current time without one,nilfor:any-valid-time).notbodies,not-join(replacing theValue::Nullfrom fix(not-join): :db/valid-at binds the query's valid time on the per-row path (#615) #616) and passes it toorbranches as aValidAt; the positive-rule sub-evaluator (semi-naive) uses it for its matcher. Magic-sets rewritten rules run through the same evaluator.PatternMatcher::with_valid_at;PatternMatcher::from_sliceis now test-only (its last non-test caller is gone).Tests
Five regression tests in
tests/recursive_rules_test.rs(positive body incl. bound-arg/magic-sets and no-:valid-at, recursive rule,not,not-join,orbranch). All five fail onv3HEAD and pass here. Full suite: 1554 passed, 10 ignored; clippy (CI flags, native + wasm32 browser) and fmt clean.Follows #616 (#615).
main(v2.x) is affected too; backport PR to follow after this merges. #617 stays open until the v2.x patch is published.🤖 Generated with Claude Code
https://claude.ai/code/session_01PtCdzbJMSS1V8qEPaJ4jXz