8000 fix(rules): recursion through a rule with not / not-join / or (#633, backport) by adityamukho · Pull Request #636 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

fix(rules): recursion through a rule with not / not-join / or (#633, backport) - #636

Merged
adityamukho merged 1 commit into
mainfrom
fix/633-mixed-recursion-v2
Oct 19, 2026
Merged

adityamukho merged 1 commit into
mainfrom
fix/633-mixed-recursion-v2

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Backport of #635 (v3) to v2.x. Refs #633 — stays open until the v2.0.x patch ships.

Change

Same as #635, applied by hand to main's StratifiedEvaluator (its mixed-rule pass differs from v3's, so not a cherry-pick):

  • A stratum in which some rule calls a not/not-join/or/or-join rule of the same stratum repeats (positive fixpoint, then mixed rules) until the mixed pass derives nothing new. Other strata run once, as before.
  • The mixed pass skips heads already in the store.
  • INT-020 bounds: passes by max_iterations, new mixed facts per pass by max_derived_facts, every fact the rules derive by max_results (matches the documented "in total" meaning since v2.0.5; before, it was per stratum and positive rules only).

Tests

Same tests as #635 (3 integration in tests/not_join_test.rs, 4 evaluator unit tests). One difference: the or test's or reads ?x (bound by an entity pattern) instead of binding ?z, because on v2.x an or branch compares a keyword and a ref exactly — case (1) of v3's #546 CHANGELOG entry, not part of this fix. All three integration tests fail without the fix.

1307 tests (1298 passing, 9 ignored). Docs: CHANGELOG (Unreleased), CLAUDE.md, README, TEST_COVERAGE.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PtCdzbJMSS1V8qEPaJ4jXz

Backport of #635 from v3. StratifiedEvaluator ran each rule with
not/not-join/or/or-join once per stratum, after the positive rules'
fixpoint, so recursion through such a rule stopped after one step. A
stratum whose rules call one of its mixed predicates now repeats until
the mixed pass derives nothing new; the mixed pass skips heads already
in the store; max_iterations, max_derived_facts and max_results bound
the loop (INT-020), with max_results counting every derived fact.

The or test reads a variable an entity pattern binds: on v2.x an or
branch compares a keyword and a ref exactly (changed on v3 by #546).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PtCdzbJMSS1V8qEPaJ4jXz
@codecov
codecov Bot commented Oct 19, 2026
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.54229% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/query/datalog/evaluator.rs 91.54% 17 Missing ⚠️

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit 92aa82a into main Oct 19, 2026
22 checks passed
@adityamukho
adityamukho deleted the fix/633-mixed-recursion-v2 branch October 19, 2026 21:11
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