8000 fix(rules): bind the query's valid time for :db/valid-at in rule definitions (#617) by adityamukho · Pull Request #619 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

fix(rules): bind the query's valid time for :db/valid-at in rule definitions (#617) - #619

Merged
adityamukho merged 1 commit into
v3from
fix/617-rule-valid-at
Oct 16, 2026
Merged

adityamukho merged 1 commit into
v3from
fix/617-rule-valid-at

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Issue #617.

Problem

StratifiedEvaluator and RecursiveEvaluator were built without the query's valid time, so inside a rule definition a :db/valid-at pattern:

  • in the rule body bound nil → INT-022 when instantiating the head;
  • in a not / not-join body bound nil → the negation never matched on it;
  • in an or branch 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; default nil keeps existing call sites unchanged). The rules query path passes the value it already computes for the top-level matcher (:valid-at value, current time without one, nil for :any-valid-time).
  • The stratified evaluator uses it for mixed-rule bodies, not bodies, not-join (replacing the Value::Null from fix(not-join): :db/valid-at binds the query's valid time on the per-row path (#615) #616) and passes it to or branches as a ValidAt; 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_slice is 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, or branch). All five fail on v3 HEAD 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

…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
codecov Bot commented Oct 16, 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 36d547a into 8000 v3 Oct 16, 2026
25 checks passed
@adityamukho
adityamukho deleted the fix/617-rule-valid-at branch October 16, 2026 11:23
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>
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.

1 participant

0